ai-helper-agent 2.6.2 → 2.6.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/dist/assets/{agent-store-xMTBHsla.js → agent-store-DR_A4rFm.js} +1 -1
- package/dist/assets/background.js +1 -1
- package/dist/assets/{chat-export-Co9I1mr6.js → chat-export-pxivPZ1I.js} +1 -1
- package/dist/assets/content.js +4 -4
- package/dist/{dist/assets/i18n-D19lS40q.js → assets/i18n-DkFO10iz.js} +4 -4
- package/dist/{dist/assets/markdown-render-73aUwmjo.js → assets/markdown-render-BG-l7OC_.js} +3 -3
- package/dist/assets/{model-profiles-CNilkaQS.js → model-profiles-CWaNLvr9.js} +1 -1
- package/dist/{dist/assets/options-o37xKbep.css → assets/options-Bah2BHqG.css} +1 -1
- package/dist/assets/options.js +89 -89
- package/dist/assets/{page-snapshot-renderer-PbM4zRTp.js → page-snapshot-renderer-CxdcddId.js} +1 -1
- package/dist/assets/{session-store-C5M7aiQR.js → session-store-CgGSFTQs.js} +3 -3
- package/dist/assets/side_panel.css +1 -1
- package/dist/assets/side_panel.js +159 -152
- package/dist/assets/{utils-DNJJTC8N.js → utils-D0eYGnHb.js} +1 -1
- package/dist/assets/{version-a-Z0n4U9.js → version-1U0wZbLN.js} +1 -1
- package/dist/assets/{workspace-manager-CovVLj3v.js → workspace-manager-BtQbbwPc.js} +1 -1
- package/dist/manifest.json +1 -1
- package/dist/offscreen/offscreen.js +6 -6
- package/dist/options.html +8 -6
- package/dist/side_panel.html +8 -8
- package/package.json +1 -1
- package/src/directory-picker.js +23 -3
- package/src/locales/en.json +0 -1
- package/src/locales/zh.json +0 -1
- package/src/server.js +7 -7
- package/dist/assets/i18n-D19lS40q.js +0 -49
- package/dist/assets/markdown-render-DLqO_8KG.js +0 -63
- package/dist/assets/options-o37xKbep.css +0 -1
- package/dist/dist/_locales/en/messages.json +0 -11
- package/dist/dist/_locales/zh_CN/messages.json +0 -11
- package/dist/dist/assets/__vite-browser-external-CM3Eme-n.js +0 -1
- package/dist/dist/assets/agent-store-xMTBHsla.js +0 -1
- package/dist/dist/assets/background.js +0 -452
- package/dist/dist/assets/chat-export-Bm0oW0MA.js +0 -37
- package/dist/dist/assets/chunk-CMxvf4Kt.js +0 -1
- package/dist/dist/assets/content.js +0 -985
- package/dist/dist/assets/dist-BUuoW_84.js +0 -24
- package/dist/dist/assets/dist-DuuG_8Br.js +0 -133
- package/dist/dist/assets/jszip.min-DO6SOhXU.js +0 -2
- package/dist/dist/assets/lib-YwkWjNcC.js +0 -220
- package/dist/dist/assets/marked.min.js-D2rXgLAQ.js +0 -56
- package/dist/dist/assets/marked.min.js-loader-tKH5SQVQ.js +0 -13
- package/dist/dist/assets/model-profiles-CNilkaQS.js +0 -24
- package/dist/dist/assets/network-scope-CNRYXk74.js +0 -1
- package/dist/dist/assets/options.js +0 -859
- package/dist/dist/assets/page-snapshot-renderer-PbM4zRTp.js +0 -3
- package/dist/dist/assets/pdf-DnVqBaAN.js +0 -6
- package/dist/dist/assets/session-store-C5M7aiQR.js +0 -81
- package/dist/dist/assets/side_panel.css +0 -1
- package/dist/dist/assets/side_panel.js +0 -2599
- package/dist/dist/assets/theme-BRAX5X2F.css +0 -1
- package/dist/dist/assets/theme-CLwYsx9o.js +0 -1
- package/dist/dist/assets/utils-DNJJTC8N.js +0 -112
- package/dist/dist/assets/version-CIqrX-s2.js +0 -1
- package/dist/dist/assets/voice-shortcut-Dtt3nhkz.js +0 -1
- package/dist/dist/assets/workspace-manager-CovVLj3v.js +0 -1
- package/dist/dist/assets/xlsx-DGkz7cnk.js +0 -105
- package/dist/dist/icons/README.md +0 -11
- package/dist/dist/icons/design-philosophy.md +0 -41
- package/dist/dist/icons/icon128.png +0 -0
- package/dist/dist/icons/icon128.svg +0 -68
- package/dist/dist/icons/icon16.png +0 -0
- package/dist/dist/icons/icon16.svg +0 -32
- package/dist/dist/icons/icon48.png +0 -0
- package/dist/dist/icons/icon48.svg +0 -56
- package/dist/dist/libs/github-markdown-light.min.css +0 -8
- package/dist/dist/libs/html2canvas.min.js +0 -20
- package/dist/dist/libs/jspdf.min.js +0 -398
- package/dist/dist/libs/marked.min.js +0 -69
- package/dist/dist/libs/mermaid.min.js +0 -2024
- package/dist/dist/libs/pdf.worker.min.js +0 -22
- package/dist/dist/libs/qrcode.min.js +0 -7
- package/dist/dist/manifest.json +0 -94
- package/dist/dist/offscreen/offscreen.html +0 -11
- package/dist/dist/offscreen/offscreen.js +0 -49
- package/dist/dist/options.html +0 -1143
- package/dist/dist/service-worker-loader.js +0 -1
- package/dist/dist/side_panel.html +0 -1366
- package/dist/dist/styles/styles.css +0 -262
- package/dist/dist/voice-capture-worklet.js +0 -47
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/agent-store-
|
|
2
|
-
import{o as e,r as t}from"./chunk-CMxvf4Kt.js";import{a as n,c as r,i,l as a,n as o,r as s,s as c}from"./i18n-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/agent-store-DR_A4rFm.js","assets/chunk-CMxvf4Kt.js","assets/session-store-CgGSFTQs.js","assets/model-profiles-CWaNLvr9.js","assets/i18n-DkFO10iz.js","assets/pdf-DnVqBaAN.js","assets/__vite-browser-external-CM3Eme-n.js","assets/lib-YwkWjNcC.js","assets/jszip.min-DO6SOhXU.js","assets/dist-DuuG_8Br.js","assets/chat-export-pxivPZ1I.js","assets/dist-BUuoW_84.js","assets/markdown-render-BG-l7OC_.js","assets/version-1U0wZbLN.js","assets/utils-D0eYGnHb.js","assets/workspace-manager-BtQbbwPc.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e,r as t}from"./chunk-CMxvf4Kt.js";import{a as n,c as r,i,l as a,n as o,r as s,s as c}from"./i18n-DkFO10iz.js";import{A as l,C as u,E as d,F as f,G as p,I as m,N as h,P as g,R as _,S as v,T as y,W as b,b as x,c as S,d as C,i as w,k as T,r as E,u as D,w as O,y as k,z as A}from"./model-profiles-CWaNLvr9.js";import{A as j,C as ee,Ct as te,D as ne,E as re,F as ie,I as ae,L as oe,N as se,O as M,P as ce,Q as le,R as ue,S as de,St as fe,T as pe,X as me,Y as he,_ as N,_t as ge,a as _e,b as ve,c as ye,ct as be,d as xe,dt as Se,et as Ce,f as we,g as Te,h as Ee,i as De,it as Oe,k as ke,kt as Ae,l as je,mt as Me,n as Ne,o as Pe,p as Fe,rt as Ie,s as Le,st as Re,t as ze,u as Be,v as Ve,w as He,wt as Ue,x as We,xt as Ge,y as Ke,z as qe}from"./session-store-CgGSFTQs.js";import{a as Je,n as Ye,r as Xe,t as Ze}from"./voice-shortcut-Dtt3nhkz.js";import{d as Qe,f as $e,i as et,n as tt,p as nt,t as rt,u as it}from"./version-1U0wZbLN.js";import{a as at,c as ot,i as st,n as ct,o as lt,r as ut,s as dt}from"./agent-store-DR_A4rFm.js";import{C as P,S as ft,T as pt,_ as mt,a as ht,b as gt,c as F,d as _t,f as vt,g as yt,h as bt,i as xt,l as St,m as Ct,n as wt,o as Tt,p as I,r as Et,s as L,t as Dt,u as Ot,v as kt,w as At,x as jt,y as Mt}from"./utils-D0eYGnHb.js";import{a as Nt,c as Pt,d as Ft,f as It,g as Lt,h as Rt,i as zt,l as Bt,m as Vt,n as Ht,o as Ut,p as Wt,r as Gt,s as Kt,t as qt,u as Jt}from"./markdown-render-BG-l7OC_.js";import{C as Yt,E as Xt,O as Zt,S as Qt,T as $t,_ as en,a as tn,b as nn,c as rn,d as an,f as on,g as sn,h as cn,i as ln,l as un,m as dn,n as fn,o as pn,p as mn,r as hn,s as gn,t as _n,u as vn,v as yn,w as bn,x as xn,y as Sn}from"./workspace-manager-BtQbbwPc.js";var Cn=ke.map(e=>e.id),wn=[...new Set([...p,`mcp`,`knowledge`])],Tn=[{labelKey:`presetMode.preciseLabel`,tipKey:`presetMode.preciseTip`,temp:.2,topP:1},{labelKey:`presetMode.generalLabel`,tipKey:`presetMode.generalTip`,temp:.45,topP:.9},{labelKey:`presetMode.divergentLabel`,tipKey:`presetMode.divergentTip`,temp:.65,topP:.9},{labelKey:`presetMode.creativeLabel`,tipKey:`presetMode.creativeTip`,temp:.9,topP:.9}];n(`zh`,{contextUsage:{compactionInjection:`[上下文摘要|压缩了{count}条历史]`}}),n(`en`,{contextUsage:{compactionInjection:`[Context Summary | {count} messages compacted]`}});var En=2e3,Dn=.7,On=1e3;function kn(e,{isolateChat:t=!0,maxMemoryMessages:n=null,compaction:r=null,historyBudget:i=1/0,currentMessage:a=null}={}){let o=a||{role:`user`,content:``};if(!t)return{messages:[o],keptHistory:[],compactionApplied:!1,trimmedCount:0,historySummaryText:null};let s=Array.isArray(e)?e:[],c=!1,u=-1;r&&r.summary&&r.upToMessageId&&(u=s.findIndex(e=>e.messageId===r.upToMessageId),c=u>=0);let f=s,p=s.map((e,t)=>t);n&&n>0&&s.length>n&&(f=s.slice(s.length-n),p=p.slice(s.length-n));let m=[];for(let e=0;e<f.length;e++)c&&p[e]<=u||m.push(f[e]);let h=[],g=y([o]);for(let e=m.length-1;e>=0;e--){let t=m[e],n=y([{...t,content:_(t.content)}]);if(g+n<=i)h.unshift(t),g+=n;else break}let v=null,b=m.length-h.length;if(b>0){let e=l(m.slice(0,b));e&&(v=d(e)>On?e.substring(0,On*4)+`
|
|
3
3
|
...[历史摘要已截断]`:e)}return{messages:[...h,o],keptHistory:h,compactionApplied:c,trimmedCount:b,historySummaryText:v}}function An(e,t){return!t||!t.summary?e:`${e}\n\n${r(`contextUsage.compactionInjection`,{count:t.compressedCount||0})}\n${t.summary}`}function jn(e,t,n,r){return t?.compactionApplied&&n?.summary?e[0]={...e[0],content:An(e[0].content,n)}:n?.summary&&r?.warn(`[SidePanel] contextCompaction invalid (upToMessageId not found), ignored this send`),e}function Mn({model:e,customModelMap:t=null,systemPromptText:n=``,toolCount:r=0,history:i=[],inputText:a=``,maxMemoryMessages:o=null,compaction:s=null,isolateChat:c=!0,userConfiguredWindow:l=0}={}){let f=h(e,l,t),p=f-d(n)-v-En,m=Math.floor(Math.max(p,0)*Dn),g={role:`user`,content:a},_=c?s:null,b=kn(i,{isolateChat:c,maxMemoryMessages:o,compaction:_,historyBudget:m,currentMessage:g}),x=d(b.compactionApplied?An(n,_):n),S=r*200,C=y(b.keptHistory),w=a&&a.trim()?y([g]):0,T=x+S+C+w,E=u(T,f);return{usedTokens:T,contextWindow:f,ratio:f>0?T/f:0,level:E.level,breakdown:{system:x,tools:S,history:C,input:w,outputReserve:v,safetyMargin:En,selectedCount:b.keptHistory.length,totalCount:i.length,trimmedCount:b.trimmedCount,compactionApplied:b.compactionApplied,compactionInvalid:!!(_&&_.summary&&!b.compactionApplied),historyBudget:m}}}function Nn(e,{maxMemoryMessages:t=null,compaction:n=null}={}){let r=kn(e,{isolateChat:!0,maxMemoryMessages:t,compaction:n,historyBudget:1/0,currentMessage:null}),i=[],a=!!(r.compactionApplied&&n?.summary);a&&i.push({role:`user`,content:`【已有摘要】\n${n.summary}`});for(let e of r.keptHistory){let t=_(e.content);i.push({role:e.role,content:typeof t==`string`?t:JSON.stringify(t??``)||``})}return{material:i,includedCount:r.keptHistory.length,hasOldSummary:a}}function Pn(e){if(!e||!e.trim()||e.trim()==`/`)return;let t=e.trim(),n=N.inputHistory.indexOf(t);n!==-1&&N.inputHistory.splice(n,1),N.inputHistory.push(t),N.inputHistory.length>20&&N.inputHistory.shift(),Fn()}function Fn(){try{chrome.storage.local.set({inputHistory:N.inputHistory}),a.debug(`[SidePanel] input history saved,count:`,N.inputHistory.length)}catch(e){a.error(`[SidePanel] saveinput history failed:`,e)}}var In=[`workspace`,`bookmark`,`toc`,`search`,`schedule`],Ln=`.workspace-panel.expanded, .bookmark-panel.expanded, .message-toc-panel.expanded, .search-panel.expanded, .schedule-panel.open`,Rn=null,zn=null;function Bn(){if(Rn)return Rn;Rn=document.createElement(`div`),Rn.className=`side-rail`,Rn.id=`sideRail`,Rn.innerHTML=In.map(e=>`<div class="side-rail-slot" data-slot="${e}"></div>`).join(``),document.body.appendChild(Rn),Hn();let e=document.getElementById(`chatContainer`);return e&&typeof ResizeObserver<`u`&&new ResizeObserver(Hn).observe(e),window.addEventListener(`resize`,Hn),Rn}function Vn(e){return(Rn||Bn()).querySelector(`.side-rail-slot[data-slot="${e}"]`)}function Hn(){if(!Rn)return;let e=document.getElementById(`chatContainer`);if(!e)return;let t=e.getBoundingClientRect(),n=window.innerHeight;Rn.style.top=`${Math.max(0,Math.round(t.top))}px`,Rn.style.bottom=`${Math.max(0,Math.round(n-t.bottom))}px`,Un()}function Un(){zn&&clearTimeout(zn),zn=setTimeout(()=>{zn=null,document.querySelectorAll(Ln).forEach(xt)},120)}n(`zh`,{messageToc:{toggleTitle:`显示目录(H{count}个标题)`,title:`目录`,headingCount:`{count} 个`}}),n(`en`,{messageToc:{toggleTitle:`Show table of contents (H{count} headings)`,title:`Contents`,headingCount:`{count}`}});function Wn(){document.addEventListener(`mouseover`,Gn,!0),document.addEventListener(`mouseout`,Kn,!0),a.debug(`[SidePanel] messagedirectory featureinitializing`)}function Gn(e){if(!(e.target instanceof Element))return;if(e.target.closest(`.message-toc-container`)){N.isMouseOverToc=!0;return}let t=e.target.closest(`.message.assistant`),n=e.target.closest(`.workspace-preview-markdown`);if(!t&&!n)return;let r=t||n,i=r.querySelectorAll(`.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6`);if(i.length===0){Jn();return}qn(r,i)}function Kn(e){if(!(e.target instanceof Element))return;if(e.target.closest(`.message-toc-container`)){N.isMouseOverToc=!1,N.tocHideTimer&&=(clearTimeout(N.tocHideTimer),null);return}let t=e.target.closest(`.message.assistant`),n=e.target.closest(`.workspace-preview-markdown`);if(!t&&!n)return;let r=e.relatedTarget;r&&(r.closest(`.message-toc-container`)||r.closest(`.message.assistant`)||r.closest(`.workspace-preview-markdown`))||N.isMouseOverToc||(N.tocHideTimer&&clearTimeout(N.tocHideTimer),N.tocHideTimer=setTimeout(()=>{N.isMouseOverToc||Jn(),N.tocHideTimer=null},800))}function qn(e,t){let n=Array.from(t);N.messageTocContainer&&Jn(),n.forEach((e,t)=>{e.id||=`toc-heading-${Date.now()}-${t}`});let i=document.createElement(`div`);i.className=`message-toc-container`,i.dataset.headingsCount=n.length;let a=0,o=n.map(e=>{let t=parseInt(e.tagName.charAt(1)),n=e.textContent.trim(),r=n.length>30?n.substring(0,30)+`...`:n,i=`H${t}`;return a++,`
|
|
4
4
|
<li class="message-toc-item level-${t}"
|
|
5
5
|
data-target="${e.id}"
|
|
@@ -24,7 +24,7 @@ import{o as e,r as t}from"./chunk-CMxvf4Kt.js";import{a as n,c as r,i,l as a,n a
|
|
|
24
24
|
</ul>
|
|
25
25
|
</div>
|
|
26
26
|
</div>
|
|
27
|
-
`;let s=e.closest(`.message-fullscreen-overlay`);(s&&s.querySelector(`.message-fullscreen-rail`)||Vn(`toc`)).appendChild(i),N.messageTocContainer=i;let c=i.querySelector(`.message-toc-toggle`),l=i.querySelector(`.message-toc-panel`);c.addEventListener(`mouseenter`,()=>{l.classList.add(`expanded`),xt(l)}),c.addEventListener(`click`,()=>{l.classList.toggle(`expanded`)?xt(l):gt(l)}),l.addEventListener(`mouseenter`,()=>{l.classList.add(`expanded`)}),i.querySelectorAll(`.message-toc-item`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.target,n=document.getElementById(t);n&&(n.scrollIntoView({behavior:`smooth`,block:`start`}),n.classList.add(`toc-highlight`),setTimeout(()=>{n.classList.remove(`toc-highlight`)},1500))})})}function Jn(){N.tocHideTimer&&=(clearTimeout(N.tocHideTimer),null),N.messageTocContainer&&=(N.messageTocContainer.remove(),null)}var Yn=t({INJECT_DEADLINE_MS:()=>$n,LEASE_MS:()=>Qn,MAX_DISPATCH_ATTEMPTS:()=>5,MAX_ITEMS_PER_SESSION:()=>20,MAX_RECENT:()=>30,QUEUE_STATUS:()=>R,acquireLease:()=>Kr,dropSession:()=>qr,enqueue:()=>Pr,findItem:()=>jr,getBucket:()=>Dr,getItems:()=>Tr,getQueuedCount:()=>Or,getRecent:()=>Er,init:()=>Sr,isDegraded:()=>xr,isPaused:()=>Nr,listSessionIdsWithItems:()=>Mr,markInjecting:()=>Rr,pauseSession:()=>Wr,peekNext:()=>kr,peekTailForEdit:()=>Ar,removeFromRecent:()=>Hr,removeItem:()=>Fr,reorder:()=>Ir,requeueFromRecent:()=>Vr,resumeSession:()=>Gr,rollbackInjecting:()=>zr,setStatus:()=>Lr,settle:()=>Br,subscribe:()=>wr,watchExternalChanges:()=>Cr}),Xn=`promptQueues`,Zn=1,Qn=30*1e3,$n=15*1e3,er=20,R={QUEUED:`queued`,DISPATCHING:`dispatching`,INJECTING:`injecting`,INJECTED:`injected`,DONE:`done`,FAILED:`failed`};new Set([R.INJECTED,R.DONE,R.FAILED]);var tr={async get(e){let t=await chrome.storage.local.get(e);return t?t[e]:void 0},async set(e){await chrome.storage.local.set(e)}};function nr(){return{version:Zn,sessions:{}}}var z=nr(),rr=!1,ir=null,ar=!1,or=``,sr=new Set,cr=new Set;function lr(){return{items:[],recent:[],paused:!1,pausedReason:null}}function ur(e){return e?(z.sessions[e]||(z.sessions[e]=lr()),z.sessions[e]):lr()}function dr(){return JSON.stringify(z)}function fr(e,t){for(let n of cr)try{n(e,t)}catch(e){a.error(`[QueueStore] listener failed:`,e?.message)}}function pr(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`q_`+crypto.randomUUID():`q_`+Date.now().toString(36)+`_`+Math.random().toString(36).slice(2,8)}function mr(e){return e.reduce((e,t)=>Math.max(e,Number(t.order)||0),0)+1}function hr(e,t){let n=e.indexOf(t);n<0||(e.splice(n,1),e.unshift(t),gr(e))}function gr(e){e.forEach((e,t)=>{e.order=t+1})}function _r(e){return e.slice().sort((e,t)=>(Number(e.order)||0)-(Number(t.order)||0))}async function vr(e){if(ar)return a.error(`[QueueStore] persist skipped in degraded mode:`,e),!1;let t=dr();or=t,yr(t);try{await tr.set({[Xn]:z})}catch(e){a.error(`[QueueStore] persist failed:`,e?.message)}fr(e)}function yr(e){if(sr.add(e),sr.size<=er)return;let t=sr.values().next().value;sr.delete(t)}function br(e,{recoverInterrupted:t=!0}={}){let n=nr();if(!e||typeof e!=`object`)return n;let r=e.sessions&&typeof e.sessions==`object`?e.sessions:{};for(let[e,i]of Object.entries(r)){let r=Array.isArray(i?.items)?i.items:[],a=Array.isArray(i?.recent)?i.recent.slice(0,30):[],o=!1;for(let e of r)!e||typeof e!=`object`||t&&(e.status===R.DISPATCHING||e.status===R.INJECTING)&&(e.status=R.QUEUED,e.interrupted=!0,e.previousStatus=e.previousStatus||R.DISPATCHING,e.leaseOwner=null,e.leaseUntil=0,o=!0);let s=_r(r);if(o){let e=s.filter(e=>e.interrupted),t=s.filter(e=>!e.interrupted);s.splice(0,s.length,...e,...t)}gr(s);let c=s.slice(0,20),l=s.slice(20);for(let e of l.reverse())a.unshift(Ur({...e,status:R.FAILED,lastError:`over_limit`}));n.sessions[e]={items:c,recent:a.slice(0,30),paused:i?.paused===!0,pausedReason:i?.pausedReason||null}}return n}function xr(){return ar}async function Sr(){return rr?z:ir||(ir=(async()=>{let e;try{e=await tr.get(Xn)}catch(e){return ar=!0,ir=null,a.error(`[QueueStore] load failed, enter degraded mode:`,e?.message),z}return z=br(e),rr=!0,ar=!1,or=dr(),z})(),ir)}function Cr(){typeof chrome>`u`||!chrome.storage?.onChanged?.addListener||chrome.storage.onChanged.addListener((e,t)=>{if(t!==`local`||!e?.[Xn])return;let n=e[Xn].newValue;if(!n)return;let r=JSON.stringify(n);sr.has(r)||r===or||(z=br(n,{recoverInterrupted:!1}),rr=!0,or=r,fr(`external`,null))})}function wr(e){return typeof e==`function`?(cr.add(e),()=>cr.delete(e)):()=>{}}function Tr(e){let t=z.sessions[e];return t?_r(t.items):[]}function Er(e,t=30){let n=z.sessions[e];return n?n.recent.slice(0,t):[]}function Dr(e){let t=z.sessions[e];return t?{items:_r(t.items),recent:t.recent.slice(),paused:t.paused===!0,pausedReason:t.pausedReason||null}:lr()}function Or(e){return Tr(e).filter(e=>e.status===R.QUEUED).length}function kr(e){return Tr(e).find(e=>e.status===R.QUEUED)||null}function Ar(e){let t=z.sessions[e];if(!t)return null;for(let e=t.items.length-1;e>=0;--e)if(t.items[e].status===R.QUEUED)return t.items[e];return null}function jr(e,t){let n=z.sessions[e];return n&&n.items.find(e=>e.id===t)||null}function Mr(){return Object.keys(z.sessions).filter(e=>(z.sessions[e]?.items?.length||0)>0)}function Nr(e){return z.sessions[e]?.paused===!0}async function Pr({sessionId:e,text:t,contextSnapshot:n=null,hasContext:r=!1,attachmentSummary:i=null,source:a=`manual`}){if(!e)return{ok:!1,error:`missing_session`};let o=String(t||``).trim();if(!o)return{ok:!1,error:`empty`};if(await Sr(),ar)return{ok:!1,error:`storage_unavailable`};let s=ur(e);if(s.items.length>=20)return{ok:!1,error:`queue_full`,limit:20};let c={id:pr(),sessionId:e,text:o,contextSnapshot:n||null,attachmentSummary:i||null,hasContext:r===!0,status:R.QUEUED,order:mr(s.items),createdAt:Date.now(),updatedAt:Date.now(),attempts:0,lastError:null,source:a,interrupted:!1,leaseOwner:null,leaseUntil:0,injectRequestedAt:0,injectDeadlineAt:0,injectedIntoCallId:null,absorbedIteration:null};return s.items.push(c),await vr(`enqueue`),{ok:!0,item:c,position:s.items.length}}async function Fr(e,t){let n=z.sessions[e];if(!n)return!1;let r=n.items.findIndex(e=>e.id===t);return r<0?!1:(n.items.splice(r,1),gr(n.items),await vr(`remove`),!0)}async function Ir(e,t){let n=z.sessions[e];if(!n||!Array.isArray(t))return!1;let r=new Map(n.items.map(e=>[e.id,e])),i=[];for(let e of t){let t=r.get(e);t&&!i.includes(t)&&i.push(t)}for(let e of _r(n.items))i.includes(e)||i.push(e);return n.items=i,gr(n.items),await vr(`reorder`),!0}async function Lr(e,t,n,r={}){let i=jr(e,t);return i?(i.status=n,Object.assign(i,r,{updatedAt:Date.now()}),await vr(`status`),!0):!1}async function Rr(e,t,n=$n){let r=jr(e,t);return r?(r.previousStatus=r.status,r.status=R.INJECTING,r.injectRequestedAt=Date.now(),r.injectDeadlineAt=Date.now()+n,r.updatedAt=Date.now(),await vr(`inject:request`),!0):!1}async function zr(e,t,n=`error`,r=null){let i=z.sessions[e];if(!i)return!1;let a=i.items.find(e=>e.id===t);return a?(a.status=R.QUEUED,a.injectDeadlineAt=0,a.updatedAt=Date.now(),a.lastError=r||n,a.rollbackReason=n,hr(i.items,a),await vr(`inject:rollback`),!0):!1}async function Br(e,t,{status:n,note:r=null,callId:i=null,iteration:a=null}={}){let o=z.sessions[e];if(!o)return!1;let s=o.items.findIndex(e=>e.id===t);if(s<0)return!1;let[c]=o.items.splice(s,1);return gr(o.items),c.status=n||R.DONE,c.settledAt=Date.now(),c.settleNote=r,i&&(c.injectedIntoCallId=i),a!=null&&(c.absorbedIteration=a),o.recent.unshift(Ur(c)),o.recent=o.recent.slice(0,30),await vr(`settle`),!0}async function Vr(e,t){let n=z.sessions[e];if(!n)return{ok:!1,error:`missing_session`};let r=n.recent.findIndex(e=>e.id===t);if(r<0)return{ok:!1,error:`not_found`};if(n.items.length>=20)return{ok:!1,error:`queue_full`,limit:20};let[i]=n.recent.splice(r,1),a={...i,status:R.QUEUED,order:mr(n.items),attempts:0,lastError:null,interrupted:!1,rollbackReason:null,settledAt:null,leaseOwner:null,leaseUntil:0,injectDeadlineAt:0,updatedAt:Date.now()};return n.items.push(a),await vr(`requeue`),{ok:!0,item:a}}async function Hr(e,t){let n=z.sessions[e];if(!n)return!1;let r=n.recent.findIndex(e=>e.id===t);return r<0?!1:(n.recent.splice(r,1),await vr(`recent-remove`),!0)}function Ur(e){let{leaseOwner:t,leaseUntil:n,injectDeadlineAt:r,contextSnapshot:i,...a}=e;return{...a,hasContext:e.hasContext===!0,contextDropped:!!i}}async function Wr(e,t=`user_stopped`){let n=ur(e);return n.paused?!1:(n.paused=!0,n.pausedReason=t,await vr(`pause`),!0)}async function Gr(e){let t=z.sessions[e];return!t||!t.paused?!1:(t.paused=!1,t.pausedReason=null,await vr(`resume`),!0)}async function Kr(e,t,n){let r=jr(e,t);if(!r)return!1;let i=Date.now();return r.leaseOwner&&r.leaseOwner!==n&&Number(r.leaseUntil)>i?!1:(r.leaseOwner=n,r.leaseUntil=i+Qn,await vr(`lease`),!0)}async function qr(e){let t=z.sessions[e];if(!t)return 0;let n=t.items.length+t.recent.length;return delete z.sessions[e],n>0&&await vr(`drop-session`),n}var Jr=`ai-helper-queue-attachments`,Yr=1,Xr=`attachments`,Zr=null,Qr=null;function $r(){return new Promise((e,t)=>{let n=indexedDB.open(Jr,Yr);n.onupgradeneeded=e=>{let t=e.target.result;t.objectStoreNames.contains(Xr)||t.createObjectStore(Xr,{keyPath:`id`}).createIndex(`sessionId`,`sessionId`,{unique:!1})},n.onsuccess=t=>{let n=t.target.result;n.onversionchange=()=>{try{n.close()}catch{}Zr=null},e(n)},n.onerror=()=>t(n.error||Error(`idb_open_failed`)),n.onblocked=()=>{}})}function ei(){return Zr||=$r(),Zr}function ti(e,t){return ei().then(n=>new Promise((r,i)=>{let a;try{a=n.transaction(Xr,e)}catch(e){Zr=null,i(e);return}let o=a.objectStore(Xr),s=null,c=e=>{s=e};try{t(o,c)}catch(e){i(e);return}a.oncomplete=()=>r(s),a.onerror=()=>i(a.error||Error(`idb_tx_failed`)),a.onabort=()=>i(a.error||Error(`idb_tx_aborted`))}))}function ni(){return{async put(e){await ti(`readwrite`,t=>{t.put(e)})},async get(e){return ti(`readonly`,(t,n)=>{let r=t.get(e);r.onsuccess=()=>n(r.result||null)})},async remove(e){await ti(`readwrite`,t=>{t.delete(e)})},async removeBySession(e){await ti(`readwrite`,t=>{let n=t.index(`sessionId`).getAllKeys(e);n.onsuccess=()=>{for(let e of n.result||[])t.delete(e)}})},async allKeys(){return ti(`readonly`,(e,t)=>{let n=e.getAllKeys();n.onsuccess=()=>t(n.result||[])})}}}function ri(){return Qr||ni()}function ii(e){return e==null?0:typeof e==`string`?e.length:typeof e==`number`||typeof e==`boolean`?8:Array.isArray(e)?e.reduce((e,t)=>e+ii(t),0):typeof e==`object`?Object.values(e).reduce((e,t)=>e+ii(t),0):0}function ai(e){let t=e&&e.attachedImages||[],n=e&&e.attachedFiles||[];return!t.length&&!n.length?null:{imageCount:t.length,fileCount:n.length,fileNames:n.map(e=>e.name).filter(Boolean).slice(0,5)}}async function oi(e,t,{images:n=[],files:r=[]}={}){if(!e)return{ok:!1,reason:`missing_id`};if(!n.length&&!r.length)return{ok:!0,skipped:!0};let i=ii(n)+ii(r);if(i>26214400)return{ok:!1,reason:`too_large`,size:i};try{return await ri().put({id:e,sessionId:t||null,size:i,images:n,files:r,updatedAt:Date.now()}),{ok:!0,size:i}}catch(e){return{ok:!1,reason:`idb_error`,message:e?.message||String(e)}}}async function si(e){if(!e)return null;try{let t=await ri().get(e);return t?{images:t.images||[],files:t.files||[]}:null}catch{return null}}async function ci(e){if(!e)return!1;try{return await ri().remove(e),!0}catch{return!1}}async function li(e){if(!e)return!1;try{return await ri().removeBySession(e),!0}catch{return!1}}async function ui(e){let t=e instanceof Set?e:new Set(e||[]);try{let e=await ri().allKeys(),n=0;for(let r of e||[])t.has(r)||(await ri().remove(r),n+=1);return n}catch{return 0}}var di=`completedSessionIds`;async function fi(){try{let e=(await chrome.storage.local.get([di]))[di]||[];N.completedSessionIds=new Set(e)}catch(e){a.warn(`[SessionManager] restore completedSessionIds failed:`,e)}}async function pi(){try{await chrome.storage.local.set({[di]:Array.from(N.completedSessionIds)})}catch(e){a.warn(`[SessionManager] persist completedSessionIds failed:`,e)}}async function mi(e){e&&e!==N.activeSessionId&&(N.completedSessionIds.has(e)||(N.completedSessionIds.add(e),await pi(),document.dispatchEvent(new CustomEvent(`generating-state-changed`))))}async function hi(e){e&&N.completedSessionIds.has(e)&&(N.completedSessionIds.delete(e),await pi(),document.dispatchEvent(new CustomEvent(`generating-state-changed`)))}async function gi(){return je()}async function _i(){return Fe()}function vi(e){return Le(e)}async function yi(e,t){return Be(e,t)}async function bi(){return De()}async function xi(e){return Te(e)}async function Si(e){await qr(e)>0&&li(e);let t=await _e(e);return N.completedSessionIds.has(e)&&(N.completedSessionIds.delete(e),await pi()),t}async function Ci(e,t){return xe(e,t)}async function wi(e){return we(e)}async function Ti(){return Ne()}async function Ei(e){return ye(e)}async function Di(e,t){return ze(e,t)}async function Oi(e,t=null){return Pe(e,t)}n(`zh`,{toolPanel:{agentRestrictedBanner:`当前 Agent 限制了可用工具,部分工具已禁用`,noMatch:`没有匹配的工具`,enabledCount:`已启用 {enabled}/{total} 个工具`,toolsEnabled:`工具已启用`,allToolsDisabled:`所有工具已禁用`,toggleBtnEnabled:`禁用所有工具`,toggleBtnDisabled:`启用所有工具`,mcpServiceToolCount:`{count} 个工具`,mcpServiceExpand:`展开/收起工具列表`,mcpExcludedByAgent:`已被当前助手排除,可在助手编辑中调整`,categorySelectAllHint:`对该分类下可见项全选/取消全选`,stateOn:`已开启`,stateOff:`已关闭`,stateLine:`{name}:{state}`}}),n(`en`,{toolPanel:{agentRestrictedBanner:`Current agent has restricted available tools, some tools are disabled`,noMatch:`No matching tools`,enabledCount:`{enabled}/{total} tools enabled`,toolsEnabled:`Tools enabled`,allToolsDisabled:`All tools disabled`,toggleBtnEnabled:`Disable all tools`,toggleBtnDisabled:`Enable all tools`,mcpServiceToolCount:`{count} tools`,mcpServiceExpand:`Show/hide tool list`,mcpExcludedByAgent:`Excluded by current assistant; adjust in assistant editor`,categorySelectAllHint:`Select/deselect all visible items in this category`,stateOn:`On`,stateOff:`Off`,stateLine:`{name}: {state}`}});var ki=[],Ai=[];function ji(e){if(!e)return``;let t=`tool.${e.id}`,n=r(t);return n===t?e.description||``:n}function Mi(e){if(!e)return``;let t=e.description||``;if(t.startsWith(`[MCP:`)){let e=t.indexOf(`]`);e!==-1&&(t=t.slice(e+1).trim())}return t===(e.name||``)?``:t}async function Ni(){try{let e=await chrome.runtime.sendMessage({type:`GET_MCP_TOOLS`});if(e?.success&&e.tools)return ki=e.tools,ki}catch{}try{return ki=(await chrome.storage.local.get([`mcpTools`])).mcpTools||[],ki}catch{return ki=[],[]}}async function Pi(){try{Ai=(await chrome.storage.local.get([`ragTools`])).ragTools||[]}catch{Ai=[]}return Ai}async function Fi(){let e=`agentMcpClosedServers_${N.activeAgentId||`default`}`;try{N.mcpClosedServers=(await chrome.storage.local.get([e]))[e]||[]}catch{N.mcpClosedServers=[]}try{let{getAgent:e}=await M(async()=>{let{getAgent:e}=await import(`./agent-store-xMTBHsla.js`).then(e=>e.t);return{getAgent:e}},__vite__mapDeps([0,1,2,3,4])),t=N.activeAgentId?await e(N.activeAgentId):null;N.activeAgentMcpExcludedServerIds=t?t.mcpExcludedServerIds??null:null}catch{}}var Ii=!1,Li=!0;chrome.storage.local.get([`enableToolPreselect`,`toolConfirmationEnabled`],e=>{Ii=e.enableToolPreselect===!0,Li=e.toolConfirmationEnabled!==!1,la()}),chrome.storage.onChanged.addListener((e,t)=>{if(t!==`local`)return;let n=!1;e.mcpTools&&(ki=e.mcpTools.newValue||[],a.debug(`[SidePanel] MCP toolcache updated:`,ki.length,``),n=!0),e.ragTools&&(Ai=e.ragTools.newValue||[],a.debug(`[SidePanel] RAG toolcache updated:`,Ai.length),n=!0),e.mcpEnabled&&(Ri=e.mcpEnabled.newValue===!0,a.debug(`[SidePanel] MCP globaltoggle changed:`,Ri),n=!0),e.skillsEnabled&&(zi=e.skillsEnabled.newValue!==!1,a.debug(`[SidePanel] Skill global toggle changed:`,zi),n=!0),e.enableImageInput&&(Bi=e.enableImageInput.newValue===!0,a.debug(`[SidePanel] 图片识别全局开关变更:`,Bi),n=!0);let r=!1;e.enableToolPreselect&&(Ii=e.enableToolPreselect.newValue===!0,r=!0),e.toolConfirmationEnabled&&(Li=e.toolConfirmationEnabled.newValue!==!1,r=!0),r&&la(),n&&(document.getElementById(`toolsPopupOverlay`)?.classList.contains(`show`)&&(ia(),aa(),Xi()),ca())}),Ni().then(()=>ca()),Pi().then(()=>ca());var Ri=!1,zi=!0,Bi=!1;chrome.storage.local.get([`mcpEnabled`,`skillsEnabled`,`enableImageInput`],e=>{Ri=e.mcpEnabled===!0,zi=e.skillsEnabled!==!1,Bi=e.enableImageInput===!0,ca()});function Vi(){let e=[...b,...Ai],t=N.activeAgentToolIds,n=e;if(t!=null){let r=new Set(t);n=e.filter(e=>r.has(e.id))}return zi||(n=n.filter(e=>e.id!==`agent_skill`)),N.agentPlatform?.connected!==!0&&(n=n.filter(e=>!e.id.startsWith(`agent_`)&&!e.id.startsWith(`knowledge_`))),Bi||(n=n.filter(e=>e.id!==`read_image`)),n}function Hi(){if(!Ri||N.agentPlatform?.connected!==!0)return[];let e=new Map;return ki.forEach(t=>{let n=t.serverId||`unknown`;e.has(n)||e.set(n,{serverId:n,serverName:t.serverName||n,tools:[],toolCount:0});let r=e.get(n);r.tools.push(t),r.toolCount++}),Array.from(e.values())}function Ui(e){return Array.isArray(N.mcpClosedServers)&&N.mcpClosedServers.includes(e)}function Wi(e){return Array.isArray(N.activeAgentMcpExcludedServerIds)&&N.activeAgentMcpExcludedServerIds.includes(e)}function Gi(e){return!Ui(e)&&!Wi(e)}function Ki(){if(N.currentCategory!==`all`&&N.currentCategory!==`mcp`)return[];let e=Hi();if(N.currentSearch){let t=N.currentSearch;e=e.filter(e=>(e.serverName||``).toLowerCase().includes(t)||(e.serverId||``).toLowerCase().includes(t)||e.tools.some(e=>(e.name||``).toLowerCase().includes(t)||ji(e).toLowerCase().includes(t)))}return e}function qi(e,t){Array.isArray(N.mcpClosedServers)||(N.mcpClosedServers=[]);let n=N.mcpClosedServers.indexOf(e);t?n>-1&&N.mcpClosedServers.splice(n,1):n===-1&&N.mcpClosedServers.push(e)}async function Ji(){let e=document.getElementById(`toolsPopupOverlay`);if(!e)return;N.currentCategory=`all`,N.currentSearch=``;let t=document.getElementById(`toolsSearchInput`);t&&(t.value=``),await Ni(),await Pi(),await Fi(),ia(),aa(),chrome.storage.local.get([`enableToolPreselect`,`toolConfirmationEnabled`],e=>{let t=document.getElementById(`toolsPreselectToggle`);t&&(t.checked=e.enableToolPreselect===void 0?!1:e.enableToolPreselect);let n=document.getElementById(`toolConfirmToggle`);n&&(n.checked=e.toolConfirmationEnabled===void 0?!0:e.toolConfirmationEnabled)}),document.querySelectorAll(`.category-btn`).forEach(e=>{e.classList.remove(`active`),e.classList.contains(`category-all`)?(e.classList.add(`active`),e.style.background=`linear-gradient(135deg, var(--brand-500) 0%, var(--brand-accent) 100%)`,e.style.color=`var(--text-on-brand)`,e.style.borderColor=`transparent`):(e.style.background=`var(--bg-surface)`,e.style.color=`var(--text-secondary)`,e.style.borderColor=`var(--border-subtle)`)}),Xi(),e.classList.add(`show`),a.debug(`[SidePanel] opentool popup`)}function Yi(){let e=document.getElementById(`toolsPopupOverlay`);e&&(document.querySelectorAll(`.category-btn`).forEach(e=>{e.classList.remove(`active`),e.style.background=``,e.style.color=``,e.style.borderColor=``}),e.classList.remove(`show`),a.debug(`[SidePanel] closetool popup`))}function Xi(){let e=document.getElementById(`toolsPopupList`);if(!e)return;e.innerHTML=``;let t=Vi();if(N.activeAgentToolIds!==null&&N.activeAgentToolIds!==void 0){let t=document.createElement(`div`);t.className=`popup-tool-agent-banner`,t.innerHTML=`<span>${r(`toolPanel.agentRestrictedBanner`)}</span>`,e.appendChild(t)}let n={};t.forEach(e=>{if(N.currentCategory!==`all`&&e.category!==N.currentCategory)return;if(N.currentSearch){let t=e.name.toLowerCase().includes(N.currentSearch),n=ji(e).toLowerCase().includes(N.currentSearch);if(!t&&!n)return}let t=e.category||`other`;n[t]||(n[t]=[]),n[t].push(e)});let i=Ki();if(wn.forEach(a=>{let o=a===`mcp`,s=n[a]||[],c=o?i:[];if(o?c.length===0:s.length===0)return;let l;if(o)l=`${c.filter(e=>Gi(e.serverId)).length}/${c.length}`;else{let e=t.filter(e=>e.category===a);l=`${e.filter(e=>N.enabledTools.includes(e.id)).length}/${e.length}`}let u=document.createElement(`div`);u.className=`popup-tool-category-group`,u.dataset.category=a;let d=document.createElement(`div`);d.className=`popup-tool-category`,d.dataset.category=a;let f=N.collapsedCategories[a]||!1;d.innerHTML=`
|
|
27
|
+
`;let s=e.closest(`.message-fullscreen-overlay`);(s&&s.querySelector(`.message-fullscreen-rail`)||Vn(`toc`)).appendChild(i),N.messageTocContainer=i;let c=i.querySelector(`.message-toc-toggle`),l=i.querySelector(`.message-toc-panel`);c.addEventListener(`mouseenter`,()=>{l.classList.add(`expanded`),xt(l)}),c.addEventListener(`click`,()=>{l.classList.toggle(`expanded`)?xt(l):gt(l)}),l.addEventListener(`mouseenter`,()=>{l.classList.add(`expanded`)}),i.querySelectorAll(`.message-toc-item`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.target,n=document.getElementById(t);n&&(n.scrollIntoView({behavior:`smooth`,block:`start`}),n.classList.add(`toc-highlight`),setTimeout(()=>{n.classList.remove(`toc-highlight`)},1500))})})}function Jn(){N.tocHideTimer&&=(clearTimeout(N.tocHideTimer),null),N.messageTocContainer&&=(N.messageTocContainer.remove(),null)}var Yn=t({INJECT_DEADLINE_MS:()=>$n,LEASE_MS:()=>Qn,MAX_DISPATCH_ATTEMPTS:()=>5,MAX_ITEMS_PER_SESSION:()=>20,MAX_RECENT:()=>30,QUEUE_STATUS:()=>R,acquireLease:()=>Kr,dropSession:()=>qr,enqueue:()=>Pr,findItem:()=>jr,getBucket:()=>Dr,getItems:()=>Tr,getQueuedCount:()=>Or,getRecent:()=>Er,init:()=>Sr,isDegraded:()=>xr,isPaused:()=>Nr,listSessionIdsWithItems:()=>Mr,markInjecting:()=>Rr,pauseSession:()=>Wr,peekNext:()=>kr,peekTailForEdit:()=>Ar,removeFromRecent:()=>Hr,removeItem:()=>Fr,reorder:()=>Ir,requeueFromRecent:()=>Vr,resumeSession:()=>Gr,rollbackInjecting:()=>zr,setStatus:()=>Lr,settle:()=>Br,subscribe:()=>wr,watchExternalChanges:()=>Cr}),Xn=`promptQueues`,Zn=1,Qn=30*1e3,$n=15*1e3,er=20,R={QUEUED:`queued`,DISPATCHING:`dispatching`,INJECTING:`injecting`,INJECTED:`injected`,DONE:`done`,FAILED:`failed`};new Set([R.INJECTED,R.DONE,R.FAILED]);var tr={async get(e){let t=await chrome.storage.local.get(e);return t?t[e]:void 0},async set(e){await chrome.storage.local.set(e)}};function nr(){return{version:Zn,sessions:{}}}var z=nr(),rr=!1,ir=null,ar=!1,or=``,sr=new Set,cr=new Set;function lr(){return{items:[],recent:[],paused:!1,pausedReason:null}}function ur(e){return e?(z.sessions[e]||(z.sessions[e]=lr()),z.sessions[e]):lr()}function dr(){return JSON.stringify(z)}function fr(e,t){for(let n of cr)try{n(e,t)}catch(e){a.error(`[QueueStore] listener failed:`,e?.message)}}function pr(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`q_`+crypto.randomUUID():`q_`+Date.now().toString(36)+`_`+Math.random().toString(36).slice(2,8)}function mr(e){return e.reduce((e,t)=>Math.max(e,Number(t.order)||0),0)+1}function hr(e,t){let n=e.indexOf(t);n<0||(e.splice(n,1),e.unshift(t),gr(e))}function gr(e){e.forEach((e,t)=>{e.order=t+1})}function _r(e){return e.slice().sort((e,t)=>(Number(e.order)||0)-(Number(t.order)||0))}async function vr(e){if(ar)return a.error(`[QueueStore] persist skipped in degraded mode:`,e),!1;let t=dr();or=t,yr(t);try{await tr.set({[Xn]:z})}catch(e){a.error(`[QueueStore] persist failed:`,e?.message)}fr(e)}function yr(e){if(sr.add(e),sr.size<=er)return;let t=sr.values().next().value;sr.delete(t)}function br(e,{recoverInterrupted:t=!0}={}){let n=nr();if(!e||typeof e!=`object`)return n;let r=e.sessions&&typeof e.sessions==`object`?e.sessions:{};for(let[e,i]of Object.entries(r)){let r=Array.isArray(i?.items)?i.items:[],a=Array.isArray(i?.recent)?i.recent.slice(0,30):[],o=!1;for(let e of r)!e||typeof e!=`object`||t&&(e.status===R.DISPATCHING||e.status===R.INJECTING)&&(e.status=R.QUEUED,e.interrupted=!0,e.previousStatus=e.previousStatus||R.DISPATCHING,e.leaseOwner=null,e.leaseUntil=0,o=!0);let s=_r(r);if(o){let e=s.filter(e=>e.interrupted),t=s.filter(e=>!e.interrupted);s.splice(0,s.length,...e,...t)}gr(s);let c=s.slice(0,20),l=s.slice(20);for(let e of l.reverse())a.unshift(Ur({...e,status:R.FAILED,lastError:`over_limit`}));n.sessions[e]={items:c,recent:a.slice(0,30),paused:i?.paused===!0,pausedReason:i?.pausedReason||null}}return n}function xr(){return ar}async function Sr(){return rr?z:ir||(ir=(async()=>{let e;try{e=await tr.get(Xn)}catch(e){return ar=!0,ir=null,a.error(`[QueueStore] load failed, enter degraded mode:`,e?.message),z}return z=br(e),rr=!0,ar=!1,or=dr(),z})(),ir)}function Cr(){typeof chrome>`u`||!chrome.storage?.onChanged?.addListener||chrome.storage.onChanged.addListener((e,t)=>{if(t!==`local`||!e?.[Xn])return;let n=e[Xn].newValue;if(!n)return;let r=JSON.stringify(n);sr.has(r)||r===or||(z=br(n,{recoverInterrupted:!1}),rr=!0,or=r,fr(`external`,null))})}function wr(e){return typeof e==`function`?(cr.add(e),()=>cr.delete(e)):()=>{}}function Tr(e){let t=z.sessions[e];return t?_r(t.items):[]}function Er(e,t=30){let n=z.sessions[e];return n?n.recent.slice(0,t):[]}function Dr(e){let t=z.sessions[e];return t?{items:_r(t.items),recent:t.recent.slice(),paused:t.paused===!0,pausedReason:t.pausedReason||null}:lr()}function Or(e){return Tr(e).filter(e=>e.status===R.QUEUED).length}function kr(e){return Tr(e).find(e=>e.status===R.QUEUED)||null}function Ar(e){let t=z.sessions[e];if(!t)return null;for(let e=t.items.length-1;e>=0;--e)if(t.items[e].status===R.QUEUED)return t.items[e];return null}function jr(e,t){let n=z.sessions[e];return n&&n.items.find(e=>e.id===t)||null}function Mr(){return Object.keys(z.sessions).filter(e=>(z.sessions[e]?.items?.length||0)>0)}function Nr(e){return z.sessions[e]?.paused===!0}async function Pr({sessionId:e,text:t,contextSnapshot:n=null,hasContext:r=!1,attachmentSummary:i=null,source:a=`manual`}){if(!e)return{ok:!1,error:`missing_session`};let o=String(t||``).trim();if(!o)return{ok:!1,error:`empty`};if(await Sr(),ar)return{ok:!1,error:`storage_unavailable`};let s=ur(e);if(s.items.length>=20)return{ok:!1,error:`queue_full`,limit:20};let c={id:pr(),sessionId:e,text:o,contextSnapshot:n||null,attachmentSummary:i||null,hasContext:r===!0,status:R.QUEUED,order:mr(s.items),createdAt:Date.now(),updatedAt:Date.now(),attempts:0,lastError:null,source:a,interrupted:!1,leaseOwner:null,leaseUntil:0,injectRequestedAt:0,injectDeadlineAt:0,injectedIntoCallId:null,absorbedIteration:null};return s.items.push(c),await vr(`enqueue`),{ok:!0,item:c,position:s.items.length}}async function Fr(e,t){let n=z.sessions[e];if(!n)return!1;let r=n.items.findIndex(e=>e.id===t);return r<0?!1:(n.items.splice(r,1),gr(n.items),await vr(`remove`),!0)}async function Ir(e,t){let n=z.sessions[e];if(!n||!Array.isArray(t))return!1;let r=new Map(n.items.map(e=>[e.id,e])),i=[];for(let e of t){let t=r.get(e);t&&!i.includes(t)&&i.push(t)}for(let e of _r(n.items))i.includes(e)||i.push(e);return n.items=i,gr(n.items),await vr(`reorder`),!0}async function Lr(e,t,n,r={}){let i=jr(e,t);return i?(i.status=n,Object.assign(i,r,{updatedAt:Date.now()}),await vr(`status`),!0):!1}async function Rr(e,t,n=$n){let r=jr(e,t);return r?(r.previousStatus=r.status,r.status=R.INJECTING,r.injectRequestedAt=Date.now(),r.injectDeadlineAt=Date.now()+n,r.updatedAt=Date.now(),await vr(`inject:request`),!0):!1}async function zr(e,t,n=`error`,r=null){let i=z.sessions[e];if(!i)return!1;let a=i.items.find(e=>e.id===t);return a?(a.status=R.QUEUED,a.injectDeadlineAt=0,a.updatedAt=Date.now(),a.lastError=r||n,a.rollbackReason=n,hr(i.items,a),await vr(`inject:rollback`),!0):!1}async function Br(e,t,{status:n,note:r=null,callId:i=null,iteration:a=null}={}){let o=z.sessions[e];if(!o)return!1;let s=o.items.findIndex(e=>e.id===t);if(s<0)return!1;let[c]=o.items.splice(s,1);return gr(o.items),c.status=n||R.DONE,c.settledAt=Date.now(),c.settleNote=r,i&&(c.injectedIntoCallId=i),a!=null&&(c.absorbedIteration=a),o.recent.unshift(Ur(c)),o.recent=o.recent.slice(0,30),await vr(`settle`),!0}async function Vr(e,t){let n=z.sessions[e];if(!n)return{ok:!1,error:`missing_session`};let r=n.recent.findIndex(e=>e.id===t);if(r<0)return{ok:!1,error:`not_found`};if(n.items.length>=20)return{ok:!1,error:`queue_full`,limit:20};let[i]=n.recent.splice(r,1),a={...i,status:R.QUEUED,order:mr(n.items),attempts:0,lastError:null,interrupted:!1,rollbackReason:null,settledAt:null,leaseOwner:null,leaseUntil:0,injectDeadlineAt:0,updatedAt:Date.now()};return n.items.push(a),await vr(`requeue`),{ok:!0,item:a}}async function Hr(e,t){let n=z.sessions[e];if(!n)return!1;let r=n.recent.findIndex(e=>e.id===t);return r<0?!1:(n.recent.splice(r,1),await vr(`recent-remove`),!0)}function Ur(e){let{leaseOwner:t,leaseUntil:n,injectDeadlineAt:r,contextSnapshot:i,...a}=e;return{...a,hasContext:e.hasContext===!0,contextDropped:!!i}}async function Wr(e,t=`user_stopped`){let n=ur(e);return n.paused?!1:(n.paused=!0,n.pausedReason=t,await vr(`pause`),!0)}async function Gr(e){let t=z.sessions[e];return!t||!t.paused?!1:(t.paused=!1,t.pausedReason=null,await vr(`resume`),!0)}async function Kr(e,t,n){let r=jr(e,t);if(!r)return!1;let i=Date.now();return r.leaseOwner&&r.leaseOwner!==n&&Number(r.leaseUntil)>i?!1:(r.leaseOwner=n,r.leaseUntil=i+Qn,await vr(`lease`),!0)}async function qr(e){let t=z.sessions[e];if(!t)return 0;let n=t.items.length+t.recent.length;return delete z.sessions[e],n>0&&await vr(`drop-session`),n}var Jr=`ai-helper-queue-attachments`,Yr=1,Xr=`attachments`,Zr=null,Qr=null;function $r(){return new Promise((e,t)=>{let n=indexedDB.open(Jr,Yr);n.onupgradeneeded=e=>{let t=e.target.result;t.objectStoreNames.contains(Xr)||t.createObjectStore(Xr,{keyPath:`id`}).createIndex(`sessionId`,`sessionId`,{unique:!1})},n.onsuccess=t=>{let n=t.target.result;n.onversionchange=()=>{try{n.close()}catch{}Zr=null},e(n)},n.onerror=()=>t(n.error||Error(`idb_open_failed`)),n.onblocked=()=>{}})}function ei(){return Zr||=$r(),Zr}function ti(e,t){return ei().then(n=>new Promise((r,i)=>{let a;try{a=n.transaction(Xr,e)}catch(e){Zr=null,i(e);return}let o=a.objectStore(Xr),s=null,c=e=>{s=e};try{t(o,c)}catch(e){i(e);return}a.oncomplete=()=>r(s),a.onerror=()=>i(a.error||Error(`idb_tx_failed`)),a.onabort=()=>i(a.error||Error(`idb_tx_aborted`))}))}function ni(){return{async put(e){await ti(`readwrite`,t=>{t.put(e)})},async get(e){return ti(`readonly`,(t,n)=>{let r=t.get(e);r.onsuccess=()=>n(r.result||null)})},async remove(e){await ti(`readwrite`,t=>{t.delete(e)})},async removeBySession(e){await ti(`readwrite`,t=>{let n=t.index(`sessionId`).getAllKeys(e);n.onsuccess=()=>{for(let e of n.result||[])t.delete(e)}})},async allKeys(){return ti(`readonly`,(e,t)=>{let n=e.getAllKeys();n.onsuccess=()=>t(n.result||[])})}}}function ri(){return Qr||ni()}function ii(e){return e==null?0:typeof e==`string`?e.length:typeof e==`number`||typeof e==`boolean`?8:Array.isArray(e)?e.reduce((e,t)=>e+ii(t),0):typeof e==`object`?Object.values(e).reduce((e,t)=>e+ii(t),0):0}function ai(e){let t=e&&e.attachedImages||[],n=e&&e.attachedFiles||[];return!t.length&&!n.length?null:{imageCount:t.length,fileCount:n.length,fileNames:n.map(e=>e.name).filter(Boolean).slice(0,5)}}async function oi(e,t,{images:n=[],files:r=[]}={}){if(!e)return{ok:!1,reason:`missing_id`};if(!n.length&&!r.length)return{ok:!0,skipped:!0};let i=ii(n)+ii(r);if(i>26214400)return{ok:!1,reason:`too_large`,size:i};try{return await ri().put({id:e,sessionId:t||null,size:i,images:n,files:r,updatedAt:Date.now()}),{ok:!0,size:i}}catch(e){return{ok:!1,reason:`idb_error`,message:e?.message||String(e)}}}async function si(e){if(!e)return null;try{let t=await ri().get(e);return t?{images:t.images||[],files:t.files||[]}:null}catch{return null}}async function ci(e){if(!e)return!1;try{return await ri().remove(e),!0}catch{return!1}}async function li(e){if(!e)return!1;try{return await ri().removeBySession(e),!0}catch{return!1}}async function ui(e){let t=e instanceof Set?e:new Set(e||[]);try{let e=await ri().allKeys(),n=0;for(let r of e||[])t.has(r)||(await ri().remove(r),n+=1);return n}catch{return 0}}var di=`completedSessionIds`;async function fi(){try{let e=(await chrome.storage.local.get([di]))[di]||[];N.completedSessionIds=new Set(e)}catch(e){a.warn(`[SessionManager] restore completedSessionIds failed:`,e)}}async function pi(){try{await chrome.storage.local.set({[di]:Array.from(N.completedSessionIds)})}catch(e){a.warn(`[SessionManager] persist completedSessionIds failed:`,e)}}async function mi(e){e&&e!==N.activeSessionId&&(N.completedSessionIds.has(e)||(N.completedSessionIds.add(e),await pi(),document.dispatchEvent(new CustomEvent(`generating-state-changed`))))}async function hi(e){e&&N.completedSessionIds.has(e)&&(N.completedSessionIds.delete(e),await pi(),document.dispatchEvent(new CustomEvent(`generating-state-changed`)))}async function gi(){return je()}async function _i(){return Fe()}function vi(e){return Le(e)}async function yi(e,t){return Be(e,t)}async function bi(){return De()}async function xi(e){return Te(e)}async function Si(e){await qr(e)>0&&li(e);let t=await _e(e);return N.completedSessionIds.has(e)&&(N.completedSessionIds.delete(e),await pi()),t}async function Ci(e,t){return xe(e,t)}async function wi(e){return we(e)}async function Ti(){return Ne()}async function Ei(e){return ye(e)}async function Di(e,t){return ze(e,t)}async function Oi(e,t=null){return Pe(e,t)}n(`zh`,{toolPanel:{agentRestrictedBanner:`当前 Agent 限制了可用工具,部分工具已禁用`,noMatch:`没有匹配的工具`,enabledCount:`已启用 {enabled}/{total} 个工具`,toolsEnabled:`工具已启用`,allToolsDisabled:`所有工具已禁用`,toggleBtnEnabled:`禁用所有工具`,toggleBtnDisabled:`启用所有工具`,mcpServiceToolCount:`{count} 个工具`,mcpServiceExpand:`展开/收起工具列表`,mcpExcludedByAgent:`已被当前助手排除,可在助手编辑中调整`,categorySelectAllHint:`对该分类下可见项全选/取消全选`,stateOn:`已开启`,stateOff:`已关闭`,stateLine:`{name}:{state}`}}),n(`en`,{toolPanel:{agentRestrictedBanner:`Current agent has restricted available tools, some tools are disabled`,noMatch:`No matching tools`,enabledCount:`{enabled}/{total} tools enabled`,toolsEnabled:`Tools enabled`,allToolsDisabled:`All tools disabled`,toggleBtnEnabled:`Disable all tools`,toggleBtnDisabled:`Enable all tools`,mcpServiceToolCount:`{count} tools`,mcpServiceExpand:`Show/hide tool list`,mcpExcludedByAgent:`Excluded by current assistant; adjust in assistant editor`,categorySelectAllHint:`Select/deselect all visible items in this category`,stateOn:`On`,stateOff:`Off`,stateLine:`{name}: {state}`}});var ki=[],Ai=[];function ji(e){if(!e)return``;let t=`tool.${e.id}`,n=r(t);return n===t?e.description||``:n}function Mi(e){if(!e)return``;let t=e.description||``;if(t.startsWith(`[MCP:`)){let e=t.indexOf(`]`);e!==-1&&(t=t.slice(e+1).trim())}return t===(e.name||``)?``:t}async function Ni(){try{let e=await chrome.runtime.sendMessage({type:`GET_MCP_TOOLS`});if(e?.success&&e.tools)return ki=e.tools,ki}catch{}try{return ki=(await chrome.storage.local.get([`mcpTools`])).mcpTools||[],ki}catch{return ki=[],[]}}async function Pi(){try{Ai=(await chrome.storage.local.get([`ragTools`])).ragTools||[]}catch{Ai=[]}return Ai}async function Fi(){let e=`agentMcpClosedServers_${N.activeAgentId||`default`}`;try{N.mcpClosedServers=(await chrome.storage.local.get([e]))[e]||[]}catch{N.mcpClosedServers=[]}try{let{getAgent:e}=await M(async()=>{let{getAgent:e}=await import(`./agent-store-DR_A4rFm.js`).then(e=>e.t);return{getAgent:e}},__vite__mapDeps([0,1,2,3,4])),t=N.activeAgentId?await e(N.activeAgentId):null;N.activeAgentMcpExcludedServerIds=t?t.mcpExcludedServerIds??null:null}catch{}}var Ii=!1,Li=!0;chrome.storage.local.get([`enableToolPreselect`,`toolConfirmationEnabled`],e=>{Ii=e.enableToolPreselect===!0,Li=e.toolConfirmationEnabled!==!1,la()}),chrome.storage.onChanged.addListener((e,t)=>{if(t!==`local`)return;let n=!1;e.mcpTools&&(ki=e.mcpTools.newValue||[],a.debug(`[SidePanel] MCP toolcache updated:`,ki.length,``),n=!0),e.ragTools&&(Ai=e.ragTools.newValue||[],a.debug(`[SidePanel] RAG toolcache updated:`,Ai.length),n=!0),e.mcpEnabled&&(Ri=e.mcpEnabled.newValue===!0,a.debug(`[SidePanel] MCP globaltoggle changed:`,Ri),n=!0),e.skillsEnabled&&(zi=e.skillsEnabled.newValue!==!1,a.debug(`[SidePanel] Skill global toggle changed:`,zi),n=!0),e.enableImageInput&&(Bi=e.enableImageInput.newValue===!0,a.debug(`[SidePanel] 图片识别全局开关变更:`,Bi),n=!0);let r=!1;e.enableToolPreselect&&(Ii=e.enableToolPreselect.newValue===!0,r=!0),e.toolConfirmationEnabled&&(Li=e.toolConfirmationEnabled.newValue!==!1,r=!0),r&&la(),n&&(document.getElementById(`toolsPopupOverlay`)?.classList.contains(`show`)&&(ia(),aa(),Xi()),ca())}),Ni().then(()=>ca()),Pi().then(()=>ca());var Ri=!1,zi=!0,Bi=!1;chrome.storage.local.get([`mcpEnabled`,`skillsEnabled`,`enableImageInput`],e=>{Ri=e.mcpEnabled===!0,zi=e.skillsEnabled!==!1,Bi=e.enableImageInput===!0,ca()});function Vi(){let e=[...b,...Ai],t=N.activeAgentToolIds,n=e;if(t!=null){let r=new Set(t);n=e.filter(e=>r.has(e.id))}return zi||(n=n.filter(e=>e.id!==`agent_skill`)),N.agentPlatform?.connected!==!0&&(n=n.filter(e=>!e.id.startsWith(`agent_`)&&!e.id.startsWith(`knowledge_`))),Bi||(n=n.filter(e=>e.id!==`read_image`)),n}function Hi(){if(!Ri||N.agentPlatform?.connected!==!0)return[];let e=new Map;return ki.forEach(t=>{let n=t.serverId||`unknown`;e.has(n)||e.set(n,{serverId:n,serverName:t.serverName||n,tools:[],toolCount:0});let r=e.get(n);r.tools.push(t),r.toolCount++}),Array.from(e.values())}function Ui(e){return Array.isArray(N.mcpClosedServers)&&N.mcpClosedServers.includes(e)}function Wi(e){return Array.isArray(N.activeAgentMcpExcludedServerIds)&&N.activeAgentMcpExcludedServerIds.includes(e)}function Gi(e){return!Ui(e)&&!Wi(e)}function Ki(){if(N.currentCategory!==`all`&&N.currentCategory!==`mcp`)return[];let e=Hi();if(N.currentSearch){let t=N.currentSearch;e=e.filter(e=>(e.serverName||``).toLowerCase().includes(t)||(e.serverId||``).toLowerCase().includes(t)||e.tools.some(e=>(e.name||``).toLowerCase().includes(t)||ji(e).toLowerCase().includes(t)))}return e}function qi(e,t){Array.isArray(N.mcpClosedServers)||(N.mcpClosedServers=[]);let n=N.mcpClosedServers.indexOf(e);t?n>-1&&N.mcpClosedServers.splice(n,1):n===-1&&N.mcpClosedServers.push(e)}async function Ji(){let e=document.getElementById(`toolsPopupOverlay`);if(!e)return;N.currentCategory=`all`,N.currentSearch=``;let t=document.getElementById(`toolsSearchInput`);t&&(t.value=``),await Ni(),await Pi(),await Fi(),ia(),aa(),chrome.storage.local.get([`enableToolPreselect`,`toolConfirmationEnabled`],e=>{let t=document.getElementById(`toolsPreselectToggle`);t&&(t.checked=e.enableToolPreselect===void 0?!1:e.enableToolPreselect);let n=document.getElementById(`toolConfirmToggle`);n&&(n.checked=e.toolConfirmationEnabled===void 0?!0:e.toolConfirmationEnabled)}),document.querySelectorAll(`.category-btn`).forEach(e=>{e.classList.remove(`active`),e.classList.contains(`category-all`)?(e.classList.add(`active`),e.style.background=`linear-gradient(135deg, var(--brand-500) 0%, var(--brand-accent) 100%)`,e.style.color=`var(--text-on-brand)`,e.style.borderColor=`transparent`):(e.style.background=`var(--bg-surface)`,e.style.color=`var(--text-secondary)`,e.style.borderColor=`var(--border-subtle)`)}),Xi(),e.classList.add(`show`),a.debug(`[SidePanel] opentool popup`)}function Yi(){let e=document.getElementById(`toolsPopupOverlay`);e&&(document.querySelectorAll(`.category-btn`).forEach(e=>{e.classList.remove(`active`),e.style.background=``,e.style.color=``,e.style.borderColor=``}),e.classList.remove(`show`),a.debug(`[SidePanel] closetool popup`))}function Xi(){let e=document.getElementById(`toolsPopupList`);if(!e)return;e.innerHTML=``;let t=Vi();if(N.activeAgentToolIds!==null&&N.activeAgentToolIds!==void 0){let t=document.createElement(`div`);t.className=`popup-tool-agent-banner`,t.innerHTML=`<span>${r(`toolPanel.agentRestrictedBanner`)}</span>`,e.appendChild(t)}let n={};t.forEach(e=>{if(N.currentCategory!==`all`&&e.category!==N.currentCategory)return;if(N.currentSearch){let t=e.name.toLowerCase().includes(N.currentSearch),n=ji(e).toLowerCase().includes(N.currentSearch);if(!t&&!n)return}let t=e.category||`other`;n[t]||(n[t]=[]),n[t].push(e)});let i=Ki();if(wn.forEach(a=>{let o=a===`mcp`,s=n[a]||[],c=o?i:[];if(o?c.length===0:s.length===0)return;let l;if(o)l=`${c.filter(e=>Gi(e.serverId)).length}/${c.length}`;else{let e=t.filter(e=>e.category===a);l=`${e.filter(e=>N.enabledTools.includes(e.id)).length}/${e.length}`}let u=document.createElement(`div`);u.className=`popup-tool-category-group`,u.dataset.category=a;let d=document.createElement(`div`);d.className=`popup-tool-category`,d.dataset.category=a;let f=N.collapsedCategories[a]||!1;d.innerHTML=`
|
|
28
28
|
<span class="category-expand-icon">${f?`▶`:`▼`}</span>
|
|
29
29
|
<span class="category-name">${r(`toolCategory.`+a)}</span>
|
|
30
30
|
<span class="category-count">${l}</span>
|
|
@@ -55,7 +55,7 @@ import{o as e,r as t}from"./chunk-CMxvf4Kt.js";import{a as n,c as r,i,l as a,n a
|
|
|
55
55
|
`,i.addEventListener(`click`,()=>Za(t)),g.appendChild(i)}),i)){let e=document.createElement(`div`);e.className=`clarify-option-item`,e.dataset.index=-1,e.setAttribute(`role`,`radio`),e.setAttribute(`aria-checked`,`false`),e.setAttribute(`tabindex`,`-1`),e.innerHTML=`
|
|
56
56
|
<div class="clarify-option-radio"></div>
|
|
57
57
|
<div class="clarify-option-content clarify-option-other">${r(`clarify.otherOption`)}</div>
|
|
58
|
-
`,e.addEventListener(`click`,()=>Za(-1)),g.appendChild(e);let t=document.getElementById(`clarifyCustomInput`);t&&g.appendChild(t)}let _=document.getElementById(`clarifyCustomInput`);_&&_.classList.remove(`show`);let v=document.getElementById(`clarifyAdditionalInfo`);v&&v.classList.toggle(`show`,o);let y=document.getElementById(`clarifyCustomTextarea`);y&&(y.value=``);let b=document.getElementById(`clarifyAdditionalTextarea`);b&&(b.value=``),l.classList.add(`show`);let x=document.querySelector(`#clarifyContainer .clarify-content`),S=document.querySelector(`#clarifyContainer .clarify-header`);return x&&(x.scrollTop=0),S&&S.classList.remove(`scrolled`),Aa=null,ja=!1,La(),Fa(s),a.debug(`[SidePanel] clarification dialogshown:`,e.toolCallId,t),!0}function Ua(){if(B)return!0;if(ka.length===0)return!1;let e=ka.shift();return Ha(e)?(B=e,Da(Oa,e),!0):(a.error(`[SidePanel] clarify overlay missing, settle as unanswered:`,e.toolCallId),Wa(e),P(r(`clarify.dropped`),`warning`),!1)}function Wa(e){Promise.resolve(chrome.runtime.sendMessage({type:`CLARIFY_RESPONSE`,toolCallId:e.toolCallId,selectedOption:-1,customInput:``,additionalInfo:``})).catch(e=>{a.debug(`[SidePanel] send unanswered clarify response failed:`,e?.message)})}function Ga(){if(ka.length>0){xa(Oa);return}Ka(),Sa(Oa)}function Ka(){let e=document.getElementById(`clarifyOverlay`);e&&e.classList.remove(`show`),N.currentClarifyToolCallId=null,N.currentClarifySessionId=null,Ia()}function qa(){B=null,Ga()}function Ja(e,t){return!!e.toolCallId&&e.toolCallId===t.toolCallId&&(e.sessionId||null)===(t.sessionId||null)&&e.question===t.question}function Ya(e){let t={...e,sessionId:e.sessionId||null};if(a.debug(`[SidePanel] showclarification dialog:`,t.toolCallId,e),B&&Ja(B,t)){a.debug(`[SidePanel] duplicate clarify request, ignored:`,t.toolCallId);return}if(ka.some(e=>Ja(e,t))){a.debug(`[SidePanel] queued duplicate clarify, ignored:`,t.toolCallId);return}ka.push(t),xa(Oa),Va(),Ta(Oa)}function Xa(){if(B){qa();return}Ka()}function Za(e){document.querySelectorAll(`.clarify-option-item`).forEach(e=>{e.classList.remove(`selected`),e.setAttribute(`aria-checked`,`false`),e.setAttribute(`tabindex`,`-1`)});let t=document.querySelector(`.clarify-option-item[data-index="${e}"]`);t&&(t.classList.add(`selected`),t.setAttribute(`aria-checked`,`true`),t.setAttribute(`tabindex`,`0`));let n=document.getElementById(`clarifyCustomInput`);if(n)if(e===-1){n.classList.add(`show`);let e=document.getElementById(`clarifyCustomTextarea`);e&&e.focus()}else n.classList.remove(`show`);a.debug(`[SidePanel] selectclarificationselect :`,e)}function Qa(){if(!B){a.error(`[SidePanel] no has currenttool callID`);return}let e=B.toolCallId,t=B.sessionId,n=-1;document.querySelectorAll(`.clarify-option-item`).forEach((e,t)=>{e.classList.contains(`selected`)&&(n=parseInt(e.dataset.index))});let r=document.getElementById(`clarifyCustomTextarea`),i=r?r.value.trim():``,o=document.getElementById(`clarifyAdditionalTextarea`),s=o?o.value.trim():``,c={type:`CLARIFY_RESPONSE`,toolCallId:e,sessionId:t,selectedOption:n,customInput:i,additionalInfo:s};a.debug(`[SidePanel] send clarificationresponse:`,c),chrome.runtime.sendMessage(c),qa()}function $a(){if(B){let e={type:`CLARIFY_RESPONSE`,toolCallId:B.toolCallId,sessionId:B.sessionId,selectedOption:-1,customInput:``,additionalInfo:``};chrome.runtime.sendMessage(e)}Xa()}function eo(e){a.debug(`[SidePanel] received clarificationtimeoutnotification:`,e);let t=e?.toolCallId;if(!t){if(e?.sessionId&&N.currentClarifySessionId&&e.sessionId!==N.currentClarifySessionId){a.debug(`[SidePanel] clarificationtimeoutfrom othersession,ignore`);return}if(!B)return;to();return}if(B&&B.toolCallId===t){to();return}let n=ka.findIndex(e=>e.toolCallId===t);n>=0&&(a.debug(`[SidePanel] drop queued clarify (already settled by background):`,t),ka.splice(n,1),Va(),Ta(Oa))}function to(){let e=B?.question;qa(),P(`${r(`clarify.timedOut`)}${e?`:${e}`:``}`,`warning`),Na(`error`)}ba(Oa,{present:Ua,pendingCount:()=>ka.length,refresh:Va});function no(){let e=document.getElementById(`clarifyConfirmBtn`);e&&e.addEventListener(`click`,Qa);let t=document.getElementById(`clarifyCancelBtn`);t&&t.addEventListener(`click`,$a);let n=document.getElementById(`clarifyExtendBtn`);n&&n.addEventListener(`click`,Ra);let r=document.querySelector(`#clarifyContainer .clarify-content`),i=document.querySelector(`#clarifyContainer .clarify-header`);r&&i&&r.addEventListener(`scroll`,()=>{i.classList.toggle(`scrolled`,r.scrollTop>2)}),chrome.runtime.onMessage.addListener((e,t,n)=>{e.type===`SHOW_CLARIFY_DIALOG`?(a.debug(`[SidePanel] received clarificationrequested :`,e,`currently activesession:`,N.activeSessionId),Ya(e.data),n({success:!0})):e.type===`PLAY_NOTIFICATION_SOUND`?(a.debug(`[SidePanel] recei to play soundrequested :`,e),Na(e.soundType),n({success:!0})):e.type===`CLARIFY_TIMEOUT`?eo(e):e.type===`CLARIFY_EXTENDED`&&za(e)}),a.debug(`[SidePanel] clarification dialogeventinitializing`)}var ro=ga.CONFIRM,io=[],ao=null,oo=null,so=null;function co(e){let t=Math.floor(e/60),n=e%60;return`${t}:${String(n).padStart(2,`0`)}`}function lo(){oo&&=(clearInterval(oo),null),so&&=(clearTimeout(so),null)}function uo(e,t){return!!e.toolCallId&&e.toolCallId===t.toolCallId&&(e.sessionId||null)===(t.sessionId||null)&&JSON.stringify(e.args??null)===JSON.stringify(t.args??null)}function fo(e){let t=e.message||r(`dialog.confirmAction`,{name:e.toolLabel||e.toolName}),n=io.length,i=Ea(ro),a=t;return n>0&&(a+=` ${r(`dialog.pendingQueue`,{count:n})}`),i>0&&(a+=` ${r(`dialog.otherPending`,{count:i})}`),a}function po(e){let{toolName:t,toolLabel:n,args:i,timeout:o=3e5}=e;N.currentConfirmToolCallId=e.toolCallId,N.currentConfirmSessionId=e.sessionId||null;let s=document.getElementById(`confirmOverlay`);if(!s)return!1;document.getElementById(`confirmToolName`).textContent=n||t;let c=document.getElementById(`confirmArgsSummary`);if(c&&i){let e=Object.entries(i).filter(([e,t])=>t!=null&&t!==``).slice(0,5);e.length>0?(c.innerHTML=e.map(([e,t])=>{let n=typeof t==`string`?t:JSON.stringify(t),r=n.length>80?n.substring(0,80)+`...`:n;return`<span class="confirm-arg" style="margin-right: 8px;"${n.length>80?` title="${n.replace(/"/g,`"`)}"`:``}><strong>${e}:</strong> ${r}</span>`}).join(`、 `),c.style.display=`block`):c.style.display=`none`}let l=document.getElementById(`confirmMessage`);l&&(l.textContent=fo(e)),lo();let u=Math.floor(o/1e3),d=document.getElementById(`confirmCountdownText`),f=document.getElementById(`confirmCountdown`);return d&&f&&(f.classList.remove(`warning`),f.style.display=`flex`,d.textContent=r(`dialog.remainingTime`,{time:co(u)}),oo=setInterval(()=>{if(u--,u<=0){clearInterval(oo),oo=null,d.textContent=r(`dialog.remainingTime`,{time:`0:00`});return}d.textContent=r(`dialog.remainingTime`,{time:co(u)}),u<=30&&f.classList.add(`warning`)},1e3)),s.style.display=`flex`,so=setTimeout(()=>{a.debug(`[SidePanel] confirm dialogtimeout,autodeny`),yo(!1,`single`)},o),!0}function mo(){if(ao)return!0;if(io.length===0)return!1;let e=io.shift();return po(e)?(ao=e,Da(ro,e),!0):(e.resolve&&e.resolve(!1),!1)}function ho(){let e=document.getElementById(`confirmOverlay`);e&&(e.style.display=`none`);let t=document.getElementById(`confirmCountdown`);t&&(t.classList.remove(`warning`),t.style.display=`none`),N.currentConfirmToolCallId=null,N.currentConfirmSessionId=null}function go(){if(io.length>0){xa(ro);return}ho(),Sa(ro)}function _o(e){let t=ao?.resolve;ao=null,lo(),t&&t(e),go()}function vo(e){let t={...e,sessionId:e.sessionId||null};return a.debug(`[SidePanel] showconfirm dialog:`,t.toolName,e),ao&&uo(ao,t)?(a.debug(`[SidePanel] duplicate confirm request, ignored:`,t.toolCallId),Promise.resolve(!1)):io.some(e=>uo(e,t))?(a.debug(`[SidePanel] queued duplicate confirm, ignored:`,t.toolCallId),Promise.resolve(!1)):new Promise(e=>{io.push({...t,resolve:e}),xa(ro),ao&&bo(),Ta(ro)})}function yo(e,t=`single`){if(!ao)return;let n=ao.toolCallId,r=ao.sessionId;lo(),chrome.runtime.sendMessage({type:`TOOL_CONFIRMATION_RESPONSE`,toolCallId:n,confirmed:e,scope:t,sessionId:r}).catch(e=>{a.debug(`[SidePanel] send confirmationresponse failed:`,e.message)}),_o(e)}function bo(){if(!ao)return;let e=document.getElementById(`confirmMessage`);e&&(e.textContent=fo(ao))}function xo(e){let t=e?.toolCallId;if(!t)return;if(ao&&ao.toolCallId===t){a.debug(`[SidePanel] dismiss active confirm dialog (already settled by background):`,t),_o(!1);return}let n=io.findIndex(e=>e.toolCallId===t);if(n>=0){a.debug(`[SidePanel] drop queued confirm dialog (already settled by background):`,t);let[e]=io.splice(n,1);e.resolve&&e.resolve(!1),bo(),Ta(ro)}}ba(ro,{present:mo,pendingCount:()=>io.length,refresh:()=>{ao&&bo()}});function So(){let e=document.getElementById(`confirmApproveOnceBtn`),t=document.getElementById(`confirmApproveLoopBtn`),n=document.getElementById(`confirmDenyBtn`);e&&e.addEventListener(`click`,()=>yo(!0,`single`)),t&&t.addEventListener(`click`,()=>yo(!0,`loop`)),n&&n.addEventListener(`click`,()=>yo(!1,`single`)),chrome.runtime.onMessage.addListener((e,t,n)=>e.type===`SHOW_CONFIRM_DIALOG`?(vo(e.data),n({received:!0}),!1):e.type===`DISMISS_CONFIRM_DIALOG`?(xo(e.data),n({received:!0}),!1):!1)}var Co=t({closeCurrentSession:()=>ms,handleDuplicateSession:()=>as,newSession:()=>Ao,renderSessionTabs:()=>Oo});n(`zh`,{session:{newSession:`新会话`,closeSession:`关闭会话`,taskCompleted:`任务已完成`,closeAllCount:`关闭全部({count})`,noMatch:`未找到匹配的会话`,rename:`重命名`,duplicate:`复制会话`,confirmCloseMessageWithTitle:`确定要关闭会话 "{title}" 吗?`,confirmCloseAllMessage:`确定要关闭所有 {count} 个会话吗?`,confirmCloseAllTitle:`关闭全部会话`,forkedFrom:`已从 "{title}" 分叉`,forkedSession:`已复制会话 "{title}"`,operationFailed:`操作失败:{message}`,sessionListTitle:`会话列表`,closeGroupAll:`全部关闭`,confirmCloseGroupMessage:`确定要关闭“{group}”下的 {count} 个会话吗?`,today:`今天`,yesterday:`昨天`,last7Days:`近 7 天`,earlier:`更早`,todayFormat:`今天 {hour}:{minute}`,yesterdayFormat:`昨天 {hour}:{minute}`,daysAgo:`{count} 天前`}}),n(`en`,{session:{newSession:`New Session`,closeSession:`Close Session`,taskCompleted:`Task completed`,closeAllCount:`Close All ({count})`,noMatch:`No matching sessions found`,rename:`Rename`,duplicate:`Duplicate`,confirmCloseMessageWithTitle:`Are you sure you want to close session "{title}"?`,confirmCloseAllMessage:`Are you sure you want to close all {count} sessions?`,confirmCloseAllTitle:`Close All Sessions`,forkedFrom:`Forked from "{title}"`,forkedSession:`Duplicated session "{title}"`,operationFailed:`Operation failed: {message}`,sessionListTitle:`Sessions`,closeGroupAll:`Close all`,confirmCloseGroupMessage:`Are you sure you want to close {count} sessions in "{group}"?`,today:`Today`,yesterday:`Yesterday`,last7Days:`Last 7 days`,earlier:`Earlier`,todayFormat:`Today {hour}:{minute}`,yesterdayFormat:`Yesterday {hour}:{minute}`,daysAgo:`{count}d ago`}});var V={visible:!1,highlightIndex:-1,filteredSessions:[]},wo={draggedId:null,sourceType:null};function To(e){if(!e)return``;let t=new Date(e),n=new Date,i=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),a=t.getTime();if(a>=i)return r(`session.todayFormat`,{hour:String(t.getHours()).padStart(2,`0`),minute:String(t.getMinutes()).padStart(2,`0`)});if(a>=i-864e5)return r(`session.yesterdayFormat`,{hour:String(t.getHours()).padStart(2,`0`),minute:String(t.getMinutes()).padStart(2,`0`)});let o=Math.floor((i-a)/864e5);return o<=7?r(`session.daysAgo`,{count:o}):t.getFullYear()===n.getFullYear()?`${t.getMonth()+1}/${t.getDate()}`:`${t.getFullYear()}/${t.getMonth()+1}/${t.getDate()}`}function Eo(e){return e.sort((e,t)=>{let n=e.updatedAt?new Date(e.updatedAt).getTime():0;return(t.updatedAt?new Date(t.updatedAt).getTime():0)-n})}function Do(e){if(!e)return`earlier`;let t=new Date(e),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),i=t.getTime();return i>=r?`today`:i>=r-864e5?`yesterday`:Math.floor((r-i)/864e5)<=7?`last7Days`:`earlier`}async function Oo(e=null){let t=e||await gi();N.sessions=t.list,N.activeSessionId=t.activeSessionId;let n=document.getElementById(`sessionTabs`),i=document.getElementById(`sessionTabsScroll`),a=document.getElementById(`sessionTabsActions`);!n||!i||!a||(i.style.opacity=``,i.innerHTML=``,t.list.forEach(e=>{let t=document.createElement(`div`);t.className=`session-tab`,t.dataset.sessionId=e.id,e.id===N.activeSessionId&&t.classList.add(`active`),t.title=e.title;let n=document.createElement(`span`);n.className=`session-tab-title`,n.textContent=e.title||r(`session.newSession`),t.appendChild(n);let a=document.createElement(`span`);if(a.className=`session-tab-close`,a.innerHTML=`✕`,a.title=r(`session.closeSession`),a.addEventListener(`click`,async t=>{if(t.stopPropagation(),(e.id===N.activeSessionId?N.messageHistory?.length||0:e.messageHistory?.length||0)===0){Yo(await Jo(e.id)),await ps();return}us(e,async()=>{await ps()})}),t.appendChild(a),e.isGenerating||N.generatingSessionIds.has(e.id)){let e=document.createElement(`span`);e.className=`session-tab-indicator`,t.appendChild(e)}else if(N.completedSessionIds.has(e.id)&&e.id!==N.activeSessionId){let e=document.createElement(`span`);e.className=`session-tab-completed-indicator`,e.title=r(`session.taskCompleted`),t.appendChild(e)}let o=Or(e.id);if(o>0){let e=document.createElement(`span`);e.className=`session-tab-queue-badge`,e.textContent=String(o>99?`99+`:o),e.title=r(`queue.badgeTitle`,{count:o}),t.appendChild(e)}t.addEventListener(`click`,async n=>{if(n.preventDefault(),e.id!==N.activeSessionId&&!rs){rs=!0,i.querySelectorAll(`.session-tab.active`).forEach(e=>e.classList.remove(`active`)),t.classList.add(`active`);try{await is(e.id)}finally{rs=!1,N.activeSessionId!==e.id&&Oo({list:N.sessions,activeSessionId:N.activeSessionId})}}}),t.addEventListener(`contextmenu`,t=>{t.preventDefault(),ds(t,e)}),t.addEventListener(`mousedown`,async t=>{t.button===1&&(t.preventDefault(),t.stopPropagation(),Yo(await Jo(e.id)),await ps())}),t.draggable=!0,t.addEventListener(`dragstart`,t=>Io(t,e.id)),t.addEventListener(`dragover`,e=>Lo(e)),t.addEventListener(`dragleave`,e=>Ro(e)),t.addEventListener(`drop`,t=>zo(t,e.id)),t.addEventListener(`dragend`,e=>Bo(e)),i.appendChild(t)}),ko(),jo(),$o(),cs(i),Mo(i),Fo(i))}function ko(){let e=document.getElementById(`sessionTabsMore`);if(!e)return;let t=e.cloneNode(!0);e.parentNode.replaceChild(t,e),t.addEventListener(`click`,e=>{e.stopPropagation(),Vo()})}async function Ao(){let e=N.activeSessionId;await _i();let t=await bi();N.activeSessionId=t.id,N.messageHistory=[],N.activeCompaction=null,vi(t),document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:t.id,previousSessionId:e}})),Oo()}function jo(){let e=document.getElementById(`sessionTabsAdd`);if(!e)return;let t=e.cloneNode(!0);e.parentNode.replaceChild(t,e),t.addEventListener(`click`,()=>Ao())}function Mo(e){let t=document.getElementById(`sessionTabsMore`);t&&(e.scrollWidth>e.clientWidth?t.style.display=`flex`:t.style.display=`none`)}var No=null;function Po(){if(No)return;let e=document.getElementById(`sessionTabsScroll`);e&&(No=new ResizeObserver(()=>{requestAnimationFrame(()=>{Mo(e)})}),No.observe(e))}function Fo(e){let t=e.querySelector(`.session-tab.active`);if(t){let n=t.offsetLeft,r=t.offsetWidth;e.scrollLeft=n-(e.clientWidth-r)/2}e.style.opacity=`1`}function Io(e,t){wo.draggedId=t,wo.sourceType=`tab`,e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t),e.currentTarget.classList.add(`dragging`)}function Lo(e){e.preventDefault(),e.dataTransfer.dropEffect=`move`,e.currentTarget.classList.add(`drag-over`)}function Ro(e){e.currentTarget.classList.remove(`drag-over`)}async function zo(e,t){e.preventDefault(),e.currentTarget.classList.remove(`drag-over`);let n=wo.draggedId;if(!n||n===t)return;let r=N.sessions||[],i=r.findIndex(e=>e.id===n),a=r.findIndex(e=>e.id===t);if(i===-1||a===-1)return;let o=[...r],[s]=o.splice(i,1);o.splice(a,0,s),N.sessions=o,await wi(o.map(e=>e.id)),Oo()}function Bo(e){e.currentTarget.classList.remove(`dragging`),document.querySelectorAll(`.session-tab.drag-over`).forEach(e=>e.classList.remove(`drag-over`)),wo.draggedId=null,wo.sourceType=null}function Vo(){V.visible?Uo():Ho()}async function Ho(){let e=document.getElementById(`sessionTabsMore`),t=document.getElementById(`sessionDropdown`);if(!e||!t)return;let n=await gi();N.sessions=n.list,N.activeSessionId=n.activeSessionId,V.filteredSessions=Eo([...n.list]),V.highlightIndex=-1,V.visible=!0,Go(),t.classList.add(`show`);let r=document.getElementById(`sessionDropdownCloseBtn`);r&&(r.onclick=()=>Uo());let i=document.getElementById(`sessionDropdownSearch`),a=document.getElementById(`sessionDropdownSearchClear`);i&&(i.value=V.lastSearchText||``,Wo(),V.lastSearchText&&Ko(V.lastSearchText),setTimeout(()=>i.focus(),50),i.oninput=()=>{V.lastSearchText=i.value,Wo(),Ko(i.value)},i.onkeydown=e=>{es(e)}),a&&(a.onclick=()=>{i&&(i.value=``,V.lastSearchText=``,Wo(),Ko(``),i.focus())}),e.classList.add(`active`)}function Uo(){let e=document.getElementById(`sessionTabsMore`),t=document.getElementById(`sessionDropdown`);t&&t.classList.remove(`show`),e&&e.classList.remove(`active`);let n=document.getElementById(`sessionDropdownSearch`);n&&(V.lastSearchText=n.value,n.oninput=null,n.onkeydown=null);let r=document.getElementById(`sessionDropdownSearchClear`);r&&(r.onclick=null),V.visible=!1,V.highlightIndex=-1,V.filteredSessions=[]}function Wo(){let e=document.getElementById(`sessionDropdownSearch`),t=document.getElementById(`sessionDropdownSearchClear`);t&&e&&(t.style.display=e.value?`flex`:`none`)}function Go(){let e=document.getElementById(`sessionDropdownList`);if(!e)return;e.innerHTML=``;let t=document.getElementById(`sessionDropdownCloseAll`);if(t){let e=(N.sessions||[]).length;t.textContent=r(`session.closeAllCount`,{count:e})}if(V.filteredSessions.length===0){let t=document.createElement(`div`);t.className=`session-dropdown-empty`,t.textContent=r(`session.noMatch`),e.appendChild(t);return}let n={today:r(`session.today`),yesterday:r(`session.yesterday`),last7Days:r(`session.last7Days`),earlier:r(`session.earlier`)},i={};V.filteredSessions.forEach(e=>{let t=Do(e.updatedAt);i[t]=(i[t]||0)+1});let a=null;V.filteredSessions.forEach((t,o)=>{let s=Do(t.updatedAt);if(s!==a){a=s;let t=document.createElement(`div`);t.className=`session-dropdown-group-header`;let o=document.createElement(`span`);if(o.textContent=n[s]||s,t.appendChild(o),(i[s]||0)>0){let e=document.createElement(`button`);e.className=`session-dropdown-group-close`,e.textContent=r(`session.closeGroupAll`),e.onclick=e=>{e.stopPropagation(),Qo(s,n[s]||s)},t.appendChild(e)}e.appendChild(t)}let c=document.createElement(`div`);if(c.className=`session-dropdown-item`,c.dataset.sessionId=t.id,c.dataset.index=o,t.id===N.activeSessionId&&c.classList.add(`active`),o===V.highlightIndex&&c.classList.add(`highlighted`),N.completedSessionIds.has(t.id)&&t.id!==N.activeSessionId&&!t.isGenerating&&!N.generatingSessionIds.has(t.id)){let e=document.createElement(`span`);e.className=`session-dropdown-item-completed`,e.title=r(`session.taskCompleted`),c.appendChild(e)}let l=Or(t.id);if(l>0){let e=document.createElement(`span`);e.className=`session-dropdown-item-queue`,e.textContent=String(l>99?`99+`:l),e.title=r(`queue.badgeTitle`,{count:l}),c.appendChild(e)}let u=document.createElement(`span`);u.className=`session-dropdown-item-icon`,u.innerHTML=`<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>`,c.appendChild(u);let d=document.createElement(`span`);if(d.className=`session-dropdown-item-title`,d.textContent=t.title||r(`session.newSession`),d.title=t.title||r(`session.newSession`),c.appendChild(d),t.id===N.activeSessionId){let e=document.createElement(`span`);e.className=`session-dropdown-item-check`,e.innerHTML=`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>`,c.appendChild(e)}let f=document.createElement(`span`);f.className=`session-dropdown-item-time`,f.textContent=To(t.updatedAt),c.appendChild(f);let p=document.createElement(`span`);p.className=`session-dropdown-item-actions`;let m=document.createElement(`span`);m.className=`session-dropdown-item-rename`,m.title=r(`session.rename`),m.innerHTML=`<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,m.addEventListener(`click`,e=>{e.stopPropagation(),e.preventDefault(),ls(t)}),p.appendChild(m);let h=document.createElement(`span`);h.className=`session-dropdown-item-duplicate`,h.title=r(`session.duplicate`),h.innerHTML=`<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="6" r="2.5"/><circle cx="6" cy="18" r="2.5"/><circle cx="18" cy="6" r="2.5"/><path d="M6 8.5v7"/><path d="M18 8.5c0 4-6 3.5-6 3.5"/></svg>`,h.addEventListener(`click`,async e=>{e.stopPropagation(),e.preventDefault(),await as(t.id);let n=await gi();N.sessions=n.list,N.activeSessionId=n.activeSessionId,Ko(document.getElementById(`sessionDropdownSearch`)?.value||``)}),p.appendChild(h);let g=document.createElement(`span`);g.className=`session-dropdown-item-close`,g.innerHTML=`✕`,g.title=r(`session.closeSession`),g.addEventListener(`click`,async e=>{e.stopPropagation(),e.preventDefault(),await Xo(t.id)}),p.appendChild(g),c.appendChild(p),c.addEventListener(`click`,async e=>{e.preventDefault(),await qo(t.id)}),e.appendChild(c)})}function Ko(e){let t=N.sessions||[],n;if(!e.trim())n=[...t];else{let i=e.trim().toLowerCase();n=t.filter(e=>(e.title||r(`session.newSession`)).toLowerCase().includes(i))}V.filteredSessions=Eo(n),V.highlightIndex=-1,Go()}async function qo(e){Uo(),e!==N.activeSessionId&&await is(e)}async function Jo(e){let t=Or(e)+Er(e).length;return await Si(e),t}function Yo(e){e<=0||P(r(`queue.sessionDropped`,{count:e}),`info`,3e3)}async function Xo(e){let t=(N.sessions||[]).find(t=>t.id===e);t&&((e===N.activeSessionId?N.messageHistory?.length||0:t.messageHistory?.length||0)>0&&!await ns(r(`session.confirmCloseMessageWithTitle`,{title:t.title}),r(`session.closeSession`))||(Yo(await Jo(e)),await ps(),Ko(document.getElementById(`sessionDropdownSearch`)?.value||``)))}async function Zo(){let e=N.sessions||[];if(e.length===0||!await ns(r(`session.confirmCloseAllMessage`,{count:e.length}),r(`session.confirmCloseAllTitle`)))return;let t=0;for(let n of e)t+=await Jo(n.id);Yo(t),await ps(),Ko(document.getElementById(`sessionDropdownSearch`)?.value||``)}async function Qo(e,t){let n=(N.sessions||[]).filter(t=>Do(t.updatedAt)===e);if(n.length===0||!await ns(r(`session.confirmCloseGroupMessage`,{group:t,count:n.length}),r(`session.closeSession`)))return;let i=0;for(let e of n)i+=await Jo(e.id);Yo(i),await ps(),Ko(document.getElementById(`sessionDropdownSearch`)?.value||``)}function $o(){let e=document.getElementById(`sessionDropdownCloseAll`),t=document.getElementById(`sessionDropdown`);if(t){if(e){let t=e.cloneNode(!0);e.parentNode.replaceChild(t,e),t.addEventListener(`click`,async e=>{e.stopPropagation(),await Zo()})}t.addEventListener(`click`,e=>{e.stopPropagation()})}}function es(e){if(!V.visible)return;let t=V.filteredSessions.length;if(t===0){e.key===`Escape`&&Uo();return}switch(e.key){case`ArrowDown`:e.preventDefault(),V.highlightIndex=Math.min(V.highlightIndex+1,t-1),Go(),ts();break;case`ArrowUp`:e.preventDefault(),V.highlightIndex=Math.max(V.highlightIndex-1,0),Go(),ts();break;case`Enter`:if(e.preventDefault(),V.highlightIndex>=0&&V.highlightIndex<t){let e=V.filteredSessions[V.highlightIndex];qo(e.id)}break;case`Escape`:e.preventDefault(),Uo();break}}function ts(){let e=document.querySelector(`.session-dropdown-item.highlighted`);e&&e.scrollIntoView({block:`nearest`})}function ns(e,t){return new Promise(t=>{let n=document.getElementById(`sessionDeleteModal`),r=document.getElementById(`sessionDeleteMessage`),i=document.getElementById(`sessionDeleteConfirmBtn`),a=document.getElementById(`sessionDeleteCancelBtn`),o=document.getElementById(`sessionDeleteCloseBtn`);if(!n||!r){t(!1);return}r.textContent=e;let s=()=>{n.classList.remove(`show`),i.removeEventListener(`click`,c),a.removeEventListener(`click`,l),o.removeEventListener(`click`,l)},c=()=>{s(),t(!0)},l=()=>{s(),t(!1)};i.addEventListener(`click`,c),a.addEventListener(`click`,l),o.addEventListener(`click`,l),n.classList.add(`show`)})}var rs=!1;async function is(e){let t=N.activeSessionId;if(!await xi(e))return;let n=`agentEnabledTools_${N.activeAgentId||`default`}`,r=`agentMcpClosedServers_${N.activeAgentId||`default`}`,[i,a,o,s]=await Promise.all([gi(),chrome.storage.local.get([r,`ragTools`,`ragToolsIntroduced`]),chrome.storage.local.get([n,`enabledTools`]),N.activeAgentId?at(N.activeAgentId):Promise.resolve(null)]);N.sessions=i.list,N.activeSessionId=e;let c=a.ragTools||[];N.mcpClosedServers=a[r]||[];let l=!!o[n],u=o[n]||o.enabledTools;if(l||u&&u.length>0){let e=da(c),t=u.filter(t=>e.has(t));if(l)N.enabledTools=t;else{let e=b.filter(e=>e.enabled&&!t.includes(e.id)).map(e=>e.id);N.enabledTools=[...t,...e]}let r=ua(N.enabledTools,c,a.ragToolsIntroduced);N.enabledTools=r.tools,N.enabledTools.length!==u.length&&chrome.storage.local.set({[n]:N.enabledTools,...r.migrated?{ragToolsIntroduced:!0}:{}})}else{N.enabledTools=b.filter(e=>e.enabled).map(e=>e.id);let e=ua(N.enabledTools,c,a.ragToolsIntroduced);N.enabledTools=e.tools,e.migrated&&chrome.storage.local.set({ragToolsIntroduced:!0,[n]:N.enabledTools})}N.activeAgentToolIds=s?s.toolIds:null,N.activeAgentMcpExcludedServerIds=s?s.mcpExcludedServerIds??null:null,document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:e,previousSessionId:t}})),hi(e),Oo(i),os(),dC();try{let{refreshBookmarkPanel:e,updateBookmarkButtons:t}=await M(async()=>{let{refreshBookmarkPanel:e,updateBookmarkButtons:t}=await Promise.resolve().then(()=>cp);return{refreshBookmarkPanel:e,updateBookmarkButtons:t}},void 0);e(),setTimeout(()=>t(),100)}catch{}let d=document.getElementById(`toolsPopupOverlay`);d&&d.classList.contains(`show`)&&(Xi(),ia(),aa()),ca()}async function as(e,t=null){if(e)try{let n=await Oi(e,t);await is(n.id),P(r(t?`session.forkedFrom`:`session.forkedSession`,{title:n.title}),`success`)}catch(e){a.error(`[SessionUI] copy/forksession failed:`,e),P(r(`session.operationFailed`,{message:e.message}),`error`)}}function os(){let e=document.querySelector(`.model-display`);e&&N.currentModel&&(e.textContent=N.currentModel);let t=document.getElementById(`enableToolsBtn`);t&&(t.checked=N.useTools);let n=document.getElementById(`tempIconValue`);n&&N.temperature!==void 0&&(n.textContent=N.temperature.toFixed(2))}var ss=new WeakSet;function cs(e){ss.has(e)||(ss.add(e),e.addEventListener(`wheel`,t=>{e.scrollWidth<=e.clientWidth||(t.preventDefault(),e.scrollLeft+=t.deltaY)},{passive:!1}))}function ls(e){let t=document.getElementById(`sessionRenameModal`),n=document.getElementById(`sessionRenameInput`),r=document.getElementById(`sessionRenameConfirmBtn`),i=document.getElementById(`sessionRenameCancelBtn`),a=document.getElementById(`sessionRenameCloseBtn`);if(!t||!n)return;n.value=e.title;let o=()=>{t.classList.remove(`show`),r.removeEventListener(`click`,s),i.removeEventListener(`click`,c),a.removeEventListener(`click`,c)},s=async()=>{let t=n.value.trim();if(t&&t!==e.title){await Ci(e.id,t),Oo();let n=await gi();N.sessions=n.list,N.activeSessionId=n.activeSessionId,Ko(document.getElementById(`sessionDropdownSearch`)?.value||``)}o()},c=()=>{o()};r.addEventListener(`click`,s),i.addEventListener(`click`,c),a.addEventListener(`click`,c),n.onkeydown=e=>{e.key===`Enter`?s():e.key===`Escape`&&c()},t.classList.add(`show`),setTimeout(()=>{n.focus(),n.select()},50)}function us(e,t){let n=document.getElementById(`sessionDeleteModal`),i=document.getElementById(`sessionDeleteMessage`),a=document.getElementById(`sessionDeleteConfirmBtn`),o=document.getElementById(`sessionDeleteCancelBtn`),s=document.getElementById(`sessionDeleteCloseBtn`);if(!n||!i)return;i.textContent=r(`session.confirmCloseMessageWithTitle`,{title:e.title});let c=()=>{n.classList.remove(`show`),a.removeEventListener(`click`,l),o.removeEventListener(`click`,u),s.removeEventListener(`click`,u)},l=async()=>{Yo(await Jo(e.id)),t&&await t(),c()},u=()=>{c()};a.addEventListener(`click`,l),o.addEventListener(`click`,u),s.addEventListener(`click`,u),n.classList.add(`show`),requestAnimationFrame(()=>a.focus())}function ds(e,t){let n=document.querySelector(`.session-context-menu`);n&&n.remove();let i=document.createElement(`div`);i.className=`session-context-menu`,i.style.left=e.clientX+`px`,i.style.top=e.clientY+`px`;let a=fs(r(`session.rename`),`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,()=>{i.remove(),ls(t)});i.appendChild(a);let o=fs(r(`session.duplicate`),`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="6" r="2.5"/><circle cx="6" cy="18" r="2.5"/><circle cx="18" cy="6" r="2.5"/><path d="M6 8.5v7"/><path d="M18 8.5c0 4-6 3.5-6 3.5"/></svg>`,()=>{i.remove(),as(t.id)});i.appendChild(o);let s=fs(r(`session.closeSession`),`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>`,async()=>{if(i.remove(),(t.id===N.activeSessionId?N.messageHistory?.length||0:t.messageHistory?.length||0)===0){Yo(await Jo(t.id)),await ps();return}us(t,async()=>{await ps()})},`danger`);i.appendChild(s),document.body.appendChild(i);let c=e=>{i.contains(e.target)||(i.remove(),document.removeEventListener(`click`,c))};setTimeout(()=>document.addEventListener(`click`,c),0)}function fs(e,t=``,n,r=``){let i=document.createElement(`div`);return i.className=`session-context-menu-item `+r,t?i.innerHTML=`${t}<span>${e}</span>`:i.textContent=e,i.addEventListener(`click`,n),i}async function ps(){let e=N.activeSessionId,t=await gi();t.activeSessionId||(await bi(),t=await gi()),N.activeSessionId=t.activeSessionId,N.sessions=t.list;let n=t.list.find(e=>e.id===t.activeSessionId);if(N.messageHistory=n&&n.messageHistory||[],N.activeCompaction=n?.contextCompaction||null,vi(n),N.activeAgentId=n&&n.agentId||null,N.activeAgentId){let e=await at(N.activeAgentId);N.activeAgentToolIds=e?e.toolIds:null,N.activeAgentMcpExcludedServerIds=e?e.mcpExcludedServerIds??null:null}else N.activeAgentToolIds=null,N.activeAgentMcpExcludedServerIds=null;document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:N.activeSessionId,previousSessionId:e}})),Oo(),await dC()}async function ms(){let e=N.activeSessionId;if(!e)return;let t=N.sessions?.find(t=>t.id===e);if(t){if((N.messageHistory?.length||0)===0){Yo(await Jo(e)),await ps();return}us(t,async()=>{await ps()})}}document.addEventListener(`generating-state-changed`,()=>{Oo()}),document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,Po):Po(),[`<svg viewBox="0 0 16 16" fill="currentColor">`,`<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25zM5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25z"/>`,`</svg>`].join(``),[`<svg viewBox="0 0 16 16" fill="currentColor">`,`<path d="M12.146.146a.5.5 0 0 1 .708 0l2.5 2.5a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168l10-10zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207 11.207 2.5zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293l6.5-6.5zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12h.5a.5.5 0 0 1 .5.5v.5a.5.5 0 0 1-.5.5h-.5a.5.5 0 0 1-.468-.325z"/>`,`</svg>`].join(``),[`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<circle cx="12" cy="12" r="10"></circle>`,`<polyline points="12 6 12 12 16 14"></polyline>`,`</svg>`].join(``),[`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<line x1="18" y1="6" x2="6" y2="18"></line>`,`<line x1="6" y1="6" x2="18" y2="18"></line>`,`</svg>`].join(``),[`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<polyline points="7 13 12 18 17 13"></polyline>`,`<polyline points="7 6 12 11 17 6"></polyline>`,`</svg>`].join(``);var hs=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>`,gs=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>`,_s=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>`,vs=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,ys=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>`,bs=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>`;[`<svg class="tool-call-icon exec" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<polyline points="4 17 10 11 4 5"/><line x1="12" y1="19" x2="20" y2="19"/>`,`</svg>`].join(``),[`<svg class="tool-call-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>`,`<polyline points="14 2 14 8 20 8"/>`,`</svg>`].join(``),[`<svg class="tool-call-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>`,`</svg>`].join(``),[`<svg class="tool-call-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/>`,`</svg>`].join(``),n(`zh`,{uiProto:{defaultTitle:`原型`,optimizePrompt:`请帮我优化这个UI原型界面 {id}({title}),`,loadFailed:`加载失败`,noDescription:`暂无描述`,previewInPanel:`面板内预览`,continueOptimizeTitle:`继续优化`,downloadPrototype:`下载原型`,confirmDeleteTitle:`确认删除`,confirmDeleteMessage:`确定删除原型 "{title}" 吗?此操作不可撤销。`,deleteFailed:`删除失败: {message}`,justNow:`刚刚`,minutesAgo:`{count} 分钟前`,hoursAgo:`{count} 小时前`}}),n(`en`,{uiProto:{defaultTitle:`Prototype`,optimizePrompt:`Please help me optimize this UI prototype {id} ({title}), `,loadFailed:`Load failed`,noDescription:`No description`,previewInPanel:`Preview in panel`,continueOptimizeTitle:`Continue optimizing`,downloadPrototype:`Download prototype`,confirmDeleteTitle:`Confirm delete`,confirmDeleteMessage:`Are you sure you want to delete prototype "{title}"? This action cannot be undone.`,deleteFailed:`Delete failed: {message}`,justNow:`Just now`,minutesAgo:`{count} minutes ago`,hoursAgo:`{count} hours ago`}});var xs=null,Ss=1,Cs=.25,ws=2,Ts=.1;function Es(e){let t=e.trim();return/^\s*<!DOCTYPE\s/i.test(t)||/^\s*<html[\s>]/i.test(t)?/<\/head>/i.test(t)?t.replace(/<\/head>/i,`<style>html,body{overflow:auto!important;height:auto!important;}</style></head>`):/<body[\s>]/i.test(t)?t.replace(/<body([\s>])/i,`<body$1<style>html,body{overflow:auto!important;height:auto!important;}</style>`):t:`<!DOCTYPE html>
|
|
58
|
+
`,e.addEventListener(`click`,()=>Za(-1)),g.appendChild(e);let t=document.getElementById(`clarifyCustomInput`);t&&g.appendChild(t)}let _=document.getElementById(`clarifyCustomInput`);_&&_.classList.remove(`show`);let v=document.getElementById(`clarifyAdditionalInfo`);v&&v.classList.toggle(`show`,o);let y=document.getElementById(`clarifyCustomTextarea`);y&&(y.value=``);let b=document.getElementById(`clarifyAdditionalTextarea`);b&&(b.value=``),l.classList.add(`show`);let x=document.querySelector(`#clarifyContainer .clarify-content`),S=document.querySelector(`#clarifyContainer .clarify-header`);return x&&(x.scrollTop=0),S&&S.classList.remove(`scrolled`),Aa=null,ja=!1,La(),Fa(s),a.debug(`[SidePanel] clarification dialogshown:`,e.toolCallId,t),!0}function Ua(){if(B)return!0;if(ka.length===0)return!1;let e=ka.shift();return Ha(e)?(B=e,Da(Oa,e),!0):(a.error(`[SidePanel] clarify overlay missing, settle as unanswered:`,e.toolCallId),Wa(e),P(r(`clarify.dropped`),`warning`),!1)}function Wa(e){Promise.resolve(chrome.runtime.sendMessage({type:`CLARIFY_RESPONSE`,toolCallId:e.toolCallId,selectedOption:-1,customInput:``,additionalInfo:``})).catch(e=>{a.debug(`[SidePanel] send unanswered clarify response failed:`,e?.message)})}function Ga(){if(ka.length>0){xa(Oa);return}Ka(),Sa(Oa)}function Ka(){let e=document.getElementById(`clarifyOverlay`);e&&e.classList.remove(`show`),N.currentClarifyToolCallId=null,N.currentClarifySessionId=null,Ia()}function qa(){B=null,Ga()}function Ja(e,t){return!!e.toolCallId&&e.toolCallId===t.toolCallId&&(e.sessionId||null)===(t.sessionId||null)&&e.question===t.question}function Ya(e){let t={...e,sessionId:e.sessionId||null};if(a.debug(`[SidePanel] showclarification dialog:`,t.toolCallId,e),B&&Ja(B,t)){a.debug(`[SidePanel] duplicate clarify request, ignored:`,t.toolCallId);return}if(ka.some(e=>Ja(e,t))){a.debug(`[SidePanel] queued duplicate clarify, ignored:`,t.toolCallId);return}ka.push(t),xa(Oa),Va(),Ta(Oa)}function Xa(){if(B){qa();return}Ka()}function Za(e){document.querySelectorAll(`.clarify-option-item`).forEach(e=>{e.classList.remove(`selected`),e.setAttribute(`aria-checked`,`false`),e.setAttribute(`tabindex`,`-1`)});let t=document.querySelector(`.clarify-option-item[data-index="${e}"]`);t&&(t.classList.add(`selected`),t.setAttribute(`aria-checked`,`true`),t.setAttribute(`tabindex`,`0`));let n=document.getElementById(`clarifyCustomInput`);if(n)if(e===-1){n.classList.add(`show`);let e=document.getElementById(`clarifyCustomTextarea`);e&&e.focus()}else n.classList.remove(`show`);a.debug(`[SidePanel] selectclarificationselect :`,e)}function Qa(){if(!B){a.error(`[SidePanel] no has currenttool callID`);return}let e=B.toolCallId,t=B.sessionId,n=-1;document.querySelectorAll(`.clarify-option-item`).forEach((e,t)=>{e.classList.contains(`selected`)&&(n=parseInt(e.dataset.index))});let r=document.getElementById(`clarifyCustomTextarea`),i=r?r.value.trim():``,o=document.getElementById(`clarifyAdditionalTextarea`),s=o?o.value.trim():``,c={type:`CLARIFY_RESPONSE`,toolCallId:e,sessionId:t,selectedOption:n,customInput:i,additionalInfo:s};a.debug(`[SidePanel] send clarificationresponse:`,c),chrome.runtime.sendMessage(c),qa()}function $a(){if(B){let e={type:`CLARIFY_RESPONSE`,toolCallId:B.toolCallId,sessionId:B.sessionId,selectedOption:-1,customInput:``,additionalInfo:``};chrome.runtime.sendMessage(e)}Xa()}function eo(e){a.debug(`[SidePanel] received clarificationtimeoutnotification:`,e);let t=e?.toolCallId;if(!t){if(e?.sessionId&&N.currentClarifySessionId&&e.sessionId!==N.currentClarifySessionId){a.debug(`[SidePanel] clarificationtimeoutfrom othersession,ignore`);return}if(!B)return;to();return}if(B&&B.toolCallId===t){to();return}let n=ka.findIndex(e=>e.toolCallId===t);n>=0&&(a.debug(`[SidePanel] drop queued clarify (already settled by background):`,t),ka.splice(n,1),Va(),Ta(Oa))}function to(){let e=B?.question;qa(),P(`${r(`clarify.timedOut`)}${e?`:${e}`:``}`,`warning`),Na(`error`)}ba(Oa,{present:Ua,pendingCount:()=>ka.length,refresh:Va});function no(){let e=document.getElementById(`clarifyConfirmBtn`);e&&e.addEventListener(`click`,Qa);let t=document.getElementById(`clarifyCancelBtn`);t&&t.addEventListener(`click`,$a);let n=document.getElementById(`clarifyExtendBtn`);n&&n.addEventListener(`click`,Ra);let r=document.querySelector(`#clarifyContainer .clarify-content`),i=document.querySelector(`#clarifyContainer .clarify-header`);r&&i&&r.addEventListener(`scroll`,()=>{i.classList.toggle(`scrolled`,r.scrollTop>2)}),chrome.runtime.onMessage.addListener((e,t,n)=>{e.type===`SHOW_CLARIFY_DIALOG`?(a.debug(`[SidePanel] received clarificationrequested :`,e,`currently activesession:`,N.activeSessionId),Ya(e.data),n({success:!0})):e.type===`PLAY_NOTIFICATION_SOUND`?(a.debug(`[SidePanel] recei to play soundrequested :`,e),Na(e.soundType),n({success:!0})):e.type===`CLARIFY_TIMEOUT`?eo(e):e.type===`CLARIFY_EXTENDED`&&za(e)}),a.debug(`[SidePanel] clarification dialogeventinitializing`)}var ro=ga.CONFIRM,io=[],ao=null,oo=null,so=null;function co(e){let t=Math.floor(e/60),n=e%60;return`${t}:${String(n).padStart(2,`0`)}`}function lo(){oo&&=(clearInterval(oo),null),so&&=(clearTimeout(so),null)}function uo(e,t){return!!e.toolCallId&&e.toolCallId===t.toolCallId&&(e.sessionId||null)===(t.sessionId||null)&&JSON.stringify(e.args??null)===JSON.stringify(t.args??null)}function fo(e){let t=e.message||r(`dialog.confirmAction`,{name:e.toolLabel||e.toolName}),n=io.length,i=Ea(ro),a=t;return n>0&&(a+=` ${r(`dialog.pendingQueue`,{count:n})}`),i>0&&(a+=` ${r(`dialog.otherPending`,{count:i})}`),a}function po(e){let{toolName:t,toolLabel:n,args:i,timeout:o=3e5}=e;N.currentConfirmToolCallId=e.toolCallId,N.currentConfirmSessionId=e.sessionId||null;let s=document.getElementById(`confirmOverlay`);if(!s)return!1;document.getElementById(`confirmToolName`).textContent=n||t;let c=document.getElementById(`confirmArgsSummary`);if(c&&i){let e=Object.entries(i).filter(([e,t])=>t!=null&&t!==``).slice(0,5);e.length>0?(c.innerHTML=e.map(([e,t])=>{let n=typeof t==`string`?t:JSON.stringify(t),r=n.length>80?n.substring(0,80)+`...`:n;return`<span class="confirm-arg" style="margin-right: 8px;"${n.length>80?` title="${n.replace(/"/g,`"`)}"`:``}><strong>${e}:</strong> ${r}</span>`}).join(`、 `),c.style.display=`block`):c.style.display=`none`}let l=document.getElementById(`confirmMessage`);l&&(l.textContent=fo(e)),lo();let u=Math.floor(o/1e3),d=document.getElementById(`confirmCountdownText`),f=document.getElementById(`confirmCountdown`);return d&&f&&(f.classList.remove(`warning`),f.style.display=`flex`,d.textContent=r(`dialog.remainingTime`,{time:co(u)}),oo=setInterval(()=>{if(u--,u<=0){clearInterval(oo),oo=null,d.textContent=r(`dialog.remainingTime`,{time:`0:00`});return}d.textContent=r(`dialog.remainingTime`,{time:co(u)}),u<=30&&f.classList.add(`warning`)},1e3)),s.style.display=`flex`,so=setTimeout(()=>{a.debug(`[SidePanel] confirm dialogtimeout,autodeny`),yo(!1,`single`)},o),!0}function mo(){if(ao)return!0;if(io.length===0)return!1;let e=io.shift();return po(e)?(ao=e,Da(ro,e),!0):(e.resolve&&e.resolve(!1),!1)}function ho(){let e=document.getElementById(`confirmOverlay`);e&&(e.style.display=`none`);let t=document.getElementById(`confirmCountdown`);t&&(t.classList.remove(`warning`),t.style.display=`none`),N.currentConfirmToolCallId=null,N.currentConfirmSessionId=null}function go(){if(io.length>0){xa(ro);return}ho(),Sa(ro)}function _o(e){let t=ao?.resolve;ao=null,lo(),t&&t(e),go()}function vo(e){let t={...e,sessionId:e.sessionId||null};return a.debug(`[SidePanel] showconfirm dialog:`,t.toolName,e),ao&&uo(ao,t)?(a.debug(`[SidePanel] duplicate confirm request, ignored:`,t.toolCallId),Promise.resolve(!1)):io.some(e=>uo(e,t))?(a.debug(`[SidePanel] queued duplicate confirm, ignored:`,t.toolCallId),Promise.resolve(!1)):new Promise(e=>{io.push({...t,resolve:e}),xa(ro),ao&&bo(),Ta(ro)})}function yo(e,t=`single`){if(!ao)return;let n=ao.toolCallId,r=ao.sessionId;lo(),chrome.runtime.sendMessage({type:`TOOL_CONFIRMATION_RESPONSE`,toolCallId:n,confirmed:e,scope:t,sessionId:r}).catch(e=>{a.debug(`[SidePanel] send confirmationresponse failed:`,e.message)}),_o(e)}function bo(){if(!ao)return;let e=document.getElementById(`confirmMessage`);e&&(e.textContent=fo(ao))}function xo(e){let t=e?.toolCallId;if(!t)return;if(ao&&ao.toolCallId===t){a.debug(`[SidePanel] dismiss active confirm dialog (already settled by background):`,t),_o(!1);return}let n=io.findIndex(e=>e.toolCallId===t);if(n>=0){a.debug(`[SidePanel] drop queued confirm dialog (already settled by background):`,t);let[e]=io.splice(n,1);e.resolve&&e.resolve(!1),bo(),Ta(ro)}}ba(ro,{present:mo,pendingCount:()=>io.length,refresh:()=>{ao&&bo()}});function So(){let e=document.getElementById(`confirmApproveOnceBtn`),t=document.getElementById(`confirmApproveLoopBtn`),n=document.getElementById(`confirmDenyBtn`);e&&e.addEventListener(`click`,()=>yo(!0,`single`)),t&&t.addEventListener(`click`,()=>yo(!0,`loop`)),n&&n.addEventListener(`click`,()=>yo(!1,`single`)),chrome.runtime.onMessage.addListener((e,t,n)=>e.type===`SHOW_CONFIRM_DIALOG`?(vo(e.data),n({received:!0}),!1):e.type===`DISMISS_CONFIRM_DIALOG`?(xo(e.data),n({received:!0}),!1):!1)}var Co=t({closeCurrentSession:()=>ms,handleDuplicateSession:()=>as,newSession:()=>Ao,renderSessionTabs:()=>Oo});n(`zh`,{session:{newSession:`新会话`,closeSession:`关闭会话`,taskCompleted:`任务已完成`,closeAllCount:`关闭全部({count})`,noMatch:`未找到匹配的会话`,rename:`重命名`,duplicate:`复制会话`,confirmCloseMessageWithTitle:`确定要关闭会话 "{title}" 吗?`,confirmCloseAllMessage:`确定要关闭所有 {count} 个会话吗?`,confirmCloseAllTitle:`关闭全部会话`,forkedFrom:`已从 "{title}" 分叉`,forkedSession:`已复制会话 "{title}"`,operationFailed:`操作失败:{message}`,sessionListTitle:`会话列表`,closeGroupAll:`全部关闭`,confirmCloseGroupMessage:`确定要关闭“{group}”下的 {count} 个会话吗?`,today:`今天`,yesterday:`昨天`,last7Days:`近 7 天`,earlier:`更早`,todayFormat:`今天 {hour}:{minute}`,yesterdayFormat:`昨天 {hour}:{minute}`,daysAgo:`{count} 天前`}}),n(`en`,{session:{newSession:`New Session`,closeSession:`Close Session`,taskCompleted:`Task completed`,closeAllCount:`Close All ({count})`,noMatch:`No matching sessions found`,rename:`Rename`,duplicate:`Duplicate`,confirmCloseMessageWithTitle:`Are you sure you want to close session "{title}"?`,confirmCloseAllMessage:`Are you sure you want to close all {count} sessions?`,confirmCloseAllTitle:`Close All Sessions`,forkedFrom:`Forked from "{title}"`,forkedSession:`Duplicated session "{title}"`,operationFailed:`Operation failed: {message}`,sessionListTitle:`Sessions`,closeGroupAll:`Close all`,confirmCloseGroupMessage:`Are you sure you want to close {count} sessions in "{group}"?`,today:`Today`,yesterday:`Yesterday`,last7Days:`Last 7 days`,earlier:`Earlier`,todayFormat:`Today {hour}:{minute}`,yesterdayFormat:`Yesterday {hour}:{minute}`,daysAgo:`{count}d ago`}});var V={visible:!1,highlightIndex:-1,filteredSessions:[]},wo={draggedId:null,sourceType:null};function To(e){if(!e)return``;let t=new Date(e),n=new Date,i=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),a=t.getTime();if(a>=i)return r(`session.todayFormat`,{hour:String(t.getHours()).padStart(2,`0`),minute:String(t.getMinutes()).padStart(2,`0`)});if(a>=i-864e5)return r(`session.yesterdayFormat`,{hour:String(t.getHours()).padStart(2,`0`),minute:String(t.getMinutes()).padStart(2,`0`)});let o=Math.floor((i-a)/864e5);return o<=7?r(`session.daysAgo`,{count:o}):t.getFullYear()===n.getFullYear()?`${t.getMonth()+1}/${t.getDate()}`:`${t.getFullYear()}/${t.getMonth()+1}/${t.getDate()}`}function Eo(e){return e.sort((e,t)=>{let n=e.updatedAt?new Date(e.updatedAt).getTime():0;return(t.updatedAt?new Date(t.updatedAt).getTime():0)-n})}function Do(e){if(!e)return`earlier`;let t=new Date(e),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),i=t.getTime();return i>=r?`today`:i>=r-864e5?`yesterday`:Math.floor((r-i)/864e5)<=7?`last7Days`:`earlier`}async function Oo(e=null){let t=e||await gi();N.sessions=t.list,N.activeSessionId=t.activeSessionId;let n=document.getElementById(`sessionTabs`),i=document.getElementById(`sessionTabsScroll`),a=document.getElementById(`sessionTabsActions`);!n||!i||!a||(i.style.opacity=``,i.innerHTML=``,t.list.forEach(e=>{let t=document.createElement(`div`);t.className=`session-tab`,t.dataset.sessionId=e.id,e.id===N.activeSessionId&&t.classList.add(`active`),t.title=e.title;let n=document.createElement(`span`);n.className=`session-tab-title`,n.textContent=e.title||r(`session.newSession`),t.appendChild(n);let a=document.createElement(`span`);if(a.className=`session-tab-close`,a.innerHTML=`✕`,a.title=r(`session.closeSession`),a.addEventListener(`click`,async t=>{if(t.stopPropagation(),(e.id===N.activeSessionId?N.messageHistory?.length||0:e.messageHistory?.length||0)===0){Yo(await Jo(e.id)),await ps();return}us(e,async()=>{await ps()})}),t.appendChild(a),e.isGenerating||N.generatingSessionIds.has(e.id)){let e=document.createElement(`span`);e.className=`session-tab-indicator`,t.appendChild(e)}else if(N.completedSessionIds.has(e.id)&&e.id!==N.activeSessionId){let e=document.createElement(`span`);e.className=`session-tab-completed-indicator`,e.title=r(`session.taskCompleted`),t.appendChild(e)}let o=Or(e.id);if(o>0){let e=document.createElement(`span`);e.className=`session-tab-queue-badge`,e.textContent=String(o>99?`99+`:o),e.title=r(`queue.badgeTitle`,{count:o}),t.appendChild(e)}t.addEventListener(`click`,async n=>{if(n.preventDefault(),e.id!==N.activeSessionId&&!rs){rs=!0,i.querySelectorAll(`.session-tab.active`).forEach(e=>e.classList.remove(`active`)),t.classList.add(`active`);try{await is(e.id)}finally{rs=!1,N.activeSessionId!==e.id&&Oo({list:N.sessions,activeSessionId:N.activeSessionId})}}}),t.addEventListener(`contextmenu`,t=>{t.preventDefault(),ds(t,e)}),t.addEventListener(`mousedown`,async t=>{t.button===1&&(t.preventDefault(),t.stopPropagation(),Yo(await Jo(e.id)),await ps())}),t.draggable=!0,t.addEventListener(`dragstart`,t=>Io(t,e.id)),t.addEventListener(`dragover`,e=>Lo(e)),t.addEventListener(`dragleave`,e=>Ro(e)),t.addEventListener(`drop`,t=>zo(t,e.id)),t.addEventListener(`dragend`,e=>Bo(e)),i.appendChild(t)}),ko(),jo(),$o(),cs(i),Mo(i),Fo(i))}function ko(){let e=document.getElementById(`sessionTabsMore`);if(!e)return;let t=e.cloneNode(!0);e.parentNode.replaceChild(t,e),t.addEventListener(`click`,e=>{e.stopPropagation(),Vo()})}async function Ao(){let e=N.activeSessionId;await _i();let t=await bi();N.activeSessionId=t.id,N.messageHistory=[],N.activeCompaction=null,vi(t),document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:t.id,previousSessionId:e}})),Oo()}function jo(){let e=document.getElementById(`sessionTabsAdd`);if(!e)return;let t=e.cloneNode(!0);e.parentNode.replaceChild(t,e),t.addEventListener(`click`,()=>Ao())}function Mo(e){let t=document.getElementById(`sessionTabsMore`);t&&(e.scrollWidth>e.clientWidth?t.style.display=`flex`:t.style.display=`none`)}var No=null;function Po(){if(No)return;let e=document.getElementById(`sessionTabsScroll`);e&&(No=new ResizeObserver(()=>{requestAnimationFrame(()=>{Mo(e)})}),No.observe(e))}function Fo(e){let t=e.querySelector(`.session-tab.active`);if(t){let n=t.offsetLeft,r=t.offsetWidth;e.scrollLeft=n-(e.clientWidth-r)/2}e.style.opacity=`1`}function Io(e,t){wo.draggedId=t,wo.sourceType=`tab`,e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t),e.currentTarget.classList.add(`dragging`)}function Lo(e){e.preventDefault(),e.dataTransfer.dropEffect=`move`,e.currentTarget.classList.add(`drag-over`)}function Ro(e){e.currentTarget.classList.remove(`drag-over`)}async function zo(e,t){e.preventDefault(),e.currentTarget.classList.remove(`drag-over`);let n=wo.draggedId;if(!n||n===t)return;let r=N.sessions||[],i=r.findIndex(e=>e.id===n),a=r.findIndex(e=>e.id===t);if(i===-1||a===-1)return;let o=[...r],[s]=o.splice(i,1);o.splice(a,0,s),N.sessions=o,await wi(o.map(e=>e.id)),Oo()}function Bo(e){e.currentTarget.classList.remove(`dragging`),document.querySelectorAll(`.session-tab.drag-over`).forEach(e=>e.classList.remove(`drag-over`)),wo.draggedId=null,wo.sourceType=null}function Vo(){V.visible?Uo():Ho()}async function Ho(){let e=document.getElementById(`sessionTabsMore`),t=document.getElementById(`sessionDropdown`);if(!e||!t)return;let n=await gi();N.sessions=n.list,N.activeSessionId=n.activeSessionId,V.filteredSessions=Eo([...n.list]),V.highlightIndex=-1,V.visible=!0,Go(),t.classList.add(`show`);let r=document.getElementById(`sessionDropdownCloseBtn`);r&&(r.onclick=()=>Uo());let i=document.getElementById(`sessionDropdownSearch`),a=document.getElementById(`sessionDropdownSearchClear`);i&&(i.value=V.lastSearchText||``,Wo(),V.lastSearchText&&Ko(V.lastSearchText),setTimeout(()=>i.focus(),50),i.oninput=()=>{V.lastSearchText=i.value,Wo(),Ko(i.value)},i.onkeydown=e=>{es(e)}),a&&(a.onclick=()=>{i&&(i.value=``,V.lastSearchText=``,Wo(),Ko(``),i.focus())}),e.classList.add(`active`)}function Uo(){let e=document.getElementById(`sessionTabsMore`),t=document.getElementById(`sessionDropdown`);t&&t.classList.remove(`show`),e&&e.classList.remove(`active`);let n=document.getElementById(`sessionDropdownSearch`);n&&(V.lastSearchText=n.value,n.oninput=null,n.onkeydown=null);let r=document.getElementById(`sessionDropdownSearchClear`);r&&(r.onclick=null),V.visible=!1,V.highlightIndex=-1,V.filteredSessions=[]}function Wo(){let e=document.getElementById(`sessionDropdownSearch`),t=document.getElementById(`sessionDropdownSearchClear`);t&&e&&(t.style.display=e.value?`flex`:`none`)}function Go(){let e=document.getElementById(`sessionDropdownList`);if(!e)return;e.innerHTML=``;let t=document.getElementById(`sessionDropdownCloseAll`);if(t){let e=(N.sessions||[]).length;t.textContent=r(`session.closeAllCount`,{count:e})}if(V.filteredSessions.length===0){let t=document.createElement(`div`);t.className=`session-dropdown-empty`,t.textContent=r(`session.noMatch`),e.appendChild(t);return}let n={today:r(`session.today`),yesterday:r(`session.yesterday`),last7Days:r(`session.last7Days`),earlier:r(`session.earlier`)},i={};V.filteredSessions.forEach(e=>{let t=Do(e.updatedAt);i[t]=(i[t]||0)+1});let a=null;V.filteredSessions.forEach((t,o)=>{let s=Do(t.updatedAt);if(s!==a){a=s;let t=document.createElement(`div`);t.className=`session-dropdown-group-header`;let o=document.createElement(`span`);if(o.textContent=n[s]||s,t.appendChild(o),(i[s]||0)>0){let e=document.createElement(`button`);e.className=`session-dropdown-group-close`,e.textContent=r(`session.closeGroupAll`),e.onclick=e=>{e.stopPropagation(),Qo(s,n[s]||s)},t.appendChild(e)}e.appendChild(t)}let c=document.createElement(`div`);if(c.className=`session-dropdown-item`,c.dataset.sessionId=t.id,c.dataset.index=o,t.id===N.activeSessionId&&c.classList.add(`active`),o===V.highlightIndex&&c.classList.add(`highlighted`),N.completedSessionIds.has(t.id)&&t.id!==N.activeSessionId&&!t.isGenerating&&!N.generatingSessionIds.has(t.id)){let e=document.createElement(`span`);e.className=`session-dropdown-item-completed`,e.title=r(`session.taskCompleted`),c.appendChild(e)}let l=Or(t.id);if(l>0){let e=document.createElement(`span`);e.className=`session-dropdown-item-queue`,e.textContent=String(l>99?`99+`:l),e.title=r(`queue.badgeTitle`,{count:l}),c.appendChild(e)}let u=document.createElement(`span`);u.className=`session-dropdown-item-icon`,u.innerHTML=`<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>`,c.appendChild(u);let d=document.createElement(`span`);if(d.className=`session-dropdown-item-title`,d.textContent=t.title||r(`session.newSession`),d.title=t.title||r(`session.newSession`),c.appendChild(d),t.id===N.activeSessionId){let e=document.createElement(`span`);e.className=`session-dropdown-item-check`,e.innerHTML=`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>`,c.appendChild(e)}let f=document.createElement(`span`);f.className=`session-dropdown-item-time`,f.textContent=To(t.updatedAt),c.appendChild(f);let p=document.createElement(`span`);p.className=`session-dropdown-item-actions`;let m=document.createElement(`span`);m.className=`session-dropdown-item-rename`,m.title=r(`session.rename`),m.innerHTML=`<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,m.addEventListener(`click`,e=>{e.stopPropagation(),e.preventDefault(),ls(t)}),p.appendChild(m);let h=document.createElement(`span`);h.className=`session-dropdown-item-duplicate`,h.title=r(`session.duplicate`),h.innerHTML=`<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="6" r="2.5"/><circle cx="6" cy="18" r="2.5"/><circle cx="18" cy="6" r="2.5"/><path d="M6 8.5v7"/><path d="M18 8.5c0 4-6 3.5-6 3.5"/></svg>`,h.addEventListener(`click`,async e=>{e.stopPropagation(),e.preventDefault(),await as(t.id);let n=await gi();N.sessions=n.list,N.activeSessionId=n.activeSessionId,Ko(document.getElementById(`sessionDropdownSearch`)?.value||``)}),p.appendChild(h);let g=document.createElement(`span`);g.className=`session-dropdown-item-close`,g.innerHTML=`✕`,g.title=r(`session.closeSession`),g.addEventListener(`click`,async e=>{e.stopPropagation(),e.preventDefault(),await Xo(t.id)}),p.appendChild(g),c.appendChild(p),c.addEventListener(`click`,async e=>{e.preventDefault(),await qo(t.id)}),e.appendChild(c)})}function Ko(e){let t=N.sessions||[],n;if(!e.trim())n=[...t];else{let i=e.trim().toLowerCase();n=t.filter(e=>(e.title||r(`session.newSession`)).toLowerCase().includes(i))}V.filteredSessions=Eo(n),V.highlightIndex=-1,Go()}async function qo(e){Uo(),e!==N.activeSessionId&&await is(e)}async function Jo(e){let t=Or(e)+Er(e).length;return await Si(e),t}function Yo(e){e<=0||P(r(`queue.sessionDropped`,{count:e}),`info`,3e3)}async function Xo(e){let t=(N.sessions||[]).find(t=>t.id===e);t&&((e===N.activeSessionId?N.messageHistory?.length||0:t.messageHistory?.length||0)>0&&!await ns(r(`session.confirmCloseMessageWithTitle`,{title:t.title}),r(`session.closeSession`))||(Yo(await Jo(e)),await ps(),Ko(document.getElementById(`sessionDropdownSearch`)?.value||``)))}async function Zo(){let e=N.sessions||[];if(e.length===0||!await ns(r(`session.confirmCloseAllMessage`,{count:e.length}),r(`session.confirmCloseAllTitle`)))return;let t=0;for(let n of e)t+=await Jo(n.id);Yo(t),await ps(),Ko(document.getElementById(`sessionDropdownSearch`)?.value||``)}async function Qo(e,t){let n=(N.sessions||[]).filter(t=>Do(t.updatedAt)===e);if(n.length===0||!await ns(r(`session.confirmCloseGroupMessage`,{group:t,count:n.length}),r(`session.closeSession`)))return;let i=0;for(let e of n)i+=await Jo(e.id);Yo(i),await ps(),Ko(document.getElementById(`sessionDropdownSearch`)?.value||``)}function $o(){let e=document.getElementById(`sessionDropdownCloseAll`),t=document.getElementById(`sessionDropdown`);if(t){if(e){let t=e.cloneNode(!0);e.parentNode.replaceChild(t,e),t.addEventListener(`click`,async e=>{e.stopPropagation(),await Zo()})}t.addEventListener(`click`,e=>{e.stopPropagation()})}}function es(e){if(!V.visible)return;let t=V.filteredSessions.length;if(t===0){e.key===`Escape`&&Uo();return}switch(e.key){case`ArrowDown`:e.preventDefault(),V.highlightIndex=Math.min(V.highlightIndex+1,t-1),Go(),ts();break;case`ArrowUp`:e.preventDefault(),V.highlightIndex=Math.max(V.highlightIndex-1,0),Go(),ts();break;case`Enter`:if(e.preventDefault(),V.highlightIndex>=0&&V.highlightIndex<t){let e=V.filteredSessions[V.highlightIndex];qo(e.id)}break;case`Escape`:e.preventDefault(),Uo();break}}function ts(){let e=document.querySelector(`.session-dropdown-item.highlighted`);e&&e.scrollIntoView({block:`nearest`})}function ns(e,t){return new Promise(t=>{let n=document.getElementById(`sessionDeleteModal`),r=document.getElementById(`sessionDeleteMessage`),i=document.getElementById(`sessionDeleteConfirmBtn`),a=document.getElementById(`sessionDeleteCancelBtn`),o=document.getElementById(`sessionDeleteCloseBtn`);if(!n||!r){t(!1);return}r.textContent=e;let s=()=>{n.classList.remove(`show`),i.removeEventListener(`click`,c),a.removeEventListener(`click`,l),o.removeEventListener(`click`,l)},c=()=>{s(),t(!0)},l=()=>{s(),t(!1)};i.addEventListener(`click`,c),a.addEventListener(`click`,l),o.addEventListener(`click`,l),n.classList.add(`show`)})}var rs=!1;async function is(e){let t=N.activeSessionId;if(!await xi(e))return;let n=`agentEnabledTools_${N.activeAgentId||`default`}`,r=`agentMcpClosedServers_${N.activeAgentId||`default`}`,[i,a,o,s]=await Promise.all([gi(),chrome.storage.local.get([r,`ragTools`,`ragToolsIntroduced`]),chrome.storage.local.get([n,`enabledTools`]),N.activeAgentId?at(N.activeAgentId):Promise.resolve(null)]);N.sessions=i.list,N.activeSessionId=e;let c=a.ragTools||[];N.mcpClosedServers=a[r]||[];let l=!!o[n],u=o[n]||o.enabledTools;if(l||u&&u.length>0){let e=da(c),t=u.filter(t=>e.has(t));if(l)N.enabledTools=t;else{let e=b.filter(e=>e.enabled&&!t.includes(e.id)).map(e=>e.id);N.enabledTools=[...t,...e]}let r=ua(N.enabledTools,c,a.ragToolsIntroduced);N.enabledTools=r.tools,N.enabledTools.length!==u.length&&chrome.storage.local.set({[n]:N.enabledTools,...r.migrated?{ragToolsIntroduced:!0}:{}})}else{N.enabledTools=b.filter(e=>e.enabled).map(e=>e.id);let e=ua(N.enabledTools,c,a.ragToolsIntroduced);N.enabledTools=e.tools,e.migrated&&chrome.storage.local.set({ragToolsIntroduced:!0,[n]:N.enabledTools})}N.activeAgentToolIds=s?s.toolIds:null,N.activeAgentMcpExcludedServerIds=s?s.mcpExcludedServerIds??null:null,document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:e,previousSessionId:t}})),hi(e),Oo(i),os(),mC();try{let{refreshBookmarkPanel:e,updateBookmarkButtons:t}=await M(async()=>{let{refreshBookmarkPanel:e,updateBookmarkButtons:t}=await Promise.resolve().then(()=>cp);return{refreshBookmarkPanel:e,updateBookmarkButtons:t}},void 0);e(),setTimeout(()=>t(),100)}catch{}let d=document.getElementById(`toolsPopupOverlay`);d&&d.classList.contains(`show`)&&(Xi(),ia(),aa()),ca()}async function as(e,t=null){if(e)try{let n=await Oi(e,t);await is(n.id),P(r(t?`session.forkedFrom`:`session.forkedSession`,{title:n.title}),`success`)}catch(e){a.error(`[SessionUI] copy/forksession failed:`,e),P(r(`session.operationFailed`,{message:e.message}),`error`)}}function os(){let e=document.querySelector(`.model-display`);e&&N.currentModel&&(e.textContent=N.currentModel);let t=document.getElementById(`enableToolsBtn`);t&&(t.checked=N.useTools);let n=document.getElementById(`tempIconValue`);n&&N.temperature!==void 0&&(n.textContent=N.temperature.toFixed(2))}var ss=new WeakSet;function cs(e){ss.has(e)||(ss.add(e),e.addEventListener(`wheel`,t=>{e.scrollWidth<=e.clientWidth||(t.preventDefault(),e.scrollLeft+=t.deltaY)},{passive:!1}))}function ls(e){let t=document.getElementById(`sessionRenameModal`),n=document.getElementById(`sessionRenameInput`),r=document.getElementById(`sessionRenameConfirmBtn`),i=document.getElementById(`sessionRenameCancelBtn`),a=document.getElementById(`sessionRenameCloseBtn`);if(!t||!n)return;n.value=e.title;let o=()=>{t.classList.remove(`show`),r.removeEventListener(`click`,s),i.removeEventListener(`click`,c),a.removeEventListener(`click`,c)},s=async()=>{let t=n.value.trim();if(t&&t!==e.title){await Ci(e.id,t),Oo();let n=await gi();N.sessions=n.list,N.activeSessionId=n.activeSessionId,Ko(document.getElementById(`sessionDropdownSearch`)?.value||``)}o()},c=()=>{o()};r.addEventListener(`click`,s),i.addEventListener(`click`,c),a.addEventListener(`click`,c),n.onkeydown=e=>{e.key===`Enter`?s():e.key===`Escape`&&c()},t.classList.add(`show`),setTimeout(()=>{n.focus(),n.select()},50)}function us(e,t){let n=document.getElementById(`sessionDeleteModal`),i=document.getElementById(`sessionDeleteMessage`),a=document.getElementById(`sessionDeleteConfirmBtn`),o=document.getElementById(`sessionDeleteCancelBtn`),s=document.getElementById(`sessionDeleteCloseBtn`);if(!n||!i)return;i.textContent=r(`session.confirmCloseMessageWithTitle`,{title:e.title});let c=()=>{n.classList.remove(`show`),a.removeEventListener(`click`,l),o.removeEventListener(`click`,u),s.removeEventListener(`click`,u)},l=async()=>{Yo(await Jo(e.id)),t&&await t(),c()},u=()=>{c()};a.addEventListener(`click`,l),o.addEventListener(`click`,u),s.addEventListener(`click`,u),n.classList.add(`show`),requestAnimationFrame(()=>a.focus())}function ds(e,t){let n=document.querySelector(`.session-context-menu`);n&&n.remove();let i=document.createElement(`div`);i.className=`session-context-menu`,i.style.left=e.clientX+`px`,i.style.top=e.clientY+`px`;let a=fs(r(`session.rename`),`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,()=>{i.remove(),ls(t)});i.appendChild(a);let o=fs(r(`session.duplicate`),`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="6" r="2.5"/><circle cx="6" cy="18" r="2.5"/><circle cx="18" cy="6" r="2.5"/><path d="M6 8.5v7"/><path d="M18 8.5c0 4-6 3.5-6 3.5"/></svg>`,()=>{i.remove(),as(t.id)});i.appendChild(o);let s=fs(r(`session.closeSession`),`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>`,async()=>{if(i.remove(),(t.id===N.activeSessionId?N.messageHistory?.length||0:t.messageHistory?.length||0)===0){Yo(await Jo(t.id)),await ps();return}us(t,async()=>{await ps()})},`danger`);i.appendChild(s),document.body.appendChild(i);let c=e=>{i.contains(e.target)||(i.remove(),document.removeEventListener(`click`,c))};setTimeout(()=>document.addEventListener(`click`,c),0)}function fs(e,t=``,n,r=``){let i=document.createElement(`div`);return i.className=`session-context-menu-item `+r,t?i.innerHTML=`${t}<span>${e}</span>`:i.textContent=e,i.addEventListener(`click`,n),i}async function ps(){let e=N.activeSessionId,t=await gi();t.activeSessionId||(await bi(),t=await gi()),N.activeSessionId=t.activeSessionId,N.sessions=t.list;let n=t.list.find(e=>e.id===t.activeSessionId);if(N.messageHistory=n&&n.messageHistory||[],N.activeCompaction=n?.contextCompaction||null,vi(n),N.activeAgentId=n&&n.agentId||null,N.activeAgentId){let e=await at(N.activeAgentId);N.activeAgentToolIds=e?e.toolIds:null,N.activeAgentMcpExcludedServerIds=e?e.mcpExcludedServerIds??null:null}else N.activeAgentToolIds=null,N.activeAgentMcpExcludedServerIds=null;document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:N.activeSessionId,previousSessionId:e}})),Oo(),await mC()}async function ms(){let e=N.activeSessionId;if(!e)return;let t=N.sessions?.find(t=>t.id===e);if(t){if((N.messageHistory?.length||0)===0){Yo(await Jo(e)),await ps();return}us(t,async()=>{await ps()})}}document.addEventListener(`generating-state-changed`,()=>{Oo()}),document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,Po):Po(),[`<svg viewBox="0 0 16 16" fill="currentColor">`,`<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25zM5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25z"/>`,`</svg>`].join(``),[`<svg viewBox="0 0 16 16" fill="currentColor">`,`<path d="M12.146.146a.5.5 0 0 1 .708 0l2.5 2.5a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168l10-10zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207 11.207 2.5zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293l6.5-6.5zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12h.5a.5.5 0 0 1 .5.5v.5a.5.5 0 0 1-.5.5h-.5a.5.5 0 0 1-.468-.325z"/>`,`</svg>`].join(``),[`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<circle cx="12" cy="12" r="10"></circle>`,`<polyline points="12 6 12 12 16 14"></polyline>`,`</svg>`].join(``),[`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<line x1="18" y1="6" x2="6" y2="18"></line>`,`<line x1="6" y1="6" x2="18" y2="18"></line>`,`</svg>`].join(``),[`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<polyline points="7 13 12 18 17 13"></polyline>`,`<polyline points="7 6 12 11 17 6"></polyline>`,`</svg>`].join(``);var hs=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>`,gs=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>`,_s=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>`,vs=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,ys=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>`,bs=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>`;[`<svg class="tool-call-icon exec" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<polyline points="4 17 10 11 4 5"/><line x1="12" y1="19" x2="20" y2="19"/>`,`</svg>`].join(``),[`<svg class="tool-call-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>`,`<polyline points="14 2 14 8 20 8"/>`,`</svg>`].join(``),[`<svg class="tool-call-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>`,`</svg>`].join(``),[`<svg class="tool-call-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/>`,`</svg>`].join(``),n(`zh`,{uiProto:{defaultTitle:`原型`,optimizePrompt:`请帮我优化这个UI原型界面 {id}({title}),`,loadFailed:`加载失败`,noDescription:`暂无描述`,previewInPanel:`面板内预览`,continueOptimizeTitle:`继续优化`,downloadPrototype:`下载原型`,confirmDeleteTitle:`确认删除`,confirmDeleteMessage:`确定删除原型 "{title}" 吗?此操作不可撤销。`,deleteFailed:`删除失败: {message}`,justNow:`刚刚`,minutesAgo:`{count} 分钟前`,hoursAgo:`{count} 小时前`}}),n(`en`,{uiProto:{defaultTitle:`Prototype`,optimizePrompt:`Please help me optimize this UI prototype {id} ({title}), `,loadFailed:`Load failed`,noDescription:`No description`,previewInPanel:`Preview in panel`,continueOptimizeTitle:`Continue optimizing`,downloadPrototype:`Download prototype`,confirmDeleteTitle:`Confirm delete`,confirmDeleteMessage:`Are you sure you want to delete prototype "{title}"? This action cannot be undone.`,deleteFailed:`Delete failed: {message}`,justNow:`Just now`,minutesAgo:`{count} minutes ago`,hoursAgo:`{count} hours ago`}});var xs=null,Ss=1,Cs=.25,ws=2,Ts=.1;function Es(e){let t=e.trim();return/^\s*<!DOCTYPE\s/i.test(t)||/^\s*<html[\s>]/i.test(t)?/<\/head>/i.test(t)?t.replace(/<\/head>/i,`<style>html,body{overflow:auto!important;height:auto!important;}</style></head>`):/<body[\s>]/i.test(t)?t.replace(/<body([\s>])/i,`<body$1<style>html,body{overflow:auto!important;height:auto!important;}</style>`):t:`<!DOCTYPE html>
|
|
59
59
|
<html>
|
|
60
60
|
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"></head>
|
|
61
61
|
<body style="margin:0;padding:0;overflow:auto;">${t}</body>
|
|
@@ -89,7 +89,7 @@ import{o as e,r as t}from"./chunk-CMxvf4Kt.js";import{a as n,c as r,i,l as a,n a
|
|
|
89
89
|
</button>
|
|
90
90
|
</div>
|
|
91
91
|
</div>
|
|
92
|
-
`}).join(``),t.querySelectorAll(`.prototype-library-item`).forEach(e=>{let t=e.querySelector(`.prototype-library-item-info`),n=e.querySelector(`.prototype-library-item-open`),i=e.querySelector(`.prototype-library-item-local-open`),o=e.querySelector(`.prototype-library-item-optimize`),s=e.querySelector(`.prototype-library-item-delete`),c=e.querySelector(`.prototype-library-item-download`);t&&t.addEventListener(`click`,()=>{let t=e.dataset.id;Ms(t)}),n&&n.addEventListener(`click`,t=>{t.stopPropagation();let n=e.dataset.id;Ms(n)}),i&&i.addEventListener(`click`,e=>{e.stopPropagation();let t=i.dataset.path;chrome.runtime.sendMessage({type:`OPEN_LOCAL_PROTOTYPE`,path:t},e=>{e?.success||a.error(`[SidePanel] local browseropen failed:`,e?.error)})}),o&&o.addEventListener(`click`,t=>{t.stopPropagation();let n=o.dataset.id;Rs(n,e.querySelector(`.prototype-library-item-title`)?.textContent||r(`uiProto.defaultTitle`)),Ls()}),s&&s.addEventListener(`click`,t=>{t.stopPropagation();let n=s.dataset.id;Bs(n,e.querySelector(`.prototype-library-item-title`)?.textContent||r(`uiProto.defaultTitle`))}),c&&c.addEventListener(`click`,e=>{e.stopPropagation();let t=c.dataset.id;zs(t)})})))}function Is(e){let t=()=>{let t=document.getElementById(`prototypeLibrarySearch`),n=document.getElementById(`prototypeLibrarySort`),r=(t?.value||``).trim().toLowerCase(),i=n?.value||`createdAt_desc`,a=e;r&&(a=e.filter(e=>(e.title||``).toLowerCase().includes(r)||(e.description||``).toLowerCase().includes(r)));let[o,s]=i.split(`_`);a=[...a].sort((e,t)=>{let n;return n=o===`title`?(e.title||``).localeCompare(t.title||``,`zh-CN`):(e.createdAt||0)-(t.createdAt||0),s===`desc`?-n:n}),Fs(a)},n=document.getElementById(`prototypeLibrarySearch`),r=document.getElementById(`prototypeLibrarySort`);if(n){let e=n.cloneNode(!0);n.parentNode.replaceChild(e,n),e.addEventListener(`input`,t)}if(r){let e=r.cloneNode(!0);r.parentNode.replaceChild(e,r),e.addEventListener(`change`,t)}}function Ls(){let e=document.getElementById(`prototypeLibraryModal`);e&&e.classList.remove(`show`),a.debug(`[SidePanel] prototype page libraryhidden`)}function Rs(e,t){let n=document.getElementById(`userInput`);n&&(n.value=r(`uiProto.optimizePrompt`,{id:e,title:t}),n.focus(),n.style.height=`auto`,n.style.height=n.scrollHeight+`px`),a.debug(`[SidePanel] from prototype page librarycontinue optimizeprototype:`,e)}async function zs(e){try{let t=await fe(e);if(!t||!t.html){a.error(`[SidePanel] download prototype failed:not foundprototype`,e);return}let n=Es(t.html),r=new Blob([n],{type:`text/html`}),i=URL.createObjectURL(r),o=document.createElement(`a`);o.href=i,o.download=(t.title||`prototype`).replace(/[^a-zA-Z0-9\u4e00-\u9fa5_-]/g,`_`)+`.html`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i),a.debug(`[SidePanel] prototype fromprototypelibrarydownload:`,o.download)}catch(e){a.error(`[SidePanel] download prototype failed:`,e)}}async function Bs(e,t){if(await Vs(r(`uiProto.confirmDeleteTitle`),r(`uiProto.confirmDeleteMessage`,{title:t}),r(`common.delete`)))try{let t=await fe(e);await Se(e),a.debug(`[SidePanel] prototype deleted:`,e),t?.localPath&&chrome.runtime.sendMessage({type:`DELETE_LOCAL_PROTOTYPE`,path:t.localPath},e=>{e?.success?a.debug(`[SidePanel] local prototypefile deleted:`,t.localPath):a.warn(`[SidePanel] local prototypefiledelete failed:`,e?.error)}),Ps()}catch(e){a.error(`[SidePanel] delete prototype failed:`,e),alert(r(`uiProto.deleteFailed`,{message:e.message}))}}function Vs(e,t,n=r(`common.confirm`)){return new Promise(r=>{let i=document.getElementById(`genericConfirmModal`),a=document.getElementById(`genericConfirmTitle`),o=document.getElementById(`genericConfirmMessage`),s=document.getElementById(`genericConfirmOkBtn`),c=document.getElementById(`genericConfirmCancelBtn`);if(!i){r(confirm(t));return}a.textContent=e,o.textContent=t,s.textContent=n;let l=()=>{i.classList.remove(`show`),s.removeEventListener(`click`,u),c.removeEventListener(`click`,d)},u=()=>{l(),r(!0)},d=()=>{l(),r(!1)};s.addEventListener(`click`,u),c.addEventListener(`click`,d),i.classList.add(`show`)})}function Hs(e){let t=document.createElement(`div`);return t.textContent=e,t.innerHTML}function Us(e){if(!e)return``;let t=new Date(e),n=new Date-t;return n<6e4?r(`uiProto.justNow`):n<36e5?r(`uiProto.minutesAgo`,{count:Math.floor(n/6e4)}):n<864e5?r(`uiProto.hoursAgo`,{count:Math.floor(n/36e5)}):t.toLocaleDateString(`zh-CN`)}function Ws(e){Ss=Math.max(Cs,Math.min(ws,e)),Ss=Math.round(Ss*100)/100;let t=document.getElementById(`prototypeIframe`),n=document.getElementById(`prototypeZoomLevel`);t&&(t.style.zoom=Ss),n&&(n.textContent=Math.round(Ss*100)+`%`,Ss===1?n.classList.remove(`zoomed`):n.classList.add(`zoomed`))}function Gs(){Ws(Ss+Ts),Js()}function Ks(){Ws(Ss-Ts),Js()}function qs(){Ws(1)}function Js(){let e=document.getElementById(`prototypeZoomLevel`);e&&(e.classList.add(`flash`),setTimeout(()=>e.classList.remove(`flash`),150))}function Ys(e){!e.ctrlKey&&!e.metaKey||(e.preventDefault(),e.deltaY<0?Gs():Ks())}function Xs(e){(e.ctrlKey||e.metaKey)&&e.key===`0`&&(e.preventDefault(),qs())}function Zs(){let e=document.getElementById(`prototypeCloseBtn`);e&&e.addEventListener(`click`,Os);let t=document.getElementById(`prototypeDownloadBtn`);t&&t.addEventListener(`click`,As);let n=document.getElementById(`prototypeOpenTabBtn`);n&&n.addEventListener(`click`,js);let r=document.getElementById(`prototypeLocalOpenBtn`);r&&r.addEventListener(`click`,()=>{let e=r.dataset.path;e&&chrome.runtime.sendMessage({type:`OPEN_LOCAL_PROTOTYPE`,path:e},e=>{e?.success||a.error(`[SidePanel] local browseropen failed:`,e?.error)})});let i=document.getElementById(`prototypeContinueBtn`);i&&i.addEventListener(`click`,ks);let o=document.getElementById(`prototypeZoomInBtn`);o&&o.addEventListener(`click`,Gs);let s=document.getElementById(`prototypeZoomOutBtn`);s&&s.addEventListener(`click`,Ks);let c=document.getElementById(`prototypeZoomLevel`);c&&c.addEventListener(`click`,qs);let l=document.getElementById(`prototypeContent`);l&&l.addEventListener(`wheel`,Ys,{passive:!1}),document.addEventListener(`keydown`,Xs);let u=document.getElementById(`prototypeLibraryCloseBtn`);u&&u.addEventListener(`click`,Ls),chrome.runtime.onMessage.addListener((e,t,n)=>{e.type===`SHOW_UI_PROTOTYPE`&&(a.debug(`[SidePanel] received showprototyperequested :`,e),e.data.localOpened?a.debug(`[SidePanel] prototype inagent-side browseropen,skip popup`):e.data.isRemoteAgent?(a.debug(`[SidePanel] remoteagent,will use browserlabelpageautoopenprototype`),Ns(e.data.prototypeId)):Ms(e.data.prototypeId),n({success:!0}))}),a.debug(`[SidePanel] UI prototype moduleeventinitializing`)}var Qs={enabled:!1,thresholdRatio:.85,minPending:4,maxFailures:2};function $s(e,t){let n=Number(e);return Number.isFinite(n)&&n>0&&n<=1?n:t}function ec(e,t){let n=Number(e);return Number.isFinite(n)&&n>=0?Math.floor(n):t}function tc({enabled:e,ratio:t,thresholdRatio:n,pendingCount:r,minPending:i,isGenerating:a,isolateChat:o}={}){if(!e||a||!o)return!1;let s=$s(n,Qs.thresholdRatio),c=ec(i,Qs.minPending);return!Number.isFinite(t)||t<s?!1:ec(r,0)>=c}function nc(e){let t=e?.messageHistory||[],n=e?.activeCompaction?.upToMessageId;if(!n)return t.length;let r=t.findIndex(e=>e.messageId===n);return r===-1?t.length:t.length-r-1}var rc=0;function ic(){rc=0}async function ac({state:e,getRatio:t,compact:n}={}){let r=e?.chatConfig||{},i=r.autoCompaction===!0;if(!i)return{attempted:!1,success:!1,reason:`disabled`};if(rc>=Qs.maxFailures)return{attempted:!1,success:!1,reason:`backoff`};let o;try{o=Number(t?t():NaN)}catch(e){return a.warn(`[AutoCompaction] usage compute failed, send continues:`,e?.message),{attempted:!1,success:!1,reason:`usage_unavailable`}}let s=nc(e);if(!tc({enabled:i,ratio:o,thresholdRatio:r.autoCompactionThreshold,pendingCount:s,isGenerating:!!e?.isGenerating,isolateChat:!!e?.isolateChat}))return{attempted:!1,success:!1,reason:`not_needed`};a.debug(`[AutoCompaction] triggered`,{ratio:o,pendingCount:s});let c=null;try{c=await n({silent:!0})}catch(e){return a.warn(`[AutoCompaction] compact threw, send continues:`,e?.message),rc++,{attempted:!0,success:!1,reason:`exception`}}return c?.success?(ic(),{attempted:!0,success:!0}):(rc++,a.debug(`[AutoCompaction] skipped send:`,c?.reason),{attempted:!0,success:!1,reason:c?.reason||`failed`})}var oc=null,sc=`global`,cc=new Map;function lc(){try{chrome.windows?.getCurrent?.().then?.(e=>{e?.id!=null&&(oc=e.id)}).catch?.(e=>{a.debug(`[PanelContext] query current window failed:`,e?.message)})}catch(e){a.debug(`[PanelContext] init window query failed:`,e?.message)}try{chrome.storage?.local?.get?.([`sidePanelScope`],e=>{sc=e?.sidePanelScope===`tab-specific`?`tab-specific`:`global`}),chrome.storage?.onChanged?.addListener?.((e,t)=>{t!==`local`||!e?.sidePanelScope||(sc=e.sidePanelScope.newValue===`tab-specific`?`tab-specific`:`global`)})}catch(e){a.debug(`[PanelContext] init scope mirror failed:`,e?.message)}}function uc(){return oc}function dc(e){e&&typeof N.currentTabId==`number`&&cc.set(e,N.currentTabId)}function fc(e,t){e&&(typeof t==`number`?cc.set(e,t):cc.delete(e))}function pc(e){if(!e)return null;let t=cc.get(e);return typeof t==`number`?t:null}function mc(e){let t=null;try{t=typeof document<`u`?!!document.hidden:null}catch{}return{windowId:oc,hostTabId:pc(e),scope:sc,panelHidden:t}}var hc=0,gc=500,_c=[{frequency:523.25,startTime:0,duration:.12,type:`sine`,gain:.3},{frequency:659.25,startTime:.09,duration:.12,type:`sine`,gain:.3},{frequency:783.99,startTime:.18,duration:.22,type:`sine`,gain:.35}],vc=[{frequency:440,startTime:0,duration:.16,type:`square`,gain:.22},{frequency:349.23,startTime:.14,duration:.3,type:`square`,gain:.22}],yc=[`#FF3B30`,`#FF9500`,`#FFCC00`,`#34C759`,`#00C7BE`,`#007AFF`,`#AF52DE`,`#FF2D55`],bc=120,xc=4e3,Sc=600,Cc=1e3,wc=.25,Tc=.99,Ec=.3,Dc=.6,Oc=9999;function kc(){return new Promise(e=>{try{chrome.storage.local.get([`completionSoundEnabled`,`completionConfettiEnabled`],t=>{e({soundEnabled:t?.completionSoundEnabled!==!1,confettiEnabled:t?.completionConfettiEnabled!==!1})})}catch(t){a.debug(`[CompletionFeedback] read config failed, use defaults:`,t?.message),e({soundEnabled:!0,confettiEnabled:!0})}})}function Ac(e){try{let t=window.AudioContext||window.webkitAudioContext;if(!t){a.debug(`[CompletionFeedback] AudioContext unavailable`);return}let n=new t;n.state===`suspended`&&typeof n.resume==`function`&&n.resume().catch(()=>{});let r=n.currentTime,i=0;for(let t of e){let e=n.createOscillator(),a=n.createGain();e.type=t.type||`sine`,e.frequency.value=t.frequency;let o=r+t.startTime,s=o+t.duration;a.gain.setValueAtTime(1e-4,o),a.gain.exponentialRampToValueAtTime(t.gain,o+.012),a.gain.exponentialRampToValueAtTime(1e-4,s),e.connect(a),a.connect(n.destination),e.start(o),e.stop(s+.02),s>i&&(i=s)}let o=Math.max(0,(i-r)*1e3)+200;setTimeout(()=>{try{n.close()}catch{}},o)}catch(e){a.debug(`[CompletionFeedback] play tone failed:`,e?.message)}}function jc(){Ac(_c),a.debug(`[CompletionFeedback] success sound played`)}function Mc(){Ac(vc),a.debug(`[CompletionFeedback] failure sound played`)}function Nc(){try{return typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}catch{return!1}}function Pc(){try{if(!document.body)return;let e=window.innerWidth,t=window.innerHeight;if(e<=0||t<=0)return;let n=document.createElement(`canvas`);n.style.cssText=`position:fixed;inset:0;pointer-events:none;z-index:${Oc};`;let r=window.devicePixelRatio||1;n.width=Math.floor(e*r),n.height=Math.floor(t*r),n.style.width=e+`px`,n.style.height=t+`px`,document.body.appendChild(n);let i=n.getContext(`2d`);if(!i){n.remove();return}i.scale(r,r);let o=[{x:e*.15,y:t+10,baseAngle:-Math.PI/2+Ec},{x:e*.85,y:t+10,baseAngle:-Math.PI/2-Ec}],s=[],c=0,l=0,u=performance.now(),d=e=>{let t=Math.min(bc,Math.floor(Math.min(e,Sc)/Sc*bc));for(;c<t;){let e=o[c%o.length],t=e.baseAngle+(Math.random()-.5)*Dc,n=12+Math.random()*8,r=4+Math.random()*4;s.push({x:e.x+(Math.random()-.5)*20,y:e.y,vx:Math.cos(t)*n,vy:Math.sin(t)*n,size:r,color:yc[Math.floor(Math.random()*yc.length)],rotation:Math.random()*Math.PI*2,rotationSpeed:(Math.random()-.5)*.3,shape:Math.random()<.5?`rect`:`circle`}),c++}},f=r=>{let a=r-u;if(a>=xc){cancelAnimationFrame(l),n.remove();return}d(a),i.clearRect(0,0,e,t);let o=xc-Cc,c=a>o?Math.max(0,1-(a-o)/Cc):1;for(let n=s.length-1;n>=0;n--){let r=s[n];if(r.vy+=wc,r.vx*=Tc,r.vy*=Tc,r.x+=r.vx,r.y+=r.vy,r.rotation+=r.rotationSpeed,r.y-r.size>t||r.x+r.size<0||r.x-r.size>e){s.splice(n,1);continue}i.save(),i.globalAlpha=c,i.translate(r.x,r.y),i.rotate(r.rotation),i.fillStyle=r.color,r.shape===`rect`?i.fillRect(-r.size/2,-r.size/2,r.size,r.size*.6):(i.beginPath(),i.arc(0,0,r.size/2,0,Math.PI*2),i.fill()),i.restore()}l=requestAnimationFrame(f)};l=requestAnimationFrame(f),a.debug(`[CompletionFeedback] confetti launched`)}catch(e){a.debug(`[CompletionFeedback] launch confetti failed:`,e?.message)}}function Fc(e,t,n,r){try{chrome.runtime.sendMessage({type:`TASK_FEEDBACK_NOTIFY`,success:e,sessionId:t||null,error:n||``,question:r||``,panel:mc(t)})?.catch?.(()=>{})}catch(e){a.debug(`[CompletionFeedback] desktop notify failed:`,e?.message)}}async function Ic(e=null,t=``){try{let n=Date.now();if(n-hc<gc){a.debug(`[CompletionFeedback] throttled, skip`);return}hc=n;let{soundEnabled:r,confettiEnabled:i}=await kc();r&&jc(),i&&!Nc()&&Pc(),Fc(!0,e,``,t)}catch(e){a.debug(`[CompletionFeedback] unexpected error:`,e?.message||e)}}async function Lc(e=null,t=``,n=``){try{let r=Date.now();if(r-hc<gc){a.debug(`[CompletionFeedback] throttled, skip`);return}hc=r;let{soundEnabled:i}=await kc();i&&Mc(),Fc(!1,e,t,n)}catch(e){a.debug(`[CompletionFeedback] unexpected error:`,e?.message||e)}}var Rc=new Set;function zc(e){return typeof e==`function`?(Rc.add(e),()=>Rc.delete(e)):()=>{}}function Bc(e){let t=e||N.activeSessionId;if(t){N.generatingSessionIds.delete(t);try{mi(t)}catch(e){a.warn(`[GenerationLifecycle] markSessionCompleted failed:`,e?.message)}typeof document<`u`&&typeof CustomEvent==`function`&&(document.dispatchEvent(new CustomEvent(`generating-state-changed`)),document.dispatchEvent(new CustomEvent(`generation-ended`,{detail:{sessionId:t}})));for(let e of Rc)try{e(t)}catch(e){a.error(`[GenerationLifecycle] end handler failed:`,e?.message)}}}function Vc(e){let t=Number(e);return!Number.isFinite(t)||t<=0?3:Math.min(20,Math.max(1,Math.round(t)))}function Hc(){return{callId:null,carried:0,lastIteration:null}}function Uc(e){let t=0;for(let n of e||[]){let e=Number(n&&n.iteration);Number.isFinite(e)&&e>t&&(t=e)}return t}function Wc(e){let{tracker:t,callId:n=null,iteration:r,everyN:i,enabled:a=!0,hasCandidate:o=!0}=e||{},s=t&&typeof t==`object`?{callId:t.callId??null,carried:Number(t.carried)||0,lastIteration:t.lastIteration??null}:Hc(),c=Number(r);if(!Number.isFinite(c)||c<=0)return{carry:!1,reason:`invalid_iteration`,tracker:s};let l=!!n&&!!s.callId&&n!==s.callId,u=s.lastIteration!=null&&c<s.lastIteration;if((l||u)&&(s=Hc()),n&&!s.callId&&(s={...s,callId:n}),!a)return{carry:!1,reason:`disabled`,tracker:s};if(c<2)return{carry:!1,reason:`too_early`,tracker:s};if(!o)return{carry:!1,reason:`no_candidate`,tracker:s};if(s.carried>=3)return{carry:!1,reason:`call_limit`,tracker:s};let d=Vc(i);return s.lastIteration!=null&&c-s.lastIteration<d?{carry:!1,reason:`interval_not_reached`,tracker:s}:{carry:!0,reason:`carry`,tracker:{callId:s.callId||n||null,carried:s.carried,lastIteration:c}}}function Gc(e,{callId:t=null}={}){let n=e&&typeof e==`object`?e:Hc();return t&&n.callId&&t!==n.callId?n:{...n,carried:(Number(n.carried)||0)+1}}n(`zh`,{voice:{start:`语音输入(开始录音)`,stop:`结束录音并转写`,recording:`正在录音`,listening:`正在聆听…`,transcribing:`正在转写…`,cancel:`取消录音`,done:`完成`,noSpeech:`没有听到声音`,noResult:`未识别到语音`,micDenied:`麦克风未授权`,micDeniedHelp:`侧边栏里浏览器不会弹授权框,请到配置页「语音输入 → 麦克风权限」授权一次`,micDeniedAction:`去授权`,micDeniedActionTitle:`打开配置页授权麦克风(侧边栏内无法弹出授权框)`,unavailable:`语音功能不可用`,modelMissing:`缺少语音模型`,modelMissingHelp:`请在配置页「语音」Tab 中导入模型包`,busy:`有语音任务正在进行`,failed:`语音识别失败`,connectionLost:`连接中断`,tooShort:`录音太短`,maxDuration:`已达单次录音时长上限,正在转写…`,unsupported:`当前浏览器不支持录音`,keyRightAlt:`右侧 Alt`,keyRightCtrl:`右侧 Ctrl`,btnTitle:`语音输入({keys})`,deviceFallback:`原麦克风不可用,已改用系统默认`}}),n(`en`,{voice:{start:`Voice input (start recording)`,stop:`Stop and transcribe`,recording:`Recording`,listening:`Listening…`,transcribing:`Transcribing…`,cancel:`Cancel recording`,done:`Done`,noSpeech:`No sound detected`,noResult:`No speech recognised`,micDenied:`Microphone not granted`,micDeniedHelp:`The browser cannot prompt inside the side panel — grant it once in Options → Voice Input → Microphone permission`,micDeniedAction:`Grant access`,micDeniedActionTitle:`Open options to grant microphone access (the side panel cannot show the prompt)`,unavailable:`Voice input unavailable`,modelMissing:`Speech model missing`,modelMissingHelp:`Import a model pack in the Options "Voice" tab`,busy:`Another voice task is running`,failed:`Speech recognition failed`,connectionLost:`Connection lost`,tooShort:`Recording too short`,maxDuration:`Recording length limit reached, transcribing…`,unsupported:`Recording is not supported in this browser`,keyRightAlt:`Right Alt`,keyRightCtrl:`Right Ctrl`,btnTitle:`Voice input ({keys})`,deviceFallback:`Selected microphone unavailable — using the system default`}});var Kc=15e3,qc=16e3,Jc=2500,Yc=.008,Xc=350,Zc=24,H={input:null,btn:null,bar:null,wave:null,timerEl:null,statusEl:null,permBtn:null,barEls:[],status:null,armed:!1,phase:`idle`,port:null,stream:null,ctx:null,node:null,source:null,startedAt:0,timer:null,silentSince:0,silenceWarned:!1,draft:null,lastText:``,appliedText:``,mute:null,programmatic:!1,draftSupported:!0,finishWaitTimer:null,adjustInputHeight:null,shortcutCfg:{...Ze},shortcutTrigger:null,shortcutBound:!1,deviceFellBack:!1};function Qc(e){return typeof e==`string`?e:``}function $c(e){let t=Math.max(0,Math.floor(e/1e3));return`${String(Math.floor(t/60)).padStart(2,`0`)}:${String(t%60).padStart(2,`0`)}`}function el(e){let t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=``,r=32768;for(let e=0;e<t.length;e+=r)n+=String.fromCharCode.apply(null,t.subarray(e,e+r));return btoa(n)}function tl(e,t,n){if(t===n)return e;let r=t/n,i=Math.floor(e.length/r),a=new Float32Array(i);for(let t=0;t<i;t++){let n=t*r,i=Math.floor(n),o=n-i,s=e[i]||0;a[t]=s+((e[i+1]===void 0?s:e[i+1])-s)*o}return a}function nl(e){let t=new Int16Array(e.length);for(let n=0;n<e.length;n++){let r=e[n]<-1?-1:e[n]>1?1:e[n];t[n]=r<0?r*32768:r*32767}return t}async function rl(e=!1){try{let t=await chrome.runtime.sendMessage({type:`ASR_GET_STATUS`,force:e});if(t&&t.success&&t.status)return H.status=t.status,H.status}catch(e){a.debug(`[Voice] status fetch failed:`,e?.message||e)}return H.status=null,null}function il(e){return!e||e.success===!1?!1:typeof e.available==`boolean`?e.available:e.deps?.ready===!0&&e.modelsReady===!0&&e.enabled===!0}function al({value:e,draft:t,text:n,caret:r,canReplace:i=!0}){let a=typeof e==`string`?e:``;if(!t)return{value:a,caret:a.length,len:0};if(!t.dirty&&i){let e=Math.min(Math.max(0,t.start),a.length),r=Math.min(Math.max(e,t.start+t.len),a.length);return{value:a.slice(0,e)+n+a.slice(r),caret:e+n.length,len:n.length}}let o=typeof r==`number`?Math.min(Math.max(0,r),a.length):a.length;return{value:a.slice(0,o)+n+a.slice(o),caret:o+n.length,len:0}}function ol({value:e,draft:t,canReplace:n=!0}){let r=typeof e==`string`?e:``;if(!t||t.dirty||!n||t.len<=0)return{value:r,caret:r.length};let i=Math.min(Math.max(0,t.start),r.length),a=Math.min(Math.max(i,t.start+t.len),r.length);return{value:r.slice(0,i)+r.slice(a),caret:i}}function sl(e){return!e||e.isComposing||e.repeat?!1:e.altKey===!0&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyV`}async function cl(){return H.armed=il(await rl()),H.btn&&(H.btn.style.display=H.armed?``:`none`),!H.armed&&H.phase!==`idle`&&Rl({rollback:!0}),H.armed}function ll(){H.draft&&(H.draft.dirty=!0)}function ul(){let e=H.input;if(!e)return{start:0,len:0,dirty:!1};let t=typeof e.selectionStart==`number`?e.selectionStart:e.value.length,n=typeof e.selectionEnd==`number`?e.selectionEnd:t;return t!==n&&e.setRangeText(``,t,n,`end`),{start:t,len:0,dirty:!1}}function dl(e,t){let n=Qc(e),r=Qc(t);return r?n?r.startsWith(n)?r.slice(n.length):null:r:``}function fl(e,t){let n=H.input;if(n){H.programmatic=!0,n.value=e;try{n.setSelectionRange(t,t)}catch{}H.programmatic=!1;try{document.dispatchEvent(new CustomEvent(`voice-draft-written`))}catch{}try{H.adjustInputHeight?.()}catch{}try{n.focus()}catch{}}}function pl(e){let t=H.input;if(!t||!H.draft)return;if(H.draft.dirty){let n=dl(H.appliedText,e);if(H.appliedText=Qc(e),!n)return;let r=typeof t.selectionStart==`number`?t.selectionStart:t.value.length;fl(t.value.slice(0,r)+n+t.value.slice(r),r+n.length);return}let n=typeof t.selectionStart==`number`?t.selectionStart:void 0,r=al({value:t.value,draft:H.draft,text:e,caret:n,canReplace:H.draftSupported});r.len>0&&(H.draft.len=r.len),H.appliedText=Qc(e),fl(r.value,r.caret)}function ml(){let e=H.input;if(!e||!H.draft)return;let t=ol({value:e.value,draft:H.draft,canReplace:H.draftSupported});if(t.value!==e.value){H.programmatic=!0,e.value=t.value;let n=Math.min(t.caret,e.value.length);try{e.setSelectionRange(n,n)}catch{}H.programmatic=!1;try{H.adjustInputHeight?.()}catch{}}H.draft=null,H.lastText=``}function hl(){if(H.wave){H.wave.textContent=``,H.barEls=[];for(let e=0;e<Zc;e++){let e=document.createElement(`i`);H.wave.appendChild(e),H.barEls.push(e)}}}function gl(e,t=``){H.statusEl&&(H.statusEl.textContent=e,H.statusEl.className=`voice-recorder-status`+(t?` is-${t}`:``))}function _l(){H.bar&&(H.bar.classList.add(`show`),H.bar.removeAttribute(`aria-hidden`))}function vl(e){H.permBtn&&(H.permBtn.style.display=e?``:`none`)}function yl(){let e=document.activeElement;if(!(!H.bar||!e||!H.bar.contains(e))){if(H.input&&typeof H.input.focus==`function`)try{H.input.focus({preventScroll:!0});return}catch{}try{e.blur()}catch{}}}function bl(){H.bar&&(yl(),vl(!1),H.bar.classList.remove(`show`),H.bar.setAttribute(`aria-hidden`,`true`),H.barEls.forEach(e=>{e.style.height=``,e.style.opacity=``}),H.timerEl&&(H.timerEl.textContent=`00:00`))}function xl(e){if(!H.barEls.length)return;let t=Math.min(1,Math.sqrt(Math.max(0,e))*6);for(let e=0;e<H.barEls.length-1;e++)H.barEls[e].style.height=H.barEls[e+1].style.height,H.barEls[e].style.opacity=H.barEls[e+1].style.opacity;let n=H.barEls[H.barEls.length-1];n.style.height=`${Math.max(2,Math.round(t*18))}px`,n.style.opacity=t>.06?`1`:`0.35`}function Sl(e){H.btn&&(H.btn.classList.toggle(`recording`,e),H.btn.setAttribute(`aria-pressed`,e?`true`:`false`),H.btn.setAttribute(`aria-label`,r(e?`voice.stop`:`voice.start`)),H.btn.title=r(e?`voice.stop`:`voice.start`))}function Cl(e){document.body?.classList.toggle(`voice-recording-active`,!!e)}function wl(){if(H.port)return H.port;try{let e=chrome.runtime.connect({name:`asr`});return e.onMessage.addListener(Bl),e.onDisconnect.addListener(()=>{H.port=null,(H.phase===`recording`||H.phase===`finalizing`)&&(Nl(),Pl(),H.draft=null,H.lastText=``,Sl(!1),Cl(!1),gl(r(`voice.connectionLost`),`warn`),setTimeout(()=>{H.phase===`idle`&&bl()},3500))}),H.port=e,e}catch(e){return a.warn(`[Voice] connect port failed:`,e?.message||e),null}}function Tl(e,t){if(xl(t),El(t),H.port)try{H.port.postMessage({type:`audio`,data:el(e)})}catch(e){a.debug(`[Voice] post audio failed:`,e?.message||e)}}function El(e){if(H.phase!==`recording`&&H.phase!==`starting`)return;if(e>=Yc){H.silentSince=0,H.silenceWarned&&(H.silenceWarned=!1,gl(r(`voice.listening`)));return}let t=Date.now();if(!H.silentSince){H.silentSince=t;return}H.silenceWarned||t-H.silentSince>=Jc&&(H.silenceWarned=!0,gl(r(`voice.noSpeech`),`warn`))}var Dl=[`voice-capture-worklet.js`,`dist/voice-capture-worklet.js`],Ol;async function kl(){if(Ol!==void 0)return Ol;for(let e of Dl){let t=``;try{t=chrome.runtime.getURL(e)}catch{continue}try{let e=await fetch(t);if(e&&e.ok)return Ol=t,t}catch{}}return Ol=null,null}async function Al(e,t){let n=await kl();if(!n)throw Error(`worklet not found in extension`);await e.audioWorklet.addModule(n);let r=new AudioWorkletNode(e,`voice-capture`),i=Math.abs(e.sampleRate-qc)>1;r.port.onmessage=t=>{let n=t.data;if(!n||n.type!==`chunk`||!n.pcm)return;let r=new Int16Array(n.pcm);if(i){let t=new Float32Array(r.length);for(let e=0;e<r.length;e++)t[e]=r[e]/32768;r=nl(tl(t,e.sampleRate,qc))}Tl(r,n.rms||0)},t.connect(r),H.node=r}function jl(e,t){let n=e.createScriptProcessor(4096,1,1),r=Math.abs(e.sampleRate-qc)>1;n.onaudioprocess=t=>{let n=t.inputBuffer.getChannelData(0),i=new Float32Array(n);r&&(i=tl(i,e.sampleRate,qc));let a=0;for(let e=0;e<i.length;e++)a+=i[e]*i[e];Tl(nl(i),Math.sqrt(a/Math.max(1,i.length)))},t.connect(n);let i=e.createGain();i.gain.value=0,n.connect(i),i.connect(e.destination),H.mute=i,H.node=n}async function Ml(){if(!navigator.mediaDevices?.getUserMedia)throw gl(r(`voice.unsupported`),`warn`),Error(`unsupported`);let e=await nt(await Qe());H.stream=e.stream,H.deviceFellBack=e.fellBack===!0;let t=window.AudioContext||window.webkitAudioContext,n;try{n=new t({sampleRate:qc})}catch{n=new t}if(n.state===`suspended`)try{await n.resume()}catch{}H.ctx=n;let i=n.createMediaStreamSource(e.stream);H.source=i;try{await Al(n,i)}catch(e){a.warn(`[Voice] worklet unavailable, fallback to ScriptProcessor:`,e?.message||e),jl(n,i)}}function Nl(){H.timer&&=(clearInterval(H.timer),null);try{H.node?.port?.close?.()}catch{}try{H.node?.disconnect?.()}catch{}try{H.mute?.disconnect?.()}catch{}try{H.source?.disconnect?.()}catch{}try{H.stream?.getTracks?.().forEach(e=>e.stop())}catch{}try{H.ctx?.close?.()}catch{}H.node=null,H.mute=null,H.source=null,H.stream=null,H.ctx=null}function Pl(){H.finishWaitTimer&&=(clearTimeout(H.finishWaitTimer),null),H.phase=`idle`}function Fl(){let e=()=>{let e=Date.now()-H.startedAt;H.timerEl&&(H.timerEl.textContent=$c(e));let t=H.status;e>=(t&&t.maxRecordingMs||300*1e3)&&Ll(`stop`)};H.timer&&clearInterval(H.timer),H.timer=setInterval(e,200),e()}async function Il(e={}){if(H.phase!==`idle`||!H.armed&&!e.force&&(await cl(),!H.armed||H.phase!==`idle`))return!1;H.phase=`starting`,H.lastText=``,H.appliedText=``,H.draft=ul(),H.draftSupported=!0,H.silentSince=0,H.silenceWarned=!1,_l(),gl(r(`voice.listening`)),Sl(!0),Cl(!0);let t=wl();if(!t)return gl(r(`voice.failed`),`warn`),Pl(),Sl(!1),Cl(!1),!1;try{await Ml()}catch(e){if(H.phase!==`starting`)return Nl(),!1;let n=e?.name||``,i=n===`NotAllowedError`||n===`SecurityError`;i?(gl(r(`voice.micDenied`),`warn`),vl(!0)):gl(r(`voice.failed`),`warn`),Nl(),Pl(),Sl(!1),Cl(!1);try{t.postMessage({type:`cancel`})}catch{}return setTimeout(()=>{H.phase===`idle`&&bl()},i?12e3:4e3),!1}if(H.phase!==`starting`)return Nl(),!1;H.startedAt=Date.now(),H.phase=`recording`,gl(r(`voice.listening`)),H.deviceFellBack&&(H.deviceFellBack=!1,gl(r(`voice.deviceFallback`),`warn`),setTimeout(()=>{H.phase===`recording`&&gl(r(`voice.listening`))},4e3)),Fl();try{t.postMessage({type:`start`,language:H.status&&H.status.language||`auto`})}catch(e){a.debug(`[Voice] post start failed:`,e?.message||e)}return!0}function Ll(e){if(H.phase!==`recording`)return;H.phase=`finalizing`;let t=Date.now()-H.startedAt;if(Nl(),Sl(!1),Cl(!1),e===`cancel`){try{H.port?.postMessage({type:`cancel`})}catch{}ml(),Pl(),bl();return}if(t<Xc&&!H.lastText){try{H.port?.postMessage({type:`cancel`})}catch{}ml(),gl(r(`voice.tooShort`),`warn`),Pl(),setTimeout(()=>{H.phase===`idle`&&bl()},2200);return}gl(r(`voice.transcribing`));try{H.port?.postMessage({type:`stop`})}catch{}H.finishWaitTimer&&clearTimeout(H.finishWaitTimer),H.finishWaitTimer=setTimeout(()=>{H.phase===`finalizing`&&zl(H.lastText,{fallback:!0})},6e4)}function Rl({rollback:e=!0}={}){if(H.phase===`idle`)return!1;let t=H.phase===`recording`||H.phase===`finalizing`;if(H.phase=`finalizing`,Nl(),t)try{H.port?.postMessage({type:`cancel`})}catch{}return e&&ml(),Pl(),Sl(!1),Cl(!1),bl(),!0}function zl(e,t={}){let n=Qc(e).trim();if(!n){ml(),gl(r(`voice.noResult`),`warn`),Pl(),setTimeout(()=>{H.phase===`idle`&&bl()},2200);return}pl(n),H.draft=null,H.lastText=``,Pl(),gl(r(`voice.done`)),setTimeout(()=>{H.phase===`idle`&&bl()},1200)}function Bl(e){if(!(!e||typeof e.type!=`string`)){if(e.type===`ready`){e.draft===!1&&H.phase===`recording`&&a.debug(`[Voice] online model missing, draft disabled`);return}if(e.type===`partial`||e.type===`endpoint`){if(H.phase!==`recording`&&H.phase!==`finalizing`)return;H.lastText=Qc(e.text),H.lastText&&pl(H.lastText);return}if(e.type===`final`){if(H.phase!==`recording`&&H.phase!==`finalizing`)return;zl(e.text||H.lastText,{fallback:e.fallback===!0});return}if(e.type===`closed`){H.phase===`finalizing`&&zl(H.lastText,{fallback:!0});return}if(e.type===`error`){let t=e.code||`internal`;if(t===`max_duration`){H.phase===`recording`&&Ll(`stop`),gl(r(`voice.maxDuration`),`warn`);return}gl(t===`busy`?r(`voice.busy`):t===`model_missing`?`${r(`voice.modelMissing`)} — ${r(`voice.modelMissingHelp`)}`:r(`voice.failed`),`warn`),Nl(),(H.phase===`recording`||H.phase===`finalizing`)&&ml(),Pl(),Sl(!1),Cl(!1),t===`model_missing`&&cl(),setTimeout(()=>{H.phase===`idle`&&bl()},3500)}}}async function Vl(){return H.phase===`recording`?(Ll(`stop`),!0):H.phase===`starting`||H.phase===`finalizing`?!1:Il()}function Hl(){return H.phase===`recording`||H.phase===`starting`||H.phase===`finalizing`}function Ul(){return Hl()?Rl({rollback:!0}):!1}function Wl(){return H.phase===`idle`?!1:Rl({rollback:!1})}async function Gl(){try{let e=(await chrome.storage.session?.get?.(`pendingVoiceStart`))?.pendingVoiceStart;return!(!e||(await chrome.storage.session.remove(`pendingVoiceStart`),typeof e!=`number`||Date.now()-e>Kc))}catch{return!1}}function Kl(){if(!H.btn)return;let e=[`Alt+V`];H.shortcutCfg.rightAlt&&e.push(r(`voice.keyRightAlt`)),H.shortcutCfg.rightCtrl&&e.push(r(`voice.keyRightCtrl`));let t=r(`voice.btnTitle`,{keys:e.join(` / `)});H.btn.title=t,H.btn.setAttribute(`aria-label`,t)}async function ql(){if(H.shortcutCfg=await Xe(),H.shortcutTrigger||=Ye(()=>H.shortcutCfg),Kl(),H.shortcutBound)return;H.shortcutBound=!0,document.addEventListener(`keydown`,e=>{H.shortcutTrigger?.onKeyDown(e)===`cancel`&&e.preventDefault()},!0),document.addEventListener(`keyup`,e=>{H.shortcutTrigger?.onKeyUp(e)===`trigger`&&(!H.armed&&H.phase===`idle`||(e.preventDefault(),Vl()))},!0),window.addEventListener(`blur`,()=>{H.shortcutTrigger?.reset()}),Je(e=>{H.shortcutCfg=e,Kl()});let e=async()=>{try{let e=await Xe();if(e.rightAlt===H.shortcutCfg.rightAlt&&e.rightCtrl===H.shortcutCfg.rightCtrl)return;H.shortcutCfg=e,Kl()}catch{}};window.addEventListener(`focus`,()=>{e()}),document.addEventListener(`visibilitychange`,()=>{document.hidden||e()})}async function Jl(e={}){if(H.input=document.getElementById(`userInput`),H.btn=document.getElementById(`voiceInputBtn`),H.bar=document.getElementById(`voiceRecorderBar`),H.wave=document.getElementById(`voiceWave`),H.timerEl=document.getElementById(`voiceTimer`),H.statusEl=document.getElementById(`voiceStatusText`),H.permBtn=document.getElementById(`voicePermBtn`),H.adjustInputHeight=typeof e.adjustInputHeight==`function`?e.adjustInputHeight:null,!H.input||!H.btn){a.debug(`[Voice] input or button missing, skip init`);return}hl(),Sl(!1),gl(r(`voice.listening`)),await ql(),H.btn.addEventListener(`click`,e=>{e.preventDefault(),Vl()}),document.getElementById(`voiceCancelBtn`)?.addEventListener(`click`,e=>{e.preventDefault(),Rl({rollback:!0})}),document.getElementById(`voiceDoneBtn`)?.addEventListener(`click`,e=>{e.preventDefault(),Ll(`stop`)}),H.permBtn?.addEventListener(`click`,e=>{e.preventDefault();try{chrome.runtime.sendMessage({type:`OPEN_OPTIONS_PAGE`,hash:`asr`}).catch?.(()=>{})}catch{}gl(r(`voice.micDeniedHelp`),`warn`),vl(!1)}),H.input.addEventListener(`input`,()=>{H.programmatic||(H.phase===`recording`||H.phase===`finalizing`)&&ll()}),chrome.runtime.onMessage.addListener((e,t,n)=>e?.type===`VOICE_TOGGLE`?(Vl(),n?.({success:!0}),!1):(e?.type===`ASR_STATUS_CHANGED`&&cl(),!1)),window.addEventListener(`pagehide`,()=>{Wl()}),document.addEventListener(`visibilitychange`,()=>{document.hidden&&H.phase===`recording`&&Wl()}),await cl()&&await Gl()&&setTimeout(()=>{Vl()},220)}var Yl=`panel_`+Date.now().toString(36)+`_`+Math.random().toString(36).slice(2,8),Xl=new Set,Zl=new Set,Ql=null,$l=new Map,eu=`queue-context-cleared`,tu=`queue-context-restored`;function nu(e){Ql=e}function ru(e){return N.generatingSessionIds.has(e||N.activeSessionId)}function iu(){return{quotedContextText:N.quotedContextText||``,selectedContextText:N.selectedContextText||``,selectedSkills:(N.selectedSkills||[]).slice(),selectedMcpServices:(N.selectedMcpServices||[]).slice(),knowledgeRefs:(N.knowledgeRefs||[]).slice(),selectedPage:N.selectedPage?{...N.selectedPage}:null,attachedImages:(N.attachedImages||[]).slice(),attachedFiles:(N.attachedFiles||[]).slice()}}function au(e){return e?e.attachmentSummary||(e.attachedImages||[]).length||(e.attachedFiles||[]).length?!0:!!(e.quotedContextText&&e.quotedContextText.trim()||e.selectedContextText&&e.selectedContextText.trim()||(e.selectedSkills||[]).length||(e.selectedMcpServices||[]).length||(e.knowledgeRefs||[]).length||e.selectedPage):!1}function ou(){return au(iu())}function su(){let e=iu();return au(e)&&lu(),e}function cu(e){e&&(e.quotedContextText&&(N.quotedContextText=e.quotedContextText),e.selectedContextText&&(N.selectedContextText=e.selectedContextText),(e.selectedSkills||[]).length&&(N.selectedSkills=e.selectedSkills.slice()),(e.selectedMcpServices||[]).length&&(N.selectedMcpServices=e.selectedMcpServices.slice()),(e.knowledgeRefs||[]).length&&(N.knowledgeRefs=e.knowledgeRefs.slice()),e.selectedPage&&(N.selectedPage={...e.selectedPage}),(e.attachedImages||[]).length&&(N.attachedImages=e.attachedImages.slice()),(e.attachedFiles||[]).length&&(N.attachedFiles=e.attachedFiles.slice()))}function lu(){let e=(N.attachedImages||[]).length>0;if(N.quotedContextText=``,N.selectedContextText=``,N.selectedSkills=[],N.selectedMcpServices=[],N.knowledgeRefs=[],N.selectedPage=null,N.attachedImages=[],N.attachedFiles=[],e){let e=document.getElementById(`imagePreviewBar`);e&&(e.innerHTML=``,e.style.display=`none`)}document.dispatchEvent(new CustomEvent(eu))}var uu=new Set([`pending`,`extracting`]);function du(){return(N.attachedFiles||[]).some(e=>uu.has(e&&e.status))}function fu(e){let t=e&&e.attachedImages||[],n=(e&&e.attachedFiles||[]).map(e=>{if(!e||typeof e.dataUrl!=`string`||!e.dataUrl.startsWith(`blob:`))return e;let t={...e};return delete t.dataUrl,t}),r={...e||{}};return delete r.attachedImages,delete r.attachedFiles,r.attachmentSummary=ai({attachedImages:t,attachedFiles:n}),{light:r,heavy:t.length||n.length?{images:t,files:n}:null}}async function pu(e){if(!e)return{ok:!1,attachments:!1,wantsAttachments:!1};let t=await si(e.id)||$l.get(e.id)||null,n=!!(e.attachmentSummary||e.contextSnapshot&&e.contextSnapshot.attachmentSummary);return cu({...e.contextSnapshot||{},attachedImages:t&&t.images||[],attachedFiles:t&&t.files||[]}),document.dispatchEvent(new CustomEvent(tu,{detail:{snapshot:e.contextSnapshot||{}}})),{ok:!0,attachments:!!t,wantsAttachments:n}}async function mu(e){return e?($l.delete(e),ci(e)):!1}async function hu({autoDrain:e=!0}={}){let t=document.getElementById(`userInput`),n=(t?.value||``).trim();if(!n)return{ok:!1,error:`empty`};Wl();let i=N.activeSessionId;if(!i)return P(r(`queue.noSession`),`error`),{ok:!1,error:`missing_session`};if(du())return P(r(`queue.filesStillExtracting`),`warning`,4e3),{ok:!1,error:`files_extracting`};let a=su(),{light:o,heavy:s}=fu(a),c=await Pr({sessionId:i,text:n,contextSnapshot:o,hasContext:au(o),attachmentSummary:o.attachmentSummary,source:`manual`});return c.ok?(s&&((await oi(c.item.id,i,s)).ok||($l.set(c.item.id,s),P(r(`queue.attachmentsVolatile`),`warning`,5e3))),t&&(t.value=``,t.style.height=`auto`,t.dispatchEvent(new Event(`input`)),t.focus()),P(r(`queue.enqueued`,{position:c.position}),`success`),document.dispatchEvent(new CustomEvent(`queue-enqueued`,{detail:{sessionId:i,item:c.item}})),e&&!ru(i)&&!Nr(i)&&_u(i),c):(cu(a),document.dispatchEvent(new CustomEvent(tu,{detail:{snapshot:a}})),c.error===`queue_full`?P(r(`queue.queueFull`,{limit:c.limit}),`warning`):P(r(`queue.enqueueFailed`),`error`),c)}async function gu(e){try{let{list:t}=await gi(),n=(t||[]).find(t=>t.id===e);return n?{messageHistory:Array.isArray(n.messageHistory)?n.messageHistory.slice():[],model:n.model,useTools:n.useTools,enabledTools:Array.isArray(n.enabledTools)?n.enabledTools.slice():n.enabledTools,agentId:n.agentId,temperature:n.temperature,topP:n.topP,contextCompaction:n.contextCompaction,workdir:n.workdir||null,workdirAgentId:n.workdirAgentId||null}:null}catch(e){return a.warn(`[QueueRunner] load session state failed:`,e?.message||e),null}}async function _u(e){let t=e||N.activeSessionId;if(!(!t||!Ql)){if(Xl.has(t)){Zl.add(t);return}Xl.add(t);try{do Zl.delete(t),await vu(t);while(Zl.has(t)&&!Nr(t))}finally{Xl.delete(t)}}}async function vu(e){if(ru(e)||Nr(e))return;let t=kr(e);if(!t)return;if((t.attempts||0)>=5){await Br(e,t.id,{status:R.FAILED,note:`too_many_attempts`}),P(r(`queue.tooManyAttempts`,{count:5}),`error`,5e3);return}if(!await Kr(e,t.id,Yl)){a.debug(`[QueueRunner] lease held by another panel, skip:`,t.id);return}await Lr(e,t.id,R.DISPATCHING,{attempts:(t.attempts||0)+1,lastError:null});let n=await si(t.id)||$l.get(t.id)||null;$l.delete(t.id);let i=!!t.attachmentSummary&&!n;i&&P(r(`queue.attachmentsMissing`),`warning`,5e3);let o={quotedContextText:``,selectedContextText:``,selectedSkills:[],selectedMcpServices:[],knowledgeRefs:[],selectedPage:null,...t.contextSnapshot||{},attachedImages:n&&n.images||[],attachedFiles:n&&n.files||[]},s=e===N.activeSessionId,c=null;if(!s&&(c=await gu(e),!c)){let t=await qr(e);t&&a.warn(`[QueueRunner] dropped queue of deleted session:`,e,t);return}let l={ok:!0};try{let n={text:t.text,fromQueue:!0,sessionId:e,context:o};s||(n.sessionState=c),l=await Ql(n)||{ok:!0}}catch(e){l={ok:!1,reason:e?.message||`dispatch_error`},a.error(`[QueueRunner] dispatch failed:`,e?.message||e)}jr(e,t.id)?l.ok===!1?l.delivered?(await Br(e,t.id,{status:R.FAILED,note:l.reason||`failed`}),await ci(t.id)):(await zr(e,t.id,`dispatch_failed`,l.reason||`dispatch_failed`),Zl.delete(e)):(await Br(e,t.id,{status:R.DONE,note:i?`relayed_no_attachments`:`relayed`}),await ci(t.id)):a.debug(`[QueueRunner] item removed during dispatch, drop result:`,t.id)}var yu=new Set;function bu(e){let t=e||N.activeSessionId;return t?(yu.add(t),t):null}function xu(e){let t=e||N.activeSessionId;return!!(t&&kr(t))}async function Su(e){let t=e||N.activeSessionId;t&&(yu.delete(t),await Gr(t),await _u(t))}function Cu(e){Nr(e)||_u(e)}var wu=new Map,Tu=new Set,Eu=new Map,Du=new Map;function Ou(e){let t=e&&e.attachmentSummary;return t?(t.imageCount||0)>0||(t.fileCount||0)>0:!1}function ku(e,t){return`${e}\u0000${t}`}function Au(e,t){let n=ku(e,t),r=wu.get(n);r&&(clearTimeout(r),wu.delete(n))}async function ju(e,t,n,r){Au(e,t);let i=jr(e,t);!i||i.status!==R.INJECTING||(await zr(e,t,n,n),r&&P(r,`warning`,4e3))}function Mu(e,t,n){return new Promise(r=>{let i=!1,a=e=>{i||(i=!0,r(e))},o=setTimeout(()=>a(null),2e3);try{chrome.runtime.sendMessage({type:`INJECT_MESSAGE`,sessionId:e,itemId:t,text:n},e=>{if(clearTimeout(o),chrome.runtime.lastError){a(null);return}a(e||null)})}catch{clearTimeout(o),a(null)}})}async function Nu(e,t,n={}){let i=t||N.activeSessionId,a=n.auto===!0;if(!i||!e)return{ok:!1,error:`missing_session`};let o=jr(i,e);if(!o)return{ok:!1,error:`not_found`};if(o.status!==R.QUEUED)return{ok:!1,error:`not_queued`};if(Ou(o))return a||P(r(`queue.injectNoAttachments`),`warning`,4e3),{ok:!1,error:`has_attachments`};let s=ku(i,e);if(Tu.has(s))return{ok:!1,error:`in_flight`};Tu.add(s);try{await Rr(i,e),wu.set(s,setTimeout(()=>{ju(i,e,`timeout`,r(`queue.injectTimeout`))},$n));let t=await Mu(i,e,o.text);if(!t)return{ok:!0,pending:!0};if(!t.accepted){let n=t.reason||`rejected`;return await ju(i,e,n,r(n===`no_running_task`?`queue.injectNoTask`:`queue.injectFailed`)),{ok:!1,error:n}}return a?i===N.activeSessionId&&P(r(`queue.autoCarried`,{iteration:n.iteration??`?`}),`success`,2500):P(r(`queue.injectAccepted`),`success`,2500),{ok:!0,pending:!0}}finally{Tu.delete(s)}}function Pu(e){let t=document.getElementById(`userInput`);t&&t.value.trim()===e&&(t.value=``,t.style.height=`auto`,t.dispatchEvent(new Event(`input`)),t.focus())}async function Fu(e){let t=N.activeSessionId,n=String(e||``).trim();if(!t||!n)return{ok:!1,error:`empty`};if(Wl(),!ru(t))return P(r(`queue.injectNoTask`),`warning`,3e3),{ok:!1,error:`no_running_task`};let i=`adhoc_`+Date.now().toString(36)+`_`+Math.random().toString(36).slice(2,7),a=setTimeout(()=>{Eu.has(i)&&(Eu.delete(i),P(r(`queue.injectTimeoutAdhoc`),`warning`,4e3))},$n);Eu.set(i,{text:n,timer:a});let o=await Mu(t,i,n);return o&&!o.accepted?(clearTimeout(a),Eu.delete(i),P(o.reason===`no_running_task`?r(`queue.injectNoTask`):r(`queue.injectFailed`),`warning`,4e3),{ok:!1,error:o.reason}):(o&&o.accepted&&P(r(`queue.injectAccepted`),`success`,2500),{ok:!0,pending:!0})}function Iu(e){let t=e?.sessionId,n=Array.isArray(e?.items)?e.items:[];if(!t||n.length===0)return;let i=0;for(let r of n){let n=Eu.get(r);if(n){clearTimeout(n.timer),Eu.delete(r),Pu(n.text);continue}Au(t,r),jr(t,r)&&(i++,Br(t,r,{status:R.INJECTED,note:`injected`,callId:e.callId||null,iteration:e.iteration??null}))}i>0&&t===N.activeSessionId&&P(r(`queue.injected`),`success`,2500),document.dispatchEvent(new CustomEvent(`queue-injected`,{detail:{sessionId:t,items:n,iteration:e.iteration??null}}))}function Lu(e){let t=e?.sessionId,n=Array.isArray(e?.items)?e.items:[];if(!t||n.length===0)return;let i=e.reason||`rejected`,a=r(i===`task_ended`?`queue.injectNoTask`:`queue.injectFailed`);for(let e of n){let r=Eu.get(e);if(r){clearTimeout(r.timer),Eu.delete(e);continue}ju(t,e,i,e===n[0]?a:null)}}function Ru(e){let t=e?.sessionId;if(!t||e.isSubtask===!0||Nr(t))return;let n=Uc(e.executionLog);if(!n)return;let r=kr(t),i=r&&!Ou(r)?r:null,o=N.chatConfig||{},s=Wc({tracker:Du.get(t),callId:e.callId||null,iteration:n,everyN:o.queueAutoCarryEveryNIterations,enabled:o.queueAutoCarry!==!1,hasCandidate:!!i});if(Du.set(t,s.tracker),!s.carry)return;a.debug(`[QueueRunner] auto carry item`,i.id,`at iteration`,n,`session`,t);let c=e.callId||null;Nu(i.id,t,{auto:!0,iteration:n}).then(e=>{!e||e.ok!==!0||Du.set(t,Gc(Du.get(t),{callId:c}))})}function zu(e){!e||typeof e!=`object`||(e.type===`INJECT_ABSORBED`?Iu(e):e.type===`INJECT_REJECTED`?Lu(e):e.type===`EXECUTION_STATUS_UPDATE`&&Ru(e))}async function Bu(){try{if(xr()){a.warn(`[QueueRunner] skip attachment prune in degraded mode`);return}let e=new Set;for(let t of Mr())for(let n of Tr(t))e.add(n.id);let t=await ui(e);t&&a.debug(`[QueueRunner] pruned orphan attachments:`,t)}catch(e){a.warn(`[QueueRunner] prune orphan attachments failed:`,e?.message||e)}}var Vu=!1,Hu=null,Uu=[];function Wu(e,t){document.addEventListener(e,t),Uu.push([e,t])}var Gu=1500;function Ku(e){return new Promise(t=>{let n=!1,r=e=>{n||(n=!0,t(e))},i=setTimeout(()=>r(null),Gu);try{chrome.runtime.sendMessage({type:`QUERY_SESSION_RUNNING`,sessionId:e},e=>{if(clearTimeout(i),chrome.runtime.lastError){r(null);return}r(!!(e&&e.running))})}catch{clearTimeout(i),r(null)}})}async function qu(){if(!N.activeSessionId)return!1;let e=Mr();if(e.length===0)return!0;let t=!1;for(let n of e){if(Nr(n)||ru(n)||!kr(n))continue;let e=await Ku(n);if(e===null){t=!0;continue}if(!e&&!(Nr(n)||ru(n)))return await _u(n),!0}return!t}function Ju(){if(Hu)return;let e=0,t=async()=>{if(Hu=null,++e>25)return;let n=!1;try{n=await qu()}catch(e){a.warn(`[QueueRunner] auto-resume attempt failed:`,e?.message||e)}n||(Hu=setTimeout(t,800))};Hu=setTimeout(t,300)}async function Yu({autoResume:e=!0}={}){Vu||(Vu=!0,await Sr(),Cr(),Bu(),zc(Cu),typeof chrome<`u`&&chrome.runtime?.onMessage?.addListener&&chrome.runtime.onMessage.addListener(zu),Wu(`task-stop-requested`,e=>{let t=e?.detail?.sessionId||N.activeSessionId;if(t){if(yu.delete(t)){Gr(t).then(()=>_u(t));return}Wr(t,`user_stopped`)}}),Wu(`generating-state-changed`,()=>{let e=N.activeSessionId;if(e){if(N.isGenerating&&Nr(e)){Gr(e);return}for(let e of Mr())if(!(Nr(e)||ru(e))&&kr(e)){_u(e);break}}}),Wu(`session-switched`,()=>Ju()),Wu(`visibilitychange`,()=>{document.visibilityState===`visible`&&Ju()}),e&&Ju())}async function Xu(e){let t=e||N.activeSessionId;t&&(await Gr(t),await _u(t))}var Zu=`combo-collapsed`,Qu=`summary-collapsed`,$u=`summary-wrapped`,ed=[Zu,Qu,$u];function td(e){if(!e)return;let t=e.querySelector(`.log-summary`);t&&(t.classList.remove(...ed),!(t.scrollWidth<=t.clientWidth)&&(t.classList.add(Zu),!(t.scrollWidth<=t.clientWidth)&&(t.classList.add(Qu),!(t.scrollWidth<=t.clientWidth)&&t.classList.add($u))))}var nd=null,rd=0,id=!1;function ad(e){e&&(nd=e,od(),!rd&&(rd=requestAnimationFrame(()=>{rd=0;let e=nd;nd=null,e&&td(e)})))}function od(){id||typeof window>`u`||(id=!0,window.addEventListener(`resize`,()=>{let e=document.querySelector(`.execution-log-panel`);e&&ad(e)}))}n(`zh`,{execLog:{statusSuccess:`成功`,statusFailed:`失败`,statusProcessing:`处理中`,unknownNode:`未知节点`,sequentialExecution:`顺序执行`,parallelExecution:`并行执行`,subtaskCountStrategy:`{count}个子任务, {strategy}`,messageCountTitle:`本次模型API调用携带的消息数`,toolCountTitle:`本次模型API调用携带的工具定义数`,messageCount:`{count}条`,toolCount:`{count}个`,durationTitle:`耗时`,sectionThought:`💡 思考`,sectionToolCall:`⚡ 工具调用`,labelTool:`工具:`,labelParams:`参数:`,sectionFilterResult:`🔍 筛选结果`,labelSelectedTools:`选中工具:`,labelCount:`数量:`,unitItems:`个`,sectionObservation:`📝 观察结果`,sectionApiRequest:`📡 API 请求`,labelModel:`模型:`,labelTemperature:`温度:`,labelTopP:`top_p:`,labelMessageCount:`消息数:`,labelToolCount:`工具数:`,sectionApiResponse:`📤 API 响应`,labelFinishReason:`完成原因:`,labelFilteredToolCount:`筛选后工具数:`,labelTokenUsage:`Token 使用:`,sectionError:`❌ 错误信息`,sectionSubtaskResult:`✅ 子任务结果`,sectionSubtaskDesc:`📝 任务描述`,subtaskPendingNode:`(待执行)`,sectionReflectionPrompt:`📊 评估提示词`,sectionReflectionRaw:`📤 评估结果(原始响应)`,sectionTokenUsage:`📊 Token 使用`,overallScore:`⭐ 综合评分: {score}/10`,sectionIssues:`📋 发现的问题`,sectionSuggestions:`💡 改进建议`,labelDecision:`🎯 决策: {decision}`,decisionPassed:`✅ 通过`,decisionRevised:`🔧 已修订`,decisionNeedsImprovement:`⚠️ 需改进`,resultUseful:`✅ 结果有用`,resultInvalid:`⚠️ 结果无效`,labelSuggestion:`建议: {suggestion}`,mainTask:`主任务`,stepCount:`({count} 步骤)`,processingDots:`处理中...`,waitingExecution:`等待执行中...`,realtimeLogTitle:`实时执行日志`,executingLabel:`执行中:`,preparing:`准备中...`,totalNodes:`总节点`,labelSuccess:`成功`,labelFailed:`失败`,labelSubtask:`子任务`,expandAll:`展开全部节点`,collapseAll:`收起全部节点`,sectionUserInjection:`💬 插话内容`}}),n(`en`,{execLog:{statusSuccess:`Success`,statusFailed:`Failed`,statusProcessing:`Processing`,unknownNode:`Unknown node`,sequentialExecution:`sequential`,parallelExecution:`parallel`,subtaskCountStrategy:`{count} subtasks, {strategy}`,messageCountTitle:`Number of messages carried in this model API call`,toolCountTitle:`Number of tool definitions carried in this model API call`,messageCount:`{count} msgs`,toolCount:`{count} tools`,durationTitle:`Duration`,sectionThought:`💡 Thought`,sectionToolCall:`⚡ Tool Call`,labelTool:`Tool:`,labelParams:`Params:`,sectionFilterResult:`🔍 Filter Result`,labelSelectedTools:`Selected tools:`,labelCount:`Count:`,unitItems:``,sectionObservation:`📝 Observation`,sectionApiRequest:`📡 API Request`,labelModel:`Model:`,labelTemperature:`Temperature:`,labelTopP:`top_p:`,labelMessageCount:`Messages:`,labelToolCount:`Tools:`,sectionApiResponse:`📤 API Response`,labelFinishReason:`Finish reason:`,labelFilteredToolCount:`Filtered tool count:`,labelTokenUsage:`Token Usage:`,sectionError:`❌ Error`,sectionSubtaskResult:`✅ Subtask Result`,sectionSubtaskDesc:`📝 Task Description`,subtaskPendingNode:`(pending)`,sectionReflectionPrompt:`📊 Reflection Prompt`,sectionReflectionRaw:`📤 Reflection Result (raw)`,sectionTokenUsage:`📊 Token Usage`,overallScore:`⭐ Overall Score: {score}/10`,sectionIssues:`📋 Issues Found`,sectionSuggestions:`💡 Suggestions`,labelDecision:`🎯 Decision: {decision}`,decisionPassed:`✅ Passed`,decisionRevised:`🔧 Revised`,decisionNeedsImprovement:`⚠️ Needs Improvement`,resultUseful:`✅ Useful`,resultInvalid:`⚠️ Invalid`,labelSuggestion:`Suggestion: {suggestion}`,mainTask:`Main Task`,stepCount:`({count} steps)`,processingDots:`Processing...`,waitingExecution:`Waiting for execution...`,realtimeLogTitle:`Real-time Execution Log`,executingLabel:`Executing:`,preparing:`Preparing...`,totalNodes:`Total nodes`,labelSuccess:`Success`,labelFailed:`Failed`,labelSubtask:`Subtask`,expandAll:`Expand all nodes`,collapseAll:`Collapse all nodes`,sectionUserInjection:`💬 Your interjection`}});function sd(e){if(e?.nodeType!==`tool_exec`||!e?.action)return``;let t=e.action.name||``,n=e.action.params;if(n==null)return``;if(typeof n==`string`&&(n=(()=>{try{return JSON.parse(n)}catch{return{raw:n}}})()),typeof n!=`object`)return String(n).trim();if(t===`execute_command`||t===`agent_exec`)return(n.command||n.cmd||``).toString().trim();if(t===`agent_file`||t===`file_upload`||t===`download_file`){let e=(n.file_path||n.filePath||n.path||n.filename||n.fileName||n.url||``).toString().trim();if(e)return e}if(t===`fetch_url`||t===`interact_element`||t===`fill_form`||t===`manage_tab`||t===`preview_ui`){let e=(n.url||n.href||n.selector||``).toString().trim();if(e)return e}if(t===`search_browser_data`||t===`search_in_page`||t===`exec_log`){let e=(n.query||n.keyword||n.text||``).toString().trim();if(e)return e}if(t===`dispatch_task`){let e=(n.task||``).toString().trim();if(e)return e}if(t===`agent_memory`){let e=(n.action||n.subAction||``).toString().trim();if(e)return e}let r=[`content`,`text`,`prompt`,`description`,`markdown`,`html`,`css`,`js`,`code`,`script`,`data`],i=Object.keys(n).filter(e=>n[e]!=null&&n[e]!==``&&!r.includes(e));if(i.length===0)return``;if(i.length===1){let e=String(n[i[0]]);return`${i[0]}: ${e}`}return i.slice(0,2).map(e=>`${e}=${JSON.stringify(n[e])}`).join(`, `)}function cd(e){return sd(e)}function ld(e){let t=Array.isArray(e)?e:[],n=t.filter(e=>e&&e.nodeType===`subtask_plan`&&Array.isArray(e.items));if(n.length===0)return t;let i=t.filter(e=>e&&e.nodeType!==`subtask_plan`),a=new Set(i.filter(e=>e.nodeType===`subtask`&&typeof e.subtaskIndex==`number`).map(e=>e.subtaskIndex)),o=new Map;n.forEach(e=>{e.items.forEach(t=>{!t||typeof t.index!=`number`||o.set(t.index,{item:t,plan:e})})});let s=[];return Array.from(o.keys()).sort((e,t)=>e-t).forEach(e=>{if(a.has(e))return;let{item:t,plan:n}=o.get(e),i=r(`execLog.subtaskPendingNode`);s.push({id:`plan_pending_${n.id||`x`}_${e}`,nodeType:`subtask`,status:`pending`,iteration:0,timestamp:n.timestamp,subtaskIndex:e,subtaskId:t.id,subtaskName:t.name,description:t.description||``,nodeName:t.name?`${t.name} ${i}`:i,taskGroup:`subtask_group_${e}`,taskGroupIndex:e+1,taskGroupName:t.name,isSubtask:!0})}),i.concat(s)}function ud(e,t){let n=e=>e.status===`pending`?2**53-1:new Date(e.timestamp).getTime();return n(e)-n(t)}function dd(e){let t=ld(e).sort(ud),n=t.length,i=``,a=null;return t.forEach((e,t)=>{let o=e.nodeType===`subtask`,s=e.nodeType===`tool_exec`,c=e.nodeType===`api_call`,l=e.nodeType===`preselect`,u=e.nodeType===`reflection`,d=e.nodeType===`user_injection`,f=s&&e.action?.name===`plan_task`;o&&(a=e.subtaskIndex);let p=``,m=``;d?m=`💬`:u?m=`🎯`:l?m=`🔍`:f?(p=`plan-task-level`,m=`📋`):o?(p=`subtask-level`,m=`🔀`):s&&a!==null?(p=`tool-level`,m=`🔧`):c&&a!==null?(p=`api-level`,m=`📡`):s?m=`⚡`:c&&(m=`📡`);let h=`○`,g=e.status||`processing`;e.status===`success`?h=`✓`:e.status===`failed`&&(h=`✗`),u&&(g=`reflection ${g}`);let _=F(e.nodeName||r(`execLog.unknownNode`));if(e.subtaskIndex!==null&&e.subtaskIndex>=0&&(_=`<span class="subtask-badge">${e.subtaskIndex+1}</span> ${_}`),e.subtaskCount&&(_+=` <span class="plan-badge">(${r(`execLog.subtaskCountStrategy`,{count:e.subtaskCount,strategy:e.strategy===`sequential`?r(`execLog.sequentialExecution`):r(`execLog.parallelExecution`)})})</span>`),(c||l||u)&&e.apiRequest){let t=[];e.apiRequest.messageCount!==void 0&&e.apiRequest.messageCount!==null&&t.push(`💬<span title="${r(`execLog.messageCountTitle`)}">${r(`execLog.messageCount`,{count:e.apiRequest.messageCount})}</span>`),!l&&e.apiRequest.toolCount!==void 0&&e.apiRequest.toolCount!==null&&t.push(`🔧<span title="${r(`execLog.toolCountTitle`)}">${r(`execLog.toolCount`,{count:e.apiRequest.toolCount})}</span>`),t.length>0&&(_+=` <span class="api-info-badge">(${t.join(` `)})</span>`)}if(s){let t=cd(e);t&&(_+=` <span class="node-cmd-preview" title="${L(t)}">${F(t)}</span>`)}i+=`
|
|
92
|
+
`}).join(``),t.querySelectorAll(`.prototype-library-item`).forEach(e=>{let t=e.querySelector(`.prototype-library-item-info`),n=e.querySelector(`.prototype-library-item-open`),i=e.querySelector(`.prototype-library-item-local-open`),o=e.querySelector(`.prototype-library-item-optimize`),s=e.querySelector(`.prototype-library-item-delete`),c=e.querySelector(`.prototype-library-item-download`);t&&t.addEventListener(`click`,()=>{let t=e.dataset.id;Ms(t)}),n&&n.addEventListener(`click`,t=>{t.stopPropagation();let n=e.dataset.id;Ms(n)}),i&&i.addEventListener(`click`,e=>{e.stopPropagation();let t=i.dataset.path;chrome.runtime.sendMessage({type:`OPEN_LOCAL_PROTOTYPE`,path:t},e=>{e?.success||a.error(`[SidePanel] local browseropen failed:`,e?.error)})}),o&&o.addEventListener(`click`,t=>{t.stopPropagation();let n=o.dataset.id;Rs(n,e.querySelector(`.prototype-library-item-title`)?.textContent||r(`uiProto.defaultTitle`)),Ls()}),s&&s.addEventListener(`click`,t=>{t.stopPropagation();let n=s.dataset.id;Bs(n,e.querySelector(`.prototype-library-item-title`)?.textContent||r(`uiProto.defaultTitle`))}),c&&c.addEventListener(`click`,e=>{e.stopPropagation();let t=c.dataset.id;zs(t)})})))}function Is(e){let t=()=>{let t=document.getElementById(`prototypeLibrarySearch`),n=document.getElementById(`prototypeLibrarySort`),r=(t?.value||``).trim().toLowerCase(),i=n?.value||`createdAt_desc`,a=e;r&&(a=e.filter(e=>(e.title||``).toLowerCase().includes(r)||(e.description||``).toLowerCase().includes(r)));let[o,s]=i.split(`_`);a=[...a].sort((e,t)=>{let n;return n=o===`title`?(e.title||``).localeCompare(t.title||``,`zh-CN`):(e.createdAt||0)-(t.createdAt||0),s===`desc`?-n:n}),Fs(a)},n=document.getElementById(`prototypeLibrarySearch`),r=document.getElementById(`prototypeLibrarySort`);if(n){let e=n.cloneNode(!0);n.parentNode.replaceChild(e,n),e.addEventListener(`input`,t)}if(r){let e=r.cloneNode(!0);r.parentNode.replaceChild(e,r),e.addEventListener(`change`,t)}}function Ls(){let e=document.getElementById(`prototypeLibraryModal`);e&&e.classList.remove(`show`),a.debug(`[SidePanel] prototype page libraryhidden`)}function Rs(e,t){let n=document.getElementById(`userInput`);n&&(n.value=r(`uiProto.optimizePrompt`,{id:e,title:t}),n.focus(),n.style.height=`auto`,n.style.height=n.scrollHeight+`px`),a.debug(`[SidePanel] from prototype page librarycontinue optimizeprototype:`,e)}async function zs(e){try{let t=await fe(e);if(!t||!t.html){a.error(`[SidePanel] download prototype failed:not foundprototype`,e);return}let n=Es(t.html),r=new Blob([n],{type:`text/html`}),i=URL.createObjectURL(r),o=document.createElement(`a`);o.href=i,o.download=(t.title||`prototype`).replace(/[^a-zA-Z0-9\u4e00-\u9fa5_-]/g,`_`)+`.html`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i),a.debug(`[SidePanel] prototype fromprototypelibrarydownload:`,o.download)}catch(e){a.error(`[SidePanel] download prototype failed:`,e)}}async function Bs(e,t){if(await Vs(r(`uiProto.confirmDeleteTitle`),r(`uiProto.confirmDeleteMessage`,{title:t}),r(`common.delete`)))try{let t=await fe(e);await Se(e),a.debug(`[SidePanel] prototype deleted:`,e),t?.localPath&&chrome.runtime.sendMessage({type:`DELETE_LOCAL_PROTOTYPE`,path:t.localPath},e=>{e?.success?a.debug(`[SidePanel] local prototypefile deleted:`,t.localPath):a.warn(`[SidePanel] local prototypefiledelete failed:`,e?.error)}),Ps()}catch(e){a.error(`[SidePanel] delete prototype failed:`,e),alert(r(`uiProto.deleteFailed`,{message:e.message}))}}function Vs(e,t,n=r(`common.confirm`)){return new Promise(r=>{let i=document.getElementById(`genericConfirmModal`),a=document.getElementById(`genericConfirmTitle`),o=document.getElementById(`genericConfirmMessage`),s=document.getElementById(`genericConfirmOkBtn`),c=document.getElementById(`genericConfirmCancelBtn`);if(!i){r(confirm(t));return}a.textContent=e,o.textContent=t,s.textContent=n;let l=()=>{i.classList.remove(`show`),s.removeEventListener(`click`,u),c.removeEventListener(`click`,d)},u=()=>{l(),r(!0)},d=()=>{l(),r(!1)};s.addEventListener(`click`,u),c.addEventListener(`click`,d),i.classList.add(`show`)})}function Hs(e){let t=document.createElement(`div`);return t.textContent=e,t.innerHTML}function Us(e){if(!e)return``;let t=new Date(e),n=new Date-t;return n<6e4?r(`uiProto.justNow`):n<36e5?r(`uiProto.minutesAgo`,{count:Math.floor(n/6e4)}):n<864e5?r(`uiProto.hoursAgo`,{count:Math.floor(n/36e5)}):t.toLocaleDateString(`zh-CN`)}function Ws(e){Ss=Math.max(Cs,Math.min(ws,e)),Ss=Math.round(Ss*100)/100;let t=document.getElementById(`prototypeIframe`),n=document.getElementById(`prototypeZoomLevel`);t&&(t.style.zoom=Ss),n&&(n.textContent=Math.round(Ss*100)+`%`,Ss===1?n.classList.remove(`zoomed`):n.classList.add(`zoomed`))}function Gs(){Ws(Ss+Ts),Js()}function Ks(){Ws(Ss-Ts),Js()}function qs(){Ws(1)}function Js(){let e=document.getElementById(`prototypeZoomLevel`);e&&(e.classList.add(`flash`),setTimeout(()=>e.classList.remove(`flash`),150))}function Ys(e){!e.ctrlKey&&!e.metaKey||(e.preventDefault(),e.deltaY<0?Gs():Ks())}function Xs(e){(e.ctrlKey||e.metaKey)&&e.key===`0`&&(e.preventDefault(),qs())}function Zs(){let e=document.getElementById(`prototypeCloseBtn`);e&&e.addEventListener(`click`,Os);let t=document.getElementById(`prototypeDownloadBtn`);t&&t.addEventListener(`click`,As);let n=document.getElementById(`prototypeOpenTabBtn`);n&&n.addEventListener(`click`,js);let r=document.getElementById(`prototypeLocalOpenBtn`);r&&r.addEventListener(`click`,()=>{let e=r.dataset.path;e&&chrome.runtime.sendMessage({type:`OPEN_LOCAL_PROTOTYPE`,path:e},e=>{e?.success||a.error(`[SidePanel] local browseropen failed:`,e?.error)})});let i=document.getElementById(`prototypeContinueBtn`);i&&i.addEventListener(`click`,ks);let o=document.getElementById(`prototypeZoomInBtn`);o&&o.addEventListener(`click`,Gs);let s=document.getElementById(`prototypeZoomOutBtn`);s&&s.addEventListener(`click`,Ks);let c=document.getElementById(`prototypeZoomLevel`);c&&c.addEventListener(`click`,qs);let l=document.getElementById(`prototypeContent`);l&&l.addEventListener(`wheel`,Ys,{passive:!1}),document.addEventListener(`keydown`,Xs);let u=document.getElementById(`prototypeLibraryCloseBtn`);u&&u.addEventListener(`click`,Ls),chrome.runtime.onMessage.addListener((e,t,n)=>{e.type===`SHOW_UI_PROTOTYPE`&&(a.debug(`[SidePanel] received showprototyperequested :`,e),e.data.localOpened?a.debug(`[SidePanel] prototype inagent-side browseropen,skip popup`):e.data.isRemoteAgent?(a.debug(`[SidePanel] remoteagent,will use browserlabelpageautoopenprototype`),Ns(e.data.prototypeId)):Ms(e.data.prototypeId),n({success:!0}))}),a.debug(`[SidePanel] UI prototype moduleeventinitializing`)}var Qs={enabled:!1,thresholdRatio:.85,minPending:4,maxFailures:2};function $s(e,t){let n=Number(e);return Number.isFinite(n)&&n>0&&n<=1?n:t}function ec(e,t){let n=Number(e);return Number.isFinite(n)&&n>=0?Math.floor(n):t}function tc({enabled:e,ratio:t,thresholdRatio:n,pendingCount:r,minPending:i,isGenerating:a,isolateChat:o}={}){if(!e||a||!o)return!1;let s=$s(n,Qs.thresholdRatio),c=ec(i,Qs.minPending);return!Number.isFinite(t)||t<s?!1:ec(r,0)>=c}function nc(e){let t=e?.messageHistory||[],n=e?.activeCompaction?.upToMessageId;if(!n)return t.length;let r=t.findIndex(e=>e.messageId===n);return r===-1?t.length:t.length-r-1}var rc=0;function ic(){rc=0}async function ac({state:e,getRatio:t,compact:n}={}){let r=e?.chatConfig||{},i=r.autoCompaction===!0;if(!i)return{attempted:!1,success:!1,reason:`disabled`};if(rc>=Qs.maxFailures)return{attempted:!1,success:!1,reason:`backoff`};let o;try{o=Number(t?t():NaN)}catch(e){return a.warn(`[AutoCompaction] usage compute failed, send continues:`,e?.message),{attempted:!1,success:!1,reason:`usage_unavailable`}}let s=nc(e);if(!tc({enabled:i,ratio:o,thresholdRatio:r.autoCompactionThreshold,pendingCount:s,isGenerating:!!e?.isGenerating,isolateChat:!!e?.isolateChat}))return{attempted:!1,success:!1,reason:`not_needed`};a.debug(`[AutoCompaction] triggered`,{ratio:o,pendingCount:s});let c=null;try{c=await n({silent:!0})}catch(e){return a.warn(`[AutoCompaction] compact threw, send continues:`,e?.message),rc++,{attempted:!0,success:!1,reason:`exception`}}return c?.success?(ic(),{attempted:!0,success:!0}):(rc++,a.debug(`[AutoCompaction] skipped send:`,c?.reason),{attempted:!0,success:!1,reason:c?.reason||`failed`})}var oc=null,sc=`global`,cc=new Map;function lc(){try{chrome.windows?.getCurrent?.().then?.(e=>{e?.id!=null&&(oc=e.id)}).catch?.(e=>{a.debug(`[PanelContext] query current window failed:`,e?.message)})}catch(e){a.debug(`[PanelContext] init window query failed:`,e?.message)}try{chrome.storage?.local?.get?.([`sidePanelScope`],e=>{sc=e?.sidePanelScope===`tab-specific`?`tab-specific`:`global`}),chrome.storage?.onChanged?.addListener?.((e,t)=>{t!==`local`||!e?.sidePanelScope||(sc=e.sidePanelScope.newValue===`tab-specific`?`tab-specific`:`global`)})}catch(e){a.debug(`[PanelContext] init scope mirror failed:`,e?.message)}}function uc(){return oc}function dc(e){e&&typeof N.currentTabId==`number`&&cc.set(e,N.currentTabId)}function fc(e,t){e&&(typeof t==`number`?cc.set(e,t):cc.delete(e))}function pc(e){if(!e)return null;let t=cc.get(e);return typeof t==`number`?t:null}function mc(e){let t=null;try{t=typeof document<`u`?!!document.hidden:null}catch{}return{windowId:oc,hostTabId:pc(e),scope:sc,panelHidden:t}}var hc=0,gc=500,_c=[{frequency:523.25,startTime:0,duration:.12,type:`sine`,gain:.3},{frequency:659.25,startTime:.09,duration:.12,type:`sine`,gain:.3},{frequency:783.99,startTime:.18,duration:.22,type:`sine`,gain:.35}],vc=[{frequency:440,startTime:0,duration:.16,type:`square`,gain:.22},{frequency:349.23,startTime:.14,duration:.3,type:`square`,gain:.22}],yc=[`#FF3B30`,`#FF9500`,`#FFCC00`,`#34C759`,`#00C7BE`,`#007AFF`,`#AF52DE`,`#FF2D55`],bc=120,xc=4e3,Sc=600,Cc=1e3,wc=.25,Tc=.99,Ec=.3,Dc=.6,Oc=9999;function kc(){return new Promise(e=>{try{chrome.storage.local.get([`completionSoundEnabled`,`completionConfettiEnabled`],t=>{e({soundEnabled:t?.completionSoundEnabled!==!1,confettiEnabled:t?.completionConfettiEnabled!==!1})})}catch(t){a.debug(`[CompletionFeedback] read config failed, use defaults:`,t?.message),e({soundEnabled:!0,confettiEnabled:!0})}})}function Ac(e){try{let t=window.AudioContext||window.webkitAudioContext;if(!t){a.debug(`[CompletionFeedback] AudioContext unavailable`);return}let n=new t;n.state===`suspended`&&typeof n.resume==`function`&&n.resume().catch(()=>{});let r=n.currentTime,i=0;for(let t of e){let e=n.createOscillator(),a=n.createGain();e.type=t.type||`sine`,e.frequency.value=t.frequency;let o=r+t.startTime,s=o+t.duration;a.gain.setValueAtTime(1e-4,o),a.gain.exponentialRampToValueAtTime(t.gain,o+.012),a.gain.exponentialRampToValueAtTime(1e-4,s),e.connect(a),a.connect(n.destination),e.start(o),e.stop(s+.02),s>i&&(i=s)}let o=Math.max(0,(i-r)*1e3)+200;setTimeout(()=>{try{n.close()}catch{}},o)}catch(e){a.debug(`[CompletionFeedback] play tone failed:`,e?.message)}}function jc(){Ac(_c),a.debug(`[CompletionFeedback] success sound played`)}function Mc(){Ac(vc),a.debug(`[CompletionFeedback] failure sound played`)}function Nc(){try{return typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}catch{return!1}}function Pc(){try{if(!document.body)return;let e=window.innerWidth,t=window.innerHeight;if(e<=0||t<=0)return;let n=document.createElement(`canvas`);n.style.cssText=`position:fixed;inset:0;pointer-events:none;z-index:${Oc};`;let r=window.devicePixelRatio||1;n.width=Math.floor(e*r),n.height=Math.floor(t*r),n.style.width=e+`px`,n.style.height=t+`px`,document.body.appendChild(n);let i=n.getContext(`2d`);if(!i){n.remove();return}i.scale(r,r);let o=[{x:e*.15,y:t+10,baseAngle:-Math.PI/2+Ec},{x:e*.85,y:t+10,baseAngle:-Math.PI/2-Ec}],s=[],c=0,l=0,u=performance.now(),d=e=>{let t=Math.min(bc,Math.floor(Math.min(e,Sc)/Sc*bc));for(;c<t;){let e=o[c%o.length],t=e.baseAngle+(Math.random()-.5)*Dc,n=12+Math.random()*8,r=4+Math.random()*4;s.push({x:e.x+(Math.random()-.5)*20,y:e.y,vx:Math.cos(t)*n,vy:Math.sin(t)*n,size:r,color:yc[Math.floor(Math.random()*yc.length)],rotation:Math.random()*Math.PI*2,rotationSpeed:(Math.random()-.5)*.3,shape:Math.random()<.5?`rect`:`circle`}),c++}},f=r=>{let a=r-u;if(a>=xc){cancelAnimationFrame(l),n.remove();return}d(a),i.clearRect(0,0,e,t);let o=xc-Cc,c=a>o?Math.max(0,1-(a-o)/Cc):1;for(let n=s.length-1;n>=0;n--){let r=s[n];if(r.vy+=wc,r.vx*=Tc,r.vy*=Tc,r.x+=r.vx,r.y+=r.vy,r.rotation+=r.rotationSpeed,r.y-r.size>t||r.x+r.size<0||r.x-r.size>e){s.splice(n,1);continue}i.save(),i.globalAlpha=c,i.translate(r.x,r.y),i.rotate(r.rotation),i.fillStyle=r.color,r.shape===`rect`?i.fillRect(-r.size/2,-r.size/2,r.size,r.size*.6):(i.beginPath(),i.arc(0,0,r.size/2,0,Math.PI*2),i.fill()),i.restore()}l=requestAnimationFrame(f)};l=requestAnimationFrame(f),a.debug(`[CompletionFeedback] confetti launched`)}catch(e){a.debug(`[CompletionFeedback] launch confetti failed:`,e?.message)}}function Fc(e,t,n,r){try{chrome.runtime.sendMessage({type:`TASK_FEEDBACK_NOTIFY`,success:e,sessionId:t||null,error:n||``,question:r||``,panel:mc(t)})?.catch?.(()=>{})}catch(e){a.debug(`[CompletionFeedback] desktop notify failed:`,e?.message)}}async function Ic(e=null,t=``){try{let n=Date.now();if(n-hc<gc){a.debug(`[CompletionFeedback] throttled, skip`);return}hc=n;let{soundEnabled:r,confettiEnabled:i}=await kc();r&&jc(),i&&!Nc()&&Pc(),Fc(!0,e,``,t)}catch(e){a.debug(`[CompletionFeedback] unexpected error:`,e?.message||e)}}async function Lc(e=null,t=``,n=``){try{let r=Date.now();if(r-hc<gc){a.debug(`[CompletionFeedback] throttled, skip`);return}hc=r;let{soundEnabled:i}=await kc();i&&Mc(),Fc(!1,e,t,n)}catch(e){a.debug(`[CompletionFeedback] unexpected error:`,e?.message||e)}}var Rc=new Set;function zc(e){return typeof e==`function`?(Rc.add(e),()=>Rc.delete(e)):()=>{}}function Bc(e){let t=e||N.activeSessionId;if(t){N.generatingSessionIds.delete(t);try{mi(t)}catch(e){a.warn(`[GenerationLifecycle] markSessionCompleted failed:`,e?.message)}typeof document<`u`&&typeof CustomEvent==`function`&&(document.dispatchEvent(new CustomEvent(`generating-state-changed`)),document.dispatchEvent(new CustomEvent(`generation-ended`,{detail:{sessionId:t}})));for(let e of Rc)try{e(t)}catch(e){a.error(`[GenerationLifecycle] end handler failed:`,e?.message)}}}function Vc(e){let t=Number(e);return!Number.isFinite(t)||t<=0?3:Math.min(20,Math.max(1,Math.round(t)))}function Hc(){return{callId:null,carried:0,lastIteration:null}}function Uc(e){let t=0;for(let n of e||[]){let e=Number(n&&n.iteration);Number.isFinite(e)&&e>t&&(t=e)}return t}function Wc(e){let{tracker:t,callId:n=null,iteration:r,everyN:i,enabled:a=!0,hasCandidate:o=!0}=e||{},s=t&&typeof t==`object`?{callId:t.callId??null,carried:Number(t.carried)||0,lastIteration:t.lastIteration??null}:Hc(),c=Number(r);if(!Number.isFinite(c)||c<=0)return{carry:!1,reason:`invalid_iteration`,tracker:s};let l=!!n&&!!s.callId&&n!==s.callId,u=s.lastIteration!=null&&c<s.lastIteration;if((l||u)&&(s=Hc()),n&&!s.callId&&(s={...s,callId:n}),!a)return{carry:!1,reason:`disabled`,tracker:s};if(c<2)return{carry:!1,reason:`too_early`,tracker:s};if(!o)return{carry:!1,reason:`no_candidate`,tracker:s};if(s.carried>=3)return{carry:!1,reason:`call_limit`,tracker:s};let d=Vc(i);return s.lastIteration!=null&&c-s.lastIteration<d?{carry:!1,reason:`interval_not_reached`,tracker:s}:{carry:!0,reason:`carry`,tracker:{callId:s.callId||n||null,carried:s.carried,lastIteration:c}}}function Gc(e,{callId:t=null}={}){let n=e&&typeof e==`object`?e:Hc();return t&&n.callId&&t!==n.callId?n:{...n,carried:(Number(n.carried)||0)+1}}n(`zh`,{voice:{start:`语音输入(开始录音)`,stop:`结束录音并转写`,recording:`正在录音`,listening:`正在聆听…`,transcribing:`正在转写…`,cancel:`取消录音`,done:`完成`,noSpeech:`没有听到声音`,noResult:`未识别到语音`,micDenied:`麦克风未授权`,micDeniedHelp:`侧边栏里浏览器不会弹授权框,请到配置页「语音输入 → 麦克风权限」授权一次`,micDeniedAction:`去授权`,micDeniedActionTitle:`打开配置页授权麦克风(侧边栏内无法弹出授权框)`,unavailable:`语音功能不可用`,modelMissing:`缺少语音模型`,modelMissingHelp:`请在配置页「语音」Tab 中导入模型包`,busy:`有语音任务正在进行`,failed:`语音识别失败`,connectionLost:`连接中断`,tooShort:`录音太短`,maxDuration:`已达单次录音时长上限,正在转写…`,unsupported:`当前浏览器不支持录音`,keyRightAlt:`右侧 Alt`,keyRightCtrl:`右侧 Ctrl`,btnTitle:`语音输入({keys})`,deviceFallback:`原麦克风不可用,已改用系统默认`}}),n(`en`,{voice:{start:`Voice input (start recording)`,stop:`Stop and transcribe`,recording:`Recording`,listening:`Listening…`,transcribing:`Transcribing…`,cancel:`Cancel recording`,done:`Done`,noSpeech:`No sound detected`,noResult:`No speech recognised`,micDenied:`Microphone not granted`,micDeniedHelp:`The browser cannot prompt inside the side panel — grant it once in Options → Voice Input → Microphone permission`,micDeniedAction:`Grant access`,micDeniedActionTitle:`Open options to grant microphone access (the side panel cannot show the prompt)`,unavailable:`Voice input unavailable`,modelMissing:`Speech model missing`,modelMissingHelp:`Import a model pack in the Options "Voice" tab`,busy:`Another voice task is running`,failed:`Speech recognition failed`,connectionLost:`Connection lost`,tooShort:`Recording too short`,maxDuration:`Recording length limit reached, transcribing…`,unsupported:`Recording is not supported in this browser`,keyRightAlt:`Right Alt`,keyRightCtrl:`Right Ctrl`,btnTitle:`Voice input ({keys})`,deviceFallback:`Selected microphone unavailable — using the system default`}});var Kc=15e3,qc=16e3,Jc=2500,Yc=.008,Xc=350,Zc=24,H={input:null,btn:null,bar:null,wave:null,timerEl:null,statusEl:null,permBtn:null,barEls:[],status:null,armed:!1,phase:`idle`,port:null,stream:null,ctx:null,node:null,source:null,startedAt:0,timer:null,silentSince:0,silenceWarned:!1,draft:null,lastText:``,appliedText:``,mute:null,programmatic:!1,draftSupported:!0,finishWaitTimer:null,adjustInputHeight:null,shortcutCfg:{...Ze},shortcutTrigger:null,shortcutBound:!1,deviceFellBack:!1};function Qc(e){return typeof e==`string`?e:``}function $c(e){let t=Math.max(0,Math.floor(e/1e3));return`${String(Math.floor(t/60)).padStart(2,`0`)}:${String(t%60).padStart(2,`0`)}`}function el(e){let t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=``,r=32768;for(let e=0;e<t.length;e+=r)n+=String.fromCharCode.apply(null,t.subarray(e,e+r));return btoa(n)}function tl(e,t,n){if(t===n)return e;let r=t/n,i=Math.floor(e.length/r),a=new Float32Array(i);for(let t=0;t<i;t++){let n=t*r,i=Math.floor(n),o=n-i,s=e[i]||0;a[t]=s+((e[i+1]===void 0?s:e[i+1])-s)*o}return a}function nl(e){let t=new Int16Array(e.length);for(let n=0;n<e.length;n++){let r=e[n]<-1?-1:e[n]>1?1:e[n];t[n]=r<0?r*32768:r*32767}return t}async function rl(e=!1){try{let t=await chrome.runtime.sendMessage({type:`ASR_GET_STATUS`,force:e});if(t&&t.success&&t.status)return H.status=t.status,H.status}catch(e){a.debug(`[Voice] status fetch failed:`,e?.message||e)}return H.status=null,null}function il(e){return!e||e.success===!1?!1:typeof e.available==`boolean`?e.available:e.deps?.ready===!0&&e.modelsReady===!0&&e.enabled===!0}function al({value:e,draft:t,text:n,caret:r,canReplace:i=!0}){let a=typeof e==`string`?e:``;if(!t)return{value:a,caret:a.length,len:0};if(!t.dirty&&i){let e=Math.min(Math.max(0,t.start),a.length),r=Math.min(Math.max(e,t.start+t.len),a.length);return{value:a.slice(0,e)+n+a.slice(r),caret:e+n.length,len:n.length}}let o=typeof r==`number`?Math.min(Math.max(0,r),a.length):a.length;return{value:a.slice(0,o)+n+a.slice(o),caret:o+n.length,len:0}}function ol({value:e,draft:t,canReplace:n=!0}){let r=typeof e==`string`?e:``;if(!t||t.dirty||!n||t.len<=0)return{value:r,caret:r.length};let i=Math.min(Math.max(0,t.start),r.length),a=Math.min(Math.max(i,t.start+t.len),r.length);return{value:r.slice(0,i)+r.slice(a),caret:i}}function sl(e){return!e||e.isComposing||e.repeat?!1:e.altKey===!0&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyV`}async function cl(){return H.armed=il(await rl()),H.btn&&(H.btn.style.display=H.armed?``:`none`),!H.armed&&H.phase!==`idle`&&Rl({rollback:!0}),H.armed}function ll(){H.draft&&(H.draft.dirty=!0)}function ul(){let e=H.input;if(!e)return{start:0,len:0,dirty:!1};let t=typeof e.selectionStart==`number`?e.selectionStart:e.value.length,n=typeof e.selectionEnd==`number`?e.selectionEnd:t;return t!==n&&e.setRangeText(``,t,n,`end`),{start:t,len:0,dirty:!1}}function dl(e,t){let n=Qc(e),r=Qc(t);return r?n?r.startsWith(n)?r.slice(n.length):null:r:``}function fl(e,t){let n=H.input;if(n){H.programmatic=!0,n.value=e;try{n.setSelectionRange(t,t)}catch{}H.programmatic=!1;try{document.dispatchEvent(new CustomEvent(`voice-draft-written`))}catch{}try{H.adjustInputHeight?.()}catch{}try{n.focus()}catch{}}}function pl(e){let t=H.input;if(!t||!H.draft)return;if(H.draft.dirty){let n=dl(H.appliedText,e);if(H.appliedText=Qc(e),!n)return;let r=typeof t.selectionStart==`number`?t.selectionStart:t.value.length;fl(t.value.slice(0,r)+n+t.value.slice(r),r+n.length);return}let n=typeof t.selectionStart==`number`?t.selectionStart:void 0,r=al({value:t.value,draft:H.draft,text:e,caret:n,canReplace:H.draftSupported});r.len>0&&(H.draft.len=r.len),H.appliedText=Qc(e),fl(r.value,r.caret)}function ml(){let e=H.input;if(!e||!H.draft)return;let t=ol({value:e.value,draft:H.draft,canReplace:H.draftSupported});if(t.value!==e.value){H.programmatic=!0,e.value=t.value;let n=Math.min(t.caret,e.value.length);try{e.setSelectionRange(n,n)}catch{}H.programmatic=!1;try{H.adjustInputHeight?.()}catch{}}H.draft=null,H.lastText=``}function hl(){if(H.wave){H.wave.textContent=``,H.barEls=[];for(let e=0;e<Zc;e++){let e=document.createElement(`i`);H.wave.appendChild(e),H.barEls.push(e)}}}function gl(e,t=``){H.statusEl&&(H.statusEl.textContent=e,H.statusEl.className=`voice-recorder-status`+(t?` is-${t}`:``))}function _l(){H.bar&&(H.bar.classList.add(`show`),H.bar.removeAttribute(`aria-hidden`))}function vl(e){H.permBtn&&(H.permBtn.style.display=e?``:`none`)}function yl(){let e=document.activeElement;if(!(!H.bar||!e||!H.bar.contains(e))){if(H.input&&typeof H.input.focus==`function`)try{H.input.focus({preventScroll:!0});return}catch{}try{e.blur()}catch{}}}function bl(){H.bar&&(yl(),vl(!1),H.bar.classList.remove(`show`),H.bar.setAttribute(`aria-hidden`,`true`),H.barEls.forEach(e=>{e.style.height=``,e.style.opacity=``}),H.timerEl&&(H.timerEl.textContent=`00:00`))}function xl(e){if(!H.barEls.length)return;let t=Math.min(1,Math.sqrt(Math.max(0,e))*6);for(let e=0;e<H.barEls.length-1;e++)H.barEls[e].style.height=H.barEls[e+1].style.height,H.barEls[e].style.opacity=H.barEls[e+1].style.opacity;let n=H.barEls[H.barEls.length-1];n.style.height=`${Math.max(2,Math.round(t*18))}px`,n.style.opacity=t>.06?`1`:`0.35`}function Sl(e){H.btn&&(H.btn.classList.toggle(`recording`,e),H.btn.setAttribute(`aria-pressed`,e?`true`:`false`),H.btn.setAttribute(`aria-label`,r(e?`voice.stop`:`voice.start`)),H.btn.title=r(e?`voice.stop`:`voice.start`))}function Cl(e){document.body?.classList.toggle(`voice-recording-active`,!!e)}function wl(){if(H.port)return H.port;try{let e=chrome.runtime.connect({name:`asr`});return e.onMessage.addListener(Bl),e.onDisconnect.addListener(()=>{H.port=null,(H.phase===`recording`||H.phase===`finalizing`)&&(Nl(),Pl(),H.draft=null,H.lastText=``,Sl(!1),Cl(!1),gl(r(`voice.connectionLost`),`warn`),setTimeout(()=>{H.phase===`idle`&&bl()},3500))}),H.port=e,e}catch(e){return a.warn(`[Voice] connect port failed:`,e?.message||e),null}}function Tl(e,t){if(xl(t),El(t),H.port)try{H.port.postMessage({type:`audio`,data:el(e)})}catch(e){a.debug(`[Voice] post audio failed:`,e?.message||e)}}function El(e){if(H.phase!==`recording`&&H.phase!==`starting`)return;if(e>=Yc){H.silentSince=0,H.silenceWarned&&(H.silenceWarned=!1,gl(r(`voice.listening`)));return}let t=Date.now();if(!H.silentSince){H.silentSince=t;return}H.silenceWarned||t-H.silentSince>=Jc&&(H.silenceWarned=!0,gl(r(`voice.noSpeech`),`warn`))}var Dl=[`voice-capture-worklet.js`,`dist/voice-capture-worklet.js`],Ol;async function kl(){if(Ol!==void 0)return Ol;for(let e of Dl){let t=``;try{t=chrome.runtime.getURL(e)}catch{continue}try{let e=await fetch(t);if(e&&e.ok)return Ol=t,t}catch{}}return Ol=null,null}async function Al(e,t){let n=await kl();if(!n)throw Error(`worklet not found in extension`);await e.audioWorklet.addModule(n);let r=new AudioWorkletNode(e,`voice-capture`),i=Math.abs(e.sampleRate-qc)>1;r.port.onmessage=t=>{let n=t.data;if(!n||n.type!==`chunk`||!n.pcm)return;let r=new Int16Array(n.pcm);if(i){let t=new Float32Array(r.length);for(let e=0;e<r.length;e++)t[e]=r[e]/32768;r=nl(tl(t,e.sampleRate,qc))}Tl(r,n.rms||0)},t.connect(r),H.node=r}function jl(e,t){let n=e.createScriptProcessor(4096,1,1),r=Math.abs(e.sampleRate-qc)>1;n.onaudioprocess=t=>{let n=t.inputBuffer.getChannelData(0),i=new Float32Array(n);r&&(i=tl(i,e.sampleRate,qc));let a=0;for(let e=0;e<i.length;e++)a+=i[e]*i[e];Tl(nl(i),Math.sqrt(a/Math.max(1,i.length)))},t.connect(n);let i=e.createGain();i.gain.value=0,n.connect(i),i.connect(e.destination),H.mute=i,H.node=n}async function Ml(){if(!navigator.mediaDevices?.getUserMedia)throw gl(r(`voice.unsupported`),`warn`),Error(`unsupported`);let e=await tt(await et());H.stream=e.stream,H.deviceFellBack=e.fellBack===!0;let t=window.AudioContext||window.webkitAudioContext,n;try{n=new t({sampleRate:qc})}catch{n=new t}if(n.state===`suspended`)try{await n.resume()}catch{}H.ctx=n;let i=n.createMediaStreamSource(e.stream);H.source=i;try{await Al(n,i)}catch(e){a.warn(`[Voice] worklet unavailable, fallback to ScriptProcessor:`,e?.message||e),jl(n,i)}}function Nl(){H.timer&&=(clearInterval(H.timer),null);try{H.node?.port?.close?.()}catch{}try{H.node?.disconnect?.()}catch{}try{H.mute?.disconnect?.()}catch{}try{H.source?.disconnect?.()}catch{}try{H.stream?.getTracks?.().forEach(e=>e.stop())}catch{}try{H.ctx?.close?.()}catch{}H.node=null,H.mute=null,H.source=null,H.stream=null,H.ctx=null}function Pl(){H.finishWaitTimer&&=(clearTimeout(H.finishWaitTimer),null),H.phase=`idle`}function Fl(){let e=()=>{let e=Date.now()-H.startedAt;H.timerEl&&(H.timerEl.textContent=$c(e));let t=H.status;e>=(t&&t.maxRecordingMs||300*1e3)&&Ll(`stop`)};H.timer&&clearInterval(H.timer),H.timer=setInterval(e,200),e()}async function Il(e={}){if(H.phase!==`idle`||!H.armed&&!e.force&&(await cl(),!H.armed||H.phase!==`idle`))return!1;H.phase=`starting`,H.lastText=``,H.appliedText=``,H.draft=ul(),H.draftSupported=!0,H.silentSince=0,H.silenceWarned=!1,_l(),gl(r(`voice.listening`)),Sl(!0),Cl(!0);let t=wl();if(!t)return gl(r(`voice.failed`),`warn`),Pl(),Sl(!1),Cl(!1),!1;try{await Ml()}catch(e){if(H.phase!==`starting`)return Nl(),!1;let n=e?.name||``,i=n===`NotAllowedError`||n===`SecurityError`;i?(gl(r(`voice.micDenied`),`warn`),vl(!0)):gl(r(`voice.failed`),`warn`),Nl(),Pl(),Sl(!1),Cl(!1);try{t.postMessage({type:`cancel`})}catch{}return setTimeout(()=>{H.phase===`idle`&&bl()},i?12e3:4e3),!1}if(H.phase!==`starting`)return Nl(),!1;H.startedAt=Date.now(),H.phase=`recording`,gl(r(`voice.listening`)),H.deviceFellBack&&(H.deviceFellBack=!1,gl(r(`voice.deviceFallback`),`warn`),setTimeout(()=>{H.phase===`recording`&&gl(r(`voice.listening`))},4e3)),Fl();try{t.postMessage({type:`start`,language:H.status&&H.status.language||`auto`})}catch(e){a.debug(`[Voice] post start failed:`,e?.message||e)}return!0}function Ll(e){if(H.phase!==`recording`)return;H.phase=`finalizing`;let t=Date.now()-H.startedAt;if(Nl(),Sl(!1),Cl(!1),e===`cancel`){try{H.port?.postMessage({type:`cancel`})}catch{}ml(),Pl(),bl();return}if(t<Xc&&!H.lastText){try{H.port?.postMessage({type:`cancel`})}catch{}ml(),gl(r(`voice.tooShort`),`warn`),Pl(),setTimeout(()=>{H.phase===`idle`&&bl()},2200);return}gl(r(`voice.transcribing`));try{H.port?.postMessage({type:`stop`})}catch{}H.finishWaitTimer&&clearTimeout(H.finishWaitTimer),H.finishWaitTimer=setTimeout(()=>{H.phase===`finalizing`&&zl(H.lastText,{fallback:!0})},6e4)}function Rl({rollback:e=!0}={}){if(H.phase===`idle`)return!1;let t=H.phase===`recording`||H.phase===`finalizing`;if(H.phase=`finalizing`,Nl(),t)try{H.port?.postMessage({type:`cancel`})}catch{}return e&&ml(),Pl(),Sl(!1),Cl(!1),bl(),!0}function zl(e,t={}){let n=Qc(e).trim();if(!n){ml(),gl(r(`voice.noResult`),`warn`),Pl(),setTimeout(()=>{H.phase===`idle`&&bl()},2200);return}pl(n),H.draft=null,H.lastText=``,Pl(),gl(r(`voice.done`)),setTimeout(()=>{H.phase===`idle`&&bl()},1200)}function Bl(e){if(!(!e||typeof e.type!=`string`)){if(e.type===`ready`){e.draft===!1&&H.phase===`recording`&&a.debug(`[Voice] online model missing, draft disabled`);return}if(e.type===`partial`||e.type===`endpoint`){if(H.phase!==`recording`&&H.phase!==`finalizing`)return;H.lastText=Qc(e.text),H.lastText&&pl(H.lastText);return}if(e.type===`final`){if(H.phase!==`recording`&&H.phase!==`finalizing`)return;zl(e.text||H.lastText,{fallback:e.fallback===!0});return}if(e.type===`closed`){H.phase===`finalizing`&&zl(H.lastText,{fallback:!0});return}if(e.type===`error`){let t=e.code||`internal`;if(t===`max_duration`){H.phase===`recording`&&Ll(`stop`),gl(r(`voice.maxDuration`),`warn`);return}gl(t===`busy`?r(`voice.busy`):t===`model_missing`?`${r(`voice.modelMissing`)} — ${r(`voice.modelMissingHelp`)}`:r(`voice.failed`),`warn`),Nl(),(H.phase===`recording`||H.phase===`finalizing`)&&ml(),Pl(),Sl(!1),Cl(!1),t===`model_missing`&&cl(),setTimeout(()=>{H.phase===`idle`&&bl()},3500)}}}async function Vl(){return H.phase===`recording`?(Ll(`stop`),!0):H.phase===`starting`||H.phase===`finalizing`?!1:Il()}function Hl(){return H.phase===`recording`||H.phase===`starting`||H.phase===`finalizing`}function Ul(){return Hl()?Rl({rollback:!0}):!1}function Wl(){return H.phase===`idle`?!1:Rl({rollback:!1})}async function Gl(){try{let e=(await chrome.storage.session?.get?.(`pendingVoiceStart`))?.pendingVoiceStart;return!(!e||(await chrome.storage.session.remove(`pendingVoiceStart`),typeof e!=`number`||Date.now()-e>Kc))}catch{return!1}}function Kl(){if(!H.btn)return;let e=[`Alt+V`];H.shortcutCfg.rightAlt&&e.push(r(`voice.keyRightAlt`)),H.shortcutCfg.rightCtrl&&e.push(r(`voice.keyRightCtrl`));let t=r(`voice.btnTitle`,{keys:e.join(` / `)});H.btn.title=t,H.btn.setAttribute(`aria-label`,t)}async function ql(){if(H.shortcutCfg=await Xe(),H.shortcutTrigger||=Ye(()=>H.shortcutCfg),Kl(),H.shortcutBound)return;H.shortcutBound=!0,document.addEventListener(`keydown`,e=>{H.shortcutTrigger?.onKeyDown(e)===`cancel`&&e.preventDefault()},!0),document.addEventListener(`keyup`,e=>{H.shortcutTrigger?.onKeyUp(e)===`trigger`&&(!H.armed&&H.phase===`idle`||(e.preventDefault(),Vl()))},!0),window.addEventListener(`blur`,()=>{H.shortcutTrigger?.reset()}),Je(e=>{H.shortcutCfg=e,Kl()});let e=async()=>{try{let e=await Xe();if(e.rightAlt===H.shortcutCfg.rightAlt&&e.rightCtrl===H.shortcutCfg.rightCtrl)return;H.shortcutCfg=e,Kl()}catch{}};window.addEventListener(`focus`,()=>{e()}),document.addEventListener(`visibilitychange`,()=>{document.hidden||e()})}async function Jl(e={}){if(H.input=document.getElementById(`userInput`),H.btn=document.getElementById(`voiceInputBtn`),H.bar=document.getElementById(`voiceRecorderBar`),H.wave=document.getElementById(`voiceWave`),H.timerEl=document.getElementById(`voiceTimer`),H.statusEl=document.getElementById(`voiceStatusText`),H.permBtn=document.getElementById(`voicePermBtn`),H.adjustInputHeight=typeof e.adjustInputHeight==`function`?e.adjustInputHeight:null,!H.input||!H.btn){a.debug(`[Voice] input or button missing, skip init`);return}hl(),Sl(!1),gl(r(`voice.listening`)),await ql(),H.btn.addEventListener(`click`,e=>{e.preventDefault(),Vl()}),document.getElementById(`voiceCancelBtn`)?.addEventListener(`click`,e=>{e.preventDefault(),Rl({rollback:!0})}),document.getElementById(`voiceDoneBtn`)?.addEventListener(`click`,e=>{e.preventDefault(),Ll(`stop`)}),H.permBtn?.addEventListener(`click`,e=>{e.preventDefault();try{chrome.runtime.sendMessage({type:`OPEN_OPTIONS_PAGE`,hash:`asr`}).catch?.(()=>{})}catch{}gl(r(`voice.micDeniedHelp`),`warn`),vl(!1)}),H.input.addEventListener(`input`,()=>{H.programmatic||(H.phase===`recording`||H.phase===`finalizing`)&&ll()}),chrome.runtime.onMessage.addListener((e,t,n)=>e?.type===`VOICE_TOGGLE`?(Vl(),n?.({success:!0}),!1):(e?.type===`ASR_STATUS_CHANGED`&&cl(),!1)),window.addEventListener(`pagehide`,()=>{Wl()}),document.addEventListener(`visibilitychange`,()=>{document.hidden&&H.phase===`recording`&&Wl()}),await cl()&&await Gl()&&setTimeout(()=>{Vl()},220)}var Yl=`panel_`+Date.now().toString(36)+`_`+Math.random().toString(36).slice(2,8),Xl=new Set,Zl=new Set,Ql=null,$l=new Map,eu=`queue-context-cleared`,tu=`queue-context-restored`;function nu(e){Ql=e}function ru(e){return N.generatingSessionIds.has(e||N.activeSessionId)}function iu(){return{quotedContextText:N.quotedContextText||``,selectedContextText:N.selectedContextText||``,selectedSkills:(N.selectedSkills||[]).slice(),selectedMcpServices:(N.selectedMcpServices||[]).slice(),knowledgeRefs:(N.knowledgeRefs||[]).slice(),selectedPage:N.selectedPage?{...N.selectedPage}:null,attachedImages:(N.attachedImages||[]).slice(),attachedFiles:(N.attachedFiles||[]).slice()}}function au(e){return e?e.attachmentSummary||(e.attachedImages||[]).length||(e.attachedFiles||[]).length?!0:!!(e.quotedContextText&&e.quotedContextText.trim()||e.selectedContextText&&e.selectedContextText.trim()||(e.selectedSkills||[]).length||(e.selectedMcpServices||[]).length||(e.knowledgeRefs||[]).length||e.selectedPage):!1}function ou(){return au(iu())}function su(){let e=iu();return au(e)&&lu(),e}function cu(e){e&&(e.quotedContextText&&(N.quotedContextText=e.quotedContextText),e.selectedContextText&&(N.selectedContextText=e.selectedContextText),(e.selectedSkills||[]).length&&(N.selectedSkills=e.selectedSkills.slice()),(e.selectedMcpServices||[]).length&&(N.selectedMcpServices=e.selectedMcpServices.slice()),(e.knowledgeRefs||[]).length&&(N.knowledgeRefs=e.knowledgeRefs.slice()),e.selectedPage&&(N.selectedPage={...e.selectedPage}),(e.attachedImages||[]).length&&(N.attachedImages=e.attachedImages.slice()),(e.attachedFiles||[]).length&&(N.attachedFiles=e.attachedFiles.slice()))}function lu(){let e=(N.attachedImages||[]).length>0;if(N.quotedContextText=``,N.selectedContextText=``,N.selectedSkills=[],N.selectedMcpServices=[],N.knowledgeRefs=[],N.selectedPage=null,N.attachedImages=[],N.attachedFiles=[],e){let e=document.getElementById(`imagePreviewBar`);e&&(e.innerHTML=``,e.style.display=`none`)}document.dispatchEvent(new CustomEvent(eu))}var uu=new Set([`pending`,`extracting`]);function du(){return(N.attachedFiles||[]).some(e=>uu.has(e&&e.status))}function fu(e){let t=e&&e.attachedImages||[],n=(e&&e.attachedFiles||[]).map(e=>{if(!e||typeof e.dataUrl!=`string`||!e.dataUrl.startsWith(`blob:`))return e;let t={...e};return delete t.dataUrl,t}),r={...e||{}};return delete r.attachedImages,delete r.attachedFiles,r.attachmentSummary=ai({attachedImages:t,attachedFiles:n}),{light:r,heavy:t.length||n.length?{images:t,files:n}:null}}async function pu(e){if(!e)return{ok:!1,attachments:!1,wantsAttachments:!1};let t=await si(e.id)||$l.get(e.id)||null,n=!!(e.attachmentSummary||e.contextSnapshot&&e.contextSnapshot.attachmentSummary);return cu({...e.contextSnapshot||{},attachedImages:t&&t.images||[],attachedFiles:t&&t.files||[]}),document.dispatchEvent(new CustomEvent(tu,{detail:{snapshot:e.contextSnapshot||{}}})),{ok:!0,attachments:!!t,wantsAttachments:n}}async function mu(e){return e?($l.delete(e),ci(e)):!1}async function hu({autoDrain:e=!0}={}){let t=document.getElementById(`userInput`),n=(t?.value||``).trim();if(!n)return{ok:!1,error:`empty`};Wl();let i=N.activeSessionId;if(!i)return P(r(`queue.noSession`),`error`),{ok:!1,error:`missing_session`};if(du())return P(r(`queue.filesStillExtracting`),`warning`,4e3),{ok:!1,error:`files_extracting`};let a=su(),{light:o,heavy:s}=fu(a),c=await Pr({sessionId:i,text:n,contextSnapshot:o,hasContext:au(o),attachmentSummary:o.attachmentSummary,source:`manual`});return c.ok?(s&&((await oi(c.item.id,i,s)).ok||($l.set(c.item.id,s),P(r(`queue.attachmentsVolatile`),`warning`,5e3))),t&&(t.value=``,t.style.height=`auto`,t.dispatchEvent(new Event(`input`)),t.focus()),P(r(`queue.enqueued`,{position:c.position}),`success`),document.dispatchEvent(new CustomEvent(`queue-enqueued`,{detail:{sessionId:i,item:c.item}})),e&&!ru(i)&&!Nr(i)&&_u(i),c):(cu(a),document.dispatchEvent(new CustomEvent(tu,{detail:{snapshot:a}})),c.error===`queue_full`?P(r(`queue.queueFull`,{limit:c.limit}),`warning`):P(r(`queue.enqueueFailed`),`error`),c)}async function gu(e){try{let{list:t}=await gi(),n=(t||[]).find(t=>t.id===e);return n?{messageHistory:Array.isArray(n.messageHistory)?n.messageHistory.slice():[],model:n.model,useTools:n.useTools,enabledTools:Array.isArray(n.enabledTools)?n.enabledTools.slice():n.enabledTools,agentId:n.agentId,temperature:n.temperature,topP:n.topP,contextCompaction:n.contextCompaction,workdir:n.workdir||null,workdirAgentId:n.workdirAgentId||null}:null}catch(e){return a.warn(`[QueueRunner] load session state failed:`,e?.message||e),null}}async function _u(e){let t=e||N.activeSessionId;if(!(!t||!Ql)){if(Xl.has(t)){Zl.add(t);return}Xl.add(t);try{do Zl.delete(t),await vu(t);while(Zl.has(t)&&!Nr(t))}finally{Xl.delete(t)}}}async function vu(e){if(ru(e)||Nr(e))return;let t=kr(e);if(!t)return;if((t.attempts||0)>=5){await Br(e,t.id,{status:R.FAILED,note:`too_many_attempts`}),P(r(`queue.tooManyAttempts`,{count:5}),`error`,5e3);return}if(!await Kr(e,t.id,Yl)){a.debug(`[QueueRunner] lease held by another panel, skip:`,t.id);return}await Lr(e,t.id,R.DISPATCHING,{attempts:(t.attempts||0)+1,lastError:null});let n=await si(t.id)||$l.get(t.id)||null;$l.delete(t.id);let i=!!t.attachmentSummary&&!n;i&&P(r(`queue.attachmentsMissing`),`warning`,5e3);let o={quotedContextText:``,selectedContextText:``,selectedSkills:[],selectedMcpServices:[],knowledgeRefs:[],selectedPage:null,...t.contextSnapshot||{},attachedImages:n&&n.images||[],attachedFiles:n&&n.files||[]},s=e===N.activeSessionId,c=null;if(!s&&(c=await gu(e),!c)){let t=await qr(e);t&&a.warn(`[QueueRunner] dropped queue of deleted session:`,e,t);return}let l={ok:!0};try{let n={text:t.text,fromQueue:!0,sessionId:e,context:o};s||(n.sessionState=c),l=await Ql(n)||{ok:!0}}catch(e){l={ok:!1,reason:e?.message||`dispatch_error`},a.error(`[QueueRunner] dispatch failed:`,e?.message||e)}jr(e,t.id)?l.ok===!1?l.delivered?(await Br(e,t.id,{status:R.FAILED,note:l.reason||`failed`}),await ci(t.id)):(await zr(e,t.id,`dispatch_failed`,l.reason||`dispatch_failed`),Zl.delete(e)):(await Br(e,t.id,{status:R.DONE,note:i?`relayed_no_attachments`:`relayed`}),await ci(t.id)):a.debug(`[QueueRunner] item removed during dispatch, drop result:`,t.id)}var yu=new Set;function bu(e){let t=e||N.activeSessionId;return t?(yu.add(t),t):null}function xu(e){let t=e||N.activeSessionId;return!!(t&&kr(t))}async function Su(e){let t=e||N.activeSessionId;t&&(yu.delete(t),await Gr(t),await _u(t))}function Cu(e){Nr(e)||_u(e)}var wu=new Map,Tu=new Set,Eu=new Map,Du=new Map;function Ou(e){let t=e&&e.attachmentSummary;return t?(t.imageCount||0)>0||(t.fileCount||0)>0:!1}function ku(e,t){return`${e}\u0000${t}`}function Au(e,t){let n=ku(e,t),r=wu.get(n);r&&(clearTimeout(r),wu.delete(n))}async function ju(e,t,n,r){Au(e,t);let i=jr(e,t);!i||i.status!==R.INJECTING||(await zr(e,t,n,n),r&&P(r,`warning`,4e3))}function Mu(e,t,n){return new Promise(r=>{let i=!1,a=e=>{i||(i=!0,r(e))},o=setTimeout(()=>a(null),2e3);try{chrome.runtime.sendMessage({type:`INJECT_MESSAGE`,sessionId:e,itemId:t,text:n},e=>{if(clearTimeout(o),chrome.runtime.lastError){a(null);return}a(e||null)})}catch{clearTimeout(o),a(null)}})}async function Nu(e,t,n={}){let i=t||N.activeSessionId,a=n.auto===!0;if(!i||!e)return{ok:!1,error:`missing_session`};let o=jr(i,e);if(!o)return{ok:!1,error:`not_found`};if(o.status!==R.QUEUED)return{ok:!1,error:`not_queued`};if(Ou(o))return a||P(r(`queue.injectNoAttachments`),`warning`,4e3),{ok:!1,error:`has_attachments`};let s=ku(i,e);if(Tu.has(s))return{ok:!1,error:`in_flight`};Tu.add(s);try{await Rr(i,e),wu.set(s,setTimeout(()=>{ju(i,e,`timeout`,r(`queue.injectTimeout`))},$n));let t=await Mu(i,e,o.text);if(!t)return{ok:!0,pending:!0};if(!t.accepted){let n=t.reason||`rejected`;return await ju(i,e,n,r(n===`no_running_task`?`queue.injectNoTask`:`queue.injectFailed`)),{ok:!1,error:n}}return a?i===N.activeSessionId&&P(r(`queue.autoCarried`,{iteration:n.iteration??`?`}),`success`,2500):P(r(`queue.injectAccepted`),`success`,2500),{ok:!0,pending:!0}}finally{Tu.delete(s)}}function Pu(e){let t=document.getElementById(`userInput`);t&&t.value.trim()===e&&(t.value=``,t.style.height=`auto`,t.dispatchEvent(new Event(`input`)),t.focus())}async function Fu(e){let t=N.activeSessionId,n=String(e||``).trim();if(!t||!n)return{ok:!1,error:`empty`};if(Wl(),!ru(t))return P(r(`queue.injectNoTask`),`warning`,3e3),{ok:!1,error:`no_running_task`};let i=`adhoc_`+Date.now().toString(36)+`_`+Math.random().toString(36).slice(2,7),a=setTimeout(()=>{Eu.has(i)&&(Eu.delete(i),P(r(`queue.injectTimeoutAdhoc`),`warning`,4e3))},$n);Eu.set(i,{text:n,timer:a});let o=await Mu(t,i,n);return o&&!o.accepted?(clearTimeout(a),Eu.delete(i),P(o.reason===`no_running_task`?r(`queue.injectNoTask`):r(`queue.injectFailed`),`warning`,4e3),{ok:!1,error:o.reason}):(o&&o.accepted&&P(r(`queue.injectAccepted`),`success`,2500),{ok:!0,pending:!0})}function Iu(e){let t=e?.sessionId,n=Array.isArray(e?.items)?e.items:[];if(!t||n.length===0)return;let i=0;for(let r of n){let n=Eu.get(r);if(n){clearTimeout(n.timer),Eu.delete(r),Pu(n.text);continue}Au(t,r),jr(t,r)&&(i++,Br(t,r,{status:R.INJECTED,note:`injected`,callId:e.callId||null,iteration:e.iteration??null}))}i>0&&t===N.activeSessionId&&P(r(`queue.injected`),`success`,2500),document.dispatchEvent(new CustomEvent(`queue-injected`,{detail:{sessionId:t,items:n,iteration:e.iteration??null}}))}function Lu(e){let t=e?.sessionId,n=Array.isArray(e?.items)?e.items:[];if(!t||n.length===0)return;let i=e.reason||`rejected`,a=r(i===`task_ended`?`queue.injectNoTask`:`queue.injectFailed`);for(let e of n){let r=Eu.get(e);if(r){clearTimeout(r.timer),Eu.delete(e);continue}ju(t,e,i,e===n[0]?a:null)}}function Ru(e){let t=e?.sessionId;if(!t||e.isSubtask===!0||Nr(t))return;let n=Uc(e.executionLog);if(!n)return;let r=kr(t),i=r&&!Ou(r)?r:null,o=N.chatConfig||{},s=Wc({tracker:Du.get(t),callId:e.callId||null,iteration:n,everyN:o.queueAutoCarryEveryNIterations,enabled:o.queueAutoCarry!==!1,hasCandidate:!!i});if(Du.set(t,s.tracker),!s.carry)return;a.debug(`[QueueRunner] auto carry item`,i.id,`at iteration`,n,`session`,t);let c=e.callId||null;Nu(i.id,t,{auto:!0,iteration:n}).then(e=>{!e||e.ok!==!0||Du.set(t,Gc(Du.get(t),{callId:c}))})}function zu(e){!e||typeof e!=`object`||(e.type===`INJECT_ABSORBED`?Iu(e):e.type===`INJECT_REJECTED`?Lu(e):e.type===`EXECUTION_STATUS_UPDATE`&&Ru(e))}async function Bu(){try{if(xr()){a.warn(`[QueueRunner] skip attachment prune in degraded mode`);return}let e=new Set;for(let t of Mr())for(let n of Tr(t))e.add(n.id);let t=await ui(e);t&&a.debug(`[QueueRunner] pruned orphan attachments:`,t)}catch(e){a.warn(`[QueueRunner] prune orphan attachments failed:`,e?.message||e)}}var Vu=!1,Hu=null,Uu=[];function Wu(e,t){document.addEventListener(e,t),Uu.push([e,t])}var Gu=1500;function Ku(e){return new Promise(t=>{let n=!1,r=e=>{n||(n=!0,t(e))},i=setTimeout(()=>r(null),Gu);try{chrome.runtime.sendMessage({type:`QUERY_SESSION_RUNNING`,sessionId:e},e=>{if(clearTimeout(i),chrome.runtime.lastError){r(null);return}r(!!(e&&e.running))})}catch{clearTimeout(i),r(null)}})}async function qu(){if(!N.activeSessionId)return!1;let e=Mr();if(e.length===0)return!0;let t=!1;for(let n of e){if(Nr(n)||ru(n)||!kr(n))continue;let e=await Ku(n);if(e===null){t=!0;continue}if(!e&&!(Nr(n)||ru(n)))return await _u(n),!0}return!t}function Ju(){if(Hu)return;let e=0,t=async()=>{if(Hu=null,++e>25)return;let n=!1;try{n=await qu()}catch(e){a.warn(`[QueueRunner] auto-resume attempt failed:`,e?.message||e)}n||(Hu=setTimeout(t,800))};Hu=setTimeout(t,300)}async function Yu({autoResume:e=!0}={}){Vu||(Vu=!0,await Sr(),Cr(),Bu(),zc(Cu),typeof chrome<`u`&&chrome.runtime?.onMessage?.addListener&&chrome.runtime.onMessage.addListener(zu),Wu(`task-stop-requested`,e=>{let t=e?.detail?.sessionId||N.activeSessionId;if(t){if(yu.delete(t)){Gr(t).then(()=>_u(t));return}Wr(t,`user_stopped`)}}),Wu(`generating-state-changed`,()=>{let e=N.activeSessionId;if(e){if(N.isGenerating&&Nr(e)){Gr(e);return}for(let e of Mr())if(!(Nr(e)||ru(e))&&kr(e)){_u(e);break}}}),Wu(`session-switched`,()=>Ju()),Wu(`visibilitychange`,()=>{document.visibilityState===`visible`&&Ju()}),e&&Ju())}async function Xu(e){let t=e||N.activeSessionId;t&&(await Gr(t),await _u(t))}var Zu=`combo-collapsed`,Qu=`summary-collapsed`,$u=`summary-wrapped`,ed=[Zu,Qu,$u];function td(e){if(!e)return;let t=e.querySelector(`.log-summary`);t&&(t.classList.remove(...ed),!(t.scrollWidth<=t.clientWidth)&&(t.classList.add(Zu),!(t.scrollWidth<=t.clientWidth)&&(t.classList.add(Qu),!(t.scrollWidth<=t.clientWidth)&&t.classList.add($u))))}var nd=null,rd=0,id=!1;function ad(e){e&&(nd=e,od(),!rd&&(rd=requestAnimationFrame(()=>{rd=0;let e=nd;nd=null,e&&td(e)})))}function od(){id||typeof window>`u`||(id=!0,window.addEventListener(`resize`,()=>{let e=document.querySelector(`.execution-log-panel`);e&&ad(e)}))}n(`zh`,{execLog:{statusSuccess:`成功`,statusFailed:`失败`,statusProcessing:`处理中`,unknownNode:`未知节点`,sequentialExecution:`顺序执行`,parallelExecution:`并行执行`,subtaskCountStrategy:`{count}个子任务, {strategy}`,messageCountTitle:`本次模型API调用携带的消息数`,toolCountTitle:`本次模型API调用携带的工具定义数`,messageCount:`{count}条`,toolCount:`{count}个`,durationTitle:`耗时`,sectionThought:`💡 思考`,sectionToolCall:`⚡ 工具调用`,labelTool:`工具:`,labelParams:`参数:`,sectionFilterResult:`🔍 筛选结果`,labelSelectedTools:`选中工具:`,labelCount:`数量:`,unitItems:`个`,sectionObservation:`📝 观察结果`,sectionApiRequest:`📡 API 请求`,labelModel:`模型:`,labelTemperature:`温度:`,labelTopP:`top_p:`,labelMessageCount:`消息数:`,labelToolCount:`工具数:`,sectionApiResponse:`📤 API 响应`,labelFinishReason:`完成原因:`,labelFilteredToolCount:`筛选后工具数:`,labelTokenUsage:`Token 使用:`,sectionError:`❌ 错误信息`,sectionSubtaskResult:`✅ 子任务结果`,sectionSubtaskDesc:`📝 任务描述`,subtaskPendingNode:`(待执行)`,sectionReflectionPrompt:`📊 评估提示词`,sectionReflectionRaw:`📤 评估结果(原始响应)`,sectionTokenUsage:`📊 Token 使用`,overallScore:`⭐ 综合评分: {score}/10`,sectionIssues:`📋 发现的问题`,sectionSuggestions:`💡 改进建议`,labelDecision:`🎯 决策: {decision}`,decisionPassed:`✅ 通过`,decisionRevised:`🔧 已修订`,decisionNeedsImprovement:`⚠️ 需改进`,resultUseful:`✅ 结果有用`,resultInvalid:`⚠️ 结果无效`,labelSuggestion:`建议: {suggestion}`,mainTask:`主任务`,stepCount:`({count} 步骤)`,processingDots:`处理中...`,waitingExecution:`等待执行中...`,realtimeLogTitle:`实时执行日志`,executingLabel:`执行中:`,preparing:`准备中...`,totalNodes:`总节点`,labelSuccess:`成功`,labelFailed:`失败`,labelSubtask:`子任务`,expandAll:`展开全部节点`,collapseAll:`收起全部节点`,sectionUserInjection:`💬 插话内容`}}),n(`en`,{execLog:{statusSuccess:`Success`,statusFailed:`Failed`,statusProcessing:`Processing`,unknownNode:`Unknown node`,sequentialExecution:`sequential`,parallelExecution:`parallel`,subtaskCountStrategy:`{count} subtasks, {strategy}`,messageCountTitle:`Number of messages carried in this model API call`,toolCountTitle:`Number of tool definitions carried in this model API call`,messageCount:`{count} msgs`,toolCount:`{count} tools`,durationTitle:`Duration`,sectionThought:`💡 Thought`,sectionToolCall:`⚡ Tool Call`,labelTool:`Tool:`,labelParams:`Params:`,sectionFilterResult:`🔍 Filter Result`,labelSelectedTools:`Selected tools:`,labelCount:`Count:`,unitItems:``,sectionObservation:`📝 Observation`,sectionApiRequest:`📡 API Request`,labelModel:`Model:`,labelTemperature:`Temperature:`,labelTopP:`top_p:`,labelMessageCount:`Messages:`,labelToolCount:`Tools:`,sectionApiResponse:`📤 API Response`,labelFinishReason:`Finish reason:`,labelFilteredToolCount:`Filtered tool count:`,labelTokenUsage:`Token Usage:`,sectionError:`❌ Error`,sectionSubtaskResult:`✅ Subtask Result`,sectionSubtaskDesc:`📝 Task Description`,subtaskPendingNode:`(pending)`,sectionReflectionPrompt:`📊 Reflection Prompt`,sectionReflectionRaw:`📤 Reflection Result (raw)`,sectionTokenUsage:`📊 Token Usage`,overallScore:`⭐ Overall Score: {score}/10`,sectionIssues:`📋 Issues Found`,sectionSuggestions:`💡 Suggestions`,labelDecision:`🎯 Decision: {decision}`,decisionPassed:`✅ Passed`,decisionRevised:`🔧 Revised`,decisionNeedsImprovement:`⚠️ Needs Improvement`,resultUseful:`✅ Useful`,resultInvalid:`⚠️ Invalid`,labelSuggestion:`Suggestion: {suggestion}`,mainTask:`Main Task`,stepCount:`({count} steps)`,processingDots:`Processing...`,waitingExecution:`Waiting for execution...`,realtimeLogTitle:`Real-time Execution Log`,executingLabel:`Executing:`,preparing:`Preparing...`,totalNodes:`Total nodes`,labelSuccess:`Success`,labelFailed:`Failed`,labelSubtask:`Subtask`,expandAll:`Expand all nodes`,collapseAll:`Collapse all nodes`,sectionUserInjection:`💬 Your interjection`}});function sd(e){if(e?.nodeType!==`tool_exec`||!e?.action)return``;let t=e.action.name||``,n=e.action.params;if(n==null)return``;if(typeof n==`string`&&(n=(()=>{try{return JSON.parse(n)}catch{return{raw:n}}})()),typeof n!=`object`)return String(n).trim();if(t===`execute_command`||t===`agent_exec`)return(n.command||n.cmd||``).toString().trim();if(t===`agent_file`||t===`file_upload`||t===`download_file`){let e=(n.file_path||n.filePath||n.path||n.filename||n.fileName||n.url||``).toString().trim();if(e)return e}if(t===`fetch_url`||t===`interact_element`||t===`fill_form`||t===`manage_tab`||t===`preview_ui`){let e=(n.url||n.href||n.selector||``).toString().trim();if(e)return e}if(t===`search_browser_data`||t===`search_in_page`||t===`exec_log`){let e=(n.query||n.keyword||n.text||``).toString().trim();if(e)return e}if(t===`dispatch_task`){let e=(n.task||``).toString().trim();if(e)return e}if(t===`agent_memory`){let e=(n.action||n.subAction||``).toString().trim();if(e)return e}let r=[`content`,`text`,`prompt`,`description`,`markdown`,`html`,`css`,`js`,`code`,`script`,`data`],i=Object.keys(n).filter(e=>n[e]!=null&&n[e]!==``&&!r.includes(e));if(i.length===0)return``;if(i.length===1){let e=String(n[i[0]]);return`${i[0]}: ${e}`}return i.slice(0,2).map(e=>`${e}=${JSON.stringify(n[e])}`).join(`, `)}function cd(e){return sd(e)}function ld(e){let t=Array.isArray(e)?e:[],n=t.filter(e=>e&&e.nodeType===`subtask_plan`&&Array.isArray(e.items));if(n.length===0)return t;let i=t.filter(e=>e&&e.nodeType!==`subtask_plan`),a=new Set(i.filter(e=>e.nodeType===`subtask`&&typeof e.subtaskIndex==`number`).map(e=>e.subtaskIndex)),o=new Map;n.forEach(e=>{e.items.forEach(t=>{!t||typeof t.index!=`number`||o.set(t.index,{item:t,plan:e})})});let s=[];return Array.from(o.keys()).sort((e,t)=>e-t).forEach(e=>{if(a.has(e))return;let{item:t,plan:n}=o.get(e),i=r(`execLog.subtaskPendingNode`);s.push({id:`plan_pending_${n.id||`x`}_${e}`,nodeType:`subtask`,status:`pending`,iteration:0,timestamp:n.timestamp,subtaskIndex:e,subtaskId:t.id,subtaskName:t.name,description:t.description||``,nodeName:t.name?`${t.name} ${i}`:i,taskGroup:`subtask_group_${e}`,taskGroupIndex:e+1,taskGroupName:t.name,isSubtask:!0})}),i.concat(s)}function ud(e,t){let n=e=>e.status===`pending`?2**53-1:new Date(e.timestamp).getTime();return n(e)-n(t)}function dd(e){let t=ld(e).sort(ud),n=t.length,i=``,a=null;return t.forEach((e,t)=>{let o=e.nodeType===`subtask`,s=e.nodeType===`tool_exec`,c=e.nodeType===`api_call`,l=e.nodeType===`preselect`,u=e.nodeType===`reflection`,d=e.nodeType===`user_injection`,f=s&&e.action?.name===`plan_task`;o&&(a=e.subtaskIndex);let p=``,m=``;d?m=`💬`:u?m=`🎯`:l?m=`🔍`:f?(p=`plan-task-level`,m=`📋`):o?(p=`subtask-level`,m=`🔀`):s&&a!==null?(p=`tool-level`,m=`🔧`):c&&a!==null?(p=`api-level`,m=`📡`):s?m=`⚡`:c&&(m=`📡`);let h=`○`,g=e.status||`processing`;e.status===`success`?h=`✓`:e.status===`failed`&&(h=`✗`),u&&(g=`reflection ${g}`);let _=F(e.nodeName||r(`execLog.unknownNode`));if(e.subtaskIndex!==null&&e.subtaskIndex>=0&&(_=`<span class="subtask-badge">${e.subtaskIndex+1}</span> ${_}`),e.subtaskCount&&(_+=` <span class="plan-badge">(${r(`execLog.subtaskCountStrategy`,{count:e.subtaskCount,strategy:e.strategy===`sequential`?r(`execLog.sequentialExecution`):r(`execLog.parallelExecution`)})})</span>`),(c||l||u)&&e.apiRequest){let t=[];e.apiRequest.messageCount!==void 0&&e.apiRequest.messageCount!==null&&t.push(`💬<span title="${r(`execLog.messageCountTitle`)}">${r(`execLog.messageCount`,{count:e.apiRequest.messageCount})}</span>`),!l&&e.apiRequest.toolCount!==void 0&&e.apiRequest.toolCount!==null&&t.push(`🔧<span title="${r(`execLog.toolCountTitle`)}">${r(`execLog.toolCount`,{count:e.apiRequest.toolCount})}</span>`),t.length>0&&(_+=` <span class="api-info-badge">(${t.join(` `)})</span>`)}if(s){let t=cd(e);t&&(_+=` <span class="node-cmd-preview" title="${L(t)}">${F(t)}</span>`)}i+=`
|
|
93
93
|
<div class="timeline-item ${p}" data-status="${e.status||`processing`}" data-node-type="${e.nodeType||``}">
|
|
94
94
|
<div class="timeline-line"></div>
|
|
95
95
|
<div class="timeline-dot ${g}">
|
|
@@ -743,7 +743,7 @@ import{o as e,r as t}from"./chunk-CMxvf4Kt.js";import{a as n,c as r,i,l as a,n a
|
|
|
743
743
|
</button>
|
|
744
744
|
</div>
|
|
745
745
|
</div>
|
|
746
|
-
`}).join(``)}function fp(e,t){if(!t)return e;let n=F(e),r=t.split(/[&|]/).map(e=>e.trim()).filter(Boolean);if(r.length===0)return n;let i=r.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)),a=RegExp(`(${i.join(`|`)})`,`gi`);return n.replace(a,`<mark class="bookmark-highlight-match">$1</mark>`)}async function pp(e,t){if(!(!e||!t)){if(N.activeSessionId!==e)try{let n=N.activeSessionId;if(await xi(e)===!1||N.activeSessionId!==e){await ip(e,t),up(),P(r(`bookmark.sessionNotExistToast`),`warning`);return}document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:e,previousSessionId:n,skipScrollRestore:!0}}));try{let{renderSessionTabs:e}=await M(async()=>{let{renderSessionTabs:e}=await Promise.resolve().then(()=>Co);return{renderSessionTabs:e}},void 0);e()}catch(e){a.warn(`[BookmarkPanel] refreshsessionTab failed:`,e)}}catch(e){a.error(`[BookmarkPanel] switchsession failed:`,e);return}setTimeout(()=>{let n=document.getElementById(`chatContainer`);if(!n)return;let i=n.querySelector(`.message[data-message-id="${t}"]`);i?(i.scrollIntoView({behavior:`instant`,block:`nearest`}),i.classList.add(`bookmark-highlight`),setTimeout(()=>{i.classList.remove(`bookmark-highlight`)},2e3)):ip(e,t).then(()=>{up(),P(r(`bookmark.messageNotExistToast`),`warning`)})},500)}}function mp(){let e=document.getElementById(`bookmarkPanelContainer`),t=N.bookmarks.length;e&&(e.style.display=t>0?``:`none`)}function hp(){let e=document.getElementById(`chatContainer`);e&&e.querySelectorAll(`.message.assistant`).forEach(e=>{let t=e.querySelector(`.bookmark-btn`);if(!t)return;let n=e.dataset.messageId,r=N.activeSessionId;gp(t,r,n)})}function gp(e,t,n){np(t,n)?(e.classList.add(`bookmarked`),e.title=r(`bookmark.removeBookmarkTitle`),e.querySelector(`svg`).setAttribute(`fill`,`currentColor`)):(e.classList.remove(`bookmarked`),e.title=r(`bookmark.addBookmarkTitle`),e.querySelector(`svg`).setAttribute(`fill`,`none`))}n(`zh`,{imageHelper:{uploadToAgentTitle:`上传文件到Agent工作目录,大模型通过工具直接操作`,uploadAndExtractTitle:`上传文件并提取文本内容(支持PDF/Word/Excel/文本等)`,clickToEnlarge:`点击查看大图`,removeImage:`移除图片`,enableImageInputFirst:`请先开启图片输入功能`,screenshotSuccess:`截图成功`,screenshotFailed:`截图失败,请重试`,noActiveTab:`无法获取当前标签页`,cropFailed:`裁剪失败,请重试`,regionScreenshotFailed:`区域截图失败,请确保页面已加载且未被浏览器限制`,imageLoadFailed:`图片加载失败`,screenshotProcessFailed:`截图处理失败,请重试`}}),n(`en`,{imageHelper:{uploadToAgentTitle:`Upload files to Agent workspace; the model operates on them directly via tools`,uploadAndExtractTitle:`Upload files and extract text content (supports PDF/Word/Excel/text, etc.)`,clickToEnlarge:`Click to enlarge`,removeImage:`Remove image`,enableImageInputFirst:`Please enable image input first`,screenshotSuccess:`Screenshot captured`,screenshotFailed:`Screenshot failed, please retry`,noActiveTab:`Unable to get the current tab`,cropFailed:`Cropping failed, please retry`,regionScreenshotFailed:`Region screenshot failed. Make sure the page is loaded and not restricted by the browser.`,imageLoadFailed:`Image load failed`,screenshotProcessFailed:`Screenshot processing failed, please retry`}});function _p(){let e=document.getElementById(`imagePreviewBar`),t=document.getElementById(`screenshotBtn`);e&&(e.style.display=N.attachedImages.length>0?``:`none`),t&&(N.enableImageInput?t.style.removeProperty(`display`):t.style.display=`none`),vp(),N.enableImageInput||(N.attachedImages=[]),bp()}function vp(){let e=document.getElementById(`userInput`);e&&e.style.removeProperty(`padding-right`)}function yp(){let e=document.getElementById(`fileAttachBtn`),t=document.getElementById(`fileInput`);e&&(e.style.display=N.enableFileInput?``:`none`),t&&(N.agentPlatform?.connected?(t.accept=`*`,e&&(e.title=r(`imageHelper.uploadToAgentTitle`))):(t.accept=`.pdf,.docx,.xlsx,.xls,.txt,.md,.json,.js,.jsx,.ts,.tsx,.html,.css,.scss,.less,.xml,.yaml,.yml,.py,.java,.c,.cpp,.h,.go,.rs,.rb,.php,.sql,.sh,.bash,.zsh,.cfg,.ini,.toml,.conf,.log,.csv,.tsv,.env,.vue,.svelte,.astro,.rtf`,e&&(e.title=r(`imageHelper.uploadAndExtractTitle`)))),vp(),N.enableFileInput||Qf()}function bp(){let e=document.getElementById(`imagePreviewBar`);if(e){if(e.innerHTML=``,N.attachedImages.length===0){e.style.display=`none`;return}e.style.display=``,N.attachedImages.forEach((t,n)=>{let i=document.createElement(`div`);i.className=`image-preview-item`;let a=document.createElement(`img`);a.src=t.dataUrl||t.compressedUrl||t.originalUrl,a.className=`image-preview-thumb`,a.title=r(`imageHelper.clickToEnlarge`),a.style.cursor=`zoom-in`,a.addEventListener(`click`,()=>{ef(t.originalUrl||t.dataUrl||t.compressedUrl,a)});let o=document.createElement(`button`);o.className=`image-preview-remove`,o.innerHTML=`×`,o.title=r(`imageHelper.removeImage`),o.addEventListener(`click`,e=>{e.stopPropagation(),N.attachedImages.splice(n,1),bp()}),i.appendChild(a),i.appendChild(o),e.appendChild(i)})}}async function xp(){if(!N.enableImageInput){P(r(`imageHelper.enableImageInputFirst`));return}try{let e=await chrome.runtime.sendMessage({type:`CAPTURE_TAB`});e?.dataUrl&&(lf(await(await fetch(e.dataUrl)).blob()),P(r(`imageHelper.screenshotSuccess`)))}catch(e){a.error(`[SidePanel] full page screenshot failed:`,e),P(r(`imageHelper.screenshotFailed`))}}async function Sp(){let e=await yt();if(!e){P(r(`imageHelper.noActiveTab`));return}try{let t=await chrome.tabs.sendMessage(e,{type:`START_REGION_SELECTION`});if(!t)return;a.debug(`[SidePanel] regionselectresult:`,t);let n=await chrome.runtime.sendMessage({type:`CAPTURE_TAB`});if(!n?.dataUrl){P(r(`imageHelper.screenshotFailed`));return}let i=await Cp(n.dataUrl,t);if(!i){P(r(`imageHelper.cropFailed`));return}lf(await(await fetch(i)).blob())}catch(e){a.error(`[SidePanel] region screenshot failed:`,e),P(r(`imageHelper.regionScreenshotFailed`))}}function Cp(e,t){return new Promise((n,i)=>{let a=new Image;a.onload=()=>{let e=document.createElement(`canvas`),r=window.devicePixelRatio||1,i=t.x*r,o=t.y*r,s=t.width*r,c=t.height*r;e.width=s,e.height=c,e.getContext(`2d`,{willReadFrequently:!0}).drawImage(a,i,o,s,c,0,0,s,c),n(e.toDataURL(`image/jpeg`,.85))},a.onerror=()=>i(Error(r(`imageHelper.imageLoadFailed`))),a.src=e})}async function wp(e,t,n){if(!N.enableImageInput){P(r(`imageHelper.enableImageInputFirst`));return}try{let i=e;t===`region`&&n&&(i=await Cp(e,n)),lf(await(await fetch(i)).blob()),P(r(`imageHelper.screenshotSuccess`))}catch(e){a.error(`[SidePanel] pageshortcutscreenshotprocessing failed:`,e),P(r(`imageHelper.screenshotProcessFailed`))}}var Tp=t({attachFilesForQuestion:()=>j_,closePreview:()=>mg,closeWorkspacePanel:()=>n_,closeWorkspacePreview:()=>t_,initWorkspacePanel:()=>Jp,locateFileInWorkspace:()=>$g,openWorkspacePanel:()=>hm,previewArtifactFile:()=>e_,refreshWorkspacePanel:()=>Kg,resetAndRefreshWorkspace:()=>qg,resolveWorkspaceAbsolutePath:()=>r_,showSwitchWorkdirDialog:()=>x_,updateWorkspacePanelVisibility:()=>Jg});n(`zh`,{workspace:{workDir:`工作目录`,closePanel:`关闭面板`,embedMode:`嵌入模式`,floatMode:`浮窗模式`,openPanel:`打开工作目录面板`,narrowViewportHint:`视口过窄,已切回浮窗模式`,switchWorkdir:`切换工作目录`,backToParent:`返回上级目录`,uploadToCurrent:`上传文件到当前目录`,newFolder:`新建文件夹`,askSelectedFiles:`基于选中的文件进行问答`,downloadSelected:`下载选中的文件/目录(多选打包为ZIP)`,deleteSelected:`删除选中的文件`,clearSearch:`清除`,search:`搜索`,searchPlaceholder:`搜索...`,selectAllToggle:`全选/取消全选`,colName:`文件名`,colSize:`大小`,colTime:`修改时间`,noMatch:`未找到匹配的文件`,dirEmpty:`此目录为空`,noWorkspace:`无法获取工作目录,请确认 Agent 已连接`,loadDirFailed:`加载目录失败`,refreshFailed:`无法刷新,请确认 Agent 已连接`,agentNotConnected:`Agent 未连接`,agentNotConnectedUpload:`Agent 未连接,无法上传`,unsupportedFileType:`不支持的文件类型`,unknownError:`未知错误`,copiedFileName:`已复制文件名: {name}`,copiedPath:`已复制路径: {path}`,copyFailed:`复制失败`,copiedToClipboard:`已复制到剪贴板`,copyFailedManual:`复制失败,请手动选择复制`,getContentFailed:`获取内容失败`,codeCopiedToClipboard:`代码已复制到剪贴板`,copyUnsupportedType:`此文件类型不支持复制文本内容`,copiedToClipboardShort:`已复制到剪贴板`,clickToCopy:`点击复制`,preview:`预览`,previewBtn:`预览`,details:`详情`,download:`下载`,downloadFile:`下载文件`,rename:`重命名`,askFile:`基于文件问答`,delete:`删除`,copyAll:`复制`,copyAllTitle:`复制全部内容`,toggleRenderPreview:`切换渲染预览`,openInBrowser:`在浏览器中打开`,openInBrowserBtn:`在浏览器中打开`,fullscreenPreview:`全屏预览`,exitFullscreen:`退出全屏`,enterEditMode:`进入编辑模式`,edit:`编辑`,save:`保存`,saveChanges:`保存修改 (Ctrl+S)`,cancelChanges:`取消修改 (Esc)`,closePreview:`关闭预览`,close:`关闭`,confirm:`确定`,cancel:`取消`,switchToSourcePreview:`切换为源码预览`,switchToRenderPreview:`切换为渲染预览`,markdownRendered:`Markdown 渲染`,lineCount:`{count} 行`,linesModified:`{count} 行 · 已修改`,truncatedHint:`(仅显示前 {shown} 行,共 {total} 行,请下载查看完整内容)`,fileTooLargeNoPreview:`文件过大 ({size}),不支持预览,请直接下载`,fileTooLargeOpenInBrowser:`文件过大 ({size}),无法内置预览,请点击上方「在浏览器中打开」按钮查看`,previewFailed:`预览失败: {error}`,openFailed:`打开失败: {error}`,documentEmpty:`(文档为空)`,pptxEmptyOrFailed:`PPTX 文件为空或解析失败`,pageCount:`{count} 页`,prevPage:`上一页`,nextPage:`下一页`,zoomOut:`缩小`,zoomIn:`放大`,fitPage:`适应页面`,originalSize:`原始大小`,imageLoadFailed:`图片加载失败`,parsingExcel:`正在解析 Excel 文件...`,loadingData:`正在加载数据...`,requestFailed:`请求失败: {error}`,parseFailed:`解析失败: {error}`,noSheetsInWorkbook:`工作簿中没有工作表`,sheetNotFound:`未找到工作表数据`,emptySheet:`(空工作表)`,xlsxTruncatedHint:`仅显示前 {shown} 行,共 {total} 行,请下载查看完整内容`,unsupportedMediaHint:`⚠ 浏览器不支持播放此格式({ext}),请下载后使用本地播放器查看。`,uploading:`上传中...`,downloadInProgress:`下载中`,uploadInProgress:`上传中`,cancelUpload:`取消上传`,downloadCanceled:`下载已取消`,downloadFailed:`下载失败`,downloadFailedWithError:`下载失败: {error}`,savingToLocal:`正在由浏览器保存至本地...`,savedToLocal:`已保存至本地`,downloaded:`已下载: {name}`,downloadedCount:`已下载 {count} 个文件`,downloadedZip:`已下载 {count} 个文件(ZIP 压缩包)`,fileCount:`{count} 个文件`,uploadCanceled:`已取消上传`,uploadSuccessCount:`成功 {count}`,uploadSkippedCount:`跳过 {count}`,uploadFailedCount:`失败 {count}`,uploadComplete:`上传完成`,uploadCompleteWithStats:`上传完成 · {stats}`,uploadedFiles:`成功上传 {count} 个文件`,filesSkipped:`{count} 个文件已存在,跳过上传`,filesUploadFailed:`{count} 个文件上传失败`,uploadFailed:`上传失败`,uploadFailedWithStatus:`上传失败 ({status})`,parseResponseFailed:`解析响应失败`,networkError:`网络错误`,cannotMoveToSubdir:`不能将目录移动到其子目录中`,moving:`移动中...`,movedToDir:`"{name}" 已移动到目标目录`,movedToTarget:`"{name}" 已移动到 "{target}"`,moveFailed:`移动失败: {error}`,searching:`搜索中...`,confirmDeleteDir:`确定要删除目录 "{name}" 及其所有内容吗?
|
|
746
|
+
`}).join(``)}function fp(e,t){if(!t)return e;let n=F(e),r=t.split(/[&|]/).map(e=>e.trim()).filter(Boolean);if(r.length===0)return n;let i=r.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)),a=RegExp(`(${i.join(`|`)})`,`gi`);return n.replace(a,`<mark class="bookmark-highlight-match">$1</mark>`)}async function pp(e,t){if(!(!e||!t)){if(N.activeSessionId!==e)try{let n=N.activeSessionId;if(await xi(e)===!1||N.activeSessionId!==e){await ip(e,t),up(),P(r(`bookmark.sessionNotExistToast`),`warning`);return}document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:e,previousSessionId:n,skipScrollRestore:!0}}));try{let{renderSessionTabs:e}=await M(async()=>{let{renderSessionTabs:e}=await Promise.resolve().then(()=>Co);return{renderSessionTabs:e}},void 0);e()}catch(e){a.warn(`[BookmarkPanel] refreshsessionTab failed:`,e)}}catch(e){a.error(`[BookmarkPanel] switchsession failed:`,e);return}setTimeout(()=>{let n=document.getElementById(`chatContainer`);if(!n)return;let i=n.querySelector(`.message[data-message-id="${t}"]`);i?(i.scrollIntoView({behavior:`instant`,block:`nearest`}),i.classList.add(`bookmark-highlight`),setTimeout(()=>{i.classList.remove(`bookmark-highlight`)},2e3)):ip(e,t).then(()=>{up(),P(r(`bookmark.messageNotExistToast`),`warning`)})},500)}}function mp(){let e=document.getElementById(`bookmarkPanelContainer`),t=N.bookmarks.length;e&&(e.style.display=t>0?``:`none`)}function hp(){let e=document.getElementById(`chatContainer`);e&&e.querySelectorAll(`.message.assistant`).forEach(e=>{let t=e.querySelector(`.bookmark-btn`);if(!t)return;let n=e.dataset.messageId,r=N.activeSessionId;gp(t,r,n)})}function gp(e,t,n){np(t,n)?(e.classList.add(`bookmarked`),e.title=r(`bookmark.removeBookmarkTitle`),e.querySelector(`svg`).setAttribute(`fill`,`currentColor`)):(e.classList.remove(`bookmarked`),e.title=r(`bookmark.addBookmarkTitle`),e.querySelector(`svg`).setAttribute(`fill`,`none`))}n(`zh`,{imageHelper:{uploadToAgentTitle:`上传文件到Agent工作目录,大模型通过工具直接操作`,uploadAndExtractTitle:`上传文件并提取文本内容(支持PDF/Word/Excel/文本等)`,clickToEnlarge:`点击查看大图`,removeImage:`移除图片`,enableImageInputFirst:`请先开启图片输入功能`,screenshotSuccess:`截图成功`,screenshotFailed:`截图失败,请重试`,noActiveTab:`无法获取当前标签页`,cropFailed:`裁剪失败,请重试`,regionScreenshotFailed:`区域截图失败,请确保页面已加载且未被浏览器限制`,imageLoadFailed:`图片加载失败`,screenshotProcessFailed:`截图处理失败,请重试`}}),n(`en`,{imageHelper:{uploadToAgentTitle:`Upload files to Agent workspace; the model operates on them directly via tools`,uploadAndExtractTitle:`Upload files and extract text content (supports PDF/Word/Excel/text, etc.)`,clickToEnlarge:`Click to enlarge`,removeImage:`Remove image`,enableImageInputFirst:`Please enable image input first`,screenshotSuccess:`Screenshot captured`,screenshotFailed:`Screenshot failed, please retry`,noActiveTab:`Unable to get the current tab`,cropFailed:`Cropping failed, please retry`,regionScreenshotFailed:`Region screenshot failed. Make sure the page is loaded and not restricted by the browser.`,imageLoadFailed:`Image load failed`,screenshotProcessFailed:`Screenshot processing failed, please retry`}});function _p(){let e=document.getElementById(`imagePreviewBar`),t=document.getElementById(`screenshotBtn`);e&&(e.style.display=N.attachedImages.length>0?``:`none`),t&&(N.enableImageInput?t.style.removeProperty(`display`):t.style.display=`none`),vp(),N.enableImageInput||(N.attachedImages=[]),bp()}function vp(){let e=document.getElementById(`userInput`);e&&e.style.removeProperty(`padding-right`)}function yp(){let e=document.getElementById(`fileAttachBtn`),t=document.getElementById(`fileInput`);e&&(e.style.display=N.enableFileInput?``:`none`),t&&(N.agentPlatform?.connected?(t.accept=`*`,e&&(e.title=r(`imageHelper.uploadToAgentTitle`))):(t.accept=`.pdf,.docx,.xlsx,.xls,.txt,.md,.json,.js,.jsx,.ts,.tsx,.html,.css,.scss,.less,.xml,.yaml,.yml,.py,.java,.c,.cpp,.h,.go,.rs,.rb,.php,.sql,.sh,.bash,.zsh,.cfg,.ini,.toml,.conf,.log,.csv,.tsv,.env,.vue,.svelte,.astro,.rtf`,e&&(e.title=r(`imageHelper.uploadAndExtractTitle`)))),vp(),N.enableFileInput||Qf()}function bp(){let e=document.getElementById(`imagePreviewBar`);if(e){if(e.innerHTML=``,N.attachedImages.length===0){e.style.display=`none`;return}e.style.display=``,N.attachedImages.forEach((t,n)=>{let i=document.createElement(`div`);i.className=`image-preview-item`;let a=document.createElement(`img`);a.src=t.dataUrl||t.compressedUrl||t.originalUrl,a.className=`image-preview-thumb`,a.title=r(`imageHelper.clickToEnlarge`),a.style.cursor=`zoom-in`,a.addEventListener(`click`,()=>{ef(t.originalUrl||t.dataUrl||t.compressedUrl,a)});let o=document.createElement(`button`);o.className=`image-preview-remove`,o.innerHTML=`×`,o.title=r(`imageHelper.removeImage`),o.addEventListener(`click`,e=>{e.stopPropagation(),N.attachedImages.splice(n,1),bp()}),i.appendChild(a),i.appendChild(o),e.appendChild(i)})}}async function xp(){if(!N.enableImageInput){P(r(`imageHelper.enableImageInputFirst`));return}try{let e=await chrome.runtime.sendMessage({type:`CAPTURE_TAB`});e?.dataUrl&&(lf(await(await fetch(e.dataUrl)).blob()),P(r(`imageHelper.screenshotSuccess`)))}catch(e){a.error(`[SidePanel] full page screenshot failed:`,e),P(r(`imageHelper.screenshotFailed`))}}async function Sp(){let e=await yt();if(!e){P(r(`imageHelper.noActiveTab`));return}try{let t=await chrome.tabs.sendMessage(e,{type:`START_REGION_SELECTION`});if(!t)return;a.debug(`[SidePanel] regionselectresult:`,t);let n=await chrome.runtime.sendMessage({type:`CAPTURE_TAB`});if(!n?.dataUrl){P(r(`imageHelper.screenshotFailed`));return}let i=await Cp(n.dataUrl,t);if(!i){P(r(`imageHelper.cropFailed`));return}lf(await(await fetch(i)).blob())}catch(e){a.error(`[SidePanel] region screenshot failed:`,e),P(r(`imageHelper.regionScreenshotFailed`))}}function Cp(e,t){return new Promise((n,i)=>{let a=new Image;a.onload=()=>{let e=document.createElement(`canvas`),r=window.devicePixelRatio||1,i=t.x*r,o=t.y*r,s=t.width*r,c=t.height*r;e.width=s,e.height=c,e.getContext(`2d`,{willReadFrequently:!0}).drawImage(a,i,o,s,c,0,0,s,c),n(e.toDataURL(`image/jpeg`,.85))},a.onerror=()=>i(Error(r(`imageHelper.imageLoadFailed`))),a.src=e})}async function wp(e,t,n){if(!N.enableImageInput){P(r(`imageHelper.enableImageInputFirst`));return}try{let i=e;t===`region`&&n&&(i=await Cp(e,n)),lf(await(await fetch(i)).blob()),P(r(`imageHelper.screenshotSuccess`))}catch(e){a.error(`[SidePanel] pageshortcutscreenshotprocessing failed:`,e),P(r(`imageHelper.screenshotProcessFailed`))}}var Tp=t({attachFilesForQuestion:()=>N_,closePreview:()=>mg,closeWorkspacePanel:()=>n_,closeWorkspacePreview:()=>t_,initWorkspacePanel:()=>Jp,locateFileInWorkspace:()=>$g,openWorkspacePanel:()=>hm,previewArtifactFile:()=>e_,refreshWorkspacePanel:()=>Kg,resetAndRefreshWorkspace:()=>qg,resolveWorkspaceAbsolutePath:()=>r_,showSwitchWorkdirDialog:()=>x_,updateWorkspacePanelVisibility:()=>Jg});n(`zh`,{workspace:{workDir:`工作目录`,closePanel:`关闭面板`,embedMode:`嵌入模式`,floatMode:`浮窗模式`,openPanel:`打开工作目录面板`,narrowViewportHint:`视口过窄,已切回浮窗模式`,switchWorkdir:`切换工作目录`,backToParent:`返回上级目录`,uploadToCurrent:`上传文件到当前目录`,newFolder:`新建文件夹`,askSelectedFiles:`基于选中的文件进行问答`,downloadSelected:`下载选中的文件/目录(多选打包为ZIP)`,deleteSelected:`删除选中的文件`,clearSearch:`清除`,search:`搜索`,searchPlaceholder:`搜索...`,selectAllToggle:`全选/取消全选`,colName:`文件名`,colSize:`大小`,colTime:`修改时间`,noMatch:`未找到匹配的文件`,dirEmpty:`此目录为空`,noWorkspace:`无法获取工作目录,请确认 Agent 已连接`,loadDirFailed:`加载目录失败`,refreshFailed:`无法刷新,请确认 Agent 已连接`,agentNotConnected:`Agent 未连接`,agentNotConnectedUpload:`Agent 未连接,无法上传`,unsupportedFileType:`不支持的文件类型`,unknownError:`未知错误`,copiedFileName:`已复制文件名: {name}`,copiedPath:`已复制路径: {path}`,copyFailed:`复制失败`,copiedToClipboard:`已复制到剪贴板`,copyFailedManual:`复制失败,请手动选择复制`,getContentFailed:`获取内容失败`,codeCopiedToClipboard:`代码已复制到剪贴板`,copyUnsupportedType:`此文件类型不支持复制文本内容`,copiedToClipboardShort:`已复制到剪贴板`,clickToCopy:`点击复制`,preview:`预览`,previewBtn:`预览`,details:`详情`,download:`下载`,downloadFile:`下载文件`,rename:`重命名`,askFile:`基于文件问答`,delete:`删除`,copyAll:`复制`,copyAllTitle:`复制全部内容`,toggleRenderPreview:`切换渲染预览`,openInBrowser:`在浏览器中打开`,openInBrowserBtn:`在浏览器中打开`,fullscreenPreview:`全屏预览`,exitFullscreen:`退出全屏`,enterEditMode:`进入编辑模式`,edit:`编辑`,save:`保存`,saveChanges:`保存修改 (Ctrl+S)`,cancelChanges:`取消修改 (Esc)`,closePreview:`关闭预览`,close:`关闭`,confirm:`确定`,cancel:`取消`,switchToSourcePreview:`切换为源码预览`,switchToRenderPreview:`切换为渲染预览`,markdownRendered:`Markdown 渲染`,lineCount:`{count} 行`,linesModified:`{count} 行 · 已修改`,truncatedHint:`(仅显示前 {shown} 行,共 {total} 行,请下载查看完整内容)`,fileTooLargeNoPreview:`文件过大 ({size}),不支持预览,请直接下载`,fileTooLargeOpenInBrowser:`文件过大 ({size}),无法内置预览,请点击上方「在浏览器中打开」按钮查看`,previewFailed:`预览失败: {error}`,openFailed:`打开失败: {error}`,documentEmpty:`(文档为空)`,pptxEmptyOrFailed:`PPTX 文件为空或解析失败`,pageCount:`{count} 页`,prevPage:`上一页`,nextPage:`下一页`,zoomOut:`缩小`,zoomIn:`放大`,fitPage:`适应页面`,originalSize:`原始大小`,imageLoadFailed:`图片加载失败`,parsingExcel:`正在解析 Excel 文件...`,loadingData:`正在加载数据...`,requestFailed:`请求失败: {error}`,parseFailed:`解析失败: {error}`,noSheetsInWorkbook:`工作簿中没有工作表`,sheetNotFound:`未找到工作表数据`,emptySheet:`(空工作表)`,xlsxTruncatedHint:`仅显示前 {shown} 行,共 {total} 行,请下载查看完整内容`,unsupportedMediaHint:`⚠ 浏览器不支持播放此格式({ext}),请下载后使用本地播放器查看。`,uploading:`上传中...`,downloadInProgress:`下载中`,uploadInProgress:`上传中`,cancelUpload:`取消上传`,downloadCanceled:`下载已取消`,downloadFailed:`下载失败`,downloadFailedWithError:`下载失败: {error}`,savingToLocal:`正在由浏览器保存至本地...`,savedToLocal:`已保存至本地`,downloaded:`已下载: {name}`,downloadedCount:`已下载 {count} 个文件`,downloadedZip:`已下载 {count} 个文件(ZIP 压缩包)`,fileCount:`{count} 个文件`,uploadCanceled:`已取消上传`,uploadSuccessCount:`成功 {count}`,uploadSkippedCount:`跳过 {count}`,uploadFailedCount:`失败 {count}`,uploadComplete:`上传完成`,uploadCompleteWithStats:`上传完成 · {stats}`,uploadedFiles:`成功上传 {count} 个文件`,filesSkipped:`{count} 个文件已存在,跳过上传`,filesUploadFailed:`{count} 个文件上传失败`,uploadFailed:`上传失败`,uploadFailedWithStatus:`上传失败 ({status})`,parseResponseFailed:`解析响应失败`,networkError:`网络错误`,cannotMoveToSubdir:`不能将目录移动到其子目录中`,moving:`移动中...`,movedToDir:`"{name}" 已移动到目标目录`,movedToTarget:`"{name}" 已移动到 "{target}"`,moveFailed:`移动失败: {error}`,searching:`搜索中...`,confirmDeleteDir:`确定要删除目录 "{name}" 及其所有内容吗?
|
|
747
747
|
|
|
748
748
|
路径: {path}
|
|
749
749
|
类型: 目录
|
|
@@ -758,11 +758,14 @@ import{o as e,r as t}from"./chunk-CMxvf4Kt.js";import{a as n,c as r,i,l as a,n a
|
|
|
758
758
|
{names}
|
|
759
759
|
|
|
760
760
|
删除后可在回收站中恢复(7天后自动清理)`,batchNamesMore:`
|
|
761
|
-
• ... 等共 {count} 项`,confirmBatchDeleteTitle:`确认批量删除`,deletedCount:`已删除 {success} 项{failed}`,deletedCountFailed:`,{count} 项失败`,fileDetailsTitle:`{name} - 文件详情`,getTypeDir:`目录`,getTypeSymlink:`符号链接`,getTypeFile:`文件`,bytes:`字节`,infoName:`名称`,infoType:`类型`,infoPath:`路径`,infoSize:`大小`,infoMime:`MIME 类型`,infoMtime:`修改时间`,infoCtime:`创建时间`,infoAtime:`访问时间`,infoPermission:`权限`,getDetailsFailed:`获取详情失败: {error}`,getWorkdirInfoFailed:`获取工作目录信息失败`,cannotConnectAgent:`无法连接 Agent,请确认代理已启动`,switchWorkdirTitle:`切换工作目录`,currentLabel:`当前: `,notSet:`未设置`,selectFromAllowed:`从允许的目录中选择(非当前目录可移除)`,orInputPath:`或输入绝对路径`,manualPathPlaceholder:`/Users/you/path 或 ~/path`,browseBtn:`浏览…`,browseUnavailable:`当前代理端环境不支持目录选择,请手动输入路径`,browseFailedWithError:`目录选择失败: {error}`,browseAgentOutdated:`当前代理端版本过旧,不支持目录选择,请更新代理端后重试`,browseBusy:`已有一个目录选择窗口在等待,请先完成或关闭它`,browseTimeout:`目录选择窗口未响应(可能被系统安全策略拦截或窗口不可见),请手动输入路径`,picking:`等待选择…`,switchBtn:`切换`,noAllowedPaths:`暂无允许的目录`,currentTag:`当前`,removeFromAllowed:`从允许列表移除`,confirmRemovePath:`确定要从允许访问的目录列表中移除以下目录吗?
|
|
761
|
+
• ... 等共 {count} 项`,confirmBatchDeleteTitle:`确认批量删除`,deletedCount:`已删除 {success} 项{failed}`,deletedCountFailed:`,{count} 项失败`,fileDetailsTitle:`{name} - 文件详情`,getTypeDir:`目录`,getTypeSymlink:`符号链接`,getTypeFile:`文件`,bytes:`字节`,infoName:`名称`,infoType:`类型`,infoPath:`路径`,infoSize:`大小`,infoMime:`MIME 类型`,infoMtime:`修改时间`,infoCtime:`创建时间`,infoAtime:`访问时间`,infoPermission:`权限`,getDetailsFailed:`获取详情失败: {error}`,getWorkdirInfoFailed:`获取工作目录信息失败`,cannotConnectAgent:`无法连接 Agent,请确认代理已启动`,switchWorkdirTitle:`切换工作目录`,currentLabel:`当前: `,notSet:`未设置`,selectFromAllowed:`从允许的目录中选择(非当前目录可移除)`,orInputPath:`或输入绝对路径`,manualPathPlaceholder:`/Users/you/path 或 ~/path`,browseBtn:`浏览…`,browseUnavailable:`当前代理端环境不支持目录选择,请手动输入路径`,browseFailedWithError:`目录选择失败: {error}`,browseAgentOutdated:`当前代理端版本过旧,不支持目录选择,请更新代理端后重试`,browseBusy:`已有一个目录选择窗口在等待,请先完成或关闭它`,browseTimeout:`目录选择窗口未响应(可能被系统安全策略拦截或窗口不可见),请手动输入路径`,picking:`等待选择…`,switchBtn:`切换`,noAllowedPaths:`暂无允许的目录`,currentTag:`当前`,defaultTag:`默认`,removeFromAllowed:`从允许列表移除`,confirmRemovePath:`确定要从允许访问的目录列表中移除以下目录吗?
|
|
762
762
|
{path}
|
|
763
763
|
|
|
764
|
-
移除后 AI 将无法访问该目录,可重新切换工作目录再加回。`,
|
|
765
|
-
{path}
|
|
764
|
+
移除后 AI 将无法访问该目录,可重新切换工作目录再加回。`,confirmRemoveStillUsable:`确定要从允许访问的目录列表中移除以下目录吗?
|
|
765
|
+
{path}
|
|
766
|
+
|
|
767
|
+
它是当前会话的目录或代理默认目录,移出列表后仍照常可用(工作目录不受允许列表限制),只是不再作为「附加授权」显示。`,confirmRemovePathTitle:`确认移除允许目录`,removedFromAllowed:`已从允许列表移除`,removedStillUsable:`已从允许列表移除(它仍是工作目录/默认目录,照常可用)`,removeFailedWithError:`移除失败: {error}`,selectOrInputPath:`请选择或输入目标路径`,alreadyCurrentWorkdir:`该目录已是当前工作目录`,confirmSwitchToNewDefault:`该路径不在允许列表内。本次会把它设为代理默认目录,切换后自动创建目录并加入允许列表(影响未绑定的会话):
|
|
768
|
+
{path}`,confirmSwitchToNewTitle:`确认切换到新默认目录`,switchFailedWithError:`切换失败: {error}`,switchedTo:`已切换到: {path}`,switchedToAndSetDefault:`已切换到: {path},并设为代理默认目录`,setAsDefaultDone:`已设为代理默认目录: {path}`,renameDir:`重命名目录`,renameFile:`重命名文件`,inputNewName:`输入新名称`,renamedTo:`已重命名为 "{name}"`,renameFailedWithError:`重命名失败: {error}`,newFolderTitle:`新建文件夹`,inputFolderName:`输入文件夹名称`,folderCreated:`已创建文件夹 "{name}"`,createFailedWithError:`创建失败: {error}`,addedFilesToQuestion:`已添加 {count} 个文件到问答`,addedFilesToQuestionNoImage:`已添加 {count} 个文件到问答(图片识别未启用,图片作为文件附件)`,selectedCount:`已选 {count}`,unsavedChanges:`未保存的修改`,discardChangesPrompt:`有未保存的修改,确定要{action}吗?`,actionClosePreview:`关闭预览`,actionCancelEdit:`取消编辑`,saving:`保存中...`,saveSuccess:`保存成功`,saveFailedWithError:`保存失败: {error}`,agentNamePrefix:` · {name}`,agentNotPaired:`Agent 未配对`,fileDetailsLabel:`文件详情`,loadingLabel:`加载中...`,export:`导出`,exportDocx:`Word`,exportPdf:`PDF`,exportImage:`图片`,exportMd:`Markdown`,copyMarkdownHint:`按住 Ctrl/Cmd 点击复制富文本`}}),n(`en`,{workspace:{workDir:`Working Directory`,closePanel:`Close Panel`,embedMode:`Embed mode`,floatMode:`Floating mode`,openPanel:`Open workspace panel`,narrowViewportHint:`Viewport too narrow, switched back to floating mode`,switchWorkdir:`Switch Working Directory`,backToParent:`Back to Parent Directory`,uploadToCurrent:`Upload files to current directory`,newFolder:`New Folder`,askSelectedFiles:`Ask based on selected files`,downloadSelected:`Download selected files/directories (multi-select as ZIP)`,deleteSelected:`Delete selected files`,clearSearch:`Clear`,search:`Search`,searchPlaceholder:`Search...`,selectAllToggle:`Select All / Deselect All`,colName:`Name`,colSize:`Size`,colTime:`Modified`,noMatch:`No matching files found`,dirEmpty:`This directory is empty`,noWorkspace:`Unable to access working directory. Please confirm the Agent is connected.`,loadDirFailed:`Failed to load directory`,refreshFailed:`Unable to refresh. Please confirm the Agent is connected.`,agentNotConnected:`Agent not connected`,agentNotConnectedUpload:`Agent not connected, unable to upload`,unsupportedFileType:`Unsupported file type`,unknownError:`Unknown error`,copiedFileName:`Copied file name: {name}`,copiedPath:`Copied path: {path}`,copyFailed:`Copy failed`,copiedToClipboard:`Copied to clipboard`,copyFailedManual:`Copy failed, please select and copy manually`,getContentFailed:`Failed to get content`,codeCopiedToClipboard:`Code copied to clipboard`,copyUnsupportedType:`Copying text content is not supported for this file type`,copiedToClipboardShort:`Copied to clipboard`,clickToCopy:`Click to copy`,preview:`Preview`,previewBtn:`Preview`,details:`Details`,download:`Download`,downloadFile:`Download file`,rename:`Rename`,askFile:`Ask about file`,delete:`Delete`,copyAll:`Copy`,copyAllTitle:`Copy all content`,toggleRenderPreview:`Toggle rendered preview`,openInBrowser:`Open in browser`,openInBrowserBtn:`Open in browser`,fullscreenPreview:`Fullscreen preview`,exitFullscreen:`Exit fullscreen`,enterEditMode:`Enter edit mode`,edit:`Edit`,save:`Save`,saveChanges:`Save changes (Ctrl+S)`,cancelChanges:`Cancel changes (Esc)`,closePreview:`Close preview`,close:`Close`,confirm:`OK`,cancel:`Cancel`,switchToSourcePreview:`Switch to source preview`,switchToRenderPreview:`Switch to rendered preview`,markdownRendered:`Markdown rendered`,lineCount:`{count} lines`,linesModified:`{count} lines · Modified`,truncatedHint:`(Showing first {shown} of {total} lines. Download to view full content.)`,fileTooLargeNoPreview:`File too large ({size}). Preview not supported. Please download directly.`,fileTooLargeOpenInBrowser:`File too large ({size}) for built-in preview. Please click "Open in browser" above to view.`,previewFailed:`Preview failed: {error}`,openFailed:`Open failed: {error}`,documentEmpty:`(Empty document)`,pptxEmptyOrFailed:`PPTX file is empty or failed to parse`,pageCount:`{count} pages`,prevPage:`Previous page`,nextPage:`Next page`,zoomOut:`Zoom out`,zoomIn:`Zoom in`,fitPage:`Fit page`,originalSize:`Original size`,imageLoadFailed:`Image load failed`,parsingExcel:`Parsing Excel file...`,loadingData:`Loading data...`,requestFailed:`Request failed: {error}`,parseFailed:`Parse failed: {error}`,noSheetsInWorkbook:`No worksheets in the workbook`,sheetNotFound:`Worksheet data not found`,emptySheet:`(Empty sheet)`,xlsxTruncatedHint:`Showing first {shown} of {total} rows. Download to view full content.`,unsupportedMediaHint:`⚠ The browser cannot play this format ({ext}). Please download and use a local player.`,uploading:`Uploading...`,downloadInProgress:`Downloading`,uploadInProgress:`Uploading`,cancelUpload:`Cancel upload`,downloadCanceled:`Download canceled`,downloadFailed:`Download failed`,downloadFailedWithError:`Download failed: {error}`,savingToLocal:`Saving to local via browser...`,savedToLocal:`Saved to local`,downloaded:`Downloaded: {name}`,downloadedCount:`Downloaded {count} files`,downloadedZip:`Downloaded {count} files (ZIP archive)`,fileCount:`{count} files`,uploadCanceled:`Upload canceled`,uploadSuccessCount:`Success {count}`,uploadSkippedCount:`Skipped {count}`,uploadFailedCount:`Failed {count}`,uploadComplete:`Upload complete`,uploadCompleteWithStats:`Upload complete · {stats}`,uploadedFiles:`Successfully uploaded {count} files`,filesSkipped:`{count} file(s) already exist, skipped`,filesUploadFailed:`{count} file(s) failed to upload`,uploadFailed:`Upload failed`,uploadFailedWithStatus:`Upload failed ({status})`,parseResponseFailed:`Failed to parse response`,networkError:`Network error`,cannotMoveToSubdir:`Cannot move a directory into its own subdirectory`,moving:`Moving...`,movedToDir:`"{name}" moved to target directory`,movedToTarget:`"{name}" moved to "{target}"`,moveFailed:`Move failed: {error}`,searching:`Searching...`,confirmDeleteDir:`Are you sure you want to delete directory "{name}" and all its contents?
|
|
766
769
|
|
|
767
770
|
Path: {path}
|
|
768
771
|
Type: Directory
|
|
@@ -777,11 +780,14 @@ Deleted items can be restored from the trash (auto-cleaned after 7 days).`,confi
|
|
|
777
780
|
{names}
|
|
778
781
|
|
|
779
782
|
Deleted items can be restored from the trash (auto-cleaned after 7 days).`,batchNamesMore:`
|
|
780
|
-
• ... and {count} more`,confirmBatchDeleteTitle:`Confirm Batch Delete`,deletedCount:`Deleted {success} item(s){failed}`,deletedCountFailed:`, {count} failed`,fileDetailsTitle:`{name} - File Details`,getTypeDir:`Directory`,getTypeSymlink:`Symbolic link`,getTypeFile:`File`,bytes:`bytes`,infoName:`Name`,infoType:`Type`,infoPath:`Path`,infoSize:`Size`,infoMime:`MIME Type`,infoMtime:`Modified`,infoCtime:`Created`,infoAtime:`Accessed`,infoPermission:`Permission`,getDetailsFailed:`Failed to get details: {error}`,getWorkdirInfoFailed:`Failed to get working directory info`,cannotConnectAgent:`Cannot connect to Agent. Please confirm the agent is running.`,switchWorkdirTitle:`Switch Working Directory`,currentLabel:`Current: `,notSet:`Not set`,selectFromAllowed:`Select from allowed directories (non-current can be removed)`,orInputPath:`Or enter an absolute path`,manualPathPlaceholder:`/Users/you/path or ~/path`,browseBtn:`Browse…`,browseUnavailable:`The agent environment does not support directory selection. Please enter the path manually.`,browseFailedWithError:`Directory selection failed: {error}`,browseAgentOutdated:`The agent version is outdated and does not support directory selection. Please update the agent and try again.`,browseBusy:`A directory picker is already open. Please finish or close it first.`,browseTimeout:`The directory picker did not respond (it may be blocked by security policy or not visible). Please enter the path manually.`,picking:`Waiting…`,switchBtn:`Switch`,noAllowedPaths:`No allowed directories`,currentTag:`Current`,removeFromAllowed:`Remove from allowed list`,confirmRemovePath:`Are you sure you want to remove the following directory from the allowed list?
|
|
783
|
+
• ... and {count} more`,confirmBatchDeleteTitle:`Confirm Batch Delete`,deletedCount:`Deleted {success} item(s){failed}`,deletedCountFailed:`, {count} failed`,fileDetailsTitle:`{name} - File Details`,getTypeDir:`Directory`,getTypeSymlink:`Symbolic link`,getTypeFile:`File`,bytes:`bytes`,infoName:`Name`,infoType:`Type`,infoPath:`Path`,infoSize:`Size`,infoMime:`MIME Type`,infoMtime:`Modified`,infoCtime:`Created`,infoAtime:`Accessed`,infoPermission:`Permission`,getDetailsFailed:`Failed to get details: {error}`,getWorkdirInfoFailed:`Failed to get working directory info`,cannotConnectAgent:`Cannot connect to Agent. Please confirm the agent is running.`,switchWorkdirTitle:`Switch Working Directory`,currentLabel:`Current: `,notSet:`Not set`,selectFromAllowed:`Select from allowed directories (non-current can be removed)`,orInputPath:`Or enter an absolute path`,manualPathPlaceholder:`/Users/you/path or ~/path`,browseBtn:`Browse…`,browseUnavailable:`The agent environment does not support directory selection. Please enter the path manually.`,browseFailedWithError:`Directory selection failed: {error}`,browseAgentOutdated:`The agent version is outdated and does not support directory selection. Please update the agent and try again.`,browseBusy:`A directory picker is already open. Please finish or close it first.`,browseTimeout:`The directory picker did not respond (it may be blocked by security policy or not visible). Please enter the path manually.`,picking:`Waiting…`,switchBtn:`Switch`,noAllowedPaths:`No allowed directories`,currentTag:`Current`,defaultTag:`Default`,removeFromAllowed:`Remove from allowed list`,confirmRemovePath:`Are you sure you want to remove the following directory from the allowed list?
|
|
784
|
+
{path}
|
|
785
|
+
|
|
786
|
+
After removal, the AI will no longer be able to access this directory. You can switch the working directory again to add it back.`,confirmRemoveStillUsable:`Remove the following directory from the allowed list?
|
|
781
787
|
{path}
|
|
782
788
|
|
|
783
|
-
|
|
784
|
-
{path}`,confirmSwitchToNewTitle:`Confirm Switch to New Directory`,switchFailedWithError:`Switch failed: {error}`,switchedTo:`Switched to: {path}`,renameDir:`Rename Directory`,renameFile:`Rename File`,inputNewName:`Enter new name`,renamedTo:`Renamed to "{name}"`,renameFailedWithError:`Rename failed: {error}`,newFolderTitle:`New Folder`,inputFolderName:`Enter folder name`,folderCreated:`Folder "{name}" created`,createFailedWithError:`Create failed: {error}`,addedFilesToQuestion:`Added {count} file(s) to question`,addedFilesToQuestionNoImage:`Added {count} file(s) to question (image recognition disabled; images attached as files)`,selectedCount:`{count} selected`,unsavedChanges:`Unsaved Changes`,discardChangesPrompt:`You have unsaved changes. Are you sure you want to {action}?`,actionClosePreview:`close the preview`,actionCancelEdit:`cancel editing`,saving:`Saving...`,saveSuccess:`Saved successfully`,saveFailedWithError:`Save failed: {error}`,agentNamePrefix:` · {name}`,agentNotPaired:`Agent not paired`,fileDetailsLabel:`File Details`,loadingLabel:`Loading...`,export:`Export`,exportDocx:`Word`,exportPdf:`PDF`,exportImage:`Image`,exportMd:`Markdown`,copyMarkdownHint:`Ctrl/Cmd+Click to copy rich text`}});var q=null,Ep=null,Dp=[],Op=50,kp=240,Ap=280,jp=520,Mp=320,Np=`workspacePanelEmbedMode`,Pp=`workspacePanelEmbedWidth`,Fp=`workspacePanelExpanded`,Ip=!1,Lp=Mp,Rp=!1,zp=!1,Bp=!1,Vp={field:`name`,asc:!0},J=new Set,Hp=!1,Up=!1,Wp=-1,Gp=!1,Kp=null;function qp(e,t,n){e?.aborted||window.addEventListener(t,n,e?{signal:e}:void 0)}function Jp(){if(Bp)return;Bp=!0;let e=document.createElement(`div`);e.className=`workspace-panel-container`,e.id=`workspacePanelContainer`,e.innerHTML=`
|
|
789
|
+
It is this session's directory or the agent default, so it stays accessible (working directories bypass the allowed list). It will simply no longer be listed as an additional allowed entry.`,confirmRemovePathTitle:`Confirm Remove Allowed Directory`,removedFromAllowed:`Removed from allowed list`,removedStillUsable:`Removed from allowed list (still available as the working/default directory)`,removeFailedWithError:`Remove failed: {error}`,selectOrInputPath:`Please select or enter a target path`,alreadyCurrentWorkdir:`This directory is already the current working directory`,confirmSwitchToNewDefault:`This path is not in the allowed list. It will become the agent default, so switching also creates the directory and adds it to the allowed list (affects unbound sessions):
|
|
790
|
+
{path}`,confirmSwitchToNewTitle:`Confirm Switch to New Default Directory`,switchFailedWithError:`Switch failed: {error}`,switchedTo:`Switched to: {path}`,switchedToAndSetDefault:`Switched to: {path} (set as agent default)`,setAsDefaultDone:`Set as agent default: {path}`,renameDir:`Rename Directory`,renameFile:`Rename File`,inputNewName:`Enter new name`,renamedTo:`Renamed to "{name}"`,renameFailedWithError:`Rename failed: {error}`,newFolderTitle:`New Folder`,inputFolderName:`Enter folder name`,folderCreated:`Folder "{name}" created`,createFailedWithError:`Create failed: {error}`,addedFilesToQuestion:`Added {count} file(s) to question`,addedFilesToQuestionNoImage:`Added {count} file(s) to question (image recognition disabled; images attached as files)`,selectedCount:`{count} selected`,unsavedChanges:`Unsaved Changes`,discardChangesPrompt:`You have unsaved changes. Are you sure you want to {action}?`,actionClosePreview:`close the preview`,actionCancelEdit:`cancel editing`,saving:`Saving...`,saveSuccess:`Saved successfully`,saveFailedWithError:`Save failed: {error}`,agentNamePrefix:` · {name}`,agentNotPaired:`Agent not paired`,fileDetailsLabel:`File Details`,loadingLabel:`Loading...`,export:`Export`,exportDocx:`Word`,exportPdf:`PDF`,exportImage:`Image`,exportMd:`Markdown`,copyMarkdownHint:`Ctrl/Cmd+Click to copy rich text`}});var q=null,Ep=null,Dp=[],Op=50,kp=240,Ap=280,jp=520,Mp=320,Np=`workspacePanelEmbedMode`,Pp=`workspacePanelEmbedWidth`,Fp=`workspacePanelExpanded`,Ip=!1,Lp=Mp,Rp=!1,zp=!1,Bp=!1,Vp={field:`name`,asc:!0},J=new Set,Hp=!1,Up=!1,Wp=-1,Gp=!1,Kp=null;function qp(e,t,n){e?.aborted||window.addEventListener(t,n,e?{signal:e}:void 0)}function Jp(){if(Bp)return;Bp=!0;let e=document.createElement(`div`);e.className=`workspace-panel-container`,e.id=`workspacePanelContainer`,e.innerHTML=`
|
|
785
791
|
<button class="workspace-panel-toggle" id="workspacePanelToggle" title="${r(`workspace.workDir`)}">
|
|
786
792
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
787
793
|
<path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/>
|
|
@@ -979,7 +985,7 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
979
985
|
<div class="workspace-preview-content" id="workspacePreviewContent"></div>
|
|
980
986
|
</div>
|
|
981
987
|
</div>
|
|
982
|
-
`,Vn(`workspace`).appendChild(e),Yp(),document.addEventListener(`session-switched`,()=>{w_().catch(e=>a.warn(`[WorkspacePanel] sync after session switch failed`,e))}),document.addEventListener(`session-workdir-changed`,e=>{let t=e.detail?.sessionId;t&&t!==N.activeSessionId||w_().catch(e=>a.warn(`[WorkspacePanel] sync after workdir change failed`,e))}),document.addEventListener(`session-hydrated`,()=>{w_().catch(e=>a.warn(`[WorkspacePanel] sync after session hydrated failed`,e))}),u_(),Rg(),lm(),um(),pm(),a.debug(`[WorkspacePanel] workspace panelinitializing`)}function Yp(){document.getElementById(`workspacePanelContainer`);let e=document.getElementById(`workspacePanel`);document.getElementById(`workspacePanelToggle`).addEventListener(`click`,async t=>{t.stopPropagation(),e.classList.contains(`expanded`)?gm():await hm()}),document.getElementById(`workspacePanelClose`).addEventListener(`click`,e=>{e.stopPropagation(),gm()}),document.getElementById(`workspacePanelModeBtn`).addEventListener(`click`,async e=>{e.stopPropagation(),await cm()});let t=document.getElementById(`workspaceSwitchBtn`);t&&t.addEventListener(`click`,async e=>{e.stopPropagation(),await x_()}),document.getElementById(`workspaceBackBtn`).addEventListener(`click`,e=>{e.stopPropagation(),Bg()}),document.getElementById(`workspaceRefreshBtn`).addEventListener(`click`,e=>{e.stopPropagation(),Vg()}),document.getElementById(`workspaceUploadBtn`).addEventListener(`click`,e=>{e.stopPropagation(),wg()}),document.getElementById(`workspaceNewFolderBtn`).addEventListener(`click`,e=>{e.stopPropagation(),k_()}),document.getElementById(`workspaceAskBtn`).addEventListener(`click`,e=>{e.stopPropagation(),M_()}),document.getElementById(`workspaceDownloadDirBtn`).addEventListener(`click`,e=>{e.stopPropagation(),Sg()}),document.getElementById(`workspaceBatchDeleteBtn`).addEventListener(`click`,e=>{e.stopPropagation(),g_()});let n=document.getElementById(`workspaceSearchInput`),i=document.getElementById(`workspaceToolbar`),a=i.querySelector(`.workspace-search-box`);function o(){return i.clientWidth<188}function s(){n.value.trim()?(a.classList.add(`search-box-expanded`),o()&&i.classList.add(`search-focused`)):(a.classList.remove(`search-box-expanded`),i.classList.remove(`search-focused`))}n.addEventListener(`input`,e=>{f_(e),s()}),n.addEventListener(`focus`,()=>{o()&&i.classList.add(`search-focused`)}),n.addEventListener(`blur`,()=>{n.value.trim()||i.classList.remove(`search-focused`)}),n.addEventListener(`keydown`,e=>{if(e.key===`Enter`)e.stopPropagation(),p_();else if(e.key===`Escape`)e.stopPropagation(),m_();else if(e.key===`ArrowUp`){if(e.preventDefault(),c_.length===0)return;l_===-1?l_=c_.length-1:l_>0&&l_--,n.value=c_[l_],a_=n.value.trim(),document.getElementById(`workspaceSearchClear`).style.display=a_?``:`none`}else e.key===`ArrowDown`&&(e.preventDefault(),l_===-1||l_>=c_.length-1?(l_=-1,n.value=``,a_=``,document.getElementById(`workspaceSearchClear`).style.display=`none`):(l_++,n.value=c_[l_],a_=n.value.trim(),document.getElementById(`workspaceSearchClear`).style.display=a_?``:`none`))}),document.getElementById(`workspaceSearchBtn`).addEventListener(`click`,()=>{n.focus(),p_()}),document.getElementById(`workspaceSearchClear`).addEventListener(`click`,m_),document.getElementById(`workspacePanel`).querySelectorAll(`.workspace-file-header .sortable`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.sort;Vp.field===t?Vp.asc=!Vp.asc:(Vp.field=t,Vp.asc=!0),Km(),Pm()})}),document.getElementById(`workspaceSelectAll`).addEventListener(`click`,Wm),document.getElementById(`workspacePanelContent`).addEventListener(`click`,Vm),document.getElementById(`workspacePanelContent`).addEventListener(`dblclick`,Hm),document.getElementById(`workspacePanelContent`).addEventListener(`keydown`,Bm),document.getElementById(`workspacePanelContent`).tabIndex=0,document.getElementById(`workspacePanelContent`).addEventListener(`dragstart`,zm);let c=null;document.getElementById(`workspacePanelContent`).addEventListener(`scroll`,()=>{Am&&(c&&cancelAnimationFrame(c),c=requestAnimationFrame(()=>{c=null,document.getElementById(`workspacePanelContent`).scrollTop!==jm&&Nm()}))}),document.getElementById(`workspacePreviewClose`).addEventListener(`click`,()=>mg()),document.getElementById(`workspacePreviewCopyBtn`).addEventListener(`click`,e=>rg(e)),document.getElementById(`workspacePreviewDownloadBtn`).addEventListener(`click`,og),document.getElementById(`workspacePreviewOpenBrowserBtn`).addEventListener(`click`,sg),document.getElementById(`workspacePreviewFullscreenBtn`).addEventListener(`click`,lg),document.getElementById(`workspacePreviewMdToggleBtn`).addEventListener(`click`,ug),document.getElementById(`workspacePreviewEditBtn`).addEventListener(`click`,hg),document.getElementById(`workspacePreviewSaveBtn`).addEventListener(`click`,gg),document.getElementById(`workspacePreviewCancelBtn`).addEventListener(`click`,_g),Kh(),document.addEventListener(`keydown`,bg),document.getElementById(`workspacePreviewFilename`).addEventListener(`click`,async e=>{let t=document.getElementById(`workspacePreviewArea`),n=t.dataset.previewName,i=t.dataset.previewPath;if(n){if((e.ctrlKey||e.metaKey)&&!e.shiftKey){e.preventDefault();try{await navigator.clipboard.writeText(n),P(r(`workspace.copiedFileName`,{name:n}))}catch{P(r(`workspace.copyFailed`),`error`)}}else if((e.ctrlKey||e.metaKey)&&e.shiftKey){if(e.preventDefault(),!i)return;try{await navigator.clipboard.writeText(i),P(r(`workspace.copiedPath`,{path:i}))}catch{P(r(`workspace.copyFailed`),`error`)}}}}),Lg(),chrome.storage.local.onChanged.addListener(zg);let l=document.createElement(`input`);l.type=`file`,l.multiple=!0,l.id=`workspaceFileInput`,l.style.display=`none`,l.addEventListener(`change`,Tg),document.body.appendChild(l)}var Xp=[];function Zp(e){Dp.push(e),Dp.length>Op&&Dp.shift()}function Qp(e){if(!e||typeof e!=`string`)return`unnamed`;let t=e.replace(/[<>:"|?*\\/\x00-\x1f]/g,`_`);return t=t.replace(/\.+$/,``),t=t.trim(),t||=`unnamed`,t}function $p(e,t){let n=X(e);if(!t)return n;let r=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return n.replace(RegExp(`(${r})`,`gi`),`<mark class="search-highlight">$1</mark>`)}var em=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M15 3v18"/></svg>`,tm=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M15 3v18"/><path d="m8 9-3 3 3 3"/></svg>`;function nm(){let e=document.getElementById(`mainRow`),t=e?e.clientWidth:window.innerWidth;return Math.max(kp,t-Ap)}function rm(e){return Math.max(kp,Math.min(e,nm()))}function im(e){let t=document.getElementById(`workspacePanelModeBtn`);t&&(t.title=r(e?`workspace.floatMode`:`workspace.embedMode`),t.innerHTML=e?tm:em)}function am(){let e=document.getElementById(`workspacePanelContainer`);if(!e)return;let t=document.getElementById(`mainRow`);t&&e.parentElement!==t&&t.appendChild(e),e.classList.add(`embedded`),e.style.setProperty(`--ws-embed-width`,`${Lp}px`),im(!0)}function om(){let e=document.getElementById(`workspacePanelContainer`);if(!e)return;e.classList.remove(`embedded`);let t=Vn(`workspace`);t&&e.parentElement!==t&&t.appendChild(e),im(!1)}async function sm(){try{await chrome.storage.local.set({[Np]:Ip,[Pp]:Lp})}catch(e){a.warn(`[WorkspacePanel] persist embed state failed`,e)}}async function cm(){if(Ip){Ip=!1,zp=!1,Rp=!1,om(),await sm();return}let e=document.getElementById(`mainRow`);if((e?e.clientWidth:window.innerWidth)<jp){P(r(`workspace.narrowViewportHint`),`error`);return}document.getElementById(`workspacePanel`).classList.contains(`expanded`)||await mm(),Lp=rm(Lp),am(),Ip=!0,zp=!0,Rp=!1,await sm()}function lm(){let e=document.getElementById(`workspacePanelContainer`),t=document.createElement(`div`);t.className=`workspace-embed-divider`,t.id=`workspaceEmbedDivider`,e.appendChild(t),t.addEventListener(`mousedown`,t=>{t.preventDefault();let n=t.clientX,r=Lp;e.classList.add(`resizing`);function i(t){let i=rm(r+(n-t.clientX));Lp=i,e.style.setProperty(`--ws-embed-width`,`${i}px`)}function a(){document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,a),e.classList.remove(`resizing`),sm()}document.addEventListener(`mousemove`,i),document.addEventListener(`mouseup`,a)})}function um(){let e=document.getElementById(`mainRow`);!e||typeof ResizeObserver>`u`||new ResizeObserver(()=>{if(Ip){e.clientWidth<jp&&(Rp=!1,Ip=!1,zp=!1,om(),sm(),P(r(`workspace.narrowViewportHint`),`error`));return}Rp&&e.clientWidth>=jp&&fm()}).observe(e)}async function dm(){if(Ip)return!0;let e=document.getElementById(`workspacePanelContainer`);if(e&&e.style.display===`none`)return!1;let t=document.getElementById(`mainRow`);return(t?t.clientWidth:window.innerWidth)<jp?!1:(Lp=rm(Lp),document.getElementById(`workspacePanel`).classList.contains(`expanded`)||await mm(),am(),Ip=!0,!0)}function fm(){Rp=!1,dm().then(e=>{e||(Rp=!0)}).catch(e=>{a.warn(`[WorkspacePanel] deferred embed restore failed`,e),Rp=!0})}async function pm(){try{let e=await chrome.storage.local.get([Np,Pp,Fp]);if(typeof e[Pp]==`number`&&e[Pp]>=kp&&(Lp=Math.round(e[Pp])),!e[Np]||(zp=!0,e[Fp]===!1)||(await new Promise(e=>{let t=!1,n=()=>{t||(t=!0,e())};requestAnimationFrame(()=>requestAnimationFrame(n)),setTimeout(n,500)}),await dm()))return;Rp=!0}catch(e){a.warn(`[WorkspacePanel] restore embed state failed`,e)}}async function mm(){let e=document.getElementById(`workspacePanel`);e.classList.contains(`expanded`)||(e.classList.add(`expanded`),xt(e),chrome.storage.local.set({[Fp]:!0}).catch(()=>{}),await Rg(),q||await _m())}async function hm(){let e=document.getElementById(`workspacePanel`);if(!(!e||e.classList.contains(`expanded`)))if(Gp=!1,zp){let e=document.getElementById(`mainRow`);if((e?e.clientWidth:window.innerWidth)<jp){await mm(),P(r(`workspace.narrowViewportHint`),`error`);return}await mm(),Lp=rm(Lp),am(),Ip=!0,Rp=!1,await sm()}else await mm()}function gm(){i_()}async function _m(){let e=await sn();if(!e){Wg(r(`workspace.noWorkspace`));return}Ep=e,Dp=[],vm(e)}async function vm(e){q=e,J.clear(),Hg(),Ug(),F_(),Km(),s_&&a_?(o_=await bn(e,a_),Pm()):await wm(e),Gm()}var ym=new Map,bm=3e4,xm=20;function Sm(e){let t=ym.get(e);return t?Date.now()-t.timestamp>=bm?(ym.delete(e),null):(ym.delete(e),ym.set(e,t),t):null}function Cm(e,t){ym.has(e)&&ym.delete(e),ym.set(e,t),ym.size>xm&&ym.delete(ym.keys().next().value)}async function wm(e){let t=document.getElementById(`workspacePanelContent`);t.innerHTML=`<div class="workspace-panel-loading">${r(`common.loading`)}</div>`;let n=Sm(e);if(n){Xp=n.entries,Pm();return}let i=await en(e);if(!i.success){Wg(i.error||r(`workspace.loadDirFailed`));return}Xp=(i.entries||[]).map(t=>({...t,path:Tm(`${e}/${t.name}`)})),Cm(e,{entries:Xp,timestamp:Date.now()}),Pm()}function Tm(e){return(e||``).replace(/\\/g,`/`).replace(/\/+/g,`/`)}function Em(e){ym.delete(e)}var Dm=200,Om=32,km=5,Am=null,jm=0;function Mm(e){let t=an(e.name,e.type),n=e.type===`directory`?`—`:gn(e.size),i=rn(e.mtime),a=e.type===`file`&&$t(e.name),o=s_?e.fullPath:Tm(`${q}/${e.name}`),s=J.has(o),c=s_&&e.matchPath!==q?Tm(e.matchPath).replace(Tm(Ep),``).replace(/^\//,``)+`/`+e.name:``,l=s_?$p(e.name,a_):X(e.name);return`
|
|
988
|
+
`,Vn(`workspace`).appendChild(e),Yp(),document.addEventListener(`session-switched`,()=>{w_().catch(e=>a.warn(`[WorkspacePanel] sync after session switch failed`,e))}),document.addEventListener(`session-workdir-changed`,e=>{let t=e.detail?.sessionId;t&&t!==N.activeSessionId||w_().catch(e=>a.warn(`[WorkspacePanel] sync after workdir change failed`,e))}),document.addEventListener(`session-hydrated`,()=>{w_().catch(e=>a.warn(`[WorkspacePanel] sync after session hydrated failed`,e))}),u_(),Rg(),lm(),um(),pm(),a.debug(`[WorkspacePanel] workspace panelinitializing`)}function Yp(){document.getElementById(`workspacePanelContainer`);let e=document.getElementById(`workspacePanel`);document.getElementById(`workspacePanelToggle`).addEventListener(`click`,async t=>{t.stopPropagation(),e.classList.contains(`expanded`)?gm():await hm()}),document.getElementById(`workspacePanelClose`).addEventListener(`click`,e=>{e.stopPropagation(),gm()}),document.getElementById(`workspacePanelModeBtn`).addEventListener(`click`,async e=>{e.stopPropagation(),await cm()});let t=document.getElementById(`workspaceSwitchBtn`);t&&t.addEventListener(`click`,async e=>{e.stopPropagation(),await x_()}),document.getElementById(`workspaceBackBtn`).addEventListener(`click`,e=>{e.stopPropagation(),Bg()}),document.getElementById(`workspaceRefreshBtn`).addEventListener(`click`,e=>{e.stopPropagation(),Vg()}),document.getElementById(`workspaceUploadBtn`).addEventListener(`click`,e=>{e.stopPropagation(),wg()}),document.getElementById(`workspaceNewFolderBtn`).addEventListener(`click`,e=>{e.stopPropagation(),j_()}),document.getElementById(`workspaceAskBtn`).addEventListener(`click`,e=>{e.stopPropagation(),P_()}),document.getElementById(`workspaceDownloadDirBtn`).addEventListener(`click`,e=>{e.stopPropagation(),Sg()}),document.getElementById(`workspaceBatchDeleteBtn`).addEventListener(`click`,e=>{e.stopPropagation(),g_()});let n=document.getElementById(`workspaceSearchInput`),i=document.getElementById(`workspaceToolbar`),a=i.querySelector(`.workspace-search-box`);function o(){return i.clientWidth<188}function s(){n.value.trim()?(a.classList.add(`search-box-expanded`),o()&&i.classList.add(`search-focused`)):(a.classList.remove(`search-box-expanded`),i.classList.remove(`search-focused`))}n.addEventListener(`input`,e=>{f_(e),s()}),n.addEventListener(`focus`,()=>{o()&&i.classList.add(`search-focused`)}),n.addEventListener(`blur`,()=>{n.value.trim()||i.classList.remove(`search-focused`)}),n.addEventListener(`keydown`,e=>{if(e.key===`Enter`)e.stopPropagation(),p_();else if(e.key===`Escape`)e.stopPropagation(),m_();else if(e.key===`ArrowUp`){if(e.preventDefault(),c_.length===0)return;l_===-1?l_=c_.length-1:l_>0&&l_--,n.value=c_[l_],a_=n.value.trim(),document.getElementById(`workspaceSearchClear`).style.display=a_?``:`none`}else e.key===`ArrowDown`&&(e.preventDefault(),l_===-1||l_>=c_.length-1?(l_=-1,n.value=``,a_=``,document.getElementById(`workspaceSearchClear`).style.display=`none`):(l_++,n.value=c_[l_],a_=n.value.trim(),document.getElementById(`workspaceSearchClear`).style.display=a_?``:`none`))}),document.getElementById(`workspaceSearchBtn`).addEventListener(`click`,()=>{n.focus(),p_()}),document.getElementById(`workspaceSearchClear`).addEventListener(`click`,m_),document.getElementById(`workspacePanel`).querySelectorAll(`.workspace-file-header .sortable`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.sort;Vp.field===t?Vp.asc=!Vp.asc:(Vp.field=t,Vp.asc=!0),Km(),Pm()})}),document.getElementById(`workspaceSelectAll`).addEventListener(`click`,Wm),document.getElementById(`workspacePanelContent`).addEventListener(`click`,Vm),document.getElementById(`workspacePanelContent`).addEventListener(`dblclick`,Hm),document.getElementById(`workspacePanelContent`).addEventListener(`keydown`,Bm),document.getElementById(`workspacePanelContent`).tabIndex=0,document.getElementById(`workspacePanelContent`).addEventListener(`dragstart`,zm);let c=null;document.getElementById(`workspacePanelContent`).addEventListener(`scroll`,()=>{Am&&(c&&cancelAnimationFrame(c),c=requestAnimationFrame(()=>{c=null,document.getElementById(`workspacePanelContent`).scrollTop!==jm&&Nm()}))}),document.getElementById(`workspacePreviewClose`).addEventListener(`click`,()=>mg()),document.getElementById(`workspacePreviewCopyBtn`).addEventListener(`click`,e=>rg(e)),document.getElementById(`workspacePreviewDownloadBtn`).addEventListener(`click`,og),document.getElementById(`workspacePreviewOpenBrowserBtn`).addEventListener(`click`,sg),document.getElementById(`workspacePreviewFullscreenBtn`).addEventListener(`click`,lg),document.getElementById(`workspacePreviewMdToggleBtn`).addEventListener(`click`,ug),document.getElementById(`workspacePreviewEditBtn`).addEventListener(`click`,hg),document.getElementById(`workspacePreviewSaveBtn`).addEventListener(`click`,gg),document.getElementById(`workspacePreviewCancelBtn`).addEventListener(`click`,_g),Kh(),document.addEventListener(`keydown`,bg),document.getElementById(`workspacePreviewFilename`).addEventListener(`click`,async e=>{let t=document.getElementById(`workspacePreviewArea`),n=t.dataset.previewName,i=t.dataset.previewPath;if(n){if((e.ctrlKey||e.metaKey)&&!e.shiftKey){e.preventDefault();try{await navigator.clipboard.writeText(n),P(r(`workspace.copiedFileName`,{name:n}))}catch{P(r(`workspace.copyFailed`),`error`)}}else if((e.ctrlKey||e.metaKey)&&e.shiftKey){if(e.preventDefault(),!i)return;try{await navigator.clipboard.writeText(i),P(r(`workspace.copiedPath`,{path:i}))}catch{P(r(`workspace.copyFailed`),`error`)}}}}),Lg(),chrome.storage.local.onChanged.addListener(zg);let l=document.createElement(`input`);l.type=`file`,l.multiple=!0,l.id=`workspaceFileInput`,l.style.display=`none`,l.addEventListener(`change`,Tg),document.body.appendChild(l)}var Xp=[];function Zp(e){Dp.push(e),Dp.length>Op&&Dp.shift()}function Qp(e){if(!e||typeof e!=`string`)return`unnamed`;let t=e.replace(/[<>:"|?*\\/\x00-\x1f]/g,`_`);return t=t.replace(/\.+$/,``),t=t.trim(),t||=`unnamed`,t}function $p(e,t){let n=X(e);if(!t)return n;let r=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return n.replace(RegExp(`(${r})`,`gi`),`<mark class="search-highlight">$1</mark>`)}var em=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M15 3v18"/></svg>`,tm=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M15 3v18"/><path d="m8 9-3 3 3 3"/></svg>`;function nm(){let e=document.getElementById(`mainRow`),t=e?e.clientWidth:window.innerWidth;return Math.max(kp,t-Ap)}function rm(e){return Math.max(kp,Math.min(e,nm()))}function im(e){let t=document.getElementById(`workspacePanelModeBtn`);t&&(t.title=r(e?`workspace.floatMode`:`workspace.embedMode`),t.innerHTML=e?tm:em)}function am(){let e=document.getElementById(`workspacePanelContainer`);if(!e)return;let t=document.getElementById(`mainRow`);t&&e.parentElement!==t&&t.appendChild(e),e.classList.add(`embedded`),e.style.setProperty(`--ws-embed-width`,`${Lp}px`),im(!0)}function om(){let e=document.getElementById(`workspacePanelContainer`);if(!e)return;e.classList.remove(`embedded`);let t=Vn(`workspace`);t&&e.parentElement!==t&&t.appendChild(e),im(!1)}async function sm(){try{await chrome.storage.local.set({[Np]:Ip,[Pp]:Lp})}catch(e){a.warn(`[WorkspacePanel] persist embed state failed`,e)}}async function cm(){if(Ip){Ip=!1,zp=!1,Rp=!1,om(),await sm();return}let e=document.getElementById(`mainRow`);if((e?e.clientWidth:window.innerWidth)<jp){P(r(`workspace.narrowViewportHint`),`error`);return}document.getElementById(`workspacePanel`).classList.contains(`expanded`)||await mm(),Lp=rm(Lp),am(),Ip=!0,zp=!0,Rp=!1,await sm()}function lm(){let e=document.getElementById(`workspacePanelContainer`),t=document.createElement(`div`);t.className=`workspace-embed-divider`,t.id=`workspaceEmbedDivider`,e.appendChild(t),t.addEventListener(`mousedown`,t=>{t.preventDefault();let n=t.clientX,r=Lp;e.classList.add(`resizing`);function i(t){let i=rm(r+(n-t.clientX));Lp=i,e.style.setProperty(`--ws-embed-width`,`${i}px`)}function a(){document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,a),e.classList.remove(`resizing`),sm()}document.addEventListener(`mousemove`,i),document.addEventListener(`mouseup`,a)})}function um(){let e=document.getElementById(`mainRow`);!e||typeof ResizeObserver>`u`||new ResizeObserver(()=>{if(Ip){e.clientWidth<jp&&(Rp=!1,Ip=!1,zp=!1,om(),sm(),P(r(`workspace.narrowViewportHint`),`error`));return}Rp&&e.clientWidth>=jp&&fm()}).observe(e)}async function dm(){if(Ip)return!0;let e=document.getElementById(`workspacePanelContainer`);if(e&&e.style.display===`none`)return!1;let t=document.getElementById(`mainRow`);return(t?t.clientWidth:window.innerWidth)<jp?!1:(Lp=rm(Lp),document.getElementById(`workspacePanel`).classList.contains(`expanded`)||await mm(),am(),Ip=!0,!0)}function fm(){Rp=!1,dm().then(e=>{e||(Rp=!0)}).catch(e=>{a.warn(`[WorkspacePanel] deferred embed restore failed`,e),Rp=!0})}async function pm(){try{let e=await chrome.storage.local.get([Np,Pp,Fp]);if(typeof e[Pp]==`number`&&e[Pp]>=kp&&(Lp=Math.round(e[Pp])),!e[Np]||(zp=!0,e[Fp]===!1)||(await new Promise(e=>{let t=!1,n=()=>{t||(t=!0,e())};requestAnimationFrame(()=>requestAnimationFrame(n)),setTimeout(n,500)}),await dm()))return;Rp=!0}catch(e){a.warn(`[WorkspacePanel] restore embed state failed`,e)}}async function mm(){let e=document.getElementById(`workspacePanel`);e.classList.contains(`expanded`)||(e.classList.add(`expanded`),xt(e),chrome.storage.local.set({[Fp]:!0}).catch(()=>{}),await Rg(),q||await _m())}async function hm(){let e=document.getElementById(`workspacePanel`);if(!(!e||e.classList.contains(`expanded`)))if(Gp=!1,zp){let e=document.getElementById(`mainRow`);if((e?e.clientWidth:window.innerWidth)<jp){await mm(),P(r(`workspace.narrowViewportHint`),`error`);return}await mm(),Lp=rm(Lp),am(),Ip=!0,Rp=!1,await sm()}else await mm()}function gm(){i_()}async function _m(){let e=await sn();if(!e){Wg(r(`workspace.noWorkspace`));return}Ep=e,Dp=[],vm(e)}async function vm(e){q=e,J.clear(),Hg(),Ug(),L_(),Km(),s_&&a_?(o_=await bn(e,a_),Pm()):await wm(e),Gm()}var ym=new Map,bm=3e4,xm=20;function Sm(e){let t=ym.get(e);return t?Date.now()-t.timestamp>=bm?(ym.delete(e),null):(ym.delete(e),ym.set(e,t),t):null}function Cm(e,t){ym.has(e)&&ym.delete(e),ym.set(e,t),ym.size>xm&&ym.delete(ym.keys().next().value)}async function wm(e){let t=document.getElementById(`workspacePanelContent`);t.innerHTML=`<div class="workspace-panel-loading">${r(`common.loading`)}</div>`;let n=Sm(e);if(n){Xp=n.entries,Pm();return}let i=await en(e);if(!i.success){Wg(i.error||r(`workspace.loadDirFailed`));return}Xp=(i.entries||[]).map(t=>({...t,path:Tm(`${e}/${t.name}`)})),Cm(e,{entries:Xp,timestamp:Date.now()}),Pm()}function Tm(e){return(e||``).replace(/\\/g,`/`).replace(/\/+/g,`/`)}function Em(e){ym.delete(e)}var Dm=200,Om=32,km=5,Am=null,jm=0;function Mm(e){let t=an(e.name,e.type),n=e.type===`directory`?`—`:gn(e.size),i=rn(e.mtime),a=e.type===`file`&&$t(e.name),o=s_?e.fullPath:Tm(`${q}/${e.name}`),s=J.has(o),c=s_&&e.matchPath!==q?Tm(e.matchPath).replace(Tm(Ep),``).replace(/^\//,``)+`/`+e.name:``,l=s_?$p(e.name,a_):X(e.name);return`
|
|
983
989
|
<div class="workspace-file-item ${e.type} ${s?`selected`:``}" data-path="${X(o)}" data-type="${e.type}" data-name="${X(e.name)}" draggable="true">
|
|
984
990
|
<span class="workspace-file-select" data-action="select">
|
|
985
991
|
<span class="workspace-checkbox ${s?`checked`:``}"></span>
|
|
@@ -996,7 +1002,7 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
996
1002
|
<button class="workspace-file-btn ask" title="${r(`workspace.askFile`)}" data-action="ask"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="13" height="13"><circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg></button>
|
|
997
1003
|
<button class="workspace-file-btn delete" title="${r(`workspace.delete`)}" data-action="delete"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="13" height="13"><path d="M3 6h18M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg></button>
|
|
998
1004
|
</span>
|
|
999
|
-
</div>`}function Nm(){if(!Am)return;let{sorted:e}=Am,t=document.getElementById(`workspacePanelContent`),n=t.clientHeight,r=t.scrollTop,i=Am.itemHeight,a=Math.max(0,Math.floor(r/i)-km),o=Math.min(e.length,Math.ceil((r+n)/i)+km),s=`<div class="workspace-file-list" style="padding-top:${a*i}px;padding-bottom:${(e.length-o)*i}px;">`;for(let t=a;t<o;t++)s+=Mm(e[t]);s+=`</div>`,t.innerHTML=s;let c=t.querySelector(`.workspace-file-item`);if(c){let a=c.offsetHeight;if(a&&Math.abs(a-i)>2){Am.itemHeight=a;let i=Math.max(0,Math.floor(r/a)-km),o=Math.min(e.length,Math.ceil((r+n)/a)+km),s=`<div class="workspace-file-list" style="padding-top:${i*a}px;padding-bottom:${(e.length-o)*a}px;">`;for(let t=i;t<o;t++)s+=Mm(e[t]);s+=`</div>`,t.innerHTML=s}}Im(),jg(),jm=t.scrollTop}function Pm(){let e=document.getElementById(`workspacePanelContent`),t=[];if(t=s_?o_:[...Xp],t.length===0){Am=null,e.innerHTML=s_?`<div class="workspace-panel-empty">${r(`workspace.noMatch`)}</div>`:`<div class="workspace-panel-empty">${r(`workspace.dirEmpty`)}</div>`;return}let n=t.filter(e=>e.type===`directory`),i=t.filter(e=>e.type!==`directory`),a=(e,t)=>{let n;if(Vp.field===`name`)n=e.name.localeCompare(t.name);else if(Vp.field===`size`){if(e.type===`directory`&&t.type!==`directory`)return Vp.asc?-1:1;if(e.type!==`directory`&&t.type===`directory`)return Vp.asc?1:-1;n=(e.size||0)-(t.size||0)}else n=(e.mtime||0)-(t.mtime||0);return Vp.asc?n:-n},o=n.sort(a),s=i.sort(a),c;if(c=Vp.field===`name`?Vp.asc?[...o,...s]:[...s.reverse(),...o.reverse()]:[...o,...s],Wp=-1,c.length>Dm){Am={sorted:c,itemHeight:Om},e.scrollTop=0,Nm();return}Am=null;let l=`<div class="workspace-file-list">`;for(let e of c)l+=Mm(e);l+=`</div>`,e.innerHTML=l}function Fm(){let e=document.getElementById(`workspacePanelContent`);return e?Array.from(e.querySelectorAll(`.workspace-file-item`)):[]}function Im(){let e=document.getElementById(`workspacePanelContent`);if(Am&&Wp>=0){let{sorted:t,itemHeight:n}=Am;if(Wp>=t.length)return;let r=e.scrollTop,i=e.clientHeight,a=Wp*n,o=a+n;if(a<r||o>r+i){e.scrollTop=Math.max(0,a-(i-n)/2),Nm();return}}let t=Fm();if(t.forEach(e=>e.classList.remove(`keyboard-focused`)),!(Wp<0))if(Am){let e=Am.sorted[Wp];if(!e)return;let n=s_?e.fullPath:Tm(`${q}/${e.name}`),r=t.find(e=>e.dataset.path===n);r&&r.classList.add(`keyboard-focused`)}else Wp<t.length&&(t[Wp].classList.add(`keyboard-focused`),t[Wp].scrollIntoView({block:`nearest`,behavior:`smooth`}))}function Lm(e){let t=Fm();t.length!==0&&(Wp=Wp===-1?e>0?0:t.length-1:Math.max(0,Math.min(t.length-1,Wp+e)),Im())}function Rm(){let e=Fm();if(Wp<0||Wp>=e.length)return null;let t=e[Wp];return{el:t,path:t.dataset.path,name:t.dataset.name,type:t.dataset.type}}function zm(e){let t=e.target.closest(`.workspace-file-item`);if(!t)return;let n=t.dataset.path,r=t.dataset.type;n&&(e.dataTransfer.effectAllowed=`copy`,e.dataTransfer.setData(`application/x-workspace-file`,JSON.stringify({path:n,name:t.dataset.name,type:r})))}async function Bm(e){let t=e.target.tagName;if(!(t===`INPUT`||t===`TEXTAREA`))switch(e.key){case`ArrowDown`:e.preventDefault(),Lm(1);break;case`ArrowUp`:e.preventDefault(),Lm(-1);break;case`Enter`:{e.preventDefault();let t=Rm();if(!t)return;t.type===`directory`?(Zp(q),await vm(t.path)):await ih(t.path,t.name);break}case`Delete`:{e.preventDefault();let t=Rm();if(!t)return;await h_(t.path,t.name,t.type);break}case`F2`:{e.preventDefault();let t=Rm();if(!t)return;await
|
|
1005
|
+
</div>`}function Nm(){if(!Am)return;let{sorted:e}=Am,t=document.getElementById(`workspacePanelContent`),n=t.clientHeight,r=t.scrollTop,i=Am.itemHeight,a=Math.max(0,Math.floor(r/i)-km),o=Math.min(e.length,Math.ceil((r+n)/i)+km),s=`<div class="workspace-file-list" style="padding-top:${a*i}px;padding-bottom:${(e.length-o)*i}px;">`;for(let t=a;t<o;t++)s+=Mm(e[t]);s+=`</div>`,t.innerHTML=s;let c=t.querySelector(`.workspace-file-item`);if(c){let a=c.offsetHeight;if(a&&Math.abs(a-i)>2){Am.itemHeight=a;let i=Math.max(0,Math.floor(r/a)-km),o=Math.min(e.length,Math.ceil((r+n)/a)+km),s=`<div class="workspace-file-list" style="padding-top:${i*a}px;padding-bottom:${(e.length-o)*a}px;">`;for(let t=i;t<o;t++)s+=Mm(e[t]);s+=`</div>`,t.innerHTML=s}}Im(),jg(),jm=t.scrollTop}function Pm(){let e=document.getElementById(`workspacePanelContent`),t=[];if(t=s_?o_:[...Xp],t.length===0){Am=null,e.innerHTML=s_?`<div class="workspace-panel-empty">${r(`workspace.noMatch`)}</div>`:`<div class="workspace-panel-empty">${r(`workspace.dirEmpty`)}</div>`;return}let n=t.filter(e=>e.type===`directory`),i=t.filter(e=>e.type!==`directory`),a=(e,t)=>{let n;if(Vp.field===`name`)n=e.name.localeCompare(t.name);else if(Vp.field===`size`){if(e.type===`directory`&&t.type!==`directory`)return Vp.asc?-1:1;if(e.type!==`directory`&&t.type===`directory`)return Vp.asc?1:-1;n=(e.size||0)-(t.size||0)}else n=(e.mtime||0)-(t.mtime||0);return Vp.asc?n:-n},o=n.sort(a),s=i.sort(a),c;if(c=Vp.field===`name`?Vp.asc?[...o,...s]:[...s.reverse(),...o.reverse()]:[...o,...s],Wp=-1,c.length>Dm){Am={sorted:c,itemHeight:Om},e.scrollTop=0,Nm();return}Am=null;let l=`<div class="workspace-file-list">`;for(let e of c)l+=Mm(e);l+=`</div>`,e.innerHTML=l}function Fm(){let e=document.getElementById(`workspacePanelContent`);return e?Array.from(e.querySelectorAll(`.workspace-file-item`)):[]}function Im(){let e=document.getElementById(`workspacePanelContent`);if(Am&&Wp>=0){let{sorted:t,itemHeight:n}=Am;if(Wp>=t.length)return;let r=e.scrollTop,i=e.clientHeight,a=Wp*n,o=a+n;if(a<r||o>r+i){e.scrollTop=Math.max(0,a-(i-n)/2),Nm();return}}let t=Fm();if(t.forEach(e=>e.classList.remove(`keyboard-focused`)),!(Wp<0))if(Am){let e=Am.sorted[Wp];if(!e)return;let n=s_?e.fullPath:Tm(`${q}/${e.name}`),r=t.find(e=>e.dataset.path===n);r&&r.classList.add(`keyboard-focused`)}else Wp<t.length&&(t[Wp].classList.add(`keyboard-focused`),t[Wp].scrollIntoView({block:`nearest`,behavior:`smooth`}))}function Lm(e){let t=Fm();t.length!==0&&(Wp=Wp===-1?e>0?0:t.length-1:Math.max(0,Math.min(t.length-1,Wp+e)),Im())}function Rm(){let e=Fm();if(Wp<0||Wp>=e.length)return null;let t=e[Wp];return{el:t,path:t.dataset.path,name:t.dataset.name,type:t.dataset.type}}function zm(e){let t=e.target.closest(`.workspace-file-item`);if(!t)return;let n=t.dataset.path,r=t.dataset.type;n&&(e.dataTransfer.effectAllowed=`copy`,e.dataTransfer.setData(`application/x-workspace-file`,JSON.stringify({path:n,name:t.dataset.name,type:r})))}async function Bm(e){let t=e.target.tagName;if(!(t===`INPUT`||t===`TEXTAREA`))switch(e.key){case`ArrowDown`:e.preventDefault(),Lm(1);break;case`ArrowUp`:e.preventDefault(),Lm(-1);break;case`Enter`:{e.preventDefault();let t=Rm();if(!t)return;t.type===`directory`?(Zp(q),await vm(t.path)):await ih(t.path,t.name);break}case`Delete`:{e.preventDefault();let t=Rm();if(!t)return;await h_(t.path,t.name,t.type);break}case`F2`:{e.preventDefault();let t=Rm();if(!t)return;await A_(t.path,t.name,t.type);break}case` `:{e.preventDefault();let t=Rm();if(!t)return;Um(t.path),Lm(1);break}case`Escape`:Wp=-1,Im();break}}async function Vm(e){let t=e.target.closest(`.workspace-file-item`);if(!t)return;Gp=!1;let n=t.dataset.path,i=t.dataset.type,a=e.target.closest(`[data-action]`),o=Fm(),s;if(Am){let e=t.dataset.path;s=Am.sorted.findIndex(t=>(s_?t.fullPath:Tm(`${q}/${t.name}`))===e)}else s=o.indexOf(t);if(s>=0&&(Wp=s,Im()),e.target.closest(`.workspace-file-select`)){e.stopPropagation(),Um(n);return}if(a){let r=a.dataset.action;e.stopPropagation(),r===`preview`?await ih(n,t.dataset.name):r===`info`?await v_(n,t.dataset.name,i):r===`download`?await xg(n,t.dataset.name):r===`ask`?await N_([n]):r===`delete`?await h_(n,t.dataset.name,i):r===`rename`&&await A_(n,t.dataset.name,i);return}if((e.ctrlKey||e.metaKey)&&!e.shiftKey){e.stopPropagation(),navigator.clipboard.writeText(t.dataset.name).then(()=>{P(r(`workspace.copiedFileName`,{name:t.dataset.name}))}).catch(()=>{P(r(`workspace.copyFailed`),`error`)});return}if((e.ctrlKey||e.metaKey)&&e.shiftKey){e.stopPropagation(),navigator.clipboard.writeText(n).then(()=>{P(r(`workspace.copiedPath`,{path:n}))}).catch(()=>{P(r(`workspace.copyFailed`),`error`)});return}if(i===`directory`){e.stopPropagation(),Zp(q),await vm(n);return}}async function Hm(e){let t=e.target.closest(`.workspace-file-item`);if(!t)return;Gp=!1;let n=t.dataset.path,r=t.dataset.type,i=t.dataset.name;if(!e.target.closest(`[data-action]`)&&!e.target.closest(`.workspace-file-select`)){if(r===`directory`){e.stopPropagation(),Zp(q),await vm(n);return}r===`file`&&$t(i)&&(e.stopPropagation(),await ih(n,i))}}function Um(e){J.has(e)?J.delete(e):J.add(e),L_(),Gm();let t=Array.from(document.querySelectorAll(`.workspace-file-item`)).find(t=>t.dataset.path===e);if(t){let n=J.has(e);t.classList.toggle(`selected`,n);let r=t.querySelector(`.workspace-checkbox`);r&&r.classList.toggle(`checked`,n)}}function Wm(){let e=(s_?o_:Xp).map(e=>s_?e.fullPath:Tm(`${q}/${e.name}`));if(e.length>0&&e.every(e=>J.has(e)))for(let t of e)J.delete(t);else for(let t of e)J.add(t);L_(),Gm();for(let e of document.querySelectorAll(`.workspace-file-item`)){let t=J.has(e.dataset.path);e.classList.toggle(`selected`,t);let n=e.querySelector(`.workspace-checkbox`);n&&n.classList.toggle(`checked`,t)}}function Gm(){let e=(s_?o_:Xp).map(e=>s_?e.fullPath:Tm(`${q}/${e.name}`)),t=document.getElementById(`workspaceSelectAll`);if(!t)return;let n=t.querySelector(`.workspace-checkbox`);e.length===0?(n.classList.remove(`checked`),n.classList.remove(`indeterminate`)):e.every(e=>J.has(e))?(n.classList.add(`checked`),n.classList.remove(`indeterminate`)):e.some(e=>J.has(e))?(n.classList.remove(`checked`),n.classList.add(`indeterminate`)):(n.classList.remove(`checked`),n.classList.remove(`indeterminate`))}function Km(){[`name`,`size`,`time`].forEach(e=>{let t=document.getElementById(`sort${e.charAt(0).toUpperCase()+e.slice(1)}Indicator`);t&&(Vp.field===e?t.textContent=Vp.asc?`▲`:`▼`:t.textContent=``)})}var qm=1024*1024,Jm=50*1024*1024,Ym=20*1024*1024,Xm=50*1024*1024,Zm=50*1024*1024,Qm=50*1024*1024,$m=200*1024*1024,eh=100*1024*1024,th=1e4,nh=2e3;async function rh(e){let t=await un();if(!t)throw Error(r(`workspace.agentNotPaired`));let n=await fetch(`${t.url}/api/fs/download-stream`,{method:`POST`,headers:{"Content-Type":`application/json`,..._n(t)},body:JSON.stringify({path:e})});if(!n.ok){let e=await n.text().catch(()=>n.statusText);throw Error(typeof e==`string`?e:`HTTP ${n.status}`)}let i=n.body.getReader(),a=[];for(;;){let{done:e,value:t}=await i.read();if(e)break;a.push(t)}let o=a.reduce((e,t)=>e+t.length,0),s=new Uint8Array(o),c=0;for(let e of a)s.set(e,c),c+=e.length;return s.buffer}async function ih(e,t){Kp&&Kp.abort(),Kp=new AbortController;let n=Kp.signal,i=document.getElementById(`workspacePreviewArea`),o=document.getElementById(`workspacePreviewContent`),s=document.getElementById(`workspacePreviewFilename`),c=document.getElementById(`workspacePreviewLineCount`),l=document.getElementById(`workspacePreviewCopyBtn`),u=document.getElementById(`workspacePreviewDownloadBtn`),d=document.getElementById(`workspacePreviewOpenBrowserBtn`),f=document.getElementById(`workspacePreviewFullscreenBtn`),p=document.getElementById(`workspacePreviewMdToggleBtn`);s.textContent=t,c.textContent=``,o.classList.remove(`xlsx-mode`),o.classList.remove(`markdown-rendered`),o.innerHTML=`<div class="workspace-panel-loading">${r(`common.loading`)}</div>`,i.style.display=`flex`,l.style.display=``,u.style.display=``,d.style.display=`none`,f.style.display=`none`,p.style.display=`none`,p.classList.remove(`active`),cg(p,!1);let m=document.getElementById(`workspacePreviewEditBtn`),h=document.getElementById(`workspacePreviewSaveBtn`),g=document.getElementById(`workspacePreviewCancelBtn`);m.style.display=`none`,h.style.display=`none`,g.style.display=`none`,delete i.dataset.editMode,delete i.dataset.origContent,i.classList.remove(`has-unsaved`),s.classList.remove(`modified`),i.classList.remove(`fullscreen`),document.getElementById(`workspacePanel`).classList.remove(`preview-fullscreen`),i.dataset.previewPath=e,i.dataset.previewName=t,delete i.dataset.previewType,delete i.dataset.previewSheets;let _=cn(t),v=Xp.find(t=>t.path===e)||o_.find(t=>t.fullPath===e),y=v?v.size:0;if(_===`text`){if(l.style.display=``,y>qm){o.innerHTML=`<div class="workspace-panel-error">${r(`workspace.fileTooLargeNoPreview`,{size:gn(y)})}</div>`;return}m.style.display=``,f.style.display=``;let n=(t.split(`.`).pop()||``).toLowerCase(),a=await nn(e);if(!a.success){o.innerHTML=`<div class="workspace-panel-error">${r(`workspace.previewFailed`,{error:X(a.error||r(`workspace.unknownError`))})}</div>`;return}let s=a.content||``;if(i.dataset.origContent=s,n===`md`||n===`markdown`){p.style.display=``,i.dataset.markdownText=s,o.classList.add(`markdown-rendered`),p.classList.add(`active`),p.title=r(`workspace.switchToSourcePreview`),cg(p,!0),l.style.display=``;let e=document.getElementById(`workspacePreviewDownloadBtn`);e&&(e.style.display=`none`);let t=document.getElementById(`workspacePreviewExportMenu`);t&&(t.style.display=``),o.innerHTML=`<div class="markdown-body workspace-preview-markdown">${Kt(s)}</div>`,fg(o),pg(o),Gt(),c.textContent=``,dg(!0);return}let u=Gg(t),d=s.split(`
|
|
1000
1006
|
`);c.textContent=r(`workspace.lineCount`,{count:d.length});let h=d.length>th,g=h?d.slice(0,th):d,_=`<table class="workspace-preview-code-table"><tbody>`;for(let e=0;e<g.length;e++)_+=`<tr><td class="line-num">${e+1}</td><td class="line-content"><code class="${u}">${X(g[e])}</code></td></tr>`;h&&(_+=`<tr><td class="line-num">…</td><td class="line-content"><code>${r(`workspace.truncatedHint`,{shown:th,total:d.length})}</code></td></tr>`),_+=`</tbody></table>`,o.innerHTML=_;return}l.style.display=`none`,d.style.display=_===`pdf`||_===`image`?``:`none`;try{if(y>({pdf:Jm,docx:Ym,pptx:Xm,xlsx:Zm,image:Qm,video:$m,audio:eh}[_]||qm)){o.innerHTML=`<div class="workspace-panel-error">${r(_===`pdf`||_===`image`?`workspace.fileTooLargeOpenInBrowser`:`workspace.fileTooLargeNoPreview`,{size:gn(y)})}</div>`;return}if(_===`xlsx`){f.style.display=``,await Lh(t,o,i);return}let a=await rh(e);switch(_){case`pdf`:f.style.display=``,await yh(a,t,o,i,n);break;case`docx`:f.style.display=``,await bh(a,o);break;case`pptx`:f.style.display=``,await jh(a,t,o,i,n);break;case`image`:f.style.display=``,await Bh(a,t,o,n);break;case`video`:case`audio`:f.style.display=``,await Hh(a,t,_,o,i);break;default:o.innerHTML=`<div class="workspace-panel-error">${r(`workspace.unsupportedFileType`)}</div>`}}catch(t){a.error(`[WorkspacePanel] preview failed:`,e,t),o.innerHTML=`<div class="workspace-panel-error">${r(`workspace.previewFailed`,{error:X((t instanceof Error?t.message:typeof t==`string`?t:String(t))||r(`workspace.unknownError`))})}</div>`}}var ah=null,oh=1,sh=1,ch=1,lh=1,uh=0,dh=0,fh=!1,ph=0,mh=0,hh=0,gh=0,_h=null,vh=1;async function yh(t,n,i,a,o){let s=await M(()=>import(`./pdf-DnVqBaAN.js`).then(t=>e(t.default,1)),__vite__mapDeps([5,1,6]));s.GlobalWorkerOptions.workerSrc=`libs/pdf.worker.min.js`;let c=await s.getDocument({data:t}).promise;ah=c,oh=1,sh=1,ch=1,lh=1,vh=1,uh=0,dh=0,a.dataset.previewType=`pdf`;let l=c.numPages;document.getElementById(`workspacePreviewLineCount`).textContent=r(`workspace.pageCount`,{count:l}),i.innerHTML=`
|
|
1001
1007
|
<div class="pdf-wrap">
|
|
1002
1008
|
<div class="pdf-toolbar">
|
|
@@ -1089,7 +1095,7 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1089
1095
|
<source src="${c}" type="${X(o)}">
|
|
1090
1096
|
</audio>
|
|
1091
1097
|
<div id="mediaUnsupportedHint" style="display:none;">${u}</div>
|
|
1092
|
-
</div>`;let d=i.querySelector(`video, audio`),f=i.querySelector(`#mediaUnsupportedHint`);if(d){let e=()=>{d.style.display=`none`,f&&(f.style.display=`block`)};d.addEventListener(`error`,e),i.querySelectorAll(`source`).forEach(t=>t.addEventListener(`error`,e))}}var Uh=!1;function Wh(e,t){let n=e.getBoundingClientRect();t.style.top=n.bottom+4+`px`;let r=n.right-160;t.style.left=Math.max(4,r)+`px`,t.style.right=`auto`}function Gh(e,t){Wh(e,t),t.classList.add(`show`)}function Kh(){let e=document.getElementById(`workspacePreviewExportMenu`),t=document.getElementById(`workspacePreviewExportBtn`),n=document.getElementById(`workspacePreviewExportDropdown`);if(!e||!t||!n)return;document.body.appendChild(n),t.addEventListener(`click`,e=>{e.stopPropagation(),n.classList.contains(`show`)?n.classList.remove(`show`):Gh(t,n)});let r=null,i=null;e.addEventListener(`mouseenter`,()=>{i&&=(clearTimeout(i),null),r=setTimeout(()=>{Gh(t,n)},200)}),e.addEventListener(`mouseleave`,()=>{r&&=(clearTimeout(r),null),i=setTimeout(()=>{!e.matches(`:hover`)&&!n.matches(`:hover`)&&n.classList.remove(`show`)},300)}),n.addEventListener(`mouseenter`,()=>{i&&=(clearTimeout(i),null)}),n.addEventListener(`mouseleave`,()=>{i=setTimeout(()=>{!e.matches(`:hover`)&&!n.matches(`:hover`)&&n.classList.remove(`show`)},200)}),n.querySelectorAll(`.ws-export-dropdown-item`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let r=e.dataset.exportType;n.classList.remove(`show`),Jh(r)})}),document.addEventListener(`click`,t=>{!e.contains(t.target)&&!n.contains(t.target)&&n.classList.remove(`show`)});let a=()=>{n.classList.contains(`show`)&&Wh(t,n)};document.getElementById(`workspacePreviewContent`)?.addEventListener(`scroll`,a),window.addEventListener(`resize`,a)}function qh(){return document.getElementById(`workspacePreviewArea`).dataset.markdownText||``}async function Jh(e){if(Uh)return;Uh=!0;let t=document.getElementById(`workspacePreviewExportBtn`);document.getElementById(`workspacePreviewExportMenu`);let n=document.getElementById(`workspacePreviewExportDropdown`),i=document.getElementById(`workspacePreviewArea`).dataset.previewName||`export`,o=t.innerHTML;t.innerHTML=`<svg viewBox="0 0 24 24" fill="none" style="animation: spin 0.8s linear infinite; width: 14px; height: 14px; flex-shrink: 0;"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-dasharray="31.4" stroke-dashoffset="10" opacity="0.25"/><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-dasharray="31.4" stroke-dashoffset="10"/></svg>`,t.disabled=!0,t.style.opacity=`0.6`;try{switch(e){case`docx`:await Zh(i);break;case`pdf`:await $h(i);break;case`image`:await eg(i);break;case`md`:tg(i);break}}catch(e){a.error(`[WorkspacePanel] export failed:`,e),P(r(`chatExport.exportFailed`,{message:e.message}),`error`)}finally{Uh=!1,t.innerHTML=o,t.disabled=!1,t.style.opacity=`1`,n.classList.remove(`show`)}}async function Yh(e){if(typeof mermaid>`u`)return;let{renderMermaidInContainer:t,convertSvgsToImages:n}=await M(async()=>{let{renderMermaidInContainer:e,convertSvgsToImages:t}=await import(`./chat-export-
|
|
1098
|
+
</div>`;let d=i.querySelector(`video, audio`),f=i.querySelector(`#mediaUnsupportedHint`);if(d){let e=()=>{d.style.display=`none`,f&&(f.style.display=`block`)};d.addEventListener(`error`,e),i.querySelectorAll(`source`).forEach(t=>t.addEventListener(`error`,e))}}var Uh=!1;function Wh(e,t){let n=e.getBoundingClientRect();t.style.top=n.bottom+4+`px`;let r=n.right-160;t.style.left=Math.max(4,r)+`px`,t.style.right=`auto`}function Gh(e,t){Wh(e,t),t.classList.add(`show`)}function Kh(){let e=document.getElementById(`workspacePreviewExportMenu`),t=document.getElementById(`workspacePreviewExportBtn`),n=document.getElementById(`workspacePreviewExportDropdown`);if(!e||!t||!n)return;document.body.appendChild(n),t.addEventListener(`click`,e=>{e.stopPropagation(),n.classList.contains(`show`)?n.classList.remove(`show`):Gh(t,n)});let r=null,i=null;e.addEventListener(`mouseenter`,()=>{i&&=(clearTimeout(i),null),r=setTimeout(()=>{Gh(t,n)},200)}),e.addEventListener(`mouseleave`,()=>{r&&=(clearTimeout(r),null),i=setTimeout(()=>{!e.matches(`:hover`)&&!n.matches(`:hover`)&&n.classList.remove(`show`)},300)}),n.addEventListener(`mouseenter`,()=>{i&&=(clearTimeout(i),null)}),n.addEventListener(`mouseleave`,()=>{i=setTimeout(()=>{!e.matches(`:hover`)&&!n.matches(`:hover`)&&n.classList.remove(`show`)},200)}),n.querySelectorAll(`.ws-export-dropdown-item`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let r=e.dataset.exportType;n.classList.remove(`show`),Jh(r)})}),document.addEventListener(`click`,t=>{!e.contains(t.target)&&!n.contains(t.target)&&n.classList.remove(`show`)});let a=()=>{n.classList.contains(`show`)&&Wh(t,n)};document.getElementById(`workspacePreviewContent`)?.addEventListener(`scroll`,a),window.addEventListener(`resize`,a)}function qh(){return document.getElementById(`workspacePreviewArea`).dataset.markdownText||``}async function Jh(e){if(Uh)return;Uh=!0;let t=document.getElementById(`workspacePreviewExportBtn`);document.getElementById(`workspacePreviewExportMenu`);let n=document.getElementById(`workspacePreviewExportDropdown`),i=document.getElementById(`workspacePreviewArea`).dataset.previewName||`export`,o=t.innerHTML;t.innerHTML=`<svg viewBox="0 0 24 24" fill="none" style="animation: spin 0.8s linear infinite; width: 14px; height: 14px; flex-shrink: 0;"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-dasharray="31.4" stroke-dashoffset="10" opacity="0.25"/><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-dasharray="31.4" stroke-dashoffset="10"/></svg>`,t.disabled=!0,t.style.opacity=`0.6`;try{switch(e){case`docx`:await Zh(i);break;case`pdf`:await $h(i);break;case`image`:await eg(i);break;case`md`:tg(i);break}}catch(e){a.error(`[WorkspacePanel] export failed:`,e),P(r(`chatExport.exportFailed`,{message:e.message}),`error`)}finally{Uh=!1,t.innerHTML=o,t.disabled=!1,t.style.opacity=`1`,n.classList.remove(`show`)}}async function Yh(e){if(typeof mermaid>`u`)return;let{renderMermaidInContainer:t,convertSvgsToImages:n}=await M(async()=>{let{renderMermaidInContainer:e,convertSvgsToImages:t}=await import(`./chat-export-pxivPZ1I.js`);return{renderMermaidInContainer:e,convertSvgsToImages:t}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));await t(e),await n(e)}async function Xh(e){if(typeof mermaid>`u`||!/```mermaid/i.test(e))return e;let{renderMermaidInContainer:t,convertSvgsToImages:n}=await M(async()=>{let{renderMermaidInContainer:e,convertSvgsToImages:t}=await import(`./chat-export-pxivPZ1I.js`);return{renderMermaidInContainer:e,convertSvgsToImages:t}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));try{let r=Kt(e),i=document.createElement(`div`);i.style.cssText=`position:fixed;left:-9999px;top:-9999px;`,i.innerHTML=r,document.body.appendChild(i),await t(i),await n(i);let a=i.querySelectorAll(`.mermaid`),o=[];for(let e of a){let t=e.querySelector(`img`);t&&t.src&&t.src.startsWith(`data:`)?o.push(t.src):o.push(null)}if(document.body.removeChild(i),o.length===0)return e;let s=0;return e.replace(/```\s*mermaid\s*[\r\n]+([\s\S]*?)```/gi,e=>{let t=o[s];return s++,t?``:e})}catch(t){return a.warn(`[WorkspacePanel] Mermaid pre-render failed:`,t.message),e}}async function Zh(e){let{Packer:t}=await M(async()=>{let{Packer:e}=await import(`./dist-BUuoW_84.js`);return{Packer:e}},__vite__mapDeps([11,1])),{createDocxDocument:n}=await M(async()=>{let{createDocxDocument:e}=await import(`./chat-export-pxivPZ1I.js`);return{createDocxDocument:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0])),i=qh();if(!i){P(r(`chatExport.noContent`),`error`);return}i=await Xh(i);let a=n(await Qh(i)),o=await t.toBlob(a),s=`word-${new Date().getTime()}.docx`;ng(o,s),P(r(`workspace.downloaded`,{name:s}),`success`)}async function Qh(e){let{Document:t,Packer:n,Paragraph:r,TextRun:i,HeadingLevel:a,Table:o,TableRow:s,TableCell:c,AlignmentType:l,WidthType:u,BorderStyle:d,ImageRun:f,ExternalHyperlink:p,convertInchesToTwip:m}=await M(async()=>{let{Document:e,Packer:t,Paragraph:n,TextRun:r,HeadingLevel:i,Table:a,TableRow:o,TableCell:s,AlignmentType:c,WidthType:l,BorderStyle:u,ImageRun:d,ExternalHyperlink:f,convertInchesToTwip:p}=await import(`./dist-BUuoW_84.js`);return{Document:e,Packer:t,Paragraph:n,TextRun:r,HeadingLevel:i,Table:a,TableRow:o,TableCell:s,AlignmentType:c,WidthType:l,BorderStyle:u,ImageRun:d,ExternalHyperlink:f,convertInchesToTwip:p}},__vite__mapDeps([11,1])),{createTextRuns:h,sanitizeDocxText:g,nextDocxImageId:_,isDocxEmbeddableImageType:v}=await M(async()=>{let{createTextRuns:e,sanitizeDocxText:t,nextDocxImageId:n,isDocxEmbeddableImageType:r}=await import(`./chat-export-pxivPZ1I.js`);return{createTextRuns:e,sanitizeDocxText:t,nextDocxImageId:n,isDocxEmbeddableImageType:r}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));if(!e||!e.trim())return[new r({children:[new i({text:``})]})];let y=[],b=g(e),x=[];b=b.replace(/```(\w*)\n([\s\S]*?)```/g,(e,t,n)=>{let r=x.length;return x.push({lang:t||``,code:n.trimEnd()}),`\n\n%%CODEBLOCK_${r}%%\n\n`});let S=[];b=b.replace(/<table[\s\S]*?<\/table>/gi,e=>{let t=S.length;return S.push(e),`\n\n%%HTMLTABLE_${t}%%\n\n`});let C=[];b=b.replace(/(?:^\|.+\|\s*$\n)+^\|[\s\-:|]+\|\s*$\n(?:^\|.+\|\s*$\n?)+/gm,e=>{let t=C.length;return C.push(e),`\n\n%%MDTABLE_${t}%%\n\n`});let w=b.split(/\n{2,}/).filter(e=>e.trim());function T(e){if(!e)return[];let t=/(\*\*(.+?)\*\*|(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)|__(.+?)__|(?<!_)_(?!_)(.+?)(?<!_)_(?!_)|`([^`]+)`|\[([^\]]+)\]\(([^)]+)\)|!\[([^\]]*)\]\(([^)]+)\))/,n=[],r=e;for(;r.length>0;){let e=r.match(t);if(!e){n.push(...h(r));break}let a=e.index;a>0&&n.push(...h(r.slice(0,a)));let o=e[1];if(e[2]!==void 0)n.push(...h(e[2],{bold:!0}));else if(e[3]!==void 0)n.push(...h(e[3],{italics:!0}));else if(e[4]!==void 0)n.push(...h(e[4],{bold:!0}));else if(e[5]!==void 0)n.push(...h(e[5],{italics:!0}));else if(e[6]!==void 0)n.push(new i({text:e[6],font:`Consolas`,size:20}));else if(e[7]!==void 0)n.push(new p({children:[new i({text:e[7],style:`Hyperlink`})],link:e[8]}));else if(e[9]!==void 0){let t=e[10];if(t.startsWith(`data:`))try{let[r,a]=t.split(`,`),o=r.match(/data:(image\/(\w+))/);if(o&&a&&v(o[2])){let t=atob(a),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);n.push(new f({data:r,transformation:{width:400,height:300},type:o[2],altText:{id:_(),name:e[9]||`image`}}))}else n.push(new i({text:`[Image: `+(e[9]||`image`)+`]`,italics:!0,color:`999999`}))}catch{n.push(new i({text:`[Image]`,italics:!0,color:`999999`}))}else n.push(new i({text:`[Image: `+(e[9]||t)+`]`,italics:!0,color:`999999`}))}r=r.slice(a+o.length)}return n}function E(e){let t=new DOMParser().parseFromString(e,`text/html`),n=[];return t.querySelectorAll(`tr`).forEach(e=>{let t=[];e.querySelectorAll(`th, td`).forEach(e=>t.push(e.textContent.trim())),t.length>0&&n.push(t)}),n}function D(e){let t=e.trim().split(`
|
|
1093
1099
|
`),n=[];for(let e of t){if(/^[\s\|:\-]+$/.test(e.replace(/\|/g,``)))continue;let t=It(e).slice(1,-1).map(e=>e.trim());t.length>0&&n.push(t)}return n}function O(e){if(e.length===0)return new r({children:[]});let t=Math.max(...e.map(e=>e.length));return new o({rows:e.map((e,n)=>{let i=[];for(let a=0;a<t;a++){let o=e[a]||``;i.push(new c({children:[new r({children:T(o),spacing:{before:40,after:40}})],shading:n===0?{fill:`F2F2F2`}:void 0,width:{size:Math.round(100/t*100)/100,type:u.PERCENTAGE}}))}return new s({children:i})}),width:{size:100,type:u.PERCENTAGE},borders:{top:{style:d.SINGLE,size:1,color:`DDDDDD`},bottom:{style:d.SINGLE,size:1,color:`DDDDDD`},left:{style:d.SINGLE,size:1,color:`DDDDDD`},right:{style:d.SINGLE,size:1,color:`DDDDDD`},insideHorizontal:{style:d.SINGLE,size:1,color:`DDDDDD`},insideVertical:{style:d.SINGLE,size:1,color:`DDDDDD`}}})}for(let e of w){let t=e.trim(),n=t.match(/^%%CODEBLOCK_(\d+)%%$/);if(n){let{lang:e,code:t}=x[parseInt(n[1])],a=e?`${e} code`:`code`;y.push(new r({children:[new i({text:a,bold:!0,font:`Consolas`,size:18})]}));let o=t.split(`
|
|
1094
1100
|
`);for(let e of o)y.push(new r({children:[new i({text:e||` `,font:`Consolas`,size:18})],spacing:{before:0,after:0,line:240},shading:{fill:`F5F5F5`}}));y.push(new r({children:[new i({text:``})]}));continue}let o=t.match(/^%%HTMLTABLE_(\d+)%%$/);if(o){let e=E(S[parseInt(o[1])]);e.length>0&&(y.push(O(e)),y.push(new r({children:[new i({text:``})]})));continue}let s=t.match(/^%%MDTABLE_(\d+)%%$/);if(s){let e=D(C[parseInt(s[1])]);y.push(O(e)),y.push(new r({children:[new i({text:``})]}));continue}let c=t.match(/^(#{1,6})\s+(.+)/);if(c){let e={1:a.HEADING_1,2:a.HEADING_2,3:a.HEADING_3,4:a.HEADING_4,5:a.HEADING_5,6:a.HEADING_6};y.push(new r({children:T(c[2]),heading:e[c[1].length]||a.HEADING_1,border:{bottom:{style:d.SINGLE,size:6,color:`EAECEF`}}}));let n=t.slice(c[0].length).replace(/^\n+/,``).trim();n&&y.push(new r({children:T(n),spacing:{before:60,after:60}}));continue}if(/^(---|\*\*\*|___)\s*$/.test(t)){y.push(new r({children:[],border:{bottom:{style:d.SINGLE,size:6,color:`CCCCCC`}},spacing:{before:200,after:200}}));continue}if(/^[\-\*\+]\s+/.test(t)){let t=e.split(/\n(?=[\-\*\+]\s+)/);for(let e of t)y.push(new r({children:T(e.replace(/^[\-\*\+]\s+/,``)),bullet:{level:0},spacing:{before:40,after:40}}));continue}if(/^\d+\.\s+/.test(t)){let t=e.split(/\n(?=\d+\.\s+)/);for(let e of t)y.push(new r({children:T(e.replace(/^\d+\.\s+/,``)),numbering:{reference:`default`,level:0},spacing:{before:40,after:40}}));continue}if(t.startsWith(`>`)){let t=e.split(`
|
|
1095
1101
|
`).map(e=>e.replace(/^>\s?/,``)).join(`
|
|
@@ -1139,8 +1145,8 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1139
1145
|
<span class="workspace-upload-progress-bytes"></span>
|
|
1140
1146
|
<span class="workspace-upload-progress-speed"></span>
|
|
1141
1147
|
</div>
|
|
1142
|
-
`,document.body.appendChild(t);let n=t.querySelector(`.workspace-upload-progress-cancel`);return n&&n.addEventListener(`click`,()=>{n.style.display=`none`,typeof e==`function`&&e()}),t}function Ng(e,t){if(!e)return;let{percent:n,completed:i,total:a,fileName:o,loaded:s,totalBytes:c,speed:l,statusText:u}=t,d=e.querySelector(`.workspace-upload-progress-title`),f=e.querySelector(`.workspace-upload-progress-file`),p=e.querySelector(`.workspace-upload-progress-bar`),m=e.querySelector(`.workspace-upload-progress-bytes`),h=e.querySelector(`.workspace-upload-progress-speed`),g=e.classList.contains(`download-mode`)?r(`workspace.downloadInProgress`):r(`workspace.uploadInProgress`);d&&(u?d.textContent=u:i!=null&&a!=null?d.textContent=`${g} ${i}/${a} · ${n}%`:d.textContent=`${g} ${n}%`),f&&o&&(f.textContent=o,f.title=o),p&&(p.style.width=n+`%`),m&&(s!=null&&c!=null&&c>0?m.textContent=`${gn(s)} / ${gn(c)}`:s!=null&&(m.textContent=gn(s))),h&&(h.textContent=l>0?`${gn(l)}/s`:``)}function Pg(e,t,n){if(!e)return;let r=e.querySelector(`.workspace-upload-progress-title`),i=e.querySelector(`.workspace-upload-progress-cancel`),a=e.querySelector(`.workspace-upload-progress-bar`);i&&(i.style.display=`none`),r&&(r.textContent=t),a&&!n&&(a.style.width=`100%`),e.classList.add(`workspace-upload-progress-done`),n&&e.classList.add(`workspace-upload-progress-error`),setTimeout(()=>{try{e.remove()}catch{}},1500)}function Fg(e){let t=document.getElementById(`workspaceUploadBtn`);t&&(t.disabled=e,e?(t.dataset.originalHtml=t.innerHTML,t.innerHTML=`<span class="workspace-upload-spinner"></span>`):t.dataset.originalHtml&&(t.innerHTML=t.dataset.originalHtml,delete t.dataset.originalHtml));let n=document.getElementById(`workspacePanel`);n&&n.classList.toggle(`upload-in-progress`,e)}async function Ig(e){let t=Array.from(e);if(t.length===0||Up)return;Up=!0,Fg(!0);let n=await un();if(!n){P(r(`workspace.agentNotConnectedUpload`),`error`),Up=!1,Fg(!1);return}let i=new Set;try{let e=await en(q);e.success&&Array.isArray(e.entries)&&(i=new Set(e.entries.map(e=>e.name)))}catch{}let a=0,o=0,s=0,c=t.reduce((e,t)=>e+t.size,0),l=Array(t.length).fill(0),u=new Set,d=!1,f=``,p=[],m=()=>{if(p.length<2)return 0;let e=p[0],t=p[p.length-1],n=(t.time-e.time)/1e3;return n<=0?0:(t.loaded-e.loaded)/n},h=Mg(()=>{d=!0;for(let e of u)try{e.abort()}catch{}u.clear()}),g=e=>{e&&(f=e);let n=l.reduce((e,t)=>e+t,0),r=c>0?Math.round(n/c*100):0,i=Date.now();p.push({time:i,loaded:n}),p.length>8&&p.shift(),Ng(h,{percent:r,completed:a+o+s,total:t.length,fileName:f,loaded:n,totalBytes:c,speed:m()})};g();for(let e=0;e<t.length&&!d;e+=3){let c=t.slice(e,e+3),f=await Promise.allSettled(c.map(async(t,a)=>{let o=e+a,s=Qp(t.name),c=Tm(`${q}/${s}`);if(i.has(s))throw l[o]=t.size,g(s),Error(`__SKIPPED__`);if(d)throw Error(`__CANCELLED__`);await new Promise((e,i)=>{let a=new XMLHttpRequest;u.add(a);let s=`${n.url}/api/fs/upload-stream?path=${encodeURIComponent(c)}`;a.open(`POST`,s);for(let[e,t]of Object.entries(_n(n)))a.setRequestHeader(e,t);a.upload.onprogress=e=>{e.lengthComputable&&(l[o]=e.loaded,g(t.name))},a.onload=()=>{if(u.delete(a),d){i(Error(`__CANCELLED__`));return}if(a.status>=200&&a.status<300)try{let n=JSON.parse(a.responseText);n.success?(l[o]=t.size,g(t.name),e()):i(Error(n.error||r(`workspace.uploadFailed`)))}catch{i(Error(r(`workspace.parseResponseFailed`)))}else try{let e=JSON.parse(a.responseText);i(Error(e.error||r(`workspace.uploadFailedWithStatus`,{status:a.status})))}catch{i(Error(r(`workspace.uploadFailedWithStatus`,{status:a.status})))}},a.onerror=()=>{u.delete(a),i(Error(d?`__CANCELLED__`:r(`workspace.networkError`)))},a.onabort=()=>{u.delete(a),i(Error(`__CANCELLED__`))},a.send(t)})}));for(let e of f)if(e.status===`fulfilled`)a++;else{let t=e.reason&&e.reason.message?e.reason.message:``;t.includes(`__SKIPPED__`)||t.includes(`已存在`)?o++:t.includes(`__CANCELLED__`)||s++}}let _,v=!1;if(d)_=r(`workspace.uploadCanceled`),v=!0;else{let e=[];a>0&&e.push(r(`workspace.uploadSuccessCount`,{count:a})),o>0&&e.push(r(`workspace.uploadSkippedCount`,{count:o})),s>0&&e.push(r(`workspace.uploadFailedCount`,{count:s})),_=e.length>0?r(`workspace.uploadCompleteWithStats`,{stats:e.join(` / `)}):r(`workspace.uploadComplete`),v=s>0}Pg(h,_,v),a>0&&P(r(`workspace.uploadedFiles`,{count:a}),`success`),o>0&&P(r(`workspace.filesSkipped`,{count:o}),`info`),s>0&&P(r(`workspace.filesUploadFailed`,{count:s}),`error`),d&&P(r(`workspace.uploadCanceled`),`info`),Up=!1,Fg(!1),a>0&&(await Vg(),N_(t[t.length-1].name))}function Lg(){let e=document.getElementById(`workspacePanel`);if(!e)return;let t=document.getElementById(`workspacePanelContent`);t.addEventListener(`dragstart`,e=>{let t=e.target.closest(`.workspace-file-item`);if(!t)return;let n=t.dataset.path,r=t.dataset.name;e.dataTransfer.setData(`application/x-workspace-move`,JSON.stringify({path:n,name:r})),e.dataTransfer.effectAllowed=`move`,t.classList.add(`dragging`);let i=()=>{t.classList.remove(`dragging`),t.removeEventListener(`dragend`,i)};t.addEventListener(`dragend`,i)}),t.addEventListener(`dragover`,n=>{n.preventDefault(),n.stopPropagation();let r=n.target.closest(`.workspace-file-item.directory`);t.querySelectorAll(`.workspace-file-item.directory.drop-target`).forEach(e=>e.classList.remove(`drop-target`)),r?(n.dataTransfer.dropEffect=n.dataTransfer.types.includes(`application/x-workspace-move`)?`move`:`copy`,r.classList.add(`drop-target`),e.classList.remove(`drag-over`)):n.dataTransfer.types.includes(`application/x-workspace-move`)||e.classList.add(`drag-over`)}),t.addEventListener(`dragleave`,n=>{n.preventDefault(),n.stopPropagation(),t.querySelectorAll(`.workspace-file-item.directory.drop-target`).forEach(e=>e.classList.remove(`drop-target`)),e.classList.remove(`drag-over`)}),t.addEventListener(`drop`,async n=>{n.preventDefault(),n.stopPropagation();let i=n.target.closest(`.workspace-file-item.directory`);if(t.querySelectorAll(`.workspace-file-item.directory.drop-target`).forEach(e=>e.classList.remove(`drop-target`)),e.classList.remove(`drag-over`),i&&n.dataTransfer.types.includes(`application/x-workspace-move`)){try{let e=JSON.parse(n.dataTransfer.getData(`application/x-workspace-move`)),t=e.path,a=i.dataset.path,o=e.name,s=Tm(t),c=Tm(a);if(s===c)return;if(s.startsWith(c+`/`)){P(r(`workspace.cannotMoveToSubdir`),`error`);return}P(r(`workspace.moving`),`info`);let l=await yn(t,a);if(l.success){P(r(`workspace.movedToDir`,{name:o}),`success`),Em(q),Em(a);let e=a.split(/[\\/]/).pop();await Vg(),N_(e)}else P(r(`workspace.moveFailed`,{error:l.error}),`error`)}catch(e){P(r(`workspace.moveFailed`,{error:e.message}),`error`)}return}if(i&&n.dataTransfer.files&&n.dataTransfer.files.length>0){let e=i.dataset.path;e.split(/[\\/]/).pop(),Zp(q),q=e,await Ig(n.dataTransfer.files),Hg(),Ug();return}if(n.dataTransfer.files&&n.dataTransfer.files.length>0){await Ig(n.dataTransfer.files);return}}),e.addEventListener(`dragover`,t=>{t.preventDefault(),t.stopPropagation(),!t.dataTransfer.types.includes(`application/x-workspace-move`)&&e.classList.add(`drag-over`)}),e.addEventListener(`dragleave`,t=>{t.preventDefault(),t.stopPropagation(),!t.dataTransfer.types.includes(`application/x-workspace-move`)&&e.classList.remove(`drag-over`)}),e.addEventListener(`drop`,async t=>{if(t.preventDefault(),t.stopPropagation(),t.dataTransfer.types.includes(`application/x-workspace-move`))return;e.classList.remove(`drag-over`);let n=t.dataTransfer.files;!n||n.length===0||await Ig(n)})}async function Rg(){try{let e=document.getElementById(`workspaceAgentName`);if(!e)return;let t=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=t.pairedAgents||[],r=t.activeAgentId;if(r){let t=n.find(e=>e.id===r);if(t&&t.name){e.textContent=` · ${t.name}`,e.style.display=``;return}}e.textContent=``,e.style.display=`none`}catch(e){a.debug(`[WorkspacePanel] update agentname failed:`,e)}}async function zg(e,t){if(t===`local`&&!(!e.pairedAgents&&!e.activeAgentId)&&(await Rg(),e.activeAgentId?.newValue!==e.activeAgentId?.oldValue)){a.debug(`[WorkspacePanel] Agent changed,refreshworking directory`),Yt(),Ep=null,q=null,Dp=[],J.clear(),a_=``,o_=[],s_=!1,ym.clear();let e=document.getElementById(`workspacePanel`);e&&e.classList.contains(`expanded`)&&await _m()}}async function Bg(){if(Dp.length===0)return;let e=Dp.pop();J.clear(),await vm(e)}async function Vg(e){if(!q){let e=Ep||await sn();if(!e){P(r(`workspace.refreshFailed`),`error`);return}Ep=e,q=e}if(Em(q),J.clear(),F_(),s_&&a_?(o_=await bn(q,a_),Pm()):await wm(q),mg(),Gm(),e!==void 0){let t=document.getElementById(`workspacePanelContent`);t&&requestAnimationFrame(()=>{t.scrollTop=e})}}function Hg(){let e=document.getElementById(`workspaceBreadcrumb`);if(!q){e.innerHTML=``;return}let t=Tm(q).split(`/`).filter(Boolean),n=Ep?Tm(Ep).replace(/\/$/,``):null,i=``,a=``;for(let e=0;e<t.length;e++){a=e===0?/^[a-zA-Z]:$/.test(t[e])?t[e]+`/`:`/`+t[e]:(a.endsWith(`/`)?a:a+`/`)+t[e];let r=e===t.length-1,o=!n||a===n||a.startsWith(n+`/`);e>0&&(i+=`<span class="workspace-breadcrumb-sep">/</span>`),r?i+=`<span class="workspace-breadcrumb-current">${X(t[e])}</span>`:o?i+=`<span class="workspace-breadcrumb-link" data-path="${X(a)}">${X(t[e])}</span>`:i+=`<span class="workspace-breadcrumb-disabled">${X(t[e])}</span>`}e.innerHTML=i||`<span class="workspace-breadcrumb-current">/</span>`,e.querySelectorAll(`.workspace-breadcrumb-link`).forEach(e=>{e.addEventListener(`click`,async t=>{t.stopPropagation();let n=e.dataset.path,r=Dp.findIndex(e=>e===n);Dp=r>=0?Dp.slice(0,r):[],J.clear(),await vm(n)}),e.addEventListener(`dragover`,t=>{t.dataTransfer.types.includes(`application/x-workspace-move`)&&(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=`move`,e.classList.add(`drop-target`))}),e.addEventListener(`dragleave`,t=>{t.preventDefault(),t.stopPropagation(),e.classList.remove(`drop-target`)}),e.addEventListener(`drop`,async t=>{if(t.preventDefault(),t.stopPropagation(),e.classList.remove(`drop-target`),t.dataTransfer.types.includes(`application/x-workspace-move`))try{let n=JSON.parse(t.dataTransfer.getData(`application/x-workspace-move`)),i=n.path,a=e.dataset.path,o=n.name,s=Tm(i),c=Tm(a);if(s===c)return;if(c.startsWith(s+`/`)){P(r(`workspace.cannotMoveToSubdir`),`error`);return}P(r(`workspace.moving`),`info`);let l=await yn(i,a);l.success?(P(r(`workspace.movedToTarget`,{name:o,target:a.split(/[\\/]/).pop()}),`success`),Em(q),Em(a),await Vg()):P(r(`workspace.moveFailed`,{error:l.error}),`error`)}catch(e){P(r(`workspace.moveFailed`,{error:e.message}),`error`)}})})}function Ug(){let e=document.getElementById(`workspaceBackBtn`);e.disabled=!(Ep&&q&&q!==Ep)}function Wg(e){let t=document.getElementById(`workspacePanelContent`);t.innerHTML=`<div class="workspace-panel-error">${X(e)}</div>`}function X(e){return e?String(e).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`):``}function Gg(e){let t=(e.split(`.`).pop()||``).toLowerCase(),n={js:`javascript`,mjs:`javascript`,ts:`typescript`,jsx:`jsx`,tsx:`tsx`,html:`html`,htm:`html`,css:`css`,scss:`scss`,less:`less`,json:`json`,xml:`xml`,yaml:`yaml`,yml:`yaml`,py:`python`,java:`java`,c:`c`,cpp:`cpp`,h:`c`,go:`go`,rs:`rust`,rb:`ruby`,php:`php`,sql:`sql`,sh:`bash`,bash:`bash`,zsh:`bash`,md:`markdown`,vue:`html`,svelte:`html`};return n[t]?`language-${n[t]}`:``}async function Kg(){q&&await wm(q)}async function qg(){Yt(),Ep=null,q=null,Dp=[],J.clear(),a_=``,o_=[],s_=!1,ym.clear();let e=document.getElementById(`workspacePanel`);e&&e.classList.contains(`expanded`)&&await _m()}function Jg(e){let t=document.getElementById(`workspacePanelContainer`);if(t)if(e){t.style.display=``;let e=document.getElementById(`workspacePanel`),n=!!(e&&e.classList.contains(`expanded`));Ip&&e&&!n?mm().catch(e=>a.warn(`[WorkspacePanel] reopen panel after reconnect failed`,e)):n&&!q&&_m().catch(e=>a.warn(`[WorkspacePanel] navigate after reconnect failed`,e)),Rp&&fm()}else t.style.display=`none`,i_(!0)}function Yg(e,t){let n=t.toLowerCase(),r=e.toLowerCase();return r===n?``:r.startsWith(n+`/`)?e.substring(t.length+1):null}function Xg(e,t){let n=t.split(`/`).filter(Boolean).pop();if(!n)return null;let r=e.lastIndexOf(`/`+n);if(r===-1)return null;let i=e.substring(r+n.length+1);return i===``?``:i}function Zg(e,t){if(!e)return null;let n=Tm(t);if(!n)return null;let r=Tm(e).trim();if(!r||r===`.`||r===`~`||r.startsWith(`~/`))return null;if(!(r.startsWith(`/`)||/^[a-zA-Z]:\//.test(r)))return n+`/`+r;let i=Yg(r,n);return i===null&&(i=Xg(r,n)),i===null?null:i===``?n:n+`/`+i}async function Qg(e){if(!(e===`~`||e&&e.startsWith(`~/`)))return e;try{let t=await mn();if(t)return Tm(e===`~`?t:t+`/`+e.slice(2))}catch{}return e}async function $g(e){if(!e)return;let t=document.getElementById(`workspacePanel`),n=document.getElementById(`workspacePanelContainer`);if(!t||!n)return;if(t.classList.add(`expanded`),xt(t),n.classList.add(`click-opened`),Ep||=await sn(),!Ep){Wg(r(`workspace.noWorkspace`));return}let i=Zg(await Qg(e),Ep);if(!i){Wg(r(`artifacts.locateFailed`));return}let a=i.lastIndexOf(`/`),o=a>0?i.substring(0,a):Ep,s=a>0?i.substring(a+1):i;Em(o),await vm(o);let c=e=>{let t=()=>{let t=null;return document.querySelectorAll(`.workspace-file-item`).forEach(n=>{n.dataset.name===e&&(t=n)}),t},n=t();if(n||!Am)return n;let r=Am.sorted.findIndex(t=>t.name===e);if(r<0)return null;let i=document.getElementById(`workspacePanelContent`);if(!i)return null;let{itemHeight:a}=Am;return i.scrollTop=Math.max(0,r*a-i.clientHeight/2+a/2),Nm(),t()};setTimeout(async()=>{let e=c(s);e||=(Em(o),await vm(o),await new Promise(e=>setTimeout(e,300)),c(s)),e?(e.classList.add(`highlighted`),e.scrollIntoView({behavior:`smooth`,block:`center`}),setTimeout(()=>e.classList.remove(`highlighted`),3e3)):P(r(`artifacts.fileNotFound`))},300)}async function e_(e,t){if(!e)return;let n=document.getElementById(`workspacePanel`),i=document.getElementById(`workspacePanelContainer`);if(!n||!i)return;let a=n.classList.contains(`expanded`);if(n.classList.add(`expanded`),xt(n),i.classList.add(`click-opened`),Ep||=await sn(),!Ep){Wg(r(`workspace.noWorkspace`));return}let o=Zg(await Qg(e),Ep);if(!o){Wg(r(`artifacts.locateFailed`));return}await mg(!0),await ih(o,t),Gp=!a}async function t_(){await mg(!0)}function n_(){i_(!0)}async function r_(e){return!e||(Ep||=await sn(),!Ep)?null:Zg(await Qg(e),Ep)}async function i_(e=!1){if(e&&await mg(!0)===!1)return;let t=document.getElementById(`workspacePanel`),n=document.getElementById(`workspacePanelContainer`);t&&(t.classList.remove(`expanded`),gt(t),e||chrome.storage.local.set({[Fp]:!1}).catch(()=>{})),n&&(n.classList.remove(`hover-expanded`),n.classList.remove(`click-opened`),Ip&&!e&&(Ip=!1,Rp=!1,n.classList.add(`closing-no-anim`),om(),requestAnimationFrame(()=>n.classList.remove(`closing-no-anim`))))}var a_=``,o_=[],s_=!1,c_=[],l_=-1;function u_(){try{chrome.storage.local.get([`workspaceSearchHistory`],e=>{c_=e.workspaceSearchHistory||[]})}catch{}}function d_(e){if(!e.trim())return;let t=c_.indexOf(e);t!==-1&&c_.splice(t,1),c_.push(e),c_.length>20&&c_.shift();try{chrome.storage.local.set({workspaceSearchHistory:c_})}catch{}}function f_(e){a_=e.target.value.trim();let t=document.getElementById(`workspaceSearchClear`);t.style.display=a_?``:`none`}async function p_(){if(!a_){s_=!1,o_=[],Pm(),Gm();return}d_(a_),l_=-1,P(r(`workspace.searching`),`info`),o_=await bn(q,a_),s_=!0,Pm(),Gm()}async function m_(){let e=document.getElementById(`workspaceSearchInput`),t=document.getElementById(`workspaceToolbar`),n=t.querySelector(`.workspace-search-box`);e.value=``,a_=``,s_=!1,o_=[],J.clear(),document.getElementById(`workspaceSearchClear`).style.display=`none`,t.classList.remove(`search-focused`),n.classList.remove(`search-box-expanded`),e.blur(),await wm(q),Gm(),F_()}async function h_(e,t,n){let i=n===`directory`,a=r(i?`workspace.confirmDeleteDir`:`workspace.confirmDeleteFile`,{name:t,path:e});if(typeof window.showCustomConfirm!=`function`){if(!confirm(a))return}else if(!await window.showCustomConfirm(a,r(`workspace.confirmDeleteTitle`)))return;let o=document.getElementById(`workspacePanelContent`),s=o?o.scrollTop:0;try{let t=await un();if(!t){P(r(`workspace.agentNotConnected`),`error`);return}let n=await(await fetch(`${t.url}/api/fs/delete`,{method:`POST`,headers:{"Content-Type":`application/json`,..._n(t)},body:JSON.stringify({path:e})})).json();n.success?(P(r(i?`workspace.dirDeleted`:`workspace.fileDeleted`),`success`),J.delete(e),F_(),await Vg(s)):P(r(`workspace.deleteFailedWithError`,{error:n.error||r(`workspace.unknownError`)}),`error`)}catch(e){P(r(`workspace.deleteFailedWithError`,{error:e.message}),`error`)}}async function g_(){if(J.size===0)return;let e=Array.from(J),t=e.map(e=>{let t=Xp.find(t=>t.path===e)||o_.find(t=>t.fullPath===e);return t?t.name:e.split(/[\\/]/).pop()}),n=t.slice(0,5).map(e=>`• ${e}`).join(`
|
|
1143
|
-
`)+(t.length>5?r(`workspace.batchNamesMore`,{count:t.length}):``),i=r(`workspace.confirmBatchDelete`,{count:e.length,names:n});if(typeof window.showCustomConfirm!=`function`){if(!confirm(i))return}else if(!await window.showCustomConfirm(i,r(`workspace.confirmBatchDeleteTitle`)))return;let a=document.getElementById(`workspacePanelContent`),o=a?a.scrollTop:0;try{let t=await un();if(!t){P(r(`workspace.agentNotConnected`),`error`);return}let n=0,i=0;for(let r of e)try{(await(await fetch(`${t.url}/api/fs/delete`,{method:`POST`,headers:{"Content-Type":`application/json`,..._n(t)},body:JSON.stringify({path:r})})).json()).success?(J.delete(r),n++):i++}catch{i++}n>0?(P(r(`workspace.deletedCount`,{success:n,failed:i>0?r(`workspace.deletedCountFailed`,{count:i}):``}),i>0?`warning`:`success`),
|
|
1148
|
+
`,document.body.appendChild(t);let n=t.querySelector(`.workspace-upload-progress-cancel`);return n&&n.addEventListener(`click`,()=>{n.style.display=`none`,typeof e==`function`&&e()}),t}function Ng(e,t){if(!e)return;let{percent:n,completed:i,total:a,fileName:o,loaded:s,totalBytes:c,speed:l,statusText:u}=t,d=e.querySelector(`.workspace-upload-progress-title`),f=e.querySelector(`.workspace-upload-progress-file`),p=e.querySelector(`.workspace-upload-progress-bar`),m=e.querySelector(`.workspace-upload-progress-bytes`),h=e.querySelector(`.workspace-upload-progress-speed`),g=e.classList.contains(`download-mode`)?r(`workspace.downloadInProgress`):r(`workspace.uploadInProgress`);d&&(u?d.textContent=u:i!=null&&a!=null?d.textContent=`${g} ${i}/${a} · ${n}%`:d.textContent=`${g} ${n}%`),f&&o&&(f.textContent=o,f.title=o),p&&(p.style.width=n+`%`),m&&(s!=null&&c!=null&&c>0?m.textContent=`${gn(s)} / ${gn(c)}`:s!=null&&(m.textContent=gn(s))),h&&(h.textContent=l>0?`${gn(l)}/s`:``)}function Pg(e,t,n){if(!e)return;let r=e.querySelector(`.workspace-upload-progress-title`),i=e.querySelector(`.workspace-upload-progress-cancel`),a=e.querySelector(`.workspace-upload-progress-bar`);i&&(i.style.display=`none`),r&&(r.textContent=t),a&&!n&&(a.style.width=`100%`),e.classList.add(`workspace-upload-progress-done`),n&&e.classList.add(`workspace-upload-progress-error`),setTimeout(()=>{try{e.remove()}catch{}},1500)}function Fg(e){let t=document.getElementById(`workspaceUploadBtn`);t&&(t.disabled=e,e?(t.dataset.originalHtml=t.innerHTML,t.innerHTML=`<span class="workspace-upload-spinner"></span>`):t.dataset.originalHtml&&(t.innerHTML=t.dataset.originalHtml,delete t.dataset.originalHtml));let n=document.getElementById(`workspacePanel`);n&&n.classList.toggle(`upload-in-progress`,e)}async function Ig(e){let t=Array.from(e);if(t.length===0||Up)return;Up=!0,Fg(!0);let n=await un();if(!n){P(r(`workspace.agentNotConnectedUpload`),`error`),Up=!1,Fg(!1);return}let i=new Set;try{let e=await en(q);e.success&&Array.isArray(e.entries)&&(i=new Set(e.entries.map(e=>e.name)))}catch{}let a=0,o=0,s=0,c=t.reduce((e,t)=>e+t.size,0),l=Array(t.length).fill(0),u=new Set,d=!1,f=``,p=[],m=()=>{if(p.length<2)return 0;let e=p[0],t=p[p.length-1],n=(t.time-e.time)/1e3;return n<=0?0:(t.loaded-e.loaded)/n},h=Mg(()=>{d=!0;for(let e of u)try{e.abort()}catch{}u.clear()}),g=e=>{e&&(f=e);let n=l.reduce((e,t)=>e+t,0),r=c>0?Math.round(n/c*100):0,i=Date.now();p.push({time:i,loaded:n}),p.length>8&&p.shift(),Ng(h,{percent:r,completed:a+o+s,total:t.length,fileName:f,loaded:n,totalBytes:c,speed:m()})};g();for(let e=0;e<t.length&&!d;e+=3){let c=t.slice(e,e+3),f=await Promise.allSettled(c.map(async(t,a)=>{let o=e+a,s=Qp(t.name),c=Tm(`${q}/${s}`);if(i.has(s))throw l[o]=t.size,g(s),Error(`__SKIPPED__`);if(d)throw Error(`__CANCELLED__`);await new Promise((e,i)=>{let a=new XMLHttpRequest;u.add(a);let s=`${n.url}/api/fs/upload-stream?path=${encodeURIComponent(c)}`;a.open(`POST`,s);for(let[e,t]of Object.entries(_n(n)))a.setRequestHeader(e,t);a.upload.onprogress=e=>{e.lengthComputable&&(l[o]=e.loaded,g(t.name))},a.onload=()=>{if(u.delete(a),d){i(Error(`__CANCELLED__`));return}if(a.status>=200&&a.status<300)try{let n=JSON.parse(a.responseText);n.success?(l[o]=t.size,g(t.name),e()):i(Error(n.error||r(`workspace.uploadFailed`)))}catch{i(Error(r(`workspace.parseResponseFailed`)))}else try{let e=JSON.parse(a.responseText);i(Error(e.error||r(`workspace.uploadFailedWithStatus`,{status:a.status})))}catch{i(Error(r(`workspace.uploadFailedWithStatus`,{status:a.status})))}},a.onerror=()=>{u.delete(a),i(Error(d?`__CANCELLED__`:r(`workspace.networkError`)))},a.onabort=()=>{u.delete(a),i(Error(`__CANCELLED__`))},a.send(t)})}));for(let e of f)if(e.status===`fulfilled`)a++;else{let t=e.reason&&e.reason.message?e.reason.message:``;t.includes(`__SKIPPED__`)||t.includes(`已存在`)?o++:t.includes(`__CANCELLED__`)||s++}}let _,v=!1;if(d)_=r(`workspace.uploadCanceled`),v=!0;else{let e=[];a>0&&e.push(r(`workspace.uploadSuccessCount`,{count:a})),o>0&&e.push(r(`workspace.uploadSkippedCount`,{count:o})),s>0&&e.push(r(`workspace.uploadFailedCount`,{count:s})),_=e.length>0?r(`workspace.uploadCompleteWithStats`,{stats:e.join(` / `)}):r(`workspace.uploadComplete`),v=s>0}Pg(h,_,v),a>0&&P(r(`workspace.uploadedFiles`,{count:a}),`success`),o>0&&P(r(`workspace.filesSkipped`,{count:o}),`info`),s>0&&P(r(`workspace.filesUploadFailed`,{count:s}),`error`),d&&P(r(`workspace.uploadCanceled`),`info`),Up=!1,Fg(!1),a>0&&(await Vg(),F_(t[t.length-1].name))}function Lg(){let e=document.getElementById(`workspacePanel`);if(!e)return;let t=document.getElementById(`workspacePanelContent`);t.addEventListener(`dragstart`,e=>{let t=e.target.closest(`.workspace-file-item`);if(!t)return;let n=t.dataset.path,r=t.dataset.name;e.dataTransfer.setData(`application/x-workspace-move`,JSON.stringify({path:n,name:r})),e.dataTransfer.effectAllowed=`move`,t.classList.add(`dragging`);let i=()=>{t.classList.remove(`dragging`),t.removeEventListener(`dragend`,i)};t.addEventListener(`dragend`,i)}),t.addEventListener(`dragover`,n=>{n.preventDefault(),n.stopPropagation();let r=n.target.closest(`.workspace-file-item.directory`);t.querySelectorAll(`.workspace-file-item.directory.drop-target`).forEach(e=>e.classList.remove(`drop-target`)),r?(n.dataTransfer.dropEffect=n.dataTransfer.types.includes(`application/x-workspace-move`)?`move`:`copy`,r.classList.add(`drop-target`),e.classList.remove(`drag-over`)):n.dataTransfer.types.includes(`application/x-workspace-move`)||e.classList.add(`drag-over`)}),t.addEventListener(`dragleave`,n=>{n.preventDefault(),n.stopPropagation(),t.querySelectorAll(`.workspace-file-item.directory.drop-target`).forEach(e=>e.classList.remove(`drop-target`)),e.classList.remove(`drag-over`)}),t.addEventListener(`drop`,async n=>{n.preventDefault(),n.stopPropagation();let i=n.target.closest(`.workspace-file-item.directory`);if(t.querySelectorAll(`.workspace-file-item.directory.drop-target`).forEach(e=>e.classList.remove(`drop-target`)),e.classList.remove(`drag-over`),i&&n.dataTransfer.types.includes(`application/x-workspace-move`)){try{let e=JSON.parse(n.dataTransfer.getData(`application/x-workspace-move`)),t=e.path,a=i.dataset.path,o=e.name,s=Tm(t),c=Tm(a);if(s===c)return;if(s.startsWith(c+`/`)){P(r(`workspace.cannotMoveToSubdir`),`error`);return}P(r(`workspace.moving`),`info`);let l=await yn(t,a);if(l.success){P(r(`workspace.movedToDir`,{name:o}),`success`),Em(q),Em(a);let e=a.split(/[\\/]/).pop();await Vg(),F_(e)}else P(r(`workspace.moveFailed`,{error:l.error}),`error`)}catch(e){P(r(`workspace.moveFailed`,{error:e.message}),`error`)}return}if(i&&n.dataTransfer.files&&n.dataTransfer.files.length>0){let e=i.dataset.path;e.split(/[\\/]/).pop(),Zp(q),q=e,await Ig(n.dataTransfer.files),Hg(),Ug();return}if(n.dataTransfer.files&&n.dataTransfer.files.length>0){await Ig(n.dataTransfer.files);return}}),e.addEventListener(`dragover`,t=>{t.preventDefault(),t.stopPropagation(),!t.dataTransfer.types.includes(`application/x-workspace-move`)&&e.classList.add(`drag-over`)}),e.addEventListener(`dragleave`,t=>{t.preventDefault(),t.stopPropagation(),!t.dataTransfer.types.includes(`application/x-workspace-move`)&&e.classList.remove(`drag-over`)}),e.addEventListener(`drop`,async t=>{if(t.preventDefault(),t.stopPropagation(),t.dataTransfer.types.includes(`application/x-workspace-move`))return;e.classList.remove(`drag-over`);let n=t.dataTransfer.files;!n||n.length===0||await Ig(n)})}async function Rg(){try{let e=document.getElementById(`workspaceAgentName`);if(!e)return;let t=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=t.pairedAgents||[],r=t.activeAgentId;if(r){let t=n.find(e=>e.id===r);if(t&&t.name){e.textContent=` · ${t.name}`,e.style.display=``;return}}e.textContent=``,e.style.display=`none`}catch(e){a.debug(`[WorkspacePanel] update agentname failed:`,e)}}async function zg(e,t){if(t===`local`&&!(!e.pairedAgents&&!e.activeAgentId)&&(await Rg(),e.activeAgentId?.newValue!==e.activeAgentId?.oldValue)){a.debug(`[WorkspacePanel] Agent changed,refreshworking directory`),Yt(),Ep=null,q=null,Dp=[],J.clear(),a_=``,o_=[],s_=!1,ym.clear();let e=document.getElementById(`workspacePanel`);e&&e.classList.contains(`expanded`)&&await _m()}}async function Bg(){if(Dp.length===0)return;let e=Dp.pop();J.clear(),await vm(e)}async function Vg(e){if(!q){let e=Ep||await sn();if(!e){P(r(`workspace.refreshFailed`),`error`);return}Ep=e,q=e}if(Em(q),J.clear(),L_(),s_&&a_?(o_=await bn(q,a_),Pm()):await wm(q),mg(),Gm(),e!==void 0){let t=document.getElementById(`workspacePanelContent`);t&&requestAnimationFrame(()=>{t.scrollTop=e})}}function Hg(){let e=document.getElementById(`workspaceBreadcrumb`);if(!q){e.innerHTML=``;return}let t=Tm(q).split(`/`).filter(Boolean),n=Ep?Tm(Ep).replace(/\/$/,``):null,i=``,a=``;for(let e=0;e<t.length;e++){a=e===0?/^[a-zA-Z]:$/.test(t[e])?t[e]+`/`:`/`+t[e]:(a.endsWith(`/`)?a:a+`/`)+t[e];let r=e===t.length-1,o=!n||a===n||a.startsWith(n+`/`);e>0&&(i+=`<span class="workspace-breadcrumb-sep">/</span>`),r?i+=`<span class="workspace-breadcrumb-current">${X(t[e])}</span>`:o?i+=`<span class="workspace-breadcrumb-link" data-path="${X(a)}">${X(t[e])}</span>`:i+=`<span class="workspace-breadcrumb-disabled">${X(t[e])}</span>`}e.innerHTML=i||`<span class="workspace-breadcrumb-current">/</span>`,e.querySelectorAll(`.workspace-breadcrumb-link`).forEach(e=>{e.addEventListener(`click`,async t=>{t.stopPropagation();let n=e.dataset.path,r=Dp.findIndex(e=>e===n);Dp=r>=0?Dp.slice(0,r):[],J.clear(),await vm(n)}),e.addEventListener(`dragover`,t=>{t.dataTransfer.types.includes(`application/x-workspace-move`)&&(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=`move`,e.classList.add(`drop-target`))}),e.addEventListener(`dragleave`,t=>{t.preventDefault(),t.stopPropagation(),e.classList.remove(`drop-target`)}),e.addEventListener(`drop`,async t=>{if(t.preventDefault(),t.stopPropagation(),e.classList.remove(`drop-target`),t.dataTransfer.types.includes(`application/x-workspace-move`))try{let n=JSON.parse(t.dataTransfer.getData(`application/x-workspace-move`)),i=n.path,a=e.dataset.path,o=n.name,s=Tm(i),c=Tm(a);if(s===c)return;if(c.startsWith(s+`/`)){P(r(`workspace.cannotMoveToSubdir`),`error`);return}P(r(`workspace.moving`),`info`);let l=await yn(i,a);l.success?(P(r(`workspace.movedToTarget`,{name:o,target:a.split(/[\\/]/).pop()}),`success`),Em(q),Em(a),await Vg()):P(r(`workspace.moveFailed`,{error:l.error}),`error`)}catch(e){P(r(`workspace.moveFailed`,{error:e.message}),`error`)}})})}function Ug(){let e=document.getElementById(`workspaceBackBtn`);e.disabled=!(Ep&&q&&q!==Ep)}function Wg(e){let t=document.getElementById(`workspacePanelContent`);t.innerHTML=`<div class="workspace-panel-error">${X(e)}</div>`}function X(e){return e?String(e).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`):``}function Gg(e){let t=(e.split(`.`).pop()||``).toLowerCase(),n={js:`javascript`,mjs:`javascript`,ts:`typescript`,jsx:`jsx`,tsx:`tsx`,html:`html`,htm:`html`,css:`css`,scss:`scss`,less:`less`,json:`json`,xml:`xml`,yaml:`yaml`,yml:`yaml`,py:`python`,java:`java`,c:`c`,cpp:`cpp`,h:`c`,go:`go`,rs:`rust`,rb:`ruby`,php:`php`,sql:`sql`,sh:`bash`,bash:`bash`,zsh:`bash`,md:`markdown`,vue:`html`,svelte:`html`};return n[t]?`language-${n[t]}`:``}async function Kg(){q&&await wm(q)}async function qg(){Yt(),Ep=null,q=null,Dp=[],J.clear(),a_=``,o_=[],s_=!1,ym.clear();let e=document.getElementById(`workspacePanel`);e&&e.classList.contains(`expanded`)&&await _m()}function Jg(e){let t=document.getElementById(`workspacePanelContainer`);if(t)if(e){t.style.display=``;let e=document.getElementById(`workspacePanel`),n=!!(e&&e.classList.contains(`expanded`));Ip&&e&&!n?mm().catch(e=>a.warn(`[WorkspacePanel] reopen panel after reconnect failed`,e)):n&&!q&&_m().catch(e=>a.warn(`[WorkspacePanel] navigate after reconnect failed`,e)),Rp&&fm()}else t.style.display=`none`,i_(!0)}function Yg(e,t){let n=t.toLowerCase(),r=e.toLowerCase();return r===n?``:r.startsWith(n+`/`)?e.substring(t.length+1):null}function Xg(e,t){let n=t.split(`/`).filter(Boolean).pop();if(!n)return null;let r=e.lastIndexOf(`/`+n);if(r===-1)return null;let i=e.substring(r+n.length+1);return i===``?``:i}function Zg(e,t){if(!e)return null;let n=Tm(t);if(!n)return null;let r=Tm(e).trim();if(!r||r===`.`||r===`~`||r.startsWith(`~/`))return null;if(!(r.startsWith(`/`)||/^[a-zA-Z]:\//.test(r)))return n+`/`+r;let i=Yg(r,n);return i===null&&(i=Xg(r,n)),i===null?null:i===``?n:n+`/`+i}async function Qg(e){if(!(e===`~`||e&&e.startsWith(`~/`)))return e;try{let t=await mn();if(t)return Tm(e===`~`?t:t+`/`+e.slice(2))}catch{}return e}async function $g(e){if(!e)return;let t=document.getElementById(`workspacePanel`),n=document.getElementById(`workspacePanelContainer`);if(!t||!n)return;if(t.classList.add(`expanded`),xt(t),n.classList.add(`click-opened`),Ep||=await sn(),!Ep){Wg(r(`workspace.noWorkspace`));return}let i=Zg(await Qg(e),Ep);if(!i){Wg(r(`artifacts.locateFailed`));return}let a=i.lastIndexOf(`/`),o=a>0?i.substring(0,a):Ep,s=a>0?i.substring(a+1):i;Em(o),await vm(o);let c=e=>{let t=()=>{let t=null;return document.querySelectorAll(`.workspace-file-item`).forEach(n=>{n.dataset.name===e&&(t=n)}),t},n=t();if(n||!Am)return n;let r=Am.sorted.findIndex(t=>t.name===e);if(r<0)return null;let i=document.getElementById(`workspacePanelContent`);if(!i)return null;let{itemHeight:a}=Am;return i.scrollTop=Math.max(0,r*a-i.clientHeight/2+a/2),Nm(),t()};setTimeout(async()=>{let e=c(s);e||=(Em(o),await vm(o),await new Promise(e=>setTimeout(e,300)),c(s)),e?(e.classList.add(`highlighted`),e.scrollIntoView({behavior:`smooth`,block:`center`}),setTimeout(()=>e.classList.remove(`highlighted`),3e3)):P(r(`artifacts.fileNotFound`))},300)}async function e_(e,t){if(!e)return;let n=document.getElementById(`workspacePanel`),i=document.getElementById(`workspacePanelContainer`);if(!n||!i)return;let a=n.classList.contains(`expanded`);if(n.classList.add(`expanded`),xt(n),i.classList.add(`click-opened`),Ep||=await sn(),!Ep){Wg(r(`workspace.noWorkspace`));return}let o=Zg(await Qg(e),Ep);if(!o){Wg(r(`artifacts.locateFailed`));return}await mg(!0),await ih(o,t),Gp=!a}async function t_(){await mg(!0)}function n_(){i_(!0)}async function r_(e){return!e||(Ep||=await sn(),!Ep)?null:Zg(await Qg(e),Ep)}async function i_(e=!1){if(e&&await mg(!0)===!1)return;let t=document.getElementById(`workspacePanel`),n=document.getElementById(`workspacePanelContainer`);t&&(t.classList.remove(`expanded`),gt(t),e||chrome.storage.local.set({[Fp]:!1}).catch(()=>{})),n&&(n.classList.remove(`hover-expanded`),n.classList.remove(`click-opened`),Ip&&!e&&(Ip=!1,Rp=!1,n.classList.add(`closing-no-anim`),om(),requestAnimationFrame(()=>n.classList.remove(`closing-no-anim`))))}var a_=``,o_=[],s_=!1,c_=[],l_=-1;function u_(){try{chrome.storage.local.get([`workspaceSearchHistory`],e=>{c_=e.workspaceSearchHistory||[]})}catch{}}function d_(e){if(!e.trim())return;let t=c_.indexOf(e);t!==-1&&c_.splice(t,1),c_.push(e),c_.length>20&&c_.shift();try{chrome.storage.local.set({workspaceSearchHistory:c_})}catch{}}function f_(e){a_=e.target.value.trim();let t=document.getElementById(`workspaceSearchClear`);t.style.display=a_?``:`none`}async function p_(){if(!a_){s_=!1,o_=[],Pm(),Gm();return}d_(a_),l_=-1,P(r(`workspace.searching`),`info`),o_=await bn(q,a_),s_=!0,Pm(),Gm()}async function m_(){let e=document.getElementById(`workspaceSearchInput`),t=document.getElementById(`workspaceToolbar`),n=t.querySelector(`.workspace-search-box`);e.value=``,a_=``,s_=!1,o_=[],J.clear(),document.getElementById(`workspaceSearchClear`).style.display=`none`,t.classList.remove(`search-focused`),n.classList.remove(`search-box-expanded`),e.blur(),await wm(q),Gm(),L_()}async function h_(e,t,n){let i=n===`directory`,a=r(i?`workspace.confirmDeleteDir`:`workspace.confirmDeleteFile`,{name:t,path:e});if(typeof window.showCustomConfirm!=`function`){if(!confirm(a))return}else if(!await window.showCustomConfirm(a,r(`workspace.confirmDeleteTitle`)))return;let o=document.getElementById(`workspacePanelContent`),s=o?o.scrollTop:0;try{let t=await un();if(!t){P(r(`workspace.agentNotConnected`),`error`);return}let n=await(await fetch(`${t.url}/api/fs/delete`,{method:`POST`,headers:{"Content-Type":`application/json`,..._n(t)},body:JSON.stringify({path:e})})).json();n.success?(P(r(i?`workspace.dirDeleted`:`workspace.fileDeleted`),`success`),J.delete(e),L_(),await Vg(s)):P(r(`workspace.deleteFailedWithError`,{error:n.error||r(`workspace.unknownError`)}),`error`)}catch(e){P(r(`workspace.deleteFailedWithError`,{error:e.message}),`error`)}}async function g_(){if(J.size===0)return;let e=Array.from(J),t=e.map(e=>{let t=Xp.find(t=>t.path===e)||o_.find(t=>t.fullPath===e);return t?t.name:e.split(/[\\/]/).pop()}),n=t.slice(0,5).map(e=>`• ${e}`).join(`
|
|
1149
|
+
`)+(t.length>5?r(`workspace.batchNamesMore`,{count:t.length}):``),i=r(`workspace.confirmBatchDelete`,{count:e.length,names:n});if(typeof window.showCustomConfirm!=`function`){if(!confirm(i))return}else if(!await window.showCustomConfirm(i,r(`workspace.confirmBatchDeleteTitle`)))return;let a=document.getElementById(`workspacePanelContent`),o=a?a.scrollTop:0;try{let t=await un();if(!t){P(r(`workspace.agentNotConnected`),`error`);return}let n=0,i=0;for(let r of e)try{(await(await fetch(`${t.url}/api/fs/delete`,{method:`POST`,headers:{"Content-Type":`application/json`,..._n(t)},body:JSON.stringify({path:r})})).json()).success?(J.delete(r),n++):i++}catch{i++}n>0?(P(r(`workspace.deletedCount`,{success:n,failed:i>0?r(`workspace.deletedCountFailed`,{count:i}):``}),i>0?`warning`:`success`),L_(),await Vg(o)):P(r(`workspace.deleteFailed`),`error`)}catch(e){P(r(`workspace.deleteFailedWithError`,{error:e.message}),`error`)}}function __(e,t){let n=[{bit:256,ch:`r`},{bit:128,ch:`w`},{bit:64,ch:`x`},{bit:32,ch:`r`},{bit:16,ch:`w`},{bit:8,ch:`x`},{bit:4,ch:`r`},{bit:2,ch:`w`},{bit:1,ch:`x`}],r=t?`d`:`-`;for(let t of n)r+=e&t.bit?t.ch:`-`,t.ch===`x`&&e&t.bit<<9&&(r=r.slice(0,-1)+(t.ch===`x`?`s`:`S`));let i=(e&511).toString(8).padStart(3,`0`);return`${r} (${i})`}async function v_(e,t,n){let i=document.createElement(`div`);i.className=`modal-overlay show`,i.innerHTML=`
|
|
1144
1150
|
<div class="modal-container file-info-modal">
|
|
1145
1151
|
<button class="file-info-close" title="${r(`workspace.close`)}" style="position:absolute;top:10px;right:12px;background:none;border:none;font-size:20px;color:var(--text-tertiary);cursor:pointer;padding:4px 8px;line-height:1;transition:color 0.15s ease;">×</button>
|
|
1146
1152
|
<div class="modal-title">${X(t)} - ${r(`workspace.fileDetailsLabel`)}</div>
|
|
@@ -1156,7 +1162,7 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1156
1162
|
<button class="modal-btn-cancel" style="padding:6px 16px;border:1px solid var(--border-default);border-radius:6px;background:var(--bg-surface);cursor:pointer;">${r(`workspace.cancel`)}</button>
|
|
1157
1163
|
<button class="modal-btn-confirm" style="padding:6px 16px;border:none;border-radius:6px;background:var(--info-500);color:var(--text-inverse);cursor:pointer;">${r(`workspace.confirm`)}</button>
|
|
1158
1164
|
</div>
|
|
1159
|
-
</div>`,document.body.appendChild(a);let o=a.querySelector(`.modal-input`),s=a.querySelector(`.modal-btn-confirm`),c=a.querySelector(`.modal-btn-cancel`),l=()=>{a.remove()},u=()=>{let e=o.value.trim();l(),i(e||null)};s.addEventListener(`click`,u),c.addEventListener(`click`,()=>{l(),i(null)}),o.addEventListener(`keydown`,e=>{e.key===`Enter`&&u(),e.key===`Escape`&&(l(),i(null))}),setTimeout(()=>o.select(),50)})}async function b_(e){if(!e)return!1;try{let{getQueuedCount:t}=await M(async()=>{let{getQueuedCount:e}=await Promise.resolve().then(()=>Yn);return{getQueuedCount:e}},void 0);return t(e)>0}catch{return!1}}async function x_(e={}){let t=e.sessionId===void 0?N.activeSessionId||null:e.sessionId;if(t&&(N.generatingSessionIds?.has(t)||await b_(t)))return P(r(`workdirTag.lockedHint`),`warning`),!1;let n=null;try{n=await vn(t)}catch{return P(r(`workspace.getWorkdirInfoFailed`),`error`),!1}if(!n)return P(r(`workspace.cannotConnectAgent`),`error`),!1;let i=!!t&&n.sessionWorkdirSupported===!0,o=!!(i&&n.sessionWorkdir),s=r(o?`workdirTag.sessionScope`:`workdirTag.defaultScope`),c=n.workdir||``,l=Array.isArray(n.allowedPaths)?[...n.allowedPaths]:[],u=!1;try{let e=await un(),t=e&&e.url?new URL(e.url).hostname:``;
|
|
1165
|
+
</div>`,document.body.appendChild(a);let o=a.querySelector(`.modal-input`),s=a.querySelector(`.modal-btn-confirm`),c=a.querySelector(`.modal-btn-cancel`),l=()=>{a.remove()},u=()=>{let e=o.value.trim();l(),i(e||null)};s.addEventListener(`click`,u),c.addEventListener(`click`,()=>{l(),i(null)}),o.addEventListener(`keydown`,e=>{e.key===`Enter`&&u(),e.key===`Escape`&&(l(),i(null))}),setTimeout(()=>o.select(),50)})}async function b_(e){if(!e)return!1;try{let{getQueuedCount:t}=await M(async()=>{let{getQueuedCount:e}=await Promise.resolve().then(()=>Yn);return{getQueuedCount:e}},void 0);return t(e)>0}catch{return!1}}async function x_(e={}){let t=e.sessionId===void 0?N.activeSessionId||null:e.sessionId;if(t&&(N.generatingSessionIds?.has(t)||await b_(t)))return P(r(`workdirTag.lockedHint`),`warning`),!1;let n=null;try{n=await vn(t)}catch{return P(r(`workspace.getWorkdirInfoFailed`),`error`),!1}if(!n)return P(r(`workspace.cannotConnectAgent`),`error`),!1;let i=!!t&&n.sessionWorkdirSupported===!0,o=!!(i&&n.sessionWorkdir),s=r(o?`workdirTag.sessionScope`:`workdirTag.defaultScope`),c=n.workdir||``,l=n.defaultWorkdir||c,u=Array.isArray(n.allowedPaths)?[...n.allowedPaths]:[],d=(e,t)=>String(e||``).replace(/\\/g,`/`).toLowerCase()===String(t||``).replace(/\\/g,`/`).toLowerCase(),f=()=>{let e=[...u],t=t=>{t&&!e.some(e=>d(e,t))&&e.push(t)};return t(l),t(c),e},p=!1;try{let e=await un(),t=e&&e.url?new URL(e.url).hostname:``;p=t===`localhost`||t===`127.0.0.1`||t===`[::1]`}catch(e){a.debug(`[WorkspacePanel] detect local agent failed:`,e)}return new Promise(e=>{let n=document.createElement(`div`);n.className=`modal-overlay show`,n.innerHTML=`
|
|
1160
1166
|
<div class="modal-container switch-workdir-dialog" style="max-width:480px;width:90%;box-sizing:border-box;position:relative;">
|
|
1161
1167
|
<button class="switch-workdir-close" title="${r(`workspace.close`)}" style="position:absolute;top:10px;right:12px;width:28px;height:28px;border:none;background:transparent;color:var(--text-tertiary);border-radius:6px;font-size:18px;cursor:pointer;display:flex;align-items:center;justify-content:center;line-height:1;padding:0;transition:all 0.2s;">✕</button>
|
|
1162
1168
|
<div class="modal-title">${r(i?`workdirTag.switchTitle`:`workspace.switchWorkdirTitle`)}</div>
|
|
@@ -1169,25 +1175,26 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1169
1175
|
<div style="font-size:12px;color:var(--text-tertiary);margin:6px 0;">${r(`workspace.orInputPath`)}</div>
|
|
1170
1176
|
<div style="display:flex;gap:8px;margin-bottom:12px;">
|
|
1171
1177
|
<input type="text" class="switch-workdir-manual" placeholder="${r(`workspace.manualPathPlaceholder`)}" style="flex:1;min-width:0;padding:8px 12px;border:1px solid var(--border-default);border-radius:6px;font-size:13px;box-sizing:border-box;" autofocus>
|
|
1172
|
-
${
|
|
1178
|
+
${p?`<button class="switch-workdir-browse" title="${r(`workspace.browseBtn`)}" style="flex-shrink:0;padding:6px 14px;border:1px solid var(--border-default);border-radius:6px;background:var(--bg-surface);color:var(--text-primary);font-size:13px;cursor:pointer;white-space:nowrap;">${r(`workspace.browseBtn`)}</button>`:``}
|
|
1173
1179
|
</div>
|
|
1174
|
-
${i?`<label style="display:flex;align-items:flex-start;gap:6px;margin-bottom:10px;font-size:12px;color:var(--text-tertiary);cursor:pointer;"><input type="checkbox" class="switch-workdir-set-default" style="margin-top:1px;flex-shrink:0;"><span>${r(`workdirTag.setAsAgentDefault`)}</span></label>`:``}
|
|
1180
|
+
${i?`<label title="${r(`workdirTag.setAsAgentDefaultHint`)}" style="display:flex;align-items:flex-start;gap:6px;margin-bottom:10px;font-size:12px;color:var(--text-tertiary);cursor:pointer;"><input type="checkbox" class="switch-workdir-set-default" style="margin-top:1px;flex-shrink:0;"><span>${r(`workdirTag.setAsAgentDefault`)}</span></label>`:``}
|
|
1175
1181
|
<div style="display:flex;justify-content:flex-end;gap:8px;">
|
|
1176
1182
|
<button class="switch-workdir-cancel" style="padding:6px 16px;border:1px solid var(--border-default);border-radius:6px;background:var(--bg-surface);cursor:pointer;">${r(`workspace.cancel`)}</button>
|
|
1177
1183
|
<button class="switch-workdir-confirm" style="padding:6px 16px;border:none;border-radius:6px;background:var(--info-500);color:var(--text-inverse);cursor:pointer;">${r(`workspace.switchBtn`)}</button>
|
|
1178
1184
|
</div>
|
|
1179
|
-
</div>`,document.body.appendChild(n);let a=n.querySelector(`#switchWorkdirList`),
|
|
1185
|
+
</div>`,document.body.appendChild(n);let a=n.querySelector(`#switchWorkdirList`),m=n.querySelector(`.switch-workdir-manual`),h=n.querySelector(`.switch-workdir-cancel`),g=n.querySelector(`.switch-workdir-confirm`),_=n.querySelector(`.switch-workdir-close`),v=n.querySelector(`.switch-workdir-browse`),y=n.querySelector(`.switch-workdir-restore`),b=n.querySelector(`.switch-workdir-set-default`);v&&v.addEventListener(`click`,async()=>{let e=v.textContent;v.disabled=!0,v.textContent=r(`workspace.picking`);try{let e=await Sn(),t=e&&typeof e==`object`?e:{},n=typeof t.error==`string`?t.error:``;t.success&&t.path?(m.value=t.path,m.focus()):t.success||(t.outdated?P(r(`workspace.browseAgentOutdated`),`error`):n===`busy`?P(r(`workspace.browseBusy`),`info`):n===`timeout`||n===`client-timeout`?P(r(`workspace.browseTimeout`),`info`,5e3):/^(no-dialog-tool|no-display|remote-source)/.test(n)?P(r(`workspace.browseUnavailable`),`info`):P(r(`workspace.browseFailedWithError`,{error:n||r(`workspace.unknownError`)}),`error`,8e3))}catch(e){P(r(`workspace.browseFailedWithError`,{error:e.message||e}),`error`)}finally{v.disabled=!1,v.textContent=e}});let x=!1,S=()=>{x||(x=!0,n.remove())};function C(){let e=f();if(!e.length){a.innerHTML=`<div style="padding:16px;text-align:center;color:var(--text-disabled);font-size:13px;">`+r(`workspace.noAllowedPaths`)+`</div>`;return}a.innerHTML=e.map(e=>{let t=d(e,c),n=d(e,l),i=u.some(t=>d(t,e)),a=`<span style="flex-shrink:0;font-size:11px;color:var(--info-500);border:1px solid var(--info-500);border-radius:4px;padding:0 6px;">`+r(`workspace.currentTag`)+`</span>`,o=`<span style="flex-shrink:0;font-size:11px;color:var(--text-tertiary);border:1px solid var(--border-default);border-radius:4px;padding:0 6px;">`+r(`workspace.defaultTag`)+`</span>`;return`
|
|
1180
1186
|
<div class="switch-workdir-item${t?` current`:``}" data-path="${X(e)}" title="${X(e)}" style="display:flex;align-items:center;gap:8px;padding:8px 12px;cursor:${t?`default`:`pointer`};font-size:13px;color:${t?`var(--text-tertiary)`:`var(--text-primary)`};word-break:break-all;border-bottom:1px solid var(--bg-subtle);${t?`background:var(--bg-subtle);`:``}">
|
|
1181
1187
|
<span style="flex-shrink:0;">📁</span>
|
|
1182
1188
|
<span style="flex:1;">${X(e)}</span>
|
|
1183
|
-
${t
|
|
1184
|
-
</div>`}).join(``)}b();async function x(e){if(!await window.showCustomConfirm(r(`workspace.confirmRemovePath`,{path:e}),r(`workspace.confirmRemovePathTitle`)))return;let t=await xn(e);t.success?(l=Array.isArray(t.allowedPaths)?t.allowedPaths:l.filter(t=>t!==e),b(),P(r(`workspace.removedFromAllowed`),`success`)):P(r(`workspace.removeFailedWithError`,{error:t.error||r(`workspace.unknownError`)}),`error`)}a.addEventListener(`click`,e=>{let t=e.target.closest(`.switch-workdir-remove`);if(t){e.stopPropagation(),x(t.dataset.removePath);return}let n=e.target.closest(`.switch-workdir-item:not(.current)`);n&&S(n.dataset.path)});async function S(n){if(!n){P(r(`workspace.selectOrInputPath`),`error`);return}if(n=n.trim(),n===c){P(r(`workspace.alreadyCurrentWorkdir`),`info`),y(),e(!1);return}let a=e=>e.replace(/\\/g,`/`).toLowerCase();if(!l.some(e=>{let t=a(n),r=a(e);return t===r||t.startsWith(r+`/`)})&&!await window.showCustomConfirm(r(`workspace.confirmSwitchToNew`,{path:n}),r(`workspace.confirmSwitchToNewTitle`)))return;y();let o=!!(_&&_.checked);e(await E_(n,{sessionId:i?t:null,setAsDefault:o}))}g&&g.addEventListener(`click`,async()=>{g.disabled=!0,y(),e(await D_(t,{sessionSupported:i}))}),p.addEventListener(`click`,()=>S(d.value)),f.addEventListener(`click`,()=>{y(),e(!1)}),m.addEventListener(`click`,()=>{y(),e(!1)}),m.addEventListener(`mouseenter`,()=>{m.style.color=`var(--text-primary)`,m.style.background=`var(--border-subtle)`}),m.addEventListener(`mouseleave`,()=>{m.style.color=`var(--text-tertiary)`,m.style.background=`transparent`}),d.addEventListener(`keydown`,t=>{t.key===`Enter`&&(t.preventDefault(),S(d.value)),t.key===`Escape`&&(y(),e(!1))}),n.addEventListener(`click`,e=>{e.target===n&&e.stopPropagation()}),setTimeout(()=>d.focus(),50)})}function S_(){Ep=null,q=null,Dp=[],J.clear(),a_=``,o_=[],s_=!1,ym.clear();let e=document.getElementById(`workspaceSearchInput`);e&&(e.value=``);let t=document.getElementById(`workspaceSearchClear`);t&&(t.style.display=`none`);let n=document.getElementById(`workspaceToolbar`);if(n){n.classList.remove(`search-focused`);let e=n.querySelector(`.workspace-search-box`);e&&e.classList.remove(`search-box-expanded`)}}var C_=0;async function w_(){let e=++C_;if(N.agentPlatform?.connected!==!0){Yt(),S_();return}await Rg();let t=Ep;Yt();let n=null;try{n=await sn()}catch(e){a.warn(`[WorkspacePanel] resolve root for session failed:`,e?.message||e)}if(e!==C_||t&&n&&t===n)return;S_();let r=document.getElementById(`workspacePreviewArea`);if(r&&r.dataset.previewPath&&(Gp=!1,await mg(!0)),await Promise.resolve(),e!==C_)return;let i=document.getElementById(`workspacePanel`);!i||!i.classList.contains(`expanded`)||await _m()}async function T_(e,t){document.dispatchEvent(new CustomEvent(`session-workdir-changed`,{detail:{sessionId:e,workdir:t}}))}async function E_(e,t={}){let n=t.sessionId===void 0?N.activeSessionId||null:t.sessionId,i=t.setAsDefault===!0,o=await Xt(e,{sessionId:n});if(!o.success)return P(r(`workspace.switchFailedWithError`,{error:o.error||r(`workspace.unknownError`)}),`error`),!1;if(n)try{let{setSessionWorkdirBinding:e}=await M(async()=>{let{setSessionWorkdirBinding:e}=await import(`./session-store-C5M7aiQR.js`).then(e=>e.m);return{setSessionWorkdirBinding:e}},__vite__mapDeps([2,1,3,4])),t=(await un())?.id||null;await e(n,o.workdir,t)}catch(e){a.warn(`[WorkspacePanel] persist session workdir failed:`,e)}if(i){let e=await Xt(o.workdir,{sessionId:null});e.success||P(r(`workspace.switchFailedWithError`,{error:e.error||r(`workspace.unknownError`)}),`error`)}if(!n||i){N.defaultWorkdir=o.workdir,N.agentPlatform&&={...N.agentPlatform,workdir:o.workdir};try{let{activeAgentId:e}=await chrome.storage.local.get([`activeAgentId`]);e&&(N.agentWorkdirs.set(e,o.workdir),typeof window.updateAgentItemWorkdir==`function`&&window.updateAgentItemWorkdir(e,o.workdir))}catch(e){a.debug(`[WorkspacePanel] sync dropdown column table workdir failed:`,e)}}return await T_(n,o.workdir),P(r(`workspace.switchedTo`,{path:o.workdir}),`success`),!0}async function D_(e,t={}){if(!e)return!1;let{unbindSessionWorkdirRemote:n}=await M(async()=>{let{unbindSessionWorkdirRemote:e}=await import(`./session-store-C5M7aiQR.js`).then(e=>e.at);return{unbindSessionWorkdirRemote:e}},__vite__mapDeps([2,1,3,4]));if(await n(e)===null&&t.sessionSupported)return P(r(`workspace.switchFailedWithError`,{error:r(`workspace.unknownError`)}),`error`),!1;try{let{setSessionWorkdirBinding:t}=await M(async()=>{let{setSessionWorkdirBinding:e}=await import(`./session-store-C5M7aiQR.js`).then(e=>e.m);return{setSessionWorkdirBinding:e}},__vite__mapDeps([2,1,3,4]));await t(e,null,null)}catch(e){a.warn(`[WorkspacePanel] clear session workdir failed:`,e)}return await T_(e,``),P(r(`workdirTag.restoredDefault`),`success`),!0}async function O_(e,t,n){let i=t,a=``,o=t.lastIndexOf(`.`);n!==`directory`&&o>0&&(i=t.substring(0,o),a=t.substring(o));let s=await y_(r(n===`directory`?`workspace.renameDir`:`workspace.renameFile`),i,r(`workspace.inputNewName`));if(!s||s===i)return;let c=s+a;try{let t=await Qt(e,c);t.success?(P(r(`workspace.renamedTo`,{name:c}),`success`),Em(q),await Vg(),N_(c)):P(r(`workspace.renameFailedWithError`,{error:t.error}),`error`)}catch(e){P(r(`workspace.renameFailedWithError`,{error:e.message}),`error`)}}async function k_(){if(!q)return;let e=await y_(r(`workspace.newFolderTitle`),``,r(`workspace.inputFolderName`));if(!e)return;let t=Tm(`${q}/${e}`);try{let n=await fn(t);n.success?(P(r(`workspace.folderCreated`,{name:e}),`success`),Em(q),await Vg(),N_(e)):P(r(`workspace.createFailedWithError`,{error:n.error}),`error`)}catch(e){P(r(`workspace.createFailedWithError`,{error:e.message}),`error`)}}async function A_(e){return new Promise((t,n)=>{let i=new Image,a=URL.createObjectURL(e);i.onload=()=>{URL.revokeObjectURL(a);let n=new FileReader;n.onloadend=()=>{let e=n.result,r=i.width,a=i.height,o=Math.max(r,a),s,c;o<=768?(s=o,c=.75):o<=1280?(s=768,c=.7):o<=2560?(s=1024,c=.65):o<=3840?(s=1280,c=.6):(s=1280,c=.55);let l=r,u=a;o>s&&(r>a?(u=Math.round(s/r*a),l=s):(l=Math.round(s/a*r),u=s));let d=document.createElement(`canvas`);d.width=l,d.height=u;let f=d.getContext(`2d`);f.imageSmoothingEnabled=!0,f.imageSmoothingQuality=`high`,f.drawImage(i,0,0,l,u),t({originalUrl:e,compressedUrl:d.toDataURL(`image/jpeg`,c)})},n.readAsDataURL(e)},i.onerror=()=>{URL.revokeObjectURL(a),n(Error(r(`workspace.imageLoadFailed`)))},i.src=a})}async function j_(e){let t=[],n=[];for(let r of e){let e=r&&typeof r==`object`,i=e?r.fullPath||r.path:r,a=i.split(/[\\/]/).pop(),o;e?o=r:(o=Xp.find(e=>e.path===i),o||=o_.find(e=>e.fullPath===i));let s=o?o.size:0,c=dn(a);if(c.startsWith(`image/`)&&N.enableImageInput)n.push({name:a,size:s,type:c,path:i});else{let e={name:a,size:s,type:c,text:``,status:`done`,agentPath:i};t.push(e)}}for(let e of n)try{let t=await un();if(t){let n=await fetch(`${t.url}/api/fs/download-stream`,{method:`POST`,headers:{"Content-Type":`application/json`,..._n(t)},body:JSON.stringify({path:e.path})});if(n.ok){let{originalUrl:e,compressedUrl:t}=await A_(await n.blob());N.attachedImages.some(e=>e.compressedUrl===t)||N.attachedImages.push({originalUrl:e,compressedUrl:t})}}}catch{}for(let e of t)N.attachedFiles.some(t=>t.name===e.name&&t.agentPath===e.agentPath)||N.attachedFiles.push(e);$f(),bp();let i=t.length+n.length;i>0&&(!N.enableImageInput&&t.some(e=>e.type?.startsWith(`image/`))?P(r(`workspace.addedFilesToQuestionNoImage`,{count:i}),`success`):P(r(`workspace.addedFilesToQuestion`,{count:i}),`success`))}async function M_(){J.size!==0&&await j_(Array.from(J))}function N_(e,t=0){let n=document.getElementById(`workspacePanelContent`);if(!n)return;if(Am){let t=Am.sorted.findIndex(t=>t.name===e);if(t>=0){let r=Am.itemHeight;n.scrollTop=Math.max(0,t*r-n.clientHeight/2+r/2),Nm();let i=Array.from(n.querySelectorAll(`.workspace-file-item`)).find(t=>t.dataset.name===e);i&&(i.classList.add(`highlight-new`),setTimeout(()=>i.classList.remove(`highlight-new`),2e3));return}}let r=Array.from(n.querySelectorAll(`.workspace-file-item`)).find(t=>t.dataset.name===e);r?(r.scrollIntoView({behavior:`smooth`,block:`center`}),r.classList.add(`highlight-new`),setTimeout(()=>r.classList.remove(`highlight-new`),2e3)):t<5&&setTimeout(()=>N_(e,t+1),150)}function P_(){let e=document.getElementById(`workspaceAskBtn`);J.size===0?e.style.display=`none`:e.style.display=``}function F_(){let e=document.getElementById(`workspaceDownloadDirBtn`),t=document.getElementById(`workspaceBatchDeleteBtn`),n=document.getElementById(`workspaceSelectedCount`);J.size===0?(e.style.display=`none`,t.style.display=`none`,n.style.display=`none`):(e.style.display=``,t.style.display=``,n.style.display=``,n.textContent=r(`workspace.selectedCount`,{count:J.size}),e.disabled=Hp),P_()}n(`zh`,{artifacts:{btnTitle:`文件产物({count})`,modalTitle:`本次任务的文件产物`,emptyHint:`本次任务没有产生文件产物`,fileCol:`文件`,sizeCol:`大小`,typeCol:`类型`,timeCol:`时间`,actionCol:`操作`,locate:`定位到文件`,preview:`预览`,closeBtn:`关闭`,typeWrite:`写入`,typeDelete:`删除`,typeCreate:`创建`,typeEdit:`编辑`,typeOther:`操作`,noWorkspace:`无法获取工作目录,请确认 Agent 已连接`,locateFailed:`定位文件失败`,fileNotFound:`目录已定位,但未找到该文件(可能已被删除)`,previewFailed:`预览文件失败`,previewNotSupported:`此文件类型不支持预览`,totalCount:`共 {count} 个文件`,badgeLabel:`产物`,download:`下载`,downloadFailed:`下载失败`,copyFileName:`复制文件名`,copyFilePath:`复制文件路径`,copiedName:`已复制文件名:{name}`,copiedPath:`已复制文件路径`,dblClickHint:`双击文件名可预览`,sortHint:`点击排序`,serialCol:`序号`}}),n(`en`,{artifacts:{btnTitle:`Artifacts ({count})`,modalTitle:`File Artifacts of This Task`,emptyHint:`No file artifacts produced in this task`,fileCol:`File`,sizeCol:`Size`,typeCol:`Type`,timeCol:`Time`,actionCol:`Actions`,locate:`Locate File`,preview:`Preview`,closeBtn:`Close`,typeWrite:`Write`,typeDelete:`Delete`,typeCreate:`Create`,typeEdit:`Edit`,typeOther:`Op`,noWorkspace:`Unable to access working directory. Please confirm the Agent is connected.`,locateFailed:`Failed to locate file`,fileNotFound:`Directory located, but file not found (may have been deleted)`,previewFailed:`Failed to preview file`,previewNotSupported:`Preview not supported for this file type`,totalCount:`{count} files in total`,badgeLabel:`Artifacts`,download:`Download`,downloadFailed:`Download failed`,copyFileName:`Copy File Name`,copyFilePath:`Copy File Path`,copiedName:`Copied file name: {name}`,copiedPath:`File path copied`,dblClickHint:`Double-click to preview`,sortHint:`Click to sort`,serialCol:`#`}});function Z(e){let t=(e||``).replace(/\\/g,`/`).replace(/\/+/g,`/`),n=t.replace(/\/+$/,``);return n?/^[A-Za-z]:$/.test(n)?n+`/`:n:t?`/`:``}function I_(e){if(!e)return``;let t=Z(e).replace(/\/+$/,``).split(`/`);return t[t.length-1]||``}function L_(e){if(!e)return``;let t=I_(e),n=t.lastIndexOf(`.`);return n>0?t.substring(n+1).toLowerCase():``}function R_(e){return String(e??``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function z_(e,t){let n=new Set(t),r=[],i=0,a=``;for(let t of e)t===`{`?i++:t===`}`&&(i=Math.max(0,i-1)),i===0&&n.has(t)?(r.push(a),a=``):a+=t;return r.push(a),r}function B_(e){let t=e.indexOf(`{`);if(t===-1)return[e];let n=0,r=-1;for(let i=t;i<e.length;i++)if(e[i]===`{`)n++;else if(e[i]===`}`&&(n--,n===0)){r=i;break}if(r===-1)return[e];let i=e.substring(0,t),a=e.substring(t+1,r),o=e.substring(r+1),s=z_(a,`,`).map(e=>e.trim());if(s.length<=1)return[e];let c=[];for(let e of s)for(let t of B_(e))for(let e of B_(o))c.push(i+t+e);return c}function V_(e,t){let n=[],r=new Set;for(let i of e)if(i)for(let e of B_(i)){if(!e)continue;let i=t(e);!i||r.has(i)||(r.add(i),n.push(i))}return n}function H_(e){if(!e)return null;let t=e;if(typeof t==`string`)try{t=JSON.parse(t)}catch{let e=t.match(/["']?path["']?\s*[:=]\s*["']([^"']+)["']/i);return e?e[1]:null}return t&&typeof t==`object`&&(t.path||t.filePath||t.file_path||t.result?.path)||null}function U_(e){let t=[],n=0,r=``;for(let i=0;i<e.length;i++){let a=e[i];if(a===`{`?n++:a===`}`&&(n=Math.max(0,n-1)),n===0&&a===`<`&&e[i+1]===`<`){let t=W_(e,i);if(t>i){r+=e.substring(i,t),i=t-1;continue}}n===0&&a===`;`?(t.push(r),r=``):n===0&&a===`&`&&e[i+1]===`&`?(t.push(r),r=``,i++):r+=a}return t.push(r),t}function W_(e,t){let n=e.substring(t).match(/^<<-?\s*['"]?([A-Za-z_][A-Za-z0-9_]*)['"]?/);if(!n)return-1;let r=n[1],i=t+n[0].length,a=e.substring(i),o=RegExp(`\\n\\s*`+r.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)+`\\s*(?=\\n|$)`),s=a.match(o);return s?i+s.index+s[0].length:-1}function G_(e){let t=Z(e||``).replace(/\/$/,``);if(!t)return``;let n=t.lastIndexOf(`/`);return n>0?t.substring(0,n):``}var K_=new Set([`du`,`df`,`stat`,`wc`,`file`,`cat`,`head`,`tail`,`grep`,`rg`]);function q_(e){if(!e||typeof e!=`string`)return!1;let t=U_(e);if(t.length===0)return!1;for(let e of t){let t=e.trim().split(/\s+/).filter(Boolean);for(;t.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(t[0]);)t.shift();if(!t.length)continue;let n=t[0].split(`/`).pop().toLowerCase();if(n===`sudo`&&t.length>1&&(n=t[1].split(`/`).pop().toLowerCase()),!K_.has(n))return!1}return!0}function J_(e,t){let n=t=>e===t||e.startsWith(t.endsWith(`/`)?t:t+`/`);return[...t].some(n)}function Y_(e,t){if(!e||typeof e!=`string`)return t||``;let n=t||``;for(let t of U_(e)){let e=t.trim().match(/^cd\s+(.+?)\s*$/);if(!e)continue;let r=e[1].trim().replace(/^['"]|['"]$/g,``);n=r.startsWith(`/`)||r.startsWith(`~/`)?r:r===`..`?n?Z(n).replace(/\/[^/]+$/,``)||`/`:`..`:Z(n?n.replace(/\/$/,``)+`/`+r:r)}return n}function X_(e,t){if(!e||typeof e!=`string`)return[];let n=[],r=t||``,i=U_(e);for(let e of i){let t=e.trim();if(!t)continue;let i=t.replace(/"[^"]*"/g,`""`).replace(/'[^']*'/g,`''`),a=t.match(/^cd\s+(.+?)\s*$/);if(a){let e=a[1].trim().replace(/^['"]|['"]$/g,``);r=e.startsWith(`/`)||e.startsWith(`~/`)?e:e===`..`?r?Z(r).replace(/\/[^/]+$/,``)||`/`:`..`:Z(r?r.replace(/\/$/,``)+`/`+e:e);continue}let o=e=>(e=e.replace(/^['"]|['"]$/g,``),!e.startsWith(`/`)&&!e.startsWith(`~/`)&&r&&(e=Z(r.replace(/\/$/,``)+`/`+e)),Z(e)),s=t.match(/^(\S+)\s+.*<<-?\s*['"]?([A-Za-z_][A-Za-z0-9_]*)['"]?\s*\n([\s\S]*?)\n\s*\2\s*$/);if(s){let e=s[1].split(`/`).pop().toLowerCase(),t=s[3],r=null;if(/^python[\d.]*$/.test(e)?r=`py`:/^(ba)?sh$/.test(e)&&(r=`sh`),r){for(let e of Z_(t,r))e&&n.push({path:o(e),isDir:!1});continue}}let c=i.match(/^mkdir\s+(?:-[a-z]+\s+)*(.+?)$/);if(c){let e=V_(z_(c[1],` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`-`)&&e!==`""`&&e!==`''`),o);for(let t of e)n.push({path:t,isDir:!0});continue}let l=i.match(/^touch\s+(.+)$/);if(l){let e=V_(z_(l[1],` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`-`)&&e!==`""`&&e!==`''`),o);for(let t of e)n.push({path:t,isDir:!1});continue}let u=null,d=i.match(/\s[>]{1,2}\s*['"]?([^\s|&;'"]+)['"]?\s*$/);if(d&&(u=d[1]),!u){let e=i.match(/^cat\s+>\s*['"]?([^\s|&;'"]+)['"]?/);e&&(u=e[1])}if(!u){let e=t.match(/^cp\s+(?:-[a-zA-Z]+\s+)*(?:.+?\s+)+?['"]?([^\s|&;'"]+)['"]?\s*$/);e&&(u=e[1])}if(!u){let e=i.match(/tee\s+(?:-[a-zA-Z]+\s+)*['"]?([^\s|&;'"]+)['"]?/);e&&(u=e[1])}if(u){let e=V_([u],o);for(let t of e)n.push({path:t,isDir:!1})}}return n}function Z_(e,t){if(!e||typeof e!=`string`)return[];let n=[],r=e.split(`
|
|
1185
|
-
`);if([`sh`,`bash`,`zsh`].includes(t))for(let e of r){let t=e.trim();if(!t||t.startsWith(`#`))continue;let r=[...t.matchAll(/[>]{1,2}\s*['"]?([^\s|&;>'"]+)['"]?/g)];for(let e of r)e[1]&&!e[1].startsWith(`/dev/`)&&n.push(e[1]);let i=t.match(/^mkdir\s+(?:-[a-z]+\s+)*(.+?)$/);if(i){let e=z_(i[1],` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`-`));n.push(...e)}let a=t.match(/^touch\s+(.+)$/);if(a){let e=z_(a[1],` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`-`));n.push(...e)}let o=t.match(/^cp\s+(?:-[a-zA-Z]+\s+)*(?:.+?\s+)+?['"]?([^\s|&;'"]+)['"]?\s*$/);o&&n.push(o[1]);let s=t.match(/tee\s+(?:-[a-zA-Z]+\s+)*['"]?([^\s|&;'"]+)['"]?/);s&&n.push(s[1])}else if(t===`bat`||t===`cmd`)for(let e of r){let t=e.trim().replace(/^@/,``);if(!t||(t.toUpperCase(),/^REM\b/i.test(t)||t.startsWith(`::`))||/^ECHO\b/i.test(t)&&!/[>]{1,2}/.test(t))continue;let r=[...t.matchAll(/[>]{1,2}\s*"?([^\s|&;>"]+)"?/g)];for(let e of r)e[1]&&e[1].toUpperCase()!==`NUL`&&n.push(e[1]);let i=t.match(/^(?:mkdir|md)\s+(?:"([^"]+)"|(\S+))/i);i&&n.push(i[1]||i[2]);let a=t.match(/^copy\s+(?:\/\S+\s+)*(?:.+?\s+)+?"?([^\s|&;"]+)"?\s*$/i);a&&n.push(a[1]);let o=t.match(/^xcopy\s+(?:\/\S+\s+)*(?:"[^"]+"|\S+)\s+(?:"([^"]+)"|(\S+))/i);o&&n.push(o[1]||o[2])}else if(t===`ps1`)for(let e of r){let t=e.trim();if(!t||t.startsWith(`#`))continue;let r=[...t.matchAll(/[>]{1,2}\s*"?([^\s|;>'"]+)"?/g)];for(let e of r)e[1]&&e[1].toUpperCase()!==`NUL`&&n.push(e[1]);let i=t.match(/(?:Set-Content|Out-File|Add-Content)\s+(?:-[\w]+\s+)*"?([^";\s|]+)"?/i);i&&n.push(i[1]);let a=t.match(/New-Item\s+(?:-[\w]+\s+)*-Path\s+"?([^";\s|]+)"?/i);a&&n.push(a[1]);let o=t.match(/New-Item\s+"?([^";\s|]+)"?\s+(?:-[\w]+\s+)*-ItemType/i);o&&n.push(o[1]);let s=t.match(/Copy-Item\s+(?:-[\w]+\s+)*"?([^";\s|]+)"?\s+(?:-[\w]+\s+)*-Destination\s+"?([^";\s|]+)"?/i);s&&n.push(s[2]);let c=t.match(/Move-Item\s+(?:-[\w]+\s+)*"?([^";\s|]+)"?\s+(?:-[\w]+\s+)*-Destination\s+"?([^";\s|]+)"?/i);c&&n.push(c[2])}else if(t===`py`)for(let e of r){let t=e.trim();if(!t||t.startsWith(`#`))continue;let r=t.match(/open\s*\(\s*['"]([^'"]+)['"]\s*,\s*['"][wax][+]?['"]/);r&&n.push(r[1]);let i=t.match(/os\.(?:makedirs|mkdir)\s*\(\s*['"]([^'"]+)['"]/);i&&n.push(i[1]);let a=t.match(/shutil\.(?:copy2?|move)\s*\([^,]+,\s*['"]([^'"]+)['"]/);a&&n.push(a[1]);let o=t.match(/Path\s*\(\s*['"]([^'"]+)['"]\s*\)\s*\.\s*(?:write_text|write_bytes|touch|mkdir)/);o&&n.push(o[1])}let i=new Set;return n.filter(e=>!e||i.has(e)||(i.add(e),/\$[\w({]|%[\w]+%/.test(e))?!1:e.includes(`/`)||e.includes(`\\`)||e.includes(`.`))}function Q_(e,t,n){if(!e||typeof e!=`string`||e.startsWith(`{`)||e.startsWith(`[`))return[];let r=e.split(/\s+/).filter(Boolean);if(r.length===0)return[];let i=new Set([`total`,`.`,`..`,`...`,`.git`,`.DS_Store`,`node_modules`,`__pycache__`,`.learnings`,`dist`,`.trae`]),a=r.some(e=>/^[d-][rwx-]{9}[@+*]?$/.test(e)),o=n?[...n.matchAll(/find\b[\s\S]*?-type\s+([df])/g)].map(e=>e[1]):[],s=o.length===1?o[0]:null,c=/[<>"'`|&;()[\]*?#!]/,l=new Map,u=(e,t)=>{!e||i.has(e)||/^\d+$/.test(e)||c.test(e)||(!l.has(e)||t)&&l.set(e,t)},d=e=>e.startsWith(`/`)?Z(e):Z((t?t.replace(/\/$/,``)+`/`:``)+e),f=e=>!(e.split(`/`).pop()||``).includes(`.`);if(r.some(e=>/^\.\/([^:]+):$/.test(e)&&e.length>3)){let e=new Set;for(let t of r){let n=t.match(/^\.\/([^:]+):$/);n&&n[1]&&e.add(n[1])}let t=null;for(let n of r){let r=n.match(/^\.\/([^:]+):$/);if(r&&r[1]){t=r[1],u(t,!0);continue}if(n.startsWith(`./`)){let t=n.slice(2);t&&!i.has(t)&&u(t,e.has(t)||f(t)&&s!==`f`);continue}if(!(i.has(n)||n.startsWith(`-`)||a||n.endsWith(`...`)))if(t===null)(n.includes(`.`)||e.has(n))&&u(n,e.has(n));else{if(n.includes(`/`)){u(n,e.has(n)||f(n));continue}let r=t+`/`+n;u(r,e.has(r)||f(r))}}}else for(let e of r){if(i.has(e)||e.startsWith(`-`)||e.startsWith(`=`)||e.endsWith(`...`)||e.includes(`:`)||e.includes(`=`)||/^\d+$/.test(e)||/^[\d.]+[KMGTPE]?B?$/i.test(e))continue;let t=null;if(e.startsWith(`./`)){if(e.length<=2)continue;t=e.slice(2)}else if(a)continue;else{if(!e.includes(`/`)&&!/^.+\.[a-zA-Z0-9]+$/.test(e))continue;t=e}!t||i.has(t)||u(t,f(t)&&s!==`f`)}let p=[];for(let[e,t]of l)p.push({path:d(e),isDir:t});return p}function $_(e){if(!e||typeof e!=`string`)return[];let t=[],n=/cat\s+>\s*['"]?(\S+)['"]?\s*<<-?\s*['"]?([A-Za-z_][A-Za-z0-9_]*)['"]?\s*\n([\s\S]*?)\n\s*\2\s*(?=\n|$)/g,r;for(;(r=n.exec(e))!==null;){let e=r[1],n=L_(e);[`sh`,`bash`,`zsh`,`bat`,`cmd`,`ps1`,`py`].includes(n)&&t.push({path:Z(e),content:r[3],ext:n})}return t}function ev(e,t){if(!e||typeof e!=`string`)return null;let n=e.trim();for(let e of t){let t=I_(e).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),r=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),i=e.replace(/\//g,`\\`).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);if(RegExp(`(?:^|[;\\s&|])(?:ba)?sh\\s+.*${t}|(?:^|[;\\s&|])python[23]?\\s+.*${t}|(?:^|[;\\s&|])node\\s+.*${t}|(?:^|[;\\s&|])\\.?/${t}|(?:^|[;\\s&|])cmd(?:\\.exe)?\\s+(?:/c|/k)\\s+.*${t}|(?:^|[;\\s&|])(?:powershell|pwsh)(?:\\.exe)?\\s+(?:-[\w-]+\\s+)*-File\\s+.*${t}|(?:^|[;\\s&|])${r}|(?:^|[;\\s&|])${i}`).test(n))return e}return null}function tv(e,t){if(!e||typeof e!=`string`)return[];let n=[],r=t||``,i=e=>(e=e.replace(/^['"]|['"]$/g,``),!e.startsWith(`/`)&&!e.startsWith(`~/`)&&!/^[A-Za-z]:[\\/]/.test(e)&&r&&(e=Z(r.replace(/\/$/,``)+`/`+e)),Z(e)),a=U_(e);for(let e of a){let t=e.trim();if(!t)continue;let a=t.match(/^cd\s+(?:\/[dD]\s+)?(.+?)\s*$/);if(a){let e=a[1].trim().replace(/^['"]|['"]$/g,``);r=e.startsWith(`/`)||/^[A-Za-z]:/.test(e)?Z(e):e.startsWith(`~/`)?e:e===`..`?r?Z(r).replace(/\/[^/]+$/,``)||`/`:`..`:Z(r?r.replace(/\/$/,``)+`/`+e:e);continue}let o=t.match(/^rm\s+((?:-[a-zA-Z]+\s+)*)(.+)$/);if(o){let e=o[1],t=o[2],r=/r|R/i.test(e),a=V_(z_(t,` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`-`)),i);for(let e of a)n.push({path:e,isDir:r});continue}let s=t.match(/^(?:del|erase)\s+((?:\/[a-zA-Z]+\s+)*)(.+)$/i);if(s){s[1];let e=s[2],t=V_(z_(e,` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`/`)),i);for(let e of t)n.push({path:e,isDir:!1});continue}let c=t.match(/^(?:rmdir|rd)\s+((?:\/[a-zA-Z]+\s+)*)(.+)$/i);if(c){let e=c[1],t=c[2],r=/s|S/i.test(e),a=V_(z_(t,` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`/`)),i);for(let e of a)n.push({path:e,isDir:r});continue}let l=t.match(/^Remove-Item\s+((?:-[\w-]+\s+)*(?:"[^"]+"|\S+)?(?:\s+(?:-[\w-]+\s+)*(?:"[^"]+"|\S+))*)/i);if(l){let e=l[1],t=/-Recurse/i.test(e),r=V_([...e.matchAll(/(?:"([^"]+)"|(?<![-\/])(\S+))/g)].map(e=>e[1]||e[2]).filter(e=>e&&!e.startsWith(`-`)),i);for(let e of r)n.push({path:e,isDir:t});continue}}return n}function nv(e){if(!Array.isArray(e)||e.length===0)return[];let t=[],n=new Set,r=[...e].sort((e,t)=>new Date(e.timestamp||0)-new Date(t.timestamp||0)),i=new Map;for(let e of r)if(!(e.nodeType!==`tool_exec`||e.status===`failed`)){if(e.action?.name===`agent_file`){let t=e.action.params;if(typeof t==`string`)try{t=JSON.parse(t)}catch{continue}if(!t||t.action!==`write`||typeof t.content!=`string`)continue;let n=Z(t.path||t.filePath||``),r=L_(n);[`sh`,`bash`,`zsh`,`bat`,`cmd`,`ps1`,`py`].includes(r)&&i.set(n,{content:t.content,ext:r})}else if(e.action?.name===`agent_exec`){let t=e.action.params,n=typeof t==`string`?t:t&&typeof t==`object`?t.command:null;if(typeof n==`string`)for(let e of $_(n))i.has(e.path)||i.set(e.path,{content:e.content,ext:e.ext})}}let a=[...i.keys()],o=new Map,s=(e,t)=>!t||e==null||t.timestamp==null?!0:new Date(t.timestamp||0).getTime()>=new Date(e||0).getTime(),c=new Set,l=!1;for(let e of r){if(e.nodeType!==`tool_exec`||!e.action)continue;let r=e.action.name||``,s=e.action.params;if(s==null)continue;if(typeof s==`string`)try{s=JSON.parse(s)}catch{continue}if(typeof s!=`object`)continue;if(r===`agent_exec`){let u=s.command||``;if(!u)continue;let d=ev(u,a);if(d&&e.status!==`failed`){let a=i.get(d);if(a){let i=Z_(a.content,a.ext);for(let a of i){if(!a)continue;let i=(a.startsWith(`/`),Z(a));if(n.has(i)){let e=t.findIndex(e=>e.path===i);e>=0&&t.splice(e,1)}n.add(i),t.push({path:i,fileName:I_(i),toolName:r,action:`typeCreate`,size:0,timestamp:e.timestamp||null,status:e.status||`unknown`,type:`file`})}}}if(e.status!==`failed`){let t=tv(u,s.cwd);for(let n of t)o.set(n.path,{isDir:n.isDir,timestamp:e.timestamp})}let f=X_(u,s.cwd);for(let e of f)if(e&&e.path){let t=e.isDir?e.path:G_(e.path);t&&c.add(t)}for(let i of f){let a=i&&i.path;if(a){if(n.has(a)){let e=t.findIndex(e=>e.path===a);e>=0&&t.splice(e,1)}n.add(a),e.status!==`failed`&&t.push({path:a,fileName:I_(a),toolName:r,action:`typeCreate`,size:0,timestamp:e.timestamp||null,status:e.status||`unknown`,type:i.isDir?`directory`:`file`})}}let p=f.length>0||!!d||/<<-?/.test(u);if(e.status!==`failed`&&typeof e.observation==`string`){let i=Y_(u,s.cwd);/\bcd\s/.test(u)&&i&&(p||l)&&c.add(Z(i));let a=Q_(e.observation,i,u);a.length>0&&!p&&(a=q_(u)?[]:a.filter(e=>J_(e.path,c)));for(let i of a){if(n.has(i.path)){let e=t.findIndex(e=>e.path===i.path);e>=0&&t.splice(e,1)}n.add(i.path),t.push({path:i.path,fileName:I_(i.path),toolName:r,action:`typeCreate`,size:0,timestamp:e.timestamp||null,status:e.status||`unknown`,type:i.isDir?`directory`:`file`})}}e.status!==`failed`&&p&&(l=!0);continue}let u=null,d=`typeOther`;if(r===`agent_file`){let t=s.action;if(t===`write`)u=s.path||s.filePath,d=`typeWrite`;else if(t===`delete`){let t=Z(s.path||s.filePath||``);t&&e.status!==`failed`&&o.set(t,{isDir:!1,timestamp:e.timestamp});continue}else continue}else if(r===`file_upload`)u=s.path||s.filePath||s.filename,d=`typeCreate`;else if(r===`download_file`)continue;else s.file_path&&(s.content!==void 0||s.action===`write`||s.action===`create`)&&(u=s.file_path,d=s.action===`create`?`typeCreate`:`typeWrite`);if(!u)continue;let f=Z(H_(e.observation)||u);if(!f)continue;if(n.has(f)){let e=t.findIndex(e=>e.path===f);e>=0&&t.splice(e,1)}if(n.add(f),e.status===`failed`)continue;let p=G_(f);p&&c.add(p),l=!0;let m=0;if(e.observation){let t=e.observation;if(typeof t==`string`)try{t=JSON.parse(t)}catch{}t&&typeof t==`object`&&(m=t.size||t.fileSize||t.file_size||0)}t.push({path:f,fileName:I_(f),toolName:r,action:d,size:m,timestamp:e.timestamp||null,status:e.status||`unknown`,type:`file`})}if(o.size>0){let e=[...o.keys()],n=(e,t)=>{if(e===t)return!0;let n=e.startsWith(`/`),r=t.startsWith(`/`);return n&&!r?e.endsWith(`/`+t)||e.endsWith(t):r&&!n?t.endsWith(`/`+e)||t.endsWith(e):!1};for(let r of t)r.deleted||(o.has(r.path)&&s(r.timestamp,o.get(r.path))||e.some(e=>{let t=o.get(e);return s(r.timestamp,t)?n(r.path,e)?!0:t&&t.isDir&&(r.path.startsWith(e+`/`)||r.path.startsWith(e+`\\`)):!1}))&&(r.deleted=!0)}return t.filter(e=>e&&e.fileName)}function rv(e){if(!e||typeof e!=`string`)return[];let t=[],n=new Set,r=/\[\[artifact:([^\]|]+)(?:\|([^\]]*))?\]\]/g,i;for(;(i=r.exec(e))!==null;){let e=(i[1]||``).trim(),r=(i[2]||``).trim();if(!e||/\$\{?[A-Za-z_][A-Za-z0-9_]*\}?|%[A-Za-z0-9_]+%/.test(e))continue;let a=iv(e);!a||n.has(a)||(n.add(a),t.push({path:e,note:r}))}return t}function iv(e){return Z(e).replace(/^\.\//,``)}function av(e,t){let n=(e||[]).map(e=>({...e,source:e.source||`static`})),r=n.map(e=>iv(e.path));for(let e of t||[]){let t=iv(e.path);if(!t)continue;let i=I_(e.path);if(!i)continue;let a=r.indexOf(t);if(a===-1&&(a=r.findIndex(e=>e.endsWith(`/`+t))),a!==-1){let t=n[a];t&&e.note&&!t.note&&(t.note=e.note);continue}r.push(t),n.push({path:e.path,fileName:i,toolName:`declared`,action:`typeCreate`,size:0,timestamp:null,status:`unknown`,type:`file`,source:`declared`,note:e.note||``})}return n}function ov(e,t){return av(nv(e),rv(t))}function sv(e){try{return $t(e)}catch{return!1}}var cv=null,lv=null,uv=null,dv=1;function fv(e){if(!e)return`—`;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function pv(e){if(!uv)return e;let t=dv;return[...e].sort((e,n)=>{let r,i;return uv===`name`?(r=(e.fileName||e.path||``).toLowerCase(),i=(n.fileName||n.path||``).toLowerCase()):uv===`type`?(r=e.type||`file`,i=n.type||`file`):(r=new Date(e.timestamp||0).getTime(),i=new Date(n.timestamp||0).getTime()),r<i?-t:r>i?t:0})}function mv(e,t){let n=an(e.fileName,e.type),i=r(`artifacts.${e.action}`),a=fv(e.timestamp),o=sv(e.fileName),s=`${R_(e.path)} · ${r(`artifacts.dblClickHint`)}`;return`
|
|
1186
|
-
<tr class="artifacts-row" data-idx="${t}" data-path="${R_(e.path)}" data-name="${R_(e.fileName)}">
|
|
1189
|
+
${t?a:``}${n?o:``}
|
|
1190
|
+
${i?`<button class="switch-workdir-remove" data-remove-path="${X(e)}" title="${r(`workspace.removeFromAllowed`)}" style="flex-shrink:0;background:none;border:none;color:var(--danger-500);cursor:pointer;font-size:16px;line-height:1;padding:2px 6px;border-radius:4px;">×</button>`:``}
|
|
1191
|
+
</div>`}).join(``)}C(),b&&b.addEventListener(`change`,()=>{a.querySelectorAll(`.switch-workdir-item.current`).forEach(e=>{e.style.cursor=T(e.dataset.path)?`pointer`:`default`})});async function w(e){let t=d(e,l)||d(e,c);if(!await window.showCustomConfirm(r(t?`workspace.confirmRemoveStillUsable`:`workspace.confirmRemovePath`,{path:e}),r(`workspace.confirmRemovePathTitle`)))return;let n=await xn(e);n.success?(u=Array.isArray(n.allowedPaths)?n.allowedPaths:u.filter(t=>t!==e),C(),P(r(t?`workspace.removedStillUsable`:`workspace.removedFromAllowed`),`success`)):P(r(`workspace.removeFailedWithError`,{error:n.error||r(`workspace.unknownError`)}),`error`)}let T=e=>{if(!(b&&b.checked))return!1;let t=e=>String(e||``).replace(/\\/g,`/`).toLowerCase();return!l||t(e)!==t(l)};a.addEventListener(`click`,e=>{let t=e.target.closest(`.switch-workdir-remove`);if(t){e.stopPropagation(),w(t.dataset.removePath);return}let n=e.target.closest(`.switch-workdir-item`);n&&(n.classList.contains(`current`)&&!T(n.dataset.path)||E(n.dataset.path))});async function E(n){if(!n){P(r(`workspace.selectOrInputPath`),`error`);return}n=n.trim();let a=e=>e.replace(/\\/g,`/`).toLowerCase(),o=(e,t)=>!!e&&!!t&&a(e)===a(t),s=!!(b&&b.checked);if(o(n,c)){if(s&&!o(n,l)){S(),e(await D_(n));return}P(r(`workspace.alreadyCurrentWorkdir`),`info`),S(),e(!1);return}let d=i?t:null,f=!d||s;!u.some(e=>{let t=a(n),r=a(e);return t===r||t.startsWith(r+`/`)})&&f&&!await window.showCustomConfirm(r(`workspace.confirmSwitchToNewDefault`,{path:n}),r(`workspace.confirmSwitchToNewTitle`))||(S(),e(await O_(n,{sessionId:d,setAsDefault:s})))}y&&y.addEventListener(`click`,async()=>{y.disabled=!0,S(),e(await k_(t,{sessionSupported:i}))}),g.addEventListener(`click`,()=>E(m.value)),h.addEventListener(`click`,()=>{S(),e(!1)}),_.addEventListener(`click`,()=>{S(),e(!1)}),_.addEventListener(`mouseenter`,()=>{_.style.color=`var(--text-primary)`,_.style.background=`var(--border-subtle)`}),_.addEventListener(`mouseleave`,()=>{_.style.color=`var(--text-tertiary)`,_.style.background=`transparent`}),m.addEventListener(`keydown`,t=>{t.key===`Enter`&&(t.preventDefault(),E(m.value)),t.key===`Escape`&&(S(),e(!1))}),n.addEventListener(`click`,e=>{e.target===n&&e.stopPropagation()}),setTimeout(()=>m.focus(),50)})}function S_(){Ep=null,q=null,Dp=[],J.clear(),a_=``,o_=[],s_=!1,ym.clear();let e=document.getElementById(`workspaceSearchInput`);e&&(e.value=``);let t=document.getElementById(`workspaceSearchClear`);t&&(t.style.display=`none`);let n=document.getElementById(`workspaceToolbar`);if(n){n.classList.remove(`search-focused`);let e=n.querySelector(`.workspace-search-box`);e&&e.classList.remove(`search-box-expanded`)}}var C_=0;async function w_(){let e=++C_;if(N.agentPlatform?.connected!==!0){Yt(),S_();return}await Rg();let t=Ep;Yt();let n=null;try{n=await sn()}catch(e){a.warn(`[WorkspacePanel] resolve root for session failed:`,e?.message||e)}if(e!==C_||t&&n&&t===n)return;S_();let r=document.getElementById(`workspacePreviewArea`);if(r&&r.dataset.previewPath&&(Gp=!1,await mg(!0)),await Promise.resolve(),e!==C_)return;let i=document.getElementById(`workspacePanel`);!i||!i.classList.contains(`expanded`)||await _m()}async function T_(e,t){document.dispatchEvent(new CustomEvent(`session-workdir-changed`,{detail:{sessionId:e,workdir:t}}))}async function E_(e){N.defaultWorkdir=e,N.agentPlatform&&={...N.agentPlatform,workdir:e};try{let{activeAgentId:t}=await chrome.storage.local.get([`activeAgentId`]);t&&(N.agentWorkdirs.set(t,e),typeof window.updateAgentItemWorkdir==`function`&&window.updateAgentItemWorkdir(t,e))}catch(e){a.debug(`[WorkspacePanel] sync dropdown column table workdir failed:`,e)}}async function D_(e){let t=await Xt(e,{sessionId:null});return t.success?(await E_(t.workdir),await T_(null,t.workdir),P(r(`workspace.setAsDefaultDone`,{path:t.workdir}),`success`),!0):(P(r(`workspace.switchFailedWithError`,{error:t.error||r(`workspace.unknownError`)}),`error`),!1)}async function O_(e,t={}){let n=t.sessionId===void 0?N.activeSessionId||null:t.sessionId,i=t.setAsDefault===!0,o=await Xt(e,{sessionId:n});if(!o.success)return P(r(`workspace.switchFailedWithError`,{error:o.error||r(`workspace.unknownError`)}),`error`),!1;if(n)try{let{setSessionWorkdirBinding:e}=await M(async()=>{let{setSessionWorkdirBinding:e}=await import(`./session-store-CgGSFTQs.js`).then(e=>e.m);return{setSessionWorkdirBinding:e}},__vite__mapDeps([2,1,3,4])),t=(await un())?.id||null;await e(n,o.workdir,t)}catch(e){a.warn(`[WorkspacePanel] persist session workdir failed:`,e)}let s=!1;if(i){let e=await Xt(o.workdir,{sessionId:null});e.success?s=!0:P(r(`workspace.switchFailedWithError`,{error:e.error||r(`workspace.unknownError`)}),`error`)}return(!n||i)&&await E_(o.workdir),await T_(n,o.workdir),P(r(s?`workspace.switchedToAndSetDefault`:`workspace.switchedTo`,{path:o.workdir}),`success`),!0}async function k_(e,t={}){if(!e)return!1;let{unbindSessionWorkdirRemote:n}=await M(async()=>{let{unbindSessionWorkdirRemote:e}=await import(`./session-store-CgGSFTQs.js`).then(e=>e.at);return{unbindSessionWorkdirRemote:e}},__vite__mapDeps([2,1,3,4]));if(await n(e)===null&&t.sessionSupported)return P(r(`workspace.switchFailedWithError`,{error:r(`workspace.unknownError`)}),`error`),!1;try{let{setSessionWorkdirBinding:t}=await M(async()=>{let{setSessionWorkdirBinding:e}=await import(`./session-store-CgGSFTQs.js`).then(e=>e.m);return{setSessionWorkdirBinding:e}},__vite__mapDeps([2,1,3,4]));await t(e,null,null)}catch(e){a.warn(`[WorkspacePanel] clear session workdir failed:`,e)}return await T_(e,``),P(r(`workdirTag.restoredDefault`),`success`),!0}async function A_(e,t,n){let i=t,a=``,o=t.lastIndexOf(`.`);n!==`directory`&&o>0&&(i=t.substring(0,o),a=t.substring(o));let s=await y_(r(n===`directory`?`workspace.renameDir`:`workspace.renameFile`),i,r(`workspace.inputNewName`));if(!s||s===i)return;let c=s+a;try{let t=await Qt(e,c);t.success?(P(r(`workspace.renamedTo`,{name:c}),`success`),Em(q),await Vg(),F_(c)):P(r(`workspace.renameFailedWithError`,{error:t.error}),`error`)}catch(e){P(r(`workspace.renameFailedWithError`,{error:e.message}),`error`)}}async function j_(){if(!q)return;let e=await y_(r(`workspace.newFolderTitle`),``,r(`workspace.inputFolderName`));if(!e)return;let t=Tm(`${q}/${e}`);try{let n=await fn(t);n.success?(P(r(`workspace.folderCreated`,{name:e}),`success`),Em(q),await Vg(),F_(e)):P(r(`workspace.createFailedWithError`,{error:n.error}),`error`)}catch(e){P(r(`workspace.createFailedWithError`,{error:e.message}),`error`)}}async function M_(e){return new Promise((t,n)=>{let i=new Image,a=URL.createObjectURL(e);i.onload=()=>{URL.revokeObjectURL(a);let n=new FileReader;n.onloadend=()=>{let e=n.result,r=i.width,a=i.height,o=Math.max(r,a),s,c;o<=768?(s=o,c=.75):o<=1280?(s=768,c=.7):o<=2560?(s=1024,c=.65):o<=3840?(s=1280,c=.6):(s=1280,c=.55);let l=r,u=a;o>s&&(r>a?(u=Math.round(s/r*a),l=s):(l=Math.round(s/a*r),u=s));let d=document.createElement(`canvas`);d.width=l,d.height=u;let f=d.getContext(`2d`);f.imageSmoothingEnabled=!0,f.imageSmoothingQuality=`high`,f.drawImage(i,0,0,l,u),t({originalUrl:e,compressedUrl:d.toDataURL(`image/jpeg`,c)})},n.readAsDataURL(e)},i.onerror=()=>{URL.revokeObjectURL(a),n(Error(r(`workspace.imageLoadFailed`)))},i.src=a})}async function N_(e){let t=[],n=[];for(let r of e){let e=r&&typeof r==`object`,i=e?r.fullPath||r.path:r,a=i.split(/[\\/]/).pop(),o;e?o=r:(o=Xp.find(e=>e.path===i),o||=o_.find(e=>e.fullPath===i));let s=o?o.size:0,c=dn(a);if(c.startsWith(`image/`)&&N.enableImageInput)n.push({name:a,size:s,type:c,path:i});else{let e={name:a,size:s,type:c,text:``,status:`done`,agentPath:i};t.push(e)}}for(let e of n)try{let t=await un();if(t){let n=await fetch(`${t.url}/api/fs/download-stream`,{method:`POST`,headers:{"Content-Type":`application/json`,..._n(t)},body:JSON.stringify({path:e.path})});if(n.ok){let{originalUrl:e,compressedUrl:t}=await M_(await n.blob());N.attachedImages.some(e=>e.compressedUrl===t)||N.attachedImages.push({originalUrl:e,compressedUrl:t})}}}catch{}for(let e of t)N.attachedFiles.some(t=>t.name===e.name&&t.agentPath===e.agentPath)||N.attachedFiles.push(e);$f(),bp();let i=t.length+n.length;i>0&&(!N.enableImageInput&&t.some(e=>e.type?.startsWith(`image/`))?P(r(`workspace.addedFilesToQuestionNoImage`,{count:i}),`success`):P(r(`workspace.addedFilesToQuestion`,{count:i}),`success`))}async function P_(){J.size!==0&&await N_(Array.from(J))}function F_(e,t=0){let n=document.getElementById(`workspacePanelContent`);if(!n)return;if(Am){let t=Am.sorted.findIndex(t=>t.name===e);if(t>=0){let r=Am.itemHeight;n.scrollTop=Math.max(0,t*r-n.clientHeight/2+r/2),Nm();let i=Array.from(n.querySelectorAll(`.workspace-file-item`)).find(t=>t.dataset.name===e);i&&(i.classList.add(`highlight-new`),setTimeout(()=>i.classList.remove(`highlight-new`),2e3));return}}let r=Array.from(n.querySelectorAll(`.workspace-file-item`)).find(t=>t.dataset.name===e);r?(r.scrollIntoView({behavior:`smooth`,block:`center`}),r.classList.add(`highlight-new`),setTimeout(()=>r.classList.remove(`highlight-new`),2e3)):t<5&&setTimeout(()=>F_(e,t+1),150)}function I_(){let e=document.getElementById(`workspaceAskBtn`);J.size===0?e.style.display=`none`:e.style.display=``}function L_(){let e=document.getElementById(`workspaceDownloadDirBtn`),t=document.getElementById(`workspaceBatchDeleteBtn`),n=document.getElementById(`workspaceSelectedCount`);J.size===0?(e.style.display=`none`,t.style.display=`none`,n.style.display=`none`):(e.style.display=``,t.style.display=``,n.style.display=``,n.textContent=r(`workspace.selectedCount`,{count:J.size}),e.disabled=Hp),I_()}n(`zh`,{artifacts:{btnTitle:`文件产物({count})`,modalTitle:`本次任务的文件产物`,emptyHint:`本次任务没有产生文件产物`,fileCol:`文件`,sizeCol:`大小`,typeCol:`类型`,timeCol:`时间`,actionCol:`操作`,locate:`定位到文件`,preview:`预览`,closeBtn:`关闭`,typeWrite:`写入`,typeDelete:`删除`,typeCreate:`创建`,typeEdit:`编辑`,typeOther:`操作`,noWorkspace:`无法获取工作目录,请确认 Agent 已连接`,locateFailed:`定位文件失败`,fileNotFound:`目录已定位,但未找到该文件(可能已被删除)`,previewFailed:`预览文件失败`,previewNotSupported:`此文件类型不支持预览`,totalCount:`共 {count} 个文件`,badgeLabel:`产物`,download:`下载`,downloadFailed:`下载失败`,copyFileName:`复制文件名`,copyFilePath:`复制文件路径`,copiedName:`已复制文件名:{name}`,copiedPath:`已复制文件路径`,dblClickHint:`双击文件名可预览`,sortHint:`点击排序`,serialCol:`序号`}}),n(`en`,{artifacts:{btnTitle:`Artifacts ({count})`,modalTitle:`File Artifacts of This Task`,emptyHint:`No file artifacts produced in this task`,fileCol:`File`,sizeCol:`Size`,typeCol:`Type`,timeCol:`Time`,actionCol:`Actions`,locate:`Locate File`,preview:`Preview`,closeBtn:`Close`,typeWrite:`Write`,typeDelete:`Delete`,typeCreate:`Create`,typeEdit:`Edit`,typeOther:`Op`,noWorkspace:`Unable to access working directory. Please confirm the Agent is connected.`,locateFailed:`Failed to locate file`,fileNotFound:`Directory located, but file not found (may have been deleted)`,previewFailed:`Failed to preview file`,previewNotSupported:`Preview not supported for this file type`,totalCount:`{count} files in total`,badgeLabel:`Artifacts`,download:`Download`,downloadFailed:`Download failed`,copyFileName:`Copy File Name`,copyFilePath:`Copy File Path`,copiedName:`Copied file name: {name}`,copiedPath:`File path copied`,dblClickHint:`Double-click to preview`,sortHint:`Click to sort`,serialCol:`#`}});function Z(e){let t=(e||``).replace(/\\/g,`/`).replace(/\/+/g,`/`),n=t.replace(/\/+$/,``);return n?/^[A-Za-z]:$/.test(n)?n+`/`:n:t?`/`:``}function R_(e){if(!e)return``;let t=Z(e).replace(/\/+$/,``).split(`/`);return t[t.length-1]||``}function z_(e){if(!e)return``;let t=R_(e),n=t.lastIndexOf(`.`);return n>0?t.substring(n+1).toLowerCase():``}function B_(e){return String(e??``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function V_(e,t){let n=new Set(t),r=[],i=0,a=``;for(let t of e)t===`{`?i++:t===`}`&&(i=Math.max(0,i-1)),i===0&&n.has(t)?(r.push(a),a=``):a+=t;return r.push(a),r}function H_(e){let t=e.indexOf(`{`);if(t===-1)return[e];let n=0,r=-1;for(let i=t;i<e.length;i++)if(e[i]===`{`)n++;else if(e[i]===`}`&&(n--,n===0)){r=i;break}if(r===-1)return[e];let i=e.substring(0,t),a=e.substring(t+1,r),o=e.substring(r+1),s=V_(a,`,`).map(e=>e.trim());if(s.length<=1)return[e];let c=[];for(let e of s)for(let t of H_(e))for(let e of H_(o))c.push(i+t+e);return c}function U_(e,t){let n=[],r=new Set;for(let i of e)if(i)for(let e of H_(i)){if(!e)continue;let i=t(e);!i||r.has(i)||(r.add(i),n.push(i))}return n}function W_(e){if(!e)return null;let t=e;if(typeof t==`string`)try{t=JSON.parse(t)}catch{let e=t.match(/["']?path["']?\s*[:=]\s*["']([^"']+)["']/i);return e?e[1]:null}return t&&typeof t==`object`&&(t.path||t.filePath||t.file_path||t.result?.path)||null}function G_(e){let t=[],n=0,r=``;for(let i=0;i<e.length;i++){let a=e[i];if(a===`{`?n++:a===`}`&&(n=Math.max(0,n-1)),n===0&&a===`<`&&e[i+1]===`<`){let t=K_(e,i);if(t>i){r+=e.substring(i,t),i=t-1;continue}}n===0&&a===`;`?(t.push(r),r=``):n===0&&a===`&`&&e[i+1]===`&`?(t.push(r),r=``,i++):r+=a}return t.push(r),t}function K_(e,t){let n=e.substring(t).match(/^<<-?\s*['"]?([A-Za-z_][A-Za-z0-9_]*)['"]?/);if(!n)return-1;let r=n[1],i=t+n[0].length,a=e.substring(i),o=RegExp(`\\n\\s*`+r.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)+`\\s*(?=\\n|$)`),s=a.match(o);return s?i+s.index+s[0].length:-1}function q_(e){let t=Z(e||``).replace(/\/$/,``);if(!t)return``;let n=t.lastIndexOf(`/`);return n>0?t.substring(0,n):``}var J_=new Set([`du`,`df`,`stat`,`wc`,`file`,`cat`,`head`,`tail`,`grep`,`rg`]);function Y_(e){if(!e||typeof e!=`string`)return!1;let t=G_(e);if(t.length===0)return!1;for(let e of t){let t=e.trim().split(/\s+/).filter(Boolean);for(;t.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(t[0]);)t.shift();if(!t.length)continue;let n=t[0].split(`/`).pop().toLowerCase();if(n===`sudo`&&t.length>1&&(n=t[1].split(`/`).pop().toLowerCase()),!J_.has(n))return!1}return!0}function X_(e,t){let n=t=>e===t||e.startsWith(t.endsWith(`/`)?t:t+`/`);return[...t].some(n)}function Z_(e,t){if(!e||typeof e!=`string`)return t||``;let n=t||``;for(let t of G_(e)){let e=t.trim().match(/^cd\s+(.+?)\s*$/);if(!e)continue;let r=e[1].trim().replace(/^['"]|['"]$/g,``);n=r.startsWith(`/`)||r.startsWith(`~/`)?r:r===`..`?n?Z(n).replace(/\/[^/]+$/,``)||`/`:`..`:Z(n?n.replace(/\/$/,``)+`/`+r:r)}return n}function Q_(e,t){if(!e||typeof e!=`string`)return[];let n=[],r=t||``,i=G_(e);for(let e of i){let t=e.trim();if(!t)continue;let i=t.replace(/"[^"]*"/g,`""`).replace(/'[^']*'/g,`''`),a=t.match(/^cd\s+(.+?)\s*$/);if(a){let e=a[1].trim().replace(/^['"]|['"]$/g,``);r=e.startsWith(`/`)||e.startsWith(`~/`)?e:e===`..`?r?Z(r).replace(/\/[^/]+$/,``)||`/`:`..`:Z(r?r.replace(/\/$/,``)+`/`+e:e);continue}let o=e=>(e=e.replace(/^['"]|['"]$/g,``),!e.startsWith(`/`)&&!e.startsWith(`~/`)&&r&&(e=Z(r.replace(/\/$/,``)+`/`+e)),Z(e)),s=t.match(/^(\S+)\s+.*<<-?\s*['"]?([A-Za-z_][A-Za-z0-9_]*)['"]?\s*\n([\s\S]*?)\n\s*\2\s*$/);if(s){let e=s[1].split(`/`).pop().toLowerCase(),t=s[3],r=null;if(/^python[\d.]*$/.test(e)?r=`py`:/^(ba)?sh$/.test(e)&&(r=`sh`),r){for(let e of $_(t,r))e&&n.push({path:o(e),isDir:!1});continue}}let c=i.match(/^mkdir\s+(?:-[a-z]+\s+)*(.+?)$/);if(c){let e=U_(V_(c[1],` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`-`)&&e!==`""`&&e!==`''`),o);for(let t of e)n.push({path:t,isDir:!0});continue}let l=i.match(/^touch\s+(.+)$/);if(l){let e=U_(V_(l[1],` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`-`)&&e!==`""`&&e!==`''`),o);for(let t of e)n.push({path:t,isDir:!1});continue}let u=null,d=i.match(/\s[>]{1,2}\s*['"]?([^\s|&;'"]+)['"]?\s*$/);if(d&&(u=d[1]),!u){let e=i.match(/^cat\s+>\s*['"]?([^\s|&;'"]+)['"]?/);e&&(u=e[1])}if(!u){let e=t.match(/^cp\s+(?:-[a-zA-Z]+\s+)*(?:.+?\s+)+?['"]?([^\s|&;'"]+)['"]?\s*$/);e&&(u=e[1])}if(!u){let e=i.match(/tee\s+(?:-[a-zA-Z]+\s+)*['"]?([^\s|&;'"]+)['"]?/);e&&(u=e[1])}if(u){let e=U_([u],o);for(let t of e)n.push({path:t,isDir:!1})}}return n}function $_(e,t){if(!e||typeof e!=`string`)return[];let n=[],r=e.split(`
|
|
1192
|
+
`);if([`sh`,`bash`,`zsh`].includes(t))for(let e of r){let t=e.trim();if(!t||t.startsWith(`#`))continue;let r=[...t.matchAll(/[>]{1,2}\s*['"]?([^\s|&;>'"]+)['"]?/g)];for(let e of r)e[1]&&!e[1].startsWith(`/dev/`)&&n.push(e[1]);let i=t.match(/^mkdir\s+(?:-[a-z]+\s+)*(.+?)$/);if(i){let e=V_(i[1],` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`-`));n.push(...e)}let a=t.match(/^touch\s+(.+)$/);if(a){let e=V_(a[1],` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`-`));n.push(...e)}let o=t.match(/^cp\s+(?:-[a-zA-Z]+\s+)*(?:.+?\s+)+?['"]?([^\s|&;'"]+)['"]?\s*$/);o&&n.push(o[1]);let s=t.match(/tee\s+(?:-[a-zA-Z]+\s+)*['"]?([^\s|&;'"]+)['"]?/);s&&n.push(s[1])}else if(t===`bat`||t===`cmd`)for(let e of r){let t=e.trim().replace(/^@/,``);if(!t||(t.toUpperCase(),/^REM\b/i.test(t)||t.startsWith(`::`))||/^ECHO\b/i.test(t)&&!/[>]{1,2}/.test(t))continue;let r=[...t.matchAll(/[>]{1,2}\s*"?([^\s|&;>"]+)"?/g)];for(let e of r)e[1]&&e[1].toUpperCase()!==`NUL`&&n.push(e[1]);let i=t.match(/^(?:mkdir|md)\s+(?:"([^"]+)"|(\S+))/i);i&&n.push(i[1]||i[2]);let a=t.match(/^copy\s+(?:\/\S+\s+)*(?:.+?\s+)+?"?([^\s|&;"]+)"?\s*$/i);a&&n.push(a[1]);let o=t.match(/^xcopy\s+(?:\/\S+\s+)*(?:"[^"]+"|\S+)\s+(?:"([^"]+)"|(\S+))/i);o&&n.push(o[1]||o[2])}else if(t===`ps1`)for(let e of r){let t=e.trim();if(!t||t.startsWith(`#`))continue;let r=[...t.matchAll(/[>]{1,2}\s*"?([^\s|;>'"]+)"?/g)];for(let e of r)e[1]&&e[1].toUpperCase()!==`NUL`&&n.push(e[1]);let i=t.match(/(?:Set-Content|Out-File|Add-Content)\s+(?:-[\w]+\s+)*"?([^";\s|]+)"?/i);i&&n.push(i[1]);let a=t.match(/New-Item\s+(?:-[\w]+\s+)*-Path\s+"?([^";\s|]+)"?/i);a&&n.push(a[1]);let o=t.match(/New-Item\s+"?([^";\s|]+)"?\s+(?:-[\w]+\s+)*-ItemType/i);o&&n.push(o[1]);let s=t.match(/Copy-Item\s+(?:-[\w]+\s+)*"?([^";\s|]+)"?\s+(?:-[\w]+\s+)*-Destination\s+"?([^";\s|]+)"?/i);s&&n.push(s[2]);let c=t.match(/Move-Item\s+(?:-[\w]+\s+)*"?([^";\s|]+)"?\s+(?:-[\w]+\s+)*-Destination\s+"?([^";\s|]+)"?/i);c&&n.push(c[2])}else if(t===`py`)for(let e of r){let t=e.trim();if(!t||t.startsWith(`#`))continue;let r=t.match(/open\s*\(\s*['"]([^'"]+)['"]\s*,\s*['"][wax][+]?['"]/);r&&n.push(r[1]);let i=t.match(/os\.(?:makedirs|mkdir)\s*\(\s*['"]([^'"]+)['"]/);i&&n.push(i[1]);let a=t.match(/shutil\.(?:copy2?|move)\s*\([^,]+,\s*['"]([^'"]+)['"]/);a&&n.push(a[1]);let o=t.match(/Path\s*\(\s*['"]([^'"]+)['"]\s*\)\s*\.\s*(?:write_text|write_bytes|touch|mkdir)/);o&&n.push(o[1])}let i=new Set;return n.filter(e=>!e||i.has(e)||(i.add(e),/\$[\w({]|%[\w]+%/.test(e))?!1:e.includes(`/`)||e.includes(`\\`)||e.includes(`.`))}function ev(e,t,n){if(!e||typeof e!=`string`||e.startsWith(`{`)||e.startsWith(`[`))return[];let r=e.split(/\s+/).filter(Boolean);if(r.length===0)return[];let i=new Set([`total`,`.`,`..`,`...`,`.git`,`.DS_Store`,`node_modules`,`__pycache__`,`.learnings`,`dist`,`.trae`]),a=r.some(e=>/^[d-][rwx-]{9}[@+*]?$/.test(e)),o=n?[...n.matchAll(/find\b[\s\S]*?-type\s+([df])/g)].map(e=>e[1]):[],s=o.length===1?o[0]:null,c=/[<>"'`|&;()[\]*?#!]/,l=new Map,u=(e,t)=>{!e||i.has(e)||/^\d+$/.test(e)||c.test(e)||(!l.has(e)||t)&&l.set(e,t)},d=e=>e.startsWith(`/`)?Z(e):Z((t?t.replace(/\/$/,``)+`/`:``)+e),f=e=>!(e.split(`/`).pop()||``).includes(`.`);if(r.some(e=>/^\.\/([^:]+):$/.test(e)&&e.length>3)){let e=new Set;for(let t of r){let n=t.match(/^\.\/([^:]+):$/);n&&n[1]&&e.add(n[1])}let t=null;for(let n of r){let r=n.match(/^\.\/([^:]+):$/);if(r&&r[1]){t=r[1],u(t,!0);continue}if(n.startsWith(`./`)){let t=n.slice(2);t&&!i.has(t)&&u(t,e.has(t)||f(t)&&s!==`f`);continue}if(!(i.has(n)||n.startsWith(`-`)||a||n.endsWith(`...`)))if(t===null)(n.includes(`.`)||e.has(n))&&u(n,e.has(n));else{if(n.includes(`/`)){u(n,e.has(n)||f(n));continue}let r=t+`/`+n;u(r,e.has(r)||f(r))}}}else for(let e of r){if(i.has(e)||e.startsWith(`-`)||e.startsWith(`=`)||e.endsWith(`...`)||e.includes(`:`)||e.includes(`=`)||/^\d+$/.test(e)||/^[\d.]+[KMGTPE]?B?$/i.test(e))continue;let t=null;if(e.startsWith(`./`)){if(e.length<=2)continue;t=e.slice(2)}else if(a)continue;else{if(!e.includes(`/`)&&!/^.+\.[a-zA-Z0-9]+$/.test(e))continue;t=e}!t||i.has(t)||u(t,f(t)&&s!==`f`)}let p=[];for(let[e,t]of l)p.push({path:d(e),isDir:t});return p}function tv(e){if(!e||typeof e!=`string`)return[];let t=[],n=/cat\s+>\s*['"]?(\S+)['"]?\s*<<-?\s*['"]?([A-Za-z_][A-Za-z0-9_]*)['"]?\s*\n([\s\S]*?)\n\s*\2\s*(?=\n|$)/g,r;for(;(r=n.exec(e))!==null;){let e=r[1],n=z_(e);[`sh`,`bash`,`zsh`,`bat`,`cmd`,`ps1`,`py`].includes(n)&&t.push({path:Z(e),content:r[3],ext:n})}return t}function nv(e,t){if(!e||typeof e!=`string`)return null;let n=e.trim();for(let e of t){let t=R_(e).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),r=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),i=e.replace(/\//g,`\\`).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);if(RegExp(`(?:^|[;\\s&|])(?:ba)?sh\\s+.*${t}|(?:^|[;\\s&|])python[23]?\\s+.*${t}|(?:^|[;\\s&|])node\\s+.*${t}|(?:^|[;\\s&|])\\.?/${t}|(?:^|[;\\s&|])cmd(?:\\.exe)?\\s+(?:/c|/k)\\s+.*${t}|(?:^|[;\\s&|])(?:powershell|pwsh)(?:\\.exe)?\\s+(?:-[\w-]+\\s+)*-File\\s+.*${t}|(?:^|[;\\s&|])${r}|(?:^|[;\\s&|])${i}`).test(n))return e}return null}function rv(e,t){if(!e||typeof e!=`string`)return[];let n=[],r=t||``,i=e=>(e=e.replace(/^['"]|['"]$/g,``),!e.startsWith(`/`)&&!e.startsWith(`~/`)&&!/^[A-Za-z]:[\\/]/.test(e)&&r&&(e=Z(r.replace(/\/$/,``)+`/`+e)),Z(e)),a=G_(e);for(let e of a){let t=e.trim();if(!t)continue;let a=t.match(/^cd\s+(?:\/[dD]\s+)?(.+?)\s*$/);if(a){let e=a[1].trim().replace(/^['"]|['"]$/g,``);r=e.startsWith(`/`)||/^[A-Za-z]:/.test(e)?Z(e):e.startsWith(`~/`)?e:e===`..`?r?Z(r).replace(/\/[^/]+$/,``)||`/`:`..`:Z(r?r.replace(/\/$/,``)+`/`+e:e);continue}let o=t.match(/^rm\s+((?:-[a-zA-Z]+\s+)*)(.+)$/);if(o){let e=o[1],t=o[2],r=/r|R/i.test(e),a=U_(V_(t,` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`-`)),i);for(let e of a)n.push({path:e,isDir:r});continue}let s=t.match(/^(?:del|erase)\s+((?:\/[a-zA-Z]+\s+)*)(.+)$/i);if(s){s[1];let e=s[2],t=U_(V_(e,` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`/`)),i);for(let e of t)n.push({path:e,isDir:!1});continue}let c=t.match(/^(?:rmdir|rd)\s+((?:\/[a-zA-Z]+\s+)*)(.+)$/i);if(c){let e=c[1],t=c[2],r=/s|S/i.test(e),a=U_(V_(t,` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`/`)),i);for(let e of a)n.push({path:e,isDir:r});continue}let l=t.match(/^Remove-Item\s+((?:-[\w-]+\s+)*(?:"[^"]+"|\S+)?(?:\s+(?:-[\w-]+\s+)*(?:"[^"]+"|\S+))*)/i);if(l){let e=l[1],t=/-Recurse/i.test(e),r=U_([...e.matchAll(/(?:"([^"]+)"|(?<![-\/])(\S+))/g)].map(e=>e[1]||e[2]).filter(e=>e&&!e.startsWith(`-`)),i);for(let e of r)n.push({path:e,isDir:t});continue}}return n}function iv(e){if(!Array.isArray(e)||e.length===0)return[];let t=[],n=new Set,r=[...e].sort((e,t)=>new Date(e.timestamp||0)-new Date(t.timestamp||0)),i=new Map;for(let e of r)if(!(e.nodeType!==`tool_exec`||e.status===`failed`)){if(e.action?.name===`agent_file`){let t=e.action.params;if(typeof t==`string`)try{t=JSON.parse(t)}catch{continue}if(!t||t.action!==`write`||typeof t.content!=`string`)continue;let n=Z(t.path||t.filePath||``),r=z_(n);[`sh`,`bash`,`zsh`,`bat`,`cmd`,`ps1`,`py`].includes(r)&&i.set(n,{content:t.content,ext:r})}else if(e.action?.name===`agent_exec`){let t=e.action.params,n=typeof t==`string`?t:t&&typeof t==`object`?t.command:null;if(typeof n==`string`)for(let e of tv(n))i.has(e.path)||i.set(e.path,{content:e.content,ext:e.ext})}}let a=[...i.keys()],o=new Map,s=(e,t)=>!t||e==null||t.timestamp==null?!0:new Date(t.timestamp||0).getTime()>=new Date(e||0).getTime(),c=new Set,l=!1;for(let e of r){if(e.nodeType!==`tool_exec`||!e.action)continue;let r=e.action.name||``,s=e.action.params;if(s==null)continue;if(typeof s==`string`)try{s=JSON.parse(s)}catch{continue}if(typeof s!=`object`)continue;if(r===`agent_exec`){let u=s.command||``;if(!u)continue;let d=nv(u,a);if(d&&e.status!==`failed`){let a=i.get(d);if(a){let i=$_(a.content,a.ext);for(let a of i){if(!a)continue;let i=(a.startsWith(`/`),Z(a));if(n.has(i)){let e=t.findIndex(e=>e.path===i);e>=0&&t.splice(e,1)}n.add(i),t.push({path:i,fileName:R_(i),toolName:r,action:`typeCreate`,size:0,timestamp:e.timestamp||null,status:e.status||`unknown`,type:`file`})}}}if(e.status!==`failed`){let t=rv(u,s.cwd);for(let n of t)o.set(n.path,{isDir:n.isDir,timestamp:e.timestamp})}let f=Q_(u,s.cwd);for(let e of f)if(e&&e.path){let t=e.isDir?e.path:q_(e.path);t&&c.add(t)}for(let i of f){let a=i&&i.path;if(a){if(n.has(a)){let e=t.findIndex(e=>e.path===a);e>=0&&t.splice(e,1)}n.add(a),e.status!==`failed`&&t.push({path:a,fileName:R_(a),toolName:r,action:`typeCreate`,size:0,timestamp:e.timestamp||null,status:e.status||`unknown`,type:i.isDir?`directory`:`file`})}}let p=f.length>0||!!d||/<<-?/.test(u);if(e.status!==`failed`&&typeof e.observation==`string`){let i=Z_(u,s.cwd);/\bcd\s/.test(u)&&i&&(p||l)&&c.add(Z(i));let a=ev(e.observation,i,u);a.length>0&&!p&&(a=Y_(u)?[]:a.filter(e=>X_(e.path,c)));for(let i of a){if(n.has(i.path)){let e=t.findIndex(e=>e.path===i.path);e>=0&&t.splice(e,1)}n.add(i.path),t.push({path:i.path,fileName:R_(i.path),toolName:r,action:`typeCreate`,size:0,timestamp:e.timestamp||null,status:e.status||`unknown`,type:i.isDir?`directory`:`file`})}}e.status!==`failed`&&p&&(l=!0);continue}let u=null,d=`typeOther`;if(r===`agent_file`){let t=s.action;if(t===`write`)u=s.path||s.filePath,d=`typeWrite`;else if(t===`delete`){let t=Z(s.path||s.filePath||``);t&&e.status!==`failed`&&o.set(t,{isDir:!1,timestamp:e.timestamp});continue}else continue}else if(r===`file_upload`)u=s.path||s.filePath||s.filename,d=`typeCreate`;else if(r===`download_file`)continue;else s.file_path&&(s.content!==void 0||s.action===`write`||s.action===`create`)&&(u=s.file_path,d=s.action===`create`?`typeCreate`:`typeWrite`);if(!u)continue;let f=Z(W_(e.observation)||u);if(!f)continue;if(n.has(f)){let e=t.findIndex(e=>e.path===f);e>=0&&t.splice(e,1)}if(n.add(f),e.status===`failed`)continue;let p=q_(f);p&&c.add(p),l=!0;let m=0;if(e.observation){let t=e.observation;if(typeof t==`string`)try{t=JSON.parse(t)}catch{}t&&typeof t==`object`&&(m=t.size||t.fileSize||t.file_size||0)}t.push({path:f,fileName:R_(f),toolName:r,action:d,size:m,timestamp:e.timestamp||null,status:e.status||`unknown`,type:`file`})}if(o.size>0){let e=[...o.keys()],n=(e,t)=>{if(e===t)return!0;let n=e.startsWith(`/`),r=t.startsWith(`/`);return n&&!r?e.endsWith(`/`+t)||e.endsWith(t):r&&!n?t.endsWith(`/`+e)||t.endsWith(e):!1};for(let r of t)r.deleted||(o.has(r.path)&&s(r.timestamp,o.get(r.path))||e.some(e=>{let t=o.get(e);return s(r.timestamp,t)?n(r.path,e)?!0:t&&t.isDir&&(r.path.startsWith(e+`/`)||r.path.startsWith(e+`\\`)):!1}))&&(r.deleted=!0)}return t.filter(e=>e&&e.fileName)}function av(e){if(!e||typeof e!=`string`)return[];let t=[],n=new Set,r=/\[\[artifact:([^\]|]+)(?:\|([^\]]*))?\]\]/g,i;for(;(i=r.exec(e))!==null;){let e=(i[1]||``).trim(),r=(i[2]||``).trim();if(!e||/\$\{?[A-Za-z_][A-Za-z0-9_]*\}?|%[A-Za-z0-9_]+%/.test(e))continue;let a=ov(e);!a||n.has(a)||(n.add(a),t.push({path:e,note:r}))}return t}function ov(e){return Z(e).replace(/^\.\//,``)}function sv(e,t){let n=(e||[]).map(e=>({...e,source:e.source||`static`})),r=n.map(e=>ov(e.path));for(let e of t||[]){let t=ov(e.path);if(!t)continue;let i=R_(e.path);if(!i)continue;let a=r.indexOf(t);if(a===-1&&(a=r.findIndex(e=>e.endsWith(`/`+t))),a!==-1){let t=n[a];t&&e.note&&!t.note&&(t.note=e.note);continue}r.push(t),n.push({path:e.path,fileName:i,toolName:`declared`,action:`typeCreate`,size:0,timestamp:null,status:`unknown`,type:`file`,source:`declared`,note:e.note||``})}return n}function cv(e,t){return sv(iv(e),av(t))}function lv(e){try{return $t(e)}catch{return!1}}var uv=null,dv=null,fv=null,pv=1;function mv(e){if(!e)return`—`;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function hv(e){if(!fv)return e;let t=pv;return[...e].sort((e,n)=>{let r,i;return fv===`name`?(r=(e.fileName||e.path||``).toLowerCase(),i=(n.fileName||n.path||``).toLowerCase()):fv===`type`?(r=e.type||`file`,i=n.type||`file`):(r=new Date(e.timestamp||0).getTime(),i=new Date(n.timestamp||0).getTime()),r<i?-t:r>i?t:0})}function gv(e,t){let n=an(e.fileName,e.type),i=r(`artifacts.${e.action}`),a=mv(e.timestamp),o=lv(e.fileName),s=`${B_(e.path)} · ${r(`artifacts.dblClickHint`)}`;return`
|
|
1193
|
+
<tr class="artifacts-row" data-idx="${t}" data-path="${B_(e.path)}" data-name="${B_(e.fileName)}">
|
|
1187
1194
|
<td class="col-index">${t+1}</td>
|
|
1188
1195
|
<td class="col-file">
|
|
1189
1196
|
<span class="artifact-icon">${n}</span>
|
|
1190
|
-
<span class="artifact-name" title="${s}">${
|
|
1197
|
+
<span class="artifact-name" title="${s}">${B_(e.fileName)}</span>
|
|
1191
1198
|
<button class="artifact-copy-btn" title="${r(`artifacts.copyFileName`)}">
|
|
1192
1199
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="13" height="13">
|
|
1193
1200
|
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"/>
|
|
@@ -1220,7 +1227,7 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1220
1227
|
</button>`:``}
|
|
1221
1228
|
</td>
|
|
1222
1229
|
</tr>
|
|
1223
|
-
`}function
|
|
1230
|
+
`}function _v(e,t){e.querySelectorAll(`.artifacts-row`).forEach(e=>{let n=t[parseInt(e.dataset.idx,10)];if(!n)return;e.addEventListener(`click`,e=>{e.target.closest(`.artifact-action-btn`)||e.target.closest(`.artifact-copy-btn`)||(clearTimeout(dv),dv=setTimeout(()=>{dv=null,t_().catch(()=>{}),$g(n.path).catch(e=>{a.error(`[Artifacts] locate failed:`,e)})},250))});let i=e.querySelector(`.artifact-name`);i&&i.addEventListener(`dblclick`,e=>{e.stopPropagation(),e.preventDefault(),clearTimeout(dv),dv=null,lv(n.fileName)&&e_(n.path,n.fileName).catch(e=>{a.error(`[Artifacts] preview failed:`,e)})});let o=e.querySelector(`.artifact-copy-btn`);o&&o.addEventListener(`click`,async e=>{e.stopPropagation();let t=e.ctrlKey||e.metaKey,i=n.fileName;t&&(i=await r_(n.path)||n.path),ht(i,o),P(t?r(`artifacts.copiedPath`):r(`artifacts.copiedName`,{name:n.fileName}),`success`)});let s=e.querySelector(`.download-btn`);s&&s.addEventListener(`click`,e=>{e.stopPropagation(),yv(n)}),e.querySelectorAll(`.locate-btn, .preview-btn`).forEach(e=>{e.addEventListener(`click`,async t=>{if(t.stopPropagation(),e.classList.contains(`locate-btn`)){t_().catch(()=>{});try{await $g(n.path)}catch(e){a.error(`[Artifacts] locate failed:`,e)}}else if(e.classList.contains(`preview-btn`))try{await e_(n.path,n.fileName)}catch(e){a.error(`[Artifacts] preview failed:`,e)}})})})}function vv(e,t){let n=hv(t),r=e.querySelector(`.artifacts-table tbody`);r.innerHTML=n.map((e,t)=>gv(e,t)).join(``),e.querySelectorAll(`.artifacts-table th.sortable`).forEach(e=>{let t=e.dataset.sort;e.classList.toggle(`sorted-asc`,t===fv&&pv===1),e.classList.toggle(`sorted-desc`,t===fv&&pv===-1)}),_v(e,n)}async function yv(e){let t=null;try{t=e.type===`directory`?await tn([e.path]):await hn(e.path)}catch(e){t={success:!1,error:e.message}}if(!t||!t.success){let e=t&&t.error?`: ${t.error}`:``;P(r(`artifacts.downloadFailed`)+e,`error`);return}let n=URL.createObjectURL(t.blob),i=document.createElement(`a`),a=t.name||R_(e.path)||`workspace.zip`;if(e.type===`directory`){let t=R_(e.path);t&&(a=t.replace(/\.zip$/i,``)+`.zip`)}i.href=n,i.download=a,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(n),5e3)}function bv(e,t){if(!t)return!0;let n=Z(e||``);if(!n||n.startsWith(`~/`)||n===`~`)return!1;if(!(n.startsWith(`/`)||/^[a-zA-Z]:\//.test(n)))return!0;let r=n.toLowerCase(),i=t.toLowerCase();return r===i||r.startsWith(i+`/`)}function xv(e,t){return!t||!(e===`~`||e&&e.startsWith(`~/`))?e:Z(e===`~`?t:t+`/`+e.slice(2))}function Sv(e,t){let n=e.querySelector(`.artifacts-modal-count`);n&&(n.textContent=r(`artifacts.totalCount`,{count:t.length}))}async function Cv(e){if(!e||e.length===0)return!1;let t=null;try{let e=await sn();e&&(t=Z(e))}catch{}let n=null;try{n=await mn()}catch{}let r=!1;if(t)for(let i=e.length-1;i>=0;i--){let a=e[i];bv(xv(a.path,n),t)||(e.splice(i,1),r=!0)}if(e.length===0)return r;try{let t=new Map;await Promise.all(e.map(async e=>{let n=e.path;try{let t=await r_(e.path);t&&(n=t)}catch{}t.has(n)||t.set(n,[]),t.get(n).push(e.path)}));let n=[...t.keys()];if(n.length===0)return r;let i=await chrome.runtime.sendMessage({type:`CHECK_FILES_EXIST`,paths:n});if(!i||!i.success||!i.results)return r;let a=new Set;for(let[e,n]of t)if(i.results[e]===!1)for(let e of n)a.add(e);if(a.size>0)for(let t=e.length-1;t>=0;t--)a.has(e[t].path)&&(e.splice(t,1),r=!0)}catch{}return r}function wv(e,t){if(!e)return;let n=e.querySelector(`.artifacts-btn-count`);t>0?(n&&(n.textContent=t),e.title=r(`artifacts.btnTitle`,{count:t}),e.style.display=``):e.style.display=`none`}function Tv(e,t){!e||e.length===0||!t||Cv(e).then(n=>{n&&wv(t,e.length)}).catch(()=>{})}function Ev(e){if(!e)return 0;for(let t=e.length-1;t>=0;t--)e[t].deleted&&e.splice(t,1);return e.length}function Dv(e,t){if(Ov(),!e)return;for(let t=e.length-1;t>=0;t--)e[t].deleted&&e.splice(t,1);if(e.length===0){wv(t,0);return}fv=null,pv=1,uv=document.createElement(`div`),uv.className=`artifacts-modal-overlay`,uv.id=`artifactsModalOverlay`;let n=document.createElement(`div`);n.className=`artifacts-modal`;let i=document.createElement(`div`);i.className=`artifacts-modal-header`,i.innerHTML=`
|
|
1224
1231
|
<div class="artifacts-modal-title">
|
|
1225
1232
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:18px;height:18px;color:var(--info-500);">
|
|
1226
1233
|
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
|
|
@@ -1243,7 +1250,7 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1243
1250
|
</tr>
|
|
1244
1251
|
</thead>
|
|
1245
1252
|
<tbody></tbody>
|
|
1246
|
-
`,a.appendChild(o);let s=document.createElement(`div`);s.className=`artifacts-modal-footer`;let c=document.createElement(`button`);c.className=`artifacts-modal-close-btn`,c.textContent=r(`artifacts.closeBtn`),c.addEventListener(`click`,
|
|
1253
|
+
`,a.appendChild(o);let s=document.createElement(`div`);s.className=`artifacts-modal-footer`;let c=document.createElement(`button`);c.className=`artifacts-modal-close-btn`,c.textContent=r(`artifacts.closeBtn`),c.addEventListener(`click`,Ov),s.appendChild(c),n.appendChild(i),n.appendChild(a),n.appendChild(s),uv.appendChild(n);let l=document.body,u=document.getElementById(`workspacePanelContainer`);if(u&&u.classList.contains(`embedded`)){let e=document.getElementById(`mainLeft`);e&&(uv.classList.add(`embedded-mode`),e.style.position=`relative`,l=e)}l.appendChild(uv),document.getElementById(`artifactsModalClose`).addEventListener(`click`,Ov);let d=e=>{e.key===`Escape`&&(Ov(),document.removeEventListener(`keydown`,d))};document.addEventListener(`keydown`,d),o.querySelectorAll(`th.sortable`).forEach(t=>{t.addEventListener(`click`,()=>{let r=t.dataset.sort;fv===r?pv=-pv:(fv=r,pv=1),vv(n,e)})}),vv(n,e),Cv(e).then(i=>{if(!(!i||!uv)){if(e.length===0){let t=n.querySelector(`.artifacts-table tbody`);t&&(t.innerHTML=`<tr><td colspan="5" class="artifacts-empty">${r(`artifacts.emptyHint`)}</td></tr>`),Sv(n,e)}else Sv(n,e),vv(n,e);wv(t,e.length)}}).catch(()=>{})}function Ov(){dv&&=(clearTimeout(dv),null),uv&&=(uv.remove(),null)}n(`zh`,{promptSelector:{noMatchAgent:`没有匹配的 Agent`,inheritGlobal:`继承全局设置`,editAgentTitle:`编辑此 Agent`,deleteAgentTitle:`删除此 Agent`,noMatchProxy:`没有匹配的代理`,unnamedProxy:`未命名代理`,enableTitle:`启用此代理`,disableTitle:`禁用此代理`,noMatchAll:`没有匹配的 Agent、网页或代理`,noTitle:`无标题`,proxyAddress:`代理地址`,deleteProxyTitle:`删除此代理`,confirmDeleteProxy:`确定要删除此代理吗?`},knowledgeSelector:{disabled:`知识库检索已关闭(可在设置页「知识库」中开启)`,notAvailable:`知识库不可用(请确认代理已连接、检索依赖已安装)`,noCollections:`暂无知识库(可在设置页「知识库」中创建)`,docChunk:`{docs} 文档 · {chunks} 分块`,disabledBadge:`已停用`,disabledTooltip:`已停用(大模型不会自主检索该库),仍可手动 @ 引用`,manualSuffix:`手动引用`}}),n(`en`,{promptSelector:{noMatchAgent:`No matching agent`,inheritGlobal:`Inherit global settings`,editAgentTitle:`Edit this agent`,deleteAgentTitle:`Delete this agent`,noMatchProxy:`No matching proxy`,unnamedProxy:`Unnamed proxy`,enableTitle:`Enable this proxy`,disableTitle:`Disable this proxy`,noMatchAll:`No matching agent, page or proxy`,noTitle:`Untitled`,proxyAddress:`Proxy address`,deleteProxyTitle:`Delete this proxy`,confirmDeleteProxy:`Are you sure you want to delete this proxy?`},knowledgeSelector:{disabled:`Knowledge retrieval is turned off (you can enable it in Settings - Knowledge)`,notAvailable:`Knowledge base unavailable (check the agent connection and installed retrieval dependencies)`,noCollections:`No knowledge base yet (create one in Settings - Knowledge)`,docChunk:`{docs} docs · {chunks} chunks`,disabledBadge:`Disabled`,disabledTooltip:`Disabled (the model won't search this knowledge base autonomously); you can still reference it manually via @`,manualSuffix:`manual`}});var Q=`pages`;async function kv(){try{let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]);return(e.pairedAgents||[]).map(t=>({...t,isActive:t.id===e.activeAgentId,isDisabled:!!t.disabled}))}catch{return[]}}var Av=!1;async function jv(e=``,t=null){let n=document.getElementById(`agentAtSelector`),r=document.getElementById(`agentAtDropdown`);pt(),n.style.display=`block`,r.classList.add(`show`),Pv(),t?await Fv(t):await Iv(e),Mv()}async function Mv(){try{let[e,t,n,i]=await Promise.all([lt(),my(),kv(),cy()]),a=document.querySelector(`#agentAtTabs .prompt-tab[data-tab="agents"]`),o=document.querySelector(`#agentAtTabs .prompt-tab[data-tab="pages"]`),s=document.querySelector(`#agentAtTabs .prompt-tab[data-tab="proxies"]`),c=document.querySelector(`#agentAtTabs .prompt-tab[data-tab="knowledge"]`);a&&(a.textContent=r(`promptSelector.agentsCount`,{count:e.length})),o&&(o.textContent=r(`promptSelector.pagesCount`,{count:t.length})),s&&(s.textContent=r(`promptSelector.proxiesCount`,{count:n.length}),s.style.display=n.length>0?``:`none`),c&&(c.textContent=r(`promptSelector.knowledgeCount`,{count:i.collections.length}),c.style.display=i.ok?``:`none`,!i.ok&&Q===`knowledge`&&Fv(`pages`))}catch{}}function Nv(){let e=document.getElementById(`agentAtSelector`),t=document.getElementById(`agentAtDropdown`);e.style.display=`none`,t.classList.remove(`show`),N.selectedAgentAtIndex=-1,N.selectedPageIndex=-1,N.selectedProxyAtIndex=-1,N.selectedKnowledgeAtIndex=-1}function Pv(){let e=document.getElementById(`agentAtDropdown`);if(!e||e.dataset.initialized)return;e.dataset.initialized=`1`,e.addEventListener(`mousedown`,e=>{e.target.closest(`.prompt-item, .prompt-tab, .skill-list-item, .mcp-list-item`)&&e.preventDefault()});let t=document.getElementById(`agentAtTabs`);t&&t.querySelectorAll(`.prompt-tab`).forEach(e=>{e.addEventListener(`click`,()=>{Fv(e.dataset.tab)})}),e.addEventListener(`click`,async e=>{if(e.target.closest(`#agentAddBtn`)){e.stopPropagation(),Nv(),MC(null);return}if(e.target.closest(`#proxyAddBtn`)){e.stopPropagation(),Nv(),chrome.runtime.sendMessage({type:`OPEN_OPTIONS_PAGE`,hash:`agent`});return}if(e.target.closest(`#knowledgeAddBtn`)){e.stopPropagation(),Nv(),chrome.runtime.sendMessage({type:`OPEN_OPTIONS_PAGE`,hash:`knowledge`});return}if(e.target.closest(`#pageAddBtn`)){e.stopPropagation(),Nv(),chrome.tabs.create({});return}let t=e.target.closest(`.agent-edit-btn`);if(t){e.stopPropagation();let n=t.dataset.agentId;Nv(),MC(n);return}let n=e.target.closest(`.agent-delete-btn`);if(n){e.stopPropagation();let t=n.dataset.agentId;if(await QC(t)){let e=document.getElementById(`userInput`);await Iv(e?Lv(e.value):``)}}})}async function Fv(e){Q=e;let t=document.getElementById(`agentAtTabs`);t&&t.querySelectorAll(`.prompt-tab`).forEach(t=>{t.classList.toggle(`active`,t.dataset.tab===e)});let n=document.getElementById(`agentAtList`),r=document.getElementById(`agentPageList`),i=document.getElementById(`agentProxyList`),a=document.getElementById(`agentKnowledgeList`);n&&(n.style.display=e===`agents`?``:`none`),r&&(r.style.display=e===`pages`?``:`none`),i&&(i.style.display=e===`proxies`?``:`none`),a&&(a.style.display=e===`knowledge`?``:`none`);let o=document.getElementById(`agentAtDropdown`);o&&o.setAttribute(`data-active-tab`,e);let s=document.getElementById(`userInput`);s&&s.focus(),await Iv(s?Lv(s.value):``)}async function Iv(e=``){let t=document.getElementById(`agentAtTabs`),n=document.getElementById(`agentPageList`),r=document.getElementById(`agentAtList`),i=document.getElementById(`agentProxyList`),a=document.getElementById(`agentKnowledgeList`);if(e){Av=!0,t&&t.classList.add(`merged-mode`),n&&(n.style.display=`none`),i&&(i.style.display=`none`),a&&(a.style.display=`none`),r&&(r.style.display=``),await Jv(e);let o=document.getElementById(`agentAtDropdown`);o&&o.setAttribute(`data-active-tab`,`merged`)}else{Av=!1,t&&t.classList.remove(`merged-mode`),t&&t.querySelectorAll(`.prompt-tab`).forEach(e=>{e.classList.toggle(`active`,e.dataset.tab===Q)}),n&&(n.style.display=Q===`pages`?``:`none`),r&&(r.style.display=Q===`agents`?``:`none`),i&&(i.style.display=Q===`proxies`?``:`none`),a&&(a.style.display=Q===`knowledge`?``:`none`);let e=document.getElementById(`agentAtDropdown`);e&&e.setAttribute(`data-active-tab`,Q),Q===`pages`?await hy(``):Q===`proxies`?await qv(``):Q===`knowledge`?await ly(``):await Bv(``)}}function Lv(e){let t=e.lastIndexOf(`@`);return t===-1?``:e.substring(t+1)}function Rv(e){return e.id==="default"?r(`agentMgr.defaultAgentName`):e.name}function zv(e){return e.id==="default"?r(`agentMgr.defaultAgentDesc`):e.description}async function Bv(e=``){let t=document.getElementById(`agentAtList`);if(!t)return;let n=await lt(),i=(e||``).toLowerCase(),a=n.filter(t=>{if(!e)return!0;let n=Rv(t),r=zv(t);return n&&n.toLowerCase().includes(i)||r&&r.toLowerCase().includes(i)});if(a.length===0){t.innerHTML=`<div class="prompt-empty">${r(`promptSelector.noMatchAgent`)}</div>`,N.selectedAgentAtIndex=-1;return}N.selectedAgentAtIndex=0,t.innerHTML=a.map((e,t)=>{let n=e.id===N.activeAgentId||!N.activeAgentId&&e.id==="default",i=e.toolIds?e.toolIds.length:e.toolIds===null?null:0,a=i===null?r(`promptSelector.inheritGlobal`):r(`promptSelector.toolCount`,{count:i}),o=Rv(e),s=zv(e);return`
|
|
1247
1254
|
<div class="prompt-item ${t===0?`selected`:``} ${n?`agent-at-active`:``}"
|
|
1248
1255
|
data-index="${t}" data-agent-id="${F(e.id)}">
|
|
1249
1256
|
<span class="prompt-item-index">${t+1}</span>
|
|
@@ -1256,7 +1263,7 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1256
1263
|
${e.isBuiltin?``:`<span class="agent-delete-btn" data-agent-id="${F(e.id)}" title="${r(`promptSelector.deleteAgentTitle`)}">✕</span>`}
|
|
1257
1264
|
</span>
|
|
1258
1265
|
</div>
|
|
1259
|
-
`}).join(``),t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,async t=>{t.target.closest(`.agent-edit-btn`)||t.target.closest(`.agent-delete-btn`)||await
|
|
1266
|
+
`}).join(``),t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,async t=>{t.target.closest(`.agent-edit-btn`)||t.target.closest(`.agent-delete-btn`)||await Qv(e.dataset.agentId)})})}async function Vv(e){if(!e?.url)return{online:!1};try{let t=new AbortController;setTimeout(()=>t.abort(),2e3);let n=await fetch(`${e.url}/api/status`,{signal:t.signal});if(!n.ok)return{online:!1};let r=await n.json();return{online:!0,version:r.version||null,platformName:r.platformName||r.platform||null,arch:r.arch||null}}catch{return{online:!1}}}var Hv=new Map,Uv=1e4;function Wv(e){let t=Hv.get(e.id);return t&&Date.now()-t.ts<Uv?t:null}function Gv(e,t){return e.isDisabled?`disabled`:e.isActive?t?`connected`:`disconnected`:t?`online`:`offline`}async function Kv(e){if(Wv(e))return;let t=await Vv(e);Hv.set(e.id,{online:t.online,version:t.version||null,platformName:t.platformName||null,ts:Date.now()}),document.querySelectorAll(`.prompt-item-proxy`).forEach(n=>{if(n.dataset.proxyId===e.id){let r=n.querySelector(`.agent-at-dot`);r&&(r.className=`agent-at-dot agent-at-dot-${Gv(e,t.online)}`)}})}async function qv(e=``){let t=document.getElementById(`agentProxyList`);if(!t)return;let n=await kv(),i=(e||``).toLowerCase(),a=n.filter(t=>e?t.name.toLowerCase().includes(i)||t.url&&t.url.toLowerCase().includes(i):!0);if(a.length===0){t.innerHTML=`<div class="prompt-empty">${r(`promptSelector.noMatchProxy`)}</div>`,N.selectedProxyAtIndex=-1;return}N.selectedProxyAtIndex=0,t.innerHTML=a.map((e,t)=>{let n=Wv(e),i=e.isActive,a=e.isDisabled,o=Gv(e,n?n.online:!1),s=e.name||r(`promptSelector.unnamedProxy`);return`
|
|
1260
1267
|
<div class="prompt-item ${t===0?`selected`:``} ${i?`agent-at-active`:``} ${a?`agent-disabled`:``} prompt-item-proxy"
|
|
1261
1268
|
data-index="${t}" data-proxy-id="${F(e.id)}">
|
|
1262
1269
|
<span class="prompt-item-index">${t+1}</span>
|
|
@@ -1269,7 +1276,7 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1269
1276
|
${a?`<span class="proxy-enable-btn" data-action="enable" data-id="${F(e.id)}" title="${r(`promptSelector.enableTitle`)}">▶</span>`:`<span class="proxy-disable-btn" data-action="disable" data-id="${F(e.id)}" title="${r(`promptSelector.disableTitle`)}">⏸</span>`}
|
|
1270
1277
|
<span class="proxy-delete-btn" data-action="delete" data-id="${F(e.id)}" title="${r(`common.delete`)}">✕</span>
|
|
1271
1278
|
</div>
|
|
1272
|
-
`}).join(``),t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,async t=>{let n=t.target.closest(`.proxy-disable-btn, .proxy-delete-btn, .proxy-enable-btn`);if(n){t.stopPropagation(),await
|
|
1279
|
+
`}).join(``),t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,async t=>{let n=t.target.closest(`.proxy-disable-btn, .proxy-delete-btn, .proxy-enable-btn`);if(n){t.stopPropagation(),await py(n.dataset.action,n.dataset.id);return}await uy(e.dataset.proxyId)})}),a.forEach(e=>Kv(e))}async function Jv(e=``){let t=document.getElementById(`agentAtList`);if(!t)return;let n=e.toLowerCase(),[i,a,o,s]=await Promise.all([lt(),my(),kv(),cy()]),c=i.filter(e=>{let t=Rv(e),r=zv(e);return t&&t.toLowerCase().includes(n)||r&&r.toLowerCase().includes(n)}),l=a.filter(e=>{if(!e.url)return!1;let t=(e.title||``).toLowerCase().includes(n),r=e.url.toLowerCase().includes(n);return t||r}),u=o.filter(e=>e.name.toLowerCase().includes(n)||e.url&&e.url.toLowerCase().includes(n)),d=s.ok?s.collections.filter(e=>e.name&&e.name.toLowerCase().includes(n)||e.description&&e.description.toLowerCase().includes(n)):[],f=c.length+l.length+u.length+d.length,p=document.getElementById(`agentAtMergedTitle`);if(p&&(p.textContent=r(`promptSelector.mergedTitleCount`,{count:f})),f===0){t.innerHTML=`<div class="prompt-empty">${r(`promptSelector.noMatchAll`)}</div>`,N.selectedAgentAtIndex=-1;return}N.selectedAgentAtIndex=0;let m=``,h=0;c.forEach(e=>{let t=e.id===N.activeAgentId||!N.activeAgentId&&e.id==="default",n=e.toolIds?e.toolIds.length:e.toolIds===null?null:0,i=n===null?r(`promptSelector.inheritGlobal`):r(`promptSelector.toolCount`,{count:n}),a=Rv(e),o=zv(e);m+=`
|
|
1273
1280
|
<div class="prompt-item${h===0?` selected`:``}${t?` agent-at-active`:``}"
|
|
1274
1281
|
data-index="${h}" data-type="agent" data-agent-id="${F(e.id)}">
|
|
1275
1282
|
<span class="prompt-item-index">${h+1}</span>
|
|
@@ -1303,7 +1310,7 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1303
1310
|
<span class="prompt-item-content">${F(e.name||``)}</span>
|
|
1304
1311
|
${i?`<span class="knowledge-item-badge badge-disabled">${r(`knowledgeSelector.disabledBadge`)}</span>`:``}
|
|
1305
1312
|
<span class="prompt-item-code">${F(n)}</span>
|
|
1306
|
-
</div>`,h++}),u.forEach(e=>{let t=e.isActive,n=e.isDisabled,i=
|
|
1313
|
+
</div>`,h++}),u.forEach(e=>{let t=e.isActive,n=e.isDisabled,i=Wv(e),a=Gv(e,i?i.online:!1),o=e.name||r(`promptSelector.unnamedProxy`);m+=`
|
|
1307
1314
|
<div class="prompt-item${h===0?` selected`:``}${t?` agent-at-active`:``}${n?` agent-disabled`:``} prompt-item-proxy"
|
|
1308
1315
|
data-index="${h}" data-type="proxy" data-proxy-id="${F(e.id)}">
|
|
1309
1316
|
<span class="prompt-item-index">${h+1}</span>
|
|
@@ -1313,12 +1320,12 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1313
1320
|
${t?`<span class="agent-item-actions"><span class="agent-active-mark">✓</span></span>`:``}
|
|
1314
1321
|
${n?`<span class="proxy-enable-btn" data-action="enable" data-id="${F(e.id)}" title="${r(`promptSelector.enableTitle`)}">▶</span>`:`<span class="proxy-disable-btn" data-action="disable" data-id="${F(e.id)}" title="${r(`promptSelector.disableTitle`)}">⏸</span>`}
|
|
1315
1322
|
<span class="proxy-delete-btn" data-action="delete" data-id="${F(e.id)}" title="${r(`common.delete`)}">✕</span>
|
|
1316
|
-
</div>`,h++}),t.innerHTML=m,t.querySelectorAll(`img.favicon-img`).forEach(e=>{e.addEventListener(`error`,()=>{e.style.display=`none`})}),u.forEach(e=>
|
|
1323
|
+
</div>`,h++}),t.innerHTML=m,t.querySelectorAll(`img.favicon-img`).forEach(e=>{e.addEventListener(`error`,()=>{e.style.display=`none`})}),u.forEach(e=>Kv(e)),t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,async t=>{let n=t.target.closest(`.page-action-btn`);if(n){t.stopPropagation(),by(parseInt(n.dataset.tabId),n.dataset.action);return}let r=t.target.closest(`.proxy-disable-btn, .proxy-delete-btn, .proxy-enable-btn`);if(r){t.stopPropagation(),await py(r.dataset.action,r.dataset.id);return}if(t.target.closest(`.agent-edit-btn`)||t.target.closest(`.agent-delete-btn`))return;let i=e.dataset.type;i===`agent`?await Qv(e.dataset.agentId):i===`page`?$v(parseInt(e.dataset.tabId)):i===`knowledge`?(ty({id:e.dataset.kbId,name:e.dataset.kbName,enabled:e.dataset.kbDisabled!==`1`}),(t.ctrlKey||t.metaKey)&&Nv()):i===`proxy`&&await uy(e.dataset.proxyId)})})}function Yv(e){let t;t=Av?N.selectedAgentAtIndex:Q===`proxies`?N.selectedProxyAtIndex:Q===`knowledge`?N.selectedKnowledgeAtIndex:N.selectedAgentAtIndex,e.forEach((e,n)=>{n===t?(e.classList.add(`selected`),e.scrollIntoView({block:`nearest`})):e.classList.remove(`selected`)})}function Xv(){let e=document.getElementById(`userInput`);if(!e)return;let t=e.value,n=t.lastIndexOf(`@`);n!==-1&&(e.value=t.substring(0,n)),e.focus(),e.selectionStart=e.selectionEnd=e.value.length}function Zv(){let e=document.getElementById(`userInput`);e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length)}async function Qv(e,{clearTrigger:t=!0}={}){t?Xv():Zv(),Nv(),await vC(e),Dt()}function $v(e){Xv(),chrome.tabs.get(e,e=>{if(chrome.runtime.lastError||!e){a.error(`[AgentAtSelector] getlabelpageinfo failed:`,chrome.runtime.lastError);return}_y(e),Nv();let t=document.getElementById(`userInput`);t&&(t.focus(),Dt())})}function ey(){let e=new Set(N.knowledgeRefs.map(e=>e.id));document.querySelectorAll(`.prompt-item-knowledge`).forEach(t=>{let n=e.has(t.dataset.kbId);t.classList.toggle(`agent-at-active`,n),t.classList.toggle(`picked`,n)})}function ty(e,{clearTrigger:t=!0}={}){t?Xv():Zv();let n=N.knowledgeRefs.findIndex(t=>t.id===e.id);n>=0?N.knowledgeRefs.splice(n,1):N.knowledgeRefs.push({id:e.id,name:e.name||e.id,enabled:e.enabled!==!1}),ey(),iy(),Dt()}function ny(e){N.knowledgeRefs=N.knowledgeRefs.filter(t=>t.id!==e),ey(),iy()}function ry(){N.knowledgeRefs=[],ey(),iy()}function iy(){let e=document.getElementById(`knowledgeIndicator`);if(e){if(N.knowledgeRefs.length===0){e.style.display=`none`,e.innerHTML=``;return}e.innerHTML=N.knowledgeRefs.map(e=>{let t=e.enabled===!1,n=t?`${e.name} (${r(`knowledgeSelector.manualSuffix`)})`:e.name;return`
|
|
1317
1324
|
<span class="knowledge-chip${t?` knowledge-chip-manual`:``}">
|
|
1318
1325
|
<span class="knowledge-chip-name" title="${F(t?r(`knowledgeSelector.disabledTooltip`):e.name)}">📚 ${F(n)}</span>
|
|
1319
1326
|
<button class="knowledge-chip-close" data-kb-id="${F(e.id)}" title="${r(`common.delete`)}">✕</button>
|
|
1320
1327
|
</span>
|
|
1321
|
-
`}).join(``),e.querySelectorAll(`.knowledge-chip-close`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),
|
|
1328
|
+
`}).join(``),e.querySelectorAll(`.knowledge-chip-close`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),ny(e.dataset.kbId)})}),e.style.display=`flex`}}var ay={ok:!1,collections:[],ts:0},oy=null,sy=15e3;async function cy(e=!1){let t=Date.now(),{ragEnabled:n}=await chrome.storage.local.get(`ragEnabled`);return n===!0?!e&&ay.ts&&t-ay.ts<sy?ay:oy||(oy=new Promise(e=>{try{chrome.runtime.sendMessage({type:`RAG_LIST_COLLECTIONS`},t=>{ay=chrome.runtime.lastError||!t||!t.success?{ok:!1,collections:[],ts:Date.now()}:{ok:!0,collections:[...t.collections||[]].sort((e,t)=>(e.enabled===!1)-+(t.enabled===!1)),ts:Date.now()},e(ay)})}catch{ay={ok:!1,collections:[],ts:Date.now()},e(ay)}}).finally(()=>{oy=null}),oy):{ok:!1,disabled:!0,collections:[],ts:Date.now()}}async function ly(e=``){let t=document.getElementById(`agentKnowledgeList`);if(!t)return;let n=await cy();if(!n.ok){t.innerHTML=`<div class="prompt-empty">${r(n.disabled?`knowledgeSelector.disabled`:`knowledgeSelector.notAvailable`)}</div>`,N.selectedKnowledgeAtIndex=-1;return}let i=(e||``).toLowerCase(),a=n.collections.filter(t=>e?t.name&&t.name.toLowerCase().includes(i)||t.description&&t.description.toLowerCase().includes(i):!0);if(a.length===0){t.innerHTML=`<div class="prompt-empty">${r(`knowledgeSelector.noCollections`)}</div>`,N.selectedKnowledgeAtIndex=-1;return}N.selectedKnowledgeAtIndex=0,t.innerHTML=a.map((e,t)=>{let n=N.knowledgeRefs.some(t=>t.id===e.id),i=r(`knowledgeSelector.docChunk`,{docs:e.documentCount||0,chunks:e.chunkCount||0}),a=e.enabled===!1;return`
|
|
1322
1329
|
<div class="prompt-item ${t===0?`selected`:``} ${n?`agent-at-active picked`:``} ${a?`knowledge-item-disabled`:``} prompt-item-knowledge"
|
|
1323
1330
|
data-index="${t}" data-kb-id="${F(e.id)}" data-kb-name="${F(e.name||``)}"
|
|
1324
1331
|
data-kb-disabled="${a?`1`:`0`}"${a?` title="${F(r(`knowledgeSelector.disabledTooltip`))}"`:``}>
|
|
@@ -1328,7 +1335,7 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1328
1335
|
${a?`<span class="knowledge-item-badge badge-disabled">${r(`knowledgeSelector.disabledBadge`)}</span>`:``}
|
|
1329
1336
|
<span class="prompt-item-code">${F(i)}</span>
|
|
1330
1337
|
</div>
|
|
1331
|
-
`}).join(``),t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,t=>{
|
|
1338
|
+
`}).join(``),t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,t=>{ty({id:e.dataset.kbId,name:e.dataset.kbName,enabled:e.dataset.kbDisabled!==`1`}),(t.ctrlKey||t.metaKey)&&Nv()})})}async function uy(e,{clearTrigger:t=!0}={}){t?Xv():Zv(),Nv();try{await chrome.storage.local.set({activeAgentId:e}),chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!0,agentId:e}),a.debug(`[AgentAtSelector] switched to agent:`,e)}catch(e){a.error(`[AgentAtSelector] switchagent failed:`,e)}Dt()}var dy=!1;function fy(){dy||(dy=!0,chrome.tabs.onActivated.addListener(()=>{let e=document.getElementById(`agentAtSelector`);if(!e||e.style.display!==`block`||Q!==`pages`&&!Av)return;let t=document.getElementById(`userInput`);Iv(t?Lv(t.value):``)}))}fy();async function py(e,t){let n=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),i=n.pairedAgents||[];switch(e){case`enable`:i=i.map(e=>e.id===t?{...e,disabled:!1}:e),await chrome.storage.local.set({pairedAgents:i});break;case`disable`:{i=i.map(e=>e.id===t?{...e,disabled:!0}:e);let e=n.activeAgentId;n.activeAgentId===t&&(e=i.find(e=>e.id!==t&&!e.disabled)?.id||null),await chrome.storage.local.set({pairedAgents:i,activeAgentId:e||``}),e?chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!0,agentId:e}):chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!1});break}case`delete`:{let e=i.find(e=>e.id===t),a=e?.url?`\n${r(`promptSelector.proxyAddress`)}: ${e.url}`:``;if(!await window.showCustomConfirm(r(`promptSelector.deleteProxyTitle`),r(`promptSelector.confirmDeleteProxy`,{name:e?.name||t,urlInfo:a})))return;i=i.filter(e=>e.id!==t);let o=n.activeAgentId===t?i.find(e=>!e.disabled)?.id||null:n.activeAgentId;await chrome.storage.local.set({pairedAgents:i,activeAgentId:o||``}),o?chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!0,agentId:o}):chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!1});break}}let a=document.getElementById(`userInput`);await Iv(a?Lv(a.value):``)}n(`zh`,{pageSelector:{noOpenPages:`暂无打开的网页`,noTitle:`无标题`,currentTab:`当前`,openNewTab:`新建标签页`,interpretPage:`解读`,summarizePage:`总结`,translatePage:`翻译`,interpretMsg:`解读一下当前网页`,summarizeMsg:`总结一下当前网页`,translateMsg:`翻译一下当前网页`}}),n(`en`,{pageSelector:{noOpenPages:`No open pages`,noTitle:`Untitled`,currentTab:`Current`,openNewTab:`Open new tab`,interpretPage:`Interpret`,summarizePage:`Summarize`,translatePage:`Translate`,interpretMsg:`Interpret the current webpage`,summarizeMsg:`Summarize the current webpage`,translateMsg:`Translate the current webpage`}});async function my(){try{return[...await chrome.tabs.query({currentWindow:!0})].sort((e,t)=>e.active===t.active?0:e.active?-1:1)}catch(e){return a.error(`[PageSelector] getlabelpage failed:`,e),[]}}async function hy(e=``){let t=document.getElementById(`agentPageList`);if(!t)return;let n=await my(),i=e.toLowerCase(),a=n.filter(t=>{if(!t.url)return!1;if(!e)return!0;let n=(t.title||``).toLowerCase().includes(i),r=t.url.toLowerCase().includes(i);return n||r});if(a.length===0){t.innerHTML=`<div class="prompt-empty">${r(`pageSelector.noOpenPages`)}</div>`,N.selectedPageIndex=-1;return}N.selectedPageIndex=0;let o=N.selectedPage?N.selectedPage.id:null;t.innerHTML=a.map((e,t)=>{let n=e.title||r(`pageSelector.noTitle`),i=e.url||``,a=e.favIconUrl?`<img src="${F(e.favIconUrl)}" width="16" height="16" style="flex-shrink:0;" class="favicon-img">`:`<span style="font-size:14px;flex-shrink:0;">🌐</span>`,s=e.active?`<span class="current-tab-badge">${r(`pageSelector.currentTab`)}</span>`:``,c=e.id===o;return`
|
|
1332
1339
|
<div class="prompt-item prompt-item-page ${t===0?`selected`:``}"
|
|
1333
1340
|
data-index="${t}" data-tab-id="${e.id}">
|
|
1334
1341
|
<span class="prompt-item-index">${t+1}</span>
|
|
@@ -1343,8 +1350,8 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1343
1350
|
<span class="page-action-btn" data-action="translate" data-tab-id="${e.id}" title="${r(`pageSelector.translatePage`)}">${r(`pageSelector.translatePage`)}</span>
|
|
1344
1351
|
</span>
|
|
1345
1352
|
</div>
|
|
1346
|
-
`}).join(``),t.querySelectorAll(`img.favicon-img`).forEach(e=>{e.addEventListener(`error`,()=>{e.style.display=`none`})}),t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,t=>{let n=t.target.closest(`.page-action-btn`);if(n){t.stopPropagation(),vy(parseInt(n.dataset.tabId),n.dataset.action);return}_y(parseInt(e.dataset.tabId))})})}function my(e){e.forEach((e,t)=>{t===N.selectedPageIndex?(e.classList.add(`selected`),e.scrollIntoView({block:`nearest`})):e.classList.remove(`selected`)})}function hy(e){N.selectedPage={id:e.id,title:e.title||r(`pageSelector.noTitle`),url:e.url||``,favIconUrl:e.favIconUrl||``};let t=document.getElementById(`pageIndicator`),n=document.getElementById(`pageIndicatorName`);if(t&&n){let e=N.selectedPage.title&&N.selectedPage.title!==r(`pageSelector.noTitle`)?N.selectedPage.title:``,i=N.selectedPage.url||``;e&&i?n.textContent=`${e} · ${i}`:n.textContent=e||i,t.style.display=`flex`}}function gy(){N.selectedPage=null,N.selectedPageIndex=-1;let e=document.getElementById(`pageIndicator`);e&&(e.style.display=`none`)}function _y(e){let t=document.getElementById(`userInput`),n=t?t.value:``,r=n.lastIndexOf(`@`);r!==-1&&(t.value=n.substring(0,r)),t&&(t.focus(),t.selectionStart=t.selectionEnd=t.value.length),chrome.tabs.get(e,e=>{if(chrome.runtime.lastError||!e){a.error(`[PageSelector] getlabelpageinfo failed:`,chrome.runtime.lastError);return}hy(e),jv(),t&&(t.focus(),Dt())})}function vy(e,t){let n={interpret:r(`pageSelector.interpretMsg`),summarize:r(`pageSelector.summarizeMsg`),translate:r(`pageSelector.translateMsg`)}[t];n&&chrome.tabs.get(e,e=>{if(chrome.runtime.lastError||!e){a.error(`[PageSelector] get tab info failed:`,chrome.runtime.lastError);return}hy(e),jv();let t=document.getElementById(`userInput`);t&&(t.value=n,Dt()),Rx()})}function yy(){let e=document.getElementById(`pageIndicatorClose`);e&&e.addEventListener(`click`,()=>{gy()})}n(`zh`,{msgFullscreen:{title:`全屏阅读`,btnTitle:`全屏查看本回答 (Alt+双击 / Alt+F)`,btnLabel:`全屏`,copy:`复制`,copyTitle:`复制回答内容(Ctrl/⌘+点击复制富文本)`,export:`导出`,exportTitle:`导出下载本回答`,exportWord:`导出 Word`,exportPdf:`导出 PDF`,exportImage:`导出图片`,exportMarkdown:`导出 Markdown`,close:`退出全屏`,closeTitle:`退出全屏 (Esc)`}}),n(`en`,{msgFullscreen:{title:`Fullscreen Reading`,btnTitle:`View this answer fullscreen (Alt+Double-click / Alt+F)`,btnLabel:`Fullscreen`,copy:`Copy`,copyTitle:`Copy answer (Ctrl/Cmd+click for rich text)`,export:`Export`,exportTitle:`Export / download this answer`,exportWord:`Export Word`,exportPdf:`Export PDF`,exportImage:`Export Image`,exportMarkdown:`Export Markdown`,close:`Exit fullscreen`,closeTitle:`Exit fullscreen (Esc)`}});var by=`messageFullscreenOverlay`,xy=`messageFullscreenBody`,Sy=`messageFullscreenTitle`,Cy=`messageFullscreenCopyBtn`,wy=`messageFullscreenCloseBtn`,Ty=`messageFullscreenExportBtn`,Ey=`messageFullscreenExportDropdown`,Dy=null,Oy=null,ky=null,Ay=!1,jy=null,My=!1;function Ny(){return Dy!==null}function Py(e){return!e||Ny()?null:e.innerHTML}function Fy(){let e=document.querySelectorAll(`#chatContainer .message.assistant`);return e.length?e[e.length-1]:null}function Iy(){let e=document.createElement(`button`);return e.className=`fullscreen-btn`,e.title=r(`msgFullscreen.btnTitle`),e.innerHTML=[`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" width="14" height="14">`,`<path d="M6 2H2v4M10 2h4v4M6 14H2v-4M10 14h4v-4"/>`,`</svg>`,`<span>${r(`msgFullscreen.btnLabel`)}</span>`].join(``),e}function Ly(){let e=document.getElementById(by),t=document.getElementById(xy);return!e||!t?(a.warn(`[MsgFullscreen] overlay/body element missing`),null):{overlay:e,body:t,title:document.getElementById(Sy),copyBtn:document.getElementById(Cy),closeBtn:document.getElementById(wy)}}function Ry(e){if(!e)return;let t=Ly();if(t&&Dy!==e){if(!Dy){let e=document.getElementById(`chatContainer`);jy=e?e.scrollTop:null}Dy&&(My=!0,zy(),My=!1),Oy=document.createComment(`msg-fullscreen-anchor`),e.parentNode.insertBefore(Oy,e),e.dataset.fullscreen=`1`,t.body.appendChild(e),Dy=e,t.overlay.style.display=`flex`,document.body.classList.add(`message-fullscreen-viewing`),t.title&&(t.title.textContent=r(`msgFullscreen.title`)),t.copyBtn&&(t.copyBtn.title=r(`msgFullscreen.copyTitle`)),t.closeBtn&&(t.closeBtn.title=r(`msgFullscreen.closeTitle`)),Yy(),Vy(t.body)}}function zy(){if(!Dy)return;let e=Ly();if(Uy(),Xy(),Oy&&Oy.parentNode)Oy.parentNode.insertBefore(Dy,Oy);else if(e){let e=document.getElementById(`chatContainer`);e&&e.appendChild(Dy)}if(Oy&&Oy.parentNode&&Oy.parentNode.removeChild(Oy),delete Dy.dataset.fullscreen,Dy=null,Oy=null,e){e.overlay.style.display=`none`,e.body.innerHTML=``;let t=e.overlay.querySelector(`.message-fullscreen-rail`);t&&t.querySelectorAll(`.message-toc-container`).forEach(e=>e.remove())}if(document.body.classList.remove(`message-fullscreen-viewing`),!My&&jy!==null){let e=document.getElementById(`chatContainer`);e&&(e.scrollTop=jy),jy=null}}function By(e){if(Dy&&Dy===e){zy();return}Ry(e||Fy())}function Vy(e){Uy(),Ay=!1,e.scrollTop=e.scrollHeight,e.addEventListener(`scroll`,Hy,{passive:!0}),typeof ResizeObserver<`u`&&(ky=new ResizeObserver(()=>{Ay||(e.scrollTop=e.scrollHeight)}),ky.observe(e.firstElementChild||e))}function Hy(){let e=document.getElementById(xy);e&&(Ay=e.scrollHeight-e.scrollTop-e.clientHeight>60)}function Uy(){let e=document.getElementById(xy);e&&e.removeEventListener(`scroll`,Hy),ky&&=(ky.disconnect(),null)}function Wy(e){if(e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&e.code===`KeyF`){e.preventDefault(),Dy?zy():Ry(Fy());return}e.key===`Escape`&&Dy&&(e.preventDefault(),e.stopImmediatePropagation(),zy())}function Gy(e){if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return;let t=e.target.closest?.(`#chatContainer .message.assistant`);t&&(e.preventDefault(),By(t))}async function Ky(e){if(!Dy)return;let{copyAssistantMessage:t}=await M(async()=>{let{copyAssistantMessage:e}=await Promise.resolve().then(()=>$y);return{copyAssistantMessage:e}},void 0);t(Dy,document.getElementById(Cy),e)}var qy={docx:`<path d="M4 1.5h6L13 4.5v10H4z"/><path d="M10 1.5v3h3"/><path d="M6 8h4M6 10.5h4"/>`,pdf:`<path d="M4 1.5h6L13 4.5v10H4z"/><path d="M10 1.5v3h3"/><path d="M6.5 11.5c2-1 2.5-4 1-4s-1 4 2 4"/>`,image:`<rect x="2.5" y="3" width="11" height="10" rx="1.2"/><circle cx="6" cy="6.5" r="1"/><path d="M13.5 10 10 6.5 4.5 12.5"/>`,markdown:`<path d="M2.5 12V4l3 3 3-3v8"/><path d="M12.5 4v6m0 0 2-2.2m-2 2.2L10.5 7.8"/>`};function Jy(){let e=document.createElement(`div`);e.className=`message-fullscreen-export`;let t=document.createElement(`button`);t.className=`message-fullscreen-icon-btn`,t.id=Ty,t.type=`button`,t.title=r(`msgFullscreen.exportTitle`),t.innerHTML=[`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" width="16" height="16">`,`<path d="M8 2v8m0 0 3-3M8 10 5 7M2.5 13.5h11"/>`,`</svg>`,`<span>${r(`msgFullscreen.export`)}</span>`,`<svg class="dropdown-arrow" width="8" height="6" viewBox="0 0 8 6" fill="currentColor"><path d="M0 0l4 6 4-6z"/></svg>`].join(``);let n=document.createElement(`div`);n.className=`message-fullscreen-export-dropdown`,n.id=Ey;let i=e=>`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round">${qy[e]}</svg>`;n.innerHTML=[`<button class="export-dropdown-item export-docx-item" type="button">${i(`docx`)}<span>${r(`msgFullscreen.exportWord`)}</span></button>`,`<button class="export-dropdown-item export-pdf-item" type="button">${i(`pdf`)}<span>${r(`msgFullscreen.exportPdf`)}</span></button>`,`<button class="export-dropdown-item export-image-item" type="button">${i(`image`)}<span>${r(`msgFullscreen.exportImage`)}</span></button>`,`<button class="export-dropdown-item export-md-item" type="button">${i(`markdown`)}<span>${r(`msgFullscreen.exportMarkdown`)}</span></button>`].join(``),t.addEventListener(`click`,e=>{e.stopPropagation(),n.classList.toggle(`show`)});let a=(e,t)=>{let r=n.querySelector(e);r.addEventListener(`click`,async e=>{e.stopPropagation(),Dy&&(n.classList.remove(`show`),(await M(()=>import(`./chat-export-Co9I1mr6.js`),__vite__mapDeps([10,11,1,12,2,3,4,13,14,0])))[t](Dy,r,n))})};return a(`.export-docx-item`,`exportAssistantMessageToDocx`),a(`.export-pdf-item`,`exportAssistantMessageToPdf`),a(`.export-image-item`,`exportAssistantMessageToImage`),a(`.export-md-item`,`exportAssistantMessageToMarkdown`),e.appendChild(t),e.appendChild(n),e}function Yy(){if(document.getElementById(Ty))return;let e=document.getElementById(wy),t=e?e.parentNode:document.querySelector(`.message-fullscreen-actions`);t&&t.insertBefore(Jy(),e||null)}function Xy(){let e=document.getElementById(Ey);e&&e.classList.remove(`show`)}var Zy=!1;function Qy(){Zy||(Zy=!0,document.addEventListener(`click`,e=>{let t=document.getElementById(Ey);t&&t.classList.contains(`show`)&&!e.target.closest?.(`.message-fullscreen-export`)&&t.classList.remove(`show`);let n=e.target.closest?.(`.fullscreen-btn`);if(n){e.stopPropagation(),By(n.closest(`.message`));return}if(e.target.closest?.(`#messageFullscreenCloseBtn`)){e.stopPropagation(),zy();return}e.target.closest?.(`#messageFullscreenCopyBtn`)&&(e.stopPropagation(),Ky(e))},!0),document.addEventListener(`keydown`,Wy,!0),document.addEventListener(`dblclick`,Gy,!0))}var $y=t({copyAssistantMessage:()=>nb,copyMessage:()=>tb,copyRichText:()=>ab,fallbackCopyRichText:()=>sb,fallbackCopyText:()=>ib,quoteAndAsk:()=>ub,setQuoteContextInjector:()=>lb,showCopySuccess:()=>rb,wrapHtmlWithStyles:()=>ob});n(`zh`,{chatCopy:{copiedMarkdown:`已复制 Markdown`,copiedRich:`已复制富文本`,copyFailedManual:`复制失败,请手动复制`}}),n(`en`,{chatCopy:{copiedMarkdown:`Markdown copied`,copiedRich:`Rich text copied`,copyFailedManual:`Copy failed, please copy manually`}});function eb(e){let t=e.querySelectorAll(`.mermaid`),n=null;for(let e of t)try{if(!n&&e._pngDataUrl){let t=e._pngDataUrl.split(`,`)[1]||``,r=atob(t),i=r.length,a=new Uint8Array(i);for(let e=0;e<i;e++)a[e]=r.charCodeAt(e);n=new Blob([a],{type:`image/png`})}let t=e.getAttribute(`data-raw-code`),r=t?decodeURIComponent(t):e.dataset.rawMermaidCode||(e.textContent||``).trim();if(r){let t=r.split(`
|
|
1347
|
-
`),n=document.createElement(`pre`);n.appendChild(document.createTextNode(t[0]||``));for(let e=1;e<t.length;e++)n.appendChild(document.createElement(`br`)),n.appendChild(document.createTextNode(t[e]));e.parentNode.replaceChild(n,e)}else e.remove()}catch(t){a.warn(`[SidePanel] Mermaid chartprocessing failed,remove:`,t.message),e.remove()}return{html:e.innerHTML,firstPngBlob:n}}function
|
|
1353
|
+
`}).join(``),t.querySelectorAll(`img.favicon-img`).forEach(e=>{e.addEventListener(`error`,()=>{e.style.display=`none`})}),t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,t=>{let n=t.target.closest(`.page-action-btn`);if(n){t.stopPropagation(),by(parseInt(n.dataset.tabId),n.dataset.action);return}yy(parseInt(e.dataset.tabId))})})}function gy(e){e.forEach((e,t)=>{t===N.selectedPageIndex?(e.classList.add(`selected`),e.scrollIntoView({block:`nearest`})):e.classList.remove(`selected`)})}function _y(e){N.selectedPage={id:e.id,title:e.title||r(`pageSelector.noTitle`),url:e.url||``,favIconUrl:e.favIconUrl||``};let t=document.getElementById(`pageIndicator`),n=document.getElementById(`pageIndicatorName`);if(t&&n){let e=N.selectedPage.title&&N.selectedPage.title!==r(`pageSelector.noTitle`)?N.selectedPage.title:``,i=N.selectedPage.url||``;e&&i?n.textContent=`${e} · ${i}`:n.textContent=e||i,t.style.display=`flex`}}function vy(){N.selectedPage=null,N.selectedPageIndex=-1;let e=document.getElementById(`pageIndicator`);e&&(e.style.display=`none`)}function yy(e){let t=document.getElementById(`userInput`),n=t?t.value:``,r=n.lastIndexOf(`@`);r!==-1&&(t.value=n.substring(0,r)),t&&(t.focus(),t.selectionStart=t.selectionEnd=t.value.length),chrome.tabs.get(e,e=>{if(chrome.runtime.lastError||!e){a.error(`[PageSelector] getlabelpageinfo failed:`,chrome.runtime.lastError);return}_y(e),Nv(),t&&(t.focus(),Dt())})}function by(e,t){let n={interpret:r(`pageSelector.interpretMsg`),summarize:r(`pageSelector.summarizeMsg`),translate:r(`pageSelector.translateMsg`)}[t];n&&chrome.tabs.get(e,e=>{if(chrome.runtime.lastError||!e){a.error(`[PageSelector] get tab info failed:`,chrome.runtime.lastError);return}_y(e),Nv();let t=document.getElementById(`userInput`);t&&(t.value=n,Dt()),Vx()})}function xy(){let e=document.getElementById(`pageIndicatorClose`);e&&e.addEventListener(`click`,()=>{vy()})}n(`zh`,{msgFullscreen:{title:`全屏阅读`,btnTitle:`全屏查看本回答 (Alt+双击 / Alt+F)`,btnLabel:`全屏`,copy:`复制`,copyTitle:`复制回答内容(Ctrl/⌘+点击复制富文本)`,export:`导出`,exportTitle:`导出下载本回答`,exportWord:`导出 Word`,exportPdf:`导出 PDF`,exportImage:`导出图片`,exportMarkdown:`导出 Markdown`,close:`退出全屏`,closeTitle:`退出全屏 (Esc)`}}),n(`en`,{msgFullscreen:{title:`Fullscreen Reading`,btnTitle:`View this answer fullscreen (Alt+Double-click / Alt+F)`,btnLabel:`Fullscreen`,copy:`Copy`,copyTitle:`Copy answer (Ctrl/Cmd+click for rich text)`,export:`Export`,exportTitle:`Export / download this answer`,exportWord:`Export Word`,exportPdf:`Export PDF`,exportImage:`Export Image`,exportMarkdown:`Export Markdown`,close:`Exit fullscreen`,closeTitle:`Exit fullscreen (Esc)`}});var Sy=`messageFullscreenOverlay`,Cy=`messageFullscreenBody`,wy=`messageFullscreenTitle`,Ty=`messageFullscreenCopyBtn`,Ey=`messageFullscreenCloseBtn`,Dy=`messageFullscreenExportBtn`,Oy=`messageFullscreenExportDropdown`,ky=null,Ay=null,jy=null,My=!1,Ny=null,Py=!1;function Fy(){return ky!==null}function Iy(e){return!e||Fy()?null:e.innerHTML}function Ly(){let e=document.querySelectorAll(`#chatContainer .message.assistant`);return e.length?e[e.length-1]:null}function Ry(){let e=document.createElement(`button`);return e.className=`fullscreen-btn`,e.title=r(`msgFullscreen.btnTitle`),e.innerHTML=[`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" width="14" height="14">`,`<path d="M6 2H2v4M10 2h4v4M6 14H2v-4M10 14h4v-4"/>`,`</svg>`,`<span>${r(`msgFullscreen.btnLabel`)}</span>`].join(``),e}function zy(){let e=document.getElementById(Sy),t=document.getElementById(Cy);return!e||!t?(a.warn(`[MsgFullscreen] overlay/body element missing`),null):{overlay:e,body:t,title:document.getElementById(wy),copyBtn:document.getElementById(Ty),closeBtn:document.getElementById(Ey)}}function By(e){if(!e)return;let t=zy();if(t&&ky!==e){if(!ky){let e=document.getElementById(`chatContainer`);Ny=e?e.scrollTop:null}ky&&(Py=!0,Vy(),Py=!1),Ay=document.createComment(`msg-fullscreen-anchor`),e.parentNode.insertBefore(Ay,e),e.dataset.fullscreen=`1`,t.body.appendChild(e),ky=e,t.overlay.style.display=`flex`,document.body.classList.add(`message-fullscreen-viewing`),t.title&&(t.title.textContent=r(`msgFullscreen.title`)),t.copyBtn&&(t.copyBtn.title=r(`msgFullscreen.copyTitle`)),t.closeBtn&&(t.closeBtn.title=r(`msgFullscreen.closeTitle`)),Zy(),Uy(t.body)}}function Vy(){if(!ky)return;let e=zy();if(Gy(),Qy(),Ay&&Ay.parentNode)Ay.parentNode.insertBefore(ky,Ay);else if(e){let e=document.getElementById(`chatContainer`);e&&e.appendChild(ky)}if(Ay&&Ay.parentNode&&Ay.parentNode.removeChild(Ay),delete ky.dataset.fullscreen,ky=null,Ay=null,e){e.overlay.style.display=`none`,e.body.innerHTML=``;let t=e.overlay.querySelector(`.message-fullscreen-rail`);t&&t.querySelectorAll(`.message-toc-container`).forEach(e=>e.remove())}if(document.body.classList.remove(`message-fullscreen-viewing`),!Py&&Ny!==null){let e=document.getElementById(`chatContainer`);e&&(e.scrollTop=Ny),Ny=null}}function Hy(e){if(ky&&ky===e){Vy();return}By(e||Ly())}function Uy(e){Gy(),My=!1,e.scrollTop=e.scrollHeight,e.addEventListener(`scroll`,Wy,{passive:!0}),typeof ResizeObserver<`u`&&(jy=new ResizeObserver(()=>{My||(e.scrollTop=e.scrollHeight)}),jy.observe(e.firstElementChild||e))}function Wy(){let e=document.getElementById(Cy);e&&(My=e.scrollHeight-e.scrollTop-e.clientHeight>60)}function Gy(){let e=document.getElementById(Cy);e&&e.removeEventListener(`scroll`,Wy),jy&&=(jy.disconnect(),null)}function Ky(e){if(e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&e.code===`KeyF`){e.preventDefault(),ky?Vy():By(Ly());return}e.key===`Escape`&&ky&&(e.preventDefault(),e.stopImmediatePropagation(),Vy())}function qy(e){if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return;let t=e.target.closest?.(`#chatContainer .message.assistant`);t&&(e.preventDefault(),Hy(t))}async function Jy(e){if(!ky)return;let{copyAssistantMessage:t}=await M(async()=>{let{copyAssistantMessage:e}=await Promise.resolve().then(()=>tb);return{copyAssistantMessage:e}},void 0);t(ky,document.getElementById(Ty),e)}var Yy={docx:`<path d="M4 1.5h6L13 4.5v10H4z"/><path d="M10 1.5v3h3"/><path d="M6 8h4M6 10.5h4"/>`,pdf:`<path d="M4 1.5h6L13 4.5v10H4z"/><path d="M10 1.5v3h3"/><path d="M6.5 11.5c2-1 2.5-4 1-4s-1 4 2 4"/>`,image:`<rect x="2.5" y="3" width="11" height="10" rx="1.2"/><circle cx="6" cy="6.5" r="1"/><path d="M13.5 10 10 6.5 4.5 12.5"/>`,markdown:`<path d="M2.5 12V4l3 3 3-3v8"/><path d="M12.5 4v6m0 0 2-2.2m-2 2.2L10.5 7.8"/>`};function Xy(){let e=document.createElement(`div`);e.className=`message-fullscreen-export`;let t=document.createElement(`button`);t.className=`message-fullscreen-icon-btn`,t.id=Dy,t.type=`button`,t.title=r(`msgFullscreen.exportTitle`),t.innerHTML=[`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" width="16" height="16">`,`<path d="M8 2v8m0 0 3-3M8 10 5 7M2.5 13.5h11"/>`,`</svg>`,`<span>${r(`msgFullscreen.export`)}</span>`,`<svg class="dropdown-arrow" width="8" height="6" viewBox="0 0 8 6" fill="currentColor"><path d="M0 0l4 6 4-6z"/></svg>`].join(``);let n=document.createElement(`div`);n.className=`message-fullscreen-export-dropdown`,n.id=Oy;let i=e=>`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round">${Yy[e]}</svg>`;n.innerHTML=[`<button class="export-dropdown-item export-docx-item" type="button">${i(`docx`)}<span>${r(`msgFullscreen.exportWord`)}</span></button>`,`<button class="export-dropdown-item export-pdf-item" type="button">${i(`pdf`)}<span>${r(`msgFullscreen.exportPdf`)}</span></button>`,`<button class="export-dropdown-item export-image-item" type="button">${i(`image`)}<span>${r(`msgFullscreen.exportImage`)}</span></button>`,`<button class="export-dropdown-item export-md-item" type="button">${i(`markdown`)}<span>${r(`msgFullscreen.exportMarkdown`)}</span></button>`].join(``),t.addEventListener(`click`,e=>{e.stopPropagation(),n.classList.toggle(`show`)});let a=(e,t)=>{let r=n.querySelector(e);r.addEventListener(`click`,async e=>{e.stopPropagation(),ky&&(n.classList.remove(`show`),(await M(()=>import(`./chat-export-pxivPZ1I.js`),__vite__mapDeps([10,11,1,12,2,3,4,13,14,0])))[t](ky,r,n))})};return a(`.export-docx-item`,`exportAssistantMessageToDocx`),a(`.export-pdf-item`,`exportAssistantMessageToPdf`),a(`.export-image-item`,`exportAssistantMessageToImage`),a(`.export-md-item`,`exportAssistantMessageToMarkdown`),e.appendChild(t),e.appendChild(n),e}function Zy(){if(document.getElementById(Dy))return;let e=document.getElementById(Ey),t=e?e.parentNode:document.querySelector(`.message-fullscreen-actions`);t&&t.insertBefore(Xy(),e||null)}function Qy(){let e=document.getElementById(Oy);e&&e.classList.remove(`show`)}var $y=!1;function eb(){$y||($y=!0,document.addEventListener(`click`,e=>{let t=document.getElementById(Oy);t&&t.classList.contains(`show`)&&!e.target.closest?.(`.message-fullscreen-export`)&&t.classList.remove(`show`);let n=e.target.closest?.(`.fullscreen-btn`);if(n){e.stopPropagation(),Hy(n.closest(`.message`));return}if(e.target.closest?.(`#messageFullscreenCloseBtn`)){e.stopPropagation(),Vy();return}e.target.closest?.(`#messageFullscreenCopyBtn`)&&(e.stopPropagation(),Jy(e))},!0),document.addEventListener(`keydown`,Ky,!0),document.addEventListener(`dblclick`,qy,!0))}var tb=t({copyAssistantMessage:()=>ib,copyMessage:()=>rb,copyRichText:()=>sb,fallbackCopyRichText:()=>lb,fallbackCopyText:()=>ob,quoteAndAsk:()=>fb,setQuoteContextInjector:()=>db,showCopySuccess:()=>ab,wrapHtmlWithStyles:()=>cb});n(`zh`,{chatCopy:{copiedMarkdown:`已复制 Markdown`,copiedRich:`已复制富文本`,copyFailedManual:`复制失败,请手动复制`}}),n(`en`,{chatCopy:{copiedMarkdown:`Markdown copied`,copiedRich:`Rich text copied`,copyFailedManual:`Copy failed, please copy manually`}});function nb(e){let t=e.querySelectorAll(`.mermaid`),n=null;for(let e of t)try{if(!n&&e._pngDataUrl){let t=e._pngDataUrl.split(`,`)[1]||``,r=atob(t),i=r.length,a=new Uint8Array(i);for(let e=0;e<i;e++)a[e]=r.charCodeAt(e);n=new Blob([a],{type:`image/png`})}let t=e.getAttribute(`data-raw-code`),r=t?decodeURIComponent(t):e.dataset.rawMermaidCode||(e.textContent||``).trim();if(r){let t=r.split(`
|
|
1354
|
+
`),n=document.createElement(`pre`);n.appendChild(document.createTextNode(t[0]||``));for(let e=1;e<t.length;e++)n.appendChild(document.createElement(`br`)),n.appendChild(document.createTextNode(t[e]));e.parentNode.replaceChild(n,e)}else e.remove()}catch(t){a.warn(`[SidePanel] Mermaid chartprocessing failed,remove:`,t.message),e.remove()}return{html:e.innerHTML,firstPngBlob:n}}function rb(e,t){try{let n=e.dataset.textContent_||e.dataset.rawContent||``;navigator.clipboard.writeText(n).then(()=>{let e=t.innerHTML;t.innerHTML=`
|
|
1348
1355
|
<svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor">
|
|
1349
1356
|
<path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.75.75 0 0 1 1.06-1.06L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0z"/>
|
|
1350
1357
|
</svg>
|
|
@@ -1352,12 +1359,12 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1352
1359
|
<svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor">
|
|
1353
1360
|
<path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.75.75 0 0 1 1.06-1.06L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0z"/>
|
|
1354
1361
|
</svg>
|
|
1355
|
-
`,t.classList.add(`copied`),setTimeout(()=>{t.innerHTML=e,t.classList.remove(`copied`)},2e3)}catch{P(r(`chatCopy.copyFailed`),`error`)}document.body.removeChild(i)})}catch(e){a.error(`[SidePanel] copy failed:`,e),P(r(`chatCopy.copyFailed`),`error`)}}function
|
|
1362
|
+
`,t.classList.add(`copied`),setTimeout(()=>{t.innerHTML=e,t.classList.remove(`copied`)},2e3)}catch{P(r(`chatCopy.copyFailed`),`error`)}document.body.removeChild(i)})}catch(e){a.error(`[SidePanel] copy failed:`,e),P(r(`chatCopy.copyFailed`),`error`)}}function ib(e,t,n){try{let r=e.dataset.rawMarkdown||e.dataset.rawContent||``,i=``;if(!r){let t=N.messageHistory.find(e=>e.role===`assistant`);if(t)r=t.content;else{let t=e.querySelector(`.final-answer .markdown-body`)||e.querySelector(`.markdown-body`);t?(r=t.innerText,i=t.innerHTML):(r=e.innerText,i=e.innerHTML)}}if(!i){let t=e.querySelector(`.final-answer .markdown-body`)||e.querySelector(`.markdown-body`);t?i=t.innerHTML:r&&(i=Kt(r))}if(n&&(n.ctrlKey||n.metaKey)&&i){let e=document.createElement(`div`);e.innerHTML=i,e.querySelectorAll(`table`).forEach(e=>{let t=Ut(e);e.parentNode.replaceChild(t,e)});let{html:n,firstPngBlob:a}=nb(e);sb(r,n,t,a)}else navigator.clipboard.writeText(r).then(()=>{t&&ab(t)}).catch(()=>{ob(r,t)})}catch(e){a.error(`[SidePanel] copy failed:`,e),P(r(`chatCopy.copyFailed`),`error`)}}function ab(e,t=!1){let n=e.innerHTML;e.innerHTML=`
|
|
1356
1363
|
<svg viewBox="0 0 16 16" fill="currentColor">
|
|
1357
1364
|
<path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.75.75 0 0 1 1.06-1.06L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0z"/>
|
|
1358
1365
|
</svg>
|
|
1359
1366
|
<span>${r(t?`chatCopy.copiedRich`:`chatCopy.copiedMarkdown`)}</span>
|
|
1360
|
-
`,e.classList.add(`copied`),setTimeout(()=>{e.innerHTML=n,e.classList.remove(`copied`)},2e3)}function
|
|
1367
|
+
`,e.classList.add(`copied`),setTimeout(()=>{e.innerHTML=n,e.classList.remove(`copied`)},2e3)}function ob(e,t){let n=document.createElement(`textarea`);n.value=e,n.style.position=`fixed`,n.style.left=`-999999px`,document.body.appendChild(n),n.select();try{document.execCommand(`copy`),ab(t)}catch{P(r(`chatCopy.copyFailedManual`),`error`)}document.body.removeChild(n)}function sb(e,t,n,r=null){let i=cb(t);if(n&&!document.hasFocus()&&n.focus(),typeof ClipboardItem<`u`){let t={"text/plain":new Blob([e],{type:`text/plain`}),"text/html":new Blob([i],{type:`text/html`})};r&&(t[`image/png`]=r);let o=new ClipboardItem(t);navigator.clipboard.write([o]).then(()=>{ab(n,!0)}).catch(t=>{a.warn(`[SidePanel] Clipboard API write failed,using fallback plan:`,t.message),lb(e,i,n)})}else lb(e,i,n)}function cb(e){return`<!DOCTYPE html><html><head>
|
|
1361
1368
|
<style>
|
|
1362
1369
|
h1 { font-size: 24px; font-weight: bold; margin: 16px 0 8px; }
|
|
1363
1370
|
h2 { font-size: 20px; font-weight: bold; margin: 14px 0 6px; }
|
|
@@ -1396,12 +1403,12 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1396
1403
|
a { color: #007bff; text-decoration: underline; }
|
|
1397
1404
|
img { max-width: 100%; }
|
|
1398
1405
|
</style>
|
|
1399
|
-
</head><body>${e}</body></html>`}function
|
|
1406
|
+
</head><body>${e}</body></html>`}function lb(e,t,n){n&&!document.hasFocus()&&n.focus();let r=document.createElement(`div`);r.style.position=`fixed`,r.style.left=`-999999px`,r.style.top=`-999999px`,r.innerHTML=t,document.body.appendChild(r);let i=document.createRange();i.selectNodeContents(r);let a=window.getSelection();a.removeAllRanges(),a.addRange(i);try{document.execCommand(`copy`),ab(n,!0)}catch{ob(e,n)}finally{a.removeAllRanges(),document.body.removeChild(r)}}var ub=null;function db(e){ub=e}function fb(e){try{let t=e.dataset.rawMarkdown||e.dataset.rawContent||``;if(!t){a.warn(`[SidePanel] unable to getmessagecontent`);return}let n=document.getElementById(`userInput`);if(!n){a.warn(`[SidePanel] cannot find input box`);return}let i=e.querySelector(`.quote-btn`),o=i?i.innerHTML:``;ub&&ub(t),i&&(i.innerHTML=`
|
|
1400
1407
|
<svg viewBox="0 0 16 16" fill="currentColor">
|
|
1401
1408
|
<path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.75.75 0 0 1 1.06-1.06L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0z"/>
|
|
1402
1409
|
</svg>
|
|
1403
1410
|
<span>${r(`chatCopy.quoted`)}</span>
|
|
1404
|
-
`,i.classList.add(`quoted`),setTimeout(()=>{i.innerHTML=o,i.classList.remove(`quoted`)},2e3)),n.focus(),a.debug(`[SidePanel] quote with messagecontent to prompt,input boxfocused`)}catch(e){a.error(`[SidePanel] quoted question failed:`,e),P(r(`chatCopy.quoteFailed`,{message:e.message}),`error`)}}n(`zh`,{chatPanels:{decisionPassed:`通过`,decisionRevised:`已修订`,decisionNeedsImprovement:`需改进`,dimAccuracy:`准确性`,dimCompleteness:`完整性`,dimRelevance:`相关性`,dimClarity:`清晰度`,dimUsefulness:`实用性`,dimSafety:`安全性`,dimEfficiency:`效率`,dimensionsTitle:`📊 评分维度`,issuesTitle:`❗ 发现的问题`,suggestionsTitle:`💡 改进建议`,roundsEvaluated:`评估 {rounds} 轮{revised}`,revisedTag:`(已修订)`,finalDecision:`最终决策:{label}`,resultUseful:`结果可用`,resultNeedsImprovement:`结果需改进`,processTitle:`🔄 评估过程`,scoreHighExplanation:`回答质量较高,内容准确、完整且清晰。`,scoreMidExplanation:`回答基本可用,但存在一些可以改进的地方。`,scoreLowExplanation:`回答质量较低,存在明显问题需要改进。`,reflectionTitle:`💡 质量评估详情`,overallScore:`综合评分`,scoreExplanationTitle:`📝 评分说明`,aboutTitle:`ℹ️ 关于质量评估`,aboutDesc:`质量评估由 AI 自动完成,从多个维度对回答进行打分,帮助判断回答的可靠程度。`,scoreStandard:`评分标准:8-10 分优秀,5-7 分良好,1-4 分需改进。`,executionLogTitle:`执行日志`,taskBreakdown:`任务拆解`,totalDurationTitle:`总耗时:{duration}`,totalDuration:`总耗时`,totalNodesTitle:`共 {count} 个执行节点`,totalNodes:`执行节点`,successCountTitle:`成功 {count} 个`,successLabel:`成功`,failedCountTitle:`失败 {count} 个`,failedLabel:`失败`,subtaskCountTitle:`子任务 {completed}/{total} 完成`,subtaskLabel:`子任务`,scoreTitle:`评分 {score}/10`,scoreLabel:`评分`,scoreUnavailable:`—`,tokenUsage:`Token 消耗`,tokenUsageTitle:`Token 消耗: {total} (Prompt: {prompt}, Completion: {completion})`,expandAll:`展开全部`,collapseAll:`收起全部`}}),n(`en`,{chatPanels:{decisionPassed:`Passed`,decisionRevised:`Revised`,decisionNeedsImprovement:`Needs Improvement`,dimAccuracy:`Accuracy`,dimCompleteness:`Completeness`,dimRelevance:`Relevance`,dimClarity:`Clarity`,dimUsefulness:`Usefulness`,dimSafety:`Safety`,dimEfficiency:`Efficiency`,dimensionsTitle:`📊 Scoring Dimensions`,issuesTitle:`❗ Issues Found`,suggestionsTitle:`💡 Suggestions`,roundsEvaluated:`Evaluated {rounds} rounds{revised}`,revisedTag:` (revised)`,finalDecision:`Final Decision: {label}`,resultUseful:`Result is useful`,resultNeedsImprovement:`Result needs improvement`,processTitle:`🔄 Evaluation Process`,scoreHighExplanation:`The answer is high quality, accurate, complete, and clear.`,scoreMidExplanation:`The answer is generally usable but has room for improvement.`,scoreLowExplanation:`The answer is low quality with obvious issues that need improvement.`,reflectionTitle:`💡 Quality Assessment Details`,overallScore:`Overall Score`,scoreExplanationTitle:`📝 Score Explanation`,aboutTitle:`ℹ️ About Quality Assessment`,aboutDesc:`Quality assessment is performed automatically by AI, scoring answers across multiple dimensions to help judge reliability.`,scoreStandard:`Scoring: 8-10 excellent, 5-7 good, 1-4 needs improvement.`,executionLogTitle:`Execution Log`,taskBreakdown:`Task Breakdown`,totalDurationTitle:`Total duration: {duration}`,totalDuration:`Duration`,totalNodesTitle:`{count} execution nodes`,totalNodes:`Nodes`,successCountTitle:`{count} succeeded`,successLabel:`Success`,failedCountTitle:`{count} failed`,failedLabel:`Failed`,subtaskCountTitle:`Subtasks {completed}/{total} done`,subtaskLabel:`Subtasks`,scoreTitle:`Score {score}/10`,scoreLabel:`Score`,scoreUnavailable:`—`,tokenUsage:`Token Usage`,tokenUsageTitle:`Token usage: {total} (Prompt: {prompt}, Completion: {completion})`,expandAll:`Expand All`,collapseAll:`Collapse All`}});function
|
|
1411
|
+
`,i.classList.add(`quoted`),setTimeout(()=>{i.innerHTML=o,i.classList.remove(`quoted`)},2e3)),n.focus(),a.debug(`[SidePanel] quote with messagecontent to prompt,input boxfocused`)}catch(e){a.error(`[SidePanel] quoted question failed:`,e),P(r(`chatCopy.quoteFailed`,{message:e.message}),`error`)}}n(`zh`,{chatPanels:{decisionPassed:`通过`,decisionRevised:`已修订`,decisionNeedsImprovement:`需改进`,dimAccuracy:`准确性`,dimCompleteness:`完整性`,dimRelevance:`相关性`,dimClarity:`清晰度`,dimUsefulness:`实用性`,dimSafety:`安全性`,dimEfficiency:`效率`,dimensionsTitle:`📊 评分维度`,issuesTitle:`❗ 发现的问题`,suggestionsTitle:`💡 改进建议`,roundsEvaluated:`评估 {rounds} 轮{revised}`,revisedTag:`(已修订)`,finalDecision:`最终决策:{label}`,resultUseful:`结果可用`,resultNeedsImprovement:`结果需改进`,processTitle:`🔄 评估过程`,scoreHighExplanation:`回答质量较高,内容准确、完整且清晰。`,scoreMidExplanation:`回答基本可用,但存在一些可以改进的地方。`,scoreLowExplanation:`回答质量较低,存在明显问题需要改进。`,reflectionTitle:`💡 质量评估详情`,overallScore:`综合评分`,scoreExplanationTitle:`📝 评分说明`,aboutTitle:`ℹ️ 关于质量评估`,aboutDesc:`质量评估由 AI 自动完成,从多个维度对回答进行打分,帮助判断回答的可靠程度。`,scoreStandard:`评分标准:8-10 分优秀,5-7 分良好,1-4 分需改进。`,executionLogTitle:`执行日志`,taskBreakdown:`任务拆解`,totalDurationTitle:`总耗时:{duration}`,totalDuration:`总耗时`,totalNodesTitle:`共 {count} 个执行节点`,totalNodes:`执行节点`,successCountTitle:`成功 {count} 个`,successLabel:`成功`,failedCountTitle:`失败 {count} 个`,failedLabel:`失败`,subtaskCountTitle:`子任务 {completed}/{total} 完成`,subtaskLabel:`子任务`,scoreTitle:`评分 {score}/10`,scoreLabel:`评分`,scoreUnavailable:`—`,tokenUsage:`Token 消耗`,tokenUsageTitle:`Token 消耗: {total} (Prompt: {prompt}, Completion: {completion})`,expandAll:`展开全部`,collapseAll:`收起全部`}}),n(`en`,{chatPanels:{decisionPassed:`Passed`,decisionRevised:`Revised`,decisionNeedsImprovement:`Needs Improvement`,dimAccuracy:`Accuracy`,dimCompleteness:`Completeness`,dimRelevance:`Relevance`,dimClarity:`Clarity`,dimUsefulness:`Usefulness`,dimSafety:`Safety`,dimEfficiency:`Efficiency`,dimensionsTitle:`📊 Scoring Dimensions`,issuesTitle:`❗ Issues Found`,suggestionsTitle:`💡 Suggestions`,roundsEvaluated:`Evaluated {rounds} rounds{revised}`,revisedTag:` (revised)`,finalDecision:`Final Decision: {label}`,resultUseful:`Result is useful`,resultNeedsImprovement:`Result needs improvement`,processTitle:`🔄 Evaluation Process`,scoreHighExplanation:`The answer is high quality, accurate, complete, and clear.`,scoreMidExplanation:`The answer is generally usable but has room for improvement.`,scoreLowExplanation:`The answer is low quality with obvious issues that need improvement.`,reflectionTitle:`💡 Quality Assessment Details`,overallScore:`Overall Score`,scoreExplanationTitle:`📝 Score Explanation`,aboutTitle:`ℹ️ About Quality Assessment`,aboutDesc:`Quality assessment is performed automatically by AI, scoring answers across multiple dimensions to help judge reliability.`,scoreStandard:`Scoring: 8-10 excellent, 5-7 good, 1-4 needs improvement.`,executionLogTitle:`Execution Log`,taskBreakdown:`Task Breakdown`,totalDurationTitle:`Total duration: {duration}`,totalDuration:`Duration`,totalNodesTitle:`{count} execution nodes`,totalNodes:`Nodes`,successCountTitle:`{count} succeeded`,successLabel:`Success`,failedCountTitle:`{count} failed`,failedLabel:`Failed`,subtaskCountTitle:`Subtasks {completed}/{total} done`,subtaskLabel:`Subtasks`,scoreTitle:`Score {score}/10`,scoreLabel:`Score`,scoreUnavailable:`—`,tokenUsage:`Token Usage`,tokenUsageTitle:`Token usage: {total} (Prompt: {prompt}, Completion: {completion})`,expandAll:`Expand All`,collapseAll:`Collapse All`}});function pb(e,t){let n=document.querySelector(`.reflection-info-overlay`);n&&n.remove();let i=document.createElement(`div`);i.className=`reflection-info-overlay`;let{overallScore:a,dimensions:o,issues:s,suggestions:c,decision:l,useful:u,reasoning:d,suggestion:f,rounds:p,wasRevised:m}=e,h=a>=8?`score-high`:a>=5?`score-mid`:`score-low`,g=a>=8?`✅`:a>=5?`🔍`:`⚠️`,_=l===`passed`?r(`chatPanels.decisionPassed`):l===`revised`?r(`chatPanels.decisionRevised`):l===`needs_improvement`?r(`chatPanels.decisionNeedsImprovement`):``,v={accuracy:r(`chatPanels.dimAccuracy`),completeness:r(`chatPanels.dimCompleteness`),relevance:r(`chatPanels.dimRelevance`),clarity:r(`chatPanels.dimClarity`),usefulness:r(`chatPanels.dimUsefulness`),safety:r(`chatPanels.dimSafety`),efficiency:r(`chatPanels.dimEfficiency`)},y=``;o&&Object.keys(o).length>0&&(y=`
|
|
1405
1412
|
<div class="ri-section">
|
|
1406
1413
|
<div class="ri-section-title">${r(`chatPanels.dimensionsTitle`)}</div>
|
|
1407
1414
|
<div class="ri-dimensions">
|
|
@@ -1456,7 +1463,7 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1456
1463
|
</div>
|
|
1457
1464
|
</div>
|
|
1458
1465
|
</div>
|
|
1459
|
-
`,document.body.appendChild(i),i.querySelector(`.ri-close`).addEventListener(`click`,()=>i.remove()),i.addEventListener(`click`,e=>{e.target===i&&i.remove()});let w=t.getBoundingClientRect(),T=i.querySelector(`.reflection-info-panel`),E=Math.min(window.innerHeight-40,560),D=w.right-380;D<10&&(D=10),D+380>window.innerWidth-10&&(D=window.innerWidth-380-10);let O=w.bottom+6;O+E>window.innerHeight-10&&(O=w.top-E-6),O<10&&(O=10),T.style.left=D+`px`,T.style.top=O+`px`,T.style.maxHeight=E+`px`}function
|
|
1466
|
+
`,document.body.appendChild(i),i.querySelector(`.ri-close`).addEventListener(`click`,()=>i.remove()),i.addEventListener(`click`,e=>{e.target===i&&i.remove()});let w=t.getBoundingClientRect(),T=i.querySelector(`.reflection-info-panel`),E=Math.min(window.innerHeight-40,560),D=w.right-380;D<10&&(D=10),D+380>window.innerWidth-10&&(D=window.innerWidth-380-10);let O=w.bottom+6;O+E>window.innerHeight-10&&(O=w.top-E-6),O<10&&(O=10),T.style.left=D+`px`,T.style.top=O+`px`,T.style.maxHeight=E+`px`}function mb(e){let t=document.querySelector(`.execution-log-panel`);t&&t.remove();let n=document.createElement(`div`);n.className=`execution-log-panel`;let i=e.reduce((e,t)=>e+(t.duration||0),0),a=e.filter(e=>e.status===`success`).length,o=e.filter(e=>e.status===`failed`).length,s=e.filter(e=>e.nodeType===`subtask`).length,c=e.filter(e=>e.nodeType===`subtask`&&e.status===`success`).length,l=e.filter(e=>e.nodeType===`tool_exec`&&e.action?.name===`plan_task`&&e.status===`success`).length,u=e.filter(e=>e.nodeType===`reflection`).find(e=>e.reflectionType===`post`),d=u&&u.overallScore!=null?`${u.overallScore}/10`:r(`chatPanels.scoreUnavailable`),f=wt(e);n.innerHTML=`
|
|
1460
1467
|
<div class="log-container">
|
|
1461
1468
|
<div class="log-header">
|
|
1462
1469
|
<div class="log-title">
|
|
@@ -1538,11 +1545,11 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1538
1545
|
${fd(e)}
|
|
1539
1546
|
</div>
|
|
1540
1547
|
</div>
|
|
1541
|
-
`,document.body.appendChild(n),ad(n),n.addEventListener(`click`,e=>{e.target===n&&n.remove()}),n.querySelector(`.log-close`).addEventListener(`click`,()=>{n.remove()});let p=n.querySelector(`.toggle-expand-btn`),m=n.querySelectorAll(`.timeline-content`),h=!1;p.addEventListener(`click`,()=>{h=!h,m.forEach(e=>{h?e.classList.add(`expanded`):e.classList.remove(`expanded`)});let e=p.querySelector(`svg`);h?(e.innerHTML=`<polyline points="17 11 12 6 7 11"></polyline><polyline points="17 18 12 13 7 18"></polyline>`,p.setAttribute(`title`,r(`chatPanels.collapseAll`))):(e.innerHTML=`<polyline points="7 13 12 18 17 13"></polyline><polyline points="7 6 12 11 17 6"></polyline>`,p.setAttribute(`title`,r(`chatPanels.expandAll`)))}),n.querySelectorAll(`.timeline-header`).forEach(e=>{e.addEventListener(`click`,()=>{e.parentElement.classList.toggle(`expanded`)})}),n.querySelectorAll(`.task-group-header`).forEach(e=>{e.addEventListener(`click`,()=>{e.parentElement.classList.toggle(`collapsed`)})});let g=n.querySelectorAll(`.combo-stat`),_=n.querySelectorAll(`.timeline-item`);g.forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.status,n=e.classList.contains(`active`);g.forEach(e=>e.classList.remove(`active`)),n?_.forEach(e=>{e.style.display=``}):(e.classList.add(`active`),_.forEach(e=>{if(t===`subtask`)e.classList.contains(`subtask-level`)?e.style.display=``:e.style.display=`none`;else{let n=e.querySelector(`.timeline-dot`);n&&n.classList.contains(t)?e.style.display=``:e.style.display=`none`}}))})})}n(`zh`,{chatResume:{title:`继续执行任务`,desc:`任务执行被中断,你可以提供补充说明帮助模型继续。`,placeholder:`输入补充说明(可选)…`,continueBtn:`继续`,interruptedAgo:`({duration}前)`,taskInterrupted:`任务执行被中断{elapsed}`,checkpointNotFound:`检查点已失效,无法继续执行。请重新发送任务。`,taskCancelled:`任务已被用户停止`,swRestarted:`Service Worker 已重启,请重新发送任务`,resumeFailed:`恢复失败:{message}`,unknownError:`未知错误`}}),n(`en`,{chatResume:{title:`Continue Task`,desc:`The task was interrupted. You can provide additional guidance to help the model continue.`,placeholder:`Enter additional guidance (optional)…`,continueBtn:`Continue`,interruptedAgo:` ({duration} ago)`,taskInterrupted:`Task execution was interrupted{elapsed}`,checkpointNotFound:`The checkpoint has expired and the task cannot be resumed. Please resend the task.`,taskCancelled:`Task was stopped by user`,swRestarted:`Service Worker restarted. Please resend the task.`,resumeFailed:`Resume failed: {message}`,unknownError:`Unknown error`}});function pb(){return new Promise(e=>{let t=document.createElement(`div`);t.className=`modal-overlay resume-dialog-overlay`,t.style.cssText=`display:flex;position:fixed;inset:0;background:var(--scrim);z-index:10000;align-items:center;justify-content:center;`;let n=document.createElement(`div`);n.className=`modal-container resume-dialog-container`,n.style.cssText=`background:var(--bg-surface);border-radius:8px;padding:24px;width:90%;max-width:480px;box-shadow:0 8px 32px var(--shadow-md);`;let i=document.createElement(`h3`);i.textContent=r(`chatResume.title`),i.style.cssText=`margin:0 0 8px 0;font-size:16px;color:var(--text-primary);`;let a=document.createElement(`p`);a.textContent=r(`chatResume.desc`),a.style.cssText=`margin:0 0 16px 0;font-size:13px;color:var(--text-secondary);line-height:1.5;`;let o=document.createElement(`textarea`);o.className=`resume-dialog-textarea`,o.placeholder=r(`chatResume.placeholder`),o.style.cssText=`width:100%;min-height:80px;padding:8px 12px;border:1px solid var(--border-default);border-radius:4px;font-size:13px;resize:vertical;box-sizing:border-box;font-family:inherit;line-height:1.5;`,o.rows=3;let s=document.createElement(`div`);s.style.cssText=`display:flex;justify-content:flex-end;gap:8px;margin-top:16px;`;let c=document.createElement(`button`);c.textContent=r(`common.cancel`),c.style.cssText=`padding:6px 16px;border:1px solid var(--border-default);background:var(--bg-surface);color:var(--text-secondary);border-radius:4px;cursor:pointer;font-size:13px;`;let l=document.createElement(`button`);l.textContent=r(`chatResume.continueBtn`),l.style.cssText=`padding:6px 16px;border:none;background:var(--info-500);color:var(--text-inverse);border-radius:4px;cursor:pointer;font-size:13px;font-weight:500;`,s.appendChild(c),s.appendChild(l),n.appendChild(i),n.appendChild(a),n.appendChild(o),n.appendChild(s),t.appendChild(n),document.body.appendChild(t),requestAnimationFrame(()=>o.focus());let u=()=>{t.remove(),document.removeEventListener(`keydown`,d)},d=t=>{t.key===`Escape`?(u(),e(null)):t.key===`Enter`&&(t.ctrlKey||t.metaKey)&&(u(),e(o.value.trim()))};c.addEventListener(`click`,()=>{u(),e(null)}),l.addEventListener(`click`,()=>{u(),e(o.value.trim())}),document.addEventListener(`keydown`,d)})}function mb(e){if(!e)return;let t=!1;for(let e of N.messageHistory)e.resumable&&(e.resumable=!1,t=!0);let n=document.getElementById(`chatContainer`);n&&n.querySelectorAll(`.message[data-resumable="true"]`).forEach(e=>{e.removeAttribute(`data-resumable`);let t=e.querySelector(`.resume-task-btn`);t&&t.remove()}),t&&gx()}async function hb(e,t){if(!(!e||!t))try{if(!(await chrome.runtime.sendMessage({type:`GET_CHECKPOINT`,sessionId:t}))?.exists){e.removeAttribute(`data-resumable`);let t=e.querySelector(`.resume-task-btn`);t&&t.remove();let n=e.dataset.messageId,r=N.messageHistory.find(e=>e.messageId===n);r&&r.resumable&&(r.resumable=!1,gx())}}catch{}}async function gb(){let e=N.activeSessionId;if(!e||N.pendingCallApiSessionIds&&N.pendingCallApiSessionIds.has(e))return;let t=N.messageHistory.some(e=>e.resumable),n=document.getElementById(`chatContainer`),i=n&&n.querySelector(`.resume-task-btn`);if(!(t&&i))try{let i=await chrome.runtime.sendMessage({type:`GET_CHECKPOINT`,sessionId:e});if(i?.exists){a.debug(`[SidePanel] found abandoned checkpoint,auto addrestorehint card`),document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:e}}));let o=i.checkpoint,s=o.updatedAt?vt(Date.now()-o.updatedAt):``,c=r(`chatResume.taskInterrupted`,{elapsed:s?r(`chatResume.interruptedAgo`,{duration:s}):``});if(t){let e=N.messageHistory.find(e=>e.resumable);if(e&&(e.content=c,gx()),n){let e=n.querySelector(`.message[data-resumable="true"]`);if(!e){let t=n.querySelectorAll(`.message.assistant`);for(let n of t)if((n.textContent||``).includes(`任务执行被中断`)){e=n;break}}e&&e.remove()}}let{element:l,messageId:u}=Gx(`assistant`,c,!0,[],null,!1,null,null,[],!0);t||(N.messageHistory.push({role:`assistant`,content:c,executionLog:[],messageId:u,resumable:!0,interrupted:!0}),gx()),hb(l,e)}}catch(e){a.warn(`[SidePanel] check abandoned checkpoint failed:`,e.message)}}async function _b(e,t=``){if(!e)return a.warn(`[SidePanel] resumeTask: missing sessionId`),!1;if(N.activeSessionId!==e)return a.warn(`[SidePanel] resumeTask: currently activesessionwith targetsession not consistent,please switch firstto targetsession`),!1;if(N.pendingCallApiSessionIds&&N.pendingCallApiSessionIds.has(e))return a.warn(`[SidePanel] resumeTask: currentsession has ongoingtask`),!1;a.debug(`[SidePanel] resumeTask: startrestoretask, sessionId:`,e,`userGuidance:`,t?`"${t.substring(0,50)}..."`:`( no )`);try{let t=await chrome.runtime.sendMessage({type:`GET_CHECKPOINT`,sessionId:e});if(!t?.exists){a.warn(`[SidePanel] resumeTask: checkpoint not found, no way to restore, sessionId:`,e);let t=r(`chatResume.checkpointNotFound`),{messageId:n}=Gx(`assistant`,t,!0,[]);return N.messageHistory.push({role:`assistant`,content:t,executionLog:[],messageId:n,resumable:!1,resumed:!0}),gx(),mb(e),!1}a.debug(`[SidePanel] resumeTask: checkpoint verified, iteration:`,t.checkpoint?.iteration)}catch(e){a.warn(`[SidePanel] resumeTask: verify checkpoint hourcommunication failed,continue tryrestore:`,e.message)}let n=e,i=Zx();N.isGenerating=!0;let o=``,s=[],c=null,l=!1,u=!1,d=null,f=null;try{let e=await oS(null,null,!1,{},{resumeFromCheckpoint:!0,userGuidance:t,loadingId:i});o=e.content,s=e.executionLog||[],c=e.reflectionScore,l=e.wasRevised||!1,u=e.wasStreamed||!1,d=e.streamingHtml||null,e.streamingConnected!==void 0&&e.streamingConnected,f=e.streamingMsgId||null}catch(e){if(N.activeSessionId!==n){let t=!!e.checkpoint||e.swRestarted||e.message===`任务已被用户停止`;return e.message===`任务已被用户停止`?Di(n,{role:`assistant`,content:r(`chatResume.taskCancelled`),executionLog:e.executionLog||[],resumable:t,resumed:!0}):e.swRestarted?Di(n,{role:`assistant`,content:r(`chatResume.swRestarted`),executionLog:e.executionLog||[],resumable:t,resumed:!0}):Di(n,{role:`assistant`,content:r(`chatResume.resumeFailed`,{message:e.message||r(`chatResume.unknownError`)}),executionLog:e.executionLog||[],resumable:!1,resumed:!0}),document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:n}})),Qx(i),!1}if(e.message===`任务已被用户停止`){Qx(i);let{messageId:t}=Gx(`assistant`,r(`chatResume.taskCancelled`),!1,e.executionLog||[]);return N.messageHistory.push({role:`assistant`,content:r(`chatResume.taskCancelled`),executionLog:e.executionLog||[],messageId:t,resumable:!0,resumed:!0}),gx(),!1}if(e.swRestarted){Qx(i);let t=!!e.checkpoint,{messageId:n}=Gx(`assistant`,r(`chatResume.swRestarted`),!1,e.executionLog||[]);return N.messageHistory.push({role:`assistant`,content:r(`chatResume.swRestarted`),executionLog:e.executionLog||[],messageId:n,resumable:t,resumed:!0}),gx(),!1}Qx(i);let t=r(`chatResume.resumeFailed`,{message:e.message||r(`chatResume.unknownError`)}),{element:a,messageId:o}=Gx(`assistant`,t,!0,e.executionLog||[]);return N.messageHistory.push({role:`assistant`,content:t,executionLog:e.executionLog||[],messageId:o,resumable:!1,resumed:!0}),gx(),!1}finally{Bc(n)}if(mb(n),N.activeSessionId!==n){let e={role:`assistant`,content:o,executionLog:s,reflectionScore:c,wasRevised:l,resumed:!0};return u&&d&&(e.htmlContent=d),Di(n,e),document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:n}})),Qx(i),!0}if(u&&d){let e=f;return N.messageHistory.push({role:`assistant`,content:o,executionLog:s,reflectionScore:c,wasRevised:l,messageId:e,resumed:!0,htmlContent:d}),gx(),!0}Qx(i);let{element:p,messageId:m}=Gx(`assistant`,o,!0,s,c,l);return N.messageHistory.push({role:`assistant`,content:o,executionLog:s,reflectionScore:c,wasRevised:l,messageId:m,resumed:!0}),gx(),p&&Jt(p),!0}var vb=t({addStreamingMessage:()=>Jb,appendToolCallItems:()=>Zb,appendToolResult:()=>$b,autoScrollToBottom:()=>Eb,bindProcessHeaderClick:()=>Mb,cancelStreamingTask:()=>nx,createCodeBlockHtml:()=>Qb,createPreSelectCard:()=>ex,createStreamingElementAccessor:()=>Bb,deleteStreamingState:()=>Vb,finalizeCancelledStream:()=>rx,finalizeStreamingMessage:()=>tx,getPendingPreselectLog:()=>Ub,initScrollToBottomBtn:()=>kb,notifyNonStreamContentArrived:()=>Ab,reconnectStreamingElement:()=>Yb,refreshAgentNames:()=>Nb,resetScrollState:()=>Ob,scrollStreamingToBottom:()=>Db,setPendingPreselectLog:()=>Wb,setProcessStartTime:()=>Kb,setReasoningContent:()=>qb,setStreamedContent:()=>Hb,setThinkingStartTime:()=>Gb,updateScrollButtonState:()=>wb,updateStreamingMessage:()=>Xb});n(`zh`,{chatStream:{thinking:`思考中...`,outputting:`输出中...`,stopGenerating:`停止生成`,thinkingResult:`思考结果`,toolActionOperate:`操作`,toolActionUpload:`上传`,toolActionDownload:`下载`,toolActionRequest:`请求`,toolActionInteract:`交互`,toolActionFill:`填写`,toolActionDispatch:`分派`,toolActionPreview:`预览`,toolActionRead:`读取`,toolActionWrite:`写入`,terminateCommand:`终止命令`,abortWaiting:`终止等待(跳过当前工具执行等待,不终止实际进程)`,executing:`执行中...`,terminating:`正在终止...`,copyCode:`复制代码`,truncatedTitle:`原始结果过大,已截断显示`,truncatedNote:`(输出过长已截断)`,noOutput:`(无输出)`,execFailed:`执行失败`,clickToExpand:`
|
|
1548
|
+
`,document.body.appendChild(n),ad(n),n.addEventListener(`click`,e=>{e.target===n&&n.remove()}),n.querySelector(`.log-close`).addEventListener(`click`,()=>{n.remove()});let p=n.querySelector(`.toggle-expand-btn`),m=n.querySelectorAll(`.timeline-content`),h=!1;p.addEventListener(`click`,()=>{h=!h,m.forEach(e=>{h?e.classList.add(`expanded`):e.classList.remove(`expanded`)});let e=p.querySelector(`svg`);h?(e.innerHTML=`<polyline points="17 11 12 6 7 11"></polyline><polyline points="17 18 12 13 7 18"></polyline>`,p.setAttribute(`title`,r(`chatPanels.collapseAll`))):(e.innerHTML=`<polyline points="7 13 12 18 17 13"></polyline><polyline points="7 6 12 11 17 6"></polyline>`,p.setAttribute(`title`,r(`chatPanels.expandAll`)))}),n.querySelectorAll(`.timeline-header`).forEach(e=>{e.addEventListener(`click`,()=>{e.parentElement.classList.toggle(`expanded`)})}),n.querySelectorAll(`.task-group-header`).forEach(e=>{e.addEventListener(`click`,()=>{e.parentElement.classList.toggle(`collapsed`)})});let g=n.querySelectorAll(`.combo-stat`),_=n.querySelectorAll(`.timeline-item`);g.forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.status,n=e.classList.contains(`active`);g.forEach(e=>e.classList.remove(`active`)),n?_.forEach(e=>{e.style.display=``}):(e.classList.add(`active`),_.forEach(e=>{if(t===`subtask`)e.classList.contains(`subtask-level`)?e.style.display=``:e.style.display=`none`;else{let n=e.querySelector(`.timeline-dot`);n&&n.classList.contains(t)?e.style.display=``:e.style.display=`none`}}))})})}n(`zh`,{chatResume:{title:`继续执行任务`,desc:`任务执行被中断,你可以提供补充说明帮助模型继续。`,placeholder:`输入补充说明(可选)…`,continueBtn:`继续`,interruptedAgo:`({duration}前)`,taskInterrupted:`任务执行被中断{elapsed}`,checkpointNotFound:`检查点已失效,无法继续执行。请重新发送任务。`,taskCancelled:`任务已被用户停止`,swRestarted:`Service Worker 已重启,请重新发送任务`,resumeFailed:`恢复失败:{message}`,unknownError:`未知错误`}}),n(`en`,{chatResume:{title:`Continue Task`,desc:`The task was interrupted. You can provide additional guidance to help the model continue.`,placeholder:`Enter additional guidance (optional)…`,continueBtn:`Continue`,interruptedAgo:` ({duration} ago)`,taskInterrupted:`Task execution was interrupted{elapsed}`,checkpointNotFound:`The checkpoint has expired and the task cannot be resumed. Please resend the task.`,taskCancelled:`Task was stopped by user`,swRestarted:`Service Worker restarted. Please resend the task.`,resumeFailed:`Resume failed: {message}`,unknownError:`Unknown error`}});function hb(){return new Promise(e=>{let t=document.createElement(`div`);t.className=`modal-overlay resume-dialog-overlay`,t.style.cssText=`display:flex;position:fixed;inset:0;background:var(--scrim);z-index:10000;align-items:center;justify-content:center;`;let n=document.createElement(`div`);n.className=`modal-container resume-dialog-container`,n.style.cssText=`background:var(--bg-surface);border-radius:8px;padding:24px;width:90%;max-width:480px;box-shadow:0 8px 32px var(--shadow-md);`;let i=document.createElement(`h3`);i.textContent=r(`chatResume.title`),i.style.cssText=`margin:0 0 8px 0;font-size:16px;color:var(--text-primary);`;let a=document.createElement(`p`);a.textContent=r(`chatResume.desc`),a.style.cssText=`margin:0 0 16px 0;font-size:13px;color:var(--text-secondary);line-height:1.5;`;let o=document.createElement(`textarea`);o.className=`resume-dialog-textarea`,o.placeholder=r(`chatResume.placeholder`),o.style.cssText=`width:100%;min-height:80px;padding:8px 12px;border:1px solid var(--border-default);border-radius:4px;font-size:13px;resize:vertical;box-sizing:border-box;font-family:inherit;line-height:1.5;`,o.rows=3;let s=document.createElement(`div`);s.style.cssText=`display:flex;justify-content:flex-end;gap:8px;margin-top:16px;`;let c=document.createElement(`button`);c.textContent=r(`common.cancel`),c.style.cssText=`padding:6px 16px;border:1px solid var(--border-default);background:var(--bg-surface);color:var(--text-secondary);border-radius:4px;cursor:pointer;font-size:13px;`;let l=document.createElement(`button`);l.textContent=r(`chatResume.continueBtn`),l.style.cssText=`padding:6px 16px;border:none;background:var(--info-500);color:var(--text-inverse);border-radius:4px;cursor:pointer;font-size:13px;font-weight:500;`,s.appendChild(c),s.appendChild(l),n.appendChild(i),n.appendChild(a),n.appendChild(o),n.appendChild(s),t.appendChild(n),document.body.appendChild(t),requestAnimationFrame(()=>o.focus());let u=()=>{t.remove(),document.removeEventListener(`keydown`,d)},d=t=>{t.key===`Escape`?(u(),e(null)):t.key===`Enter`&&(t.ctrlKey||t.metaKey)&&(u(),e(o.value.trim()))};c.addEventListener(`click`,()=>{u(),e(null)}),l.addEventListener(`click`,()=>{u(),e(o.value.trim())}),document.addEventListener(`keydown`,d)})}function gb(e){if(!e)return;let t=!1;for(let e of N.messageHistory)e.resumable&&(e.resumable=!1,t=!0);let n=document.getElementById(`chatContainer`);n&&n.querySelectorAll(`.message[data-resumable="true"]`).forEach(e=>{e.removeAttribute(`data-resumable`);let t=e.querySelector(`.resume-task-btn`);t&&t.remove()}),t&&yx()}async function _b(e,t){if(!(!e||!t))try{if(!(await chrome.runtime.sendMessage({type:`GET_CHECKPOINT`,sessionId:t}))?.exists){e.removeAttribute(`data-resumable`);let t=e.querySelector(`.resume-task-btn`);t&&t.remove();let n=e.dataset.messageId,r=N.messageHistory.find(e=>e.messageId===n);r&&r.resumable&&(r.resumable=!1,yx())}}catch{}}async function vb(){let e=N.activeSessionId;if(!e||N.pendingCallApiSessionIds&&N.pendingCallApiSessionIds.has(e))return;let t=N.messageHistory.some(e=>e.resumable),n=document.getElementById(`chatContainer`),i=n&&n.querySelector(`.resume-task-btn`);if(!(t&&i))try{let i=await chrome.runtime.sendMessage({type:`GET_CHECKPOINT`,sessionId:e});if(i?.exists){a.debug(`[SidePanel] found abandoned checkpoint,auto addrestorehint card`),document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:e}}));let o=i.checkpoint,s=o.updatedAt?vt(Date.now()-o.updatedAt):``,c=r(`chatResume.taskInterrupted`,{elapsed:s?r(`chatResume.interruptedAgo`,{duration:s}):``});if(t){let e=N.messageHistory.find(e=>e.resumable);if(e&&(e.content=c,yx()),n){let e=n.querySelector(`.message[data-resumable="true"]`);if(!e){let t=n.querySelectorAll(`.message.assistant`);for(let n of t)if((n.textContent||``).includes(`任务执行被中断`)){e=n;break}}e&&e.remove()}}let{element:l,messageId:u}=Jx(`assistant`,c,!0,[],null,!1,null,null,[],!0);t||(N.messageHistory.push({role:`assistant`,content:c,executionLog:[],messageId:u,resumable:!0,interrupted:!0}),yx()),_b(l,e)}}catch(e){a.warn(`[SidePanel] check abandoned checkpoint failed:`,e.message)}}async function yb(e,t=``){if(!e)return a.warn(`[SidePanel] resumeTask: missing sessionId`),!1;if(N.activeSessionId!==e)return a.warn(`[SidePanel] resumeTask: currently activesessionwith targetsession not consistent,please switch firstto targetsession`),!1;if(N.pendingCallApiSessionIds&&N.pendingCallApiSessionIds.has(e))return a.warn(`[SidePanel] resumeTask: currentsession has ongoingtask`),!1;a.debug(`[SidePanel] resumeTask: startrestoretask, sessionId:`,e,`userGuidance:`,t?`"${t.substring(0,50)}..."`:`( no )`);try{let t=await chrome.runtime.sendMessage({type:`GET_CHECKPOINT`,sessionId:e});if(!t?.exists){a.warn(`[SidePanel] resumeTask: checkpoint not found, no way to restore, sessionId:`,e);let t=r(`chatResume.checkpointNotFound`),{messageId:n}=Jx(`assistant`,t,!0,[]);return N.messageHistory.push({role:`assistant`,content:t,executionLog:[],messageId:n,resumable:!1,resumed:!0}),yx(),gb(e),!1}a.debug(`[SidePanel] resumeTask: checkpoint verified, iteration:`,t.checkpoint?.iteration)}catch(e){a.warn(`[SidePanel] resumeTask: verify checkpoint hourcommunication failed,continue tryrestore:`,e.message)}let n=e,i=eS();N.isGenerating=!0;let o=``,s=[],c=null,l=!1,u=!1,d=null,f=null;try{let e=await lS(null,null,!1,{},{resumeFromCheckpoint:!0,userGuidance:t,loadingId:i});o=e.content,s=e.executionLog||[],c=e.reflectionScore,l=e.wasRevised||!1,u=e.wasStreamed||!1,d=e.streamingHtml||null,e.streamingConnected!==void 0&&e.streamingConnected,f=e.streamingMsgId||null}catch(e){if(N.activeSessionId!==n){let t=!!e.checkpoint||e.swRestarted||e.message===`任务已被用户停止`;return e.message===`任务已被用户停止`?Di(n,{role:`assistant`,content:r(`chatResume.taskCancelled`),executionLog:e.executionLog||[],resumable:t,resumed:!0}):e.swRestarted?Di(n,{role:`assistant`,content:r(`chatResume.swRestarted`),executionLog:e.executionLog||[],resumable:t,resumed:!0}):Di(n,{role:`assistant`,content:r(`chatResume.resumeFailed`,{message:e.message||r(`chatResume.unknownError`)}),executionLog:e.executionLog||[],resumable:!1,resumed:!0}),document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:n}})),tS(i),!1}if(e.message===`任务已被用户停止`){tS(i);let{messageId:t}=Jx(`assistant`,r(`chatResume.taskCancelled`),!1,e.executionLog||[]);return N.messageHistory.push({role:`assistant`,content:r(`chatResume.taskCancelled`),executionLog:e.executionLog||[],messageId:t,resumable:!0,resumed:!0}),yx(),!1}if(e.swRestarted){tS(i);let t=!!e.checkpoint,{messageId:n}=Jx(`assistant`,r(`chatResume.swRestarted`),!1,e.executionLog||[]);return N.messageHistory.push({role:`assistant`,content:r(`chatResume.swRestarted`),executionLog:e.executionLog||[],messageId:n,resumable:t,resumed:!0}),yx(),!1}tS(i);let t=r(`chatResume.resumeFailed`,{message:e.message||r(`chatResume.unknownError`)}),{element:a,messageId:o}=Jx(`assistant`,t,!0,e.executionLog||[]);return N.messageHistory.push({role:`assistant`,content:t,executionLog:e.executionLog||[],messageId:o,resumable:!1,resumed:!0}),yx(),!1}finally{Bc(n)}if(gb(n),N.activeSessionId!==n){let e={role:`assistant`,content:o,executionLog:s,reflectionScore:c,wasRevised:l,resumed:!0};return u&&d&&(e.htmlContent=d),Di(n,e),document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:n}})),tS(i),!0}if(u&&d){let e=f;return N.messageHistory.push({role:`assistant`,content:o,executionLog:s,reflectionScore:c,wasRevised:l,messageId:e,resumed:!0,htmlContent:d}),yx(),!0}tS(i);let{element:p,messageId:m}=Jx(`assistant`,o,!0,s,c,l);return N.messageHistory.push({role:`assistant`,content:o,executionLog:s,reflectionScore:c,wasRevised:l,messageId:m,resumed:!0}),yx(),p&&Jt(p),!0}var bb=t({addStreamingMessage:()=>Xb,appendToolCallItems:()=>$b,appendToolResult:()=>nx,autoScrollToBottom:()=>Ob,bindProcessHeaderClick:()=>Pb,cancelStreamingTask:()=>ax,createAgentStreamOutput:()=>tx,createCodeBlockHtml:()=>ex,createPreSelectCard:()=>rx,createStreamingElementAccessor:()=>Hb,deleteStreamingState:()=>Ub,finalizeCancelledStream:()=>ox,finalizeStreamingMessage:()=>ix,getPendingPreselectLog:()=>Gb,initScrollToBottomBtn:()=>jb,notifyNonStreamContentArrived:()=>Mb,reconnectStreamingElement:()=>Zb,refreshAgentNames:()=>Fb,resetScrollState:()=>Ab,scrollStreamingToBottom:()=>kb,setPendingPreselectLog:()=>Kb,setProcessStartTime:()=>Jb,setReasoningContent:()=>Yb,setStreamedContent:()=>Wb,setThinkingStartTime:()=>qb,updateScrollButtonState:()=>Eb,updateStreamingMessage:()=>Qb});n(`zh`,{chatStream:{thinking:`思考中...`,outputting:`输出中...`,stopGenerating:`停止生成`,thinkingResult:`思考结果`,toolActionOperate:`操作`,toolActionUpload:`上传`,toolActionDownload:`下载`,toolActionRequest:`请求`,toolActionInteract:`交互`,toolActionFill:`填写`,toolActionDispatch:`分派`,toolActionPreview:`预览`,toolActionRead:`读取`,toolActionWrite:`写入`,terminateCommand:`终止命令`,abortWaiting:`终止等待(跳过当前工具执行等待,不终止实际进程)`,executing:`执行中...`,terminating:`正在终止...`,copyCode:`复制代码`,truncatedTitle:`原始结果过大,已截断显示`,truncatedNote:`(输出过长已截断)`,noOutput:`(无输出)`,execFailed:`执行失败`,clickToExpand:`
|
|
1542
1549
|
... (点击展开查看完整输出)`,execResult:`执行结果`,statusFailed:`失败`,statusCompleted:`完成`,preselectFiltered:`从 {total} 个工具中筛选出 <strong>{count}</strong> 个:`,preselectSkippedAll:`跳过筛选({reason}),使用全部工具`,preselectSkippedCount:`跳过筛选({reason}),工具总数 {count}`,preselectDirectAnswer:`模型直接回答:`,toolPreselect:`工具预筛选`,toolsAfterFilter:`筛选后工具数:<strong>{count}</strong>`,listSeparator:`、`,totalNodes:`总节点`,successLabel:`成功`,failedLabel:`失败`,tokenLabel:`Token`,tokenUsageTitle:`Token 消耗: {total} (Prompt: {prompt}, Completion: {completion})`,thinkingProcess:`思考过程`,copyMarkdown:`复制 Markdown 内容 (Ctrl/Cmd + 点击复制富文本)`,copy:`复制`,quoteTitle:`引用该内容问答`,quote:`引用`,export:`导出`,exportWord:`导出 Word`,exportPdf:`导出 PDF`,exportImage:`导出图片`,exportMarkdown:`导出 Markdown`,executionLog:`执行日志`,reflectionRoundsTag:` ({count}轮)`,qualityAssessmentTitle:`AI 质量评估: {score}/10{rounds}
|
|
1543
1550
|
点击查看评估详情`,reflectionFailedTitle:`反思评估失败(点击查看执行日志)`,reflectionFailedBadge:`⚠️ 反思失败`,prototypeOpenedLocal:`已在本地浏览器打开,点击可在面板内查看`,viewUiPrototype:`查看 UI 原型`,bookmarkMessage:`收藏消息`,removeBookmark:`取消收藏`,forkSession:`从此处分叉会话(仅复制到此条消息)`,deleteMessage:`删除消息`,stopping:`停止中...`,taskStopped:`任务已被用户停止`,cancelled:`已取消`}}),n(`en`,{chatStream:{thinking:`Thinking...`,outputting:`Outputting...`,stopGenerating:`Stop generating`,thinkingResult:`Thinking result`,toolActionOperate:`Operate`,toolActionUpload:`Upload`,toolActionDownload:`Download`,toolActionRequest:`Request`,toolActionInteract:`Interact`,toolActionFill:`Fill`,toolActionDispatch:`Dispatch`,toolActionPreview:`Preview`,toolActionRead:`Read`,toolActionWrite:`Write`,terminateCommand:`Terminate command`,abortWaiting:`Abort waiting (skip current tool wait, does not terminate the actual process)`,executing:`Executing...`,terminating:`Terminating...`,copyCode:`Copy code`,truncatedTitle:`Original result too large, truncated for display`,truncatedNote:`(output too long, truncated)`,noOutput:`(no output)`,execFailed:`Execution failed`,clickToExpand:`
|
|
1544
1551
|
... (click to expand and view full output)`,execResult:`Execution result`,statusFailed:`Failed`,statusCompleted:`Completed`,preselectFiltered:`Filtered <strong>{count}</strong> of {total} tools: `,preselectSkippedAll:`Skipped filtering ({reason}), using all tools`,preselectSkippedCount:`Skipped filtering ({reason}), total tools: {count}`,preselectDirectAnswer:`Model direct answer: `,toolPreselect:`Tool Pre-filter`,toolsAfterFilter:`Tools after filtering: <strong>{count}</strong>`,listSeparator:`, `,totalNodes:`Total nodes`,successLabel:`Success`,failedLabel:`Failed`,tokenLabel:`Token`,tokenUsageTitle:`Token usage: {total} (Prompt: {prompt}, Completion: {completion})`,thinkingProcess:`Thinking process`,copyMarkdown:`Copy Markdown content (Ctrl/Cmd + click to copy rich text)`,copy:`Copy`,quoteTitle:`Quote this content for Q&A`,quote:`Quote`,export:`Export`,exportWord:`Export Word`,exportPdf:`Export PDF`,exportImage:`Export Image`,exportMarkdown:`Export Markdown`,executionLog:`Execution log`,reflectionRoundsTag:` ({count} rounds)`,qualityAssessmentTitle:`AI quality assessment: {score}/10{rounds}
|
|
1545
|
-
Click to view assessment details`,reflectionFailedTitle:`Reflection assessment failed (click to view execution log)`,reflectionFailedBadge:`⚠️ Reflection failed`,prototypeOpenedLocal:`Already opened in local browser, click to view in panel`,viewUiPrototype:`View UI prototype`,bookmarkMessage:`Bookmark message`,removeBookmark:`Remove bookmark`,forkSession:`Fork session from here (copy up to this message only)`,deleteMessage:`Delete message`,stopping:`Stopping...`,taskStopped:`Task stopped by user`,cancelled:`Cancelled`}});var
|
|
1552
|
+
Click to view assessment details`,reflectionFailedTitle:`Reflection assessment failed (click to view execution log)`,reflectionFailedBadge:`⚠️ Reflection failed`,prototypeOpenedLocal:`Already opened in local browser, click to view in panel`,viewUiPrototype:`View UI prototype`,bookmarkMessage:`Bookmark message`,removeBookmark:`Remove bookmark`,forkSession:`Fork session from here (copy up to this message only)`,deleteMessage:`Delete message`,stopping:`Stopping...`,taskStopped:`Task stopped by user`,cancelled:`Cancelled`}});var xb=new Map,Sb=!1,Cb=!1,wb=!1,Tb=!1;function Eb(){let e=document.getElementById(`scrollToBottomBtn`),t=document.getElementById(`scrollToBottomBadge`);if(!e)return;let n=document.getElementById(`chatContainer`);if(!n)return;let r=n.scrollHeight-n.scrollTop-n.clientHeight<80;r?(e.classList.remove(`visible`),Tb=!1):e.classList.add(`visible`),t&&(Tb&&!r?(t.classList.add(`active`),N.isGenerating?t.classList.add(`pulsing`):t.classList.remove(`pulsing`)):t.classList.remove(`active`,`pulsing`))}function Db(){if(wb)return;let e=document.getElementById(`chatContainer`);e&&(wb=!0,e.addEventListener(`scroll`,()=>{if(Sb)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<80;Cb=!t,t?Tb=!1:N.isGenerating&&(Tb=!0),Eb()},{passive:!0}),document.addEventListener(`generating-state-changed`,()=>{N.isGenerating&&(Tb=!0),requestAnimationFrame(()=>Eb())}))}function Ob(e,t={}){if(!e)return;Db();let{force:n=!1,smooth:r=!1}=t;if(!n&&Cb){Tb=!0,Eb();return}if(Sb=!0,r){e.scrollTo({top:e.scrollHeight,behavior:`smooth`}),requestAnimationFrame(()=>{Sb=!1});return}e.scrollTop=e.scrollHeight,requestAnimationFrame(()=>{Cb||(e.scrollTop=e.scrollHeight),requestAnimationFrame(()=>{Sb=!1})})}function kb(e){if(!e||!e.isConnected)return;let t=document.getElementById(`chatContainer`);t&&Ob(t)}function Ab(){Cb=!1,Tb=!1,N.isGenerating&&(Tb=!0),Eb()}function jb(){Db();let e=document.getElementById(`scrollToBottomBtn`);if(!e||e.dataset.bound)return;e.dataset.bound=`1`;let t=localStorage.getItem(`scrollBtnPosition`)||`center`;e.classList.add(`pos-${t}`);let n=!1,r=0,i=0,a=!1,o=0,s=!1;function c(){let t=document.getElementById(`chatContainer`);if(!t)return;let n=t.clientWidth,r={left:n/6,center:n/2,right:n*5/6},i=`center`,a=1/0;for(let[e,t]of Object.entries(r)){let n=Math.abs(o-t);n<a&&(a=n,i=e)}e.classList.remove(`pos-left`,`pos-center`,`pos-right`),e.classList.add(`pos-${i}`),e.style.left=``,e.style.marginLeft=``,e.style.right=``,localStorage.setItem(`scrollBtnPosition`,i)}function l(){let t=document.getElementById(`chatContainer`),n=e.getBoundingClientRect(),a=t?t.getBoundingClientRect():null,o=a?n.left-a.left+n.width/2:r;e.classList.remove(`pos-left`,`pos-center`,`pos-right`),e.style.left=`${o}px`,e.style.marginLeft=`0`,e.style.right=`auto`,e.classList.add(`dragging`),i=o,s=!0}function u(e){e.type===`mousedown`&&e.button!==0||(e.preventDefault(),n=!0,a=!1,s=!1,r=e.touches?e.touches[0].clientX:e.clientX)}function d(t){if(!n)return;let c=t.touches?t.touches[0].clientX:t.clientX;if(!s){if(Math.abs(c-r)<=3)return;a=!0,l()}let u=document.getElementById(`chatContainer`);if(!u)return;let d=u.getBoundingClientRect(),f=i+(c-r),p=e.offsetWidth/2;f=Math.max(p,Math.min(d.width-p,f)),o=f,e.style.left=`${f}px`}function f(){if(n){if(n=!1,a)e.classList.remove(`dragging`),c();else{s&&(e.classList.remove(`dragging`),e.style.left=``,e.style.marginLeft=``,e.style.right=``);let t=document.getElementById(`chatContainer`);t&&(Cb=!1,Tb=!1,Eb(),Ob(t,{force:!0,smooth:!0}))}a=!1,s=!1}}e.addEventListener(`mousedown`,u),e.addEventListener(`touchstart`,u,{passive:!1}),document.addEventListener(`mousemove`,d),document.addEventListener(`touchmove`,d,{passive:!1}),document.addEventListener(`mouseup`,f),document.addEventListener(`touchend`,f),Eb()}function Mb(){Db();let e=document.getElementById(`chatContainer`);e&&(e.scrollHeight-e.scrollTop-e.clientHeight<80||(Tb=!0),Eb())}function Nb(e,t){let n=e.querySelector(`.thinking-process-content`);if(!n)return;e.dataset.activeFilter=t,e.querySelectorAll(`.thinking-process-stat[data-filter]`).forEach(e=>{e.classList.toggle(`active`,e.dataset.filter===t)});let r=e=>t===`all`||e===t;n.querySelectorAll(`.tool-call-item`).forEach(e=>{e.classList.contains(`preselect-card`)||(e.style.display=r(e.dataset.status)?``:`none`)}),n.querySelectorAll(`.thinking-badge`).forEach(e=>{let t=r(e.dataset.status||`success`);e.style.display=t?``:`none`;let n=e.nextElementSibling;n&&n.classList.contains(`thinking-content`)&&(n.style.display=t?``:`none`)}),n.querySelectorAll(`.thinking-content`).forEach(e=>{let t=e.previousElementSibling;t&&t.classList.contains(`thinking-badge`)||(e.style.display=r(`success`)?``:`none`)})}function Pb(e){if(!e||e._filterBound)return;e._filterBound=!0;let t=[``,`success`,`failed`];e.querySelectorAll(`.thinking-process-stat`).forEach((e,n)=>{t[n]&&(e.dataset.filter=t[n],e.classList.add(`filterable`))}),e.querySelectorAll(`.token-stat`).forEach(e=>{e.style.cursor=`pointer`}),e.addEventListener(`click`,t=>{if(t.ctrlKey||t.metaKey)return;let n=t.target.closest(`.thinking-process-stat`),r=e.closest(`.thinking-process`);if(r){if(n&&n.classList.contains(`token-stat`)){let e=r.closest(`.message`);if(e)try{let t=e.dataset.executionLog,r=wt(t?JSON.parse(t):[]);r&&At(r,n)}catch{}return}n&&n.dataset.filter?Nb(r,r.dataset.activeFilter===n.dataset.filter?`all`:n.dataset.filter):r.classList.toggle(`collapsed`)}});let n=e.closest(`.thinking-process`);n&&Nb(n,n.dataset.activeFilter||`all`)}async function Fb(){try{let{getAllAgents:e}=await M(async()=>{let{getAllAgents:e}=await import(`./agent-store-DR_A4rFm.js`).then(e=>e.t);return{getAllAgents:e}},__vite__mapDeps([0,1,2,3,4])),t=await e();xb.clear();for(let e of t)xb.set(e.id,e.name||e.id)}catch{}}function Ib(e){return xb.get(e)||e}var Lb=new Map,Rb=new Map,zb=null,Bb=0,Vb=0;function Hb(e){return t=>t===void 0?Lb.get(e)||null:(Lb.set(e,t),t)}function Ub(e){Lb.delete(e),Rb.delete(e)}function Wb(e,t){Rb.set(e,t)}function Gb(){return zb}function Kb(e){zb=e}function qb(e){Bb=e}function Jb(e){Vb=e}function Yb(e){}function Xb(e){let t=document.getElementById(`chatContainer`),n=document.createElement(`div`);n.className=`message-wrapper assistant streaming`;let i=`msg_`+Date.now().toString(36)+`_`+Math.random().toString(36).substring(2,8);n.dataset.messageId=i,n.dataset.sessionId=e||``,n.innerHTML=`
|
|
1546
1553
|
<div class="message-content">
|
|
1547
1554
|
<div class="stream-content"></div>
|
|
1548
1555
|
<div class="thinking-indicator">
|
|
@@ -1563,7 +1570,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1563
1570
|
</div>
|
|
1564
1571
|
<div class="stream-status hidden"></div>
|
|
1565
1572
|
</div>
|
|
1566
|
-
`,(!e||e===N.activeSessionId)&&t&&(t.appendChild(n),
|
|
1573
|
+
`,(!e||e===N.activeSessionId)&&t&&(t.appendChild(n),Ab(),Eb(),requestAnimationFrame(()=>{Ob(t,{force:!0})}));let a=n.querySelector(`.streaming-stop-btn`);return a&&a.addEventListener(`click`,e=>{e.stopPropagation(),ax(a)}),n}function Zb(e){let t=Lb.get(e);if(!t||t.dataset.sessionId&&t.dataset.sessionId!==e)return;let n=document.getElementById(`chatContainer`);if(!n)return;n.appendChild(t);let i=Rb.get(e)||``;i&&(Qb(t,i),t.querySelectorAll(`.thinking-indicator:not(.hidden)`).forEach(e=>{let t=e.parentElement,n=e.previousElementSibling,i=document.createElement(`span`);i.className=`thinking-badge`,i.dataset.status=`success`,i.innerHTML=`<svg class="thinking-icon-static" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2a3 3 0 0 0-3 3v1a3 3 0 0 0 3 3 3 3 0 0 1 3 3v1a3 3 0 0 1-3 3 3 3 0 0 0-3 3v1a3 3 0 0 0 3 3"/><circle cx="8" cy="12" r="1.5"/><circle cx="16" cy="12" r="1.5"/></svg>`+r(`chatStream.thinkingResult`),n&&n.classList.contains(`thinking-content`)?t.insertBefore(i,n):t.insertBefore(i,e),e.classList.add(`hidden`)})),requestAnimationFrame(()=>{n.scrollTop=n.scrollHeight})}function Qb(e,t){let n=e.querySelector(`.stream-content`);if(!n)return;let i=n.querySelector(`.thinking-indicator:not(.hidden)`)||e.querySelector(`.thinking-indicator:not(.hidden)`);if(i){let e=i.querySelector(`.thinking-label`);if(e&&(e.textContent===r(`chatStream.thinking`)||e.dataset.retrying===`1`)&&(e.textContent=r(`chatStream.outputting`),delete e.dataset.retrying),n.contains(i)){let e=i.previousElementSibling;if(e&&e.classList.contains(`thinking-content`))e.innerHTML=Pt(t);else{let e=document.createElement(`div`);e.className=`thinking-content`,e.innerHTML=Pt(t),n.insertBefore(e,i)}}else{let e=n.querySelectorAll(`.thinking-content`);if(e.length===0){let e=document.createElement(`div`);e.className=`thinking-content`,e.innerHTML=Pt(t),n.appendChild(e)}else{let r=e[e.length-1],i=r.nextElementSibling;if(!i||!i.classList.contains(`thinking-badge`))r.innerHTML=Pt(t);else{let e=document.createElement(`div`);e.className=`thinking-content`,e.innerHTML=Pt(t),n.appendChild(e)}}}}else{let e=n.querySelectorAll(`.thinking-badge`);if(e.length>0){let n=e[e.length-1],r=n.nextElementSibling;if(r&&r.classList.contains(`thinking-content`))r.innerHTML=Pt(t);else{let e=document.createElement(`div`);e.className=`thinking-content`,e.innerHTML=Pt(t),n.after(e)}}else{let e=document.createElement(`div`);e.className=`thinking-content`,e.innerHTML=Pt(t),n.appendChild(e)}}e.isConnected&&requestAnimationFrame(()=>{let e=document.getElementById(`chatContainer`);e&&Ob(e)})}function $b(e,t){if(!e||!t?.length)return;let n=e.querySelector(`.stream-content`);if(!n)return;let i=e.querySelector(`.thinking-indicator:not(.hidden)`);if(i){let e=Bb>0?vt(Date.now()-Bb):``,t=document.createElement(`span`);if(t.className=`thinking-badge`,t.innerHTML=`<svg class="thinking-icon-static" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2a3 3 0 0 0-3 3v1a3 3 0 0 0 3 3 3 3 0 0 1 3 3v1a3 3 0 0 1-3 3 3 3 0 0 0-3 3v1a3 3 0 0 0 3 3"/><circle cx="8" cy="12" r="1.5"/><circle cx="16" cy="12" r="1.5"/></svg>${r(`chatStream.thinkingResult`)}${e?` <span class="thinking-duration">`+e+`</span>`:``}`,t.dataset.status=`success`,n.contains(i)){let e=i.previousElementSibling;e&&e.classList.contains(`thinking-content`)?n.insertBefore(t,e):n.insertBefore(t,i),i.classList.add(`hidden`)}else{let e=n.querySelectorAll(`.thinking-content`);if(e.length>0){let r=e[e.length-1],i=r.nextElementSibling;!i||!i.classList.contains(`thinking-badge`)?n.insertBefore(t,r):n.appendChild(t)}else n.appendChild(t);i.classList.add(`hidden`),i.remove()}}let a={execute_command:{metaType:`exec`},agent_exec:{metaType:`exec`},agent_file:{metaType:`file`,action:r(`chatStream.toolActionOperate`)},file_upload:{metaType:`file`,action:r(`chatStream.toolActionUpload`)},download_file:{metaType:`file`,action:r(`chatStream.toolActionDownload`)},fetch_url:{metaType:`web`,action:r(`chatStream.toolActionRequest`)},interact_element:{metaType:`web`,action:r(`chatStream.toolActionInteract`)},fill_form:{metaType:`web`,action:r(`chatStream.toolActionFill`)},manage_tab:{metaType:`web`,action:r(`chatStream.toolActionOperate`)},search_browser_data:{metaType:`search`},search_in_page:{metaType:`search`},dispatch_task:{metaType:`subagent`,action:r(`chatStream.toolActionDispatch`)},exec_log:{metaType:`search`},preview_ui:{metaType:`web`,action:r(`chatStream.toolActionPreview`)}};t.filter(e=>e&&typeof e==`object`).forEach(e=>{let t=e.function?.name||`unknown`,i=a[t]||{metaType:`other`},o;try{o=JSON.parse(e.function?.arguments||`{}`)}catch{o={raw:e.function?.arguments||``}}let s=JSON.stringify(o,null,2),c=``,l=``;if(i.metaType===`exec`){let e=o.command||o.cmd||JSON.stringify(o);l=e,c=`<code class="tool-call-cmd">$ ${F(e)}</code>`}else if(i.metaType===`file`){let e=o.file_path||o.filePath||o.path||o.filename||o.fileName||o.url||``,n=i.action===r(`chatStream.toolActionRead`)?`📖`:i.action===r(`chatStream.toolActionWrite`)?`📝`:i.action===r(`chatStream.toolActionUpload`)?`📤`:`📥`;l=e||t,c=`<span class="tool-call-file">${n} ${F(e)||F(t)}</span>`}else if(i.metaType===`web`){let e=o.url||o.href||o.selector||``;l=e||JSON.stringify(o),c=`<span class="tool-call-web">${F(i.action)}: ${F(e)||F(JSON.stringify(o).substring(0,80))}</span>`}else if(i.metaType===`search`){let e=o.query||o.keyword||o.text||``;l=e||t,c=`<span class="tool-call-search">🔍 ${F(e)||F(t)}</span>`}else if(i.metaType===`subagent`){let e=o.subAgentId||o.agent_id||``,t=e?Ib(e):``,n=(o.task||``).substring(0,80);t&&t!==e?(l=`${t} (${e}): ${n}`,c=`<span class="tool-call-subagent">🤖 <strong>${F(t)}</strong> <span class="tool-call-subagent-id">(${F(e)})</span>: ${F(n)}</span>`):(l=`${e}: ${n}`,c=`<span class="tool-call-subagent">🤖 <strong>${F(e)}</strong>: ${F(n)}</span>`)}else{let e=Object.keys(o);if(e.length===0)l=t,c=`<span>${F(t)}</span>`;else if(e.length===1){let t=JSON.stringify(o[e[0]]);l=`${e[0]}: ${t}`,c=`<span>${F(e[0])}: ${F(t.substring(0,80))}</span>`}else l=e.map(e=>`${e}=${JSON.stringify(o[e])}`).join(`, `),c=`<span>${e.slice(0,2).map(e=>`${F(e)}=${F(JSON.stringify(o[e]).substring(0,30))}`).join(`, `)}${e.length>2?` ...`:``}</span>`}let u=i.metaType===`exec`?`<svg class="tool-call-icon exec" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1567
1574
|
<polyline points="4 17 10 11 4 5"/><line x1="12" y1="19" x2="20" y2="19"/>
|
|
1568
1575
|
</svg>`:i.metaType===`file`?`<svg class="tool-call-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1569
1576
|
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
|
|
@@ -1591,16 +1598,19 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1591
1598
|
<svg class="tool-call-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>
|
|
1592
1599
|
</div>
|
|
1593
1600
|
<div class="tool-call-body">
|
|
1594
|
-
${
|
|
1601
|
+
${ex(F(s))}
|
|
1595
1602
|
</div>
|
|
1596
|
-
`,l){let e=d.querySelector(`.tool-call-summary`);e&&(e.title=l)}if(qt(),f){let e=d.querySelector(`.tool-call-terminate-btn`);e&&e.addEventListener(`click`,e=>{e.stopPropagation(),
|
|
1603
|
+
`,l){let e=d.querySelector(`.tool-call-summary`);e&&(e.title=l)}if(qt(),f){let e=d.querySelector(`.tool-call-terminate-btn`);e&&e.addEventListener(`click`,e=>{e.stopPropagation(),aS(N.activeSessionId)})}let h=d.querySelector(`.tool-call-abort-btn`);h&&h.addEventListener(`click`,e=>{e.stopPropagation(),chrome.runtime.sendMessage({type:`ABORT_CURRENT_TOOL`,sessionId:N.activeSessionId}),h.disabled=!0,h.title=r(`chatStream.terminating`)}),d.querySelector(`.tool-call-header`).addEventListener(`click`,e=>{e.ctrlKey||e.metaKey||d.classList.toggle(`expanded`)}),n.appendChild(d)}),e.isConnected&&requestAnimationFrame(()=>{let e=document.getElementById(`chatContainer`);e&&Ob(e)})}function ex(e,t=``){let n=t?` class="${t}"`:``;return`<div class="code-block-container" style="position: relative;">
|
|
1597
1604
|
<button class="code-copy-btn" title="${r(`chatStream.copyCode`)}">
|
|
1598
1605
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
1599
1606
|
<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25zM5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25z"/>
|
|
1600
1607
|
</svg>
|
|
1601
1608
|
</button>
|
|
1602
1609
|
<pre${n}><code>${e}</code></pre>
|
|
1603
|
-
</div>`}function
|
|
1610
|
+
</div>`}function tx(e,t){let n=document.createElement(`div`);n.className=`agent-stream-output`,n.innerHTML=`
|
|
1611
|
+
<div class="tool-result-title">${r(`chatMsg.toolResultTitle`)}</div>
|
|
1612
|
+
${ex(``,`agent-stream-content`)}
|
|
1613
|
+
`;let i=(e?e.querySelector(`.tool-call-body`)||e:null)||t;return i&&i.appendChild(n),n}function nx(e,t){if(!e?.toolCallId)return;let n=t;if(!n)return;let i=n.querySelector(`.tool-call-item[data-tool-call-id="${e.toolCallId}"]`);if(!i)return;i.classList.add(`has-result`),i.dataset.status=e.success?`success`:`failed`;let a=parseInt(i.getAttribute(`data-created-at`),10),o=Date.now()-a,s=o<400&&o>=0?400-o:0,c=()=>{let n=i.querySelector(`.tool-call-executing`);n&&n.remove();let a=i.querySelector(`.tool-call-terminate-btn`);a&&(a.style.display=`none`);let o=i.querySelector(`.tool-call-abort-btn`);o&&(o.style.display=`none`);let s=i.querySelector(`.tool-call-result`);s&&s.remove();let c=e.truncated?`<span class="tool-result-truncated" title="${r(`chatStream.truncatedTitle`)}">${r(`chatStream.truncatedNote`)}</span>`:``,l=i.getAttribute(`data-meta-type`)===`exec`,u=i.querySelector(`.tool-call-header`),d=`
|
|
1604
1614
|
<span class="tool-result-status ${e.success?`success`:`fail`}">
|
|
1605
1615
|
${e.success?`<svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>`:`<svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16"><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z"/></svg>`}
|
|
1606
1616
|
</span>
|
|
@@ -1609,9 +1619,9 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1609
1619
|
`,f=u.querySelector(`.tool-call-chevron`);if(f?f.insertAdjacentHTML(`beforebegin`,d):u.insertAdjacentHTML(`beforeend`,d),!l||!e.success){let t=e.content||(e.success?r(`chatStream.noOutput`):r(`chatStream.execFailed`)),n=t.length>500?t.substring(0,500)+r(`chatStream.clickToExpand`):t,a=t,o=document.createElement(`div`);if(o.className=`tool-call-result`,o.innerHTML=`
|
|
1610
1620
|
<div class="tool-result-title">${r(`chatStream.execResult`)}</div>
|
|
1611
1621
|
<div class="tool-result-content">
|
|
1612
|
-
${
|
|
1622
|
+
${ex(F(n))}
|
|
1613
1623
|
</div>
|
|
1614
|
-
`,a.length>500){let e=o.querySelector(`code`);e.dataset.fullContent=a;let t=!1;o.style.cursor=`pointer`,o.addEventListener(`click`,r=>{r.ctrlKey||r.metaKey||(t=!t,e.textContent=t?a:n)})}let s=i.querySelector(`.tool-call-body`);s?s.appendChild(o):i.appendChild(o)}qt(),t.isConnected&&requestAnimationFrame(()=>{let e=document.getElementById(`chatContainer`);e&&
|
|
1624
|
+
`,a.length>500){let e=o.querySelector(`code`);e.dataset.fullContent=a;let t=!1;o.style.cursor=`pointer`,o.addEventListener(`click`,r=>{r.ctrlKey||r.metaKey||(t=!t,e.textContent=t?a:n)})}let s=i.querySelector(`.tool-call-body`);s?s.appendChild(o):i.appendChild(o)}qt(),t.isConnected&&requestAnimationFrame(()=>{let e=document.getElementById(`chatContainer`);e&&Ob(e)})};s>0?setTimeout(c,s):c()}function rx(e){let t=document.createElement(`div`);t.className=`tool-call-item preselect-card`+(N.chatConfig?.streamExpandTools?` expanded`:``);let n=e.status===`failed`,i=``,a=``;if(e.action?.params?.selected){let t=e.action.params.selected;i=`<div class="tool-call-summary"><span>${r(`chatStream.preselectFiltered`,{total:e.apiRequest?.toolCount||`?`,count:t.length})}</span></div>`,a=`<span class="preselect-summary">${t.map(e=>`<code>${F(e)}</code>`).join(r(`chatStream.listSeparator`))}</span>`}else e.action?.name===`all_tools`?(i=`<div class="tool-call-summary"><span>${F(e.action.params.reason||``)}</span></div>`,a=`<span class="preselect-summary">${r(`chatStream.preselectSkippedAll`,{reason:F(e.action.params.reason||``)})}</span>`):e.action?.name===`skip`?(i=`<div class="tool-call-summary"><span>${F(e.action.params.reason||``)}</span></div>`,a=`<span class="preselect-summary">${r(`chatStream.preselectSkippedCount`,{reason:F(e.action.params.reason||``),count:e.action.params.toolCount||`?`})}</span>`):e.error?(i=`<div class="tool-call-summary"><span style="color:var(--danger-500);">${F(e.error)}</span></div>`,a=`<span class="preselect-summary" style="color:var(--danger-500);">${F(e.error)}</span>`):e.thought&&(i=`<div class="tool-call-summary"><span>${r(`chatStream.preselectDirectAnswer`)}</span></div>`,a=`<span class="preselect-summary">${r(`chatStream.preselectDirectAnswer`)}${F(e.thought).substring(0,200)}</span>`);let o=e.duration?vt(e.duration):``,s=n?`<svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16"><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z"/></svg>`:`<svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>`;return t.innerHTML=`
|
|
1615
1625
|
<div class="tool-call-header">
|
|
1616
1626
|
<svg class="tool-call-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1617
1627
|
<circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>
|
|
@@ -1626,7 +1636,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1626
1636
|
${a}
|
|
1627
1637
|
${e.apiResponse?.toolCountAfter===void 0?``:`<div class="preselect-meta">${r(`chatStream.toolsAfterFilter`,{count:e.apiResponse.toolCountAfter})}</div>`}
|
|
1628
1638
|
</div>
|
|
1629
|
-
`,t.querySelector(`.tool-call-header`).addEventListener(`click`,e=>{e.ctrlKey||e.metaKey||t.classList.toggle(`expanded`)}),t}function
|
|
1639
|
+
`,t.querySelector(`.tool-call-header`).addEventListener(`click`,e=>{e.ctrlKey||e.metaKey||t.classList.toggle(`expanded`)}),t}function ix(e,t,n=[],i=null,o=null,s=!1){if(!e)return;let c=e.querySelector(`.message-content`),l=e.querySelector(`.stream-content`),u=e.querySelector(`.thinking-indicator:not(.hidden)`);if(u&&l){let e=Bb>0?vt(Date.now()-Bb):``,t=document.createElement(`span`);if(t.className=`thinking-badge`,t.innerHTML=`<svg class="thinking-icon-static" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2a3 3 0 0 0-3 3v1a3 3 0 0 0 3 3 3 3 0 0 1 3 3v1a3 3 0 0 1-3 3 3 3 0 0 0-3 3v1a3 3 0 0 0 3 3"/><circle cx="8" cy="12" r="1.5"/><circle cx="16" cy="12" r="1.5"/></svg>${r(`chatStream.thinkingResult`)}${e?` <span class="thinking-duration">`+e+`</span>`:``}`,t.dataset.status=`success`,l.contains(u)){let e=u.previousElementSibling;e&&e.classList.contains(`thinking-content`)?l.insertBefore(t,e):l.insertBefore(t,u),u.classList.add(`hidden`)}else{let e=l.querySelectorAll(`.thinking-content`);if(e.length>0){let n=e[e.length-1],r=n.nextElementSibling;!r||!r.classList.contains(`thinking-badge`)?l.insertBefore(t,n):l.appendChild(t)}else l.appendChild(t);u.classList.add(`hidden`),u.remove()}}e.querySelectorAll(`.thinking-indicator`).forEach(e=>e.classList.add(`hidden`));let d=e.querySelector(`.stream-status`);if(d&&d.remove(),e.classList.remove(`streaming`),c&&c.querySelector(`.tool-call-item`)||l&&l.querySelector(`.tool-call-item`)){let e=Vb>0?vt(Date.now()-Vb):``,i=(n||[]).filter(e=>e.nodeType===`api_call`||e.nodeType===`tool_exec`),o=i.filter(e=>e.status===`success`).length,u=i.filter(e=>e.status===`failed`).length,d=i.length,f=wt(n),p=document.createElement(`div`);p.className=`thinking-process collapsed`;let m=document.createElement(`div`);m.className=`thinking-process-header`;let h=d>0?`
|
|
1630
1640
|
<span class="thinking-process-stat">
|
|
1631
1641
|
<span class="stat-icon node-icon">◉</span>
|
|
1632
1642
|
<span class="stat-label">${r(`chatStream.totalNodes`)}</span>
|
|
@@ -1661,7 +1671,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1661
1671
|
<svg class="thinking-process-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
1662
1672
|
<polyline points="6 9 12 15 18 9"/>
|
|
1663
1673
|
</svg>
|
|
1664
|
-
`,f){let e=m.querySelector(`.token-stat`);e&&(e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),At(f,e)}))}let _=document.createElement(`div`);_.className=`thinking-process-body`;let v=document.createElement(`div`);if(v.className=`thinking-process-content`,_.appendChild(v),l)for(;l.firstChild;)v.appendChild(l.firstChild);c.querySelectorAll(`.tool-call-item`).forEach(e=>v.appendChild(e)),v.querySelectorAll(`.preselect-card`).forEach(e=>e.remove());let y=(n||[]).filter(e=>e.nodeType===`preselect`);a.debug(`[finalizeStreamingMessage] executionLog length:`,(n||[]).length,`preselectEntries:`,y.length),y.forEach(e=>{a.debug(`[finalizeStreamingMessage] creating preselect card for entry:`,e);let t=
|
|
1674
|
+
`,f){let e=m.querySelector(`.token-stat`);e&&(e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),At(f,e)}))}let _=document.createElement(`div`);_.className=`thinking-process-body`;let v=document.createElement(`div`);if(v.className=`thinking-process-content`,_.appendChild(v),l)for(;l.firstChild;)v.appendChild(l.firstChild);c.querySelectorAll(`.tool-call-item`).forEach(e=>v.appendChild(e)),v.querySelectorAll(`.preselect-card`).forEach(e=>e.remove());let y=(n||[]).filter(e=>e.nodeType===`preselect`);a.debug(`[finalizeStreamingMessage] executionLog length:`,(n||[]).length,`preselectEntries:`,y.length),y.forEach(e=>{a.debug(`[finalizeStreamingMessage] creating preselect card for entry:`,e);let t=rx(e);v.insertBefore(t,v.firstChild)});let b=v.querySelectorAll(`.thinking-content`),x=ux(t).trim();if(b.length>0){let e=b[b.length-1],t=e.textContent.trim();if(!s||s&&t===x){let t=e.previousElementSibling;for(;t;){if(t.classList.contains(`thinking-badge`)){t.remove();break}t=t.previousElementSibling}e.remove()}}if(v.children.length>0&&v.textContent.trim()){p.appendChild(m),p.appendChild(_);let e=document.createElement(`div`);e.className=`final-answer`;let n=ux(t);n&&n.trim()&&(e.innerHTML=Pt(n));let r=c.querySelector(`.thinking-indicator`);r&&r.remove(),l&&(l.innerHTML=``),c.appendChild(p),c.appendChild(e),Pb(m)}else{let e=c.querySelector(`.thinking-indicator`);if(e&&e.remove(),l){let e=ux(t);e&&e.trim()&&(l.innerHTML=Pt(e))}}}else if(l){let e=ux(t);if(l.querySelector(`.thinking-content`)){let t=Vb>0?vt(Date.now()-Vb):``,i=(n||[]).filter(e=>e.nodeType===`api_call`||e.nodeType===`tool_exec`),a=i.filter(e=>e.status===`success`).length,o=i.filter(e=>e.status===`failed`).length,u=i.length,d=wt(n),f=document.createElement(`div`);f.className=`thinking-process collapsed`;let p=document.createElement(`div`);p.className=`thinking-process-header`;let m=u>0?`
|
|
1665
1675
|
<span class="thinking-process-stat">
|
|
1666
1676
|
<span class="stat-icon node-icon">◉</span>
|
|
1667
1677
|
<span class="stat-label">${r(`chatStream.totalNodes`)}</span>
|
|
@@ -1696,7 +1706,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1696
1706
|
<svg class="thinking-process-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
1697
1707
|
<polyline points="6 9 12 15 18 9"/>
|
|
1698
1708
|
</svg>
|
|
1699
|
-
`,d){let e=p.querySelector(`.token-stat`);e&&(e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),At(d,e)}))}let g=document.createElement(`div`);g.className=`thinking-process-body`;let _=document.createElement(`div`);for(_.className=`thinking-process-content`,g.appendChild(_);l.firstChild;)_.appendChild(l.firstChild);let v=_.querySelectorAll(`.thinking-content`),y=e.trim();if(v.length>0){let e=v[v.length-1],t=e.textContent.trim();if(!s||s&&t===y){let t=e.previousElementSibling;for(;t;){if(t.classList.contains(`thinking-badge`)){t.remove();break}t=t.previousElementSibling}e.remove()}}if(_.children.length>0&&_.textContent.trim()){f.appendChild(p),f.appendChild(g);let t=document.createElement(`div`);t.className=`final-answer`,e&&e.trim()&&(t.innerHTML=Pt(e));let n=c.querySelector(`.thinking-indicator`);n&&n.remove(),c.appendChild(f),c.appendChild(t),Mb(p)}else{let t=c.querySelector(`.thinking-indicator`);t&&t.remove(),e&&e.trim()&&(l.innerHTML=Pt(e))}}else e&&e.trim()&&(l.innerHTML=Pt(e))}e.classList.add(`assistant`,`message`),e.dataset.rawContent=typeof t==`string`?Wt(t):JSON.stringify(t),e.dataset.textContent_=Wt(sx(t)),e.dataset.executionLog=JSON.stringify(n);let f=document.createElement(`div`);f.className=`message-footer`;let p=document.createElement(`button`);p.className=`copy-btn`,p.title=r(`chatStream.copyMarkdown`),p.innerHTML=[`<svg viewBox="0 0 16 16" fill="currentColor">`,`<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25zM5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25z"/>`,`</svg>`,`<span>`+r(`chatStream.copy`)+`</span>`].join(``),p.addEventListener(`click`,t=>{t.stopPropagation(),nb(e,p,t)}),f.appendChild(p);let m=document.createElement(`button`);m.className=`quote-btn`,m.title=r(`chatStream.quoteTitle`),m.innerHTML=[`<svg t="1781246498458" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9645" width="14" height="14"><path d="M156.09136 606.57001a457.596822 457.596822 0 0 1 221.680239-392.516385 50.844091 50.844091 0 1 1 50.844091 86.943396 355.90864 355.90864 0 0 0-138.804369 152.532274h16.77855a152.532274 152.532274 0 1 1-152.532274 152.532274z m406.752731 0a457.596822 457.596822 0 0 1 221.680239-392.007944 50.844091 50.844091 0 1 1 50.844091 86.943396 355.90864 355.90864 0 0 0-138.804369 152.532274h16.77855a152.532274 152.532274 0 1 1-152.532274 152.532274z" fill="#8a8a8a" p-id="9646"></path></svg>`,`<span>`+r(`chatStream.quote`)+`</span>`].join(``),m.addEventListener(`click`,t=>{t.stopPropagation(),ub(e)}),f.appendChild(m),f.appendChild(Iy());let h=document.createElement(`div`);h.className=`export-menu-container`;let g=document.createElement(`button`);g.className=`export-trigger-btn`,g.innerHTML=`<svg t="1781245244396" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5115" width="14" height="14"><path d="M496.213333 739.84c2.133333 2.133333 4.693333 3.84 7.68 5.12 0.853333 0.426667 2.133333 0.426667 2.986667 0.853333 1.706667 0.426667 2.986667 0.853333 4.693333 0.853334 5.546667 0 11.093333-2.133333 14.933334-6.4l256-256c8.533333-8.533333 8.533333-21.76 0-30.293334s-21.76-8.533333-30.293334 0L533.333333 674.133333V128c0-11.946667-9.386667-21.333333-21.333333-21.333333s-21.333333 9.386667-21.333333 21.333333v545.706667l-219.306667-219.306667c-8.533333-8.533333-21.76-8.533333-30.293333 0s-8.533333 21.76 0 30.293333l255.146666 255.146667zM768 874.666667H256c-11.946667 0-21.333333 9.386667-21.333333 21.333333s9.386667 21.333333 21.333333 21.333333h512c11.946667 0 21.333333-9.386667 21.333333-21.333333s-9.386667-21.333333-21.333333-21.333333z" fill="#8a8a8a" p-id="5116"></path></svg><span>`+r(`chatStream.export`)+`</span><svg class="dropdown-arrow" width="8" height="6" viewBox="0 0 8 6" fill="currentColor"><path d="M0 0l4 6 4-6z"/></svg>`;let _=document.createElement(`div`);_.className=`export-dropdown`,_.innerHTML=[`<button class="export-dropdown-item export-docx-item" type="button">`,`<svg t="1781245550030" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6544" width="32" height="32"><path d="M747.936 901.171H276.819c-72.2 0-130.953-55.224-130.953-123.078V244.721c0-67.854 58.752-123.078 130.953-123.078h383.525c6.597 0 12.937 2.505 17.795 6.954l192.363 178.046c5.317 4.96 8.386 11.914 8.386 19.227v452.223c0 67.854-58.752 123.078-130.952 123.078zM276.819 174.004c-43.31 0-78.592 31.703-78.592 70.717v533.372c0 39.015 35.282 70.718 78.592 70.718h471.117c43.31 0 78.592-31.703 78.592-70.718V337.324l-176.461-163.32H276.819z" fill="#8a8a8a" p-id="6545"></path><path d="M830.567 331.546H669.446c-14.471 0-26.18-11.71-26.18-26.181V156.209c0-14.471 11.709-26.18 26.18-26.18s26.181 11.709 26.181 26.18v122.976h134.94c14.471 0 26.181 11.709 26.181 26.18s-11.711 26.181-26.181 26.181z" fill="#8a8a8a" p-id="6546"></path><path d="M730.214 428.749l-92.04 343.616h-53.179L511.363 498.29l-75.677 274.074h-53.179l-92.04-343.616h49.088l69.542 255.667 69.541-255.667h63.406l69.541 255.667 69.541-255.667h49.088z" fill="#8a8a8a" p-id="6547"></path></svg>`,`<span>`+r(`chatStream.exportWord`)+`</span>`,`</button>`,`<button class="export-dropdown-item export-pdf-item" type="button">`,`<svg t="1781245863206" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8152" width="32" height="32"><path d="M582.4 864H170.666667c-6.4 0-10.666667-4.266667-10.666667-10.666667V170.666667c0-6.4 4.266667-10.666667 10.666667-10.666667h309.333333V320c0 40.533333 34.133333 74.666667 74.666667 74.666667h160v38.4c0 17.066667 14.933333 32 32 32s32-14.933333 32-32V298.666667c0-8.533333-4.266667-17.066667-8.533334-23.466667l-170.666666-170.666667c-6.4-6.4-14.933333-8.533333-23.466667-8.533333H170.666667C130.133333 96 96 130.133333 96 170.666667v682.666666c0 40.533333 34.133333 74.666667 74.666667 74.666667h411.733333c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32z m132.266667-550.4v17.066667H554.666667c-6.4 0-10.666667-4.266667-10.666667-10.666667V160h19.2l151.466667 153.6z" fill="#8a8a8a" p-id="8153"></path><path d="M332.8 533.333333c-12.8 0-19.2 2.133333-25.6 6.4-6.4 4.266667-8.533333 12.8-8.533333 23.466667v206.933333c0 6.4 2.133333 12.8 6.4 19.2 4.266667 4.266667 10.666667 8.533333 21.333333 8.533334s17.066667-4.266667 21.333333-8.533334c4.266667-4.266667 6.4-10.666667 6.4-19.2v-64h32c57.6 0 89.6-29.866667 89.6-87.466666 0-27.733333-8.533333-51.2-23.466666-64-14.933333-14.933333-36.266667-21.333333-66.133334-21.333334h-53.333333z m87.466667 85.333334c0 12.8-2.133333 23.466667-8.533334 27.733333-4.266667 4.266667-14.933333 8.533333-27.733333 8.533333h-32v-70.4H384c12.8 0 21.333333 2.133333 27.733333 8.533334 6.4 4.266667 8.533333 12.8 8.533334 25.6zM667.733333 571.733333c-8.533333-12.8-21.333333-21.333333-34.133333-29.866666-14.933333-4.266667-32-8.533333-51.2-8.533334h-61.866667c-8.533333 0-17.066667 0-23.466666 8.533334-2.133333 4.266667-4.266667 10.666667-4.266667 19.2V768c0 8.533333 2.133333 14.933333 4.266667 19.2 6.4 8.533333 14.933333 8.533333 23.466666 8.533333h64c19.2 0 34.133333-4.266667 49.066667-10.666666 12.8-6.4 25.6-17.066667 34.133333-29.866667 8.533333-12.8 14.933333-25.6 19.2-42.666667 4.266667-14.933333 6.4-32 6.4-49.066666 0-17.066667-2.133333-34.133333-6.4-49.066667-4.266667-14.933333-10.666667-29.866667-19.2-42.666667z m-42.666666 153.6c-8.533333 12.8-21.333333 19.2-38.4 19.2h-38.4v-160H576c21.333333 0 38.4 6.4 46.933333 19.2 10.666667 12.8 14.933333 34.133333 14.933334 59.733334 2.133333 27.733333-4.266667 46.933333-12.8 61.866666zM851.2 533.333333h-106.666667c-8.533333 0-17.066667 2.133333-21.333333 6.4-6.4 4.266667-8.533333 12.8-8.533333 21.333334v209.066666c0 6.4 2.133333 12.8 6.4 17.066667 4.266667 6.4 10.666667 8.533333 21.333333 8.533333 8.533333 0 17.066667-2.133333 21.333333-8.533333 2.133333-4.266667 6.4-8.533333 6.4-19.2v-85.333333h72.533334c12.8 0 23.466667-6.4 25.6-17.066667 2.133333-8.533333 2.133333-14.933333 0-17.066667-2.133333-4.266667-6.4-17.066667-25.6-17.066666H768v-49.066667h81.066667c8.533333 0 14.933333-2.133333 19.2-4.266667 4.266667-2.133333 8.533333-8.533333 8.533333-21.333333 2.133333-12.8-8.533333-23.466667-25.6-23.466667z" fill="#8a8a8a" p-id="8154"></path></svg>`,`<span>`+r(`chatStream.exportPdf`)+`</span>`,`</button>`,`<button class="export-dropdown-item export-image-item" type="button">`,`<svg t="1784207887308" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5993" width="32" height="32"><path d="M400.696 268.795c-17.249 0-31.233 13.986-31.233 31.233v30.471c0 17.249 13.986 31.233 31.233 31.233s31.233-13.986 31.233-31.233v-30.471c0-17.249-13.985-31.233-31.233-31.233z" fill="#8a8a8a" p-id="5994"></path><path d="M623.649 361.734c17.249 0 31.234-13.986 31.234-31.233v-30.471c0-17.249-13.986-31.233-31.234-31.233s-31.233 13.986-31.233 31.233v30.471c-0.001 17.248 13.985 31.233 31.233 31.233z" fill="#8a8a8a" p-id="5995"></path><path d="M438.295 388.804c-14.656 9.104-19.155 28.362-10.050 43.013 11.209 18.047 41.976 48.59 86.157 48.59 43.958 0 75.1-30.313 86.574-48.223 9.303-14.529 5.068-33.847-9.455-43.15-14.539-9.298-33.852-5.068-43.15 9.455-0.122 0.199-13.38 19.45-33.969 19.45-20.009 0-32.444-18.128-33.278-19.373-9.166-14.423-28.28-18.805-42.829-9.761z" fill="#8a8a8a" p-id="5996"></path><path d="M824.508503 116.690676 571.592236 116.690676c-17.248849 0-31.233352 13.985526-31.233352 31.233352s13.985526 31.233352 31.233352 31.233352l252.916267 0c40.181141 0 72.878844 32.692586 72.878844 72.878844l0 396.966057-189.334159-165.29465c-12.20088-10.655687-30.517037-10.207479-42.173518 0.9967L468.578048 674.16231 309.521472 517.519714c-11.895935-11.70253-30.903847-12.002358-43.154869-0.645706L126.957507 646.163629l0-394.126382c0-40.186258 32.692586-72.878844 72.878844-72.878844l252.916267 0c17.248849 0 31.233352-13.985526 31.233352-31.233352S470.000444 116.690676 452.751594 116.690676L199.836351 116.690676c-74.632791 0-135.346571 60.71378-135.346571 135.346571l0 520.56405c0 74.632791 60.71378 135.346571 135.346571 135.346571l252.916267 0c17.248849 0 31.233352-13.985526 31.233352-31.233352s-13.985526-31.233352-31.233352-31.233352L199.836351 845.481164c-40.186258 0-72.878844-32.692586-72.878844-72.878844l0-41.23924 160.003134-148.385539 159.428036 157.007917c12.048407 11.865235 31.361265 11.981892 43.546795 0.274246l198.576661-190.68697 208.876238 182.346001 0 40.683585c0 40.186258-32.697703 72.878844-72.878844 72.878844L571.592236 845.481164c-17.248849 0-31.233352 13.985526-31.233352 31.233352s13.985526 31.233352 31.233352 31.233352l252.916267 0c74.627674 0 135.346571-60.71378 135.346571-135.346571L959.855074 252.037247C959.855074 177.404456 899.136178 116.690676 824.508503 116.690676z" fill="#8a8a8a" p-id="5997"></path></svg>`,`<span>`+r(`chatStream.exportImage`)+`</span>`,`</button>`,`<button class="export-dropdown-item export-md-item" type="button">`,`<svg t="1784038824502" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1666" width="32" height="32"><path d="M601.216 85.333333a42.666667 42.666667 0 0 1 30.485333 12.821334l209.450667 213.973333a42.666667 42.666667 0 0 1 12.181333 29.866667V853.333333a85.333333 85.333333 0 0 1-85.333333 85.333334H256a85.333333 85.333333 0 0 1-85.333333-85.333334V170.666667a85.333333 85.333333 0 0 1 85.333333-85.333334h345.216z m-35.584 64H256a21.333333 21.333333 0 0 0-21.333333 21.333334v682.666666a21.333333 21.333333 0 0 0 21.333333 21.333334h512a21.333333 21.333333 0 0 0 21.333333-21.333334V395.413333h-191.68a32 32 0 0 1-32-32L565.632 149.333333z m64 38.186667v143.893333h140.821333L629.632 187.52z" fill="#8a8a8a" p-id="1667"></path><path d="M384.341333 800l-3.072-0.106667a32 32 0 0 1-29.162666-34.624l21.973333-256c2.752-32.256 46.165333-40.490667 60.544-11.477333l77.290667 156.010667 78.805333-156.224c14.08-27.925333 55.082667-20.906667 60.074667 8.789333l0.384 3.050667 20.714666 256a32 32 0 0 1-63.786666 5.162666l-11.541334-142.549333-56.341333 111.722667c-11.413333 22.613333-42.88 23.381333-55.744 2.517333l-1.493333-2.730667-54.912-110.826666-12.181334 142.016a32 32 0 0 1-31.552 29.269333z" fill="#8a8a8a" p-id="1668"></path></svg>`,`<span>`+r(`chatStream.exportMarkdown`)+`</span>`,`</button>`].join(``);let v=_.querySelector(`.export-docx-item`);v.addEventListener(`click`,async t=>{t.stopPropagation();let{exportAssistantMessageToDocx:n}=await M(async()=>{let{exportAssistantMessageToDocx:e}=await import(`./chat-export-Co9I1mr6.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));n(e,v,_)});let y=_.querySelector(`.export-md-item`);y.addEventListener(`click`,async t=>{t.stopPropagation();let{exportAssistantMessageToMarkdown:n}=await M(async()=>{let{exportAssistantMessageToMarkdown:e}=await import(`./chat-export-Co9I1mr6.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));n(e,y,_)});let b=_.querySelector(`.export-pdf-item`);b.addEventListener(`click`,async t=>{t.stopPropagation();let{exportAssistantMessageToPdf:n}=await M(async()=>{let{exportAssistantMessageToPdf:e}=await import(`./chat-export-Co9I1mr6.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));n(e,b,_)});let x=_.querySelector(`.export-image-item`);x.addEventListener(`click`,async t=>{t.stopPropagation();let{exportAssistantMessageToImage:n}=await M(async()=>{let{exportAssistantMessageToImage:e}=await import(`./chat-export-Co9I1mr6.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));n(e,x,_)}),g.addEventListener(`click`,e=>{e.stopPropagation(),document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==_&&e.classList.remove(`show`)}),_.classList.toggle(`show`)});let S=null;h.addEventListener(`mouseenter`,()=>{S=setTimeout(()=>{document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==_&&e.classList.remove(`show`)}),_.classList.add(`show`)},300)}),h.addEventListener(`mouseleave`,()=>{S&&=(clearTimeout(S),null),setTimeout(()=>{!h.matches(`:hover`)&&!_.matches(`:hover`)&&_.classList.remove(`show`)},100)}),h.appendChild(g),h.appendChild(_),f.appendChild(h);let C=document.createElement(`div`);C.className=`footer-right-actions`,C.style.marginLeft=`auto`,C.style.display=`flex`,C.style.alignItems=`center`,C.style.gap=`8px`;let w=wt(n);if(w){let e=document.createElement(`span`);e.className=`token-usage-tag`,e.title=r(`chatStream.tokenUsageTitle`,{total:I(w.totalTokens),prompt:I(w.promptTokens),completion:I(w.completionTokens)}),e.innerHTML=`<span class="token-tag-icon">⬤</span><span class="token-tag-value">${I(w.totalTokens)}</span>`,e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),At(w,e)}),C.appendChild(e)}let T=rv(t),E=ov(n,t);if(T.length&&(e.dataset.declaredArtifacts=JSON.stringify(T)),wv(E),E.length>0){let e=document.createElement(`button`);e.className=`artifacts-btn`,e.type=`button`,e.title=r(`artifacts.btnTitle`,{count:E.length}),e.innerHTML=`
|
|
1709
|
+
`,d){let e=p.querySelector(`.token-stat`);e&&(e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),At(d,e)}))}let g=document.createElement(`div`);g.className=`thinking-process-body`;let _=document.createElement(`div`);for(_.className=`thinking-process-content`,g.appendChild(_);l.firstChild;)_.appendChild(l.firstChild);let v=_.querySelectorAll(`.thinking-content`),y=e.trim();if(v.length>0){let e=v[v.length-1],t=e.textContent.trim();if(!s||s&&t===y){let t=e.previousElementSibling;for(;t;){if(t.classList.contains(`thinking-badge`)){t.remove();break}t=t.previousElementSibling}e.remove()}}if(_.children.length>0&&_.textContent.trim()){f.appendChild(p),f.appendChild(g);let t=document.createElement(`div`);t.className=`final-answer`,e&&e.trim()&&(t.innerHTML=Pt(e));let n=c.querySelector(`.thinking-indicator`);n&&n.remove(),c.appendChild(f),c.appendChild(t),Pb(p)}else{let t=c.querySelector(`.thinking-indicator`);t&&t.remove(),e&&e.trim()&&(l.innerHTML=Pt(e))}}else e&&e.trim()&&(l.innerHTML=Pt(e))}e.classList.add(`assistant`,`message`),e.dataset.rawContent=typeof t==`string`?Wt(t):JSON.stringify(t),e.dataset.textContent_=Wt(ux(t)),e.dataset.executionLog=JSON.stringify(n);let f=document.createElement(`div`);f.className=`message-footer`;let p=document.createElement(`button`);p.className=`copy-btn`,p.title=r(`chatStream.copyMarkdown`),p.innerHTML=[`<svg viewBox="0 0 16 16" fill="currentColor">`,`<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25zM5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25z"/>`,`</svg>`,`<span>`+r(`chatStream.copy`)+`</span>`].join(``),p.addEventListener(`click`,t=>{t.stopPropagation(),ib(e,p,t)}),f.appendChild(p);let m=document.createElement(`button`);m.className=`quote-btn`,m.title=r(`chatStream.quoteTitle`),m.innerHTML=[`<svg t="1781246498458" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9645" width="14" height="14"><path d="M156.09136 606.57001a457.596822 457.596822 0 0 1 221.680239-392.516385 50.844091 50.844091 0 1 1 50.844091 86.943396 355.90864 355.90864 0 0 0-138.804369 152.532274h16.77855a152.532274 152.532274 0 1 1-152.532274 152.532274z m406.752731 0a457.596822 457.596822 0 0 1 221.680239-392.007944 50.844091 50.844091 0 1 1 50.844091 86.943396 355.90864 355.90864 0 0 0-138.804369 152.532274h16.77855a152.532274 152.532274 0 1 1-152.532274 152.532274z" fill="#8a8a8a" p-id="9646"></path></svg>`,`<span>`+r(`chatStream.quote`)+`</span>`].join(``),m.addEventListener(`click`,t=>{t.stopPropagation(),fb(e)}),f.appendChild(m),f.appendChild(Ry());let h=document.createElement(`div`);h.className=`export-menu-container`;let g=document.createElement(`button`);g.className=`export-trigger-btn`,g.innerHTML=`<svg t="1781245244396" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5115" width="14" height="14"><path d="M496.213333 739.84c2.133333 2.133333 4.693333 3.84 7.68 5.12 0.853333 0.426667 2.133333 0.426667 2.986667 0.853333 1.706667 0.426667 2.986667 0.853333 4.693333 0.853334 5.546667 0 11.093333-2.133333 14.933334-6.4l256-256c8.533333-8.533333 8.533333-21.76 0-30.293334s-21.76-8.533333-30.293334 0L533.333333 674.133333V128c0-11.946667-9.386667-21.333333-21.333333-21.333333s-21.333333 9.386667-21.333333 21.333333v545.706667l-219.306667-219.306667c-8.533333-8.533333-21.76-8.533333-30.293333 0s-8.533333 21.76 0 30.293333l255.146666 255.146667zM768 874.666667H256c-11.946667 0-21.333333 9.386667-21.333333 21.333333s9.386667 21.333333 21.333333 21.333333h512c11.946667 0 21.333333-9.386667 21.333333-21.333333s-9.386667-21.333333-21.333333-21.333333z" fill="#8a8a8a" p-id="5116"></path></svg><span>`+r(`chatStream.export`)+`</span><svg class="dropdown-arrow" width="8" height="6" viewBox="0 0 8 6" fill="currentColor"><path d="M0 0l4 6 4-6z"/></svg>`;let _=document.createElement(`div`);_.className=`export-dropdown`,_.innerHTML=[`<button class="export-dropdown-item export-docx-item" type="button">`,`<svg t="1781245550030" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6544" width="32" height="32"><path d="M747.936 901.171H276.819c-72.2 0-130.953-55.224-130.953-123.078V244.721c0-67.854 58.752-123.078 130.953-123.078h383.525c6.597 0 12.937 2.505 17.795 6.954l192.363 178.046c5.317 4.96 8.386 11.914 8.386 19.227v452.223c0 67.854-58.752 123.078-130.952 123.078zM276.819 174.004c-43.31 0-78.592 31.703-78.592 70.717v533.372c0 39.015 35.282 70.718 78.592 70.718h471.117c43.31 0 78.592-31.703 78.592-70.718V337.324l-176.461-163.32H276.819z" fill="#8a8a8a" p-id="6545"></path><path d="M830.567 331.546H669.446c-14.471 0-26.18-11.71-26.18-26.181V156.209c0-14.471 11.709-26.18 26.18-26.18s26.181 11.709 26.181 26.18v122.976h134.94c14.471 0 26.181 11.709 26.181 26.18s-11.711 26.181-26.181 26.181z" fill="#8a8a8a" p-id="6546"></path><path d="M730.214 428.749l-92.04 343.616h-53.179L511.363 498.29l-75.677 274.074h-53.179l-92.04-343.616h49.088l69.542 255.667 69.541-255.667h63.406l69.541 255.667 69.541-255.667h49.088z" fill="#8a8a8a" p-id="6547"></path></svg>`,`<span>`+r(`chatStream.exportWord`)+`</span>`,`</button>`,`<button class="export-dropdown-item export-pdf-item" type="button">`,`<svg t="1781245863206" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8152" width="32" height="32"><path d="M582.4 864H170.666667c-6.4 0-10.666667-4.266667-10.666667-10.666667V170.666667c0-6.4 4.266667-10.666667 10.666667-10.666667h309.333333V320c0 40.533333 34.133333 74.666667 74.666667 74.666667h160v38.4c0 17.066667 14.933333 32 32 32s32-14.933333 32-32V298.666667c0-8.533333-4.266667-17.066667-8.533334-23.466667l-170.666666-170.666667c-6.4-6.4-14.933333-8.533333-23.466667-8.533333H170.666667C130.133333 96 96 130.133333 96 170.666667v682.666666c0 40.533333 34.133333 74.666667 74.666667 74.666667h411.733333c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32z m132.266667-550.4v17.066667H554.666667c-6.4 0-10.666667-4.266667-10.666667-10.666667V160h19.2l151.466667 153.6z" fill="#8a8a8a" p-id="8153"></path><path d="M332.8 533.333333c-12.8 0-19.2 2.133333-25.6 6.4-6.4 4.266667-8.533333 12.8-8.533333 23.466667v206.933333c0 6.4 2.133333 12.8 6.4 19.2 4.266667 4.266667 10.666667 8.533333 21.333333 8.533334s17.066667-4.266667 21.333333-8.533334c4.266667-4.266667 6.4-10.666667 6.4-19.2v-64h32c57.6 0 89.6-29.866667 89.6-87.466666 0-27.733333-8.533333-51.2-23.466666-64-14.933333-14.933333-36.266667-21.333333-66.133334-21.333334h-53.333333z m87.466667 85.333334c0 12.8-2.133333 23.466667-8.533334 27.733333-4.266667 4.266667-14.933333 8.533333-27.733333 8.533333h-32v-70.4H384c12.8 0 21.333333 2.133333 27.733333 8.533334 6.4 4.266667 8.533333 12.8 8.533334 25.6zM667.733333 571.733333c-8.533333-12.8-21.333333-21.333333-34.133333-29.866666-14.933333-4.266667-32-8.533333-51.2-8.533334h-61.866667c-8.533333 0-17.066667 0-23.466666 8.533334-2.133333 4.266667-4.266667 10.666667-4.266667 19.2V768c0 8.533333 2.133333 14.933333 4.266667 19.2 6.4 8.533333 14.933333 8.533333 23.466666 8.533333h64c19.2 0 34.133333-4.266667 49.066667-10.666666 12.8-6.4 25.6-17.066667 34.133333-29.866667 8.533333-12.8 14.933333-25.6 19.2-42.666667 4.266667-14.933333 6.4-32 6.4-49.066666 0-17.066667-2.133333-34.133333-6.4-49.066667-4.266667-14.933333-10.666667-29.866667-19.2-42.666667z m-42.666666 153.6c-8.533333 12.8-21.333333 19.2-38.4 19.2h-38.4v-160H576c21.333333 0 38.4 6.4 46.933333 19.2 10.666667 12.8 14.933333 34.133333 14.933334 59.733334 2.133333 27.733333-4.266667 46.933333-12.8 61.866666zM851.2 533.333333h-106.666667c-8.533333 0-17.066667 2.133333-21.333333 6.4-6.4 4.266667-8.533333 12.8-8.533333 21.333334v209.066666c0 6.4 2.133333 12.8 6.4 17.066667 4.266667 6.4 10.666667 8.533333 21.333333 8.533333 8.533333 0 17.066667-2.133333 21.333333-8.533333 2.133333-4.266667 6.4-8.533333 6.4-19.2v-85.333333h72.533334c12.8 0 23.466667-6.4 25.6-17.066667 2.133333-8.533333 2.133333-14.933333 0-17.066667-2.133333-4.266667-6.4-17.066667-25.6-17.066666H768v-49.066667h81.066667c8.533333 0 14.933333-2.133333 19.2-4.266667 4.266667-2.133333 8.533333-8.533333 8.533333-21.333333 2.133333-12.8-8.533333-23.466667-25.6-23.466667z" fill="#8a8a8a" p-id="8154"></path></svg>`,`<span>`+r(`chatStream.exportPdf`)+`</span>`,`</button>`,`<button class="export-dropdown-item export-image-item" type="button">`,`<svg t="1784207887308" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5993" width="32" height="32"><path d="M400.696 268.795c-17.249 0-31.233 13.986-31.233 31.233v30.471c0 17.249 13.986 31.233 31.233 31.233s31.233-13.986 31.233-31.233v-30.471c0-17.249-13.985-31.233-31.233-31.233z" fill="#8a8a8a" p-id="5994"></path><path d="M623.649 361.734c17.249 0 31.234-13.986 31.234-31.233v-30.471c0-17.249-13.986-31.233-31.234-31.233s-31.233 13.986-31.233 31.233v30.471c-0.001 17.248 13.985 31.233 31.233 31.233z" fill="#8a8a8a" p-id="5995"></path><path d="M438.295 388.804c-14.656 9.104-19.155 28.362-10.050 43.013 11.209 18.047 41.976 48.59 86.157 48.59 43.958 0 75.1-30.313 86.574-48.223 9.303-14.529 5.068-33.847-9.455-43.15-14.539-9.298-33.852-5.068-43.15 9.455-0.122 0.199-13.38 19.45-33.969 19.45-20.009 0-32.444-18.128-33.278-19.373-9.166-14.423-28.28-18.805-42.829-9.761z" fill="#8a8a8a" p-id="5996"></path><path d="M824.508503 116.690676 571.592236 116.690676c-17.248849 0-31.233352 13.985526-31.233352 31.233352s13.985526 31.233352 31.233352 31.233352l252.916267 0c40.181141 0 72.878844 32.692586 72.878844 72.878844l0 396.966057-189.334159-165.29465c-12.20088-10.655687-30.517037-10.207479-42.173518 0.9967L468.578048 674.16231 309.521472 517.519714c-11.895935-11.70253-30.903847-12.002358-43.154869-0.645706L126.957507 646.163629l0-394.126382c0-40.186258 32.692586-72.878844 72.878844-72.878844l252.916267 0c17.248849 0 31.233352-13.985526 31.233352-31.233352S470.000444 116.690676 452.751594 116.690676L199.836351 116.690676c-74.632791 0-135.346571 60.71378-135.346571 135.346571l0 520.56405c0 74.632791 60.71378 135.346571 135.346571 135.346571l252.916267 0c17.248849 0 31.233352-13.985526 31.233352-31.233352s-13.985526-31.233352-31.233352-31.233352L199.836351 845.481164c-40.186258 0-72.878844-32.692586-72.878844-72.878844l0-41.23924 160.003134-148.385539 159.428036 157.007917c12.048407 11.865235 31.361265 11.981892 43.546795 0.274246l198.576661-190.68697 208.876238 182.346001 0 40.683585c0 40.186258-32.697703 72.878844-72.878844 72.878844L571.592236 845.481164c-17.248849 0-31.233352 13.985526-31.233352 31.233352s13.985526 31.233352 31.233352 31.233352l252.916267 0c74.627674 0 135.346571-60.71378 135.346571-135.346571L959.855074 252.037247C959.855074 177.404456 899.136178 116.690676 824.508503 116.690676z" fill="#8a8a8a" p-id="5997"></path></svg>`,`<span>`+r(`chatStream.exportImage`)+`</span>`,`</button>`,`<button class="export-dropdown-item export-md-item" type="button">`,`<svg t="1784038824502" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1666" width="32" height="32"><path d="M601.216 85.333333a42.666667 42.666667 0 0 1 30.485333 12.821334l209.450667 213.973333a42.666667 42.666667 0 0 1 12.181333 29.866667V853.333333a85.333333 85.333333 0 0 1-85.333333 85.333334H256a85.333333 85.333333 0 0 1-85.333333-85.333334V170.666667a85.333333 85.333333 0 0 1 85.333333-85.333334h345.216z m-35.584 64H256a21.333333 21.333333 0 0 0-21.333333 21.333334v682.666666a21.333333 21.333333 0 0 0 21.333333 21.333334h512a21.333333 21.333333 0 0 0 21.333333-21.333334V395.413333h-191.68a32 32 0 0 1-32-32L565.632 149.333333z m64 38.186667v143.893333h140.821333L629.632 187.52z" fill="#8a8a8a" p-id="1667"></path><path d="M384.341333 800l-3.072-0.106667a32 32 0 0 1-29.162666-34.624l21.973333-256c2.752-32.256 46.165333-40.490667 60.544-11.477333l77.290667 156.010667 78.805333-156.224c14.08-27.925333 55.082667-20.906667 60.074667 8.789333l0.384 3.050667 20.714666 256a32 32 0 0 1-63.786666 5.162666l-11.541334-142.549333-56.341333 111.722667c-11.413333 22.613333-42.88 23.381333-55.744 2.517333l-1.493333-2.730667-54.912-110.826666-12.181334 142.016a32 32 0 0 1-31.552 29.269333z" fill="#8a8a8a" p-id="1668"></path></svg>`,`<span>`+r(`chatStream.exportMarkdown`)+`</span>`,`</button>`].join(``);let v=_.querySelector(`.export-docx-item`);v.addEventListener(`click`,async t=>{t.stopPropagation();let{exportAssistantMessageToDocx:n}=await M(async()=>{let{exportAssistantMessageToDocx:e}=await import(`./chat-export-pxivPZ1I.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));n(e,v,_)});let y=_.querySelector(`.export-md-item`);y.addEventListener(`click`,async t=>{t.stopPropagation();let{exportAssistantMessageToMarkdown:n}=await M(async()=>{let{exportAssistantMessageToMarkdown:e}=await import(`./chat-export-pxivPZ1I.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));n(e,y,_)});let b=_.querySelector(`.export-pdf-item`);b.addEventListener(`click`,async t=>{t.stopPropagation();let{exportAssistantMessageToPdf:n}=await M(async()=>{let{exportAssistantMessageToPdf:e}=await import(`./chat-export-pxivPZ1I.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));n(e,b,_)});let x=_.querySelector(`.export-image-item`);x.addEventListener(`click`,async t=>{t.stopPropagation();let{exportAssistantMessageToImage:n}=await M(async()=>{let{exportAssistantMessageToImage:e}=await import(`./chat-export-pxivPZ1I.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));n(e,x,_)}),g.addEventListener(`click`,e=>{e.stopPropagation(),document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==_&&e.classList.remove(`show`)}),_.classList.toggle(`show`)});let S=null;h.addEventListener(`mouseenter`,()=>{S=setTimeout(()=>{document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==_&&e.classList.remove(`show`)}),_.classList.add(`show`)},300)}),h.addEventListener(`mouseleave`,()=>{S&&=(clearTimeout(S),null),setTimeout(()=>{!h.matches(`:hover`)&&!_.matches(`:hover`)&&_.classList.remove(`show`)},100)}),h.appendChild(g),h.appendChild(_),f.appendChild(h);let C=document.createElement(`div`);C.className=`footer-right-actions`,C.style.marginLeft=`auto`,C.style.display=`flex`,C.style.alignItems=`center`,C.style.gap=`8px`;let w=wt(n);if(w){let e=document.createElement(`span`);e.className=`token-usage-tag`,e.title=r(`chatStream.tokenUsageTitle`,{total:I(w.totalTokens),prompt:I(w.promptTokens),completion:I(w.completionTokens)}),e.innerHTML=`<span class="token-tag-icon">⬤</span><span class="token-tag-value">${I(w.totalTokens)}</span>`,e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),At(w,e)}),C.appendChild(e)}let T=av(t),E=cv(n,t);if(T.length&&(e.dataset.declaredArtifacts=JSON.stringify(T)),Ev(E),E.length>0){let e=document.createElement(`button`);e.className=`artifacts-btn`,e.type=`button`,e.title=r(`artifacts.btnTitle`,{count:E.length}),e.innerHTML=`
|
|
1700
1710
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="14" height="14">
|
|
1701
1711
|
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
|
|
1702
1712
|
<polyline points="14 2 14 8 20 8"/>
|
|
@@ -1704,7 +1714,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1704
1714
|
<line x1="9" y1="15" x2="15" y2="15"/>
|
|
1705
1715
|
</svg>
|
|
1706
1716
|
<span class="artifacts-btn-count">${E.length}</span>
|
|
1707
|
-
`,e.addEventListener(`click`,t=>{t.stopPropagation(),
|
|
1717
|
+
`,e.addEventListener(`click`,t=>{t.stopPropagation(),Dv(E,e)}),C.appendChild(e),Tv(E,e)}if(zt(e,E.map(e=>e.path)).catch(()=>{}),n&&n.length>0&&N.chatConfig?.enableExecutionLog){let e=document.createElement(`button`);e.className=`execution-log-btn`,e.type=`button`,e.title=r(`chatStream.executionLog`),e.innerHTML=[`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<circle cx="12" cy="12" r="10"></circle>`,`<polyline points="12 6 12 12 16 14"></polyline>`,`</svg>`].join(``),C.appendChild(e)}let D=i!=null,O=n?n.filter(e=>e.nodeType===`reflection`&&e.reflectionType===`post`&&e.status===`success`).length:0,k=n?.find(e=>e.nodeType===`reflection`&&e.reflectionType===`post`);if(D&&N.chatConfig?.enableExecutionLog){let e=i>=8?`score-high`:i>=5?`score-mid`:`score-low`,t=i>=8?`✅`:i>=5?`🔍`:`⚠️`,n=O>1?r(`chatStream.reflectionRoundsTag`,{count:O}):``,a=document.createElement(`button`);a.className=`reflection-score-btn`,a.type=`button`,a.title=r(`chatStream.qualityAssessmentTitle`,{score:i,rounds:n}),a.innerHTML=`<span class="reflection-badge ${e}"><span class="reflection-badge-emoji">${t}</span> ${i}/10</span>`,a.dataset.reflectionData=JSON.stringify({overallScore:k?.overallScore??i,dimensions:k?.dimensions||null,issues:k?.issues||null,suggestions:k?.suggestions||null,decision:k?.action?.decision||null,useful:k?.useful??null,reasoning:k?.reasoning||null,suggestion:k?.suggestion||null,rounds:O,wasRevised:!1}),C.appendChild(a)}else if(!D&&k&&k.status===`failed`&&N.chatConfig?.enableExecutionLog){let e=document.createElement(`button`);e.className=`reflection-score-btn`,e.type=`button`,e.title=r(`chatStream.reflectionFailedTitle`),e.innerHTML=`<span class="reflection-badge score-low">${r(`chatStream.reflectionFailedBadge`)}</span>`,C.appendChild(e)}let A=n?.slice().reverse().find(e=>e.nodeType===`tool_exec`&&(e.action?.name===`preview_ui`||e.action?.name===`preview_ui_prototype`)&&e.status===`success`);if(A){let e=!1;if(A.observation)try{e=(typeof A.observation==`string`?JSON.parse(A.observation):A.observation)?.localOpened===!0}catch{}let t=document.createElement(`button`);t.className=`prototype-btn-small`,t.type=`button`,t.title=r(e?`chatStream.prototypeOpenedLocal`:`chatStream.viewUiPrototype`),t.innerHTML=hs,t.addEventListener(`click`,()=>{let e=A.prototypeId;if(!e&&A.observation)try{e=(typeof A.observation==`string`?JSON.parse(A.observation):A.observation)?.prototypeId}catch{}e?Ms(e):a.error(`[SidePanel] not found prototypeId,entry keys:`,Object.keys(A),`observation:`,A.observation)}),C.appendChild(t)}let j=document.createElement(`button`);j.className=`bookmark-btn`,j.title=r(`chatStream.bookmarkMessage`),j.innerHTML=`
|
|
1708
1718
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1709
1719
|
<path d="M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"/>
|
|
1710
1720
|
</svg>
|
|
@@ -1718,27 +1728,27 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1718
1728
|
<polyline points="3 6 5 6 21 6"></polyline>
|
|
1719
1729
|
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
|
|
1720
1730
|
</svg>
|
|
1721
|
-
`,te.addEventListener(`click`,t=>{t.stopPropagation(),
|
|
1731
|
+
`,te.addEventListener(`click`,t=>{t.stopPropagation(),sS(e)}),C.appendChild(te),f.appendChild(C),e.querySelector(`.message-content`).appendChild(f),Zx(),$x(),qt(),Jt(e),requestAnimationFrame(()=>{if(Db(),!Cb){let t=document.getElementById(`chatContainer`);t&&e.offsetHeight>t.clientHeight*.6&&e.scrollIntoView({behavior:`smooth`,block:`start`})}Eb()})}function ax(e){if(!e||e.disabled)return!1;try{document.dispatchEvent(new CustomEvent(`task-stop-requested`,{detail:{sessionId:N.activeSessionId}}))}catch{}e.disabled=!0,e.style.opacity=`0.4`,e.style.cursor=`not-allowed`;let t=document.querySelector(`.loading-message .stop-task-btn`);if(t){t.disabled=!0,t.style.opacity=`0.6`,t.style.cursor=`not-allowed`;let e=document.querySelector(`.loading-message .loading-text`);e&&(e.textContent=r(`chatStream.stopping`))}return chrome.runtime.sendMessage({type:`CANCEL_REACT`,tabId:null,sessionId:N.activeSessionId}),N.pendingCancelApi&&N.pendingCancelApi({message:r(`chatStream.taskStopped`),executionLog:N.currentExecutionStatus?.executionLog||[]}),!0}function ox(e){if(!e)return;e.querySelectorAll(`.thinking-indicator`).forEach(e=>e.classList.add(`hidden`));let t=e.querySelector(`.stream-status`);t&&(t.textContent=``),e.querySelectorAll(`.tool-call-executing`).forEach(e=>{e.textContent=r(`chatStream.cancelled`),e.classList.add(`tool-call-cancelled`)}),e.querySelectorAll(`.subtask-status-label`).forEach(e=>{let t=e.querySelector(`.subtask-spinner`);t&&t.remove(),e.textContent.includes(r(`chatStream.executing`))&&(e.textContent=r(`chatStream.cancelled`))}),e.querySelectorAll(`.subtask-progress-active`).forEach(e=>e.classList.remove(`subtask-progress-active`)),e.querySelectorAll(`.subtask-node-spinner`).forEach(e=>e.replaceWith(`○`)),e.querySelectorAll(`.subtask-spinner, .thinking-spinner, .loading-dots`).forEach(e=>e.remove()),e.classList.remove(`streaming`),e.classList.add(`stream-cancelled`),e.querySelectorAll(`.tool-call-abort-btn`).forEach(e=>e.style.display=`none`),e.querySelectorAll(`.tool-call-terminate-btn`).forEach(e=>e.style.display=`none`)}db(dx),n(`zh`,{chatMsg:{searchPrompt:`搜索一下`,exportWord:`导出 Word`,exportPdf:`导出 PDF`,exportImage:`导出图片`,exportMarkdown:`导出 Markdown`,executionLogTitle:`执行日志`,revisedTag:`已修订`,roundsTag:` ({count}轮)`,revisedSuffix:`(已修订)`,scoreBadgeTitle:`AI 质量评估: {score}/10{rounds}{revised}
|
|
1722
1732
|
点击查看评估详情`,reflectionFailedTitle:`反思评估失败(点击查看执行日志)`,reflectionFailedBadge:`⚠️ 反思失败`,prototypeLocalOpened:`已在本地浏览器打开,点击可在面板内查看`,prototypeView:`查看 UI 原型`,bookmarkMessage:`收藏消息`,unbookmarkMessage:`取消收藏`,forkSession:`从此处分叉会话(仅复制到此条消息)`,deleteMessageTitle:`删除消息`,resumeTaskTitle:`从上次中断处继续执行任务`,resumeTaskBtn:`继续执行`,clickToEnlarge:`点击查看大图`,fileExtracting:` 提取中...`,fileFailed:` 失败`,fileExtractFailed:`提取失败`,copyMessageTitle:`复制消息内容`,editAndResend:`编辑后重新发送`,thinking:`思考中...`,stopTask:`停止任务`,viewExecutionLog:`查看执行日志`,preparing:`准备中...`,emptyModelReply:`模型未返回任何内容。若你发送了图片,请确认所选模型支持视觉识别(图片识别需选择支持多模态视觉的模型),或更换模型后重试。`,stopping:`停止中...`,retrying:`连接异常,正在重试 ({attempt}/{max})...`,copyCode:`复制代码`,aborting:`正在终止...`,terminateCommandTitle:`终止命令执行`,terminateCommandPrompt:`请选择终止方式:`,terminateWaitTitle:`终止等待`,terminateWaitDesc:`仅停止等待命令输出,后台进程继续运行。<br/>适用于挂起型服务(如 npm run dev)。`,terminateCommandBtnTitle:`终止命令`,terminateCommandBtnDesc:`直接终止后台命令进程,释放资源。`,confirmDeleteMessage:`确认删除消息`,deleteMessageWarning:`删除后消息将从对话历史中移除,且无法恢复。`,confirmDelete:`确认删除`,quotedContextLabel:`💬 已引用: {text}`,selectedContextLabel:`📌 已选中: {text}`,subtaskDone:`完成`,subtaskFailed:`失败`,subtaskPartial:`部分完成`,subtaskFailReason:`中断原因:{error}`,subtaskExecuting:`执行中...`,subtaskPending:`待执行`,subtaskDescLabel:`任务描述:`,subtaskResultLabel:`产出摘要:`,subtaskAllDone:`✓ 全部完成`,subtaskReplaySkipped:`已跳过重放`,subtaskReplaySkippedHint:`中断前已成功完成,本轮未重复执行,写操作不会二次生效`,subtaskFilterEmpty:`当前过滤下无匹配节点`,subtaskFilterHint:`点击按此状态过滤节点,再点取消`,subtaskStatOtherHint:`已取消 / 未完成节点(用户拒绝确认、任务终止时仍在执行等),点击过滤`,subtaskPartialFail:`✗ {success}/{total} 完成,{fail} 个节点失败`,unknownNode:`未知`,stopGeneration:`停止生成`,toolResultTitle:`执行结果`,reflectionInProgress:`质量评估中...`,cannotGetMessageContent:`无法获取消息内容`,editFailed:`编辑失败: {message}`,errTaskStopped:`任务已被用户停止`,errTaskReplaced:`任务已被新请求替代`,errSwRestarted:`后台服务异常重启,API 调用已中断`,errTimeout:`请求超时({seconds}秒)`,cancelBtn:`取消`}}),n(`en`,{chatMsg:{searchPrompt:`Search`,exportWord:`Export Word`,exportPdf:`Export PDF`,exportImage:`Export Image`,exportMarkdown:`Export Markdown`,executionLogTitle:`Execution Log`,revisedTag:`Revised`,roundsTag:` ({count} rounds)`,revisedSuffix:` (Revised)`,scoreBadgeTitle:`AI Quality Assessment: {score}/10{rounds}{revised}
|
|
1723
|
-
Click to view assessment details`,reflectionFailedTitle:`Reflection assessment failed (click to view execution log)`,reflectionFailedBadge:`⚠️ Reflection Failed`,prototypeLocalOpened:`Opened in local browser, click to view in panel`,prototypeView:`View UI Prototype`,bookmarkMessage:`Bookmark message`,unbookmarkMessage:`Remove bookmark`,forkSession:`Fork session from here (copy up to this message only)`,deleteMessageTitle:`Delete message`,resumeTaskTitle:`Resume task from last interruption`,resumeTaskBtn:`Resume`,clickToEnlarge:`Click to view full size`,fileExtracting:` extracting...`,fileFailed:` failed`,fileExtractFailed:`Extraction failed`,copyMessageTitle:`Copy message content`,editAndResend:`Edit and resend`,thinking:`Thinking...`,stopTask:`Stop task`,viewExecutionLog:`View execution log`,preparing:`Preparing...`,emptyModelReply:`The model returned no content. If you sent an image, make sure the selected model supports vision (image recognition requires a multimodal vision model), or switch model and retry.`,stopping:`Stopping...`,retrying:`Connection unstable, retrying ({attempt}/{max})...`,copyCode:`Copy code`,aborting:`Aborting...`,terminateCommandTitle:`Terminate Command Execution`,terminateCommandPrompt:`Please select a termination method:`,terminateWaitTitle:`Stop Waiting`,terminateWaitDesc:`Only stop waiting for command output; the background process continues running.<br/>Suitable for hanging services (e.g. npm run dev).`,terminateCommandBtnTitle:`Terminate Command`,terminateCommandBtnDesc:`Directly terminate the background command process and release resources.`,confirmDeleteMessage:`Confirm Delete Message`,deleteMessageWarning:`After deletion, the message will be removed from the conversation history and cannot be recovered.`,confirmDelete:`Confirm Delete`,quotedContextLabel:`💬 Quoted: {text}`,selectedContextLabel:`📌 Selected: {text}`,subtaskDone:`Done`,subtaskFailed:`Failed`,subtaskPartial:`Partial`,subtaskFailReason:`Interrupted: {error}`,subtaskExecuting:`Executing...`,subtaskPending:`Pending`,subtaskDescLabel:`Description: `,subtaskResultLabel:`Output summary: `,subtaskAllDone:`✓ All done`,subtaskReplaySkipped:`replay skipped`,subtaskReplaySkippedHint:`Already completed before the interruption; not re-run this round, so side effects do not apply twice`,subtaskFilterEmpty:`No nodes match this filter`,subtaskFilterHint:`Click to filter nodes by this status, click again to clear`,subtaskStatOtherHint:`Cancelled / unfinished nodes (denied confirmations, still running when the task ended). Click to filter`,subtaskPartialFail:`✗ {success}/{total} done, {fail} nodes failed`,unknownNode:`Unknown`,stopGeneration:`Stop generation`,toolResultTitle:`Execution Result`,reflectionInProgress:`Assessing quality...`,cannotGetMessageContent:`Cannot get message content`,editFailed:`Edit failed: {message}`,errTaskStopped:`Task stopped by user`,errTaskReplaced:`Task replaced by new request`,errSwRestarted:`Background service restarted unexpectedly, API call interrupted`,errTimeout:`Request timeout ({seconds}s)`,cancelBtn:`Cancel`}});var
|
|
1733
|
+
Click to view assessment details`,reflectionFailedTitle:`Reflection assessment failed (click to view execution log)`,reflectionFailedBadge:`⚠️ Reflection Failed`,prototypeLocalOpened:`Opened in local browser, click to view in panel`,prototypeView:`View UI Prototype`,bookmarkMessage:`Bookmark message`,unbookmarkMessage:`Remove bookmark`,forkSession:`Fork session from here (copy up to this message only)`,deleteMessageTitle:`Delete message`,resumeTaskTitle:`Resume task from last interruption`,resumeTaskBtn:`Resume`,clickToEnlarge:`Click to view full size`,fileExtracting:` extracting...`,fileFailed:` failed`,fileExtractFailed:`Extraction failed`,copyMessageTitle:`Copy message content`,editAndResend:`Edit and resend`,thinking:`Thinking...`,stopTask:`Stop task`,viewExecutionLog:`View execution log`,preparing:`Preparing...`,emptyModelReply:`The model returned no content. If you sent an image, make sure the selected model supports vision (image recognition requires a multimodal vision model), or switch model and retry.`,stopping:`Stopping...`,retrying:`Connection unstable, retrying ({attempt}/{max})...`,copyCode:`Copy code`,aborting:`Aborting...`,terminateCommandTitle:`Terminate Command Execution`,terminateCommandPrompt:`Please select a termination method:`,terminateWaitTitle:`Stop Waiting`,terminateWaitDesc:`Only stop waiting for command output; the background process continues running.<br/>Suitable for hanging services (e.g. npm run dev).`,terminateCommandBtnTitle:`Terminate Command`,terminateCommandBtnDesc:`Directly terminate the background command process and release resources.`,confirmDeleteMessage:`Confirm Delete Message`,deleteMessageWarning:`After deletion, the message will be removed from the conversation history and cannot be recovered.`,confirmDelete:`Confirm Delete`,quotedContextLabel:`💬 Quoted: {text}`,selectedContextLabel:`📌 Selected: {text}`,subtaskDone:`Done`,subtaskFailed:`Failed`,subtaskPartial:`Partial`,subtaskFailReason:`Interrupted: {error}`,subtaskExecuting:`Executing...`,subtaskPending:`Pending`,subtaskDescLabel:`Description: `,subtaskResultLabel:`Output summary: `,subtaskAllDone:`✓ All done`,subtaskReplaySkipped:`replay skipped`,subtaskReplaySkippedHint:`Already completed before the interruption; not re-run this round, so side effects do not apply twice`,subtaskFilterEmpty:`No nodes match this filter`,subtaskFilterHint:`Click to filter nodes by this status, click again to clear`,subtaskStatOtherHint:`Cancelled / unfinished nodes (denied confirmations, still running when the task ended). Click to filter`,subtaskPartialFail:`✗ {success}/{total} done, {fail} nodes failed`,unknownNode:`Unknown`,stopGeneration:`Stop generation`,toolResultTitle:`Execution Result`,reflectionInProgress:`Assessing quality...`,cannotGetMessageContent:`Cannot get message content`,editFailed:`Edit failed: {message}`,errTaskStopped:`Task stopped by user`,errTaskReplaced:`Task replaced by new request`,errSwRestarted:`Background service restarted unexpectedly, API call interrupted`,errTimeout:`Request timeout ({seconds}s)`,cancelBtn:`Cancel`}});var sx=`pendingCallApiSessions`;function cx(){chrome.storage.session.set({[sx]:[...N.pendingCallApiSessionIds]}).catch(()=>{})}async function lx(){try{let e=await chrome.storage.session.get([sx]);e[sx]&&Array.isArray(e[sx])&&(N.pendingCallApiSessionIds=new Set(e[sx]))}catch{}}function ux(e){if(Array.isArray(e))return e.filter(e=>e.type===`text`).map(e=>e.text).join(``);if(typeof e==`string`&&e.startsWith(`[`))try{let t=JSON.parse(e);if(Array.isArray(t))return t.filter(e=>e.type===`text`).map(e=>e.text).join(``)}catch{}return e}function dx(e){let t=ux(e);N.quotedContextText=t;let n=document.getElementById(`selectionIndicator`),i=document.getElementById(`selectionText`),a=document.getElementById(`userInput`);if(n&&i&&a){let e;e=t.length>100?t.substring(0,100)+`...`:t.length>50?t.substring(0,50)+`...`:t,i.textContent=r(`chat.quotedPrefix`,{text:e}),n.classList.add(`show`)}}function fx(){let e=document.getElementById(`selectionIndicator`),t=document.getElementById(`selectionText`);if(!e||!t)return;let n=(N.quotedContextText||``).trim(),i=(N.selectedContextText||``).trim(),a=n||i;if(!a){e.classList.remove(`show`);return}let o;o=a.length>100?a.substring(0,100)+`...`:a.length>50?a.substring(0,50)+`...`:a,t.textContent=r(n?`chatMsg.quotedContextLabel`:`chatMsg.selectedContextLabel`,{text:o}),e.classList.add(`show`)}function px(){a.debug(`[SidePanel] clear selectedcontenttext `),N.selectedContextText=``,N.quotedContextText=``;let e=document.getElementById(`selectionIndicator`),t=document.getElementById(`userInput`);if(e&&(e.classList.remove(`show`),a.debug(`[SidePanel] hiddenselected contentprompt`)),typeof window.hideFloatingMenu==`function`&&window.hideFloatingMenu(),t&&t.value.startsWith(`[选中内容]`)){let e=t.value.split(`
|
|
1724
1734
|
`),n=e.findIndex(e=>e.startsWith(`[用户问题]`));n===-1?t.value=``:t.value=e.slice(n+1).join(`
|
|
1725
|
-
`).trim()}}var
|
|
1735
|
+
`).trim()}}var mx,hx=new Promise(e=>{mx=e});function gx(){N.activeSessionId&&document.dispatchEvent(new CustomEvent(`session-hydrated`,{detail:{sessionId:N.activeSessionId,workdir:N.sessionWorkdir||null}}))}async function _x(){try{await vx()}finally{mx()}}async function vx(){let e=await gi();if(e.activeSessionId&&e.list.length>0){N.activeSessionId=e.activeSessionId,N.sessions=e.list;let t=e.list.find(t=>t.id===e.activeSessionId);if(t){if(N.messageHistory=t.messageHistory||[],N.activeCompaction=t.contextCompaction||null,vi(t),gx(),N.currentModel=t.model||N.currentModel,N.useTools=t.useTools===void 0?N.useTools:t.useTools,N.temperature=t.temperature===void 0?N.temperature:t.temperature,N.topP=t.topP===void 0?N.topP:t.topP,N.activeAgentId=t.agentId||null,N.activeAgentId&&N.activeAgentId!=="default"){try{let{getAgent:e}=await M(async()=>{let{getAgent:e}=await import(`./agent-store-DR_A4rFm.js`).then(e=>e.t);return{getAgent:e}},__vite__mapDeps([0,1,2,3,4])),t=await e(N.activeAgentId);t&&(N.activeAgentMcpExcludedServerIds=t.mcpExcludedServerIds??null,t.model&&(N.currentModel=t.model),t.temperature!==null&&t.temperature!==void 0&&(N.temperature=t.temperature,N.topP=t.topP!==null&&t.topP!==void 0?t.topP:1),document.dispatchEvent(new CustomEvent(`agent-model-changed`)))}catch{}N.activeAgentMcpExcludedServerIds=null}else{N.activeAgentMcpExcludedServerIds=null;try{let e=await chrome.storage.local.get([`modelName`,`temperature`,`topP`]);e.modelName&&(N.currentModel=e.modelName),e.temperature!==void 0&&(N.temperature=e.temperature),e.topP!==void 0&&(N.topP=e.topP)}catch{}document.dispatchEvent(new CustomEvent(`agent-model-changed`))}let e=`agentMcpClosedServers_${N.activeAgentId||`default`}`;N.mcpClosedServers=(await chrome.storage.local.get([e]))[e]||[]}let n=document.getElementById(`chatContainer`);n&&n.querySelectorAll(`.message, .user-context-bubble`).forEach(e=>e.remove()),N.messageHistory.forEach(e=>{let t=e.wasRevised;if(!t&&e.executionLog)try{t=(typeof e.executionLog==`string`?JSON.parse(e.executionLog):e.executionLog).some(e=>e.nodeType===`reflection`&&e.reflectionType===`post`&&e.action?.decision===`revised`)}catch{}if(e.role===`user`&&e.contextBubbles&&Array.isArray(e.contextBubbles)&&e.contextBubbles.forEach(e=>{let t=``;switch(e.type){case`skill`:t=r(`contextBubble.bubbleSkill`,{name:e.name,desc:e.description?`:`+e.description:``});break;case`mcp`:t=r(`contextBubble.bubbleMcp`,{name:e.serverName});break;case`page`:t=r(`contextBubble.bubblePage`,{title:e.title,url:e.url});break;case`file`:t=`${e.name} (${If(e.size||0)})`;break;case`knowledge`:{let t=Array.isArray(e.refs)?e.refs:[];t.length>0&&Ex(t,e.failed===!0);break}}t&&e.type!==`file`&&Gx(e.type,t,!1)}),e.htmlContent)rS(e.htmlContent,e.messageId,e.resumable);else{let n=(e.contextBubbles||[]).filter(e=>e.type===`file`).map(e=>({name:e.name,size:e.size||0,type:e.fileType||``}));Jx(e.role,e.content,!1,e.executionLog||[],e.reflectionScore,t,null,e.messageId,n,e.resumable,e.timestamp??null)}}),Zx(),$x(),Nt();let i=document.querySelector(`.welcome-message`);i&&N.messageHistory.length>0&&i.remove(),Bt(),qt(),Cw(),e.activeSessionId===N.activeSessionId?Oo(e):Oo(),await vb();let a=`scrollPosition_`+(N.activeSessionId||`default`);chrome.storage.local.get([a],e=>{e[a]!==void 0&&setTimeout(()=>{let t=document.getElementById(`chatContainer`);t.scrollTop=e[a]},100)})}else{await bi();let e=await gi();e.activeSessionId&&(N.activeSessionId=e.activeSessionId,N.sessions=e.list,vi(e.list.find(t=>t.id===e.activeSessionId)),gx()),Oo(e)}}function yx(){try{_i().catch(e=>{a.error(`[SidePanel] save currentsession failed:`,e)})}catch(e){a.error(`[SidePanel] save conversationhistory exception:`,e)}}async function bx(){try{await _i()}catch(e){a.error(`[SidePanel] save conversationhistory exception:`,e)}}function xx(){N.messageHistory&&N.messageHistory.length>0&&Ti().then(()=>{N.messageHistory=[],N.activeCompaction=null;let e=document.getElementById(`chatContainer`);if(e){e.innerHTML=``;let t=document.createElement(`div`);t.className=`welcome-message`,t.innerHTML=`
|
|
1726
1736
|
<div class="icon-wrapper">
|
|
1727
1737
|
<div class="icon">💬</div>
|
|
1728
1738
|
</div>
|
|
1729
1739
|
<h2>${r(`chat.welcomeTitle`)}</h2>
|
|
1730
1740
|
<p>${r(`chat.welcomeSubtitle`)}</p>
|
|
1731
|
-
`,e.appendChild(t)}chrome.storage.local.remove(`scrollPosition_`+(N.activeSessionId||`default`)),Oo()})}function
|
|
1741
|
+
`,e.appendChild(t)}chrome.storage.local.remove(`scrollPosition_`+(N.activeSessionId||`default`)),Oo()})}function Sx(){document.getElementById(`confirmModal`).classList.add(`show`)}function Cx(){document.getElementById(`confirmModal`).classList.remove(`show`)}var wx=1500;async function Tx(e,t){if(!t||t.length===0)return null;let{ragEnabled:n}=await chrome.storage.local.get(`ragEnabled`);if(n!==!0)return a.debug(`[SidePanel] RAG global switch off, skip knowledge context`),null;let i=await new Promise(n=>{try{chrome.runtime.sendMessage({type:`RAG_SEARCH`,params:{query:e,collectionIds:t.map(e=>e.id).filter(Boolean),topK:5}},e=>{if(chrome.runtime.lastError){n(null);return}n(e&&e.success?e:null)})}catch{n(null)}}),o=!i,s=i&&i.results||[],c=new Map(t.filter(e=>e.id).map(e=>[e.id,e.name])),l=new Map;s.forEach(e=>{let t=e.collectionId||``,n=l.get(t);n||(n={id:t,name:c.get(t)||t||r(`contextBubble.labelKnowledge`),hitCount:0,items:[]},l.set(t,n)),n.items.push(e),n.hitCount++});let u=Array.from(l.values()),d=s.length,f=e=>e.map(e=>{let t=String(e.content||``).trim();return{score:typeof e.score==`number`?e.score:Number(e.score)||0,content:t.slice(0,wx),truncated:t.length>wx,fullLength:t.length}}),p=t.map(e=>({id:e.id,name:e.name,hitCount:e.id&&l.get(e.id)?.hitCount||0,hits:e.id?f(l.get(e.id)?.items||[]):[]}));u.forEach(e=>{p.some(t=>t.id&&t.id===e.id)||p.push({id:e.id,name:e.name,hitCount:e.hitCount,hits:f(e.items)})});let m=[`[知识库检索结果](引用: ${t.map(e=>e.name).join(`、`)})`];return o?m.push(`知识库检索失败:检索服务暂时不可用(这不代表知识库中没有相关内容)。`):d===0?m.push(`未找到与问题相关的内容。`):u.forEach(e=>{m.push(``),m.push(`【${e.name}】`),e.items.forEach(e=>{let t=typeof e.score==`number`?e.score.toFixed(3):String(e.score??``);m.push(`· 相关度 ${t}`),m.push(String(e.content||``).trim().slice(0,wx)),m.push(``)})}),m.push(`[/知识库检索结果]`),{text:m.join(`
|
|
1732
1742
|
`)+`
|
|
1733
1743
|
|
|
1734
|
-
`,refs:p,failed:o}}function
|
|
1744
|
+
`,refs:p,failed:o}}function Ex(e,t=!1){if(!Array.isArray(e)||e.length===0)return;let n=e.reduce((e,t)=>e+(t.hitCount||0),0);if(t){Gx(`knowledge`,r(`contextBubble.bubbleKnowledgeFailed`,{name:e.map(e=>e.name).join(`、`)}),!1);return}if(n===0){Gx(`knowledge`,r(`contextBubble.bubbleKnowledgeMiss`,{name:e.map(e=>e.name).join(`、`)}),!1);return}e.forEach(e=>{(e.hitCount||0)>0?Gx(`knowledge`,r(`contextBubble.bubbleKnowledge`,{name:e.name,count:e.hitCount}),!1,Array.isArray(e.hits)?e.hits:null):Gx(`knowledge`,r(`contextBubble.bubbleKnowledgeMiss`,{name:e.name}),!1)})}function Dx(e,t,n,r=.8){return e===`failed`?!n||n<=0?`failed`:t/n>=r?`partial`:`failed`:e}function Ox(e){let t=Array.isArray(e)?e:[],n=0,r=0;for(let e of t)e&&e.status===`success`?n++:e&&e.status===`failed`&&r++;return{total:t.length,success:n,failed:r,other:t.length-n-r}}function kx(e,t){return(Array.isArray(e)?e:[]).some(e=>!!e&&e.nodeType===`subtask`&&e.subtaskIndex===t&&e.skippedReplay===!0)}function Ax(e,t){return t!==`success`&&t!==`failed`&&t!==`other`?e||null:e===t?null:t}function jx(e,t){let n=Array.isArray(e)?e:[];return t!==`success`&&t!==`failed`&&t!==`other`?n:t===`other`?n.filter(e=>!e||e.status!==`success`&&e.status!==`failed`):n.filter(e=>e&&e.status===t)}var Mx=`<svg class="subtask-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="17" rx="2"/><line x1="8" y1="2" x2="8" y2="4"/><line x1="16" y1="2" x2="16" y2="4"/><line x1="3" y1="10" x2="21" y2="10"/></svg>`,Nx=`<svg class="subtask-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>`;function Px(e){let t=Array.isArray(e)?e:[],n=null;for(let e of t)!e||e.nodeType!==`subtask_plan`||!Array.isArray(e.items)||(!n||new Date(e.timestamp||0)>=new Date(n.timestamp||0))&&(n=e);if(!n)return null;let r=n.items,i=r.filter(e=>e&&typeof e.index==`number`);return{total:n.subtaskTotal||r.length,items:i,timestamp:n.timestamp}}function Fx(e,t){let n=e.description?String(e.description).replace(/\s+/g,` `).trim():``,i=n?`<div class="subtask-detail-desc"><span class="subtask-detail-label">${r(`chatMsg.subtaskDescLabel`)}</span>${F(n)}</div>`:``;return`
|
|
1735
1745
|
<div class="subtask-header">
|
|
1736
|
-
${
|
|
1746
|
+
${Nx}${Mx}${`<span class="subtask-badge">${e.index+1}/${t}</span>`}<span class="subtask-name" title="${L(n)}">${F(e.name||``)}</span><span class="subtask-status-pending">${r(`chatMsg.subtaskPending`)}</span>
|
|
1737
1747
|
</div>
|
|
1738
1748
|
<div class="subtask-detail-body">${i}</div>
|
|
1739
|
-
`}function
|
|
1749
|
+
`}function Ix(e){!e||e._clickDelegated||(e._clickDelegated=!0,e.addEventListener(`click`,t=>{let n=t.target.closest(`[data-node-filter]`);if(n){t.stopPropagation(),e._nodeFilter=Ax(e._nodeFilter||null,n.dataset.nodeFilter),e._nodeFilter&&e.classList.add(`subtask-expanded`),e._renderNodes?.();return}t.target.closest(`.subtask-header`)&&e.classList.toggle(`subtask-expanded`)}))}function Lx(e,t){let n=Number(t.dataset.subtaskIndex),r=Array.from(e.querySelectorAll(`.subtask-progress[data-subtask-index]`)).find(e=>Number(e.dataset.subtaskIndex)>n);r?e.insertBefore(t,r):e.appendChild(t)}function Rx(e){let t=e||r(`chatResume.unknownError`),n=t.toLowerCase();return n.includes(`network`)||n.includes(`failed to fetch`)||n.includes(`load failed`)?r(`chat.networkError`):n.includes(`timeout`)||t.includes(`超时`)?r(`chat.timeoutError`,{message:t}):r(`chat.requestFailed`,{message:t})}var zx=Object.freeze({quotedContextText:``,selectedContextText:``,selectedSkills:[],selectedMcpServices:[],knowledgeRefs:[],selectedPage:null,attachedFiles:[],attachedImages:[]});function Bx(){return{quotedContextText:N.quotedContextText||``,selectedContextText:N.selectedContextText||``,selectedSkills:(N.selectedSkills||[]).slice(),selectedMcpServices:(N.selectedMcpServices||[]).slice(),knowledgeRefs:(N.knowledgeRefs||[]).slice(),selectedPage:N.selectedPage||null,attachedFiles:(N.attachedFiles||[]).slice(),attachedImages:(N.attachedImages||[]).slice()}}async function Vx(e={}){await hx;let t=document.getElementById(`userInput`),n=document.getElementById(`chatContainer`),i=e.sessionId||N.activeSessionId,o=i===N.activeSessionId,s=o?null:e.sessionState||{},c=o?N.messageHistory:s.messageHistory||[],l=e.context||(o?Bx():zx),f=!e.context,p=o?N.currentModel:s.model||N.currentModel,m=o||s.useTools===void 0?N.useTools:s.useTools,g=o?N.enabledTools:s.enabledTools||N.enabledTools,_=o?N.activeCompaction:s.contextCompaction||null,v=String(e.text==null?t?.value||``:e.text).trim();if(!v)return{ok:!1,reason:`empty`};if(e.fromQueue||Wl(),N.generatingSessionIds.has(i))return{ok:!1,reason:`generating`};if(gb(i),chrome.runtime.sendMessage({type:`DELETE_CHECKPOINT`,sessionId:i}),o&&await ac({state:N,getRatio:()=>cw().usage?.ratio??0,compact:_w}),o){let e=n?.querySelector(`.welcome-message`);e&&e.remove()}let b=v,x=l.selectedContextText&&l.selectedContextText.trim(),S=l.quotedContextText&&l.quotedContextText.trim(),C=[];if(S){let e=l.quotedContextText.trim(),{compressed:t,wasCompressed:n}=O(e);b=`[引用内容${n?`摘要`:``}]\n${t}\n\n[用户问题]\n${v}`,o&&Gx(`quoted`,e,!1),C.push({type:`quoted`,text:e}),o&&f&&N.quotedContextText===l.quotedContextText&&(N.quotedContextText=``)}else if(x){let e=l.selectedContextText.trim(),{compressed:t,wasCompressed:n}=O(e);b=`[选中内容${n?`摘要`:``}]\n${t}\n\n[用户问题]\n${v}`,o&&Gx(`selected`,e,!1),C.push({type:`selected`,text:e}),o&&f&&N.selectedContextText===l.selectedContextText&&(N.selectedContextText=``)}let w=await $S(l.selectedSkills);if(w){b=w+b;for(let e of l.selectedSkills||[])o&&Gx(`skill`,r(`contextBubble.bubbleSkill`,{name:e.name,desc:e.description?`:`+e.description:``}),!1),C.push({type:`skill`,name:e.name,description:e.description||``});if(o){let e=new Set(l.selectedSkills||[]),t=N.selectedSkills.filter(t=>!e.has(t));t.length!==N.selectedSkills.length&&(N.selectedSkills=t,N.selectedSkillIndex=-1,qS(),JS())}}let T=null,E=oC(l.selectedMcpServices);if(E){let e=(l.selectedMcpServices||[]).map(e=>e.serverId).filter(Boolean);T=e.length>0?e:null,b=E+b;for(let e of l.selectedMcpServices||[])o&&Gx(`mcp`,r(`contextBubble.bubbleMcp`,{name:e.serverName}),!1),C.push({type:`mcp`,serverName:e.serverName,serverId:e.serverId||``});if(o){let e=new Set(l.selectedMcpServices||[]),t=N.selectedMcpServices.filter(t=>!e.has(t));t.length!==N.selectedMcpServices.length&&(N.selectedMcpServices=t,N.selectedMcpServiceIndex=-1,sC(),cC())}}if((l.knowledgeRefs||[]).length>0){let e=l.knowledgeRefs.slice();o&&(N.isGenerating=!0);let t=o?Gx(`knowledge`,r(`contextBubble.bubbleKnowledgeSearching`),!0):null,n=null;try{n=await Tx(v,e)}catch(e){a.warn(`[SidePanel] knowledge search failed:`,e)}if(t&&t.parentNode&&t.remove(),n&&(b=n.text+b,o&&Ex(n.refs,n.failed===!0),C.push({type:`knowledge`,refs:n.refs,failed:n.failed||void 0})),o){let t=new Set(e),n=N.knowledgeRefs.filter(e=>!t.has(e));n.length!==N.knowledgeRefs.length&&(N.knowledgeRefs=n,ey(),iy())}}if(l.selectedPage){let e=l.selectedPage;b=`[网页上下文]\n标题: ${e.title}\nURL: ${e.url}\ntabId: ${e.id}\n`+b,o&&Gx(`page`,r(`contextBubble.bubblePage`,{title:e.title,url:e.url}),!1),C.push({type:`page`,title:e.title,url:e.url}),o&&N.selectedPage===l.selectedPage&&vy()}let D=!1,k=(l.attachedFiles||[]).slice();if(k.length>0){let e=ep(k);e&&(b+=e);try{await ne(i,k)}catch(e){a.warn(`[Chat] save doc image snapshot failed:`,e.message)}k.forEach(e=>{e.status===`done`&&C.push({type:`file`,name:e.name,size:e.size,fileType:e.type})})}let j=`msg_`+Date.now().toString(36)+`_`+Math.random().toString(36).substring(2,8),ee=new Date().toISOString(),te={role:`user`,content:df(b,l.attachedImages),messageId:j,timestamp:ee,contextBubbles:C};o?(Jx(`user`,df(v,l.attachedImages),!0,[],null,!1,b,j,k,!1,ee),N.messageHistory.push(te),yx(),Pn(v),N.inputHistoryIndex=-1):c.push(te),D=!0,o&&!e.fromQueue&&(t.value=``,t.style.height=`auto`),o&&(x||S)&&(!N.quotedContextText&&!N.selectedContextText?px():fx()),N.generatingSessionIds.add(i),document.dispatchEvent(new CustomEvent(`generating-state-changed`));let re=o?eS():null,ie=N.enableImageInput&&(l.attachedImages||[]).length>0&&N.imageModelName||p;if(o&&(l.attachedImages||[]).length>0){let e=new Set(l.attachedImages),t=N.attachedImages.filter(t=>!e.has(t));t.length!==N.attachedImages.length&&(N.attachedImages=t,uf())}if(o&&k.length>0){let e=new Set(k),t=N.attachedFiles.filter(t=>!e.has(t));if(t.length!==N.attachedFiles.length){for(let t of N.attachedFiles)e.has(t)&&t.dataUrl&&URL.revokeObjectURL(t.dataUrl);N.attachedFiles=t,$f()}}let ae=e=>{if(!o){c.push(e);return}if(N.activeSessionId!==i){Di(i,e);return}N.messageHistory.push(e)};try{await Tt();let e=await $C(o?N.activeAgentId:s.agentId||null),t=ew(e),n=e?.skillIds??null;o&&(N.activeAgentToolIds=t,N.activeAgentSkillIds=n,N.activeAgentMcpExcludedServerIds=e?e.mcpExcludedServerIds??null:null);let f={agentId:o?N.activeAgentId:s.agentId||null,agentToolIds:t,agentSkillIds:n,agentMcpExcludedServerIds:e?e.mcpExcludedServerIds??null:null};a.debug(`[SidePanel] sendmessagedebuginfo:`),a.debug(` - agent:`,e?e.name:`default assistant`),a.debug(` - agentToolIds:`,t),a.debug(` - isolateChat:`,N.isolateChat),a.debug(` - chatConfig:`,N.chatConfig),a.debug(` - messageHistory.length:`,c.length);let p=[{role:`system`,content:await kt(e,{sessionId:i})}];if(N.isolateChat){let e=d(p[0]?.content||``),t=h(ie,0,N.customModelMap)-e-4096-2e3;Math.floor(t*.7);let n=c[c.length-1],r=kn(c.slice(0,-1),{isolateChat:!0,maxMemoryMessages:N.chatConfig.maxMemoryMessages,compaction:_,currentMessage:n});jn(p,r,_,a),r.historySummaryText&&(p[0]={...p[0],content:p[0].content+`
|
|
1740
1750
|
|
|
1741
|
-
`+r.historySummaryText}),a.debug(`[SidePanel] history selection: keep ${r.keptHistory.length}/${c.length-1}, trimmed ${r.trimmedCount}, compactionApplied: ${r.compactionApplied}`),p=[...p,...r.messages];for(let e=0;e<p.length-1;e++)p[e]={...p[e],content:ff(p[e].content)}}else{let e=df(b,l.attachedImages);p.push({role:`user`,content:e})}let x=await bt(o?null:{temperature:s.temperature,topP:s.topP});o&&(x._loadingId=re);let S=y(p),C=h(ie,0,N.customModelMap),w=u(S,C);if(a.debug(`[SidePanel] send context: ${S} tokens (message: ${p.length} ), pressure: ${w.level}(${Math.round(w.ratio*100)}%)`),w.level===`critical`){a.warn(`[SidePanel] context pressure too high,maindynamictrimming...`);let e=d(p[0]?.content||``),t=await
|
|
1751
|
+
`+r.historySummaryText}),a.debug(`[SidePanel] history selection: keep ${r.keptHistory.length}/${c.length-1}, trimmed ${r.trimmedCount}, compactionApplied: ${r.compactionApplied}`),p=[...p,...r.messages];for(let e=0;e<p.length-1;e++)p[e]={...p[e],content:ff(p[e].content)}}else{let e=df(b,l.attachedImages);p.push({role:`user`,content:e})}let x=await bt(o?null:{temperature:s.temperature,topP:s.topP});o&&(x._loadingId=re);let S=y(p),C=h(ie,0,N.customModelMap),w=u(S,C);if(a.debug(`[SidePanel] send context: ${S} tokens (message: ${p.length} ), pressure: ${w.level}(${Math.round(w.ratio*100)}%)`),w.level===`critical`){a.warn(`[SidePanel] context pressure too high,maindynamictrimming...`);let e=d(p[0]?.content||``),t=await cS(T),n=(g.length+t)*200,r=C-e-n-4096-2e3,i=A(p,Math.max(r,2e3),{generateSummary:!1});p=i.messages,a.warn(`[SidePanel] proactively trimmed: ${S} → ${y(p)} tokens (${i.trimmedCount} )`)}let E,D,O,k=!1,j=!1,ee=null,te=!0,ne=null;try{let e=await lS(p,ie,m,x,{forcedMcpServerIds:T,sessionId:i,agent:f});E=e.content,D=e.executionLog||[],O=e.reflectionScore,k=e.wasRevised||!1,j=e.wasStreamed||!1,ee=e.streamingHtml||null,te=e.streamingConnected===void 0?!0:e.streamingConnected,ne=e.streamingMsgId||null}catch(e){if(!o||N.activeSessionId!==i){let t=!!e.checkpoint||e.swRestarted||e.message===r(`chatMsg.errTaskStopped`);return ae({role:`assistant`,content:e.message===r(`chatMsg.errTaskStopped`)?r(`chatResume.taskCancelled`):e.swRestarted?r(`chat.taskInterruptedSwRestart`):Rx(e.message),executionLog:e.executionLog||[],resumable:t}),document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:i}})),re&&tS(re),N.substituteLoadingIds.delete(i),{ok:!1,delivered:!0,reason:`inactive`}}if(e.message===r(`chatMsg.errTaskStopped`)){re&&tS(re),N.substituteLoadingIds.delete(i);let{messageId:t}=Jx(`assistant`,r(`chatResume.taskCancelled`),!1,e.executionLog||[],null,!1,null,null,[],!0);return N.messageHistory.push({role:`assistant`,content:r(`chatResume.taskCancelled`),executionLog:e.executionLog||[],messageId:t,resumable:!0}),yx(),{ok:!1,delivered:!0,reason:`cancelled`}}if(e.swRestarted){re&&tS(re),N.substituteLoadingIds.delete(i);let t=!!e.checkpoint,{messageId:n}=Jx(`assistant`,r(`chat.taskInterruptedSwRestart`),!1,e.executionLog||[],null,!1,null,null,[],t);return N.messageHistory.push({role:`assistant`,content:r(`chat.taskInterruptedSwRestart`),executionLog:e.executionLog||[],messageId:n,resumable:t}),yx(),Lc(i,r(`chat.taskInterruptedSwRestart`),v),{ok:!1,delivered:!0,reason:`sw_restarted`}}re&&tS(re),N.substituteLoadingIds.delete(i),E=Rx(e.message),D=e.executionLog||[];let{messageId:t}=Jx(`assistant`,E,!0,D,O,!1,null,null,[],!0);return N.messageHistory.push({role:`assistant`,content:E,executionLog:D,reflectionScore:O,messageId:t,resumable:!0}),Lc(i,E,v),{ok:!1,delivered:!0,reason:`error`}}if(!o||N.activeSessionId!==i){let e={role:`assistant`,content:E,executionLog:D,reflectionScore:O,wasRevised:k,messageId:ne||`msg_`+Date.now().toString(36)+`_`+Math.random().toString(36).substring(2,8)};return j&&ee&&(e.htmlContent=ee),ae(e),document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:i}})),re&&tS(re),N.substituteLoadingIds.delete(i),{ok:!0,delivered:!0}}let oe=null;if(!j||!ee)if(re&&tS(re),N.substituteLoadingIds.has(i)&&(tS(N.substituteLoadingIds.get(i)),N.substituteLoadingIds.delete(i)),j)N.substituteLoadingIds.has(i)&&(tS(N.substituteLoadingIds.get(i)),N.substituteLoadingIds.delete(i)),oe=ne;else{let{element:e,messageId:t}=Jx(`assistant`,E,!0,D,O,k);oe=t,await Jt(e),Mb()}else oe=ne;let se={role:`assistant`,content:E,executionLog:D,reflectionScore:O,wasRevised:k,messageId:oe};if(j&&ee&&(se.htmlContent=ee,!te&&!document.querySelector(`[data-message-id="${oe}"]`))){rS(ee),Zx(),$x();let e=document.getElementById(`chatContainer`);e&&(e.scrollTop=e.scrollHeight)}return N.messageHistory.push(se),Ic(i,v),{ok:!0,delivered:!0}}catch(e){return a.error(`[SidePanel] sendMessage exception:`,e?.message||e),{ok:!1,delivered:D,reason:e?.message||`exception`}}finally{o?yx():(await yi(i,{messageHistory:c,model:s.model,useTools:s.useTools,enabledTools:s.enabledTools,agentId:s.agentId,temperature:s.temperature,topP:s.topP,activeCompaction:s.contextCompaction,workdir:s.workdir,workdirAgentId:s.workdirAgentId}),document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:i}}))),Bc(i),o&&t.focus()}}function Hx(e,t){let n=document.getElementById(`userInput`);if(!t||N.isGenerating){a.debug(`[SidePanel] triggerSelectionSearch skip:`,{hasText:!!t,isGenerating:N.isGenerating});return}N.selectedContextText=t,N.quotedContextText=``,n.value=r(`chatMsg.searchPrompt`),n.dispatchEvent(new Event(`input`)),Vx()}function Ux(e){let t=document.getElementById(`userInput`);!t||!e||(t.value=e,t.dispatchEvent(new Event(`input`)),t.focus())}async function Wx(e,t=``){await hx;let n=document.getElementById(`userInput`);if(!(!n||!e)){if(t&&(N.selectedContextText=t,N.quotedContextText=``),N.isGenerating){n.value=e,n.dispatchEvent(new Event(`input`)),await hu();return}n.value=e,n.dispatchEvent(new Event(`input`)),n.focus(),Vx()}}function Gx(e,t,n=!0,i=null){let a=document.getElementById(`chatContainer`),o=document.createElement(`div`);o.className=`user-context-bubble`,o.dataset.role=`context`;let s=e===`quoted`?`💬`:e===`skill`?`🧩`:e===`mcp`?`🔌`:e===`page`?`🌐`:e===`file`?`📎`:e===`knowledge`?`📚`:`📌`,c=r(e===`quoted`?`contextBubble.labelQuoted`:e===`skill`?`contextBubble.labelSkill`:e===`mcp`?`contextBubble.labelMcp`:e===`page`?`contextBubble.labelPage`:e===`file`?`contextBubble.labelFile`:e===`knowledge`?`contextBubble.labelKnowledge`:`contextBubble.labelSelection`),l=F(t);if(e===`knowledge`&&Array.isArray(i)&&i.length>0){let e=i.map(e=>{let t=typeof e.score==`number`?e.score.toFixed(3):``,n=t?`<span class="kb-bubble-hit-score">${t}</span>`:``,i=e.truncated?`<span class="kb-bubble-hit-truncated" title="${r(`contextBubble.kbHitTruncatedTitle`)}">${r(`contextBubble.kbHitTruncated`,{total:e.fullLength||0,kept:wx})}</span>`:``;return`<div class="kb-bubble-hit"><div class="kb-bubble-hit-text" title="${r(`contextBubble.kbHitToggle`)}">${n}${F(e.content||``)}</div>${i}</div>`}).join(``),n=i.filter(e=>e.truncated).length,a=n>0?`<span class="kb-bubble-truncated-badge">${r(`contextBubble.kbHitTruncatedBadge`,{count:n})}</span>`:``;l=`<div class="kb-bubble-summary">${F(t)}${a}</div>${e}`}o.innerHTML=`
|
|
1742
1752
|
<div class="context-bubble-inner">
|
|
1743
1753
|
<div class="context-bubble-header" title="${r(`contextBubble.clickToExpand`)}">
|
|
1744
1754
|
<span class="context-icon">${s}</span>
|
|
@@ -1746,7 +1756,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1746
1756
|
</div>
|
|
1747
1757
|
<div class="context-bubble-content">${l}</div>
|
|
1748
1758
|
</div>
|
|
1749
|
-
`;let u=o.querySelector(`.context-bubble-header`),d=o.querySelector(`.context-bubble-content`);return u.addEventListener(`click`,e=>{e.stopPropagation(),d.classList.toggle(`expanded`)}),e===`knowledge`&&o.querySelectorAll(`.kb-bubble-hit-text`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),e.classList.toggle(`expanded`)})}),a.appendChild(o),n&&(a.scrollTop=a.scrollHeight),o}function Ux(e){let t=e,n;do n=t,t=t.replace(/^\[(?:已选技能|Selected skill): [^\]]+\]\n[\s\S]*?(?:请根据上述技能说明[\s\S]*?处理以下问题[::]|Please use the relevant tools[\s\S]*?handle the following problem[.:])\s*\n/,``).replace(/^\[(?:已选技能|Selected skill): [^\]]+\]\n(?:请|Please)[^\n]*(?:处理以下问题|handle the following problem)[^。\n]*。?\s*\n/,``);while(t!==n);return t}function Wx(e){let t=e,n;do n=t,t=t.replace(/^\[(?:已选MCP服务|Selected MCP service):\s*[^\]]+\]\n(?:请使用「[^」]+」MCP服务来处理以下问题:|Please use the "[^"]+" MCP service to handle the following problem:)\s*\n/,``);while(t!==n);return t}function Gx(e,t,n=!0,i=[],o=null,s=!1,c=null,l=null,u=[],d=!1,f=void 0){let p=document.getElementById(`chatContainer`),m=document.createElement(`div`);m.className=`message ${e}`;let h=f===void 0?new Date().toISOString():f||null;h&&(m.dataset.timestamp=h);let g=l||`msg_`+Date.now().toString(36)+`_`+Math.random().toString(36).substring(2,8);m.dataset.messageId=g;let _=Array.isArray(t)?t.filter(e=>e.type===`text`).map(e=>e.text).join(``):t,v=Array.isArray(t)&&t.some(e=>e.type===`image_url`);m.dataset.rawContent=Array.isArray(t)?JSON.stringify(t):Wt(t),m.dataset.textContent_=Wt(c||_);let y=_;if(m.dataset.executionLog=JSON.stringify(i),s&&(m.dataset.wasRevised=`true`),e===`assistant`){m.innerHTML=Pt(t);let e=document.createElement(`div`);e.className=`message-footer`;let n=document.createElement(`button`);n.className=`copy-btn`,n.title=r(`chatStream.copyMarkdown`),n.innerHTML=[`<svg viewBox="0 0 16 16" fill="currentColor">`,`<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25zM5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25z"/>`,`</svg>`,`<span>${r(`common.copy`)}</span>`].join(``),n.addEventListener(`click`,e=>{e.stopPropagation(),nb(m,n,e)}),e.appendChild(n);let c=document.createElement(`button`);c.className=`quote-btn`,c.title=r(`chat.quoteTitle`),c.innerHTML=[`<svg t="1781246498458" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9645" width="14" height="14"><path d="M156.09136 606.57001a457.596822 457.596822 0 0 1 221.680239-392.516385 50.844091 50.844091 0 1 1 50.844091 86.943396 355.90864 355.90864 0 0 0-138.804369 152.532274h16.77855a152.532274 152.532274 0 1 1-152.532274 152.532274z m406.752731 0a457.596822 457.596822 0 0 1 221.680239-392.007944 50.844091 50.844091 0 1 1 50.844091 86.943396 355.90864 355.90864 0 0 0-138.804369 152.532274h16.77855a152.532274 152.532274 0 1 1-152.532274 152.532274z" fill="#8a8a8a" p-id="9646"></path></svg>`,`<span>${r(`chat.quote`)}</span>`].join(``),c.addEventListener(`click`,e=>{e.stopPropagation(),ub(m)}),e.appendChild(c),e.appendChild(Iy());let l=document.createElement(`div`);l.className=`export-menu-container`;let u=document.createElement(`button`);u.className=`export-trigger-btn`,u.innerHTML=`<svg t="1781245244396" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5115" width="14" height="14"><path d="M496.213333 739.84c2.133333 2.133333 4.693333 3.84 7.68 5.12 0.853333 0.426667 2.133333 0.426667 2.986667 0.853333 1.706667 0.426667 2.986667 0.853333 4.693333 0.853334 5.546667 0 11.093333-2.133333 14.933334-6.4l256-256c8.533333-8.533333 8.533333-21.76 0-30.293334s-21.76-8.533333-30.293334 0L533.333333 674.133333V128c0-11.946667-9.386667-21.333333-21.333333-21.333333s-21.333333 9.386667-21.333333 21.333333v545.706667l-219.306667-219.306667c-8.533333-8.533333-21.76-8.533333-30.293333 0s-8.533333 21.76 0 30.293333l255.146666 255.146667zM768 874.666667H256c-11.946667 0-21.333333 9.386667-21.333333 21.333333s9.386667 21.333333 21.333333 21.333333h512c11.946667 0 21.333333-9.386667 21.333333-21.333333s-9.386667-21.333333-21.333333-21.333333z" fill="#8a8a8a" p-id="5116"></path></svg><span>${r(`chat.export`)}</span><svg class="dropdown-arrow" width="8" height="6" viewBox="0 0 8 6" fill="currentColor"><path d="M0 0l4 6 4-6z"/></svg>`;let f=document.createElement(`div`);f.className=`export-dropdown`,f.innerHTML=[`<button class="export-dropdown-item export-docx-item" type="button">`,`<svg t="1781245550030" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6544" width="32" height="32"><path d="M747.936 901.171H276.819c-72.2 0-130.953-55.224-130.953-123.078V244.721c0-67.854 58.752-123.078 130.953-123.078h383.525c6.597 0 12.937 2.505 17.795 6.954l192.363 178.046c5.317 4.96 8.386 11.914 8.386 19.227v452.223c0 67.854-58.752 123.078-130.952 123.078zM276.819 174.004c-43.31 0-78.592 31.703-78.592 70.717v533.372c0 39.015 35.282 70.718 78.592 70.718h471.117c43.31 0 78.592-31.703 78.592-70.718V337.324l-176.461-163.32H276.819z" fill="#8a8a8a" p-id="6545"></path><path d="M830.567 331.546H669.446c-14.471 0-26.18-11.71-26.18-26.181V156.209c0-14.471 11.709-26.18 26.18-26.18s26.181 11.709 26.181 26.18v122.976h134.94c14.471 0 26.181 11.709 26.181 26.18s-11.711 26.181-26.181 26.181z" fill="#8a8a8a" p-id="6546"></path><path d="M730.214 428.749l-92.04 343.616h-53.179L511.363 498.29l-75.677 274.074h-53.179l-92.04-343.616h49.088l69.542 255.667 69.541-255.667h63.406l69.541 255.667 69.541-255.667h49.088z" fill="#8a8a8a" p-id="6547"></path></svg>`,`<span>${r(`chatMsg.exportWord`)}</span>`,`</button>`,`<button class="export-dropdown-item export-pdf-item" type="button">`,`<svg t="1781245863206" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8152" width="32" height="32"><path d="M582.4 864H170.666667c-6.4 0-10.666667-4.266667-10.666667-10.666667V170.666667c0-6.4 4.266667-10.666667 10.666667-10.666667h309.333333V320c0 40.533333 34.133333 74.666667 74.666667 74.666667h160v38.4c0 17.066667 14.933333 32 32 32s32-14.933333 32-32V298.666667c0-8.533333-4.266667-17.066667-8.533334-23.466667l-170.666666-170.666667c-6.4-6.4-14.933333-8.533333-23.466667-8.533333H170.666667C130.133333 96 96 130.133333 96 170.666667v682.666666c0 40.533333 34.133333 74.666667 74.666667 74.666667h411.733333c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32z m132.266667-550.4v17.066667H554.666667c-6.4 0-10.666667-4.266667-10.666667-10.666667V160h19.2l151.466667 153.6z" fill="#8a8a8a" p-id="8153"></path><path d="M332.8 533.333333c-12.8 0-19.2 2.133333-25.6 6.4-6.4 4.266667-8.533333 12.8-8.533333 23.466667v206.933333c0 6.4 2.133333 12.8 6.4 19.2 4.266667 4.266667 10.666667 8.533333 21.333333 8.533334s17.066667-4.266667 21.333333-8.533334c4.266667-4.266667 6.4-10.666667 6.4-19.2v-64h32c57.6 0 89.6-29.866667 89.6-87.466666 0-27.733333-8.533333-51.2-23.466666-64-14.933333-14.933333-36.266667-21.333333-66.133334-21.333334h-53.333333z m87.466667 85.333334c0 12.8-2.133333 23.466667-8.533334 27.733333-4.266667 4.266667-14.933333 8.533333-27.733333 8.533333h-32v-70.4H384c12.8 0 21.333333 2.133333 27.733333 8.533334 6.4 4.266667 8.533333 12.8 8.533334 25.6zM667.733333 571.733333c-8.533333-12.8-21.333333-21.333333-34.133333-29.866666-14.933333-4.266667-32-8.533333-51.2-8.533334h-61.866667c-8.533333 0-17.066667 0-23.466666 8.533334-2.133333 4.266667-4.266667 10.666667-4.266667 19.2V768c0 8.533333 2.133333 14.933333 4.266667 19.2 6.4 8.533333 14.933333 8.533333 23.466666 8.533333h64c19.2 0 34.133333-4.266667 49.066667-10.666666 12.8-6.4 25.6-17.066667 34.133333-29.866667 8.533333-12.8 14.933333-25.6 19.2-42.666667 4.266667-14.933333 6.4-32 6.4-49.066666 0-17.066667-2.133333-34.133333-6.4-49.066667-4.266667-14.933333-10.666667-29.866667-19.2-42.666667z m-42.666666 153.6c-8.533333 12.8-21.333333 19.2-38.4 19.2h-38.4v-160H576c21.333333 0 38.4 6.4 46.933333 19.2 10.666667 12.8 14.933333 34.133333 14.933334 59.733334 2.133333 27.733333-4.266667 46.933333-12.8 61.866666zM851.2 533.333333h-106.666667c-8.533333 0-17.066667 2.133333-21.333333 6.4-6.4 4.266667-8.533333 12.8-8.533333 21.333334v209.066666c0 6.4 2.133333 12.8 6.4 17.066667 4.266667 6.4 10.666667 8.533333 21.333333 8.533333 8.533333 0 17.066667-2.133333 21.333333-8.533333 2.133333-4.266667 6.4-8.533333 6.4-19.2v-85.333333h72.533334c12.8 0 23.466667-6.4 25.6-17.066667 2.133333-8.533333 2.133333-14.933333 0-17.066667-2.133333-4.266667-6.4-17.066667-25.6-17.066666H768v-49.066667h81.066667c8.533333 0 14.933333-2.133333 19.2-4.266667 4.266667-2.133333 8.533333-8.533333 8.533333-21.333333 2.133333-12.8-8.533333-23.466667-25.6-23.466667z" fill="#8a8a8a" p-id="8154"></path></svg>`,`<span>${r(`chatMsg.exportPdf`)}</span>`,`</button>`,`<button class="export-dropdown-item export-image-item" type="button">`,`<svg t="1784207887308" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5993" width="32" height="32"><path d="M400.696 268.795c-17.249 0-31.233 13.986-31.233 31.233v30.471c0 17.249 13.986 31.233 31.233 31.233s31.233-13.986 31.233-31.233v-30.471c0-17.249-13.985-31.233-31.233-31.233z" fill="#8a8a8a" p-id="5994"></path><path d="M623.649 361.734c17.249 0 31.234-13.986 31.234-31.233v-30.471c0-17.249-13.986-31.233-31.234-31.233s-31.233 13.986-31.233 31.233v30.471c-0.001 17.248 13.985 31.233 31.233 31.233z" fill="#8a8a8a" p-id="5995"></path><path d="M438.295 388.804c-14.656 9.104-19.155 28.362-10.050 43.013 11.209 18.047 41.976 48.59 86.157 48.59 43.958 0 75.1-30.313 86.574-48.223 9.303-14.529 5.068-33.847-9.455-43.15-14.539-9.298-33.852-5.068-43.15 9.455-0.122 0.199-13.38 19.45-33.969 19.45-20.009 0-32.444-18.128-33.278-19.373-9.166-14.423-28.28-18.805-42.829-9.761z" fill="#8a8a8a" p-id="5996"></path><path d="M824.508503 116.690676 571.592236 116.690676c-17.248849 0-31.233352 13.985526-31.233352 31.233352s13.985526 31.233352 31.233352 31.233352l252.916267 0c40.181141 0 72.878844 32.692586 72.878844 72.878844l0 396.966057-189.334159-165.29465c-12.20088-10.655687-30.517037-10.207479-42.173518 0.9967L468.578048 674.16231 309.521472 517.519714c-11.895935-11.70253-30.903847-12.002358-43.154869-0.645706L126.957507 646.163629l0-394.126382c0-40.186258 32.692586-72.878844 72.878844-72.878844l252.916267 0c17.248849 0 31.233352-13.985526 31.233352-31.233352S470.000444 116.690676 452.751594 116.690676L199.836351 116.690676c-74.632791 0-135.346571 60.71378-135.346571 135.346571l0 520.56405c0 74.632791 60.71378 135.346571 135.346571 135.346571l252.916267 0c17.248849 0 31.233352-13.985526 31.233352-31.233352s-13.985526-31.233352-31.233352-31.233352L199.836351 845.481164c-40.186258 0-72.878844-32.692586-72.878844-72.878844l0-41.23924 160.003134-148.385539 159.428036 157.007917c12.048407 11.865235 31.361265 11.981892 43.546795 0.274246l198.576661-190.68697 208.876238 182.346001 0 40.683585c0 40.186258-32.697703 72.878844-72.878844 72.878844L571.592236 845.481164c-17.248849 0-31.233352 13.985526-31.233352 31.233352s13.985526 31.233352 31.233352 31.233352l252.916267 0c74.627674 0 135.346571-60.71378 135.346571-135.346571L959.855074 252.037247C959.855074 177.404456 899.136178 116.690676 824.508503 116.690676z" fill="#8a8a8a" p-id="5997"></path></svg>`,`<span>${r(`chatMsg.exportImage`)}</span>`,`</button>`,`<button class="export-dropdown-item export-md-item" type="button">`,`<svg t="1784038824502" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1666" width="32" height="32"><path d="M601.216 85.333333a42.666667 42.666667 0 0 1 30.485333 12.821334l209.450667 213.973333a42.666667 42.666667 0 0 1 12.181333 29.866667V853.333333a85.333333 85.333333 0 0 1-85.333333 85.333334H256a85.333333 85.333333 0 0 1-85.333333-85.333334V170.666667a85.333333 85.333333 0 0 1 85.333333-85.333334h345.216z m-35.584 64H256a21.333333 21.333333 0 0 0-21.333333 21.333334v682.666666a21.333333 21.333333 0 0 0 21.333333 21.333334h512a21.333333 21.333333 0 0 0 21.333333-21.333334V395.413333h-191.68a32 32 0 0 1-32-32L565.632 149.333333z m64 38.186667v143.893333h140.821333L629.632 187.52z" fill="#8a8a8a" p-id="1667"></path><path d="M384.341333 800l-3.072-0.106667a32 32 0 0 1-29.162666-34.624l21.973333-256c2.752-32.256 46.165333-40.490667 60.544-11.477333l77.290667 156.010667 78.805333-156.224c14.08-27.925333 55.082667-20.906667 60.074667 8.789333l0.384 3.050667 20.714666 256a32 32 0 0 1-63.786666 5.162666l-11.541334-142.549333-56.341333 111.722667c-11.413333 22.613333-42.88 23.381333-55.744 2.517333l-1.493333-2.730667-54.912-110.826666-12.181334 142.016a32 32 0 0 1-31.552 29.269333z" fill="#8a8a8a" p-id="1668"></path></svg>`,`<span>${r(`chatMsg.exportMarkdown`)}</span>`,`</button>`].join(``);let p=f.querySelector(`.export-docx-item`);p.addEventListener(`click`,async e=>{e.stopPropagation();let{exportAssistantMessageToDocx:t}=await M(async()=>{let{exportAssistantMessageToDocx:e}=await import(`./chat-export-Co9I1mr6.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));t(m,p,f)});let h=f.querySelector(`.export-md-item`);h.addEventListener(`click`,async e=>{e.stopPropagation();let{exportAssistantMessageToMarkdown:t}=await M(async()=>{let{exportAssistantMessageToMarkdown:e}=await import(`./chat-export-Co9I1mr6.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));t(m,h,f)});let _=f.querySelector(`.export-pdf-item`);_.addEventListener(`click`,async e=>{e.stopPropagation();let{exportAssistantMessageToPdf:t}=await M(async()=>{let{exportAssistantMessageToPdf:e}=await import(`./chat-export-Co9I1mr6.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));t(m,_,f)});let v=f.querySelector(`.export-image-item`);v.addEventListener(`click`,async e=>{e.stopPropagation();let{exportAssistantMessageToImage:t}=await M(async()=>{let{exportAssistantMessageToImage:e}=await import(`./chat-export-Co9I1mr6.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));t(m,v,f)}),u.addEventListener(`click`,e=>{e.stopPropagation(),document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==f&&e.classList.remove(`show`)}),f.classList.toggle(`show`)});let y=null;l.addEventListener(`mouseenter`,()=>{y=setTimeout(()=>{document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==f&&e.classList.remove(`show`)}),f.classList.add(`show`)},300)}),l.addEventListener(`mouseleave`,()=>{y&&=(clearTimeout(y),null),setTimeout(()=>{!l.matches(`:hover`)&&!f.matches(`:hover`)&&f.classList.remove(`show`)},100)}),l.appendChild(u),l.appendChild(f),e.appendChild(l);let b=document.createElement(`div`);b.className=`footer-right-actions`,b.style.marginLeft=`auto`,b.style.display=`flex`,b.style.alignItems=`center`,b.style.gap=`8px`;let x=wt(i);if(x){let e=document.createElement(`span`);e.className=`token-usage-tag`,e.title=r(`chatStream.tokenUsageTitle`,{total:I(x.totalTokens),prompt:I(x.promptTokens),completion:I(x.completionTokens)}),e.innerHTML=`<span class="token-tag-icon">⬤</span><span class="token-tag-value">${I(x.totalTokens)}</span>`,e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),At(x,e)}),b.appendChild(e)}let S=i&&i.length>0,C=o!=null,w=i?i.filter(e=>e.nodeType===`reflection`&&e.reflectionType===`post`&&e.status===`success`).length:0;Jx(),Xx(),Nt();let T=i?.find(e=>e.nodeType===`reflection`&&e.reflectionType===`post`),E=rv(t),D=ov(i,t);if(E.length&&(m.dataset.declaredArtifacts=JSON.stringify(E)),wv(D),console.log(`[addMessage] executionLog entries:`,i?.length,`| agent_file entries:`,i?.filter(e=>e.nodeType===`tool_exec`&&e.action?.name===`agent_file`).length,`| artifacts:`,D.length),D.length>0){let e=document.createElement(`button`);e.className=`artifacts-btn`,e.type=`button`,e.title=r(`artifacts.btnTitle`,{count:D.length}),e.innerHTML=`
|
|
1759
|
+
`;let u=o.querySelector(`.context-bubble-header`),d=o.querySelector(`.context-bubble-content`);return u.addEventListener(`click`,e=>{e.stopPropagation(),d.classList.toggle(`expanded`)}),e===`knowledge`&&o.querySelectorAll(`.kb-bubble-hit-text`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),e.classList.toggle(`expanded`)})}),a.appendChild(o),n&&(a.scrollTop=a.scrollHeight),o}function Kx(e){let t=e,n;do n=t,t=t.replace(/^\[(?:已选技能|Selected skill): [^\]]+\]\n[\s\S]*?(?:请根据上述技能说明[\s\S]*?处理以下问题[::]|Please use the relevant tools[\s\S]*?handle the following problem[.:])\s*\n/,``).replace(/^\[(?:已选技能|Selected skill): [^\]]+\]\n(?:请|Please)[^\n]*(?:处理以下问题|handle the following problem)[^。\n]*。?\s*\n/,``);while(t!==n);return t}function qx(e){let t=e,n;do n=t,t=t.replace(/^\[(?:已选MCP服务|Selected MCP service):\s*[^\]]+\]\n(?:请使用「[^」]+」MCP服务来处理以下问题:|Please use the "[^"]+" MCP service to handle the following problem:)\s*\n/,``);while(t!==n);return t}function Jx(e,t,n=!0,i=[],o=null,s=!1,c=null,l=null,u=[],d=!1,f=void 0){let p=document.getElementById(`chatContainer`),m=document.createElement(`div`);m.className=`message ${e}`;let h=f===void 0?new Date().toISOString():f||null;h&&(m.dataset.timestamp=h);let g=l||`msg_`+Date.now().toString(36)+`_`+Math.random().toString(36).substring(2,8);m.dataset.messageId=g;let _=Array.isArray(t)?t.filter(e=>e.type===`text`).map(e=>e.text).join(``):t,v=Array.isArray(t)&&t.some(e=>e.type===`image_url`);m.dataset.rawContent=Array.isArray(t)?JSON.stringify(t):Wt(t),m.dataset.textContent_=Wt(c||_);let y=_;if(m.dataset.executionLog=JSON.stringify(i),s&&(m.dataset.wasRevised=`true`),e===`assistant`){m.innerHTML=Pt(t);let e=document.createElement(`div`);e.className=`message-footer`;let n=document.createElement(`button`);n.className=`copy-btn`,n.title=r(`chatStream.copyMarkdown`),n.innerHTML=[`<svg viewBox="0 0 16 16" fill="currentColor">`,`<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25zM5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25z"/>`,`</svg>`,`<span>${r(`common.copy`)}</span>`].join(``),n.addEventListener(`click`,e=>{e.stopPropagation(),ib(m,n,e)}),e.appendChild(n);let c=document.createElement(`button`);c.className=`quote-btn`,c.title=r(`chat.quoteTitle`),c.innerHTML=[`<svg t="1781246498458" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9645" width="14" height="14"><path d="M156.09136 606.57001a457.596822 457.596822 0 0 1 221.680239-392.516385 50.844091 50.844091 0 1 1 50.844091 86.943396 355.90864 355.90864 0 0 0-138.804369 152.532274h16.77855a152.532274 152.532274 0 1 1-152.532274 152.532274z m406.752731 0a457.596822 457.596822 0 0 1 221.680239-392.007944 50.844091 50.844091 0 1 1 50.844091 86.943396 355.90864 355.90864 0 0 0-138.804369 152.532274h16.77855a152.532274 152.532274 0 1 1-152.532274 152.532274z" fill="#8a8a8a" p-id="9646"></path></svg>`,`<span>${r(`chat.quote`)}</span>`].join(``),c.addEventListener(`click`,e=>{e.stopPropagation(),fb(m)}),e.appendChild(c),e.appendChild(Ry());let l=document.createElement(`div`);l.className=`export-menu-container`;let u=document.createElement(`button`);u.className=`export-trigger-btn`,u.innerHTML=`<svg t="1781245244396" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5115" width="14" height="14"><path d="M496.213333 739.84c2.133333 2.133333 4.693333 3.84 7.68 5.12 0.853333 0.426667 2.133333 0.426667 2.986667 0.853333 1.706667 0.426667 2.986667 0.853333 4.693333 0.853334 5.546667 0 11.093333-2.133333 14.933334-6.4l256-256c8.533333-8.533333 8.533333-21.76 0-30.293334s-21.76-8.533333-30.293334 0L533.333333 674.133333V128c0-11.946667-9.386667-21.333333-21.333333-21.333333s-21.333333 9.386667-21.333333 21.333333v545.706667l-219.306667-219.306667c-8.533333-8.533333-21.76-8.533333-30.293333 0s-8.533333 21.76 0 30.293333l255.146666 255.146667zM768 874.666667H256c-11.946667 0-21.333333 9.386667-21.333333 21.333333s9.386667 21.333333 21.333333 21.333333h512c11.946667 0 21.333333-9.386667 21.333333-21.333333s-9.386667-21.333333-21.333333-21.333333z" fill="#8a8a8a" p-id="5116"></path></svg><span>${r(`chat.export`)}</span><svg class="dropdown-arrow" width="8" height="6" viewBox="0 0 8 6" fill="currentColor"><path d="M0 0l4 6 4-6z"/></svg>`;let f=document.createElement(`div`);f.className=`export-dropdown`,f.innerHTML=[`<button class="export-dropdown-item export-docx-item" type="button">`,`<svg t="1781245550030" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6544" width="32" height="32"><path d="M747.936 901.171H276.819c-72.2 0-130.953-55.224-130.953-123.078V244.721c0-67.854 58.752-123.078 130.953-123.078h383.525c6.597 0 12.937 2.505 17.795 6.954l192.363 178.046c5.317 4.96 8.386 11.914 8.386 19.227v452.223c0 67.854-58.752 123.078-130.952 123.078zM276.819 174.004c-43.31 0-78.592 31.703-78.592 70.717v533.372c0 39.015 35.282 70.718 78.592 70.718h471.117c43.31 0 78.592-31.703 78.592-70.718V337.324l-176.461-163.32H276.819z" fill="#8a8a8a" p-id="6545"></path><path d="M830.567 331.546H669.446c-14.471 0-26.18-11.71-26.18-26.181V156.209c0-14.471 11.709-26.18 26.18-26.18s26.181 11.709 26.181 26.18v122.976h134.94c14.471 0 26.181 11.709 26.181 26.18s-11.711 26.181-26.181 26.181z" fill="#8a8a8a" p-id="6546"></path><path d="M730.214 428.749l-92.04 343.616h-53.179L511.363 498.29l-75.677 274.074h-53.179l-92.04-343.616h49.088l69.542 255.667 69.541-255.667h63.406l69.541 255.667 69.541-255.667h49.088z" fill="#8a8a8a" p-id="6547"></path></svg>`,`<span>${r(`chatMsg.exportWord`)}</span>`,`</button>`,`<button class="export-dropdown-item export-pdf-item" type="button">`,`<svg t="1781245863206" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8152" width="32" height="32"><path d="M582.4 864H170.666667c-6.4 0-10.666667-4.266667-10.666667-10.666667V170.666667c0-6.4 4.266667-10.666667 10.666667-10.666667h309.333333V320c0 40.533333 34.133333 74.666667 74.666667 74.666667h160v38.4c0 17.066667 14.933333 32 32 32s32-14.933333 32-32V298.666667c0-8.533333-4.266667-17.066667-8.533334-23.466667l-170.666666-170.666667c-6.4-6.4-14.933333-8.533333-23.466667-8.533333H170.666667C130.133333 96 96 130.133333 96 170.666667v682.666666c0 40.533333 34.133333 74.666667 74.666667 74.666667h411.733333c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32z m132.266667-550.4v17.066667H554.666667c-6.4 0-10.666667-4.266667-10.666667-10.666667V160h19.2l151.466667 153.6z" fill="#8a8a8a" p-id="8153"></path><path d="M332.8 533.333333c-12.8 0-19.2 2.133333-25.6 6.4-6.4 4.266667-8.533333 12.8-8.533333 23.466667v206.933333c0 6.4 2.133333 12.8 6.4 19.2 4.266667 4.266667 10.666667 8.533333 21.333333 8.533334s17.066667-4.266667 21.333333-8.533334c4.266667-4.266667 6.4-10.666667 6.4-19.2v-64h32c57.6 0 89.6-29.866667 89.6-87.466666 0-27.733333-8.533333-51.2-23.466666-64-14.933333-14.933333-36.266667-21.333333-66.133334-21.333334h-53.333333z m87.466667 85.333334c0 12.8-2.133333 23.466667-8.533334 27.733333-4.266667 4.266667-14.933333 8.533333-27.733333 8.533333h-32v-70.4H384c12.8 0 21.333333 2.133333 27.733333 8.533334 6.4 4.266667 8.533333 12.8 8.533334 25.6zM667.733333 571.733333c-8.533333-12.8-21.333333-21.333333-34.133333-29.866666-14.933333-4.266667-32-8.533333-51.2-8.533334h-61.866667c-8.533333 0-17.066667 0-23.466666 8.533334-2.133333 4.266667-4.266667 10.666667-4.266667 19.2V768c0 8.533333 2.133333 14.933333 4.266667 19.2 6.4 8.533333 14.933333 8.533333 23.466666 8.533333h64c19.2 0 34.133333-4.266667 49.066667-10.666666 12.8-6.4 25.6-17.066667 34.133333-29.866667 8.533333-12.8 14.933333-25.6 19.2-42.666667 4.266667-14.933333 6.4-32 6.4-49.066666 0-17.066667-2.133333-34.133333-6.4-49.066667-4.266667-14.933333-10.666667-29.866667-19.2-42.666667z m-42.666666 153.6c-8.533333 12.8-21.333333 19.2-38.4 19.2h-38.4v-160H576c21.333333 0 38.4 6.4 46.933333 19.2 10.666667 12.8 14.933333 34.133333 14.933334 59.733334 2.133333 27.733333-4.266667 46.933333-12.8 61.866666zM851.2 533.333333h-106.666667c-8.533333 0-17.066667 2.133333-21.333333 6.4-6.4 4.266667-8.533333 12.8-8.533333 21.333334v209.066666c0 6.4 2.133333 12.8 6.4 17.066667 4.266667 6.4 10.666667 8.533333 21.333333 8.533333 8.533333 0 17.066667-2.133333 21.333333-8.533333 2.133333-4.266667 6.4-8.533333 6.4-19.2v-85.333333h72.533334c12.8 0 23.466667-6.4 25.6-17.066667 2.133333-8.533333 2.133333-14.933333 0-17.066667-2.133333-4.266667-6.4-17.066667-25.6-17.066666H768v-49.066667h81.066667c8.533333 0 14.933333-2.133333 19.2-4.266667 4.266667-2.133333 8.533333-8.533333 8.533333-21.333333 2.133333-12.8-8.533333-23.466667-25.6-23.466667z" fill="#8a8a8a" p-id="8154"></path></svg>`,`<span>${r(`chatMsg.exportPdf`)}</span>`,`</button>`,`<button class="export-dropdown-item export-image-item" type="button">`,`<svg t="1784207887308" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5993" width="32" height="32"><path d="M400.696 268.795c-17.249 0-31.233 13.986-31.233 31.233v30.471c0 17.249 13.986 31.233 31.233 31.233s31.233-13.986 31.233-31.233v-30.471c0-17.249-13.985-31.233-31.233-31.233z" fill="#8a8a8a" p-id="5994"></path><path d="M623.649 361.734c17.249 0 31.234-13.986 31.234-31.233v-30.471c0-17.249-13.986-31.233-31.234-31.233s-31.233 13.986-31.233 31.233v30.471c-0.001 17.248 13.985 31.233 31.233 31.233z" fill="#8a8a8a" p-id="5995"></path><path d="M438.295 388.804c-14.656 9.104-19.155 28.362-10.050 43.013 11.209 18.047 41.976 48.59 86.157 48.59 43.958 0 75.1-30.313 86.574-48.223 9.303-14.529 5.068-33.847-9.455-43.15-14.539-9.298-33.852-5.068-43.15 9.455-0.122 0.199-13.38 19.45-33.969 19.45-20.009 0-32.444-18.128-33.278-19.373-9.166-14.423-28.28-18.805-42.829-9.761z" fill="#8a8a8a" p-id="5996"></path><path d="M824.508503 116.690676 571.592236 116.690676c-17.248849 0-31.233352 13.985526-31.233352 31.233352s13.985526 31.233352 31.233352 31.233352l252.916267 0c40.181141 0 72.878844 32.692586 72.878844 72.878844l0 396.966057-189.334159-165.29465c-12.20088-10.655687-30.517037-10.207479-42.173518 0.9967L468.578048 674.16231 309.521472 517.519714c-11.895935-11.70253-30.903847-12.002358-43.154869-0.645706L126.957507 646.163629l0-394.126382c0-40.186258 32.692586-72.878844 72.878844-72.878844l252.916267 0c17.248849 0 31.233352-13.985526 31.233352-31.233352S470.000444 116.690676 452.751594 116.690676L199.836351 116.690676c-74.632791 0-135.346571 60.71378-135.346571 135.346571l0 520.56405c0 74.632791 60.71378 135.346571 135.346571 135.346571l252.916267 0c17.248849 0 31.233352-13.985526 31.233352-31.233352s-13.985526-31.233352-31.233352-31.233352L199.836351 845.481164c-40.186258 0-72.878844-32.692586-72.878844-72.878844l0-41.23924 160.003134-148.385539 159.428036 157.007917c12.048407 11.865235 31.361265 11.981892 43.546795 0.274246l198.576661-190.68697 208.876238 182.346001 0 40.683585c0 40.186258-32.697703 72.878844-72.878844 72.878844L571.592236 845.481164c-17.248849 0-31.233352 13.985526-31.233352 31.233352s13.985526 31.233352 31.233352 31.233352l252.916267 0c74.627674 0 135.346571-60.71378 135.346571-135.346571L959.855074 252.037247C959.855074 177.404456 899.136178 116.690676 824.508503 116.690676z" fill="#8a8a8a" p-id="5997"></path></svg>`,`<span>${r(`chatMsg.exportImage`)}</span>`,`</button>`,`<button class="export-dropdown-item export-md-item" type="button">`,`<svg t="1784038824502" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1666" width="32" height="32"><path d="M601.216 85.333333a42.666667 42.666667 0 0 1 30.485333 12.821334l209.450667 213.973333a42.666667 42.666667 0 0 1 12.181333 29.866667V853.333333a85.333333 85.333333 0 0 1-85.333333 85.333334H256a85.333333 85.333333 0 0 1-85.333333-85.333334V170.666667a85.333333 85.333333 0 0 1 85.333333-85.333334h345.216z m-35.584 64H256a21.333333 21.333333 0 0 0-21.333333 21.333334v682.666666a21.333333 21.333333 0 0 0 21.333333 21.333334h512a21.333333 21.333333 0 0 0 21.333333-21.333334V395.413333h-191.68a32 32 0 0 1-32-32L565.632 149.333333z m64 38.186667v143.893333h140.821333L629.632 187.52z" fill="#8a8a8a" p-id="1667"></path><path d="M384.341333 800l-3.072-0.106667a32 32 0 0 1-29.162666-34.624l21.973333-256c2.752-32.256 46.165333-40.490667 60.544-11.477333l77.290667 156.010667 78.805333-156.224c14.08-27.925333 55.082667-20.906667 60.074667 8.789333l0.384 3.050667 20.714666 256a32 32 0 0 1-63.786666 5.162666l-11.541334-142.549333-56.341333 111.722667c-11.413333 22.613333-42.88 23.381333-55.744 2.517333l-1.493333-2.730667-54.912-110.826666-12.181334 142.016a32 32 0 0 1-31.552 29.269333z" fill="#8a8a8a" p-id="1668"></path></svg>`,`<span>${r(`chatMsg.exportMarkdown`)}</span>`,`</button>`].join(``);let p=f.querySelector(`.export-docx-item`);p.addEventListener(`click`,async e=>{e.stopPropagation();let{exportAssistantMessageToDocx:t}=await M(async()=>{let{exportAssistantMessageToDocx:e}=await import(`./chat-export-pxivPZ1I.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));t(m,p,f)});let h=f.querySelector(`.export-md-item`);h.addEventListener(`click`,async e=>{e.stopPropagation();let{exportAssistantMessageToMarkdown:t}=await M(async()=>{let{exportAssistantMessageToMarkdown:e}=await import(`./chat-export-pxivPZ1I.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));t(m,h,f)});let _=f.querySelector(`.export-pdf-item`);_.addEventListener(`click`,async e=>{e.stopPropagation();let{exportAssistantMessageToPdf:t}=await M(async()=>{let{exportAssistantMessageToPdf:e}=await import(`./chat-export-pxivPZ1I.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));t(m,_,f)});let v=f.querySelector(`.export-image-item`);v.addEventListener(`click`,async e=>{e.stopPropagation();let{exportAssistantMessageToImage:t}=await M(async()=>{let{exportAssistantMessageToImage:e}=await import(`./chat-export-pxivPZ1I.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));t(m,v,f)}),u.addEventListener(`click`,e=>{e.stopPropagation(),document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==f&&e.classList.remove(`show`)}),f.classList.toggle(`show`)});let y=null;l.addEventListener(`mouseenter`,()=>{y=setTimeout(()=>{document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==f&&e.classList.remove(`show`)}),f.classList.add(`show`)},300)}),l.addEventListener(`mouseleave`,()=>{y&&=(clearTimeout(y),null),setTimeout(()=>{!l.matches(`:hover`)&&!f.matches(`:hover`)&&f.classList.remove(`show`)},100)}),l.appendChild(u),l.appendChild(f),e.appendChild(l);let b=document.createElement(`div`);b.className=`footer-right-actions`,b.style.marginLeft=`auto`,b.style.display=`flex`,b.style.alignItems=`center`,b.style.gap=`8px`;let x=wt(i);if(x){let e=document.createElement(`span`);e.className=`token-usage-tag`,e.title=r(`chatStream.tokenUsageTitle`,{total:I(x.totalTokens),prompt:I(x.promptTokens),completion:I(x.completionTokens)}),e.innerHTML=`<span class="token-tag-icon">⬤</span><span class="token-tag-value">${I(x.totalTokens)}</span>`,e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),At(x,e)}),b.appendChild(e)}let S=i&&i.length>0,C=o!=null,w=i?i.filter(e=>e.nodeType===`reflection`&&e.reflectionType===`post`&&e.status===`success`).length:0;Zx(),$x(),Nt();let T=i?.find(e=>e.nodeType===`reflection`&&e.reflectionType===`post`),E=av(t),D=cv(i,t);if(E.length&&(m.dataset.declaredArtifacts=JSON.stringify(E)),Ev(D),console.log(`[addMessage] executionLog entries:`,i?.length,`| agent_file entries:`,i?.filter(e=>e.nodeType===`tool_exec`&&e.action?.name===`agent_file`).length,`| artifacts:`,D.length),D.length>0){let e=document.createElement(`button`);e.className=`artifacts-btn`,e.type=`button`,e.title=r(`artifacts.btnTitle`,{count:D.length}),e.innerHTML=`
|
|
1750
1760
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="14" height="14">
|
|
1751
1761
|
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
|
|
1752
1762
|
<polyline points="14 2 14 8 20 8"/>
|
|
@@ -1754,7 +1764,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1754
1764
|
<line x1="9" y1="15" x2="15" y2="15"/>
|
|
1755
1765
|
</svg>
|
|
1756
1766
|
<span class="artifacts-btn-count">${D.length}</span>
|
|
1757
|
-
`,e.addEventListener(`click`,t=>{t.stopPropagation(),
|
|
1767
|
+
`,e.addEventListener(`click`,t=>{t.stopPropagation(),Dv(D,e)}),b.appendChild(e),Tv(D,e)}if(zt(m,D.map(e=>e.path)).catch(()=>{}),S&&N.chatConfig.enableExecutionLog){let e=document.createElement(`button`);e.className=`execution-log-btn`,e.type=`button`,e.title=r(`chatMsg.executionLogTitle`),e.innerHTML=[`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<circle cx="12" cy="12" r="10"></circle>`,`<polyline points="12 6 12 12 16 14"></polyline>`,`</svg>`].join(``),b.appendChild(e)}if(C&&N.chatConfig.enableExecutionLog){let e=o>=8?`score-high`:o>=5?`score-mid`:`score-low`,t=o>=8?`✅`:o>=5?`🔍`:`⚠️`,n=s?` <span class="reflection-revised-tag">${r(`chatMsg.revisedTag`)}</span>`:``,i=w>1?r(`chatMsg.roundsTag`,{count:w}):``,a=document.createElement(`button`);a.className=`reflection-score-btn`,a.type=`button`,a.title=r(`chatMsg.scoreBadgeTitle`,{score:o,rounds:i,revised:s?r(`chatMsg.revisedSuffix`):``}),a.innerHTML=`<span class="reflection-badge ${e}"><span class="reflection-badge-emoji">${t}</span> ${o}/10${n}</span>`,a.dataset.reflectionData=JSON.stringify({overallScore:T?.overallScore??o,dimensions:T?.dimensions||null,issues:T?.issues||null,suggestions:T?.suggestions||null,decision:T?.action?.decision||null,useful:T?.useful??null,reasoning:T?.reasoning||null,suggestion:T?.suggestion||null,rounds:w,wasRevised:s}),b.appendChild(a)}else if(!C&&T&&T.status===`failed`&&N.chatConfig?.enableExecutionLog){let e=document.createElement(`button`);e.className=`reflection-score-btn`,e.type=`button`,e.title=r(`chatMsg.reflectionFailedTitle`),e.innerHTML=`<span class="reflection-badge score-low">${r(`chatMsg.reflectionFailedBadge`)}</span>`,b.appendChild(e)}let O=i?.slice().reverse().find(e=>e.nodeType===`tool_exec`&&e.action?.name===`preview_ui`||e.action?.name===`preview_preview_ui`&&e.status===`success`);if(O){let e=!1;if(O.observation)try{e=(typeof O.observation==`string`?JSON.parse(O.observation):O.observation)?.localOpened===!0}catch{}let t=document.createElement(`button`);t.className=`prototype-btn-small`,t.type=`button`,t.title=r(e?`chatMsg.prototypeLocalOpened`:`chatMsg.prototypeView`),t.innerHTML=hs,t.addEventListener(`click`,()=>{let e=O.prototypeId;if(!e&&O.observation)try{e=(typeof O.observation==`string`?JSON.parse(O.observation):O.observation)?.prototypeId}catch{}e?Ms(e):a.error(`[SidePanel] not found prototypeId,entry keys:`,Object.keys(O),`observation:`,O.observation)}),b.appendChild(t)}let k=document.createElement(`button`);k.className=`bookmark-btn`,k.title=r(`chatMsg.bookmarkMessage`),k.innerHTML=`
|
|
1758
1768
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1759
1769
|
<path d="M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"/>
|
|
1760
1770
|
</svg>
|
|
@@ -1768,17 +1778,17 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1768
1778
|
<polyline points="3 6 5 6 21 6"></polyline>
|
|
1769
1779
|
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
|
|
1770
1780
|
</svg>
|
|
1771
|
-
`,j.addEventListener(`click`,e=>{e.stopPropagation(),
|
|
1781
|
+
`,j.addEventListener(`click`,e=>{e.stopPropagation(),sS(m)}),b.appendChild(j),e.appendChild(b),d){let t=document.createElement(`button`);t.className=`resume-task-btn`,t.type=`button`,t.title=r(`chatMsg.resumeTaskTitle`),t.innerHTML=`
|
|
1772
1782
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1773
1783
|
<polygon points="5 3 19 12 5 21 5 3"></polygon>
|
|
1774
1784
|
</svg>
|
|
1775
1785
|
<span>${r(`chatMsg.resumeTaskBtn`)}</span>
|
|
1776
|
-
`,t.addEventListener(`click`,async e=>{if(e.stopPropagation(),t.disabled)return;let n=await
|
|
1786
|
+
`,t.addEventListener(`click`,async e=>{if(e.stopPropagation(),t.disabled)return;let n=await hb();n!==null&&(t.disabled=!0,t.style.opacity=`0.6`,t.style.cursor=`not-allowed`,yb(N.activeSessionId,n).finally(()=>{t.disabled=!1,t.style.opacity=``,t.style.cursor=``}))}),e.appendChild(t),m.dataset.resumable=`true`,_b(m,N.activeSessionId)}m.appendChild(e)}else{let e=y;e=e.replace(/^\[网页上下文\]\n标题: .+\nURL: .+\ntabId: \d+\n/,``),e=e.replace(/\[知识库检索结果\][^\n]*\n[\s\S]*?\[\/知识库检索结果\]\n\n?/,``),e=qx(e),e=Kx(e);let n=e.match(/^\[引用内容(?:摘要)?\]\n([\s\S]+?)\n\n\[用户问题\]\n([\s\S]*)$/),i=e.match(/^\[选中内容(?:摘要)?\]\n([\s\S]+?)\n\n\[用户问题\]\n([\s\S]*)$/),a=n||i;if(a){let e=n?`quoted`:`selected`,t=a[1].trim(),r=a[2].trim();if(u&&u.length>0){let e=r.search(/\n\n\[(?:工作目录)?文件(?:内容)?:/);e!==-1&&(r=r.substring(0,e))}r=r.replace(/^\[网页上下文\]\n标题: .+\nURL: .+\ntabId: \d+\n/,``),r=qx(r),r=Kx(r),r=r.replace(/\[工作目录文件: [^\]]+\]/g,``),m._pendingContext={type:e,contextText:t,userQuestion:r},m.textContent=r}else{let e=y;if(u&&u.length>0){let t=e.search(/\n\n\[(?:工作目录)?文件(?:内容)?:/);t!==-1&&(e=e.substring(0,t))}e=e.replace(/^\[网页上下文\]\n标题: .+\nURL: .+\ntabId: \d+\n/,``),e=e.replace(/\[知识库检索结果\][^\n]*\n[\s\S]*?\[\/知识库检索结果\]\n\n?/,``),e=qx(e),e=Kx(e),e=e.replace(/\[工作目录文件: [^\]]+\]/g,``),m.textContent=e}if(v){let e=document.createElement(`div`);e.className=`user-message-images`,t.filter(e=>e.type===`image_url`).forEach((t,n)=>{let i=document.createElement(`img`),a=t.image_url.original_url||t.image_url.url;i.src=a,i.className=`user-message-image`,i.title=r(`chatMsg.clickToEnlarge`),i.addEventListener(`click`,()=>{ef(a,i)}),e.appendChild(i)}),m.appendChild(e)}if(u&&u.length>0){m.dataset.attachedFiles=JSON.stringify(u.map(e=>({name:e.name,size:e.size,type:e.type,text:e.text,status:e.status,agentPath:e.agentPath||``})));let e=document.createElement(`div`);e.className=`user-message-files`;let t=u.filter(e=>e.status===`done`),n=u.filter(e=>e.status!==`done`);[...t,...n].forEach(t=>{let n=document.createElement(`span`);n.className=`user-message-file-tag ${t.status}`,n.textContent=`${Ff(t.name)} ${t.name} (${If(t.size)})`,t.status===`extracting`?n.textContent+=r(`chatMsg.fileExtracting`):t.status===`error`&&(n.textContent+=r(`chatMsg.fileFailed`),n.title=t.error||r(`chatMsg.fileExtractFailed`)),e.appendChild(n)}),m.appendChild(e)}let o=document.createElement(`div`);o.className=`message-toolbar`;let s=document.createElement(`button`);s.className=`message-toolbar-btn copy-btn`,s.title=r(`chatMsg.copyMessageTitle`),s.innerHTML=[`<svg viewBox="0 0 16 16" fill="currentColor">`,`<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25zM5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25z"/>`,`</svg>`].join(``),s.addEventListener(`click`,e=>{e.stopPropagation(),rb(m,s)});let c=document.createElement(`button`);c.className=`message-toolbar-btn edit-btn`,c.title=r(`chatMsg.editAndResend`),c.innerHTML=[`<svg viewBox="0 0 16 16" fill="currentColor">`,`<path d="M12.146.146a.5.5 0 0 1 .708 0l2.5 2.5a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168l10-10zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207 11.207 2.5zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293l6.5-6.5zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12h.5a.5.5 0 0 1 .5.5v.5a.5.5 0 0 1-.5.5h-.5a.5.5 0 0 1-.468-.325z"/>`,`</svg>`].join(``),c.addEventListener(`click`,e=>{e.stopPropagation(),uS(m)}),o.appendChild(s),o.appendChild(c);let l=document.createElement(`button`);if(l.className=`message-toolbar-btn delete-btn`,l.title=r(`chatMsg.deleteMessageTitle`),l.innerHTML=`
|
|
1777
1787
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1778
1788
|
<polyline points="3 6 5 6 21 6"></polyline>
|
|
1779
1789
|
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
|
|
1780
1790
|
</svg>
|
|
1781
|
-
`,l.addEventListener(`click`,e=>{e.stopPropagation(),
|
|
1791
|
+
`,l.addEventListener(`click`,e=>{e.stopPropagation(),sS(m)}),o.appendChild(l),m.appendChild(o),h){m.classList.add(`has-time`);let e=document.createElement(`time`);e.className=`message-time`,e.dateTime=h,e.textContent=Ot(h),e.title=_t(h),m.appendChild(e)}}if(p.appendChild(m),m._pendingContext){let{type:e,contextText:t}=m._pendingContext,n=Gx(e,t,!1);p.insertBefore(n,m),delete m._pendingContext}return n&&Ob(p,{smooth:!0}),e===`assistant`&&qt(),{element:m,messageId:g,timestamp:h}}function Yx(e){let t=document.getElementById(`chatContainer`);t&&t.classList.toggle(`timestamps-hidden`,e===!1)}var Xx=!1;function Zx(){if(Xx)return;let e=document.getElementById(`chatContainer`);e&&(e.addEventListener(`click`,e=>{let t=e.target.closest(`.execution-log-btn`);if(!t)return;let n=t.closest(`.message`);if(!n)return;e.preventDefault(),e.stopPropagation();let r=n.dataset.executionLog;if(r)try{let e=JSON.parse(r);a.debug(`[chat-manager] exec log buttonclick(delegate), entries:`,e.length),mb(e)}catch(e){a.error(`[chat-manager] parse executionLog failed:`,e)}}),Xx=!0)}var Qx=!1;function $x(){if(Qx)return;let e=document.getElementById(`chatContainer`);e&&(e.addEventListener(`click`,e=>{let t=e.target.closest(`.reflection-score-btn`);if(!t)return;e.preventDefault(),e.stopPropagation();let n=t.dataset.reflectionData;if(n)try{pb(JSON.parse(n),t)}catch(e){a.error(`[chat-manager] parse reflectionData failed:`,e)}}),Qx=!0)}function eS(){let e=document.getElementById(`chatContainer`),t=`loading-`+Date.now(),n=document.createElement(`div`);n.className=`loading-message`,n.id=t,n.innerHTML=`
|
|
1782
1792
|
<div class="loading-content">
|
|
1783
1793
|
<div class="loading-dots">
|
|
1784
1794
|
<span></span>
|
|
@@ -1802,7 +1812,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1802
1812
|
<span class="current-node-name">${r(`chatMsg.preparing`)}</span>
|
|
1803
1813
|
</div>
|
|
1804
1814
|
</div>
|
|
1805
|
-
`,e.appendChild(n),requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight});let i=n.querySelector(`.stop-task-btn`),o=n.querySelector(`.loading-text`);i&&i.addEventListener(`click`,e=>{e.stopPropagation(),i.disabled=!0,i.style.opacity=`0.6`,i.style.cursor=`not-allowed`,o&&(o.textContent=r(`chatMsg.stopping`)),chrome.runtime.sendMessage({type:`CANCEL_REACT`,tabId:null,sessionId:N.activeSessionId}),N.pendingCancelApi&&N.pendingCancelApi({message:r(`chatMsg.errTaskStopped`),executionLog:N.currentExecutionStatus?.executionLog||[]})});let s=N.activeSessionId;if(N.executionLogListener=(e,n,r)=>e.sessionId&&e.sessionId!==s?!1:e.type===`EXECUTION_STATUS_UPDATE`?(a.debug(`[SidePanel] recei to execution statusupdate:`,e.nodeName,e.status,`log count:`,e.executionLog?.length),bd(t,e.nodeName,e.status,e.executionLog),!1):!1,chrome.runtime.onMessage.addListener(N.executionLogListener),N.chatConfig.enableExecutionLog){let e=n.querySelector(`.execution-status-container`);e&&(e.style.display=`flex`)}let c=n.querySelector(`.execution-log-toggle-btn`);return c&&c.addEventListener(`click`,e=>{e.stopPropagation(),yd(t)}),t}function
|
|
1815
|
+
`,e.appendChild(n),requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight});let i=n.querySelector(`.stop-task-btn`),o=n.querySelector(`.loading-text`);i&&i.addEventListener(`click`,e=>{e.stopPropagation(),i.disabled=!0,i.style.opacity=`0.6`,i.style.cursor=`not-allowed`,o&&(o.textContent=r(`chatMsg.stopping`)),chrome.runtime.sendMessage({type:`CANCEL_REACT`,tabId:null,sessionId:N.activeSessionId}),N.pendingCancelApi&&N.pendingCancelApi({message:r(`chatMsg.errTaskStopped`),executionLog:N.currentExecutionStatus?.executionLog||[]})});let s=N.activeSessionId;if(N.executionLogListener=(e,n,r)=>e.sessionId&&e.sessionId!==s?!1:e.type===`EXECUTION_STATUS_UPDATE`?(a.debug(`[SidePanel] recei to execution statusupdate:`,e.nodeName,e.status,`log count:`,e.executionLog?.length),bd(t,e.nodeName,e.status,e.executionLog),!1):!1,chrome.runtime.onMessage.addListener(N.executionLogListener),N.chatConfig.enableExecutionLog){let e=n.querySelector(`.execution-status-container`);e&&(e.style.display=`flex`)}let c=n.querySelector(`.execution-log-toggle-btn`);return c&&c.addEventListener(`click`,e=>{e.stopPropagation(),yd(t)}),t}function tS(e){let t=document.getElementById(e);if(t){let e=t.querySelector(`.loading-text`);e&&(e.textContent=r(`chatMsg.thinking`)),t.remove()}N.executionLogListener&&=(chrome.runtime.onMessage.removeListener(N.executionLogListener),null),N.currentExecutionStatus=null;let n=document.querySelector(`.execution-log-panel.realtime-mode`);n&&n.remove()}function nS(e){if(!e)return;let t=iv((()=>{try{let t=e.dataset.executionLog;return t?JSON.parse(t):[]}catch{return[]}})()),n=[];try{n=JSON.parse(e.dataset.declaredArtifacts||`[]`)}catch{n=[]}let i=n.length?sv(t,n):t;if(Ev(i),zt(e,i.map(e=>e.path)).catch(()=>{}),i.length===0)return;let a=e.querySelector(`.artifacts-btn`);if(!a){let t=e.querySelector(`.footer-right-actions`);if(!t)return;a=document.createElement(`button`),a.className=`artifacts-btn`,a.type=`button`,a.title=r(`artifacts.btnTitle`,{count:i.length}),a.innerHTML=`
|
|
1806
1816
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="14" height="14">
|
|
1807
1817
|
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
|
|
1808
1818
|
<polyline points="14 2 14 8 20 8"/>
|
|
@@ -1810,20 +1820,20 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1810
1820
|
<line x1="9" y1="15" x2="15" y2="15"/>
|
|
1811
1821
|
</svg>
|
|
1812
1822
|
<span class="artifacts-btn-count">${i.length}</span>
|
|
1813
|
-
`;let n=t.querySelector(`.execution-log-btn`);n?t.insertBefore(a,n):t.prepend(a)}a._artifactsBound||(a.addEventListener(`click`,e=>{e.stopPropagation(),
|
|
1823
|
+
`;let n=t.querySelector(`.execution-log-btn`);n?t.insertBefore(a,n):t.prepend(a)}a._artifactsBound||(a.addEventListener(`click`,e=>{e.stopPropagation(),Dv(i,a)}),a._artifactsBound=!0,Tv(i,a))}function rS(e,t=null,n=!1){let i=document.getElementById(`chatContainer`);if(!i||!e)return;let o=document.createElement(`div`);o.innerHTML=e;let s=o.firstElementChild;if(!s)return;if(t&&(s.dataset.messageId=t),n){s.dataset.resumable=`true`;let e=s.querySelector(`:scope > .message-footer`);if(e&&!e.querySelector(`.resume-task-btn`)){let t=document.createElement(`button`);t.className=`resume-task-btn`,t.type=`button`,t.title=r(`chatMsg.resumeTaskTitle`),t.innerHTML=`
|
|
1814
1824
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1815
1825
|
<polygon points="5 3 19 12 5 21 5 3"></polygon>
|
|
1816
1826
|
</svg>
|
|
1817
1827
|
<span>${r(`chatMsg.resumeTaskBtn`)}</span>
|
|
1818
|
-
`,t.addEventListener(`click`,async e=>{if(e.stopPropagation(),t.disabled)return;let n=await
|
|
1828
|
+
`,t.addEventListener(`click`,async e=>{if(e.stopPropagation(),t.disabled)return;let n=await hb();n!==null&&(t.disabled=!0,t.style.opacity=`0.6`,t.style.cursor=`not-allowed`,yb(N.activeSessionId,n).finally(()=>{t.disabled=!1,t.style.opacity=``,t.style.cursor=``}))}),e.appendChild(t),_b(s,N.activeSessionId)}}s.classList.remove(`streaming`);let c=s.querySelector(`.thinking-process-header`);c&&Pb(c),s.querySelectorAll(`.tool-call-header`).forEach(e=>{e.addEventListener(`click`,t=>{t.ctrlKey||t.metaKey||e.closest(`.tool-call-item`).classList.toggle(`expanded`)})}),s.querySelectorAll(`.tool-call-result`).forEach(e=>{let t=e.querySelector(`code`);if(!t)return;let n=t.dataset.fullContent;if(!n||n.length<=500)return;let r=t.textContent||``,i=!1;e.style.cursor=`pointer`,e.addEventListener(`click`,e=>{e.ctrlKey||e.metaKey||(e.stopPropagation(),i=!i,t.textContent=i?n:r)})}),s.querySelectorAll(`.tool-call-body > pre, .tool-result-content > pre, .agent-stream-output > pre`).forEach(e=>{if(e.parentElement.classList.contains(`code-block-container`))return;let t=document.createElement(`div`);t.className=`code-block-container`,t.style.position=`relative`,t.innerHTML=`<button class="code-copy-btn" title="${r(`chatMsg.copyCode`)}">
|
|
1819
1829
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
1820
1830
|
<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25zM5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25z"/>
|
|
1821
1831
|
</svg>
|
|
1822
|
-
</button>`,e.parentElement.insertBefore(t,e),t.appendChild(e)}),s.querySelectorAll(`.subtask-progress`).forEach(e=>{
|
|
1832
|
+
</button>`,e.parentElement.insertBefore(t,e),t.appendChild(e)}),s.querySelectorAll(`.subtask-progress`).forEach(e=>{Ix(e)}),s.querySelectorAll(`.tool-call-terminate-btn, .agent-stream-terminate-btn`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation(),aS(N.activeSessionId)})}),s.querySelectorAll(`.tool-call-abort-btn`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),chrome.runtime.sendMessage({type:`ABORT_CURRENT_TOOL`,sessionId:N.activeSessionId}),e.disabled=!0,e.title=r(`chatMsg.aborting`)})});let l=s.querySelector(`.message-footer`);if(l){let e=l.querySelector(`.copy-btn`);e&&e.addEventListener(`click`,t=>{t.stopPropagation(),ib(s,e,t)});let t=l.querySelector(`.quote-btn`);t&&t.addEventListener(`click`,e=>{e.stopPropagation(),fb(s)});let n=l.querySelector(`.export-trigger-btn`),r=l.querySelector(`.export-dropdown`);n&&r&&(n.addEventListener(`click`,e=>{e.stopPropagation(),document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==r&&e.classList.remove(`show`)}),r.classList.toggle(`show`)}),r.querySelector(`.export-docx-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let t=e.currentTarget,{exportAssistantMessageToDocx:n}=await M(async()=>{let{exportAssistantMessageToDocx:e}=await import(`./chat-export-pxivPZ1I.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));n(s,t,r)}),r.querySelector(`.export-md-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let t=e.currentTarget,{exportAssistantMessageToMarkdown:n}=await M(async()=>{let{exportAssistantMessageToMarkdown:e}=await import(`./chat-export-pxivPZ1I.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));n(s,t,r)}),r.querySelector(`.export-pdf-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let t=e.currentTarget,{exportAssistantMessageToPdf:n}=await M(async()=>{let{exportAssistantMessageToPdf:e}=await import(`./chat-export-pxivPZ1I.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));n(s,t,r)}),r.querySelector(`.export-image-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let t=e.currentTarget,{exportAssistantMessageToImage:n}=await M(async()=>{let{exportAssistantMessageToImage:e}=await import(`./chat-export-pxivPZ1I.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));n(s,t,r)}));let i=l.querySelector(`.prototype-btn-small`);if(i){let e=(()=>{try{let e=s.dataset.executionLog;return e?JSON.parse(e):[]}catch{return[]}})().find(e=>e.nodeType===`tool_exec`&&e.action?.name===`preview_ui`||e.action?.name===`preview_preview_ui`&&e.status===`success`);e&&i.addEventListener(`click`,()=>{let t=e.prototypeId;if(!t&&e.observation)try{t=(typeof e.observation==`string`?JSON.parse(e.observation):e.observation)?.prototypeId}catch{}t?Ms(t):a.error(`[SidePanel] not found prototypeId,entry keys:`,Object.keys(e),`observation:`,e.observation)})}let o=l.querySelector(`.bookmark-btn`);o&&(gp(o,N.activeSessionId,s.dataset.messageId),o.addEventListener(`click`,async e=>{e.stopPropagation();let t=N.activeSessionId,n=s.dataset.messageId;if(o.classList.contains(`bookmarked`)){await ip(t,n),gp(o,t,n);let{refreshBookmarkPanel:e}=await M(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>cp);return{refreshBookmarkPanel:e}},void 0);e()}else{await rp(t,n,s.dataset.textContent_||``,N.sessions.find(e=>e.id===t)?.title||``),gp(o,t,n);let{refreshBookmarkPanel:e}=await M(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>cp);return{refreshBookmarkPanel:e}},void 0);e()}}));let c=l.querySelector(`.delete-btn`);c&&c.addEventListener(`click`,e=>{e.stopPropagation(),sS(s)});let u=l.querySelector(`.fork-btn`);u&&u.addEventListener(`click`,async e=>{e.stopPropagation();let t=s.dataset.messageId;t&&await as(N.activeSessionId,t)});let d=l.querySelector(`.resume-task-btn`);d&&d.addEventListener(`click`,async e=>{if(e.stopPropagation(),d.disabled)return;let t=await hb();t!==null&&(d.disabled=!0,d.style.opacity=`0.6`,d.style.cursor=`not-allowed`,yb(N.activeSessionId,t).finally(()=>{d.disabled=!1,d.style.opacity=``,d.style.cursor=``}))}),nS(s);let f=l.querySelector(`.token-usage-tag`);f&&!f._clickBound&&(f._clickBound=!0,f.style.cursor=`pointer`,f.addEventListener(`click`,e=>{e.stopPropagation();try{let e=s.dataset.executionLog,t=wt(e?JSON.parse(e):[]);t&&At(t,f)}catch{}}))}let u=s.querySelector(`.message-toolbar`);if(u){let e=u.querySelector(`.edit-btn`);e&&e.addEventListener(`click`,e=>{e.stopPropagation(),uS(s)});let t=u.querySelector(`.copy-btn`);t&&t.addEventListener(`click`,e=>{e.stopPropagation(),rb(s,t)});let n=u.querySelector(`.delete-btn`);n&&n.addEventListener(`click`,e=>{e.stopPropagation(),sS(s)})}s.querySelectorAll(`.user-message-image`).forEach(e=>{e.addEventListener(`click`,()=>{ef(e.src,e)})}),i.appendChild(s),Cw()}function iS(e){e.querySelectorAll(`.tool-call-body > pre, .tool-result-content > pre, .agent-stream-output > pre`).forEach(e=>{if(e.parentElement.classList.contains(`code-block-container`))return;let t=document.createElement(`div`);t.className=`code-block-container`,t.style.position=`relative`,t.innerHTML=`<button class="code-copy-btn" title="${r(`chatMsg.copyCode`)}">
|
|
1823
1833
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
1824
1834
|
<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25zM5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25z"/>
|
|
1825
1835
|
</svg>
|
|
1826
|
-
</button>`,e.parentElement.insertBefore(t,e),t.appendChild(e)}),e.querySelectorAll(`.thinking-process-header`).forEach(e=>{
|
|
1836
|
+
</button>`,e.parentElement.insertBefore(t,e),t.appendChild(e)}),e.querySelectorAll(`.thinking-process-header`).forEach(e=>{Pb(e)}),e.querySelectorAll(`.tool-call-header`).forEach(e=>{e.addEventListener(`click`,t=>{if(t.ctrlKey||t.metaKey)return;let n=e.closest(`.tool-call-item`);n&&n.classList.toggle(`expanded`)})}),e.querySelectorAll(`.tool-call-result`).forEach(e=>{let t=e.querySelector(`code`);if(!t)return;let n=t.dataset.fullContent;if(!n||n.length<=500)return;let r=t.textContent||``,i=!1;e.style.cursor=`pointer`,e.addEventListener(`click`,e=>{e.ctrlKey||e.metaKey||(e.stopPropagation(),i=!i,t.textContent=i?n:r)})}),e.querySelectorAll(`.subtask-progress`).forEach(e=>{Ix(e)}),e.querySelectorAll(`.tool-call-terminate-btn, .agent-stream-terminate-btn`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation(),aS(N.activeSessionId)})}),e.querySelectorAll(`.tool-call-abort-btn`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),chrome.runtime.sendMessage({type:`ABORT_CURRENT_TOOL`,sessionId:N.activeSessionId}),e.disabled=!0,e.title=r(`chatMsg.aborting`)})}),e.querySelectorAll(`.message-footer`).forEach(e=>{let t=e.closest(`.message`);if(!t)return;let n=e.querySelector(`.copy-btn`);n&&n.addEventListener(`click`,e=>{e.stopPropagation(),ib(t,n,e)});let r=e.querySelector(`.quote-btn`);r&&r.addEventListener(`click`,e=>{e.stopPropagation(),fb(t)});let i=e.querySelector(`.export-trigger-btn`),a=e.querySelector(`.export-dropdown`);i&&a&&(i.addEventListener(`click`,e=>{e.stopPropagation(),document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==a&&e.classList.remove(`show`)}),a.classList.toggle(`show`)}),a.querySelector(`.export-docx-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let n=e.currentTarget,{exportAssistantMessageToDocx:r}=await M(async()=>{let{exportAssistantMessageToDocx:e}=await import(`./chat-export-pxivPZ1I.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));r(t,n,a)}),a.querySelector(`.export-md-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let n=e.currentTarget,{exportAssistantMessageToMarkdown:r}=await M(async()=>{let{exportAssistantMessageToMarkdown:e}=await import(`./chat-export-pxivPZ1I.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));r(t,n,a)}),a.querySelector(`.export-pdf-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let n=e.currentTarget,{exportAssistantMessageToPdf:r}=await M(async()=>{let{exportAssistantMessageToPdf:e}=await import(`./chat-export-pxivPZ1I.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));r(t,n,a)}),a.querySelector(`.export-image-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let n=e.currentTarget,{exportAssistantMessageToImage:r}=await M(async()=>{let{exportAssistantMessageToImage:e}=await import(`./chat-export-pxivPZ1I.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([10,11,1,12,2,3,4,13,14,0]));r(t,n,a)}));let o=e.querySelector(`.prototype-btn-small`);if(o){let e=(()=>{try{let e=t.dataset.executionLog;return e?JSON.parse(e):[]}catch{return[]}})().find(e=>e.nodeType===`tool_exec`&&e.action?.name===`preview_ui`||e.action?.name===`preview_preview_ui`&&e.status===`success`);e&&o.addEventListener(`click`,()=>{let t=e.prototypeId;if(!t&&e.observation)try{t=(typeof e.observation==`string`?JSON.parse(e.observation):e.observation)?.prototypeId}catch{}t&&Ms(t)})}let s=e.querySelector(`.bookmark-btn`);s&&(gp(s,N.activeSessionId,t.dataset.messageId),s.addEventListener(`click`,async e=>{e.stopPropagation();let n=N.activeSessionId,r=t.dataset.messageId;if(s.classList.contains(`bookmarked`)){await ip(n,r),gp(s,n,r);let{refreshBookmarkPanel:e}=await M(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>cp);return{refreshBookmarkPanel:e}},void 0);e()}else{await rp(n,r,t.dataset.textContent_||``,N.sessions.find(e=>e.id===n)?.title||``),gp(s,n,r);let{refreshBookmarkPanel:e}=await M(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>cp);return{refreshBookmarkPanel:e}},void 0);e()}}));let c=e.querySelector(`.delete-btn`);c&&c.addEventListener(`click`,e=>{e.stopPropagation(),sS(t)});let l=e.querySelector(`.fork-btn`);l&&l.addEventListener(`click`,async e=>{e.stopPropagation();let n=t.dataset.messageId;n&&await as(N.activeSessionId,n)});let u=e.querySelector(`.resume-task-btn`);u&&u.addEventListener(`click`,async e=>{if(e.stopPropagation(),u.disabled)return;let t=await hb();t!==null&&(u.disabled=!0,u.style.opacity=`0.6`,u.style.cursor=`not-allowed`,yb(N.activeSessionId,t).finally(()=>{u.disabled=!1,u.style.opacity=``,u.style.cursor=``}))}),nS(t);let d=e.querySelector(`.token-usage-tag`);d&&!d._clickBound&&(d._clickBound=!0,d.style.cursor=`pointer`,d.addEventListener(`click`,e=>{e.stopPropagation();try{let e=t.dataset.executionLog,n=wt(e?JSON.parse(e):[]);n&&At(n,d)}catch{}}))}),e.querySelectorAll(`.message-toolbar`).forEach(e=>{let t=e.closest(`.message`);if(!t)return;let n=e.querySelector(`.edit-btn`);n&&n.addEventListener(`click`,e=>{e.stopPropagation(),uS(t)});let r=e.querySelector(`.copy-btn`);r&&r.addEventListener(`click`,e=>{e.stopPropagation(),rb(t,r)});let i=e.querySelector(`.delete-btn`);i&&i.addEventListener(`click`,e=>{e.stopPropagation(),sS(t)})}),e.querySelectorAll(`.user-message-image`).forEach(e=>{e.addEventListener(`click`,()=>{ef(e.src,e)})}),e.querySelectorAll(`.mermaid-controls`).forEach(e=>e.remove()),Gt(),Zx(),$x(),Cw()}function aS(e){return new Promise(t=>{let n=document.querySelector(`.command-terminate-overlay`);n&&n.remove();let i=document.createElement(`div`);i.className=`command-terminate-overlay`,i.innerHTML=`
|
|
1827
1837
|
<div class="command-terminate-modal">
|
|
1828
1838
|
<div class="command-terminate-header">
|
|
1829
1839
|
<div class="command-terminate-icon">⏹</div>
|
|
@@ -1852,7 +1862,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1852
1862
|
<button class="command-terminate-cancel">${r(`common.cancel`)}</button>
|
|
1853
1863
|
</div>
|
|
1854
1864
|
</div>
|
|
1855
|
-
`,document.body.appendChild(i);let a=()=>{i.remove()};i.querySelector(`.command-terminate-cancel`).addEventListener(`click`,()=>{a(),t(null)}),i.querySelector(`.wait-btn`).addEventListener(`click`,()=>{a(),chrome.runtime.sendMessage({type:`TERMINATE_COMMAND`,sessionId:e,mode:`wait`}),t(`wait`)}),i.querySelector(`.kill-btn`).addEventListener(`click`,()=>{a(),chrome.runtime.sendMessage({type:`TERMINATE_COMMAND`,sessionId:e,mode:`kill`}),t(`kill`)})})}function
|
|
1865
|
+
`,document.body.appendChild(i);let a=()=>{i.remove()};i.querySelector(`.command-terminate-cancel`).addEventListener(`click`,()=>{a(),t(null)}),i.querySelector(`.wait-btn`).addEventListener(`click`,()=>{a(),chrome.runtime.sendMessage({type:`TERMINATE_COMMAND`,sessionId:e,mode:`wait`}),t(`wait`)}),i.querySelector(`.kill-btn`).addEventListener(`click`,()=>{a(),chrome.runtime.sendMessage({type:`TERMINATE_COMMAND`,sessionId:e,mode:`kill`}),t(`kill`)})})}function oS(e){return new Promise(t=>{let n=document.querySelector(`.delete-confirm-overlay`);n&&n.remove();let i=document.createElement(`div`);i.className=`delete-confirm-overlay`;let a=e.length>50?e.substring(0,50)+`...`:e;i.innerHTML=`
|
|
1856
1866
|
<div class="delete-confirm-modal">
|
|
1857
1867
|
<div class="delete-confirm-header">
|
|
1858
1868
|
<div class="delete-confirm-icon">🗑️</div>
|
|
@@ -1867,7 +1877,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1867
1877
|
<button class="delete-confirm-confirm">${r(`chatMsg.confirmDelete`)}</button>
|
|
1868
1878
|
</div>
|
|
1869
1879
|
</div>
|
|
1870
|
-
`,document.body.appendChild(i);let o=i.querySelector(`.delete-confirm-cancel`),s=i.querySelector(`.delete-confirm-confirm`);o.addEventListener(`click`,()=>{i.remove(),t(!1)}),s.addEventListener(`click`,()=>{i.remove(),t(!0)}),i.addEventListener(`click`,e=>{e.target})})}async function
|
|
1880
|
+
`,document.body.appendChild(i);let o=i.querySelector(`.delete-confirm-cancel`),s=i.querySelector(`.delete-confirm-confirm`);o.addEventListener(`click`,()=>{i.remove(),t(!1)}),s.addEventListener(`click`,()=>{i.remove(),t(!0)}),i.addEventListener(`click`,e=>{e.target})})}async function sS(e,t=!1){let n=e.dataset.messageId,i=e.classList.contains(`user`)?`user`:`assistant`,o=``;if(o=i===`user`?e.textContent.trim():e.dataset.textContent_||``,!t&&!await oS(o))return;if(n){let e=N.messageHistory.findIndex(e=>e.messageId===n);e!==-1&&N.messageHistory.splice(e,1)}else{let t=e.dataset.timestamp,n=N.messageHistory.findIndex(e=>e.timestamp===t);n!==-1&&N.messageHistory.splice(n,1)}let s=e.previousElementSibling;s&&s.classList.contains(`user-context-bubble`)&&s.remove(),e.remove();let c=document.getElementById(`chatContainer`);c.querySelectorAll(`.message`).length===0&&(c.innerHTML=`
|
|
1871
1881
|
<div class="welcome-message">
|
|
1872
1882
|
<div class="icon-wrapper">
|
|
1873
1883
|
<div class="icon">💬</div>
|
|
@@ -1875,7 +1885,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1875
1885
|
<h2>${r(`chat.welcomeTitle`)}</h2>
|
|
1876
1886
|
<p>${r(`chat.welcomeSubtitle`)}</p>
|
|
1877
1887
|
</div>
|
|
1878
|
-
`),await
|
|
1888
|
+
`),await bx(),n&&N.activeSessionId&&be(N.activeSessionId,n).then(e=>{e||a.warn(`[SidePanel] IndexedDB messagecleanup failed, messageId:`,n)}).catch(e=>{a.error(`[SidePanel] IndexedDB messagecleanup exception:`,e)}),a.debug(`[SidePanel] deletedmessage: ${i}, messageId: ${n}`)}async function cS(e=null){try{let{mcpTools:t}=await chrome.storage.local.get([`mcpTools`]),n=t||[],r=new Set(Array.isArray(N.mcpClosedServers)?N.mcpClosedServers:[]),i=new Set(Array.isArray(N.activeAgentMcpExcludedServerIds)?N.activeAgentMcpExcludedServerIds:[]),a=new Set(Array.isArray(e)?e:[]);return n.filter(e=>{let t=e.serverId||`unknown`;return a.has(t)?!0:!r.has(t)&&!i.has(t)}).length}catch{return 0}}async function lS(e,t,n=!1,i={},o={}){let{resumeFromCheckpoint:s=!1,userGuidance:c=``,loadingId:l=null,forcedMcpServerIds:u=null,sessionId:d=null,agent:f=null}=o,p=f?f.agentId:N.activeAgentId,m=f?f.agentToolIds:N.activeAgentToolIds,h=f?f.agentSkillIds:N.activeAgentSkillIds,g=f?f.agentMcpExcludedServerIds:N.activeAgentMcpExcludedServerIds,_=(await mt()).loopTimeout,v=await new Promise(e=>{chrome.storage.local.get(`reflectionConfig`,t=>{e(t.reflectionConfig||{enabled:!1})})}),y=d||N.activeSessionId,b=s?`resume_${Date.now()}_${Math.random().toString(36).substring(2,8)}`:`call_${Date.now()}_${Math.random().toString(36).substring(2,8)}`;if(a.debug(`[SidePanel] callApi: generating callId: ${b}${s?` (restoremode)`:``}`),s&&l&&(i={...i,_loadingId:l}),N.pendingCancelApiMap&&N.pendingCancelApiMap.has(y)){a.debug(`[SidePanel] callApi: detectedsession has ongoing API call with , first cancelold`);let e=N.pendingCancelApiMap.get(y);e&&e({message:r(`chatMsg.errTaskReplaced`),executionLog:[]})}N.pendingCallApiSessionIds&&N.pendingCallApiSessionIds.has(y)&&(N.pendingCallApiSessionIds.delete(y),cx());let x=Hb(y),S=chrome.runtime.connect({name:`keepalive-`+y});a.debug(`[SidePanel] keepalive portconnected, sessionId:`,y),dc(y);try{let e=uc();S.postMessage({type:`KEEPALIVE_IDENTITY`,identity:e==null?null:{windowId:e}})}catch{}let C={restarted:!1,rejectFn:null,cleanup:null,checkpoint:null};S.onMessage.addListener(e=>{if(e.type===`HOST_TAB_RESOLVED`&&e.sessionId===y){fc(y,e.hostTabId);return}e.type===`SW_RESTARTED`&&e.sessionId===y&&(a.warn(`[SidePanel] ⚠️ recei to SW_RESTARTED notification,background re started,API call lost`),C.restarted=!0,C.checkpoint=e.checkpoint||null,C.rejectFn&&C.cleanup&&(C.cleanup(),C.rejectFn({message:r(`chatMsg.errSwRestarted`),executionLog:[],checkpoint:C.checkpoint,swRestarted:!0}))),e.type===`SHOW_CLARIFY_DIALOG`?Ya(e.data):e.type===`CLARIFY_TIMEOUT`?eo(e):e.type===`CLARIFY_EXTENDED`?za(e):e.type===`SHOW_CONFIRM_DIALOG`?vo(e.data):e.type===`DISMISS_CONFIRM_DIALOG`&&xo(e.data)});let w={timeoutId:null,removeListener:()=>{}},T=()=>{try{S.disconnect()}catch{}w.timeoutId&&=(clearTimeout(w.timeoutId),null),w.removeListener(),N.pendingCancelApiMap.delete(y),N.pendingCallApiSessionIds.delete(y),Ub(y),cx()};return new Promise((o,l)=>{if(C.cleanup=T,C.rejectFn=l,C.restarted){T(),l({message:r(`chatMsg.errSwRestarted`),executionLog:[],checkpoint:C.checkpoint,swRestarted:!0});return}let d=[],f=Math.round(_/1e3);x(null),Kb(null),Jb(0);let S=``,E={},D=e=>{x()&&ox(x()),T(),(!e.executionLog||e.executionLog.length===0||d.length>0)&&(e.executionLog=d),l(e)};N.pendingCancelApi=D,N.pendingCallApiSessionIds.add(y),cx(),a.debug(`[SidePanel] callApi: add pendingCallApiSessionIds, mySessionId =`,y,`, set:`,[...N.pendingCallApiSessionIds]),w.timeoutId=setTimeout(()=>{D({message:r(`chatMsg.errTimeout`,{seconds:f}),executionLog:d}),chrome.runtime.sendMessage({type:`CANCEL_REACT`,tabId:N.currentTabId,sessionId:y}).catch(e=>{a.debug(`[SidePanel] sendcancelrequest failed:`,e.message)})},_);let O=Date.now(),k=0,A=null,j=()=>{A===null&&w.timeoutId!==null&&(A=Date.now(),clearTimeout(w.timeoutId),w.timeoutId=null,a.debug(`[SidePanel] before sidetimeoutpaused (waitinguser response:clarification/sensitive toolconfirm)`))},ee=()=>{if(A!==null){let e=Date.now()-A;k+=e,A=null;let t=Date.now()-O,n=_+k-t;if(n<=0){D({message:r(`chatMsg.errTimeout`,{seconds:f}),executionLog:d});return}w.timeoutId=setTimeout(()=>{D({message:r(`chatMsg.errTimeout`,{seconds:f}),executionLog:d}),chrome.runtime.sendMessage({type:`CANCEL_REACT`,tabId:N.currentTabId,sessionId:y}).catch(e=>{a.debug(`[SidePanel] sendcancelrequest failed:`,e.message)})},n),a.debug(`[SidePanel] before sidetimeoutrestored,pause duration:`,Math.round(e/1e3),`s,remaining time:`,Math.round(n/1e3),`s`)}},te=e=>{if(e.sessionId&&e.sessionId!==y||e.callId&&e.callId!==b)return!1;if(e.type===`EXECUTION_STATUS_UPDATE`){let t=e.executionLog||[];if(t.length>0&&t.forEach(e=>{let t=d.findIndex(t=>t.id===e.id);t===-1?d.push(e):d[t]={...d[t],...e}}),e.subtaskTotal&&e.subtaskTotal>0){let t=x();if(t){let n=t.querySelector(`.stream-content`);if(n){let t=e.subtaskIndex??0,i=Px(d);i&&[...i.items].sort((e,t)=>e.index-t.index).forEach(r=>{if(r.index===t)return;let a=`.subtask-progress[data-subtask-index="${r.index}"]`;if(n.querySelector(a))return;let o=document.createElement(`div`);o.className=`subtask-progress subtask-progress-pending`,o.dataset.subtaskIndex=r.index,o.innerHTML=Fx(r,i.total||e.subtaskTotal),Lx(n,o),Ix(o)});let a=`.subtask-progress[data-subtask-index="${t}"]`,o=n.querySelector(a),s=o?o.classList.contains(`subtask-expanded`):!1;o||(o=document.createElement(`div`),o.className=`subtask-progress`,o.dataset.subtaskIndex=t,Lx(n,o));let c=Mx,l=t+1,u=e.subtaskTotal,f=e.subtaskName||``,p=`<span class="subtask-badge">${l}/${u}</span>`,m=Nx,h=e.status!==`success`&&e.status!==`failed`,g=d.filter(e=>e.subtaskIndex===t&&e.nodeType!==`subtask`),_=Ox(g),v=_.total,y=_.success,b=_.failed,x=_.other,S=g.find(e=>e.status===`processing`),C=Dx(e.status,y,v),w=i?i.items.find(e=>e.index===t):null,T=w&&w.description?String(w.description).replace(/\s+/g,` `).trim():``,E=d.find(e=>e.subtaskIndex===t&&e.nodeType===`subtask`),D=kx(d,t)?`<span class="subtask-replay-skipped" title="${L(r(`chatMsg.subtaskReplaySkippedHint`))}">${r(`chatMsg.subtaskReplaySkipped`)}</span>`:``;o.classList.remove(`subtask-progress-pending`);let O=``;e.status===`success`?(O=`<span class="subtask-status-done">${r(`chatMsg.subtaskDone`)}</span>`,o.classList.add(`subtask-progress-done`),o.classList.remove(`subtask-progress-active`)):C===`partial`?(O=`<span class="subtask-status-partial">${r(`chatMsg.subtaskPartial`)}</span>`,o.classList.add(`subtask-progress-failed`),o.classList.remove(`subtask-progress-active`)):e.status===`failed`?(O=`<span class="subtask-status-failed">${r(`chatMsg.subtaskFailed`)}</span>`,o.classList.add(`subtask-progress-failed`),o.classList.remove(`subtask-progress-active`)):(O=`<span class="subtask-status-label"><span class="subtask-spinner"></span>${r(`chatMsg.subtaskExecuting`)}</span>`,o.classList.add(`subtask-progress-active`));let k=``;if(h&&v>0){let e=S?S.nodeType===`tool_exec`?`🔧`:S.nodeType===`api_call`?`📡`:S.nodeType===`reflection`?`🎯`:S.nodeType===`preselect`?`🔍`:`○`:`○`,t=S?F(S.nodeName||``):r(`chatMsg.preparing`),n=S?sd(S):``;k=`<div class="subtask-progress-line">
|
|
1879
1889
|
<span class="subtask-current-node"><span class="subtask-current-spinner"></span><span class="node-label">${e} ${t}</span>${n?` <span class="subtask-current-cmd" title="${L(n)}">${F(n)}</span>`:``}</span>
|
|
1880
1890
|
<span class="subtask-node-stats">
|
|
1881
1891
|
<span class="subtask-stat-total">${v}</span>
|
|
@@ -1903,12 +1913,12 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1903
1913
|
</div>
|
|
1904
1914
|
${k}
|
|
1905
1915
|
<div class="subtask-detail-body"></div>
|
|
1906
|
-
`,s&&o.classList.add(`subtask-expanded`);let A=o.querySelector(`.subtask-detail-body`);o._renderNodes=()=>{if(!A)return;let e=[];T&&e.push(`<div class="subtask-detail-desc"><span class="subtask-detail-label">${r(`chatMsg.subtaskDescLabel`)}</span>${F(T)}</div>`);let n=E&&E.result?String(E.result).trim():``;n&&e.push(`<div class="subtask-detail-result"><span class="subtask-detail-label">${r(`chatMsg.subtaskResultLabel`)}</span>${F(n)}</div>`);let i=d.filter(e=>e.subtaskIndex===t&&e.nodeType!==`subtask`),a=
|
|
1916
|
+
`,s&&o.classList.add(`subtask-expanded`);let A=o.querySelector(`.subtask-detail-body`);o._renderNodes=()=>{if(!A)return;let e=[];T&&e.push(`<div class="subtask-detail-desc"><span class="subtask-detail-label">${r(`chatMsg.subtaskDescLabel`)}</span>${F(T)}</div>`);let n=E&&E.result?String(E.result).trim():``;n&&e.push(`<div class="subtask-detail-result"><span class="subtask-detail-label">${r(`chatMsg.subtaskResultLabel`)}</span>${F(n)}</div>`);let i=d.filter(e=>e.subtaskIndex===t&&e.nodeType!==`subtask`),a=jx(i,o._nodeFilter),s=``;i.length>0&&a.length===0?s=`<div class="subtask-node-empty">${F(r(`chatMsg.subtaskFilterEmpty`))}</div>`:a.length>0&&(s=a.map(e=>{let t=e.nodeType===`tool_exec`?`🔧`:e.nodeType===`api_call`?`📡`:e.nodeType===`reflection`?`🎯`:e.nodeType===`preselect`?`🔍`:`○`,n=e.status===`success`?`✓`:e.status===`failed`?`✗`:h?`<span class="subtask-node-spinner"></span>`:`○`,i=e.status===`success`?`done`:e.status===`failed`?`failed`:`processing`,a=e.duration?vt(e.duration):``,o=F(e.nodeName||r(`chatMsg.unknownNode`)),s=``;if(e.nodeType===`tool_exec`){let t=sd(e);t&&(s=`<span class="subtask-node-cmd" title="${L(t)}">${F(t)}</span>`)}return`<div class="subtask-node ${i}">
|
|
1907
1917
|
<span class="subtask-node-icon">${t}</span>
|
|
1908
1918
|
<span class="subtask-node-status">${n}</span>
|
|
1909
1919
|
<span class="subtask-node-name">${o}${s}</span>
|
|
1910
1920
|
${a?`<span class="subtask-node-dur">${a}</span>`:``}
|
|
1911
|
-
</div>`}).join(``)),A.innerHTML=e.join(``)+s},o._renderNodes(),
|
|
1921
|
+
</div>`}).join(``)),A.innerHTML=e.join(``)+s},o._renderNodes(),Ix(o),e.status===`success`&&l>=u&&n.querySelectorAll(`.subtask-progress`).forEach(e=>e.classList.add(`subtask-progress-all-done`))}}}return!1}if(e.type===`CLARIFY_START`)return j(),!1;if(e.type===`CLARIFY_END`)return ee(),!1;if(e.type===`TOOL_CONFIRM_START`)return j(),!1;if(e.type===`TOOL_CONFIRM_END`)return ee(),!1;if(e.type===`STREAM_PRESELECT`){if(a.debug(`[SidePanel] received pre-filterlog,:`,e.preselectLog?.length),Kb(e.preselectLog||null),x()&&Gb()&&Gb().length>0){let e=x().querySelector(`.message-content`);e&&(Gb().forEach(t=>{let n=rx(t);e.insertBefore(n,e.firstChild)}),Kb(null),a.debug(`[SidePanel] pre-filtercard imageappended to existingstreamingelement`))}return!1}if(e.type===`API_RETRYING`){let t=r(`chatMsg.retrying`,{attempt:e.attempt,max:e.maxRetries}),n=x();if(n){let e=n.querySelector(`.thinking-indicator:not(.hidden) .thinking-label`);e&&(e.textContent=t,e.dataset.retrying=`1`)}else{let e=document.querySelector(`.loading-message .loading-text`);e&&(e.textContent=t)}return!1}if(e.type===`STREAM_START`){a.debug(`[SidePanel] streamingoutput start`);let e=i._loadingId,t=e?document.getElementById(e):document.querySelector(`.loading-message`);if(t&&t.remove(),N.executionLogListener&&=(chrome.runtime.onMessage.removeListener(N.executionLogListener),null),N.currentExecutionStatus=null,x()){let e=x().querySelector(`.stream-content`);if(e){let t=e.querySelector(`.thinking-indicator:not(.hidden)`);if(t&&a.warn(`[STREAM_START] has can seen thinking indicator,skipcreate:`,t),!t){let t=document.createElement(`div`);t.className=`thinking-indicator`,t.innerHTML=`
|
|
1912
1922
|
<svg class="thinking-icon pulse-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1913
1923
|
<path d="M12 2a3 3 0 0 0-3 3v1a3 3 0 0 0 3 3 3 3 0 0 1 3 3v1a3 3 0 0 1-3 3 3 3 0 0 0-3 3v1a3 3 0 0 0 3 3"/>
|
|
1914
1924
|
<circle cx="8" cy="12" r="1.5"/>
|
|
@@ -1921,20 +1931,17 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1921
1931
|
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
|
|
1922
1932
|
</svg>
|
|
1923
1933
|
</button>
|
|
1924
|
-
`;let n=t.querySelector(`.streaming-stop-btn`);n&&n.addEventListener(`click`,e=>{e.stopPropagation(),
|
|
1925
|
-
|
|
1926
|
-
${Qb(``,`agent-stream-content`)}
|
|
1927
|
-
`,e.toolCallId){let t=x().querySelector(`.tool-call-item[data-tool-call-id="${e.toolCallId}"]`);if(t){let e=t.querySelector(`.tool-call-body`);e?e.appendChild(n):t.appendChild(n)}}if(!n.isConnected){let e=x().querySelector(`.stream-content`);e&&e.appendChild(n)}t={element:n,stdout:``,stderr:``},E[e.execId]=t,qt()}let n=t.element.querySelector(`code`);n&&(e.streamType===`stderr`?t.stderr+=e.data:t.stdout+=e.data,n.textContent=t.stdout+(t.stderr?`
|
|
1928
|
-
`+t.stderr:``),n.parentElement.scrollTop=n.parentElement.scrollHeight)}return!1}if(e.type===`AGENT_STREAM_DONE`){if(e.execId){let t=E[e.execId];t&&e.exitCode!==0&&t.element.classList.add(`agent-stream-error`)}return!1}if(e.type===`STREAM_DONE`){if(x()){let e=x().querySelector(`.stream-status`);e&&(v?.enabled?e.textContent=r(`chatMsg.reflectionInProgress`):e.textContent=``)}return!1}if(e.type===`API_COMPLETE`){let t=e.content&&String(e.content).trim()?e.content:r(`chatMsg.emptyModelReply`);x()&&tx(x(),t,e.executionLog||[],e.reflectionScore,e.reasoningContent,e.wasRevised);let n=x(),i=!!n,a=n?n.dataset.htmlContent||n.outerHTML:null,s=n?n.isConnected:!1,c=n?n.dataset.messageId:null;return T(),console.log(`[callApi API_COMPLETE] wasStreamed:`,i,`| message.executionLog entries:`,e.executionLog?.length||0,`| local executionLog entries:`,d.length,`| agent_file entries:`,(e.executionLog||d)?.filter(e=>e.nodeType===`tool_exec`&&e.action?.name===`agent_file`).length||0),o({content:t,executionLog:e.executionLog||d,reflectionScore:e.reflectionScore,wasStreamed:i,wasRevised:e.wasRevised,streamingHtml:a,streamingConnected:s,streamingMsgId:c}),!1}else if(e.type===`API_ERROR`){let t=x();return t&&t.isConnected&&t.remove(),T(),l({message:e.error,executionLog:e.executionLog||d}),!1}return!1};if(chrome.runtime.onMessage.addListener(te),w.removeListener=()=>{chrome.runtime.onMessage.removeListener(te)},s)a.debug(`[SidePanel] send RESUME_REACT message,sessionId:`,y,`userGuidance:`,c?`"${c.substring(0,50)}..."`:`( no )`,`timeout:`,_),chrome.runtime.sendMessage({type:`RESUME_REACT`,sessionId:y,callId:b,userGuidance:c||``});else{let r=e.some(e=>Array.isArray(e.content)&&e.content.some(e=>e&&e.type===`image_url`));a.debug(`[SidePanel] send CALL_API message,useTools:`,n,`tabId:`,N.currentTabId,`sessionId:`,y,`apiParams:`,i,`timeout:`,_),chrome.runtime.sendMessage({type:`CALL_API`,sessionId:y,messages:e,model:t,useTools:n,tabId:N.currentTabId,apiParams:i,agentId:p,agentToolIds:m,agentSkillIds:h,forcedMcpServerIds:Array.isArray(u)&&u.length>0?u:null,agentMcpExcludedServerIds:g??null,callId:b,imageApiBase:N.enableImageInput&&r&&N.imageApiBase||``,imageApiKey:N.enableImageInput&&r&&N.imageApiKey||``})}})}function sS(e){try{let t=e.dataset.rawContent||``,n=e.dataset.textContent_||``;if(!n&&!t){P(r(`chatMsg.cannotGetMessageContent`),`error`);return}let i=[];if(t.startsWith(`[`))try{let e=JSON.parse(t);if(Array.isArray(e)){let t=e.filter(e=>e.type===`image_url`);for(let e of t){let t=e.image_url.original_url||e.image_url.url;i.push({originalUrl:t,compressedUrl:e.image_url.url,width:e.image_url.width,height:e.image_url.height})}}}catch{}i.length>0&&(N.attachedImages=i,uf());let o=[];if(e.dataset.attachedFiles)try{let t=JSON.parse(e.dataset.attachedFiles);for(let e of t)o.push({name:e.name,size:e.size,type:e.type,text:e.text||``,status:e.status||`done`,agentPath:e.agentPath||``})}catch{}o.length>0&&(N.attachedFiles=o,M(()=>Promise.resolve().then(()=>Mf).then(e=>{e.renderFilePreviews()}),void 0));let s=n.match(/^\[网页上下文\]\n标题: (.+)\nURL: (.+)\ntabId: (\d+)\n/);if(s){gy(),N.selectedPage={id:parseInt(s[3]),title:s[1],url:s[2],favIconUrl:``};let e=document.getElementById(`pageIndicator`),t=document.getElementById(`pageIndicatorName`);if(e&&t){let n=s[1],r=s[2];n&&n!==`无标题`&&r?t.textContent=`${n} · ${r}`:t.textContent=n||r,e.style.display=`flex`}}let c=n.match(/\[知识库检索结果\](引用: ([^)]+))/);if(c){let e=c[1].split(`、`).map(e=>e.trim()).filter(Boolean);e.length>0&&(ty(),N.knowledgeRefs=e.map(e=>({id:``,name:e})),ny(),oy().then(e=>{if(e&&e.ok){let t=new Map((e.collections||[]).map(e=>[e.name,e]));N.knowledgeRefs=N.knowledgeRefs.map(e=>{if(e.id)return e;let n=t.get(e.name);return{id:n?.id||``,name:e.name,enabled:n?n.enabled!==!1:!0}}),ny()}}).catch(()=>{}))}let l=Array.from(new Set([...n.matchAll(/\[(?:已选技能|Selected skill):\s*([^\n\]]+)\]/g)].map(e=>e[1].split(` - `)[0].trim()).filter(Boolean)));l.length>0&&(US(),N.selectedSkills=l.map(e=>({name:e,description:``,type:`agent`})),WS());let u=Array.from(new Set([...n.matchAll(/\[(?:已选MCP服务|Selected MCP service):\s*([^\n\]]+)\]/g)].map(e=>e[1].split(` - `)[0].trim()).filter(Boolean)));u.length>0&&(nC(),N.selectedMcpServices=u.map(e=>({serverId:``,serverName:e,toolCount:0})),iC(),chrome.storage.local.get([`mcpTools`],e=>{let t=e.mcpTools||[];u.forEach(e=>{let n=N.selectedMcpServices.find(t=>t.serverName===e);if(!n||n.serverId)return;let r=t.find(t=>(t.serverName||``)===e)||t.find(t=>(t.serverName||``).startsWith(e));r&&(n.serverId=r.serverId||``,n.toolCount=t.filter(e=>e.serverId===r.serverId).length)}),iC()}));let d=n;s&&(d=d.replace(/^\[网页上下文\]\n标题: .+\nURL: .+\ntabId: \d+\n/,``)),c&&(d=d.replace(/\[知识库检索结果\][^\n]*\n[\s\S]*?\[\/知识库检索结果\]\n\n?/,``)),u.length>0&&(d=Wx(d)),l.length>0&&(d=Ux(d));let f=N.quotedContextText,p=N.selectedContextText;N.quotedContextText=``,N.selectedContextText=``;let m=d.match(/^\[引用内容(?:摘要)?\]\n([\s\S]+?)\n\n\[用户问题\]\n([\s\S]*)$/),h=d.match(/^\[选中内容(?:摘要)?\]\n([\s\S]+?)\n\n\[用户问题\]\n([\s\S]*)$/),g=m||h,_=d;if(g){let e=m?`quoted`:`selected`,t=g[1].trim(),n=g[2].trim();if(o.length>0){let e=n.search(/\n\n\[(?:工作目录)?文件(?:内容)?:/);e!==-1&&(n=n.substring(0,e).trim())}let i=document.getElementById(`selectionIndicator`),a=document.getElementById(`selectionText`);if(i&&a){let n;n=t.length>100?t.substring(0,100)+`...`:t.length>50?t.substring(0,50)+`...`:t,e===`quoted`?(N.quotedContextText=t,N.selectedContextText=p,a.textContent=r(`chatMsg.quotedContextLabel`,{text:n})):(N.selectedContextText=t,N.quotedContextText=f,a.textContent=r(`chatMsg.selectedContextLabel`,{text:n})),i.classList.add(`show`)}_=n}else if(N.quotedContextText=f,N.selectedContextText=p,o.length>0){let e=_.search(/\n\n\[(?:工作目录)?文件(?:内容)?:/);e!==-1&&(_=_.substring(0,e).trim())}let v=document.getElementById(`userInput`);v.value=_,Dt(),v.focus(),v.selectionStart=v.selectionEnd=v.value.length,a.debug(`[SidePanel] loadedmessagecontent to input box,waitingafter user editsend`)}catch(e){a.error(`[SidePanel] editmessage failed:`,e),P(r(`chatMsg.editFailed`,{message:e.message}),`error`)}}n(`zh`,{promptMgr:{promptsTabCount:`提示词 ({count})`,skillsTabCount:`技能 ({count})`,mcpTabCount:`MCP ({count})`,noMatchPrompt:`暂无匹配的提示词`,mergedHeaderHint:`方向键切换 · Enter发送/选择 · Ctrl+Enter带入/选中并关闭 · Esc取消`,noMatchResult:`暂无匹配结果`,requestFailed:`❌ 请求失败:{message}`,emptyPromptHint:`暂无提示词,请添加`,menuDisplayTitle:`菜单显示`,codeAndContentRequired:`请填写编码和内容`,codeExists:`编码已存在`,saveChanges:`保存修改`,confirmDeletePrompt:`确定要删除提示词 "/{code}" 吗?`}}),n(`en`,{promptMgr:{promptsTabCount:`Prompts ({count})`,skillsTabCount:`Skills ({count})`,mcpTabCount:`MCP ({count})`,noMatchPrompt:`No matching prompts`,mergedHeaderHint:`Arrow keys to switch · Enter to send/select · Ctrl+Enter to insert/select & close · Esc to cancel`,noMatchResult:`No matching results`,requestFailed:`❌ Request failed: {message}`,emptyPromptHint:`No prompts yet, please add one`,menuDisplayTitle:`Show in menu`,codeAndContentRequired:`Please fill in both code and content`,codeExists:`Code already exists`,saveChanges:`Save changes`,confirmDeletePrompt:`Are you sure you want to delete prompt "/{code}"?`}});var cS=`<svg viewBox="0 0 1024 1024" width="12" height="12" fill="currentColor"><path d="M674.56 231.552l101.568 56.96-56.896-101.632 56.96-101.568-101.632 56.896-101.632-56.896 56.96 101.568-56.896 101.632 101.568-56.96zM186.944 629.76l-101.504-56.896 56.832 101.632-56.832 101.568 101.504-56.96 101.632 56.96-56.896-101.568 56.896-101.568-101.568 56.832zM85.44 85.312l56.832 101.568-56.832 101.632 101.504-56.96 101.632 56.96L231.68 186.88l56.896-101.568-101.568 56.896-101.568-56.896z m351.872 438.016l-99.2-99.136L424.32 337.984l99.072 99.264-86.08 86.144m-41.856-223.04L300.352 395.392a40.448 40.448 0 0 0 0 57.28l474.24 474.112a40.448 40.448 0 0 0 57.344 0l94.912-95.04a40.448 40.448 0 0 0 0-57.344L452.736 300.288a40.448 40.448 0 0 0-57.28 0z"/></svg>`;function lS(){a.debug(`[SidePanel] clear selectedcontenttext `),N.selectedContextText=``,N.quotedContextText=``;let e=document.getElementById(`selectionIndicator`),t=document.getElementById(`userInput`);if(e&&(e.classList.remove(`show`),a.debug(`[SidePanel] hiddenselected contentprompt`)),typeof window.hideFloatingMenu==`function`&&window.hideFloatingMenu(),t&&t.value.startsWith(`[选中内容]`)){let e=t.value.split(`
|
|
1934
|
+
`;let n=t.querySelector(`.streaming-stop-btn`);n&&n.addEventListener(`click`,e=>{e.stopPropagation(),ax(n)}),e.appendChild(t)}}}else if(x(Xb(y)),Jb(Date.now()),Gb()&&Gb().length>0){let e=x().querySelector(`.message-content`);Gb().forEach(t=>{let n=rx(t);e.insertBefore(n,e.firstChild)}),Kb(null)}return S=``,Wb(y,``),qb(Date.now()),kb(x()),!1}if(e.type===`STREAM_CHUNK`)return x()&&(S+=e.delta,Wb(y,S),x().isConnected&&Qb(x(),S)),!1;if(e.type===`STREAM_TOOL_CALL`)return x()||(x(Xb(y)),Jb(Date.now())),x()&&e.toolCalls?.length>0&&$b(x(),e.toolCalls),!1;if(e.type===`STREAM_TOOL_RESULT`)return x()&&e.result&&nx(e.result,x()),!1;if(e.type===`AGENT_STREAM`){if(x()&&e.execId){let t=E[e.execId];if(!t){let n=x();t={element:tx(e.toolCallId?n.querySelector(`.tool-call-item[data-tool-call-id="${e.toolCallId}"]`):null,n.querySelector(`.stream-content`)),stdout:``,stderr:``},E[e.execId]=t,qt()}let n=t.element.querySelector(`code`);n&&(e.streamType===`stderr`?t.stderr+=e.data:t.stdout+=e.data,n.textContent=t.stdout+(t.stderr?`
|
|
1935
|
+
`+t.stderr:``),n.parentElement.scrollTop=n.parentElement.scrollHeight)}return!1}if(e.type===`AGENT_STREAM_DONE`){if(e.execId){let t=E[e.execId];t&&e.exitCode!==0&&t.element.classList.add(`agent-stream-error`)}return!1}if(e.type===`STREAM_DONE`){if(x()){let e=x().querySelector(`.stream-status`);e&&(v?.enabled?e.textContent=r(`chatMsg.reflectionInProgress`):e.textContent=``)}return!1}if(e.type===`API_COMPLETE`){let t=e.content&&String(e.content).trim()?e.content:r(`chatMsg.emptyModelReply`);x()&&ix(x(),t,e.executionLog||[],e.reflectionScore,e.reasoningContent,e.wasRevised);let n=x(),i=!!n,a=n?n.dataset.htmlContent||n.outerHTML:null,s=n?n.isConnected:!1,c=n?n.dataset.messageId:null;return T(),console.log(`[callApi API_COMPLETE] wasStreamed:`,i,`| message.executionLog entries:`,e.executionLog?.length||0,`| local executionLog entries:`,d.length,`| agent_file entries:`,(e.executionLog||d)?.filter(e=>e.nodeType===`tool_exec`&&e.action?.name===`agent_file`).length||0),o({content:t,executionLog:e.executionLog||d,reflectionScore:e.reflectionScore,wasStreamed:i,wasRevised:e.wasRevised,streamingHtml:a,streamingConnected:s,streamingMsgId:c}),!1}else if(e.type===`API_ERROR`){let t=x();return t&&t.isConnected&&t.remove(),T(),l({message:e.error,executionLog:e.executionLog||d}),!1}return!1};if(chrome.runtime.onMessage.addListener(te),w.removeListener=()=>{chrome.runtime.onMessage.removeListener(te)},s)a.debug(`[SidePanel] send RESUME_REACT message,sessionId:`,y,`userGuidance:`,c?`"${c.substring(0,50)}..."`:`( no )`,`timeout:`,_),chrome.runtime.sendMessage({type:`RESUME_REACT`,sessionId:y,callId:b,userGuidance:c||``});else{let r=e.some(e=>Array.isArray(e.content)&&e.content.some(e=>e&&e.type===`image_url`));a.debug(`[SidePanel] send CALL_API message,useTools:`,n,`tabId:`,N.currentTabId,`sessionId:`,y,`apiParams:`,i,`timeout:`,_),chrome.runtime.sendMessage({type:`CALL_API`,sessionId:y,messages:e,model:t,useTools:n,tabId:N.currentTabId,apiParams:i,agentId:p,agentToolIds:m,agentSkillIds:h,forcedMcpServerIds:Array.isArray(u)&&u.length>0?u:null,agentMcpExcludedServerIds:g??null,callId:b,imageApiBase:N.enableImageInput&&r&&N.imageApiBase||``,imageApiKey:N.enableImageInput&&r&&N.imageApiKey||``})}})}function uS(e){try{let t=e.dataset.rawContent||``,n=e.dataset.textContent_||``;if(!n&&!t){P(r(`chatMsg.cannotGetMessageContent`),`error`);return}let i=[];if(t.startsWith(`[`))try{let e=JSON.parse(t);if(Array.isArray(e)){let t=e.filter(e=>e.type===`image_url`);for(let e of t){let t=e.image_url.original_url||e.image_url.url;i.push({originalUrl:t,compressedUrl:e.image_url.url,width:e.image_url.width,height:e.image_url.height})}}}catch{}i.length>0&&(N.attachedImages=i,uf());let o=[];if(e.dataset.attachedFiles)try{let t=JSON.parse(e.dataset.attachedFiles);for(let e of t)o.push({name:e.name,size:e.size,type:e.type,text:e.text||``,status:e.status||`done`,agentPath:e.agentPath||``})}catch{}o.length>0&&(N.attachedFiles=o,M(()=>Promise.resolve().then(()=>Mf).then(e=>{e.renderFilePreviews()}),void 0));let s=n.match(/^\[网页上下文\]\n标题: (.+)\nURL: (.+)\ntabId: (\d+)\n/);if(s){vy(),N.selectedPage={id:parseInt(s[3]),title:s[1],url:s[2],favIconUrl:``};let e=document.getElementById(`pageIndicator`),t=document.getElementById(`pageIndicatorName`);if(e&&t){let n=s[1],r=s[2];n&&n!==`无标题`&&r?t.textContent=`${n} · ${r}`:t.textContent=n||r,e.style.display=`flex`}}let c=n.match(/\[知识库检索结果\](引用: ([^)]+))/);if(c){let e=c[1].split(`、`).map(e=>e.trim()).filter(Boolean);e.length>0&&(ry(),N.knowledgeRefs=e.map(e=>({id:``,name:e})),iy(),cy().then(e=>{if(e&&e.ok){let t=new Map((e.collections||[]).map(e=>[e.name,e]));N.knowledgeRefs=N.knowledgeRefs.map(e=>{if(e.id)return e;let n=t.get(e.name);return{id:n?.id||``,name:e.name,enabled:n?n.enabled!==!1:!0}}),iy()}}).catch(()=>{}))}let l=Array.from(new Set([...n.matchAll(/\[(?:已选技能|Selected skill):\s*([^\n\]]+)\]/g)].map(e=>e[1].split(` - `)[0].trim()).filter(Boolean)));l.length>0&&(KS(),N.selectedSkills=l.map(e=>({name:e,description:``,type:`agent`})),qS());let u=Array.from(new Set([...n.matchAll(/\[(?:已选MCP服务|Selected MCP service):\s*([^\n\]]+)\]/g)].map(e=>e[1].split(` - `)[0].trim()).filter(Boolean)));u.length>0&&(aC(),N.selectedMcpServices=u.map(e=>({serverId:``,serverName:e,toolCount:0})),sC(),chrome.storage.local.get([`mcpTools`],e=>{let t=e.mcpTools||[];u.forEach(e=>{let n=N.selectedMcpServices.find(t=>t.serverName===e);if(!n||n.serverId)return;let r=t.find(t=>(t.serverName||``)===e)||t.find(t=>(t.serverName||``).startsWith(e));r&&(n.serverId=r.serverId||``,n.toolCount=t.filter(e=>e.serverId===r.serverId).length)}),sC()}));let d=n;s&&(d=d.replace(/^\[网页上下文\]\n标题: .+\nURL: .+\ntabId: \d+\n/,``)),c&&(d=d.replace(/\[知识库检索结果\][^\n]*\n[\s\S]*?\[\/知识库检索结果\]\n\n?/,``)),u.length>0&&(d=qx(d)),l.length>0&&(d=Kx(d));let f=N.quotedContextText,p=N.selectedContextText;N.quotedContextText=``,N.selectedContextText=``;let m=d.match(/^\[引用内容(?:摘要)?\]\n([\s\S]+?)\n\n\[用户问题\]\n([\s\S]*)$/),h=d.match(/^\[选中内容(?:摘要)?\]\n([\s\S]+?)\n\n\[用户问题\]\n([\s\S]*)$/),g=m||h,_=d;if(g){let e=m?`quoted`:`selected`,t=g[1].trim(),n=g[2].trim();if(o.length>0){let e=n.search(/\n\n\[(?:工作目录)?文件(?:内容)?:/);e!==-1&&(n=n.substring(0,e).trim())}let i=document.getElementById(`selectionIndicator`),a=document.getElementById(`selectionText`);if(i&&a){let n;n=t.length>100?t.substring(0,100)+`...`:t.length>50?t.substring(0,50)+`...`:t,e===`quoted`?(N.quotedContextText=t,N.selectedContextText=p,a.textContent=r(`chatMsg.quotedContextLabel`,{text:n})):(N.selectedContextText=t,N.quotedContextText=f,a.textContent=r(`chatMsg.selectedContextLabel`,{text:n})),i.classList.add(`show`)}_=n}else if(N.quotedContextText=f,N.selectedContextText=p,o.length>0){let e=_.search(/\n\n\[(?:工作目录)?文件(?:内容)?:/);e!==-1&&(_=_.substring(0,e).trim())}let v=document.getElementById(`userInput`);v.value=_,Dt(),v.focus(),v.selectionStart=v.selectionEnd=v.value.length,a.debug(`[SidePanel] loadedmessagecontent to input box,waitingafter user editsend`)}catch(e){a.error(`[SidePanel] editmessage failed:`,e),P(r(`chatMsg.editFailed`,{message:e.message}),`error`)}}n(`zh`,{promptMgr:{promptsTabCount:`提示词 ({count})`,skillsTabCount:`技能 ({count})`,mcpTabCount:`MCP ({count})`,noMatchPrompt:`暂无匹配的提示词`,mergedHeaderHint:`方向键切换 · Enter发送/选择 · Ctrl+Enter带入/选中并关闭 · Esc取消`,noMatchResult:`暂无匹配结果`,requestFailed:`❌ 请求失败:{message}`,emptyPromptHint:`暂无提示词,请添加`,menuDisplayTitle:`菜单显示`,codeAndContentRequired:`请填写编码和内容`,codeExists:`编码已存在`,saveChanges:`保存修改`,confirmDeletePrompt:`确定要删除提示词 "/{code}" 吗?`}}),n(`en`,{promptMgr:{promptsTabCount:`Prompts ({count})`,skillsTabCount:`Skills ({count})`,mcpTabCount:`MCP ({count})`,noMatchPrompt:`No matching prompts`,mergedHeaderHint:`Arrow keys to switch · Enter to send/select · Ctrl+Enter to insert/select & close · Esc to cancel`,noMatchResult:`No matching results`,requestFailed:`❌ Request failed: {message}`,emptyPromptHint:`No prompts yet, please add one`,menuDisplayTitle:`Show in menu`,codeAndContentRequired:`Please fill in both code and content`,codeExists:`Code already exists`,saveChanges:`Save changes`,confirmDeletePrompt:`Are you sure you want to delete prompt "/{code}"?`}});var dS=`<svg viewBox="0 0 1024 1024" width="12" height="12" fill="currentColor"><path d="M674.56 231.552l101.568 56.96-56.896-101.632 56.96-101.568-101.632 56.896-101.632-56.896 56.96 101.568-56.896 101.632 101.568-56.96zM186.944 629.76l-101.504-56.896 56.832 101.632-56.832 101.568 101.504-56.96 101.632 56.96-56.896-101.568 56.896-101.568-101.568 56.832zM85.44 85.312l56.832 101.568-56.832 101.632 101.504-56.96 101.632 56.96L231.68 186.88l56.896-101.568-101.568 56.896-101.568-56.896z m351.872 438.016l-99.2-99.136L424.32 337.984l99.072 99.264-86.08 86.144m-41.856-223.04L300.352 395.392a40.448 40.448 0 0 0 0 57.28l474.24 474.112a40.448 40.448 0 0 0 57.344 0l94.912-95.04a40.448 40.448 0 0 0 0-57.344L452.736 300.288a40.448 40.448 0 0 0-57.28 0z"/></svg>`;function fS(){a.debug(`[SidePanel] clear selectedcontenttext `),N.selectedContextText=``,N.quotedContextText=``;let e=document.getElementById(`selectionIndicator`),t=document.getElementById(`userInput`);if(e&&(e.classList.remove(`show`),a.debug(`[SidePanel] hiddenselected contentprompt`)),typeof window.hideFloatingMenu==`function`&&window.hideFloatingMenu(),t&&t.value.startsWith(`[选中内容]`)){let e=t.value.split(`
|
|
1929
1936
|
`),n=0;for(let t=0;t<e.length;t++)if(e[t].startsWith(`[用户问题]`)){n=t;break}n>0&&(t.value=e.slice(n).join(`
|
|
1930
|
-
`),t.dispatchEvent(new Event(`input`)),a.debug(`[SidePanel] removedinput box selected content before suffix`))}N.lastSelectedText=``,N.currentSelectionRange=null}function
|
|
1937
|
+
`),t.dispatchEvent(new Event(`input`)),a.debug(`[SidePanel] removedinput box selected content before suffix`))}N.lastSelectedText=``,N.currentSelectionRange=null}function pS(){let e=document.getElementById(`promptManageList`).querySelectorAll(`.prompt-manage-item`);e.forEach(t=>{t.addEventListener(`dragstart`,e=>{N.draggedItemIndex=parseInt(t.dataset.index),t.classList.add(`dragging`),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,N.draggedItemIndex)}),t.addEventListener(`dragend`,()=>{t.classList.remove(`dragging`),e.forEach(e=>e.classList.remove(`drag-over`)),N.draggedItemIndex=null}),t.addEventListener(`dragover`,e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,t.classList.add(`drag-over`)}),t.addEventListener(`dragleave`,()=>{t.classList.remove(`drag-over`)}),t.addEventListener(`drop`,e=>{e.stopPropagation(),e.preventDefault();let n=parseInt(t.dataset.index);if(N.draggedItemIndex!==null&&N.draggedItemIndex!==n){let e=N.customPrompts[N.draggedItemIndex];N.customPrompts.splice(N.draggedItemIndex,1),N.customPrompts.splice(n,0,e),chrome.storage.local.set({customPrompts:N.customPrompts}),ES()}t.classList.remove(`drag-over`)})})}function mS(){let e=document.querySelector(`#promptDropdown .prompt-dropdown-header`);if(!e||e.querySelector(`.prompt-manage-btn`))return;let t=document.createElement(`button`);t.className=`prompt-manage-btn`,t.title=r(`promptManager.title`),t.style.fontSize=`13px`,t.innerHTML=`✚`,t.addEventListener(`click`,e=>{e.stopPropagation(),wS()}),e.appendChild(t)}async function hS(e=``,t=null){let n=document.getElementById(`promptSelector`),r=document.getElementById(`promptDropdown`);pt(),n.style.display=`block`,r.classList.add(`show`);let i=document.getElementById(`skillsTab`),a=document.getElementById(`mcpTab`),o=i?await zS():!1,s=a?await eC():!1;if(i&&(i.style.display=o?`block`:`none`),a&&(a.style.display=s?`block`:`none`),_S(o,s),e)await bS(e);else{let n=t||N.lastActiveDropdownTab||`prompts`,r=document.querySelector(`#promptDropdownTabs .prompt-tab[data-tab="${n}"]`),i=`prompts`;if(r&&r.style.display!==`none`)i=n;else{let e=document.querySelectorAll(`#promptDropdownTabs .prompt-tab`);for(let t of e)if(t.style.display!==`none`){i=t.dataset.tab;break}}await XS(i),yS(e)}}function gS(){let e=document.getElementById(`promptSelector`),t=document.getElementById(`promptDropdown`);e.style.display=`none`,t.classList.remove(`show`),N.selectedPromptIndex=-1,N.showMergedList=!1;let n=document.getElementById(`promptDropdownTabs`);n&&n.classList.remove(`merged-mode`)}async function _S(e,t){try{let n=N.customPrompts.length,i=document.querySelector(`#promptDropdownTabs .prompt-tab[data-tab="prompts"]`);if(i&&(i.textContent=r(`promptMgr.promptsTabCount`,{count:n})),e){let e=await VS(),t=document.getElementById(`skillsTab`);t&&(t.textContent=r(`promptMgr.skillsTabCount`,{count:e.length}))}if(t){let e=await tC(),t=document.getElementById(`mcpTab`);t&&(t.textContent=r(`promptMgr.mcpTabCount`,{count:e.length}))}}catch{}}function vS(e=``){e?bS(e):yS(e)}function yS(e=``){let t=document.getElementById(`promptList`),n=e.toLowerCase(),i=N.customPrompts.filter(t=>e?t.code.toLowerCase().includes(n)||t.content.toLowerCase().includes(n):!0);if(i.length===0){t.innerHTML=`<div class="prompt-empty">${r(`promptMgr.noMatchPrompt`)}</div>`,N.selectedPromptIndex=-1;return}N.selectedPromptIndex=0,t.innerHTML=i.map((e,t)=>`
|
|
1931
1938
|
<div class="prompt-item ${t===N.selectedPromptIndex?`selected`:``}" data-index="${t}" data-code="${e.code}">
|
|
1932
1939
|
<span class="prompt-item-index">${t+1}</span>
|
|
1933
|
-
<span class="prompt-item-icon">${
|
|
1940
|
+
<span class="prompt-item-icon">${dS}</span>
|
|
1934
1941
|
<span class="prompt-item-content">${e.content}</span>
|
|
1935
1942
|
<span class="prompt-item-code">/${e.code}</span>
|
|
1936
1943
|
</div>
|
|
1937
|
-
`).join(``),t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,t=>{let n=e.dataset.code;t.ctrlKey||t.metaKey?
|
|
1944
|
+
`).join(``),t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,t=>{let n=e.dataset.code;t.ctrlKey||t.metaKey?SS(n):CS(n)})})}async function bS(e=``){let t=document.getElementById(`promptList`),n=document.getElementById(`skillList`),i=document.getElementById(`mcpList`),a=document.getElementById(`promptDropdownTabs`),o=document.querySelector(`#promptDropdownHeader .prompt-dropdown-header-text`),s=document.querySelector(`#promptDropdownHeader .prompt-manage-btn`),c=document.querySelector(`#promptDropdownHeader .skill-manage-btn`),l=document.querySelector(`#promptDropdownHeader .mcp-manage-btn`);a&&a.classList.add(`merged-mode`),n&&(n.style.display=`none`),i&&(i.style.display=`none`),t&&(t.style.display=`block`),o&&(o.textContent=r(`promptMgr.mergedHeaderHint`)),s&&(s.style.display=``),c&&(c.style.display=`none`),l&&(l.style.display=`none`),N.showMergedList=!0,N.activeDropdownTab=`prompts`;let u=e.toLowerCase(),d=N.customPrompts.filter(t=>e?t.code.toLowerCase().includes(u)||t.content.toLowerCase().includes(u):!0),f=[];await zS()&&(f=(await VS()).filter(t=>e?(t.name||``).toLowerCase().includes(u)||(t.description||``).toLowerCase().includes(u):!0));let p=[];await eC()&&(p=(await tC()).filter(t=>e?(t.serverName||``).toLowerCase().includes(u)||(t.serverId||``).toLowerCase().includes(u):!0));let m=d.length+f.length+p.length,h=document.getElementById(`promptMergedTitle`);if(h&&(h.textContent=r(`promptSelector.mergedTitleCount`,{count:m})),m===0){t.innerHTML=`<div class="prompt-empty">${r(`promptMgr.noMatchResult`)}</div>`,N.selectedPromptIndex=-1;return}N.selectedPromptIndex=0;let g=0,_=d.map(e=>{let t=`
|
|
1938
1945
|
<div class="prompt-item ${g===0?`selected`:``}" data-index="${g}" data-type="prompt" data-code="${e.code}">
|
|
1939
1946
|
<span class="prompt-item-index">${g+1}</span>
|
|
1940
1947
|
<span class="prompt-item-icon">📋</span>
|
|
@@ -1952,13 +1959,13 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1952
1959
|
<span class="prompt-item-content">🔌 ${F(e.serverName)}</span>
|
|
1953
1960
|
${t?`<span class="merged-item-badge badge-mcp-inactive">${r(`skillSelector.mcpInactiveBadge`)}</span>`:``}
|
|
1954
1961
|
<span class="merged-item-badge badge-mcp">MCP</span>
|
|
1955
|
-
</div>`;return g++,n}).join(``);t.innerHTML=_+v+y,t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,async t=>{let n=e.dataset.type;if(n===`skill`){let n=e.dataset.skillName;
|
|
1962
|
+
</div>`;return g++,n}).join(``);t.innerHTML=_+v+y,t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,async t=>{let n=e.dataset.type;if(n===`skill`){let n=e.dataset.skillName;GS(n,await VS()),(t.ctrlKey||t.metaKey)&&gS()}else if(n===`mcp`){let n=e.dataset.serverId,r=e.dataset.serverName;iC(n,r,await tC()),(t.ctrlKey||t.metaKey)&&gS()}else{let n=e.dataset.code;t.ctrlKey||t.metaKey?SS(n):CS(n)}})}),JS(),cC()}function xS(e){e.forEach((e,t)=>{t===N.selectedPromptIndex?(e.classList.add(`selected`),e.scrollIntoView({block:`nearest`})):e.classList.remove(`selected`)})}function SS(e,{skipTriggerStrip:t=!1}={}){let n=N.customPrompts.find(t=>t.code===e);if(!n)return;let r=document.getElementById(`userInput`),i=r.value,o=i.lastIndexOf(`/`),s=i;if(!t&&o!==-1){let e=-1;for(let t=o-1;t>=0;t--)if(i[t]===`
|
|
1956
1963
|
`){e=t;break}s=e===-1?i.substring(0,o).trimEnd():i.substring(0,e+1).trimEnd()}r.value=s+(s&&!s.endsWith(`
|
|
1957
1964
|
`)?`
|
|
1958
1965
|
|
|
1959
|
-
`:``)+n.content,r.focus(),r.selectionStart=r.selectionEnd=r.value.length,
|
|
1966
|
+
`:``)+n.content,r.focus(),r.selectionStart=r.selectionEnd=r.value.length,gS(),Dt(),a.debug(`[SidePanel] trackaddpromptword to input box:`,n.code,n.content)}async function CS(e){let t=N.customPrompts.find(t=>t.code===e);if(!t)return;if(N.isGenerating){a.debug(`[SidePanel] generating,please wait...`);return}let n=document.getElementById(`userInput`)?.value||``,i={quotedContextText:N.quotedContextText||``,selectedContextText:N.selectedContextText||``,selectedSkills:N.selectedSkills.slice(),selectedMcpServices:N.selectedMcpServices.slice(),knowledgeRefs:N.knowledgeRefs.slice(),selectedPage:N.selectedPage,attachedImages:N.attachedImages.slice(),attachedFiles:N.attachedFiles.slice()};await ac({state:N,getRatio:()=>cw().usage?.ratio??0,compact:_w}),gS();let o=document.getElementById(`chatContainer`).querySelector(`.welcome-message`);o&&o.remove();let s=t.content,c=i.selectedContextText&&i.selectedContextText.trim(),l=i.quotedContextText&&i.quotedContextText.trim(),u=[];if(l){let e=i.quotedContextText.trim(),{compressed:n,wasCompressed:r}=O(e);s=`[引用内容${r?`摘要`:``}]\n${n}\n\n[用户问题]\n${t.content}`,Gx(`quoted`,e,!1),u.push({type:`quoted`,text:e}),N.quotedContextText===i.quotedContextText&&(N.quotedContextText=``)}else if(c){let e=i.selectedContextText.trim(),{compressed:n,wasCompressed:r}=O(e);s=`[选中内容${r?`摘要`:``}]\n${n}\n\n[用户问题]\n${t.content}`,Gx(`selected`,e,!1),u.push({type:`selected`,text:e}),N.selectedContextText===i.selectedContextText&&(N.selectedContextText=``)}let d=i.selectedSkills,f=await $S(d);if(f){s=f+s;for(let e of d)Gx(`skill`,r(`contextBubble.bubbleSkill`,{name:e.name,desc:e.description?`:`+e.description:``}),!1),u.push({type:`skill`,name:e.name,description:e.description||``});let e=new Set(d),t=N.selectedSkills.filter(t=>!e.has(t));t.length!==N.selectedSkills.length&&(N.selectedSkills=t,N.selectedSkillIndex=-1,qS(),JS())}let p=null,m=i.selectedMcpServices,h=oC(m);if(h){let e=m.map(e=>e.serverId).filter(Boolean);p=e.length>0?e:null,s=h+s;for(let e of m)Gx(`mcp`,r(`contextBubble.bubbleMcp`,{name:e.serverName}),!1),u.push({type:`mcp`,serverName:e.serverName,serverId:e.serverId||``});let t=new Set(m),n=N.selectedMcpServices.filter(e=>!t.has(e));n.length!==N.selectedMcpServices.length&&(N.selectedMcpServices=n,N.selectedMcpServiceIndex=-1,sC(),cC())}let _=i.knowledgeRefs;if(_.length>0){let e=Gx(`knowledge`,r(`contextBubble.bubbleKnowledgeSearching`),!1),n=null;try{n=await Tx(t.content,_)}catch(e){a.warn(`[SidePanel] knowledge search failed:`,e)}e&&e.parentNode&&e.remove(),n&&(s=n.text+s,Ex(n.refs,n.failed===!0),u.push({type:`knowledge`,refs:n.refs,failed:n.failed||void 0}));let i=new Set(_),o=N.knowledgeRefs.filter(e=>!i.has(e));o.length!==N.knowledgeRefs.length&&(N.knowledgeRefs=o,ey(),iy())}let v=i.selectedPage;v&&(s=`[网页上下文]\n标题: ${v.title}\nURL: ${v.url}\ntabId: ${v.id}\n`+s,Gx(`page`,r(`contextBubble.bubblePage`,{title:v.title,url:v.url}),!1),u.push({type:`page`,title:v.title,url:v.url}),N.selectedPage===v&&vy()),(c||l)&&(!N.quotedContextText&&!N.selectedContextText?fS():fx());let y=i.attachedFiles;if(y.length>0){let e=ep(y);e&&(s+=e);try{await ne(N.activeSessionId,y)}catch(e){a.warn(`[Prompt] save doc image snapshot failed:`,e.message)}y.forEach(e=>{e.status===`done`&&u.push({type:`file`,name:e.name,size:e.size,fileType:e.type})})}let b=i.attachedImages,x=df(s,b),{messageId:S,timestamp:C}=Jx(`user`,df(t.content,b),!0,[],null,!1,s,null,y);N.messageHistory.push({role:`user`,content:x,messageId:S,timestamp:C,contextBubbles:u}),yx(),Pn(t.content);let w=document.getElementById(`userInput`);w.value===n&&(w.value=``,w.style.height=`auto`),N.isGenerating=!0;let T=eS(),E=N.activeSessionId,D=N.enableImageInput&&b.length>0&&N.imageModelName||N.currentModel;if(b.length>0){let e=new Set(b),t=N.attachedImages.filter(t=>!e.has(t));t.length!==N.attachedImages.length&&(N.attachedImages=t,uf())}if(y.length>0){let e=new Set(y),t=N.attachedFiles.filter(t=>!e.has(t));if(t.length!==N.attachedFiles.length){for(let t of N.attachedFiles)e.has(t)&&t.dataUrl&&URL.revokeObjectURL(t.dataUrl);N.attachedFiles=t,$f()}}try{await Tt(),a.debug(`[SidePanel] sendmessagedebuginfo:`),a.debug(` - isolateChat:`,N.isolateChat),a.debug(` - chatConfig:`,N.chatConfig),a.debug(` - messageHistory.length:`,N.messageHistory.length);let e=[{role:`system`,content:await kt(null,{sessionId:E})}];if(N.isolateChat){let t=g(D,N.enabledTools.length||50,0,N.customModelMap),n=Math.floor(t*.7),r=N.messageHistory[N.messageHistory.length-1],i=kn(N.messageHistory.slice(0,-1),{isolateChat:!0,maxMemoryMessages:N.chatConfig.maxMemoryMessages,compaction:N.activeCompaction,historyBudget:n,currentMessage:r});jn(e,i,N.activeCompaction,a),i.historySummaryText&&(e[0]={...e[0],content:e[0].content+`
|
|
1960
1967
|
|
|
1961
|
-
`+i.historySummaryText}),e=[...e,...i.messages];for(let t=0;t<e.length-1;t++)e[t]={...e[t],content:ff(e[t].content)}}else e.push({role:`user`,content:x});let n=await bt(),i,o,s=!1,c=null,l=null;try{let t=await
|
|
1968
|
+
`+i.historySummaryText}),e=[...e,...i.messages];for(let t=0;t<e.length-1;t++)e[t]={...e[t],content:ff(e[t].content)}}else e.push({role:`user`,content:x});let n=await bt(),i,o,s=!1,c=null,l=null;try{let t=await lS(e,D,N.useTools,n,{forcedMcpServerIds:p});i=t.content,o=t.executionLog||[],s=t.wasStreamed||!1,c=t.streamingHtml||null,t.streamingConnected!==void 0&&t.streamingConnected,l=t.streamingMsgId||null}catch(e){tS(T),i=r(`promptMgr.requestFailed`,{message:e.message||r(`agentConfig.unknownError`)}),o=e.executionLog||[];let{element:n,messageId:a}=Jx(`assistant`,i,!0,o);throw N.messageHistory.push({role:`assistant`,content:i,executionLog:o,messageId:a}),yx(),e.message!==r(`chatMsg.errTaskStopped`)&&Lc(E,i,t.content),e}let u=null;if(!s||!c)if(tS(T),s)u=l;else{let{element:e,messageId:t}=Jx(`assistant`,i,!0,o);u=t,await Jt(e)}else u=l;N.messageHistory.push({role:`assistant`,content:i,executionLog:o,messageId:u}),yx(),Ic(E,t.content)}catch{}finally{Bc(E),w.focus()}}function wS(){document.getElementById(`promptManageModal`).classList.add(`show`),ES()}function TS(){document.getElementById(`promptManageModal`).classList.remove(`show`);let e=document.getElementById(`editPromptIndex`),t=document.getElementById(`newPromptCode`),n=document.getElementById(`newPromptContent`),i=document.getElementById(`promptManageAddBtn`);e&&(e.value=``),t&&(t.value=``),n&&(n.value=``),i&&(i.textContent=r(`promptManager.addPrompt`),i.style.background=`var(--brand-500)`)}function ES(){let e=document.getElementById(`promptManageList`);if(N.customPrompts.length===0){e.innerHTML=`<div class="prompt-empty">${r(`promptMgr.emptyPromptHint`)}</div>`;return}e.innerHTML=N.customPrompts.map((e,t)=>`
|
|
1962
1969
|
<div class="prompt-manage-item" draggable="true" data-index="${t}">
|
|
1963
1970
|
<div class="prompt-manage-item-left">
|
|
1964
1971
|
<span class="prompt-drag-handle" title="${r(`toolbar.dragSort`)}">⋮⋮</span>
|
|
@@ -1986,7 +1993,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1986
1993
|
</button>
|
|
1987
1994
|
</div>
|
|
1988
1995
|
</div>
|
|
1989
|
-
`).join(``),e.querySelectorAll(`.move-up-btn`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let n=parseInt(e.dataset.index);if(n>0){let e=N.customPrompts[n];N.customPrompts[n]=N.customPrompts[n-1],N.customPrompts[n-1]=e,chrome.storage.local.set({customPrompts:N.customPrompts}),
|
|
1996
|
+
`).join(``),e.querySelectorAll(`.move-up-btn`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let n=parseInt(e.dataset.index);if(n>0){let e=N.customPrompts[n];N.customPrompts[n]=N.customPrompts[n-1],N.customPrompts[n-1]=e,chrome.storage.local.set({customPrompts:N.customPrompts}),ES()}})}),e.querySelectorAll(`.move-down-btn`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let n=parseInt(e.dataset.index);if(n<N.customPrompts.length-1){let e=N.customPrompts[n];N.customPrompts[n]=N.customPrompts[n+1],N.customPrompts[n+1]=e,chrome.storage.local.set({customPrompts:N.customPrompts}),ES()}})}),e.querySelectorAll(`.menu-toggle-btn`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let n=parseInt(e.dataset.index);N.customPrompts[n].enabledInMenu=!N.customPrompts[n].enabledInMenu,chrome.storage.local.set({customPrompts:N.customPrompts}),ES()})}),e.querySelectorAll(`.edit-btn`).forEach(e=>{e.addEventListener(`click`,()=>{AS(parseInt(e.dataset.index))})}),e.querySelectorAll(`.delete-btn`).forEach(e=>{e.addEventListener(`click`,()=>{jS(parseInt(e.dataset.index))})}),pS()}function DS(e){let t=document.getElementById(`promptErrorModal`),n=document.getElementById(`promptErrorMessage`);n.textContent=e,t.classList.add(`show`)}function OS(){document.getElementById(`promptErrorModal`).classList.remove(`show`)}function kS(){let e=document.getElementById(`editPromptIndex`),t=document.getElementById(`newPromptCode`),n=document.getElementById(`newPromptContent`),i=t.value.trim(),a=n.value.trim();if(!i||!a){DS(r(`promptMgr.codeAndContentRequired`));return}let o=e?parseInt(e.value):-1,s=N.customPrompts.findIndex(e=>e.code===i);if(s!==-1&&s!==o){DS(r(`promptMgr.codeExists`));return}o>=0&&o<N.customPrompts.length?N.customPrompts[o]={...N.customPrompts[o],code:i,content:a}:N.customPrompts.push({code:i,content:a,enabledInMenu:!1}),chrome.storage.local.set({customPrompts:N.customPrompts}),t.value=``,n.value=``,e&&(e.value=``);let c=document.getElementById(`promptManageAddBtn`);c.textContent=r(`promptManager.addPrompt`),c.style.background=`var(--brand-500)`,ES()}function AS(e){let t=N.customPrompts[e];if(!t)return;let n=document.getElementById(`editPromptIndex`),i=document.getElementById(`newPromptCode`),a=document.getElementById(`newPromptContent`),o=document.getElementById(`promptManageAddBtn`);n&&(n.value=e),i.value=t.code,a.value=t.content,o.textContent=r(`promptMgr.saveChanges`),o.style.background=`var(--warning-500)`,i.scrollIntoView({behavior:`smooth`})}function jS(e){let t=N.customPrompts[e];if(!t)return;N.pendingDeleteIndex=e;let n=document.getElementById(`deleteConfirmModal`),i=document.getElementById(`deleteConfirmMessage`);i.textContent=r(`promptMgr.confirmDeletePrompt`,{code:t.code}),n.classList.add(`show`)}function MS(){document.getElementById(`deleteConfirmModal`).classList.remove(`show`),N.pendingDeleteIndex=-1}function NS(e){N.customPrompts.splice(e,1),chrome.storage.local.set({customPrompts:N.customPrompts}),ES()}function PS(){let e=document.getElementById(`promptManageCancelBtn`),t=document.getElementById(`promptManageAddBtn`),n=document.getElementById(`promptModalCloseBtn`);e&&e.addEventListener(`click`,TS),t&&t.addEventListener(`click`,kS),n&&n.addEventListener(`click`,TS);let r=document.getElementById(`deleteCancelBtn`),i=document.getElementById(`deleteConfirmBtn`);r&&r.addEventListener(`click`,MS),i&&i.addEventListener(`click`,()=>{N.pendingDeleteIndex>=0&&NS(N.pendingDeleteIndex),MS()});let a=document.getElementById(`deleteConfirmModal`);a&&a.addEventListener(`click`,e=>{e.target===a&&MS()});let o=document.getElementById(`promptErrorConfirmBtn`);o&&o.addEventListener(`click`,OS);let s=document.getElementById(`promptErrorModal`);s&&s.addEventListener(`click`,e=>{e.target===s&&OS()});let c=document.getElementById(`promptDropdown`);c&&c.addEventListener(`mousedown`,e=>{e.target.closest(`.prompt-item, .prompt-tab, .skill-list-item, .mcp-list-item`)&&e.preventDefault()})}n(`zh`,{promptSelector:{noMatchSkill:`暂无匹配的技能`,skillManageTitle:`管理技能`,noMatchMcp:`暂无匹配的 MCP 服务`,toolCount:`{count} 个工具`,mcpManageTitle:`管理 MCP 服务`}}),n(`en`,{promptSelector:{noMatchSkill:`No matching skills`,skillManageTitle:`Manage skills`,noMatchMcp:`No matching MCP services`,toolCount:`{count} tools`,mcpManageTitle:`Manage MCP services`}}),n(`zh`,{skillSelector:{selectedSkillStart:`[已选技能: {name}`,useSkillToolsHint:`请根据上述技能说明,使用相关工具处理以下问题:
|
|
1990
1997
|
`,loadSkillHint:"请使用 `agent_skill`(action=load)加载「{name}」的完整说明,然后根据说明自主调用相关工具处理以下问题。\n",runSkillHint:"请使用 `agent_skill`(action=run)执行「{name}」技能来处理以下问题",requiredParam:`必填`,optionalParam:`可选`,callParamsPrefix:`,调用参数:`,paramItem:`({flag},{type}:{desc})`,paramJoin:`、`,sentenceEnd:`。
|
|
1991
1998
|
`,selectedMcpContext:`[已选MCP服务: {name}]
|
|
1992
1999
|
请使用「{name}」MCP服务来处理以下问题:
|
|
@@ -1994,7 +2001,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1994
2001
|
`,loadSkillHint:'Please use `agent_skill` (action=load) to load the full description of "{name}", then autonomously call relevant tools to handle the following problem.\n',runSkillHint:'Please use `agent_skill` (action=run) to execute the "{name}" skill to handle the following problem',requiredParam:`required`,optionalParam:`optional`,callParamsPrefix:`, parameters: `,paramItem:`({flag}, {type}: {desc})`,paramJoin:`, `,sentenceEnd:`.
|
|
1995
2002
|
`,selectedMcpContext:`[Selected MCP service: {name}]
|
|
1996
2003
|
Please use the "{name}" MCP service to handle the following problem:
|
|
1997
|
-
`,disabledBadge:`Disabled`,disabledTooltip:`Not enabled (won't be auto-injected into the AI prompt), but you can still select and use it manually`,mcpInactiveBadge:`Inactive`,mcpInactiveTooltip:`This service is currently inactive (closed or excluded by the current agent). Selecting it will force-enable it for this request.`,manualUseSuffix:`Manual`}});var
|
|
2004
|
+
`,disabledBadge:`Disabled`,disabledTooltip:`Not enabled (won't be auto-injected into the AI prompt), but you can still select and use it manually`,mcpInactiveBadge:`Inactive`,mcpInactiveTooltip:`This service is currently inactive (closed or excluded by the current agent). Selecting it will force-enable it for this request.`,manualUseSuffix:`Manual`}});var FS=[],IS=0,LS=3e4;async function RS(e=!1){let t=Date.now();return!e&&FS.length>0&&t-IS<LS?FS:new Promise(e=>{chrome.runtime.sendMessage({type:`GET_SKILL_LIST`},t=>{if(chrome.runtime.lastError||!t?.success){e(FS);return}FS=t.skills||[],IS=Date.now(),e(FS)})})}async function zS(){if(!N.agentPlatform?.connected||(await new Promise(e=>{chrome.storage.local.get([`skillsEnabled`],e)})).skillsEnabled===!1)return!1;try{return(await VS()).length>0}catch{return!1}}async function BS(e=!1){return(await RS(e)).filter(e=>e.enabled!==!1)}async function VS(e=!1){let t=[...await RS(e)];return t.sort((e,t)=>(e.enabled===!1)-+(t.enabled===!1)),t}async function HS(e=``){let t=document.getElementById(`skillList`);if(!t)return;let n=await VS(!0),i=e.toLowerCase(),a=n.filter(t=>e?(t.name||``).toLowerCase().includes(i)||(t.description||``).toLowerCase().includes(i):!0);if(a.length===0){t.innerHTML=`<div class="prompt-empty">${r(`promptSelector.noMatchSkill`)}</div>`,N.selectedSkillIndex=-1;return}N.selectedSkillIndex=0,t.innerHTML=a.map((e,t)=>{let n=e.type===`agent`?`Agent`:`Workflow`,i=e.description||``,a=e.enabled===!1,o=a?`${e.name}\n${r(`skillSelector.disabledTooltip`)}`:e.name;return`
|
|
1998
2005
|
<div class="skill-list-item ${t===0?`selected`:``} ${a?`skill-list-item-disabled`:``}" data-index="${t}" data-skill-name="${F(e.name)}" title="${L(o)}">
|
|
1999
2006
|
<span class="skill-list-item-index">${t+1}</span>
|
|
2000
2007
|
<span class="skill-list-item-icon">🧩</span>
|
|
@@ -2005,15 +2012,15 @@ Please use the "{name}" MCP service to handle the following problem:
|
|
|
2005
2012
|
<span class="skill-list-item-badge">${n}</span>
|
|
2006
2013
|
${a?`<span class="skill-list-item-badge badge-disabled">${r(`skillSelector.disabledBadge`)}</span>`:``}
|
|
2007
2014
|
</div>
|
|
2008
|
-
`}).join(``),t.querySelectorAll(`.skill-list-item`).forEach(e=>{e.addEventListener(`click`,t=>{let r=e.dataset.skillName;
|
|
2015
|
+
`}).join(``),t.querySelectorAll(`.skill-list-item`).forEach(e=>{e.addEventListener(`click`,t=>{let r=e.dataset.skillName;GS(r,n),(t.ctrlKey||t.metaKey)&&gS()})}),JS()}function US(e){e.forEach((e,t)=>{t===N.selectedSkillIndex?(e.classList.add(`selected`),e.scrollIntoView({block:`nearest`})):e.classList.remove(`selected`)})}function WS(){let e=document.getElementById(`userInput`);if(!e)return;let t=e.value,n=t.lastIndexOf(`/`);n!==-1&&(e.value=t.substring(0,n)),e.focus(),e.selectionStart=e.selectionEnd=e.value.length,Dt()}function GS(e,t,{clearTrigger:n=!0}={}){let r=t.find(t=>t.name===e);if(!r)return;let i=N.selectedSkills.findIndex(t=>t.name===e);if(i>=0?N.selectedSkills.splice(i,1):N.selectedSkills.push({name:r.name,description:r.description||``,type:r.type||`agent`,stepCount:r.stepCount||0,parameters:r.parameters||{},enabled:r.enabled!==!1}),JS(),qS(),n)WS();else{let e=document.getElementById(`userInput`);e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length),Dt()}a.debug(`[SidePanel] skill toggled:`,r.name,`count:`,N.selectedSkills.length)}function KS(){N.selectedSkills=[],N.selectedSkillIndex=-1,qS(),JS(),a.debug(`[SidePanel] skill clearedselect`)}function qS(){let e=document.getElementById(`skillIndicator`);if(e){if(N.selectedSkills.length===0){e.style.display=`none`,e.innerHTML=``;return}e.innerHTML=N.selectedSkills.map(e=>{let t=e.enabled===!1,n=t?`${e.name} (${r(`skillSelector.manualUseSuffix`)})`:e.name,i=t?r(`skillSelector.disabledTooltip`):e.name;return`
|
|
2009
2016
|
<span class="ref-chip skill-ref-chip${t?` skill-ref-chip-manual`:``}">
|
|
2010
2017
|
<span class="ref-chip-name" title="${L(i)}">🧩 ${F(n)}</span>
|
|
2011
2018
|
<button class="ref-chip-close" data-skill-name="${L(e.name)}" title="${r(`common.delete`)}">✕</button>
|
|
2012
2019
|
</span>
|
|
2013
|
-
`}).join(``),e.querySelectorAll(`.ref-chip-close`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),N.selectedSkills=N.selectedSkills.filter(t=>t.name!==e.dataset.skillName),
|
|
2020
|
+
`}).join(``),e.querySelectorAll(`.ref-chip-close`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),N.selectedSkills=N.selectedSkills.filter(t=>t.name!==e.dataset.skillName),qS(),JS()})}),e.style.display=`flex`}}function JS(){let e=new Set(N.selectedSkills.map(e=>e.name));document.querySelectorAll(`.skill-list-item, .merged-skill-item`).forEach(t=>{t.classList.toggle(`picked`,e.has(t.dataset.skillName))})}function YS(){let e=document.getElementById(`skillIndicatorClose`);e&&e.addEventListener(`click`,KS)}async function XS(e){N.activeDropdownTab=e,N.lastActiveDropdownTab=e,N.showMergedList=!1;let t=document.getElementById(`promptList`),n=document.getElementById(`skillList`),i=document.getElementById(`mcpList`),a=document.getElementById(`promptDropdownTabs`),o=document.querySelectorAll(`#promptDropdownTabs .prompt-tab`),s=document.querySelector(`#promptDropdownHeader .prompt-dropdown-header-text`);a&&a.classList.remove(`merged-mode`),o.forEach(t=>{t.classList.toggle(`active`,t.dataset.tab===e)}),e===`skills`?(t&&(t.style.display=`none`),n&&(n.style.display=`block`),i&&(i.style.display=`none`),s&&(s.textContent=r(`promptSelector.switchHintSelect`)),N.selectedPromptIndex=-1,N.selectedMcpServiceIndex=-1,await HS()):e===`mcp`?(t&&(t.style.display=`none`),n&&(n.style.display=`none`),i&&(i.style.display=`block`),s&&(s.textContent=r(`promptSelector.switchHintSelect`)),N.selectedPromptIndex=-1,N.selectedSkillIndex=-1,await nC()):(t&&(t.style.display=`block`),n&&(n.style.display=`none`),i&&(i.style.display=`none`),s&&(s.textContent=r(`promptSelector.switchHint`)),N.selectedSkillIndex=-1,N.selectedMcpServiceIndex=-1);let c=document.querySelector(`#promptDropdownHeader .prompt-manage-btn`),l=document.querySelector(`#promptDropdownHeader .skill-manage-btn`),u=document.querySelector(`#promptDropdownHeader .mcp-manage-btn`);c&&(c.style.display=e===`prompts`?``:`none`),l&&(l.style.display=e===`skills`?``:`none`),u&&(u.style.display=e===`mcp`?``:`none`);let d=document.getElementById(`userInput`);d&&d.focus()}function ZS(){let e=document.getElementById(`promptDropdownHeader`);if(!e||e.querySelector(`.skill-manage-btn`))return;let t=document.createElement(`button`);t.className=`skill-manage-btn`,t.title=r(`promptSelector.skillManageTitle`),t.style.display=`none`,t.style.fontSize=`13px`,t.innerHTML=`✚`,t.addEventListener(`click`,e=>{e.stopPropagation(),chrome.runtime.sendMessage({type:`OPEN_OPTIONS_PAGE`,hash:`toolbox`})}),e.appendChild(t)}function QS(){let e=document.getElementById(`promptDropdownTabs`);e&&(ZS(),uC(),e.addEventListener(`click`,e=>{let t=e.target.closest(`.prompt-tab`);if(!t)return;let n=t.dataset.tab;n!==N.activeDropdownTab&&XS(n)}))}async function $S(e){let t=e||N.selectedSkills||[];if(t.length===0)return``;let n=[];for(let e of t){let t=e.type===`agent`,i=r(`skillSelector.selectedSkillStart`,{name:e.name});if(e.description&&(i+=` - ${e.description}`),i+=`]
|
|
2014
2021
|
`,t)try{let t=await new Promise(t=>{chrome.runtime.sendMessage({type:`GET_AGENT_SKILL_PROMPT`,name:e.name},e=>{if(chrome.runtime.lastError||!e?.success){t(null);return}t(e)})});t&&t.prompt?i+=`${t.prompt}\n\n${r(`skillSelector.useSkillToolsHint`)}`:i+=r(`skillSelector.loadSkillHint`,{name:e.name})}catch{i+=r(`skillSelector.loadSkillHint`,{name:e.name})}else{i+=r(`skillSelector.runSkillHint`,{name:e.name});let t=e.parameters;if(t&&t.properties&&Object.keys(t.properties).length>0){let e=t.required||[],n=Object.entries(t.properties).map(([t,n])=>r(`skillSelector.paramItem`,{flag:e.includes(t)?r(`skillSelector.requiredParam`):r(`skillSelector.optionalParam`),type:n.type||`string`,desc:n.description||``})).join(r(`skillSelector.paramJoin`));i+=r(`skillSelector.callParamsPrefix`)+n}i+=r(`skillSelector.sentenceEnd`)}n.push(i)}return n.join(`
|
|
2015
2022
|
|
|
2016
|
-
`)}async function
|
|
2023
|
+
`)}async function eC(){return!N.agentPlatform?.connected||!await new Promise(e=>{chrome.storage.local.get([`mcpEnabled`],t=>e(t.mcpEnabled))})?!1:(await tC()).length>0}async function tC(){return new Promise(e=>{chrome.storage.local.get([`mcpTools`],t=>{let n=t.mcpTools||[],r=new Set(Array.isArray(N.mcpClosedServers)?N.mcpClosedServers:[]),i=new Set(Array.isArray(N.activeAgentMcpExcludedServerIds)?N.activeAgentMcpExcludedServerIds:[]),a=new Map;n.forEach(e=>{let t=e.serverId||`unknown`;a.has(t)||a.set(t,{serverId:t,serverName:e.serverName||t,toolCount:0,effectiveOpen:!r.has(t)&&!i.has(t)}),a.get(t).toolCount++});let o=Array.from(a.values());e([...o.filter(e=>e.effectiveOpen),...o.filter(e=>!e.effectiveOpen)])})})}async function nC(e=``){let t=document.getElementById(`mcpList`);if(!t)return;let n=await tC(),i=e.toLowerCase(),a=n.filter(t=>e?(t.serverName||``).toLowerCase().includes(i)||(t.serverId||``).toLowerCase().includes(i):!0);if(a.length===0){t.innerHTML=`<div class="prompt-empty">${r(`promptSelector.noMatchMcp`)}</div>`,N.selectedMcpServiceIndex=-1;return}N.selectedMcpServiceIndex=0,t.innerHTML=a.map((e,t)=>{let n=e.effectiveOpen===!1,i=n?`${e.serverName}\n${r(`skillSelector.mcpInactiveTooltip`)}`:e.serverName;return`
|
|
2017
2024
|
<div class="mcp-list-item ${t===0?`selected`:``} ${n?`mcp-list-item-inactive`:``}" data-index="${t}" data-server-id="${F(e.serverId)}" data-server-name="${F(e.serverName)}" title="${L(i)}">
|
|
2018
2025
|
<span class="mcp-list-item-index">${t+1}</span>
|
|
2019
2026
|
<span class="mcp-list-item-icon">🔌</span>
|
|
@@ -2024,20 +2031,20 @@ Please use the "{name}" MCP service to handle the following problem:
|
|
|
2024
2031
|
${n?`<span class="mcp-list-item-badge mcp-badge-inactive">${r(`skillSelector.mcpInactiveBadge`)}</span>`:``}
|
|
2025
2032
|
<span class="mcp-list-item-badge">${r(`promptSelector.toolCount`,{count:e.toolCount})}</span>
|
|
2026
2033
|
</div>
|
|
2027
|
-
`}).join(``),t.querySelectorAll(`.mcp-list-item`).forEach(e=>{e.addEventListener(`click`,t=>{let r=e.dataset.serverId,i=e.dataset.serverName;
|
|
2028
|
-
`)}function
|
|
2034
|
+
`}).join(``),t.querySelectorAll(`.mcp-list-item`).forEach(e=>{e.addEventListener(`click`,t=>{let r=e.dataset.serverId,i=e.dataset.serverName;iC(r,i,n),(t.ctrlKey||t.metaKey)&&gS()})}),cC()}function rC(e){e.forEach((e,t)=>{t===N.selectedMcpServiceIndex?(e.classList.add(`selected`),e.scrollIntoView({block:`nearest`})):e.classList.remove(`selected`)})}function iC(e,t,n,{clearTrigger:r=!0}={}){let i=n?.find(t=>t.serverId===e)?.toolCount||0,o=t||e,s=N.selectedMcpServices.findIndex(e=>e.serverName===o);if(s>=0?N.selectedMcpServices.splice(s,1):N.selectedMcpServices.push({serverId:e,serverName:o,toolCount:i}),cC(),sC(),r)WS();else{let e=document.getElementById(`userInput`);e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length),Dt()}a.debug(`[SidePanel] MCP service toggled:`,o,`count:`,N.selectedMcpServices.length)}function aC(){N.selectedMcpServices=[],N.selectedMcpServiceIndex=-1,sC(),cC(),a.debug(`[SidePanel] cleared MCP serviceselect`)}function oC(e){let t=e||N.selectedMcpServices||[];return t.length===0?``:t.map(e=>r(`skillSelector.selectedMcpContext`,{name:e.serverName})).join(`
|
|
2035
|
+
`)}function sC(){let e=document.getElementById(`mcpIndicator`);if(e){if(N.selectedMcpServices.length===0){e.style.display=`none`,e.innerHTML=``;return}e.innerHTML=N.selectedMcpServices.map(e=>`
|
|
2029
2036
|
<span class="ref-chip mcp-ref-chip">
|
|
2030
2037
|
<span class="ref-chip-name" title="${L(e.serverName)}">🔌 ${F(e.serverName)}</span>
|
|
2031
2038
|
<button class="ref-chip-close" data-server-name="${L(e.serverName)}" title="${r(`common.delete`)}">✕</button>
|
|
2032
2039
|
</span>
|
|
2033
|
-
`).join(``),e.querySelectorAll(`.ref-chip-close`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),N.selectedMcpServices=N.selectedMcpServices.filter(t=>t.serverName!==e.dataset.serverName),iC(),aC()})}),e.style.display=`flex`}}function aC(){let e=new Set(N.selectedMcpServices.map(e=>e.serverName));document.querySelectorAll(`.mcp-list-item, .merged-mcp-item`).forEach(t=>{t.classList.toggle(`picked`,e.has(t.dataset.serverName))})}function oC(){let e=document.getElementById(`mcpIndicatorClose`);e&&e.addEventListener(`click`,nC)}function sC(){let e=document.getElementById(`promptDropdownHeader`);if(!e||e.querySelector(`.mcp-manage-btn`))return;let t=document.createElement(`button`);t.className=`mcp-manage-btn`,t.title=r(`promptSelector.mcpManageTitle`),t.style.display=`none`,t.style.fontSize=`13px`,t.innerHTML=`✚`,t.addEventListener(`click`,e=>{e.stopPropagation(),chrome.runtime.sendMessage({type:`OPEN_OPTIONS_PAGE`,hash:`toolbox`})}),e.appendChild(t)}var cC=[[`🀄`,`mahjong tile red dragon`,`symbols`,`麻将,红中`],[`🃏`,`playing card black joker`,`symbols`,``],[`🅰`,`negative squared latin capital letter a`,`symbols`,``],[`🅱`,`negative squared latin capital letter b`,`symbols`,``],[`🅾`,`negative squared latin capital letter o`,`symbols`,``],[`🅿`,`negative squared latin capital letter p`,`symbols`,``],[`🆎`,`negative squared ab`,`symbols`,``],[`🆑`,`squared cl`,`symbols`,``],[`🆒`,`squared cool`,`symbols`,``],[`🆓`,`squared free`,`symbols`,``],[`🆔`,`squared id`,`symbols`,``],[`🆕`,`squared new`,`symbols`,``],[`🆖`,`squared ng`,`symbols`,``],[`🆗`,`squared ok`,`symbols`,``],[`🆘`,`squared sos`,`symbols`,``],[`🆙`,`squared up with exclamation mark`,`symbols`,``],[`🆚`,`squared vs`,`symbols`,``],[`🇨🇩`,`regional indicator symbol letter c`,`flags`,``],[`🇬🇭`,`regional indicator symbol letter g`,`flags`,``],[`🇲🇳`,`regional indicator symbol letter m`,`flags`,``],[`🇷🇸`,`regional indicator symbol letter r`,`flags`,``],[`🈁`,`squared katakana koko`,`symbols`,``],[`🈂`,`squared katakana sa`,`symbols`,``],[`🈚`,`squared cjk unified ideograph-7121`,`symbols`,``],[`🈯`,`squared cjk unified ideograph-6307`,`symbols`,``],[`🈲`,`squared cjk unified ideograph-7981`,`symbols`,``],[`🈳`,`squared cjk unified ideograph-7a7a`,`symbols`,``],[`🈴`,`squared cjk unified ideograph-5408`,`symbols`,``],[`🈵`,`squared cjk unified ideograph-6e80`,`symbols`,``],[`🈶`,`squared cjk unified ideograph-6709`,`symbols`,``],[`🈷`,`squared cjk unified ideograph-6708`,`symbols`,``],[`🈸`,`squared cjk unified ideograph-7533`,`symbols`,``],[`🈹`,`squared cjk unified ideograph-5272`,`symbols`,``],[`🈺`,`squared cjk unified ideograph-55b6`,`symbols`,``],[`🉐`,`circled ideograph advantage`,`symbols`,``],[`🉑`,`circled ideograph accept`,`symbols`,``],[`🌀`,`cyclone`,`symbols`,`台风,龙卷风,旋风`],[`🌁`,`foggy`,`symbols`,`雾,雾霾,朦胧`],[`🌂`,`closed umbrella`,`symbols`,``],[`🌃`,`night with stars`,`symbols`,`夜晚,星空,城市`],[`🌄`,`sunrise over mountains`,`symbols`,`日出,山,早晨`],[`🌅`,`sunrise`,`symbols`,`日出,太阳,早晨`],[`🌆`,`cityscape at dusk`,`symbols`,`黄昏,傍晚,城市`],[`🌇`,`sunset over buildings`,`symbols`,`日落,黄昏`],[`🌈`,`rainbow`,`symbols`,`彩虹,雨后`],[`🌉`,`bridge at night`,`symbols`,`桥,大桥`],[`🌊`,`water wave`,`symbols`,`海浪,波浪,海`],[`🌋`,`volcano`,`symbols`,`火山,爆发`],[`🌌`,`milky way`,`symbols`,``],[`🌍`,`earth globe europe-africa`,`symbols`,``],[`🌎`,`earth globe americas`,`symbols`,`地球,美洲`],[`🌏`,`earth globe asia-australia`,`symbols`,`地球,亚洲`],[`🌐`,`globe with meridians`,`symbols`,``],[`🌑`,`new moon symbol`,`symbols`,``],[`🌒`,`waxing crescent moon symbol`,`symbols`,``],[`🌓`,`first quarter moon symbol`,`symbols`,``],[`🌔`,`waxing gibbous moon symbol`,`symbols`,``],[`🌕`,`full moon symbol`,`symbols`,``],[`🌖`,`waning gibbous moon symbol`,`symbols`,``],[`🌗`,`last quarter moon symbol`,`symbols`,``],[`🌘`,`waning crescent moon symbol`,`symbols`,``],[`🌙`,`crescent moon`,`symbols`,``],[`🌚`,`new moon with face`,`symbols`,``],[`🌛`,`first quarter moon with face`,`symbols`,``],[`🌜`,`last quarter moon with face`,`symbols`,``],[`🌝`,`full moon with face`,`symbols`,``],[`🌞`,`sun with face`,`symbols`,``],[`🌟`,`glowing star`,`symbols`,`星星,闪光,闪耀`],[`🌠`,`shooting star`,`symbols`,``],[`🌡`,`thermometer`,`symbols`,``],[`🌤`,`white sun with small cloud`,`symbols`,``],[`🌥`,`white sun behind cloud`,`symbols`,``],[`🌦`,`white sun behind cloud with rain`,`symbols`,``],[`🌧`,`cloud with rain`,`symbols`,``],[`🌨`,`cloud with snow`,`symbols`,``],[`🌩`,`cloud with lightning`,`symbols`,``],[`🌪`,`cloud with tornado`,`symbols`,``],[`🌫`,`fog`,`symbols`,``],[`🌬`,`wind blowing face`,`symbols`,``],[`🌭`,`hot dog`,`food`,`热狗`],[`🌮`,`taco`,`food`,`墨西哥卷饼`],[`🌯`,`burrito`,`food`,`墨西哥卷,卷饼`],[`🌰`,`chestnut`,`food`,`栗子,坚果`],[`🌱`,`seedling`,`food`,``],[`🌲`,`evergreen tree`,`food`,`松树,树`],[`🌳`,`deciduous tree`,`food`,`树,大树`],[`🌴`,`palm tree`,`food`,`棕榈树,热带,度假`],[`🌵`,`cactus`,`food`,`仙人掌,沙漠`],[`🌶`,`hot pepper`,`food`,``],[`🌷`,`tulip`,`food`,`郁金香,花`],[`🌸`,`cherry blossom`,`food`,`樱花,花,春天`],[`🌹`,`rose`,`food`,`玫瑰,花,爱情`],[`🌺`,`hibiscus`,`food`,`花,芙蓉`],[`🌻`,`sunflower`,`food`,`向日葵,花,太阳`],[`🌼`,`blossom`,`food`,`雏菊,花`],[`🌽`,`ear of maize`,`food`,`玉米`],[`🌾`,`ear of rice`,`food`,``],[`🌿`,`herb`,`food`,`草,植物,草药`],[`🍀`,`four leaf clover`,`food`,`四叶草,幸运,好运`],[`🍁`,`maple leaf`,`food`,`枫叶,秋天,红叶`],[`🍂`,`fallen leaf`,`food`,`落叶,秋天`],[`🍃`,`leaf fluttering in wind`,`food`,`树叶,风`],[`🍄`,`mushroom`,`food`,`蘑菇,菌`],[`🍅`,`tomato`,`food`,`番茄,西红柿`],[`🍆`,`aubergine`,`food`,`茄子`],[`🍇`,`grapes`,`food`,`葡萄`],[`🍈`,`melon`,`food`,`哈密瓜,甜瓜`],[`🍉`,`watermelon`,`food`,`西瓜`],[`🍊`,`tangerine`,`food`,`橙子,橘子`],[`🍋`,`lemon`,`food`,`柠檬`],[`🍌`,`banana`,`food`,`香蕉`],[`🍍`,`pineapple`,`food`,`菠萝`],[`🍎`,`red apple`,`food`,`苹果`],[`🍏`,`green apple`,`food`,``],[`🍐`,`pear`,`food`,`梨`],[`🍑`,`peach`,`food`,`桃子,蜜桃`],[`🍒`,`cherries`,`food`,`樱桃,车厘子`],[`🍓`,`strawberry`,`food`,`草莓`],[`🍔`,`hamburger`,`food`,`汉堡,汉堡包`],[`🍕`,`slice of pizza`,`food`,`披萨,比萨`],[`🍖`,`meat on bone`,`food`,`骨头,肉,排骨`],[`🍗`,`poultry leg`,`food`,`鸡腿,炸鸡`],[`🍘`,`rice cracker`,`food`,`米饼,仙贝`],[`🍙`,`rice ball`,`food`,`饭团`],[`🍚`,`cooked rice`,`food`,`米饭,饭`],[`🍛`,`curry and rice`,`food`,`咖喱,咖喱饭`],[`🍜`,`steaming bowl`,`food`,`面条,拉面,面`],[`🍝`,`spaghetti`,`food`,`意大利面,意面`],[`🍞`,`bread`,`food`,`面包`],[`🍟`,`french fries`,`food`,`薯条,炸薯条`],[`🍠`,`roasted sweet potato`,`food`,`红薯,地瓜`],[`🍡`,`dango`,`food`,`团子,丸子`],[`🍢`,`oden`,`food`,`关东煮,串`],[`🍣`,`sushi`,`food`,`寿司,三文鱼`],[`🍤`,`fried shrimp`,`food`,`炸虾,天妇罗`],[`🍥`,`fish cake with swirl design`,`food`,`鱼板,鸣门卷`],[`🍦`,`soft ice cream`,`food`,`冰淇淋,甜筒`],[`🍧`,`shaved ice`,`food`,`刨冰,冰沙`],[`🍨`,`ice cream`,`food`,`冰淇淋,圣代`],[`🍩`,`doughnut`,`food`,``],[`🍪`,`cookie`,`food`,``],[`🍫`,`chocolate bar`,`food`,`巧克力`],[`🍬`,`candy`,`food`,`糖果,糖`],[`🍭`,`lollipop`,`food`,`棒棒糖`],[`🍮`,`custard`,`food`,`布丁,焦糖`],[`🍯`,`honey pot`,`food`,`蜂蜜,蜜`],[`🍰`,`shortcake`,`food`,`蛋糕,奶油蛋糕`],[`🍱`,`bento box`,`food`,`便当,盒饭`],[`🍲`,`pot of food`,`food`,`火锅,汤锅,炖菜`],[`🍳`,`cooking`,`food`,`煎蛋,鸡蛋`],[`🍴`,`fork and knife`,`food`,`刀叉,餐具`],[`🍵`,`teacup without handle`,`food`,`绿茶,茶,抹茶`],[`🍶`,`sake bottle and cup`,`food`,`清酒,日本酒`],[`🍷`,`wine glass`,`food`,`红酒,葡萄酒,酒`],[`🍸`,`cocktail glass`,`food`,`鸡尾酒,马提尼`],[`🍹`,`tropical drink`,`food`,`果汁,鸡尾酒`],[`🍺`,`beer mug`,`food`,`啤酒,啤酒杯`],[`🍻`,`clinking beer mugs`,`food`,`干杯,碰杯,啤酒`],[`🍼`,`baby bottle`,`food`,`奶瓶,婴儿,奶粉`],[`🍽`,`fork and knife with plate`,`food`,``],[`🍾`,`bottle with popping cork`,`food`,`香槟,起泡酒,庆祝`],[`🍿`,`popcorn`,`food`,``],[`🎀`,`ribbon`,`activity`,`蝴蝶结,礼物,装饰`],[`🎁`,`wrapped present`,`activity`,`礼物,礼盒,生日`],[`🎂`,`birthday cake`,`activity`,`生日蛋糕,生日,蛋糕`],[`🎃`,`jack-o-lantern`,`activity`,``],[`🎄`,`christmas tree`,`activity`,``],[`🎅`,`father christmas`,`activity`,`圣诞老人,圣诞,圣诞节`],[`🎆`,`fireworks`,`activity`,``],[`🎇`,`firework sparkler`,`activity`,``],[`🎈`,`balloon`,`activity`,`气球,庆祝,派对`],[`🎉`,`party popper`,`activity`,`彩带,庆祝,派对,欢呼`],[`🎊`,`confetti ball`,`activity`,`庆祝`],[`🎋`,`tanabata tree`,`activity`,``],[`🎌`,`crossed flags`,`flags`,`旗,日本,交叉旗`],[`🎍`,`pine decoration`,`activity`,``],[`🎎`,`japanese dolls`,`activity`,`人偶,日本人偶`],[`🎏`,`carp streamer`,`activity`,`鲤鱼旗,日本,端午节`],[`🎐`,`wind chime`,`activity`,`风铃,夏天`],[`🎑`,`moon viewing ceremony`,`activity`,``],[`🎒`,`school satchel`,`activity`,`书包,背包`],[`🎓`,`graduation cap`,`activity`,`学士帽,毕业,学位`],[`🎖`,`military medal`,`activity`,``],[`🎗`,`reminder ribbon`,`activity`,``],[`🎙`,`studio microphone`,`activity`,``],[`🎚`,`level slider`,`activity`,``],[`🎛`,`control knobs`,`activity`,``],[`🎞`,`film frames`,`activity`,``],[`🎟`,`admission tickets`,`activity`,``],[`🎠`,`carousel horse`,`activity`,`旋转木马,游乐园`],[`🎡`,`ferris wheel`,`activity`,`摩天轮,游乐园`],[`🎢`,`roller coaster`,`activity`,`过山车,游乐园`],[`🎣`,`fishing pole and fish`,`activity`,`钓鱼`],[`🎤`,`microphone`,`activity`,`麦克风,唱歌,K歌`],[`🎥`,`movie camera`,`activity`,`摄影机,电影,拍摄`],[`🎦`,`cinema`,`activity`,``],[`🎧`,`headphone`,`activity`,`耳机,听歌,音乐,戴`],[`🎨`,`artist palette`,`activity`,`调色板,画画,美术,艺术`],[`🎩`,`top hat`,`activity`,`礼帽,魔术帽,帽子`],[`🎪`,`circus tent`,`activity`,`马戏团`],[`🎫`,`ticket`,`activity`,`门票,票,入场券`],[`🎬`,`clapper board`,`activity`,`场记板,电影,拍戏,导演`],[`🎭`,`performing arts`,`activity`,`面具,戏剧,表演,舞台`],[`🎮`,`video game`,`activity`,`游戏机,游戏,手柄,玩`],[`🎯`,`direct hit`,`activity`,`目标`],[`🎰`,`slot machine`,`activity`,``],[`🎱`,`billiards`,`activity`,`台球`],[`🎲`,`game die`,`activity`,`骰子,赌博,游戏`],[`🎳`,`bowling`,`activity`,`保龄球,球`],[`🎴`,`flower playing cards`,`activity`,`花牌,卡牌,纸牌`],[`🎵`,`musical note`,`activity`,`音符,音乐,歌`],[`🎶`,`multiple musical notes`,`activity`,`音符,音乐,唱歌`],[`🎷`,`saxophone`,`activity`,`萨克斯,爵士,乐器`],[`🎸`,`guitar`,`activity`,`吉他,弹吉他,摇滚`],[`🎹`,`musical keyboard`,`activity`,`钢琴,键盘,弹琴`],[`🎺`,`trumpet`,`activity`,`小号,喇叭,乐器`],[`🎻`,`violin`,`activity`,`小提琴,弦乐`],[`🎼`,`musical score`,`activity`,`乐谱,音乐,谱`],[`🎽`,`running shirt with sash`,`activity`,`背心`],[`🎾`,`tennis racquet and ball`,`activity`,`网球,球`],[`🎿`,`ski and ski boot`,`activity`,`滑雪`],[`🏀`,`basketball and hoop`,`activity`,`篮球,球`],[`🏁`,`chequered flag`,`flags`,`终点,旗帜,赛车,比赛`],[`🏂`,`snowboarder`,`activity`,``],[`🏃`,`runner`,`activity`,`跑步,跑,奔跑`],[`🏄`,`surfer`,`activity`,``],[`🏅`,`sports medal`,`activity`,`奖牌,奖章,荣誉`],[`🏆`,`trophy`,`activity`,``],[`🏇`,`horse racing`,`activity`,``],[`🏈`,`american football`,`activity`,`橄榄球,美式足球`],[`🏉`,`rugby football`,`activity`,`橄榄球,英式`],[`🏊`,`swimmer`,`activity`,``],[`🏋`,`weight lifter`,`activity`,``],[`🏌`,`golfer`,`activity`,``],[`🏍`,`racing motorcycle`,`activity`,``],[`🏎`,`racing car`,`activity`,``],[`🏏`,`cricket bat and ball`,`activity`,``],[`🏐`,`volleyball`,`activity`,`排球,球`],[`🏑`,`field hockey stick and ball`,`activity`,``],[`🏒`,`ice hockey stick and puck`,`activity`,``],[`🏓`,`table tennis paddle and ball`,`activity`,`乒乓球,乒乓,球`],[`🏔`,`snow capped mountain`,`activity`,``],[`🏕`,`camping`,`activity`,``],[`🏖`,`beach with umbrella`,`activity`,``],[`🏗`,`building construction`,`activity`,``],[`🏘`,`house buildings`,`activity`,``],[`🏙`,`cityscape`,`activity`,``],[`🏚`,`derelict house building`,`activity`,``],[`🏛`,`classical building`,`activity`,``],[`🏜`,`desert`,`activity`,``],[`🏝`,`desert island`,`activity`,``],[`🏞`,`national park`,`activity`,``],[`🏟`,`stadium`,`activity`,``],[`🏠`,`house building`,`travel`,`房子,家,住宅`],[`🏡`,`house with garden`,`travel`,`房子,家,花园`],[`🏢`,`office building`,`travel`,`办公楼,大楼,写字楼`],[`🏣`,`japanese post office`,`travel`,`邮局,邮政`],[`🏤`,`european post office`,`travel`,`邮局`],[`🏥`,`hospital`,`travel`,`医院,医疗`],[`🏦`,`bank`,`travel`,`银行,金融`],[`🏧`,`automated teller machine`,`travel`,``],[`🏨`,`hotel`,`travel`,`酒店,旅馆`],[`🏩`,`love hotel`,`travel`,`爱情旅馆,酒店`],[`🏪`,`convenience store`,`travel`,`便利店,商店`],[`🏫`,`school`,`travel`,`学校,校园`],[`🏬`,`department store`,`travel`,`商场,百货,购物`],[`🏭`,`factory`,`travel`,`工厂,工业`],[`🏮`,`izakaya lantern`,`travel`,``],[`🏯`,`japanese castle`,`objects`,`城堡,日本城堡`],[`🏰`,`european castle`,`travel`,`城堡,童话`],[`🏳`,`waving white flag`,`flags`,``],[`🏴`,`waving black flag`,`flags`,`黑旗`],[`🏵`,`rosette`,`objects`,``],[`🏷`,`label`,`objects`,``],[`🏸`,`badminton racquet and shuttlecock`,`activity`,`羽毛球,球`],[`🏹`,`bow and arrow`,`activity`,`射箭,弓箭,弓`],[`🏺`,`amphora`,`activity`,`陶罐,花瓶,双耳瓶`],[`🏻`,`emoji modifier fitzpatrick type-1-2`,`symbols`,``],[`🏼`,`emoji modifier fitzpatrick type-3`,`symbols`,``],[`🏽`,`emoji modifier fitzpatrick type-4`,`symbols`,``],[`🏾`,`emoji modifier fitzpatrick type-5`,`symbols`,``],[`🏿`,`emoji modifier fitzpatrick type-6`,`symbols`,``],[`🐀`,`rat`,`animals`,`老鼠,鼠`],[`🐁`,`mouse`,`animals`,`老鼠,鼠`],[`🐂`,`ox`,`animals`,`公牛,牛`],[`🐃`,`water buffalo`,`animals`,`水牛,牛`],[`🐄`,`cow`,`animals`,`奶牛,牛`],[`🐅`,`tiger`,`animals`,``],[`🐆`,`leopard`,`animals`,``],[`🐇`,`rabbit`,`animals`,`兔子,兔`],[`🐈`,`cat`,`animals`,`猫,猫咪`],[`🐉`,`dragon`,`animals`,`龙,中国龙`],[`🐊`,`crocodile`,`animals`,`鳄鱼,短吻鳄`],[`🐋`,`whale`,`animals`,`鲸鱼`],[`🐌`,`snail`,`animals`,``],[`🐍`,`snake`,`animals`,`蛇,爬行动物`],[`🐎`,`horse`,`animals`,``],[`🐏`,`ram`,`animals`,`羊,公羊`],[`🐐`,`goat`,`animals`,`山羊,羊`],[`🐑`,`sheep`,`animals`,`羊,绵羊`],[`🐒`,`monkey`,`animals`,``],[`🐓`,`rooster`,`animals`,`公鸡,鸡`],[`🐔`,`chicken`,`animals`,`鸡,母鸡`],[`🐕`,`dog`,`animals`,`狗,小狗`],[`🐖`,`pig`,`animals`,`猪`],[`🐗`,`boar`,`animals`,`野猪,猪`],[`🐘`,`elephant`,`animals`,`大象`],[`🐙`,`octopus`,`animals`,`章鱼,八爪鱼`],[`🐚`,`spiral shell`,`animals`,``],[`🐛`,`bug`,`animals`,``],[`🐜`,`ant`,`animals`,``],[`🐝`,`honeybee`,`animals`,``],[`🐞`,`lady beetle`,`animals`,``],[`🐟`,`fish`,`animals`,`鱼,鱼`],[`🐠`,`tropical fish`,`animals`,`热带鱼,鱼`],[`🐡`,`blowfish`,`animals`,`河豚,鱼`],[`🐢`,`turtle`,`animals`,`乌龟,慢`],[`🐣`,`hatching chick`,`animals`,`小鸡,破壳,孵化`],[`🐤`,`baby chick`,`animals`,`小鸡,黄,可爱`],[`🐥`,`front-facing baby chick`,`animals`,`小鸡,正面`],[`🐦`,`bird`,`animals`,`鸟`],[`🐧`,`penguin`,`animals`,`企鹅,南极`],[`🐨`,`koala`,`animals`,`考拉,无尾熊`],[`🐩`,`poodle`,`animals`,`贵宾犬,狗`],[`🐪`,`dromedary camel`,`animals`,`骆驼`],[`🐫`,`bactrian camel`,`animals`,`骆驼,双峰`],[`🐬`,`dolphin`,`animals`,`海豚,海洋`],[`🐭`,`mouse face`,`animals`,`老鼠,鼠`],[`🐮`,`cow face`,`animals`,`牛,奶牛`],[`🐯`,`tiger face`,`animals`,``],[`🐰`,`rabbit face`,`animals`,`兔子,兔,可爱`],[`🐱`,`cat face`,`animals`,``],[`🐲`,`dragon face`,`animals`,`龙,龙头`],[`🐳`,`spouting whale`,`animals`,`鲸鱼,喷水`],[`🐴`,`horse face`,`animals`,`马`],[`🐵`,`monkey face`,`animals`,``],[`🐶`,`dog face`,`animals`,``],[`🐷`,`pig face`,`animals`,`猪,猪头`],[`🐸`,`frog face`,`animals`,`青蛙,蛙`],[`🐹`,`hamster face`,`animals`,`仓鼠`],[`🐺`,`wolf face`,`animals`,``],[`🐻`,`bear face`,`animals`,`熊,泰迪熊`],[`🐼`,`panda face`,`animals`,``],[`🐽`,`pig nose`,`animals`,`猪鼻子,猪`],[`🐾`,`paw prints`,`animals`,`爪印,脚印`],[`🐿`,`chipmunk`,`animals`,``],[`👀`,`eyes`,`people`,``],[`👁`,`eye`,`people`,``],[`👂`,`ear`,`people`,`耳朵,听`],[`👃`,`nose`,`people`,`鼻子,闻`],[`👄`,`mouth`,`people`,`嘴巴,嘴唇,吻`],[`👅`,`tongue`,`people`,`舌头,舔`],[`👆`,`white up pointing backhand index`,`people`,`指,上面,向上`],[`👇`,`white down pointing backhand index`,`people`,`指,下面,向下`],[`👈`,`white left pointing backhand index`,`people`,`指,左边,指向`],[`👉`,`white right pointing backhand index`,`people`,`指,右边,指向`],[`👊`,`fisted hand sign`,`people`,`拳头,打,战斗`],[`👋`,`waving hand sign`,`people`,`挥手,再见,你好`],[`👌`,`ok hand sign`,`people`,`OK,好,可以`],[`👍`,`thumbs up sign`,`people`,`点赞,好,赞,棒`],[`👎`,`thumbs down sign`,`people`,`差评,不好,踩`],[`👏`,`clapping hands sign`,`people`,`鼓掌,拍手,掌声`],[`👐`,`open hands sign`,`people`,`张开,手,开放`],[`👑`,`crown`,`people`,`皇冠,王冠,国王,女王`],[`👒`,`womans hat`,`people`,`帽子,草帽,遮阳帽`],[`👓`,`eyeglasses`,`people`,`眼镜`],[`👔`,`necktie`,`people`,`领带,西装,工作`],[`👕`,`t-shirt`,`people`,`衣服,T恤`],[`👖`,`jeans`,`people`,`裤子,牛仔裤`],[`👗`,`dress`,`people`,`裙子,连衣裙`],[`👘`,`kimono`,`people`,`和服`],[`👙`,`bikini`,`people`,`比基尼,泳装`],[`👚`,`womans clothes`,`people`,`女装,衣服`],[`👛`,`purse`,`people`,`钱包,小包`],[`👜`,`handbag`,`people`,`手提包,包包`],[`👝`,`pouch`,`people`,`手拿包,包包`],[`👞`,`mans shoe`,`people`,`皮鞋,鞋`],[`👟`,`athletic shoe`,`people`,`运动鞋,跑鞋`],[`👠`,`high-heeled shoe`,`people`,`高跟鞋,鞋`],[`👡`,`womans sandal`,`people`,`凉鞋,鞋`],[`👢`,`womans boots`,`people`,`靴子,长靴`],[`👣`,`footprints`,`people`,`脚印,脚步,足迹`],[`👤`,`bust in silhouette`,`people`,`人,剪影,用户`],[`👥`,`busts in silhouette`,`people`,`人群,人,多个人`],[`👦`,`boy`,`people`,`男孩,小男孩`],[`👧`,`girl`,`people`,`女孩,小女孩`],[`👨`,`man`,`people`,`男人,男士`],[`👩`,`woman`,`people`,`女人,女士`],[`👪`,`family`,`people`,`家庭`],[`👫`,`woman and man holding hands`,`people`,``],[`👬`,`men holding hands`,`people`,``],[`👭`,`women holding hands`,`people`,``],[`👮`,`police officer`,`people`,`警察,警官`],[`👯`,`woman with bunny ears`,`people`,`兔子舞,蹦迪,派对`],[`👰`,`bride with veil`,`people`,`新娘,婚纱,结婚`],[`👱`,`person with blond hair`,`people`,``],[`👲`,`man with gua pi mao`,`people`,`中国人`],[`👳`,`man with turban`,`people`,`包头巾,印度,阿拉伯`],[`👴`,`older man`,`people`,`老人,老爷爷`],[`👵`,`older woman`,`people`,`老人,老奶奶`],[`👶`,`baby`,`people`,`婴儿,宝宝,小孩`],[`👷`,`construction worker`,`people`,`工人`],[`👸`,`princess`,`people`,`公主,女王`],[`👹`,`japanese ogre`,`people`,`妖怪,鬼,怪物`],[`👺`,`japanese goblin`,`people`,`天狗,怪物,鬼`],[`👻`,`ghost`,`people`,`幽灵,鬼,万圣节`],[`👼`,`baby angel`,`people`,`天使,婴儿,可爱`],[`👽`,`extraterrestrial alien`,`people`,`外星人,ET,飞碟`],[`👾`,`alien monster`,`people`,`外星人,怪兽,游戏`],[`👿`,`imp`,`people`,`恶魔,愤怒`],[`💀`,`skull`,`people`,`骷髅,死亡,骨头`],[`💁`,`information desk person`,`people`,``],[`💂`,`guardsman`,`people`,`卫兵,士兵`],[`💃`,`dancer`,`people`,`跳舞,舞女,跳舞`],[`💄`,`lipstick`,`people`,`口红,化妆`],[`💅`,`nail polish`,`people`,`美甲,指甲,涂`],[`💆`,`face massage`,`people`,`按摩,放松,头部`],[`💇`,`haircut`,`people`,`理发,剪发,发型`],[`💈`,`barber pole`,`people`,`理发店,理发`],[`💉`,`syringe`,`people`,`注射器,针,疫苗`],[`💊`,`pill`,`people`,`药丸,药,胶囊`],[`💋`,`kiss mark`,`people`,`吻,口红印,亲亲`],[`💌`,`love letter`,`people`,`情书,信,爱情`],[`💍`,`ring`,`people`,`戒指,钻戒,结婚`],[`💎`,`gem stone`,`people`,`钻石,宝石,珠宝`],[`💏`,`kiss`,`people`,``],[`💐`,`bouquet`,`smileys`,`花束,花,礼物`],[`💑`,`couple with heart`,`smileys`,``],[`💒`,`wedding`,`smileys`,`教堂,婚礼,教堂婚礼`],[`💓`,`beating heart`,`smileys`,`爱心,跳动,心跳`],[`💔`,`broken heart`,`smileys`,`心碎,伤心,破碎`],[`💕`,`two hearts`,`smileys`,`爱心,两个,喜欢`],[`💖`,`sparkling heart`,`smileys`,`爱心,闪光,喜欢`],[`💗`,`growing heart`,`smileys`,`爱心,跳动,喜欢`],[`💘`,`heart with arrow`,`smileys`,`爱心,箭,丘比特`],[`💙`,`blue heart`,`smileys`,``],[`💚`,`green heart`,`smileys`,``],[`💛`,`yellow heart`,`smileys`,``],[`💜`,`purple heart`,`smileys`,``],[`💝`,`heart with ribbon`,`smileys`,`爱心,礼物,蝴蝶结`],[`💞`,`revolving hearts`,`smileys`,`爱心,旋转,轮回`],[`💟`,`heart decoration`,`smileys`,`爱心,符号`],[`💠`,`diamond shape with a dot inside`,`objects`,``],[`💡`,`electric light bulb`,`objects`,``],[`💢`,`anger symbol`,`objects`,`生气,怒气`],[`💣`,`bomb`,`objects`,`炸弹,爆炸`],[`💤`,`sleeping symbol`,`objects`,`睡觉,打呼,困`],[`💥`,`collision symbol`,`objects`,``],[`💦`,`splashing sweat symbol`,`objects`,`汗,水,泪`],[`💧`,`droplet`,`objects`,`水滴,水,眼泪`],[`💨`,`dash symbol`,`objects`,`风,跑,快,烟雾`],[`💩`,`pile of poo`,`objects`,`大便,屎,狗屎`],[`💪`,`flexed biceps`,`people`,`肌肉,力量,加油,强壮`],[`💫`,`dizzy symbol`,`objects`,`星星,旋转`],[`💬`,`speech balloon`,`objects`,`对话,聊天`],[`💭`,`thought balloon`,`objects`,`想法,思考,气泡`],[`💮`,`white flower`,`objects`,``],[`💯`,`hundred points symbol`,`objects`,``],[`💰`,`money bag`,`objects`,`钱袋,钱,金钱`],[`💱`,`currency exchange`,`objects`,``],[`💲`,`heavy dollar sign`,`objects`,``],[`💳`,`credit card`,`objects`,`信用卡,银行卡,支付`],[`💴`,`banknote with yen sign`,`objects`,`日元,日圆,钱`],[`💵`,`banknote with dollar sign`,`objects`,`美元,美金,钱`],[`💶`,`banknote with euro sign`,`objects`,`欧元,钱`],[`💷`,`banknote with pound sign`,`objects`,`英镑,钱`],[`💸`,`money with wings`,`objects`,`钱,飞钱,花钱`],[`💹`,`chart with upwards trend and yen sign`,`objects`,`股票,上涨,图表,增长`],[`💺`,`seat`,`objects`,`座位,椅子,飞机座位`],[`💻`,`personal computer`,`objects`,`电脑,笔记本,笔记本电脑`],[`💼`,`briefcase`,`objects`,`公文包,工作,商务`],[`💽`,`minidisc`,`objects`,`光盘,磁盘`],[`💾`,`floppy disk`,`objects`,`软盘,保存`],[`💿`,`optical disc`,`objects`,`光盘,CD`],[`📀`,`dvd`,`objects`,`光盘,DVD`],[`📁`,`file folder`,`objects`,`文件夹`],[`📂`,`open file folder`,`objects`,`文件夹,打开`],[`📃`,`page with curl`,`objects`,`文件,文档`],[`📄`,`page facing up`,`objects`,`文件,文档,纸`],[`📅`,`calendar`,`objects`,`日历`],[`📆`,`tear-off calendar`,`objects`,`日历,日历页`],[`📇`,`card index`,`objects`,`名片,索引卡`],[`📈`,`chart with upwards trend`,`objects`,``],[`📉`,`chart with downwards trend`,`objects`,``],[`📊`,`bar chart`,`objects`,``],[`📋`,`clipboard`,`objects`,`剪贴板,清单,列表`],[`📌`,`pushpin`,`objects`,``],[`📍`,`round pushpin`,`objects`,``],[`📎`,`paperclip`,`objects`,``],[`📏`,`straight ruler`,`objects`,``],[`📐`,`triangular ruler`,`objects`,``],[`📑`,`bookmark tabs`,`objects`,`书签,标签,文件`],[`📒`,`ledger`,`objects`,``],[`📓`,`notebook`,`objects`,``],[`📔`,`notebook with decorative cover`,`objects`,``],[`📕`,`closed book`,`objects`,``],[`📖`,`open book`,`objects`,``],[`📗`,`green book`,`objects`,``],[`📘`,`blue book`,`objects`,``],[`📙`,`orange book`,`objects`,``],[`📚`,`books`,`objects`,``],[`📛`,`name badge`,`objects`,``],[`📜`,`scroll`,`objects`,``],[`📝`,`memo`,`objects`,`笔记,备忘录,写作,文档`],[`📞`,`telephone receiver`,`objects`,`电话`],[`📟`,`pager`,`objects`,`寻呼机,传呼机`],[`📠`,`fax machine`,`objects`,`传真机,传真`],[`📡`,`satellite antenna`,`objects`,`天线,卫星,信号`],[`📢`,`public address loudspeaker`,`objects`,``],[`📣`,`cheering megaphone`,`objects`,``],[`📤`,`outbox tray`,`objects`,`发送,输出,上传`],[`📥`,`inbox tray`,`objects`,`接收,下载,收件箱`],[`📦`,`package`,`objects`,`包裹,快递,箱子`],[`📧`,`e-mail symbol`,`objects`,`邮件,电子邮件`],[`📨`,`incoming envelope`,`objects`,`邮件,收到`],[`📩`,`envelope with downwards arrow above`,`objects`,`邮件,发送`],[`📪`,`closed mailbox with lowered flag`,`objects`,`邮箱,关闭`],[`📫`,`closed mailbox with raised flag`,`objects`,`邮箱,信箱,邮件`],[`📬`,`open mailbox with raised flag`,`objects`,`邮箱,有信`],[`📭`,`open mailbox with lowered flag`,`objects`,`邮箱,无信`],[`📮`,`postbox`,`objects`,`邮筒,邮政`],[`📯`,`postal horn`,`objects`,``],[`📰`,`newspaper`,`objects`,`报纸,新闻,报`],[`📱`,`mobile phone`,`objects`,`手机,智能手机,电话`],[`📲`,`mobile phone with rightwards arrow at left`,`objects`,`手机,接收,信号`],[`📳`,`vibration mode`,`objects`,``],[`📴`,`mobile phone off`,`objects`,``],[`📵`,`no mobile phones`,`objects`,``],[`📶`,`antenna with bars`,`objects`,``],[`📷`,`camera`,`objects`,`相机,拍照,照片`],[`📸`,`camera with flash`,`objects`,`相机,闪光灯,拍照`],[`📹`,`video camera`,`objects`,`摄像机,录像`],[`📺`,`television`,`objects`,``],[`📻`,`radio`,`objects`,`收音机,广播`],[`📼`,`videocassette`,`objects`,`录像带,磁带`],[`📽`,`film projector`,`objects`,``],[`📿`,`prayer beads`,`objects`,`念珠,佛珠,项链`],[`🔀`,`twisted rightwards arrows`,`objects`,``],[`🔁`,`clockwise rightwards and leftwards open circle arrows`,`objects`,``],[`🔂`,`clockwise rightwards and leftwards open circle arrows with circled one overlay`,`objects`,``],[`🔃`,`clockwise downwards and upwards open circle arrows`,`objects`,``],[`🔄`,`anticlockwise downwards and upwards open circle arrows`,`objects`,``],[`🔅`,`low brightness symbol`,`objects`,``],[`🔆`,`high brightness symbol`,`objects`,``],[`🔇`,`speaker with cancellation stroke`,`objects`,``],[`🔈`,`speaker`,`objects`,``],[`🔉`,`speaker with one sound wave`,`objects`,``],[`🔊`,`speaker with three sound waves`,`objects`,``],[`🔋`,`battery`,`objects`,``],[`🔌`,`electric plug`,`objects`,``],[`🔍`,`left-pointing magnifying glass`,`objects`,`搜索,放大镜,查找,查询`],[`🔎`,`right-pointing magnifying glass`,`objects`,`搜索,放大镜,查找`],[`🔏`,`lock with ink pen`,`objects`,`锁,保密,笔`],[`🔐`,`closed lock with key`,`objects`,`锁,安全,钥匙`],[`🔑`,`key`,`objects`,`钥匙,解锁`],[`🔒`,`lock`,`objects`,`锁,锁定,安全`],[`🔓`,`open lock`,`objects`,`解锁,打开`],[`🔔`,`bell`,`objects`,``],[`🔕`,`bell with cancellation stroke`,`objects`,``],[`🔖`,`bookmark`,`objects`,`书签,标记`],[`🔗`,`link symbol`,`objects`,``],[`🔘`,`radio button`,`objects`,``],[`🔙`,`back with leftwards arrow above`,`objects`,``],[`🔚`,`end with leftwards arrow above`,`objects`,``],[`🔛`,`on with exclamation mark with left right arrow above`,`objects`,``],[`🔜`,`soon with rightwards arrow above`,`objects`,``],[`🔝`,`top with upwards arrow above`,`objects`,``],[`🔞`,`no one under eighteen symbol`,`objects`,``],[`🔟`,`keycap 10`,`objects`,``],[`🔠`,`input symbol for latin capital letters`,`objects`,``],[`🔡`,`input symbol for latin small letters`,`objects`,``],[`🔢`,`input symbol for numbers`,`objects`,``],[`🔣`,`input symbol for symbols`,`objects`,``],[`🔤`,`input symbol for latin letters`,`objects`,``],[`🔥`,`fire`,`objects`,``],[`🔦`,`electric torch`,`objects`,``],[`🔧`,`wrench`,`objects`,`扳手,工具,维修`],[`🔨`,`hammer`,`objects`,`锤子,工具`],[`🔩`,`nut and bolt`,`objects`,`螺丝,螺母`],[`🔪`,`hocho`,`objects`,``],[`🔫`,`pistol`,`objects`,`枪`],[`🔬`,`microscope`,`objects`,`显微镜,科学,研究`],[`🔭`,`telescope`,`objects`,`望远镜,天文,观察`],[`🔮`,`crystal ball`,`objects`,``],[`🔯`,`six pointed star with middle dot`,`objects`,``],[`🔰`,`japanese symbol for beginner`,`objects`,``],[`🔱`,`trident emblem`,`objects`,``],[`🔲`,`black square button`,`objects`,``],[`🔳`,`white square button`,`objects`,``],[`🔴`,`large red circle`,`objects`,``],[`🔵`,`large blue circle`,`objects`,``],[`🔶`,`large orange diamond`,`objects`,``],[`🔷`,`large blue diamond`,`objects`,``],[`🔸`,`small orange diamond`,`objects`,``],[`🔹`,`small blue diamond`,`objects`,``],[`🔺`,`up-pointing red triangle`,`objects`,``],[`🔻`,`down-pointing red triangle`,`objects`,``],[`🔼`,`up-pointing small red triangle`,`objects`,``],[`🔽`,`down-pointing small red triangle`,`objects`,``],[`🕉`,`om symbol`,`objects`,``],[`🕊`,`dove of peace`,`objects`,``],[`🕋`,`kaaba`,`objects`,`天房,麦加,伊斯兰`],[`🕌`,`mosque`,`objects`,`清真寺,伊斯兰`],[`🕍`,`synagogue`,`objects`,`犹太教堂,犹太`],[`🕎`,`menorah with nine branches`,`objects`,``],[`🕐`,`clock face one oclock`,`objects`,`一点,时钟`],[`🕑`,`clock face two oclock`,`objects`,`两点,时钟`],[`🕒`,`clock face three oclock`,`objects`,`三点,时钟`],[`🕓`,`clock face four oclock`,`objects`,`四点,时钟`],[`🕔`,`clock face five oclock`,`objects`,`五点,时钟`],[`🕕`,`clock face six oclock`,`objects`,`六点,时钟`],[`🕖`,`clock face seven oclock`,`objects`,`七点,时钟`],[`🕗`,`clock face eight oclock`,`objects`,`八点,时钟`],[`🕘`,`clock face nine oclock`,`objects`,`九点,时钟`],[`🕙`,`clock face ten oclock`,`objects`,`十点,时钟`],[`🕚`,`clock face eleven oclock`,`objects`,`十一点,时钟`],[`🕛`,`clock face twelve oclock`,`objects`,`十二点,时钟,时间`],[`🕜`,`clock face one-thirty`,`objects`,``],[`🕝`,`clock face two-thirty`,`objects`,``],[`🕞`,`clock face three-thirty`,`objects`,``],[`🕟`,`clock face four-thirty`,`objects`,``],[`🕠`,`clock face five-thirty`,`objects`,``],[`🕡`,`clock face six-thirty`,`objects`,``],[`🕢`,`clock face seven-thirty`,`objects`,``],[`🕣`,`clock face eight-thirty`,`objects`,``],[`🕤`,`clock face nine-thirty`,`objects`,``],[`🕥`,`clock face ten-thirty`,`objects`,``],[`🕦`,`clock face eleven-thirty`,`objects`,``],[`🕧`,`clock face twelve-thirty`,`objects`,``],[`🕯`,`candle`,`objects`,``],[`🕰`,`mantelpiece clock`,`objects`,``],[`🕳`,`hole`,`objects`,``],[`🕴`,`man in business suit levitating`,`objects`,``],[`🕵`,`sleuth or spy`,`objects`,``],[`🕶`,`dark sunglasses`,`objects`,``],[`🕷`,`spider`,`objects`,``],[`🕸`,`spider web`,`objects`,``],[`🕹`,`joystick`,`objects`,``],[`🕺`,`man dancing`,`objects`,`跳舞,舞男`],[`🖇`,`linked paperclips`,`objects`,``],[`🖊`,`lower left ballpoint pen`,`objects`,``],[`🖋`,`lower left fountain pen`,`objects`,``],[`🖌`,`lower left paintbrush`,`objects`,``],[`🖍`,`lower left crayon`,`objects`,``],[`🖐`,`raised hand with fingers splayed`,`objects`,``],[`🖕`,`reversed hand with middle finger extended`,`objects`,`中指,骂人`],[`🖖`,`raised hand with part between middle and ring fingers`,`objects`,`瓦肯,举手,胜利`],[`🖤`,`black heart`,`objects`,``],[`🖥`,`desktop computer`,`objects`,``],[`🖨`,`printer`,`objects`,``],[`🖱`,`three button mouse`,`objects`,``],[`🖲`,`trackball`,`objects`,``],[`🖼`,`frame with picture`,`objects`,``],[`🗂`,`card index dividers`,`objects`,``],[`🗃`,`card file box`,`objects`,``],[`🗄`,`file cabinet`,`objects`,``],[`🗑`,`wastebasket`,`objects`,``],[`🗒`,`spiral note pad`,`objects`,``],[`🗓`,`spiral calendar pad`,`objects`,``],[`🗜`,`compression`,`objects`,``],[`🗝`,`old key`,`objects`,``],[`🗞`,`rolled-up newspaper`,`objects`,``],[`🗡`,`dagger knife`,`objects`,``],[`🗣`,`speaking head in silhouette`,`objects`,``],[`🗨`,`left speech bubble`,`objects`,``],[`🗯`,`right anger bubble`,`objects`,``],[`🗳`,`ballot box with ballot`,`objects`,``],[`🗺`,`world map`,`objects`,``],[`🗻`,`mount fuji`,`objects`,`富士山,山`],[`🗼`,`tokyo tower`,`objects`,`塔,东京塔`],[`🗽`,`statue of liberty`,`objects`,`自由女神像,纽约`],[`🗾`,`silhouette of japan`,`objects`,``],[`🗿`,`moyai`,`objects`,`雕像`],[`😀`,`grinning face`,`smileys`,`笑脸,开心,高兴`],[`😁`,`grinning face with smiling eyes`,`smileys`,`笑脸,开心`],[`😂`,`face with tears of joy`,`smileys`,`笑哭,大笑,笑`],[`😃`,`smiling face with open mouth`,`smileys`,`笑脸,开心`],[`😄`,`smiling face with open mouth and smiling eyes`,`smileys`,`笑脸,开心`],[`😅`,`smiling face with open mouth and cold sweat`,`smileys`,`笑脸,汗,尴尬`],[`😆`,`smiling face with open mouth and tightly-closed eyes`,`smileys`,`笑脸,大笑`],[`😇`,`smiling face with halo`,`smileys`,`天使,微笑,善良`],[`😈`,`smiling face with horns`,`smileys`,`恶魔,坏笑,邪恶`],[`😉`,`winking face`,`smileys`,`眨眼,调皮`],[`😊`,`smiling face with smiling eyes`,`smileys`,`微笑,开心,脸红`],[`😋`,`face savouring delicious food`,`smileys`,`好吃,美味,舔`],[`😌`,`relieved face`,`smileys`,`放松,安心`],[`😍`,`smiling face with heart-shaped eyes`,`smileys`,`爱,喜欢,花痴`],[`😎`,`smiling face with sunglasses`,`smileys`,`酷,墨镜,帅气`],[`😏`,`smirking face`,`smileys`,`得意,微笑,坏笑`],[`😐`,`neutral face`,`smileys`,`无语,面无表情`],[`😑`,`expressionless face`,`smileys`,`无语,面无表情`],[`😒`,`unamused face`,`smileys`,`不满,无语,翻白眼`],[`😓`,`face with cold sweat`,`smileys`,`冷汗,尴尬`],[`😔`,`pensive face`,`smileys`,`难过,低落`],[`😕`,`confused face`,`smileys`,`困惑,不解`],[`😖`,`confounded face`,`smileys`,`纠结,痛苦`],[`😗`,`kissing face`,`smileys`,`亲亲,吻`],[`😘`,`face throwing a kiss`,`smileys`,`飞吻,亲亲,爱`],[`😙`,`kissing face with smiling eyes`,`smileys`,``],[`😚`,`kissing face with closed eyes`,`smileys`,`亲亲,吻`],[`😛`,`face with stuck-out tongue`,`smileys`,`吐舌头,调皮`],[`😜`,`face with stuck-out tongue and winking eye`,`smileys`,`吐舌头,调皮,眨眼`],[`😝`,`face with stuck-out tongue and tightly-closed eyes`,`smileys`,`吐舌头,调皮`],[`😞`,`disappointed face`,`smileys`,`失望,难过`],[`😟`,`worried face`,`smileys`,`担心,忧虑`],[`😠`,`angry face`,`smileys`,`生气,愤怒`],[`😡`,`pouting face`,`smileys`,`生气,愤怒,红脸`],[`😢`,`crying face`,`smileys`,`哭,伤心,流泪`],[`😣`,`persevering face`,`smileys`,`挣扎,痛苦`],[`😤`,`face with look of triumph`,`smileys`,`生气,冒烟,气`],[`😥`,`disappointed but relieved face`,`smileys`,`难过,失望,松气`],[`😦`,`frowning face with open mouth`,`smileys`,`惊讶,张嘴`],[`😧`,`anguished face`,`smileys`,`震惊,痛苦`],[`😨`,`fearful face`,`smileys`,`害怕,恐惧`],[`😩`,`weary face`,`smileys`,`累,疲惫,哭`],[`😪`,`sleepy face`,`smileys`,`困,想睡`],[`😫`,`tired face`,`smileys`,`累,疲惫`],[`😬`,`grimacing face`,`smileys`,`尴尬,咧嘴`],[`😭`,`loudly crying face`,`smileys`,`大哭,伤心,哭`],[`😮`,`face with open mouth`,`smileys`,`惊讶,哇`],[`😯`,`hushed face`,`smileys`,`惊讶,安静`],[`😰`,`face with open mouth and cold sweat`,`smileys`,`担心,冷汗`],[`😱`,`face screaming in fear`,`smileys`,`尖叫,害怕,恐怖`],[`😲`,`astonished face`,`smileys`,`震惊,惊讶`],[`😳`,`flushed face`,`smileys`,`脸红,害羞,震惊`],[`😴`,`sleeping face`,`smileys`,`睡觉,睡觉`],[`😵`,`dizzy face`,`smileys`,`晕,头晕,死`],[`😶`,`face without mouth`,`smileys`,`沉默,无语`],[`😷`,`face with medical mask`,`smileys`,`生病,口罩,感冒`],[`😸`,`grinning cat face with smiling eyes`,`smileys`,`猫,笑脸`],[`😹`,`cat face with tears of joy`,`smileys`,`猫,笑哭`],[`😺`,`smiling cat face with open mouth`,`smileys`,`猫,笑脸,开心`],[`😻`,`smiling cat face with heart-shaped eyes`,`smileys`,`猫,爱,喜欢`],[`😼`,`cat face with wry smile`,`smileys`,`猫,坏笑`],[`😽`,`kissing cat face with closed eyes`,`smileys`,`猫,亲亲`],[`😾`,`pouting cat face`,`smileys`,`猫,生气`],[`😿`,`crying cat face`,`smileys`,`猫,哭,伤心`],[`🙀`,`weary cat face`,`smileys`,`猫,震惊,害怕`],[`🙁`,`slightly frowning face`,`smileys`,`难过,失望`],[`🙂`,`slightly smiling face`,`smileys`,`微笑,笑`],[`🙃`,`upside-down face`,`smileys`,`微笑,倒`],[`🙄`,`face with rolling eyes`,`smileys`,`翻白眼,无语`],[`🙅`,`face with no good gesture`,`smileys`,``],[`🙆`,`face with ok gesture`,`smileys`,``],[`🙇`,`person bowing deeply`,`smileys`,``],[`🙈`,`see-no-evil monkey`,`smileys`,``],[`🙉`,`hear-no-evil monkey`,`smileys`,``],[`🙊`,`speak-no-evil monkey`,`smileys`,``],[`🙋`,`happy person raising one hand`,`smileys`,``],[`🙌`,`person raising both hands in celebration`,`smileys`,`欢呼,举起,庆祝`],[`🙍`,`person frowning`,`smileys`,``],[`🙎`,`person with pouting face`,`smileys`,``],[`🙏`,`person with folded hands`,`smileys`,`祈祷,拜托,感谢,合十`],[`🚀`,`rocket`,`travel`,`火箭,发射,太空`],[`🚁`,`helicopter`,`travel`,`直升机`],[`🚂`,`steam locomotive`,`travel`,`火车,蒸汽火车`],[`🚃`,`railway car`,`travel`,`电车,火车`],[`🚄`,`high-speed train`,`travel`,`高铁,动车,火车`],[`🚅`,`high-speed train with bullet nose`,`travel`,``],[`🚆`,`train`,`travel`,`火车,铁路`],[`🚇`,`metro`,`travel`,`地铁,地铁站`],[`🚈`,`light rail`,`travel`,`轻轨,轨道交通`],[`🚉`,`station`,`travel`,`火车站,车站`],[`🚊`,`tram`,`travel`,`电车`],[`🚋`,`tram car`,`travel`,`电车,有轨电车`],[`🚌`,`bus`,`travel`,`公交车,巴士`],[`🚍`,`oncoming bus`,`travel`,`公交车`],[`🚎`,`trolleybus`,`travel`,`无轨电车,巴士`],[`🚏`,`bus stop`,`travel`,`公交站,车站`],[`🚐`,`minibus`,`travel`,`面包车,小巴`],[`🚑`,`ambulance`,`travel`,`救护车,急救`],[`🚒`,`fire engine`,`travel`,`消防车,救火`],[`🚓`,`police car`,`travel`,`警车,警察`],[`🚔`,`oncoming police car`,`travel`,`警车,巡逻`],[`🚕`,`taxi`,`travel`,`出租车,的士`],[`🚖`,`oncoming taxi`,`travel`,`出租车`],[`🚗`,`automobile`,`travel`,`汽车,轿车,车`],[`🚘`,`oncoming automobile`,`travel`,`汽车`],[`🚙`,`recreational vehicle`,`travel`,`SUV,越野车,汽车`],[`🚚`,`delivery truck`,`travel`,`卡车,货车`],[`🚛`,`articulated lorry`,`travel`,`卡车,货车`],[`🚜`,`tractor`,`travel`,`拖拉机,农用`],[`🚝`,`monorail`,`travel`,`单轨,单轨列车`],[`🚞`,`mountain railway`,`travel`,`火车,山区铁路`],[`🚟`,`suspension railway`,`travel`,`缆车,悬挂列车`],[`🚠`,`mountain cableway`,`travel`,`缆车,高山`],[`🚡`,`aerial tramway`,`travel`,`缆车,索道`],[`🚢`,`ship`,`travel`,`轮船,船,大海`],[`🚣`,`rowboat`,`travel`,``],[`🚤`,`speedboat`,`travel`,`快艇,汽艇`],[`🚥`,`horizontal traffic light`,`travel`,`红绿灯,交通信号灯`],[`🚦`,`vertical traffic light`,`travel`,`红绿灯,信号灯`],[`🚧`,`construction sign`,`travel`,`施工,施工中,路障`],[`🚨`,`police cars revolving light`,`travel`,`警车灯,警报,紧急`],[`🚩`,`triangular flag on post`,`travel`,`红旗,旗帜,标志`],[`🚪`,`door`,`travel`,`门,房门`],[`🚫`,`no entry sign`,`travel`,``],[`🚬`,`smoking symbol`,`travel`,`香烟,烟,吸烟`],[`🚭`,`no smoking symbol`,`travel`,``],[`🚮`,`put litter in its place symbol`,`travel`,`垃圾,清理`],[`🚯`,`do not litter symbol`,`travel`,``],[`🚰`,`potable water symbol`,`travel`,``],[`🚱`,`non-potable water symbol`,`travel`,``],[`🚲`,`bicycle`,`travel`,`自行车,单车,骑行`],[`🚳`,`no bicycles`,`travel`,``],[`🚴`,`bicyclist`,`travel`,``],[`🚵`,`mountain bicyclist`,`travel`,``],[`🚶`,`pedestrian`,`travel`,`走路,步行,散步`],[`🚷`,`no pedestrians`,`travel`,``],[`🚸`,`children crossing`,`travel`,``],[`🚹`,`mens symbol`,`travel`,``],[`🚺`,`womens symbol`,`travel`,``],[`🚻`,`restroom`,`travel`,``],[`🚼`,`baby symbol`,`travel`,``],[`🚽`,`toilet`,`travel`,`马桶,厕所,卫生间`],[`🚾`,`water closet`,`travel`,``],[`🚿`,`shower`,`travel`,`淋浴,洗澡`],[`🛀`,`bath`,`travel`,`泡澡`],[`🛁`,`bathtub`,`travel`,`浴缸,洗澡,泡澡`],[`🛂`,`passport control`,`travel`,``],[`🛃`,`customs`,`travel`,``],[`🛄`,`baggage claim`,`travel`,``],[`🛅`,`left luggage`,`travel`,``],[`🛋`,`couch and lamp`,`travel`,``],[`🛌`,`sleeping accommodation`,`travel`,`睡觉`],[`🛍`,`shopping bags`,`travel`,``],[`🛎`,`bellhop bell`,`travel`,``],[`🛏`,`bed`,`travel`,``],[`🛐`,`place of worship`,`travel`,``],[`🛑`,`octagonal sign`,`travel`,`停止,停车,红圈`],[`🛒`,`shopping trolley`,`travel`,`购物车,购物`],[`🛕`,`hindu temple`,`travel`,`印度教神庙`],[`🛖`,`hut`,`travel`,`草屋,小屋`],[`🛗`,`elevator`,`travel`,``],[`🛜`,`wireless`,`travel`,``],[`🛝`,`playground slide`,`travel`,``],[`🛞`,`wheel`,`travel`,`车轮,轮胎`],[`🛟`,`ring buoy`,`travel`,`救生圈,救生`],[`🛠`,`hammer and wrench`,`travel`,``],[`🛡`,`shield`,`travel`,``],[`🛢`,`oil drum`,`travel`,``],[`🛣`,`motorway`,`travel`,``],[`🛤`,`railway track`,`travel`,``],[`🛥`,`motor boat`,`travel`,``],[`🛩`,`small airplane`,`travel`,``],[`🛫`,`airplane departure`,`travel`,`起飞,飞机,出发`],[`🛬`,`airplane arriving`,`travel`,`降落,飞机,到达`],[`🛰`,`satellite`,`travel`,``],[`🛳`,`passenger ship`,`travel`,``],[`🛴`,`scooter`,`travel`,`滑板车,平衡车`],[`🛵`,`motor scooter`,`travel`,`摩托车,电动车,踏板车`],[`🛶`,`canoe`,`travel`,`独木舟,皮划艇`],[`🛷`,`sled`,`travel`,`雪橇,雪车`],[`🛸`,`flying saucer`,`travel`,`飞碟,UFO,外星人`],[`🛹`,`skateboard`,`travel`,`滑板`],[`🛺`,`auto rickshaw`,`travel`,`三轮车,突突车`],[`🛻`,`pickup truck`,`travel`,`皮卡,卡车`],[`🛼`,`roller skate`,`travel`,`轮滑`],[`🟠`,`large orange circle`,`symbols`,``],[`🟡`,`large yellow circle`,`symbols`,``],[`🟢`,`large green circle`,`symbols`,``],[`🟣`,`large purple circle`,`symbols`,``],[`🟤`,`large brown circle`,`symbols`,``],[`🟥`,`large red square`,`symbols`,``],[`🟦`,`large blue square`,`symbols`,``],[`🟧`,`large orange square`,`symbols`,``],[`🟨`,`large yellow square`,`symbols`,``],[`🟩`,`large green square`,`symbols`,``],[`🟪`,`large purple square`,`symbols`,``],[`🟫`,`large brown square`,`symbols`,``],[`🟰`,`heavy equals sign`,`symbols`,``],[`🤌`,`pinched fingers`,`symbols`,`手指,捏,意大利`],[`🤍`,`white heart`,`symbols`,`白心,白色,爱心`],[`🤎`,`brown heart`,`symbols`,`棕心,棕色,爱心`],[`🤏`,`pinching hand`,`symbols`,`捏,一点点,微小`],[`🤐`,`zipper-mouth face`,`smileys`,`闭嘴,不说`],[`🤑`,`money-mouth face`,`smileys`,`发财,金钱,贪婪`],[`🤒`,`face with thermometer`,`smileys`,`发烧,生病,温度计`],[`🤓`,`nerd face`,`smileys`,`书呆子,眼镜`],[`🤔`,`thinking face`,`smileys`,`思考,疑问,想`],[`🤕`,`face with head-bandage`,`smileys`,`受伤,包扎,头`],[`🤖`,`robot face`,`smileys`,`机器人,AI,机械`],[`🤗`,`hugging face`,`smileys`,`拥抱,欢迎`],[`🤘`,`sign of the horns`,`smileys`,`摇滚,手势,牛`],[`🤙`,`call me hand`,`smileys`,`打电话,挂,酷`],[`🤚`,`raised back of hand`,`smileys`,`手,举手,停`],[`🤛`,`left-facing fist`,`smileys`,`拳头,左边`],[`🤜`,`right-facing fist`,`smileys`,`拳头,右边`],[`🤝`,`handshake`,`smileys`,`握手,合作,协议`],[`🤞`,`hand with index and middle fingers crossed`,`smileys`,`祈祷,好运,手指交叉`],[`🤟`,`i love you hand sign`,`smileys`,`爱你,摇滚`],[`🤠`,`face with cowboy hat`,`smileys`,`牛仔,帽子`],[`🤡`,`clown face`,`smileys`,`小丑,马戏团`],[`🤢`,`nauseated face`,`smileys`,`恶心,呕吐`],[`🤣`,`rolling on the floor laughing`,`smileys`,`笑哭,大笑,笑`],[`🤤`,`drooling face`,`smileys`,`流口水,馋`],[`🤥`,`lying face`,`smileys`,`说谎,撒谎`],[`🤦`,`face palm`,`smileys`,`捂脸,无奈,扶额`],[`🤧`,`sneezing face`,`smileys`,`打喷嚏,感冒`],[`🤨`,`face with one eyebrow raised`,`symbols`,`怀疑,挑眉`],[`🤩`,`grinning face with star eyes`,`symbols`,`星星眼,兴奋,惊讶`],[`🤪`,`grinning face with one large and one small eye`,`symbols`,`疯狂,搞怪`],[`🤫`,`face with finger covering closed lips`,`symbols`,`嘘,安静`],[`🤬`,`serious face with symbols covering mouth`,`symbols`,`骂人,脏话,生气`],[`🤭`,`smiling face with smiling eyes and hand covering mouth`,`symbols`,`捂嘴,偷笑,惊讶`],[`🤮`,`face with open mouth vomiting`,`symbols`,`呕吐,恶心`],[`🤯`,`shocked face with exploding head`,`smileys`,`爆炸,震惊,头炸`],[`🤰`,`pregnant woman`,`people`,`孕妇,怀孕`],[`🤱`,`breast-feeding`,`people`,``],[`🤲`,`palms up together`,`people`,``],[`🤳`,`selfie`,`people`,`自拍,拍照`],[`🤴`,`prince`,`people`,`王子,国王`],[`🤵`,`man in tuxedo`,`people`,`新郎,西装,燕尾服`],[`🤶`,`mother christmas`,`people`,`圣诞奶奶,圣诞老人`],[`🤷`,`shrug`,`people`,`耸肩,无奈,不知道`],[`🤸`,`person doing cartwheel`,`people`,`翻跟头,体操,空翻`],[`🤹`,`juggling`,`people`,`杂耍`],[`🤺`,`fencer`,`people`,`击剑,剑术`],[`🤼`,`wrestlers`,`activity`,`摔跤,格斗`],[`🤽`,`water polo`,`activity`,``],[`🤾`,`handball`,`activity`,``],[`🤿`,`diving mask`,`activity`,`潜水面罩,潜水`],[`🥀`,`wilted flower`,`symbols`,``],[`🥁`,`drum with drumsticks`,`symbols`,`鼓,打鼓,乐器`],[`🥂`,`clinking glasses`,`symbols`,`干杯,香槟杯`],[`🥃`,`tumbler glass`,`symbols`,`威士忌,酒杯`],[`🥄`,`spoon`,`symbols`,`勺子,汤匙`],[`🥅`,`goal net`,`symbols`,`球门,网,进球`],[`🥇`,`first place medal`,`symbols`,`金牌,冠军,第一名,奖牌`],[`🥈`,`second place medal`,`symbols`,`银牌,第二名,奖牌`],[`🥉`,`third place medal`,`symbols`,`铜牌,第三名,奖牌`],[`🥊`,`boxing glove`,`symbols`,`拳击,拳击手套,打拳`],[`🥋`,`martial arts uniform`,`symbols`,`道服,武术,空手道`],[`🥌`,`curling stone`,`symbols`,`冰壶,冰壶`],[`🥍`,`lacrosse stick and ball`,`symbols`,``],[`🥎`,`softball`,`symbols`,`垒球,球`],[`🥏`,`flying disc`,`symbols`,`飞盘,飞碟`],[`🥐`,`croissant`,`food`,`牛角包,可颂`],[`🥑`,`avocado`,`food`,`牛油果,鳄梨`],[`🥒`,`cucumber`,`food`,`黄瓜`],[`🥓`,`bacon`,`food`,`培根,腊肉`],[`🥔`,`potato`,`food`,`土豆,马铃薯`],[`🥕`,`carrot`,`food`,`胡萝卜`],[`🥖`,`baguette bread`,`food`,`法棍,面包`],[`🥗`,`green salad`,`food`,`沙拉,蔬菜`],[`🥘`,`shallow pan of food`,`food`,`炖锅,海鲜饭`],[`🥙`,`stuffed flatbread`,`food`,`卷饼,肉夹馍`],[`🥚`,`egg`,`food`,`鸡蛋,蛋`],[`🥛`,`glass of milk`,`food`,`牛奶,奶`],[`🥜`,`peanuts`,`food`,``],[`🥝`,`kiwifruit`,`food`,`猕猴桃,奇异果`],[`🥞`,`pancakes`,`food`,`松饼,煎饼`],[`🥟`,`dumpling`,`food`,`饺子,锅贴`],[`🥠`,`fortune cookie`,`food`,`幸运饼干`],[`🥡`,`takeout box`,`food`,``],[`🥢`,`chopsticks`,`food`,`筷子`],[`🥣`,`bowl with spoon`,`food`,``],[`🥤`,`cup with straw`,`food`,`饮料,杯`],[`🥥`,`coconut`,`food`,`椰子`],[`🥦`,`broccoli`,`food`,`西兰花`],[`🥧`,`pie`,`food`,`派,馅饼`],[`🥨`,`pretzel`,`food`,`椒盐卷饼`],[`🥩`,`cut of meat`,`food`,`牛排,肉`],[`🥪`,`sandwich`,`food`,`三明治`],[`🥫`,`canned food`,`food`,`罐头,罐装`],[`🥬`,`leafy green`,`symbols`,`青菜,白菜,生菜`],[`🥭`,`mango`,`symbols`,`芒果`],[`🥮`,`moon cake`,`symbols`,``],[`🥯`,`bagel`,`symbols`,`贝果,面包圈`],[`🥰`,`smiling face with smiling eyes and three hearts`,`smileys`,`爱,微笑,爱心`],[`🥱`,`yawning face`,`smileys`,`打哈欠,困,无聊`],[`🥲`,`smiling face with tear`,`smileys`,``],[`🥳`,`face with party horn and party hat`,`smileys`,`庆祝,派对,欢呼`],[`🥴`,`face with uneven eyes and wavy mouth`,`smileys`,`晕,醉,头昏`],[`🥵`,`overheated face`,`smileys`,`热`],[`🥶`,`freezing face`,`smileys`,`冷`],[`🥷`,`ninja`,`people`,`忍者,忍者`],[`🥸`,`disguised face`,`symbols`,`伪装`],[`🥹`,`face holding back tears`,`symbols`,`感动,忍住,哭,泪目`],[`🥺`,`face with pleading eyes`,`smileys`,`可怜,委屈,求`],[`🥻`,`sari`,`symbols`,`纱丽,印度`],[`🥼`,`lab coat`,`symbols`,``],[`🥽`,`goggles`,`symbols`,``],[`🥾`,`hiking boot`,`symbols`,`靴子,登山鞋`],[`🥿`,`flat shoe`,`symbols`,`平底鞋,鞋`],[`🦀`,`crab`,`animals`,`螃蟹,海鲜`],[`🦁`,`lion face`,`animals`,``],[`🦂`,`scorpion`,`animals`,``],[`🦃`,`turkey`,`animals`,`火鸡,感恩节`],[`🦄`,`unicorn face`,`animals`,`独角兽,梦幻`],[`🦅`,`eagle`,`animals`,`老鹰,鹰`],[`🦆`,`duck`,`animals`,`鸭子,鸭`],[`🦇`,`bat`,`animals`,`蝙蝠`],[`🦈`,`shark`,`animals`,`鲨鱼,鱼`],[`🦉`,`owl`,`animals`,`猫头鹰,智慧`],[`🦊`,`fox face`,`animals`,``],[`🦋`,`butterfly`,`animals`,``],[`🦌`,`deer`,`animals`,`鹿,麋鹿`],[`🦍`,`gorilla`,`animals`,``],[`🦎`,`lizard`,`animals`,`蜥蜴,爬行动物`],[`🦏`,`rhinoceros`,`animals`,`犀牛`],[`🦐`,`shrimp`,`animals`,`虾,海鲜`],[`🦑`,`squid`,`animals`,`鱿鱼,海鲜`],[`🦒`,`giraffe face`,`animals`,`长颈鹿`],[`🦓`,`zebra face`,`animals`,`斑马`],[`🦔`,`hedgehog`,`animals`,`刺猬`],[`🦕`,`sauropod`,`animals`,`恐龙,雷龙`],[`🦖`,`t-rex`,`animals`,`恐龙,霸王龙`],[`🦗`,`cricket`,`animals`,``],[`🦘`,`kangaroo`,`animals`,`袋鼠`],[`🦙`,`llama`,`animals`,`羊驼,草泥马`],[`🦚`,`peacock`,`animals`,`孔雀,开屏`],[`🦛`,`hippopotamus`,`animals`,`河马`],[`🦜`,`parrot`,`animals`,`鹦鹉`],[`🦝`,`raccoon`,`animals`,`浣熊`],[`🦞`,`lobster`,`animals`,`龙虾,海鲜`],[`🦟`,`mosquito`,`animals`,``],[`🦠`,`microbe`,`animals`,``],[`🦡`,`badger`,`animals`,`獾`],[`🦢`,`swan`,`animals`,`天鹅,鹅`],[`🦣`,`mammoth`,`animals`,`猛犸象`],[`🦤`,`dodo`,`animals`,`渡渡鸟`],[`🦥`,`sloth`,`animals`,`树懒`],[`🦦`,`otter`,`animals`,`水獭`],[`🦧`,`orangutan`,`animals`,``],[`🦨`,`skunk`,`animals`,`臭鼬`],[`🦩`,`flamingo`,`animals`,`火烈鸟,红鹤`],[`🦪`,`oyster`,`animals`,`生蚝,牡蛎`],[`🦫`,`beaver`,`animals`,`河狸,海狸`],[`🦬`,`bison`,`animals`,`野牛,水牛`],[`🦭`,`seal`,`animals`,`海豹,海狮`],[`🦮`,`guide dog`,`animals`,`导盲犬,狗`],[`🦯`,`probing cane`,`symbols`,``],[`🦰`,`emoji component red hair`,`people`,`红发,头发,发色`],[`🦱`,`emoji component curly hair`,`people`,`卷发,头发`],[`🦲`,`emoji component bald`,`people`,`光头,秃头`],[`🦳`,`emoji component white hair`,`people`,`白发,头发`],[`🦴`,`bone`,`people`,``],[`🦵`,`leg`,`people`,`腿,大腿`],[`🦶`,`foot`,`people`,`脚,足`],[`🦷`,`tooth`,`people`,`牙齿,牙`],[`🦸`,`superhero`,`people`,`英雄`],[`🦹`,`supervillain`,`people`,`超级反派,坏人,反派`],[`🦺`,`safety vest`,`symbols`,``],[`🦻`,`ear with hearing aid`,`symbols`,`助听器,耳朵`],[`🦼`,`motorized wheelchair`,`people`,``],[`🦽`,`manual wheelchair`,`people`,``],[`🦾`,`mechanical arm`,`people`,`机械臂,机器人,义肢`],[`🦿`,`mechanical leg`,`people`,`机械腿,义肢`],[`🧀`,`cheese wedge`,`food`,`奶酪,芝士`],[`🧁`,`cupcake`,`food`,`纸杯蛋糕,杯子蛋糕`],[`🧂`,`salt shaker`,`food`,``],[`🧃`,`beverage box`,`food`,`果汁盒,饮料`],[`🧄`,`garlic`,`food`,`大蒜,蒜`],[`🧅`,`onion`,`food`,`洋葱`],[`🧆`,`falafel`,`food`,`鹰嘴豆丸子`],[`🧇`,`waffle`,`food`,`华夫饼`],[`🧈`,`butter`,`food`,`黄油,奶油`],[`🧉`,`mate drink`,`food`,`马黛茶`],[`🧊`,`ice cube`,`food`,`冰块,冰`],[`🧋`,`bubble tea`,`food`,`奶茶,珍珠奶茶`],[`🧌`,`troll`,`symbols`,`巨魔,妖怪`],[`🧍`,`standing person`,`symbols`,`站立,站着,人`],[`🧎`,`kneeling person`,`symbols`,`跪,跪下,祈祷`],[`🧏`,`deaf person`,`symbols`,``],[`🧐`,`face with monocle`,`people`,`检查,研究,眼镜`],[`🧑`,`adult`,`people`,`人`],[`🧒`,`child`,`people`,``],[`🧓`,`older adult`,`people`,`老人,奶奶,爷爷`],[`🧔`,`bearded person`,`people`,`胡子,胡须,大叔`],[`🧕`,`person with headscarf`,`people`,`头巾`],[`🧖`,`person in steamy room`,`people`,`桑拿,蒸汽,洗澡`],[`🧗`,`person climbing`,`people`,`攀岩`],[`🧘`,`person in lotus position`,`people`,`打坐`],[`🧙`,`mage`,`people`,`巫师,魔法师,法师`],[`🧚`,`fairy`,`people`,`仙女,精灵,小仙女`],[`🧛`,`vampire`,`people`,`吸血鬼,德古拉`],[`🧜`,`merperson`,`people`,`美人鱼,人鱼`],[`🧝`,`elf`,`people`,`精灵,耳朵`],[`🧞`,`genie`,`people`,`灯神,精灵,神灯`],[`🧟`,`zombie`,`people`,`僵尸,丧尸`],[`🧠`,`brain`,`people`,`大脑,思考,记忆,AI`],[`🧡`,`orange heart`,`people`,``],[`🧢`,`billed cap`,`people`,`棒球帽,帽子`],[`🧣`,`scarf`,`people`,`围巾,冬天`],[`🧤`,`gloves`,`people`,`手套,冬天`],[`🧥`,`coat`,`people`,`大衣,外套`],[`🧦`,`socks`,`people`,`袜子`],[`🧧`,`red gift envelope`,`objects`,`红包,利是,新年`],[`🧨`,`firecracker`,`objects`,``],[`🧩`,`jigsaw puzzle piece`,`objects`,`拼图,拼图游戏`],[`🧪`,`test tube`,`objects`,`试管,实验,化学,科学`],[`🧫`,`petri dish`,`objects`,`培养皿,实验,细菌`],[`🧬`,`dna double helix`,`objects`,`DNA,基因,生物`],[`🧭`,`compass`,`objects`,`指南针`],[`🧮`,`abacus`,`objects`,`算盘,计算`],[`🧯`,`fire extinguisher`,`objects`,`灭火器,消防`],[`🧰`,`toolbox`,`objects`,`工具箱,工具`],[`🧱`,`brick`,`objects`,`砖`],[`🧲`,`magnet`,`objects`,`磁铁,磁性`],[`🧳`,`luggage`,`objects`,`行李箱`],[`🧴`,`lotion bottle`,`objects`,`乳液,护肤,防晒`],[`🧵`,`spool of thread`,`objects`,`线,针线,缝纫`],[`🧶`,`ball of yarn`,`objects`,`毛线,织毛衣`],[`🧷`,`safety pin`,`objects`,`别针,安全别针`],[`🧸`,`teddy bear`,`objects`,`泰迪熊,玩具熊`],[`🧹`,`broom`,`objects`,`扫帚`],[`🧺`,`basket`,`objects`,`篮子`],[`🧻`,`roll of paper`,`objects`,`纸巾`],[`🧼`,`bar of soap`,`objects`,`肥皂,洗手,清洁`],[`🧽`,`sponge`,`objects`,`海绵,清洁`],[`🧾`,`receipt`,`objects`,`收据`],[`🧿`,`nazar amulet`,`objects`,`护身符`],[`🩰`,`ballet shoes`,`activity`,`芭蕾`],[`🩱`,`one-piece swimsuit`,`activity`,`泳衣`],[`🩲`,`briefs`,`activity`,`泳裤`],[`🩳`,`shorts`,`activity`,`短裤`],[`🩴`,`thong sandal`,`activity`,`凉拖`],[`🩵`,`light blue heart`,`activity`,`浅蓝`],[`🩶`,`grey heart`,`activity`,`灰心`],[`🩷`,`pink heart`,`activity`,`粉色`],[`🩸`,`drop of blood`,`activity`,`血`],[`🩹`,`adhesive bandage`,`activity`,`创可贴`],[`🩺`,`stethoscope`,`activity`,`听诊器`],[`🩻`,`x-ray`,`activity`,`X光`],[`🩼`,`crutch`,`activity`,`拐杖`],[`🪀`,`yo-yo`,`objects`,`玩具`],[`🪁`,`kite`,`objects`,`风筝`],[`🪂`,`parachute`,`objects`,`跳伞`],[`🪃`,`boomerang`,`objects`,``],[`🪄`,`magic wand`,`objects`,`魔杖,魔法,魔术`],[`🪅`,`pinata`,`objects`,`皮纳塔`],[`🪆`,`nesting dolls`,`objects`,``],[`🪇`,`maracas`,`objects`,`沙锤`],[`🪈`,`flute`,`objects`,`笛子`],[`🪐`,`ringed planet`,`objects`,``],[`🪑`,`chair`,`objects`,`椅子`],[`🪒`,`razor`,`objects`,`剃须刀,剃刀`],[`🪓`,`axe`,`objects`,`斧头,斧子`],[`🪔`,`diya lamp`,`objects`,`油灯`],[`🪕`,`banjo`,`objects`,`班卓琴`],[`🪖`,`military helmet`,`objects`,`军盔`],[`🪗`,`accordion`,`objects`,`手风琴`],[`🪘`,`long drum`,`objects`,`鼓`],[`🪙`,`coin`,`objects`,`金币`],[`🪚`,`carpentry saw`,`objects`,`锯子,锯`],[`🪛`,`screwdriver`,`objects`,`螺丝刀`],[`🪜`,`ladder`,`objects`,`梯子`],[`🪝`,`hook`,`objects`,`钩子,挂钩`],[`🪞`,`mirror`,`objects`,`镜子`],[`🪟`,`window`,`objects`,`窗户`],[`🪠`,`plunger`,`objects`,`皮搋子,通马桶`],[`🪡`,`sewing needle`,`objects`,`针,缝纫,刺绣`],[`🪢`,`knot`,`objects`,``],[`🪣`,`bucket`,`objects`,`水桶,桶`],[`🪤`,`mouse trap`,`objects`,`捕鼠器`],[`🪥`,`toothbrush`,`objects`,`牙刷,刷牙`],[`🪦`,`headstone`,`objects`,`墓碑`],[`🪧`,`placard`,`objects`,`告示牌`],[`🪨`,`rock`,`objects`,`石头,岩石`],[`🪩`,`mirror ball`,`objects`,`迪斯科球`],[`🪪`,`identification card`,`objects`,`身份证`],[`🪫`,`low battery`,`objects`,`电池,没电,低电量`],[`🪬`,`hamsa`,`objects`,`手掌印,护身符`],[`🪭`,`folding hand fan`,`objects`,``],[`🪮`,`hair pick`,`objects`,`梳子`],[`🪯`,`khanda`,`objects`,``],[`🪰`,`fly`,`objects`,`苍蝇,飞虫`],[`🪱`,`worm`,`objects`,``],[`🪲`,`beetle`,`objects`,`甲虫,昆虫`],[`🪳`,`cockroach`,`objects`,`蟑螂,虫子`],[`🪴`,`potted plant`,`objects`,`盆栽,植物,绿植`],[`🪵`,`wood`,`objects`,`木头,柴火,木`],[`🪶`,`feather`,`objects`,`羽毛,羽毛笔`],[`🪷`,`lotus`,`objects`,`莲花`],[`🪸`,`coral`,`objects`,`珊瑚`],[`🪹`,`empty nest`,`objects`,`鸟巢`],[`🪺`,`nest with eggs`,`objects`,`鸟巢`],[`🪻`,`hyacinth`,`objects`,`风信子`],[`🪼`,`jellyfish`,`objects`,`水母`],[`🪽`,`wing`,`objects`,`翅膀`],[`🪿`,`goose`,`objects`,`鹅`],[`🫀`,`anatomical heart`,`objects`,`心脏,心跳`],[`🫁`,`lungs`,`objects`,`肺,呼吸`],[`🫂`,`people hugging`,`objects`,`拥抱,人,朋友`],[`🫃`,`pregnant man`,`objects`,`孕妇,怀孕`],[`🫄`,`pregnant person`,`objects`,`孕妇,怀孕`],[`🫅`,`person with crown`,`objects`,`国王,王子,皇冠`],[`🫎`,`moose`,`objects`,`驼鹿,麋鹿`],[`🫏`,`donkey`,`objects`,`驴,动物`],[`🫐`,`blueberries`,`food`,`蓝莓`],[`🫑`,`bell pepper`,`food`,`甜椒,彩椒`],[`🫒`,`olive`,`food`,`橄榄`],[`🫓`,`flatbread`,`food`,`薄饼,饼`],[`🫔`,`tamale`,`food`,`玉米粉蒸肉`],[`🫕`,`fondue`,`food`,`奶酪火锅`],[`🫖`,`teapot`,`food`,`茶壶,茶`],[`🫗`,`pouring liquid`,`food`,`倒,倒水,水杯`],[`🫘`,`beans`,`food`,`豆子,红豆`],[`🫙`,`jar`,`food`,`罐子,玻璃罐`],[`🫚`,`ginger root`,`food`,`姜,生姜`],[`🫛`,`pea pod`,`food`,`豌豆荚,豆`],[`🫠`,`melting face`,`smileys`,`融化`],[`🫡`,`saluting face`,`smileys`,`敬礼`],[`🫢`,`face with open eyes and hand over mouth`,`smileys`,`捂眼`],[`🫣`,`face with peeking eye`,`smileys`,`偷看`],[`🫤`,`face with diagonal mouth`,`smileys`,`撇嘴`],[`🫥`,`dotted line face`,`smileys`,`隐形`],[`🫦`,`biting lip`,`smileys`,`咬唇,嘴唇`],[`🫧`,`bubbles`,`smileys`,`泡泡`],[`🫨`,`shaking face`,`smileys`,`摇晃,震动,抖`],[`🫰`,`hand with index finger and thumb crossed`,`people`,`比心,手指,捏`],[`🫱`,`rightwards hand`,`people`,`手,右边,推`],[`🫲`,`leftwards hand`,`people`,`手,左边,推`],[`🫳`,`palm down hand`,`people`,`手,向下,放`],[`🫴`,`palm up hand`,`people`,`手,向上,举`],[`🫵`,`index pointing at the viewer`,`people`,`指,你`],[`🫶`,`heart hands`,`people`,`比心,爱心,手势`],[`🫷`,`leftwards pushing hand`,`people`,`手,推,右边`],[`🫸`,`rightwards pushing hand`,`people`,`手,推,左边`],[`‼`,`double exclamation mark`,`symbols`,``],[`‼️`,`double exclamation mark`,`symbols`,``],[`⁉`,`exclamation question mark`,`symbols`,``],[`⁉️`,`exclamation question mark`,`symbols`,``],[`™`,`trade mark sign`,`symbols`,``],[`™️`,`trade mark sign`,`symbols`,``],[`ℹ`,`information source`,`symbols`,``],[`ℹ️`,`information source`,`symbols`,``],[`↔`,`left right arrow`,`symbols`,``],[`↔️`,`left right arrow`,`symbols`,``],[`↕`,`up down arrow`,`symbols`,``],[`↕️`,`up down arrow`,`symbols`,``],[`↖`,`north west arrow`,`symbols`,``],[`↖️`,`north west arrow`,`symbols`,``],[`↗`,`north east arrow`,`symbols`,``],[`↗️`,`north east arrow`,`symbols`,``],[`↘`,`south east arrow`,`symbols`,``],[`↘️`,`south east arrow`,`symbols`,``],[`↙`,`south west arrow`,`symbols`,``],[`↙️`,`south west arrow`,`symbols`,``],[`↩`,`leftwards arrow with hook`,`symbols`,``],[`↩️`,`leftwards arrow with hook`,`symbols`,``],[`↪`,`rightwards arrow with hook`,`symbols`,``],[`↪️`,`rightwards arrow with hook`,`symbols`,``],[`⌚`,`watch`,`objects`,`手表`],[`⌚️`,`watch`,`objects`,``],[`⌛`,`hourglass`,`objects`,`沙漏,时间,等待`],[`⌛️`,`hourglass`,`objects`,``],[`⌨`,`keyboard`,`symbols`,``],[`⌨️`,`keyboard`,`symbols`,`键盘,打字`],[`⏏`,`eject symbol`,`symbols`,``],[`⏏️`,`eject symbol`,`symbols`,``],[`⏩`,`black right-pointing double triangle`,`objects`,``],[`⏪`,`black left-pointing double triangle`,`objects`,``],[`⏫`,`black up-pointing double triangle`,`objects`,``],[`⏬`,`black down-pointing double triangle`,`objects`,``],[`⏭`,`black right-pointing double triangle with vertical bar`,`objects`,``],[`⏭️`,`black right-pointing double triangle with vertical bar`,`objects`,``],[`⏮`,`black left-pointing double triangle with vertical bar`,`objects`,``],[`⏮️`,`black left-pointing double triangle with vertical bar`,`objects`,``],[`⏯`,`black right-pointing triangle with double vertical bar`,`objects`,``],[`⏯️`,`black right-pointing triangle with double vertical bar`,`objects`,``],[`⏰`,`alarm clock`,`objects`,`闹钟,时间,起床`],[`⏱`,`stopwatch`,`objects`,``],[`⏱️`,`stopwatch`,`objects`,`秒表`],[`⏲`,`timer clock`,`objects`,``],[`⏲️`,`timer clock`,`objects`,`计时器`],[`⏳`,`hourglass with flowing sand`,`objects`,`沙漏`],[`⏸`,`double vertical bar`,`symbols`,``],[`⏸️`,`double vertical bar`,`symbols`,``],[`⏹`,`black square for stop`,`symbols`,``],[`⏹️`,`black square for stop`,`symbols`,``],[`⏺`,`black circle for record`,`symbols`,``],[`⏺️`,`black circle for record`,`symbols`,``],[`Ⓜ`,`circled latin capital letter m`,`symbols`,``],[`Ⓜ️`,`circled latin capital letter m`,`symbols`,``],[`▪`,`black small square`,`symbols`,``],[`▪️`,`black small square`,`symbols`,``],[`▫`,`white small square`,`symbols`,``],[`▫️`,`white small square`,`symbols`,``],[`▶`,`black right-pointing triangle`,`symbols`,``],[`▶️`,`black right-pointing triangle`,`symbols`,``],[`◀`,`black left-pointing triangle`,`symbols`,``],[`◀️`,`black left-pointing triangle`,`symbols`,``],[`◻`,`white medium square`,`symbols`,``],[`◻️`,`white medium square`,`symbols`,``],[`◼`,`black medium square`,`symbols`,``],[`◼️`,`black medium square`,`symbols`,``],[`◽`,`white medium small square`,`symbols`,``],[`◾`,`black medium small square`,`symbols`,``],[`◾️`,`black medium small square`,`symbols`,``],[`☀`,`black sun with rays`,`symbols`,``],[`☀️`,`black sun with rays`,`symbols`,`太阳,晴天,阳光`],[`☁`,`cloud`,`symbols`,``],[`☁️`,`cloud`,`symbols`,`云,多云,天气`],[`☂`,`umbrella`,`symbols`,``],[`☂️`,`umbrella`,`symbols`,``],[`☃`,`snowman`,`symbols`,``],[`☃️`,`snowman`,`symbols`,`雪人,冬天,雪`],[`☄`,`comet`,`symbols`,``],[`☄️`,`comet`,`symbols`,``],[`☎`,`black telephone`,`symbols`,``],[`☎️`,`black telephone`,`symbols`,`电话`],[`☑`,`ballot box with check`,`symbols`,``],[`☑️`,`ballot box with check`,`symbols`,``],[`☔`,`umbrella with rain drops`,`symbols`,``],[`☔️`,`umbrella with rain drops`,`symbols`,``],[`☕`,`hot beverage`,`food`,`咖啡,热饮`],[`☕️`,`hot beverage`,`food`,``],[`☘`,`shamrock`,`symbols`,``],[`☘️`,`shamrock`,`symbols`,``],[`☝`,`white up pointing index`,`symbols`,``],[`☝️`,`white up pointing index`,`symbols`,`指,上面,向上`],[`☠`,`skull and crossbones`,`symbols`,``],[`☠️`,`skull and crossbones`,`symbols`,`骷髅,死亡,危险`],[`☢`,`radioactive sign`,`symbols`,``],[`☢️`,`radioactive sign`,`symbols`,``],[`☣`,`biohazard sign`,`symbols`,``],[`☣️`,`biohazard sign`,`symbols`,``],[`☦`,`orthodox cross`,`symbols`,``],[`☦️`,`orthodox cross`,`symbols`,``],[`☪`,`star and crescent`,`symbols`,``],[`☪️`,`star and crescent`,`symbols`,``],[`☮`,`peace symbol`,`symbols`,``],[`☮️`,`peace symbol`,`symbols`,``],[`☯`,`yin yang`,`symbols`,``],[`☯️`,`yin yang`,`symbols`,``],[`☸`,`wheel of dharma`,`symbols`,``],[`☸️`,`wheel of dharma`,`symbols`,``],[`☹`,`white frowning face`,`smileys`,``],[`☹️`,`white frowning face`,`smileys`,``],[`☺`,`white smiling face`,`smileys`,``],[`☺️`,`white smiling face`,`smileys`,``],[`♀`,`female sign`,`symbols`,``],[`♀️`,`female sign`,`symbols`,``],[`♂`,`male sign`,`symbols`,``],[`♂️`,`male sign`,`symbols`,``],[`♈`,`aries`,`symbols`,``],[`♈️`,`aries`,`symbols`,``],[`♉`,`taurus`,`symbols`,``],[`♉️`,`taurus`,`symbols`,``],[`♊`,`gemini`,`symbols`,``],[`♊️`,`gemini`,`symbols`,``],[`♋`,`cancer`,`symbols`,``],[`♋️`,`cancer`,`symbols`,``],[`♌`,`leo`,`symbols`,``],[`♌️`,`leo`,`symbols`,``],[`♍`,`virgo`,`symbols`,``],[`♍️`,`virgo`,`symbols`,``],[`♎`,`libra`,`symbols`,``],[`♎️`,`libra`,`symbols`,``],[`♏`,`scorpius`,`symbols`,``],[`♏️`,`scorpius`,`symbols`,``],[`♐`,`sagittarius`,`symbols`,``],[`♐️`,`sagittarius`,`symbols`,``],[`♑`,`capricorn`,`symbols`,``],[`♑️`,`capricorn`,`symbols`,``],[`♒`,`aquarius`,`symbols`,``],[`♒️`,`aquarius`,`symbols`,``],[`♓`,`pisces`,`symbols`,``],[`♓️`,`pisces`,`symbols`,``],[`♟`,`black chess pawn`,`symbols`,``],[`♟️`,`black chess pawn`,`symbols`,`棋子,国际象棋,象棋`],[`♠`,`black spade suit`,`symbols`,``],[`♠️`,`black spade suit`,`symbols`,``],[`♣`,`black club suit`,`symbols`,``],[`♣️`,`black club suit`,`symbols`,``],[`♥`,`black heart suit`,`symbols`,``],[`♥️`,`black heart suit`,`symbols`,``],[`♦`,`black diamond suit`,`symbols`,``],[`♦️`,`black diamond suit`,`symbols`,``],[`♨`,`hot springs`,`symbols`,``],[`♨️`,`hot springs`,`symbols`,`温泉,热泉`],[`♻`,`black universal recycling symbol`,`symbols`,``],[`♻️`,`black universal recycling symbol`,`symbols`,``],[`♾`,`permanent paper sign`,`symbols`,``],[`♾️`,`permanent paper sign`,`symbols`,``],[`♿`,`wheelchair symbol`,`symbols`,``],[`♿️`,`wheelchair symbol`,`symbols`,``],[`⚒`,`hammer and pick`,`symbols`,``],[`⚒️`,`hammer and pick`,`symbols`,`锤子,工具`],[`⚓`,`anchor`,`symbols`,`锚,航海,停泊`],[`⚔`,`crossed swords`,`symbols`,``],[`⚔️`,`crossed swords`,`symbols`,`剑,交叉,战斗`],[`⚕`,`staff of aesculapius`,`symbols`,``],[`⚕️`,`staff of aesculapius`,`symbols`,``],[`⚖`,`scales`,`symbols`,``],[`⚖️`,`scales`,`symbols`,``],[`⚗`,`alembic`,`symbols`,``],[`⚗️`,`alembic`,`symbols`,``],[`⚙`,`gear`,`symbols`,``],[`⚙️`,`gear`,`symbols`,``],[`⚛`,`atom symbol`,`symbols`,``],[`⚛️`,`atom symbol`,`symbols`,``],[`⚜`,`fleur-de-lis`,`symbols`,``],[`⚜️`,`fleur-de-lis`,`symbols`,``],[`⚠`,`warning sign`,`symbols`,``],[`⚠️`,`warning sign`,`symbols`,``],[`⚡`,`high voltage sign`,`symbols`,``],[`⚧`,`male with stroke and male and female sign`,`symbols`,``],[`⚧️`,`male with stroke and male and female sign`,`symbols`,``],[`⚪`,`medium white circle`,`symbols`,``],[`⚪️`,`medium white circle`,`symbols`,``],[`⚫`,`medium black circle`,`symbols`,``],[`⚰`,`coffin`,`symbols`,``],[`⚰️`,`coffin`,`symbols`,`棺材,死亡`],[`⚱`,`funeral urn`,`symbols`,``],[`⚱️`,`funeral urn`,`symbols`,`骨灰盒,死亡`],[`⚽`,`soccer ball`,`activity`,`足球,球`],[`⚽️`,`soccer ball`,`activity`,``],[`⚾`,`baseball`,`activity`,`棒球,球`],[`⚾️`,`baseball`,`activity`,``],[`⛄`,`snowman without snow`,`symbols`,`雪人,冬天`],[`⛄️`,`snowman without snow`,`symbols`,``],[`⛅`,`sun behind cloud`,`symbols`,`太阳,云,多云`],[`⛈`,`thunder cloud and rain`,`symbols`,``],[`⛈️`,`thunder cloud and rain`,`symbols`,`雷雨,雷暴,天气`],[`⛎`,`ophiuchus`,`symbols`,``],[`⛏`,`pick`,`symbols`,``],[`⛏️`,`pick`,`symbols`,`镐,工具`],[`⛑`,`helmet with white cross`,`symbols`,``],[`⛑️`,`helmet with white cross`,`symbols`,`头盔,救援,安全`],[`⛓`,`chains`,`symbols`,``],[`⛓️`,`chains`,`symbols`,``],[`⛔`,`no entry`,`symbols`,``],[`⛩`,`shinto shrine`,`travel`,``],[`⛩️`,`shinto shrine`,`travel`,`鸟居,神社,日本`],[`⛪`,`church`,`travel`,`教堂`],[`⛰`,`mountain`,`travel`,``],[`⛰️`,`mountain`,`travel`,`山,山峰`],[`⛱`,`umbrella on ground`,`travel`,``],[`⛱️`,`umbrella on ground`,`travel`,``],[`⛲`,`fountain`,`travel`,`喷泉`],[`⛲️`,`fountain`,`travel`,``],[`⛳`,`flag in hole`,`activity`,`高尔夫,高尔夫球,球洞`],[`⛳️`,`flag in hole`,`activity`,``],[`⛴`,`ferry`,`travel`,``],[`⛴️`,`ferry`,`travel`,`渡轮,船`],[`⛵`,`sailboat`,`travel`,`帆船,船`],[`⛵️`,`sailboat`,`travel`,``],[`⛷`,`skier`,`activity`,``],[`⛷️`,`skier`,`activity`,``],[`⛸`,`ice skate`,`activity`,``],[`⛸️`,`ice skate`,`activity`,`溜冰,冰刀,滑冰`],[`⛹`,`person with ball`,`activity`,``],[`⛹️`,`person with ball`,`activity`,``],[`⛺`,`tent`,`travel`,`帐篷,露营`],[`⛺️`,`tent`,`travel`,``],[`⛽`,`fuel pump`,`travel`,`加油站,加油,汽油`],[`✂`,`black scissors`,`symbols`,``],[`✂️`,`black scissors`,`symbols`,``],[`✅`,`white heavy check mark`,`symbols`,``],[`✈`,`airplane`,`travel`,``],[`✈️`,`airplane`,`travel`,`飞机,航班,起飞`],[`✉`,`envelope`,`symbols`,``],[`✉️`,`envelope`,`symbols`,`信封,邮件,信`],[`✊`,`raised fist`,`people`,`拳头,加油,力量`],[`✋`,`raised hand`,`people`,`手,举手,停`],[`✌`,`victory hand`,`symbols`,``],[`✌️`,`victory hand`,`symbols`,`胜利,耶,剪刀手`],[`✍`,`writing hand`,`symbols`,``],[`✍️`,`writing hand`,`symbols`,`写字,写作,手`],[`✏`,`pencil`,`symbols`,``],[`✏️`,`pencil`,`symbols`,``],[`✒`,`black nib`,`symbols`,``],[`✒️`,`black nib`,`symbols`,``],[`✔`,`heavy check mark`,`symbols`,``],[`✔️`,`heavy check mark`,`symbols`,``],[`✖`,`heavy multiplication x`,`symbols`,``],[`✖️`,`heavy multiplication x`,`symbols`,``],[`✝`,`latin cross`,`symbols`,``],[`✝️`,`latin cross`,`symbols`,``],[`✡`,`star of david`,`symbols`,``],[`✡️`,`star of david`,`symbols`,``],[`✨`,`sparkles`,`symbols`,`星星,闪光,发光`],[`✳`,`eight spoked asterisk`,`symbols`,``],[`✳️`,`eight spoked asterisk`,`symbols`,``],[`✴`,`eight pointed black star`,`symbols`,``],[`✴️`,`eight pointed black star`,`symbols`,``],[`❄`,`snowflake`,`symbols`,``],[`❄️`,`snowflake`,`symbols`,`雪花,雪,冬天,冷`],[`❇`,`sparkle`,`symbols`,``],[`❇️`,`sparkle`,`symbols`,``],[`❌`,`cross mark`,`symbols`,``],[`❎`,`negative squared cross mark`,`symbols`,``],[`❓`,`black question mark ornament`,`symbols`,``],[`❔`,`white question mark ornament`,`symbols`,``],[`❕`,`white exclamation mark ornament`,`symbols`,``],[`❗`,`heavy exclamation mark symbol`,`symbols`,``],[`❗️`,`heavy exclamation mark symbol`,`symbols`,``],[`❣`,`heavy heart exclamation mark ornament`,`symbols`,``],[`❣️`,`heavy heart exclamation mark ornament`,`symbols`,`爱心,感叹号`],[`❤`,`heavy black heart`,`smileys`,``],[`❤️`,`heavy black heart`,`smileys`,`爱心,红心,爱`],[`➕`,`heavy plus sign`,`symbols`,``],[`➖`,`heavy minus sign`,`symbols`,``],[`➗`,`heavy division sign`,`symbols`,``],[`➡`,`black rightwards arrow`,`symbols`,``],[`➡️`,`black rightwards arrow`,`symbols`,``],[`➰`,`curly loop`,`symbols`,``],[`➿`,`double curly loop`,`symbols`,``],[`⬅`,`leftwards black arrow`,`symbols`,``],[`⬅️`,`leftwards black arrow`,`symbols`,``],[`⬆`,`upwards black arrow`,`symbols`,``],[`⬆️`,`upwards black arrow`,`symbols`,``],[`⬇`,`downwards black arrow`,`symbols`,``],[`⬇️`,`downwards black arrow`,`symbols`,``],[`⬛`,`black large square`,`symbols`,``],[`⬛️`,`black large square`,`symbols`,``],[`⬜`,`white large square`,`symbols`,``],[`⬜️`,`white large square`,`symbols`,``],[`⭐`,`white medium star`,`symbols`,`星星,五星,评分`],[`⭕`,`heavy large circle`,`symbols`,``],[`⭕️`,`heavy large circle`,`symbols`,``],[`⤴`,`arrow pointing rightwards then curving upwards`,`symbols`,``],[`⤴️`,`arrow pointing rightwards then curving upwards`,`symbols`,``],[`⤵`,`arrow pointing rightwards then curving downwards`,`symbols`,``],[`⤵️`,`arrow pointing rightwards then curving downwards`,`symbols`,``],[`〰`,`wavy dash`,`symbols`,``],[`〰️`,`wavy dash`,`symbols`,``],[`〽`,`part alternation mark`,`symbols`,``],[`〽️`,`part alternation mark`,`symbols`,``],[`㊗`,`circled ideograph congratulation`,`symbols`,``],[`㊗️`,`circled ideograph congratulation`,`symbols`,``],[`㊙`,`circled ideograph secret`,`symbols`,``],[`㊙️`,`circled ideograph secret`,`symbols`,``],[`©`,`copyright sign`,`symbols`,``],[`©️`,`copyright sign`,`symbols`,``],[`®`,`registered sign`,`symbols`,``],[`®️`,`registered sign`,`symbols`,``],[`👨💻`,`man technologist`,`people`,`程序员,开发者,工程师,码农`],[`👩💻`,`woman technologist`,`people`,`程序员,开发者,工程师`],[`🧑💻`,`technologist`,`people`,`程序员,开发者,工程师`],[`👨🔧`,`man mechanic`,`people`,``],[`👩🔧`,`woman mechanic`,`people`,``],[`👨🎨`,`man artist`,`people`,``],[`👩🎨`,`woman artist`,`people`,``],[`👨🚀`,`man astronaut`,`people`,``],[`👩🚀`,`woman astronaut`,`people`,``],[`👨⚕️`,`man health worker`,`people`,``],[`👩⚕️`,`woman health worker`,`people`,``],[`👨🏫`,`man teacher`,`people`,``],[`👩🏫`,`woman teacher`,`people`,``],[`👨🍳`,`man cook`,`people`,``],[`👩🍳`,`woman cook`,`people`,``],[`👨🌾`,`man farmer`,`people`,``],[`👩🌾`,`woman farmer`,`people`,``],[`👩🏭`,`woman factory worker`,`people`,``],[`👨🎓`,`man student`,`people`,``],[`👩🎓`,`woman student`,`people`,``],[`👨🚒`,`man firefighter`,`people`,``],[`👩🚒`,`woman firefighter`,`people`,``],[`👨⚖️`,`man judge`,`people`,``],[`👩⚖️`,`woman judge`,`people`,``],[`👨💼`,`man office worker`,`people`,``],[`👩💼`,`woman office worker`,`people`,``],[`👨🎤`,`man singer`,`people`,``],[`👩🎤`,`woman singer`,`people`,``],[`👨🦰`,`man red hair`,`people`,``],[`👩🦰`,`woman red hair`,`people`,``],[`👨🦱`,`man curly hair`,`people`,``],[`👩🦱`,`woman curly hair`,`people`,``],[`👩🦲`,`woman bald`,`people`,``],[`👨🦳`,`man white hair`,`people`,``],[`👩🦳`,`woman white hair`,`people`,``],[`👩❤️👨`,`couple with heart`,`people`,``],[`👨❤️👨`,`couple with heart`,`people`,``],[`👩❤️👩`,`couple with heart`,`people`,``],[`👨👩👧`,`family man woman girl`,`people`,``],[`👨👩👦`,`family man woman boy`,`people`,``],[`👨👩👧👦`,`family man woman girl boy`,`people`,``],[`👨👩👦👦`,`man`,`people`,``],[`👨👩👧👧`,`family man woman girl girl`,`people`,``],[`👩👩👧`,`family woman woman girl`,`people`,``],[`👨👨👧`,`family man man girl`,`people`,``],[`👨👦`,`family man boy`,`people`,``],[`👩👧`,`family woman girl`,`people`,``],[`👨👧👦`,`family man girl boy`,`people`,``],[`👩❤️💋👨`,`kiss woman man`,`people`,``],[`🧑🤝🧑`,`people holding hands`,`people`,``],[`❤️🔥`,`heart on fire`,`smileys`,``],[`🧑🚒`,`firefighter`,`people`,`消防员`],[`🧑🏭`,`factory worker`,`people`,``],[`🧑🎓`,`student`,`people`,`学生,毕业生,大学生`],[`🧑🏫`,`teacher`,`people`,`老师,教师,教授`],[`🧑🎤`,`singer`,`people`,`歌手,歌星`],[`🧑⚕️`,`health worker`,`people`,`医生,医疗`],[`🧑⚖️`,`judge`,`people`,`法官,审判`],[`🧑🍳`,`cook`,`people`,`厨师,大厨`],[`🧑🌾`,`farmer`,`people`,`农民,农夫`],[`🧑🎨`,`artist`,`people`,`画家,艺术家`],[`🧑🔬`,`scientist`,`people`,``],[`🧑🔧`,`mechanic`,`people`,`技工,维修工`],[`🧑💼`,`office worker`,`people`,`白领,上班族,职员`],[`🧑🚀`,`astronaut`,`people`,`宇航员,太空人`],[`🏃♂️`,`man running`,`activity`,``],[`🏃♀️`,`woman running`,`activity`,``],[`🚶♂️`,`man walking`,`travel`,``],[`🚶♀️`,`woman walking`,`travel`,``],[`🧎♂️`,`man kneeling`,`symbols`,``],[`🧎♀️`,`woman kneeling`,`symbols`,``],[`🏋️♂️`,`man lifting weights`,`activity`,``],[`🏋️♀️`,`woman lifting weights`,`activity`,``],[`🤸♂️`,`man cartwheeling`,`people`,``],[`🤸♀️`,`woman cartwheeling`,`people`,``],[`⛹️♂️`,`man bouncing ball`,`activity`,``],[`⛹️♀️`,`woman bouncing ball`,`activity`,``],[`🤾♂️`,`man playing handball`,`activity`,``],[`🤾♀️`,`woman playing handball`,`activity`,``],[`🧘♀️`,`woman in lotus position`,`people`,``],[`🏄♂️`,`man surfing`,`activity`,``],[`🏄♀️`,`woman surfing`,`activity`,``],[`🏊♂️`,`man swimming`,`activity`,``],[`🏊♀️`,`woman swimming`,`activity`,``],[`🚴♂️`,`man biking`,`travel`,``],[`🚴♀️`,`woman biking`,`travel`,``],[`🚵♂️`,`man mountain biking`,`travel`,``],[`🚵♀️`,`woman mountain biking`,`travel`,``],[`👯♂️`,`men with bunny ears`,`people`,``],[`👯♀️`,`women with bunny ears`,`people`,``],[`🧖♂️`,`man in steamy room`,`people`,``],[`🧖♀️`,`woman in steamy room`,`people`,``],[`🧗♂️`,`man climbing`,`people`,``],[`🧗♀️`,`woman climbing`,`people`,``],[`🤦♂️`,`man facepalming`,`smileys`,``],[`🤦♀️`,`woman facepalming`,`smileys`,``],[`🤷♂️`,`man shrugging`,`people`,``],[`🤷♀️`,`woman shrugging`,`people`,``],[`🙍♂️`,`person frowning`,`smileys`,``],[`🙍♀️`,`woman frowning`,`smileys`,``],[`🙎♂️`,`man pouting`,`smileys`,``],[`🙎♀️`,`woman pouting`,`smileys`,``],[`🙅♂️`,`man gesturing no`,`smileys`,``],[`🙅♀️`,`woman gesturing no`,`smileys`,``],[`🙆♂️`,`man gesturing ok`,`smileys`,``],[`🙆♀️`,`woman gesturing ok`,`smileys`,``],[`💁♂️`,`man tipping hand`,`people`,``],[`💁♀️`,`woman tipping hand`,`people`,``],[`🙋♂️`,`man raising hand`,`smileys`,``],[`🙋♀️`,`woman raising hand`,`smileys`,``],[`🙇♂️`,`man bowing`,`smileys`,``],[`🙇♀️`,`woman bowing`,`smileys`,``],[`💆♂️`,`man getting massage`,`people`,``],[`💆♀️`,`woman getting massage`,`people`,``],[`💇♂️`,`man getting haircut`,`people`,``],[`💇♀️`,`woman getting haircut`,`people`,``],[`🧞♂️`,`man genie`,`people`,``],[`🧞♀️`,`woman genie`,`people`,``],[`🧟♂️`,`man zombie`,`people`,``],[`🧟♀️`,`woman zombie`,`people`,``],[`🧜♂️`,`merman`,`people`,``],[`🧚♂️`,`man fairy`,`people`,``],[`🧚♀️`,`woman fairy`,`people`,``],[`🧛♂️`,`man vampire`,`people`,``],[`🧛♀️`,`woman vampire`,`people`,``],[`🧙♂️`,`man mage`,`people`,``],[`🧙♀️`,`mage`,`people`,``],[`🧝♂️`,`man elf`,`people`,``],[`🧝♀️`,`woman elf`,`people`,``],[`🦸♂️`,`man superhero`,`people`,``],[`🦸♀️`,`woman superhero`,`people`,``],[`🦹♂️`,`man supervillain`,`people`,``],[`🦹♀️`,`woman supervillain`,`people`,``],[`0️⃣`,`keycap 0`,`symbols`,``],[`1️⃣`,`keycap 1`,`symbols`,``],[`2️⃣`,`keycap 2`,`symbols`,``],[`3️⃣`,`keycap 3`,`symbols`,``],[`4️⃣`,`keycap 4`,`symbols`,``],[`5️⃣`,`keycap 5`,`symbols`,``],[`6️⃣`,`keycap 6`,`symbols`,``],[`7️⃣`,`keycap 7`,`symbols`,``],[`8️⃣`,`keycap 8`,`symbols`,``],[`9️⃣`,`keycap 9`,`symbols`,``],[`#️⃣`,`keycap #`,`symbols`,``],[`*️⃣`,`keycap *`,`symbols`,``],[`🇨🇳`,`flag china`,`flags`,`中国,国旗,五星红旗`],[`🇺🇸`,`flag united states`,`flags`,`美国,国旗,USA`],[`🇬🇧`,`flag united kingdom`,`flags`,`英国,国旗,UK`],[`🇯🇵`,`flag japan`,`flags`,`日本,国旗`],[`🇫🇷`,`flag france`,`flags`,`法国,国旗`],[`🇩🇪`,`flag germany`,`flags`,`德国,国旗`],[`🇮🇹`,`flag italy`,`flags`,`意大利,国旗`],[`🇪🇸`,`flag spain`,`flags`,`西班牙,国旗`],[`🇷🇺`,`flag russia`,`flags`,`俄罗斯,国旗`],[`🇮🇳`,`regional indicator symbol letter i`,`flags`,`印度,国旗`],[`🇧🇷`,`flag brazil`,`flags`,`巴西,国旗`],[`🇨🇦`,`flag canada`,`flags`,`加拿大,国旗`],[`🇦🇺`,`flag australia`,`flags`,`澳大利亚,国旗`],[`🇸🇬`,`flag singapore`,`flags`,`新加坡,国旗`],[`🇭🇰`,`flag hong kong`,`flags`,`香港,国旗,区旗`],[`🇹🇼`,`flag taiwan`,`flags`,`台湾,国旗`],[`🇲🇴`,`flag macau`,`flags`,`澳门,国旗`],[`🇻🇳`,`flag vietnam`,`flags`,`越南,国旗`],[`🇲🇾`,`regional indicator symbol letter m`,`flags`,`马来西亚,国旗`],[`🇮🇩`,`flag indonesia`,`flags`,`印尼,国旗`],[`🇵🇭`,`flag philippines`,`flags`,`菲律宾,国旗`],[`🇹🇷`,`flag turkey`,`flags`,`土耳其,国旗`],[`🇸🇦`,`flag saudi arabia`,`flags`,`沙特,国旗`],[`🇦🇪`,`flag united arab emirates`,`flags`,`阿联酋,国旗`],[`🇳🇱`,`flag netherlands`,`flags`,`荷兰,国旗`],[`🇸🇪`,`flag sweden`,`flags`,`瑞典,国旗`],[`🇨🇭`,`flag switzerland`,`flags`,`瑞士,国旗`],[`🇦🇹`,`flag austria`,`flags`,`奥地利,国旗`],[`🇧🇪`,`flag belgium`,`flags`,`比利时,国旗`],[`🇵🇹`,`flag portugal`,`flags`,`葡萄牙,国旗`],[`🇬🇷`,`flag greece`,`flags`,`希腊,国旗`],[`🇳🇴`,`flag norway`,`flags`,`挪威,国旗`],[`🇩🇰`,`flag denmark`,`flags`,`丹麦,国旗`],[`🇫🇮`,`flag finland`,`flags`,`芬兰,国旗`],[`🇵🇱`,`flag poland`,`flags`,`波兰,国旗`],[`🇺🇦`,`flag ukraine`,`flags`,`乌克兰,国旗`],[`🇮🇱`,`flag israel`,`flags`,`以色列,国旗`],[`🇪🇬`,`flag egypt`,`flags`,`埃及,国旗`],[`🇿🇦`,`flag south africa`,`flags`,`南非,国旗`],[`🇳🇬`,`flag nigeria`,`flags`,`尼日利亚,国旗`],[`🇲🇽`,`flag mexico`,`flags`,`墨西哥,国旗`],[`🇦🇷`,`flag argentina`,`flags`,``],[`🇨🇱`,`flag chile`,`flags`,`智利,国旗`],[`🇰🇿`,`flag kazakhstan`,`flags`,`哈萨克斯坦,国旗`],[`🇺🇿`,`flag uzbekistan`,`flags`,`乌兹别克斯坦,国旗`],[`🇳🇿`,`flag new zealand`,`flags`,`新西兰,国旗`],[`🇮🇪`,`flag ireland`,`flags`,`爱尔兰,国旗`],[`🇨🇿`,`flag czechia`,`flags`,`捷克,国旗`],[`👍🏻`,`thumbs up light skin`,`people`,``],[`👍🏽`,`thumbs up sign`,`people`,``],[`👍🏾`,`thumbs up medium dark skin`,`people`,``],[`👍🏿`,`thumbs up dark skin`,`people`,``],[`👏🏻`,`clapping hands light skin`,`people`,``],[`👏🏼`,`clapping hands medium light skin`,`people`,``],[`👏🏽`,`clapping hands medium skin`,`people`,``],[`👏🏾`,`clapping hands medium dark skin`,`people`,``],[`👏🏿`,`clapping hands dark skin`,`people`,``],[`🙏🏻`,`folded hands light skin`,`smileys`,``],[`🙏🏼`,`folded hands medium light skin`,`smileys`,``],[`🙏🏽`,`folded hands medium skin`,`smileys`,``],[`🙏🏾`,`folded hands medium dark skin`,`smileys`,``],[`🙏🏿`,`folded hands dark skin`,`smileys`,``],[`🏳️🌈`,`rainbow flag`,`flags`,``],[`🏴☠️`,`pirate flag`,`flags`,`海盗旗,海盗`]];n(`zh`,{agentMgr:{allTools:`全部`,defaultAgentName:`默认助手`,defaultAgentDesc:`全能 AI 助手,拥有所有工具能力`,switchedTo:`已切换到:{name}`,editAgent:`编辑助手`,templateLoaded:`已加载模板:{name}`,noSkillsHint:`暂无启用技能(请先确认 Agent 已连接且技能开关已开启)`,nameRequired:`请输入助手名称`,agentUpdated:`助手已更新`,agentCreated:`助手 "{name}" 已创建`,saveFailed:`保存失败:{message}`,confirmDeleteAgentMessage:`确定要删除助手 "{name}" 吗?
|
|
2040
|
+
`).join(``),e.querySelectorAll(`.ref-chip-close`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),N.selectedMcpServices=N.selectedMcpServices.filter(t=>t.serverName!==e.dataset.serverName),sC(),cC()})}),e.style.display=`flex`}}function cC(){let e=new Set(N.selectedMcpServices.map(e=>e.serverName));document.querySelectorAll(`.mcp-list-item, .merged-mcp-item`).forEach(t=>{t.classList.toggle(`picked`,e.has(t.dataset.serverName))})}function lC(){let e=document.getElementById(`mcpIndicatorClose`);e&&e.addEventListener(`click`,aC)}function uC(){let e=document.getElementById(`promptDropdownHeader`);if(!e||e.querySelector(`.mcp-manage-btn`))return;let t=document.createElement(`button`);t.className=`mcp-manage-btn`,t.title=r(`promptSelector.mcpManageTitle`),t.style.display=`none`,t.style.fontSize=`13px`,t.innerHTML=`✚`,t.addEventListener(`click`,e=>{e.stopPropagation(),chrome.runtime.sendMessage({type:`OPEN_OPTIONS_PAGE`,hash:`toolbox`})}),e.appendChild(t)}var dC=[[`🀄`,`mahjong tile red dragon`,`symbols`,`麻将,红中`],[`🃏`,`playing card black joker`,`symbols`,``],[`🅰`,`negative squared latin capital letter a`,`symbols`,``],[`🅱`,`negative squared latin capital letter b`,`symbols`,``],[`🅾`,`negative squared latin capital letter o`,`symbols`,``],[`🅿`,`negative squared latin capital letter p`,`symbols`,``],[`🆎`,`negative squared ab`,`symbols`,``],[`🆑`,`squared cl`,`symbols`,``],[`🆒`,`squared cool`,`symbols`,``],[`🆓`,`squared free`,`symbols`,``],[`🆔`,`squared id`,`symbols`,``],[`🆕`,`squared new`,`symbols`,``],[`🆖`,`squared ng`,`symbols`,``],[`🆗`,`squared ok`,`symbols`,``],[`🆘`,`squared sos`,`symbols`,``],[`🆙`,`squared up with exclamation mark`,`symbols`,``],[`🆚`,`squared vs`,`symbols`,``],[`🇨🇩`,`regional indicator symbol letter c`,`flags`,``],[`🇬🇭`,`regional indicator symbol letter g`,`flags`,``],[`🇲🇳`,`regional indicator symbol letter m`,`flags`,``],[`🇷🇸`,`regional indicator symbol letter r`,`flags`,``],[`🈁`,`squared katakana koko`,`symbols`,``],[`🈂`,`squared katakana sa`,`symbols`,``],[`🈚`,`squared cjk unified ideograph-7121`,`symbols`,``],[`🈯`,`squared cjk unified ideograph-6307`,`symbols`,``],[`🈲`,`squared cjk unified ideograph-7981`,`symbols`,``],[`🈳`,`squared cjk unified ideograph-7a7a`,`symbols`,``],[`🈴`,`squared cjk unified ideograph-5408`,`symbols`,``],[`🈵`,`squared cjk unified ideograph-6e80`,`symbols`,``],[`🈶`,`squared cjk unified ideograph-6709`,`symbols`,``],[`🈷`,`squared cjk unified ideograph-6708`,`symbols`,``],[`🈸`,`squared cjk unified ideograph-7533`,`symbols`,``],[`🈹`,`squared cjk unified ideograph-5272`,`symbols`,``],[`🈺`,`squared cjk unified ideograph-55b6`,`symbols`,``],[`🉐`,`circled ideograph advantage`,`symbols`,``],[`🉑`,`circled ideograph accept`,`symbols`,``],[`🌀`,`cyclone`,`symbols`,`台风,龙卷风,旋风`],[`🌁`,`foggy`,`symbols`,`雾,雾霾,朦胧`],[`🌂`,`closed umbrella`,`symbols`,``],[`🌃`,`night with stars`,`symbols`,`夜晚,星空,城市`],[`🌄`,`sunrise over mountains`,`symbols`,`日出,山,早晨`],[`🌅`,`sunrise`,`symbols`,`日出,太阳,早晨`],[`🌆`,`cityscape at dusk`,`symbols`,`黄昏,傍晚,城市`],[`🌇`,`sunset over buildings`,`symbols`,`日落,黄昏`],[`🌈`,`rainbow`,`symbols`,`彩虹,雨后`],[`🌉`,`bridge at night`,`symbols`,`桥,大桥`],[`🌊`,`water wave`,`symbols`,`海浪,波浪,海`],[`🌋`,`volcano`,`symbols`,`火山,爆发`],[`🌌`,`milky way`,`symbols`,``],[`🌍`,`earth globe europe-africa`,`symbols`,``],[`🌎`,`earth globe americas`,`symbols`,`地球,美洲`],[`🌏`,`earth globe asia-australia`,`symbols`,`地球,亚洲`],[`🌐`,`globe with meridians`,`symbols`,``],[`🌑`,`new moon symbol`,`symbols`,``],[`🌒`,`waxing crescent moon symbol`,`symbols`,``],[`🌓`,`first quarter moon symbol`,`symbols`,``],[`🌔`,`waxing gibbous moon symbol`,`symbols`,``],[`🌕`,`full moon symbol`,`symbols`,``],[`🌖`,`waning gibbous moon symbol`,`symbols`,``],[`🌗`,`last quarter moon symbol`,`symbols`,``],[`🌘`,`waning crescent moon symbol`,`symbols`,``],[`🌙`,`crescent moon`,`symbols`,``],[`🌚`,`new moon with face`,`symbols`,``],[`🌛`,`first quarter moon with face`,`symbols`,``],[`🌜`,`last quarter moon with face`,`symbols`,``],[`🌝`,`full moon with face`,`symbols`,``],[`🌞`,`sun with face`,`symbols`,``],[`🌟`,`glowing star`,`symbols`,`星星,闪光,闪耀`],[`🌠`,`shooting star`,`symbols`,``],[`🌡`,`thermometer`,`symbols`,``],[`🌤`,`white sun with small cloud`,`symbols`,``],[`🌥`,`white sun behind cloud`,`symbols`,``],[`🌦`,`white sun behind cloud with rain`,`symbols`,``],[`🌧`,`cloud with rain`,`symbols`,``],[`🌨`,`cloud with snow`,`symbols`,``],[`🌩`,`cloud with lightning`,`symbols`,``],[`🌪`,`cloud with tornado`,`symbols`,``],[`🌫`,`fog`,`symbols`,``],[`🌬`,`wind blowing face`,`symbols`,``],[`🌭`,`hot dog`,`food`,`热狗`],[`🌮`,`taco`,`food`,`墨西哥卷饼`],[`🌯`,`burrito`,`food`,`墨西哥卷,卷饼`],[`🌰`,`chestnut`,`food`,`栗子,坚果`],[`🌱`,`seedling`,`food`,``],[`🌲`,`evergreen tree`,`food`,`松树,树`],[`🌳`,`deciduous tree`,`food`,`树,大树`],[`🌴`,`palm tree`,`food`,`棕榈树,热带,度假`],[`🌵`,`cactus`,`food`,`仙人掌,沙漠`],[`🌶`,`hot pepper`,`food`,``],[`🌷`,`tulip`,`food`,`郁金香,花`],[`🌸`,`cherry blossom`,`food`,`樱花,花,春天`],[`🌹`,`rose`,`food`,`玫瑰,花,爱情`],[`🌺`,`hibiscus`,`food`,`花,芙蓉`],[`🌻`,`sunflower`,`food`,`向日葵,花,太阳`],[`🌼`,`blossom`,`food`,`雏菊,花`],[`🌽`,`ear of maize`,`food`,`玉米`],[`🌾`,`ear of rice`,`food`,``],[`🌿`,`herb`,`food`,`草,植物,草药`],[`🍀`,`four leaf clover`,`food`,`四叶草,幸运,好运`],[`🍁`,`maple leaf`,`food`,`枫叶,秋天,红叶`],[`🍂`,`fallen leaf`,`food`,`落叶,秋天`],[`🍃`,`leaf fluttering in wind`,`food`,`树叶,风`],[`🍄`,`mushroom`,`food`,`蘑菇,菌`],[`🍅`,`tomato`,`food`,`番茄,西红柿`],[`🍆`,`aubergine`,`food`,`茄子`],[`🍇`,`grapes`,`food`,`葡萄`],[`🍈`,`melon`,`food`,`哈密瓜,甜瓜`],[`🍉`,`watermelon`,`food`,`西瓜`],[`🍊`,`tangerine`,`food`,`橙子,橘子`],[`🍋`,`lemon`,`food`,`柠檬`],[`🍌`,`banana`,`food`,`香蕉`],[`🍍`,`pineapple`,`food`,`菠萝`],[`🍎`,`red apple`,`food`,`苹果`],[`🍏`,`green apple`,`food`,``],[`🍐`,`pear`,`food`,`梨`],[`🍑`,`peach`,`food`,`桃子,蜜桃`],[`🍒`,`cherries`,`food`,`樱桃,车厘子`],[`🍓`,`strawberry`,`food`,`草莓`],[`🍔`,`hamburger`,`food`,`汉堡,汉堡包`],[`🍕`,`slice of pizza`,`food`,`披萨,比萨`],[`🍖`,`meat on bone`,`food`,`骨头,肉,排骨`],[`🍗`,`poultry leg`,`food`,`鸡腿,炸鸡`],[`🍘`,`rice cracker`,`food`,`米饼,仙贝`],[`🍙`,`rice ball`,`food`,`饭团`],[`🍚`,`cooked rice`,`food`,`米饭,饭`],[`🍛`,`curry and rice`,`food`,`咖喱,咖喱饭`],[`🍜`,`steaming bowl`,`food`,`面条,拉面,面`],[`🍝`,`spaghetti`,`food`,`意大利面,意面`],[`🍞`,`bread`,`food`,`面包`],[`🍟`,`french fries`,`food`,`薯条,炸薯条`],[`🍠`,`roasted sweet potato`,`food`,`红薯,地瓜`],[`🍡`,`dango`,`food`,`团子,丸子`],[`🍢`,`oden`,`food`,`关东煮,串`],[`🍣`,`sushi`,`food`,`寿司,三文鱼`],[`🍤`,`fried shrimp`,`food`,`炸虾,天妇罗`],[`🍥`,`fish cake with swirl design`,`food`,`鱼板,鸣门卷`],[`🍦`,`soft ice cream`,`food`,`冰淇淋,甜筒`],[`🍧`,`shaved ice`,`food`,`刨冰,冰沙`],[`🍨`,`ice cream`,`food`,`冰淇淋,圣代`],[`🍩`,`doughnut`,`food`,``],[`🍪`,`cookie`,`food`,``],[`🍫`,`chocolate bar`,`food`,`巧克力`],[`🍬`,`candy`,`food`,`糖果,糖`],[`🍭`,`lollipop`,`food`,`棒棒糖`],[`🍮`,`custard`,`food`,`布丁,焦糖`],[`🍯`,`honey pot`,`food`,`蜂蜜,蜜`],[`🍰`,`shortcake`,`food`,`蛋糕,奶油蛋糕`],[`🍱`,`bento box`,`food`,`便当,盒饭`],[`🍲`,`pot of food`,`food`,`火锅,汤锅,炖菜`],[`🍳`,`cooking`,`food`,`煎蛋,鸡蛋`],[`🍴`,`fork and knife`,`food`,`刀叉,餐具`],[`🍵`,`teacup without handle`,`food`,`绿茶,茶,抹茶`],[`🍶`,`sake bottle and cup`,`food`,`清酒,日本酒`],[`🍷`,`wine glass`,`food`,`红酒,葡萄酒,酒`],[`🍸`,`cocktail glass`,`food`,`鸡尾酒,马提尼`],[`🍹`,`tropical drink`,`food`,`果汁,鸡尾酒`],[`🍺`,`beer mug`,`food`,`啤酒,啤酒杯`],[`🍻`,`clinking beer mugs`,`food`,`干杯,碰杯,啤酒`],[`🍼`,`baby bottle`,`food`,`奶瓶,婴儿,奶粉`],[`🍽`,`fork and knife with plate`,`food`,``],[`🍾`,`bottle with popping cork`,`food`,`香槟,起泡酒,庆祝`],[`🍿`,`popcorn`,`food`,``],[`🎀`,`ribbon`,`activity`,`蝴蝶结,礼物,装饰`],[`🎁`,`wrapped present`,`activity`,`礼物,礼盒,生日`],[`🎂`,`birthday cake`,`activity`,`生日蛋糕,生日,蛋糕`],[`🎃`,`jack-o-lantern`,`activity`,``],[`🎄`,`christmas tree`,`activity`,``],[`🎅`,`father christmas`,`activity`,`圣诞老人,圣诞,圣诞节`],[`🎆`,`fireworks`,`activity`,``],[`🎇`,`firework sparkler`,`activity`,``],[`🎈`,`balloon`,`activity`,`气球,庆祝,派对`],[`🎉`,`party popper`,`activity`,`彩带,庆祝,派对,欢呼`],[`🎊`,`confetti ball`,`activity`,`庆祝`],[`🎋`,`tanabata tree`,`activity`,``],[`🎌`,`crossed flags`,`flags`,`旗,日本,交叉旗`],[`🎍`,`pine decoration`,`activity`,``],[`🎎`,`japanese dolls`,`activity`,`人偶,日本人偶`],[`🎏`,`carp streamer`,`activity`,`鲤鱼旗,日本,端午节`],[`🎐`,`wind chime`,`activity`,`风铃,夏天`],[`🎑`,`moon viewing ceremony`,`activity`,``],[`🎒`,`school satchel`,`activity`,`书包,背包`],[`🎓`,`graduation cap`,`activity`,`学士帽,毕业,学位`],[`🎖`,`military medal`,`activity`,``],[`🎗`,`reminder ribbon`,`activity`,``],[`🎙`,`studio microphone`,`activity`,``],[`🎚`,`level slider`,`activity`,``],[`🎛`,`control knobs`,`activity`,``],[`🎞`,`film frames`,`activity`,``],[`🎟`,`admission tickets`,`activity`,``],[`🎠`,`carousel horse`,`activity`,`旋转木马,游乐园`],[`🎡`,`ferris wheel`,`activity`,`摩天轮,游乐园`],[`🎢`,`roller coaster`,`activity`,`过山车,游乐园`],[`🎣`,`fishing pole and fish`,`activity`,`钓鱼`],[`🎤`,`microphone`,`activity`,`麦克风,唱歌,K歌`],[`🎥`,`movie camera`,`activity`,`摄影机,电影,拍摄`],[`🎦`,`cinema`,`activity`,``],[`🎧`,`headphone`,`activity`,`耳机,听歌,音乐,戴`],[`🎨`,`artist palette`,`activity`,`调色板,画画,美术,艺术`],[`🎩`,`top hat`,`activity`,`礼帽,魔术帽,帽子`],[`🎪`,`circus tent`,`activity`,`马戏团`],[`🎫`,`ticket`,`activity`,`门票,票,入场券`],[`🎬`,`clapper board`,`activity`,`场记板,电影,拍戏,导演`],[`🎭`,`performing arts`,`activity`,`面具,戏剧,表演,舞台`],[`🎮`,`video game`,`activity`,`游戏机,游戏,手柄,玩`],[`🎯`,`direct hit`,`activity`,`目标`],[`🎰`,`slot machine`,`activity`,``],[`🎱`,`billiards`,`activity`,`台球`],[`🎲`,`game die`,`activity`,`骰子,赌博,游戏`],[`🎳`,`bowling`,`activity`,`保龄球,球`],[`🎴`,`flower playing cards`,`activity`,`花牌,卡牌,纸牌`],[`🎵`,`musical note`,`activity`,`音符,音乐,歌`],[`🎶`,`multiple musical notes`,`activity`,`音符,音乐,唱歌`],[`🎷`,`saxophone`,`activity`,`萨克斯,爵士,乐器`],[`🎸`,`guitar`,`activity`,`吉他,弹吉他,摇滚`],[`🎹`,`musical keyboard`,`activity`,`钢琴,键盘,弹琴`],[`🎺`,`trumpet`,`activity`,`小号,喇叭,乐器`],[`🎻`,`violin`,`activity`,`小提琴,弦乐`],[`🎼`,`musical score`,`activity`,`乐谱,音乐,谱`],[`🎽`,`running shirt with sash`,`activity`,`背心`],[`🎾`,`tennis racquet and ball`,`activity`,`网球,球`],[`🎿`,`ski and ski boot`,`activity`,`滑雪`],[`🏀`,`basketball and hoop`,`activity`,`篮球,球`],[`🏁`,`chequered flag`,`flags`,`终点,旗帜,赛车,比赛`],[`🏂`,`snowboarder`,`activity`,``],[`🏃`,`runner`,`activity`,`跑步,跑,奔跑`],[`🏄`,`surfer`,`activity`,``],[`🏅`,`sports medal`,`activity`,`奖牌,奖章,荣誉`],[`🏆`,`trophy`,`activity`,``],[`🏇`,`horse racing`,`activity`,``],[`🏈`,`american football`,`activity`,`橄榄球,美式足球`],[`🏉`,`rugby football`,`activity`,`橄榄球,英式`],[`🏊`,`swimmer`,`activity`,``],[`🏋`,`weight lifter`,`activity`,``],[`🏌`,`golfer`,`activity`,``],[`🏍`,`racing motorcycle`,`activity`,``],[`🏎`,`racing car`,`activity`,``],[`🏏`,`cricket bat and ball`,`activity`,``],[`🏐`,`volleyball`,`activity`,`排球,球`],[`🏑`,`field hockey stick and ball`,`activity`,``],[`🏒`,`ice hockey stick and puck`,`activity`,``],[`🏓`,`table tennis paddle and ball`,`activity`,`乒乓球,乒乓,球`],[`🏔`,`snow capped mountain`,`activity`,``],[`🏕`,`camping`,`activity`,``],[`🏖`,`beach with umbrella`,`activity`,``],[`🏗`,`building construction`,`activity`,``],[`🏘`,`house buildings`,`activity`,``],[`🏙`,`cityscape`,`activity`,``],[`🏚`,`derelict house building`,`activity`,``],[`🏛`,`classical building`,`activity`,``],[`🏜`,`desert`,`activity`,``],[`🏝`,`desert island`,`activity`,``],[`🏞`,`national park`,`activity`,``],[`🏟`,`stadium`,`activity`,``],[`🏠`,`house building`,`travel`,`房子,家,住宅`],[`🏡`,`house with garden`,`travel`,`房子,家,花园`],[`🏢`,`office building`,`travel`,`办公楼,大楼,写字楼`],[`🏣`,`japanese post office`,`travel`,`邮局,邮政`],[`🏤`,`european post office`,`travel`,`邮局`],[`🏥`,`hospital`,`travel`,`医院,医疗`],[`🏦`,`bank`,`travel`,`银行,金融`],[`🏧`,`automated teller machine`,`travel`,``],[`🏨`,`hotel`,`travel`,`酒店,旅馆`],[`🏩`,`love hotel`,`travel`,`爱情旅馆,酒店`],[`🏪`,`convenience store`,`travel`,`便利店,商店`],[`🏫`,`school`,`travel`,`学校,校园`],[`🏬`,`department store`,`travel`,`商场,百货,购物`],[`🏭`,`factory`,`travel`,`工厂,工业`],[`🏮`,`izakaya lantern`,`travel`,``],[`🏯`,`japanese castle`,`objects`,`城堡,日本城堡`],[`🏰`,`european castle`,`travel`,`城堡,童话`],[`🏳`,`waving white flag`,`flags`,``],[`🏴`,`waving black flag`,`flags`,`黑旗`],[`🏵`,`rosette`,`objects`,``],[`🏷`,`label`,`objects`,``],[`🏸`,`badminton racquet and shuttlecock`,`activity`,`羽毛球,球`],[`🏹`,`bow and arrow`,`activity`,`射箭,弓箭,弓`],[`🏺`,`amphora`,`activity`,`陶罐,花瓶,双耳瓶`],[`🏻`,`emoji modifier fitzpatrick type-1-2`,`symbols`,``],[`🏼`,`emoji modifier fitzpatrick type-3`,`symbols`,``],[`🏽`,`emoji modifier fitzpatrick type-4`,`symbols`,``],[`🏾`,`emoji modifier fitzpatrick type-5`,`symbols`,``],[`🏿`,`emoji modifier fitzpatrick type-6`,`symbols`,``],[`🐀`,`rat`,`animals`,`老鼠,鼠`],[`🐁`,`mouse`,`animals`,`老鼠,鼠`],[`🐂`,`ox`,`animals`,`公牛,牛`],[`🐃`,`water buffalo`,`animals`,`水牛,牛`],[`🐄`,`cow`,`animals`,`奶牛,牛`],[`🐅`,`tiger`,`animals`,``],[`🐆`,`leopard`,`animals`,``],[`🐇`,`rabbit`,`animals`,`兔子,兔`],[`🐈`,`cat`,`animals`,`猫,猫咪`],[`🐉`,`dragon`,`animals`,`龙,中国龙`],[`🐊`,`crocodile`,`animals`,`鳄鱼,短吻鳄`],[`🐋`,`whale`,`animals`,`鲸鱼`],[`🐌`,`snail`,`animals`,``],[`🐍`,`snake`,`animals`,`蛇,爬行动物`],[`🐎`,`horse`,`animals`,``],[`🐏`,`ram`,`animals`,`羊,公羊`],[`🐐`,`goat`,`animals`,`山羊,羊`],[`🐑`,`sheep`,`animals`,`羊,绵羊`],[`🐒`,`monkey`,`animals`,``],[`🐓`,`rooster`,`animals`,`公鸡,鸡`],[`🐔`,`chicken`,`animals`,`鸡,母鸡`],[`🐕`,`dog`,`animals`,`狗,小狗`],[`🐖`,`pig`,`animals`,`猪`],[`🐗`,`boar`,`animals`,`野猪,猪`],[`🐘`,`elephant`,`animals`,`大象`],[`🐙`,`octopus`,`animals`,`章鱼,八爪鱼`],[`🐚`,`spiral shell`,`animals`,``],[`🐛`,`bug`,`animals`,``],[`🐜`,`ant`,`animals`,``],[`🐝`,`honeybee`,`animals`,``],[`🐞`,`lady beetle`,`animals`,``],[`🐟`,`fish`,`animals`,`鱼,鱼`],[`🐠`,`tropical fish`,`animals`,`热带鱼,鱼`],[`🐡`,`blowfish`,`animals`,`河豚,鱼`],[`🐢`,`turtle`,`animals`,`乌龟,慢`],[`🐣`,`hatching chick`,`animals`,`小鸡,破壳,孵化`],[`🐤`,`baby chick`,`animals`,`小鸡,黄,可爱`],[`🐥`,`front-facing baby chick`,`animals`,`小鸡,正面`],[`🐦`,`bird`,`animals`,`鸟`],[`🐧`,`penguin`,`animals`,`企鹅,南极`],[`🐨`,`koala`,`animals`,`考拉,无尾熊`],[`🐩`,`poodle`,`animals`,`贵宾犬,狗`],[`🐪`,`dromedary camel`,`animals`,`骆驼`],[`🐫`,`bactrian camel`,`animals`,`骆驼,双峰`],[`🐬`,`dolphin`,`animals`,`海豚,海洋`],[`🐭`,`mouse face`,`animals`,`老鼠,鼠`],[`🐮`,`cow face`,`animals`,`牛,奶牛`],[`🐯`,`tiger face`,`animals`,``],[`🐰`,`rabbit face`,`animals`,`兔子,兔,可爱`],[`🐱`,`cat face`,`animals`,``],[`🐲`,`dragon face`,`animals`,`龙,龙头`],[`🐳`,`spouting whale`,`animals`,`鲸鱼,喷水`],[`🐴`,`horse face`,`animals`,`马`],[`🐵`,`monkey face`,`animals`,``],[`🐶`,`dog face`,`animals`,``],[`🐷`,`pig face`,`animals`,`猪,猪头`],[`🐸`,`frog face`,`animals`,`青蛙,蛙`],[`🐹`,`hamster face`,`animals`,`仓鼠`],[`🐺`,`wolf face`,`animals`,``],[`🐻`,`bear face`,`animals`,`熊,泰迪熊`],[`🐼`,`panda face`,`animals`,``],[`🐽`,`pig nose`,`animals`,`猪鼻子,猪`],[`🐾`,`paw prints`,`animals`,`爪印,脚印`],[`🐿`,`chipmunk`,`animals`,``],[`👀`,`eyes`,`people`,``],[`👁`,`eye`,`people`,``],[`👂`,`ear`,`people`,`耳朵,听`],[`👃`,`nose`,`people`,`鼻子,闻`],[`👄`,`mouth`,`people`,`嘴巴,嘴唇,吻`],[`👅`,`tongue`,`people`,`舌头,舔`],[`👆`,`white up pointing backhand index`,`people`,`指,上面,向上`],[`👇`,`white down pointing backhand index`,`people`,`指,下面,向下`],[`👈`,`white left pointing backhand index`,`people`,`指,左边,指向`],[`👉`,`white right pointing backhand index`,`people`,`指,右边,指向`],[`👊`,`fisted hand sign`,`people`,`拳头,打,战斗`],[`👋`,`waving hand sign`,`people`,`挥手,再见,你好`],[`👌`,`ok hand sign`,`people`,`OK,好,可以`],[`👍`,`thumbs up sign`,`people`,`点赞,好,赞,棒`],[`👎`,`thumbs down sign`,`people`,`差评,不好,踩`],[`👏`,`clapping hands sign`,`people`,`鼓掌,拍手,掌声`],[`👐`,`open hands sign`,`people`,`张开,手,开放`],[`👑`,`crown`,`people`,`皇冠,王冠,国王,女王`],[`👒`,`womans hat`,`people`,`帽子,草帽,遮阳帽`],[`👓`,`eyeglasses`,`people`,`眼镜`],[`👔`,`necktie`,`people`,`领带,西装,工作`],[`👕`,`t-shirt`,`people`,`衣服,T恤`],[`👖`,`jeans`,`people`,`裤子,牛仔裤`],[`👗`,`dress`,`people`,`裙子,连衣裙`],[`👘`,`kimono`,`people`,`和服`],[`👙`,`bikini`,`people`,`比基尼,泳装`],[`👚`,`womans clothes`,`people`,`女装,衣服`],[`👛`,`purse`,`people`,`钱包,小包`],[`👜`,`handbag`,`people`,`手提包,包包`],[`👝`,`pouch`,`people`,`手拿包,包包`],[`👞`,`mans shoe`,`people`,`皮鞋,鞋`],[`👟`,`athletic shoe`,`people`,`运动鞋,跑鞋`],[`👠`,`high-heeled shoe`,`people`,`高跟鞋,鞋`],[`👡`,`womans sandal`,`people`,`凉鞋,鞋`],[`👢`,`womans boots`,`people`,`靴子,长靴`],[`👣`,`footprints`,`people`,`脚印,脚步,足迹`],[`👤`,`bust in silhouette`,`people`,`人,剪影,用户`],[`👥`,`busts in silhouette`,`people`,`人群,人,多个人`],[`👦`,`boy`,`people`,`男孩,小男孩`],[`👧`,`girl`,`people`,`女孩,小女孩`],[`👨`,`man`,`people`,`男人,男士`],[`👩`,`woman`,`people`,`女人,女士`],[`👪`,`family`,`people`,`家庭`],[`👫`,`woman and man holding hands`,`people`,``],[`👬`,`men holding hands`,`people`,``],[`👭`,`women holding hands`,`people`,``],[`👮`,`police officer`,`people`,`警察,警官`],[`👯`,`woman with bunny ears`,`people`,`兔子舞,蹦迪,派对`],[`👰`,`bride with veil`,`people`,`新娘,婚纱,结婚`],[`👱`,`person with blond hair`,`people`,``],[`👲`,`man with gua pi mao`,`people`,`中国人`],[`👳`,`man with turban`,`people`,`包头巾,印度,阿拉伯`],[`👴`,`older man`,`people`,`老人,老爷爷`],[`👵`,`older woman`,`people`,`老人,老奶奶`],[`👶`,`baby`,`people`,`婴儿,宝宝,小孩`],[`👷`,`construction worker`,`people`,`工人`],[`👸`,`princess`,`people`,`公主,女王`],[`👹`,`japanese ogre`,`people`,`妖怪,鬼,怪物`],[`👺`,`japanese goblin`,`people`,`天狗,怪物,鬼`],[`👻`,`ghost`,`people`,`幽灵,鬼,万圣节`],[`👼`,`baby angel`,`people`,`天使,婴儿,可爱`],[`👽`,`extraterrestrial alien`,`people`,`外星人,ET,飞碟`],[`👾`,`alien monster`,`people`,`外星人,怪兽,游戏`],[`👿`,`imp`,`people`,`恶魔,愤怒`],[`💀`,`skull`,`people`,`骷髅,死亡,骨头`],[`💁`,`information desk person`,`people`,``],[`💂`,`guardsman`,`people`,`卫兵,士兵`],[`💃`,`dancer`,`people`,`跳舞,舞女,跳舞`],[`💄`,`lipstick`,`people`,`口红,化妆`],[`💅`,`nail polish`,`people`,`美甲,指甲,涂`],[`💆`,`face massage`,`people`,`按摩,放松,头部`],[`💇`,`haircut`,`people`,`理发,剪发,发型`],[`💈`,`barber pole`,`people`,`理发店,理发`],[`💉`,`syringe`,`people`,`注射器,针,疫苗`],[`💊`,`pill`,`people`,`药丸,药,胶囊`],[`💋`,`kiss mark`,`people`,`吻,口红印,亲亲`],[`💌`,`love letter`,`people`,`情书,信,爱情`],[`💍`,`ring`,`people`,`戒指,钻戒,结婚`],[`💎`,`gem stone`,`people`,`钻石,宝石,珠宝`],[`💏`,`kiss`,`people`,``],[`💐`,`bouquet`,`smileys`,`花束,花,礼物`],[`💑`,`couple with heart`,`smileys`,``],[`💒`,`wedding`,`smileys`,`教堂,婚礼,教堂婚礼`],[`💓`,`beating heart`,`smileys`,`爱心,跳动,心跳`],[`💔`,`broken heart`,`smileys`,`心碎,伤心,破碎`],[`💕`,`two hearts`,`smileys`,`爱心,两个,喜欢`],[`💖`,`sparkling heart`,`smileys`,`爱心,闪光,喜欢`],[`💗`,`growing heart`,`smileys`,`爱心,跳动,喜欢`],[`💘`,`heart with arrow`,`smileys`,`爱心,箭,丘比特`],[`💙`,`blue heart`,`smileys`,``],[`💚`,`green heart`,`smileys`,``],[`💛`,`yellow heart`,`smileys`,``],[`💜`,`purple heart`,`smileys`,``],[`💝`,`heart with ribbon`,`smileys`,`爱心,礼物,蝴蝶结`],[`💞`,`revolving hearts`,`smileys`,`爱心,旋转,轮回`],[`💟`,`heart decoration`,`smileys`,`爱心,符号`],[`💠`,`diamond shape with a dot inside`,`objects`,``],[`💡`,`electric light bulb`,`objects`,``],[`💢`,`anger symbol`,`objects`,`生气,怒气`],[`💣`,`bomb`,`objects`,`炸弹,爆炸`],[`💤`,`sleeping symbol`,`objects`,`睡觉,打呼,困`],[`💥`,`collision symbol`,`objects`,``],[`💦`,`splashing sweat symbol`,`objects`,`汗,水,泪`],[`💧`,`droplet`,`objects`,`水滴,水,眼泪`],[`💨`,`dash symbol`,`objects`,`风,跑,快,烟雾`],[`💩`,`pile of poo`,`objects`,`大便,屎,狗屎`],[`💪`,`flexed biceps`,`people`,`肌肉,力量,加油,强壮`],[`💫`,`dizzy symbol`,`objects`,`星星,旋转`],[`💬`,`speech balloon`,`objects`,`对话,聊天`],[`💭`,`thought balloon`,`objects`,`想法,思考,气泡`],[`💮`,`white flower`,`objects`,``],[`💯`,`hundred points symbol`,`objects`,``],[`💰`,`money bag`,`objects`,`钱袋,钱,金钱`],[`💱`,`currency exchange`,`objects`,``],[`💲`,`heavy dollar sign`,`objects`,``],[`💳`,`credit card`,`objects`,`信用卡,银行卡,支付`],[`💴`,`banknote with yen sign`,`objects`,`日元,日圆,钱`],[`💵`,`banknote with dollar sign`,`objects`,`美元,美金,钱`],[`💶`,`banknote with euro sign`,`objects`,`欧元,钱`],[`💷`,`banknote with pound sign`,`objects`,`英镑,钱`],[`💸`,`money with wings`,`objects`,`钱,飞钱,花钱`],[`💹`,`chart with upwards trend and yen sign`,`objects`,`股票,上涨,图表,增长`],[`💺`,`seat`,`objects`,`座位,椅子,飞机座位`],[`💻`,`personal computer`,`objects`,`电脑,笔记本,笔记本电脑`],[`💼`,`briefcase`,`objects`,`公文包,工作,商务`],[`💽`,`minidisc`,`objects`,`光盘,磁盘`],[`💾`,`floppy disk`,`objects`,`软盘,保存`],[`💿`,`optical disc`,`objects`,`光盘,CD`],[`📀`,`dvd`,`objects`,`光盘,DVD`],[`📁`,`file folder`,`objects`,`文件夹`],[`📂`,`open file folder`,`objects`,`文件夹,打开`],[`📃`,`page with curl`,`objects`,`文件,文档`],[`📄`,`page facing up`,`objects`,`文件,文档,纸`],[`📅`,`calendar`,`objects`,`日历`],[`📆`,`tear-off calendar`,`objects`,`日历,日历页`],[`📇`,`card index`,`objects`,`名片,索引卡`],[`📈`,`chart with upwards trend`,`objects`,``],[`📉`,`chart with downwards trend`,`objects`,``],[`📊`,`bar chart`,`objects`,``],[`📋`,`clipboard`,`objects`,`剪贴板,清单,列表`],[`📌`,`pushpin`,`objects`,``],[`📍`,`round pushpin`,`objects`,``],[`📎`,`paperclip`,`objects`,``],[`📏`,`straight ruler`,`objects`,``],[`📐`,`triangular ruler`,`objects`,``],[`📑`,`bookmark tabs`,`objects`,`书签,标签,文件`],[`📒`,`ledger`,`objects`,``],[`📓`,`notebook`,`objects`,``],[`📔`,`notebook with decorative cover`,`objects`,``],[`📕`,`closed book`,`objects`,``],[`📖`,`open book`,`objects`,``],[`📗`,`green book`,`objects`,``],[`📘`,`blue book`,`objects`,``],[`📙`,`orange book`,`objects`,``],[`📚`,`books`,`objects`,``],[`📛`,`name badge`,`objects`,``],[`📜`,`scroll`,`objects`,``],[`📝`,`memo`,`objects`,`笔记,备忘录,写作,文档`],[`📞`,`telephone receiver`,`objects`,`电话`],[`📟`,`pager`,`objects`,`寻呼机,传呼机`],[`📠`,`fax machine`,`objects`,`传真机,传真`],[`📡`,`satellite antenna`,`objects`,`天线,卫星,信号`],[`📢`,`public address loudspeaker`,`objects`,``],[`📣`,`cheering megaphone`,`objects`,``],[`📤`,`outbox tray`,`objects`,`发送,输出,上传`],[`📥`,`inbox tray`,`objects`,`接收,下载,收件箱`],[`📦`,`package`,`objects`,`包裹,快递,箱子`],[`📧`,`e-mail symbol`,`objects`,`邮件,电子邮件`],[`📨`,`incoming envelope`,`objects`,`邮件,收到`],[`📩`,`envelope with downwards arrow above`,`objects`,`邮件,发送`],[`📪`,`closed mailbox with lowered flag`,`objects`,`邮箱,关闭`],[`📫`,`closed mailbox with raised flag`,`objects`,`邮箱,信箱,邮件`],[`📬`,`open mailbox with raised flag`,`objects`,`邮箱,有信`],[`📭`,`open mailbox with lowered flag`,`objects`,`邮箱,无信`],[`📮`,`postbox`,`objects`,`邮筒,邮政`],[`📯`,`postal horn`,`objects`,``],[`📰`,`newspaper`,`objects`,`报纸,新闻,报`],[`📱`,`mobile phone`,`objects`,`手机,智能手机,电话`],[`📲`,`mobile phone with rightwards arrow at left`,`objects`,`手机,接收,信号`],[`📳`,`vibration mode`,`objects`,``],[`📴`,`mobile phone off`,`objects`,``],[`📵`,`no mobile phones`,`objects`,``],[`📶`,`antenna with bars`,`objects`,``],[`📷`,`camera`,`objects`,`相机,拍照,照片`],[`📸`,`camera with flash`,`objects`,`相机,闪光灯,拍照`],[`📹`,`video camera`,`objects`,`摄像机,录像`],[`📺`,`television`,`objects`,``],[`📻`,`radio`,`objects`,`收音机,广播`],[`📼`,`videocassette`,`objects`,`录像带,磁带`],[`📽`,`film projector`,`objects`,``],[`📿`,`prayer beads`,`objects`,`念珠,佛珠,项链`],[`🔀`,`twisted rightwards arrows`,`objects`,``],[`🔁`,`clockwise rightwards and leftwards open circle arrows`,`objects`,``],[`🔂`,`clockwise rightwards and leftwards open circle arrows with circled one overlay`,`objects`,``],[`🔃`,`clockwise downwards and upwards open circle arrows`,`objects`,``],[`🔄`,`anticlockwise downwards and upwards open circle arrows`,`objects`,``],[`🔅`,`low brightness symbol`,`objects`,``],[`🔆`,`high brightness symbol`,`objects`,``],[`🔇`,`speaker with cancellation stroke`,`objects`,``],[`🔈`,`speaker`,`objects`,``],[`🔉`,`speaker with one sound wave`,`objects`,``],[`🔊`,`speaker with three sound waves`,`objects`,``],[`🔋`,`battery`,`objects`,``],[`🔌`,`electric plug`,`objects`,``],[`🔍`,`left-pointing magnifying glass`,`objects`,`搜索,放大镜,查找,查询`],[`🔎`,`right-pointing magnifying glass`,`objects`,`搜索,放大镜,查找`],[`🔏`,`lock with ink pen`,`objects`,`锁,保密,笔`],[`🔐`,`closed lock with key`,`objects`,`锁,安全,钥匙`],[`🔑`,`key`,`objects`,`钥匙,解锁`],[`🔒`,`lock`,`objects`,`锁,锁定,安全`],[`🔓`,`open lock`,`objects`,`解锁,打开`],[`🔔`,`bell`,`objects`,``],[`🔕`,`bell with cancellation stroke`,`objects`,``],[`🔖`,`bookmark`,`objects`,`书签,标记`],[`🔗`,`link symbol`,`objects`,``],[`🔘`,`radio button`,`objects`,``],[`🔙`,`back with leftwards arrow above`,`objects`,``],[`🔚`,`end with leftwards arrow above`,`objects`,``],[`🔛`,`on with exclamation mark with left right arrow above`,`objects`,``],[`🔜`,`soon with rightwards arrow above`,`objects`,``],[`🔝`,`top with upwards arrow above`,`objects`,``],[`🔞`,`no one under eighteen symbol`,`objects`,``],[`🔟`,`keycap 10`,`objects`,``],[`🔠`,`input symbol for latin capital letters`,`objects`,``],[`🔡`,`input symbol for latin small letters`,`objects`,``],[`🔢`,`input symbol for numbers`,`objects`,``],[`🔣`,`input symbol for symbols`,`objects`,``],[`🔤`,`input symbol for latin letters`,`objects`,``],[`🔥`,`fire`,`objects`,``],[`🔦`,`electric torch`,`objects`,``],[`🔧`,`wrench`,`objects`,`扳手,工具,维修`],[`🔨`,`hammer`,`objects`,`锤子,工具`],[`🔩`,`nut and bolt`,`objects`,`螺丝,螺母`],[`🔪`,`hocho`,`objects`,``],[`🔫`,`pistol`,`objects`,`枪`],[`🔬`,`microscope`,`objects`,`显微镜,科学,研究`],[`🔭`,`telescope`,`objects`,`望远镜,天文,观察`],[`🔮`,`crystal ball`,`objects`,``],[`🔯`,`six pointed star with middle dot`,`objects`,``],[`🔰`,`japanese symbol for beginner`,`objects`,``],[`🔱`,`trident emblem`,`objects`,``],[`🔲`,`black square button`,`objects`,``],[`🔳`,`white square button`,`objects`,``],[`🔴`,`large red circle`,`objects`,``],[`🔵`,`large blue circle`,`objects`,``],[`🔶`,`large orange diamond`,`objects`,``],[`🔷`,`large blue diamond`,`objects`,``],[`🔸`,`small orange diamond`,`objects`,``],[`🔹`,`small blue diamond`,`objects`,``],[`🔺`,`up-pointing red triangle`,`objects`,``],[`🔻`,`down-pointing red triangle`,`objects`,``],[`🔼`,`up-pointing small red triangle`,`objects`,``],[`🔽`,`down-pointing small red triangle`,`objects`,``],[`🕉`,`om symbol`,`objects`,``],[`🕊`,`dove of peace`,`objects`,``],[`🕋`,`kaaba`,`objects`,`天房,麦加,伊斯兰`],[`🕌`,`mosque`,`objects`,`清真寺,伊斯兰`],[`🕍`,`synagogue`,`objects`,`犹太教堂,犹太`],[`🕎`,`menorah with nine branches`,`objects`,``],[`🕐`,`clock face one oclock`,`objects`,`一点,时钟`],[`🕑`,`clock face two oclock`,`objects`,`两点,时钟`],[`🕒`,`clock face three oclock`,`objects`,`三点,时钟`],[`🕓`,`clock face four oclock`,`objects`,`四点,时钟`],[`🕔`,`clock face five oclock`,`objects`,`五点,时钟`],[`🕕`,`clock face six oclock`,`objects`,`六点,时钟`],[`🕖`,`clock face seven oclock`,`objects`,`七点,时钟`],[`🕗`,`clock face eight oclock`,`objects`,`八点,时钟`],[`🕘`,`clock face nine oclock`,`objects`,`九点,时钟`],[`🕙`,`clock face ten oclock`,`objects`,`十点,时钟`],[`🕚`,`clock face eleven oclock`,`objects`,`十一点,时钟`],[`🕛`,`clock face twelve oclock`,`objects`,`十二点,时钟,时间`],[`🕜`,`clock face one-thirty`,`objects`,``],[`🕝`,`clock face two-thirty`,`objects`,``],[`🕞`,`clock face three-thirty`,`objects`,``],[`🕟`,`clock face four-thirty`,`objects`,``],[`🕠`,`clock face five-thirty`,`objects`,``],[`🕡`,`clock face six-thirty`,`objects`,``],[`🕢`,`clock face seven-thirty`,`objects`,``],[`🕣`,`clock face eight-thirty`,`objects`,``],[`🕤`,`clock face nine-thirty`,`objects`,``],[`🕥`,`clock face ten-thirty`,`objects`,``],[`🕦`,`clock face eleven-thirty`,`objects`,``],[`🕧`,`clock face twelve-thirty`,`objects`,``],[`🕯`,`candle`,`objects`,``],[`🕰`,`mantelpiece clock`,`objects`,``],[`🕳`,`hole`,`objects`,``],[`🕴`,`man in business suit levitating`,`objects`,``],[`🕵`,`sleuth or spy`,`objects`,``],[`🕶`,`dark sunglasses`,`objects`,``],[`🕷`,`spider`,`objects`,``],[`🕸`,`spider web`,`objects`,``],[`🕹`,`joystick`,`objects`,``],[`🕺`,`man dancing`,`objects`,`跳舞,舞男`],[`🖇`,`linked paperclips`,`objects`,``],[`🖊`,`lower left ballpoint pen`,`objects`,``],[`🖋`,`lower left fountain pen`,`objects`,``],[`🖌`,`lower left paintbrush`,`objects`,``],[`🖍`,`lower left crayon`,`objects`,``],[`🖐`,`raised hand with fingers splayed`,`objects`,``],[`🖕`,`reversed hand with middle finger extended`,`objects`,`中指,骂人`],[`🖖`,`raised hand with part between middle and ring fingers`,`objects`,`瓦肯,举手,胜利`],[`🖤`,`black heart`,`objects`,``],[`🖥`,`desktop computer`,`objects`,``],[`🖨`,`printer`,`objects`,``],[`🖱`,`three button mouse`,`objects`,``],[`🖲`,`trackball`,`objects`,``],[`🖼`,`frame with picture`,`objects`,``],[`🗂`,`card index dividers`,`objects`,``],[`🗃`,`card file box`,`objects`,``],[`🗄`,`file cabinet`,`objects`,``],[`🗑`,`wastebasket`,`objects`,``],[`🗒`,`spiral note pad`,`objects`,``],[`🗓`,`spiral calendar pad`,`objects`,``],[`🗜`,`compression`,`objects`,``],[`🗝`,`old key`,`objects`,``],[`🗞`,`rolled-up newspaper`,`objects`,``],[`🗡`,`dagger knife`,`objects`,``],[`🗣`,`speaking head in silhouette`,`objects`,``],[`🗨`,`left speech bubble`,`objects`,``],[`🗯`,`right anger bubble`,`objects`,``],[`🗳`,`ballot box with ballot`,`objects`,``],[`🗺`,`world map`,`objects`,``],[`🗻`,`mount fuji`,`objects`,`富士山,山`],[`🗼`,`tokyo tower`,`objects`,`塔,东京塔`],[`🗽`,`statue of liberty`,`objects`,`自由女神像,纽约`],[`🗾`,`silhouette of japan`,`objects`,``],[`🗿`,`moyai`,`objects`,`雕像`],[`😀`,`grinning face`,`smileys`,`笑脸,开心,高兴`],[`😁`,`grinning face with smiling eyes`,`smileys`,`笑脸,开心`],[`😂`,`face with tears of joy`,`smileys`,`笑哭,大笑,笑`],[`😃`,`smiling face with open mouth`,`smileys`,`笑脸,开心`],[`😄`,`smiling face with open mouth and smiling eyes`,`smileys`,`笑脸,开心`],[`😅`,`smiling face with open mouth and cold sweat`,`smileys`,`笑脸,汗,尴尬`],[`😆`,`smiling face with open mouth and tightly-closed eyes`,`smileys`,`笑脸,大笑`],[`😇`,`smiling face with halo`,`smileys`,`天使,微笑,善良`],[`😈`,`smiling face with horns`,`smileys`,`恶魔,坏笑,邪恶`],[`😉`,`winking face`,`smileys`,`眨眼,调皮`],[`😊`,`smiling face with smiling eyes`,`smileys`,`微笑,开心,脸红`],[`😋`,`face savouring delicious food`,`smileys`,`好吃,美味,舔`],[`😌`,`relieved face`,`smileys`,`放松,安心`],[`😍`,`smiling face with heart-shaped eyes`,`smileys`,`爱,喜欢,花痴`],[`😎`,`smiling face with sunglasses`,`smileys`,`酷,墨镜,帅气`],[`😏`,`smirking face`,`smileys`,`得意,微笑,坏笑`],[`😐`,`neutral face`,`smileys`,`无语,面无表情`],[`😑`,`expressionless face`,`smileys`,`无语,面无表情`],[`😒`,`unamused face`,`smileys`,`不满,无语,翻白眼`],[`😓`,`face with cold sweat`,`smileys`,`冷汗,尴尬`],[`😔`,`pensive face`,`smileys`,`难过,低落`],[`😕`,`confused face`,`smileys`,`困惑,不解`],[`😖`,`confounded face`,`smileys`,`纠结,痛苦`],[`😗`,`kissing face`,`smileys`,`亲亲,吻`],[`😘`,`face throwing a kiss`,`smileys`,`飞吻,亲亲,爱`],[`😙`,`kissing face with smiling eyes`,`smileys`,``],[`😚`,`kissing face with closed eyes`,`smileys`,`亲亲,吻`],[`😛`,`face with stuck-out tongue`,`smileys`,`吐舌头,调皮`],[`😜`,`face with stuck-out tongue and winking eye`,`smileys`,`吐舌头,调皮,眨眼`],[`😝`,`face with stuck-out tongue and tightly-closed eyes`,`smileys`,`吐舌头,调皮`],[`😞`,`disappointed face`,`smileys`,`失望,难过`],[`😟`,`worried face`,`smileys`,`担心,忧虑`],[`😠`,`angry face`,`smileys`,`生气,愤怒`],[`😡`,`pouting face`,`smileys`,`生气,愤怒,红脸`],[`😢`,`crying face`,`smileys`,`哭,伤心,流泪`],[`😣`,`persevering face`,`smileys`,`挣扎,痛苦`],[`😤`,`face with look of triumph`,`smileys`,`生气,冒烟,气`],[`😥`,`disappointed but relieved face`,`smileys`,`难过,失望,松气`],[`😦`,`frowning face with open mouth`,`smileys`,`惊讶,张嘴`],[`😧`,`anguished face`,`smileys`,`震惊,痛苦`],[`😨`,`fearful face`,`smileys`,`害怕,恐惧`],[`😩`,`weary face`,`smileys`,`累,疲惫,哭`],[`😪`,`sleepy face`,`smileys`,`困,想睡`],[`😫`,`tired face`,`smileys`,`累,疲惫`],[`😬`,`grimacing face`,`smileys`,`尴尬,咧嘴`],[`😭`,`loudly crying face`,`smileys`,`大哭,伤心,哭`],[`😮`,`face with open mouth`,`smileys`,`惊讶,哇`],[`😯`,`hushed face`,`smileys`,`惊讶,安静`],[`😰`,`face with open mouth and cold sweat`,`smileys`,`担心,冷汗`],[`😱`,`face screaming in fear`,`smileys`,`尖叫,害怕,恐怖`],[`😲`,`astonished face`,`smileys`,`震惊,惊讶`],[`😳`,`flushed face`,`smileys`,`脸红,害羞,震惊`],[`😴`,`sleeping face`,`smileys`,`睡觉,睡觉`],[`😵`,`dizzy face`,`smileys`,`晕,头晕,死`],[`😶`,`face without mouth`,`smileys`,`沉默,无语`],[`😷`,`face with medical mask`,`smileys`,`生病,口罩,感冒`],[`😸`,`grinning cat face with smiling eyes`,`smileys`,`猫,笑脸`],[`😹`,`cat face with tears of joy`,`smileys`,`猫,笑哭`],[`😺`,`smiling cat face with open mouth`,`smileys`,`猫,笑脸,开心`],[`😻`,`smiling cat face with heart-shaped eyes`,`smileys`,`猫,爱,喜欢`],[`😼`,`cat face with wry smile`,`smileys`,`猫,坏笑`],[`😽`,`kissing cat face with closed eyes`,`smileys`,`猫,亲亲`],[`😾`,`pouting cat face`,`smileys`,`猫,生气`],[`😿`,`crying cat face`,`smileys`,`猫,哭,伤心`],[`🙀`,`weary cat face`,`smileys`,`猫,震惊,害怕`],[`🙁`,`slightly frowning face`,`smileys`,`难过,失望`],[`🙂`,`slightly smiling face`,`smileys`,`微笑,笑`],[`🙃`,`upside-down face`,`smileys`,`微笑,倒`],[`🙄`,`face with rolling eyes`,`smileys`,`翻白眼,无语`],[`🙅`,`face with no good gesture`,`smileys`,``],[`🙆`,`face with ok gesture`,`smileys`,``],[`🙇`,`person bowing deeply`,`smileys`,``],[`🙈`,`see-no-evil monkey`,`smileys`,``],[`🙉`,`hear-no-evil monkey`,`smileys`,``],[`🙊`,`speak-no-evil monkey`,`smileys`,``],[`🙋`,`happy person raising one hand`,`smileys`,``],[`🙌`,`person raising both hands in celebration`,`smileys`,`欢呼,举起,庆祝`],[`🙍`,`person frowning`,`smileys`,``],[`🙎`,`person with pouting face`,`smileys`,``],[`🙏`,`person with folded hands`,`smileys`,`祈祷,拜托,感谢,合十`],[`🚀`,`rocket`,`travel`,`火箭,发射,太空`],[`🚁`,`helicopter`,`travel`,`直升机`],[`🚂`,`steam locomotive`,`travel`,`火车,蒸汽火车`],[`🚃`,`railway car`,`travel`,`电车,火车`],[`🚄`,`high-speed train`,`travel`,`高铁,动车,火车`],[`🚅`,`high-speed train with bullet nose`,`travel`,``],[`🚆`,`train`,`travel`,`火车,铁路`],[`🚇`,`metro`,`travel`,`地铁,地铁站`],[`🚈`,`light rail`,`travel`,`轻轨,轨道交通`],[`🚉`,`station`,`travel`,`火车站,车站`],[`🚊`,`tram`,`travel`,`电车`],[`🚋`,`tram car`,`travel`,`电车,有轨电车`],[`🚌`,`bus`,`travel`,`公交车,巴士`],[`🚍`,`oncoming bus`,`travel`,`公交车`],[`🚎`,`trolleybus`,`travel`,`无轨电车,巴士`],[`🚏`,`bus stop`,`travel`,`公交站,车站`],[`🚐`,`minibus`,`travel`,`面包车,小巴`],[`🚑`,`ambulance`,`travel`,`救护车,急救`],[`🚒`,`fire engine`,`travel`,`消防车,救火`],[`🚓`,`police car`,`travel`,`警车,警察`],[`🚔`,`oncoming police car`,`travel`,`警车,巡逻`],[`🚕`,`taxi`,`travel`,`出租车,的士`],[`🚖`,`oncoming taxi`,`travel`,`出租车`],[`🚗`,`automobile`,`travel`,`汽车,轿车,车`],[`🚘`,`oncoming automobile`,`travel`,`汽车`],[`🚙`,`recreational vehicle`,`travel`,`SUV,越野车,汽车`],[`🚚`,`delivery truck`,`travel`,`卡车,货车`],[`🚛`,`articulated lorry`,`travel`,`卡车,货车`],[`🚜`,`tractor`,`travel`,`拖拉机,农用`],[`🚝`,`monorail`,`travel`,`单轨,单轨列车`],[`🚞`,`mountain railway`,`travel`,`火车,山区铁路`],[`🚟`,`suspension railway`,`travel`,`缆车,悬挂列车`],[`🚠`,`mountain cableway`,`travel`,`缆车,高山`],[`🚡`,`aerial tramway`,`travel`,`缆车,索道`],[`🚢`,`ship`,`travel`,`轮船,船,大海`],[`🚣`,`rowboat`,`travel`,``],[`🚤`,`speedboat`,`travel`,`快艇,汽艇`],[`🚥`,`horizontal traffic light`,`travel`,`红绿灯,交通信号灯`],[`🚦`,`vertical traffic light`,`travel`,`红绿灯,信号灯`],[`🚧`,`construction sign`,`travel`,`施工,施工中,路障`],[`🚨`,`police cars revolving light`,`travel`,`警车灯,警报,紧急`],[`🚩`,`triangular flag on post`,`travel`,`红旗,旗帜,标志`],[`🚪`,`door`,`travel`,`门,房门`],[`🚫`,`no entry sign`,`travel`,``],[`🚬`,`smoking symbol`,`travel`,`香烟,烟,吸烟`],[`🚭`,`no smoking symbol`,`travel`,``],[`🚮`,`put litter in its place symbol`,`travel`,`垃圾,清理`],[`🚯`,`do not litter symbol`,`travel`,``],[`🚰`,`potable water symbol`,`travel`,``],[`🚱`,`non-potable water symbol`,`travel`,``],[`🚲`,`bicycle`,`travel`,`自行车,单车,骑行`],[`🚳`,`no bicycles`,`travel`,``],[`🚴`,`bicyclist`,`travel`,``],[`🚵`,`mountain bicyclist`,`travel`,``],[`🚶`,`pedestrian`,`travel`,`走路,步行,散步`],[`🚷`,`no pedestrians`,`travel`,``],[`🚸`,`children crossing`,`travel`,``],[`🚹`,`mens symbol`,`travel`,``],[`🚺`,`womens symbol`,`travel`,``],[`🚻`,`restroom`,`travel`,``],[`🚼`,`baby symbol`,`travel`,``],[`🚽`,`toilet`,`travel`,`马桶,厕所,卫生间`],[`🚾`,`water closet`,`travel`,``],[`🚿`,`shower`,`travel`,`淋浴,洗澡`],[`🛀`,`bath`,`travel`,`泡澡`],[`🛁`,`bathtub`,`travel`,`浴缸,洗澡,泡澡`],[`🛂`,`passport control`,`travel`,``],[`🛃`,`customs`,`travel`,``],[`🛄`,`baggage claim`,`travel`,``],[`🛅`,`left luggage`,`travel`,``],[`🛋`,`couch and lamp`,`travel`,``],[`🛌`,`sleeping accommodation`,`travel`,`睡觉`],[`🛍`,`shopping bags`,`travel`,``],[`🛎`,`bellhop bell`,`travel`,``],[`🛏`,`bed`,`travel`,``],[`🛐`,`place of worship`,`travel`,``],[`🛑`,`octagonal sign`,`travel`,`停止,停车,红圈`],[`🛒`,`shopping trolley`,`travel`,`购物车,购物`],[`🛕`,`hindu temple`,`travel`,`印度教神庙`],[`🛖`,`hut`,`travel`,`草屋,小屋`],[`🛗`,`elevator`,`travel`,``],[`🛜`,`wireless`,`travel`,``],[`🛝`,`playground slide`,`travel`,``],[`🛞`,`wheel`,`travel`,`车轮,轮胎`],[`🛟`,`ring buoy`,`travel`,`救生圈,救生`],[`🛠`,`hammer and wrench`,`travel`,``],[`🛡`,`shield`,`travel`,``],[`🛢`,`oil drum`,`travel`,``],[`🛣`,`motorway`,`travel`,``],[`🛤`,`railway track`,`travel`,``],[`🛥`,`motor boat`,`travel`,``],[`🛩`,`small airplane`,`travel`,``],[`🛫`,`airplane departure`,`travel`,`起飞,飞机,出发`],[`🛬`,`airplane arriving`,`travel`,`降落,飞机,到达`],[`🛰`,`satellite`,`travel`,``],[`🛳`,`passenger ship`,`travel`,``],[`🛴`,`scooter`,`travel`,`滑板车,平衡车`],[`🛵`,`motor scooter`,`travel`,`摩托车,电动车,踏板车`],[`🛶`,`canoe`,`travel`,`独木舟,皮划艇`],[`🛷`,`sled`,`travel`,`雪橇,雪车`],[`🛸`,`flying saucer`,`travel`,`飞碟,UFO,外星人`],[`🛹`,`skateboard`,`travel`,`滑板`],[`🛺`,`auto rickshaw`,`travel`,`三轮车,突突车`],[`🛻`,`pickup truck`,`travel`,`皮卡,卡车`],[`🛼`,`roller skate`,`travel`,`轮滑`],[`🟠`,`large orange circle`,`symbols`,``],[`🟡`,`large yellow circle`,`symbols`,``],[`🟢`,`large green circle`,`symbols`,``],[`🟣`,`large purple circle`,`symbols`,``],[`🟤`,`large brown circle`,`symbols`,``],[`🟥`,`large red square`,`symbols`,``],[`🟦`,`large blue square`,`symbols`,``],[`🟧`,`large orange square`,`symbols`,``],[`🟨`,`large yellow square`,`symbols`,``],[`🟩`,`large green square`,`symbols`,``],[`🟪`,`large purple square`,`symbols`,``],[`🟫`,`large brown square`,`symbols`,``],[`🟰`,`heavy equals sign`,`symbols`,``],[`🤌`,`pinched fingers`,`symbols`,`手指,捏,意大利`],[`🤍`,`white heart`,`symbols`,`白心,白色,爱心`],[`🤎`,`brown heart`,`symbols`,`棕心,棕色,爱心`],[`🤏`,`pinching hand`,`symbols`,`捏,一点点,微小`],[`🤐`,`zipper-mouth face`,`smileys`,`闭嘴,不说`],[`🤑`,`money-mouth face`,`smileys`,`发财,金钱,贪婪`],[`🤒`,`face with thermometer`,`smileys`,`发烧,生病,温度计`],[`🤓`,`nerd face`,`smileys`,`书呆子,眼镜`],[`🤔`,`thinking face`,`smileys`,`思考,疑问,想`],[`🤕`,`face with head-bandage`,`smileys`,`受伤,包扎,头`],[`🤖`,`robot face`,`smileys`,`机器人,AI,机械`],[`🤗`,`hugging face`,`smileys`,`拥抱,欢迎`],[`🤘`,`sign of the horns`,`smileys`,`摇滚,手势,牛`],[`🤙`,`call me hand`,`smileys`,`打电话,挂,酷`],[`🤚`,`raised back of hand`,`smileys`,`手,举手,停`],[`🤛`,`left-facing fist`,`smileys`,`拳头,左边`],[`🤜`,`right-facing fist`,`smileys`,`拳头,右边`],[`🤝`,`handshake`,`smileys`,`握手,合作,协议`],[`🤞`,`hand with index and middle fingers crossed`,`smileys`,`祈祷,好运,手指交叉`],[`🤟`,`i love you hand sign`,`smileys`,`爱你,摇滚`],[`🤠`,`face with cowboy hat`,`smileys`,`牛仔,帽子`],[`🤡`,`clown face`,`smileys`,`小丑,马戏团`],[`🤢`,`nauseated face`,`smileys`,`恶心,呕吐`],[`🤣`,`rolling on the floor laughing`,`smileys`,`笑哭,大笑,笑`],[`🤤`,`drooling face`,`smileys`,`流口水,馋`],[`🤥`,`lying face`,`smileys`,`说谎,撒谎`],[`🤦`,`face palm`,`smileys`,`捂脸,无奈,扶额`],[`🤧`,`sneezing face`,`smileys`,`打喷嚏,感冒`],[`🤨`,`face with one eyebrow raised`,`symbols`,`怀疑,挑眉`],[`🤩`,`grinning face with star eyes`,`symbols`,`星星眼,兴奋,惊讶`],[`🤪`,`grinning face with one large and one small eye`,`symbols`,`疯狂,搞怪`],[`🤫`,`face with finger covering closed lips`,`symbols`,`嘘,安静`],[`🤬`,`serious face with symbols covering mouth`,`symbols`,`骂人,脏话,生气`],[`🤭`,`smiling face with smiling eyes and hand covering mouth`,`symbols`,`捂嘴,偷笑,惊讶`],[`🤮`,`face with open mouth vomiting`,`symbols`,`呕吐,恶心`],[`🤯`,`shocked face with exploding head`,`smileys`,`爆炸,震惊,头炸`],[`🤰`,`pregnant woman`,`people`,`孕妇,怀孕`],[`🤱`,`breast-feeding`,`people`,``],[`🤲`,`palms up together`,`people`,``],[`🤳`,`selfie`,`people`,`自拍,拍照`],[`🤴`,`prince`,`people`,`王子,国王`],[`🤵`,`man in tuxedo`,`people`,`新郎,西装,燕尾服`],[`🤶`,`mother christmas`,`people`,`圣诞奶奶,圣诞老人`],[`🤷`,`shrug`,`people`,`耸肩,无奈,不知道`],[`🤸`,`person doing cartwheel`,`people`,`翻跟头,体操,空翻`],[`🤹`,`juggling`,`people`,`杂耍`],[`🤺`,`fencer`,`people`,`击剑,剑术`],[`🤼`,`wrestlers`,`activity`,`摔跤,格斗`],[`🤽`,`water polo`,`activity`,``],[`🤾`,`handball`,`activity`,``],[`🤿`,`diving mask`,`activity`,`潜水面罩,潜水`],[`🥀`,`wilted flower`,`symbols`,``],[`🥁`,`drum with drumsticks`,`symbols`,`鼓,打鼓,乐器`],[`🥂`,`clinking glasses`,`symbols`,`干杯,香槟杯`],[`🥃`,`tumbler glass`,`symbols`,`威士忌,酒杯`],[`🥄`,`spoon`,`symbols`,`勺子,汤匙`],[`🥅`,`goal net`,`symbols`,`球门,网,进球`],[`🥇`,`first place medal`,`symbols`,`金牌,冠军,第一名,奖牌`],[`🥈`,`second place medal`,`symbols`,`银牌,第二名,奖牌`],[`🥉`,`third place medal`,`symbols`,`铜牌,第三名,奖牌`],[`🥊`,`boxing glove`,`symbols`,`拳击,拳击手套,打拳`],[`🥋`,`martial arts uniform`,`symbols`,`道服,武术,空手道`],[`🥌`,`curling stone`,`symbols`,`冰壶,冰壶`],[`🥍`,`lacrosse stick and ball`,`symbols`,``],[`🥎`,`softball`,`symbols`,`垒球,球`],[`🥏`,`flying disc`,`symbols`,`飞盘,飞碟`],[`🥐`,`croissant`,`food`,`牛角包,可颂`],[`🥑`,`avocado`,`food`,`牛油果,鳄梨`],[`🥒`,`cucumber`,`food`,`黄瓜`],[`🥓`,`bacon`,`food`,`培根,腊肉`],[`🥔`,`potato`,`food`,`土豆,马铃薯`],[`🥕`,`carrot`,`food`,`胡萝卜`],[`🥖`,`baguette bread`,`food`,`法棍,面包`],[`🥗`,`green salad`,`food`,`沙拉,蔬菜`],[`🥘`,`shallow pan of food`,`food`,`炖锅,海鲜饭`],[`🥙`,`stuffed flatbread`,`food`,`卷饼,肉夹馍`],[`🥚`,`egg`,`food`,`鸡蛋,蛋`],[`🥛`,`glass of milk`,`food`,`牛奶,奶`],[`🥜`,`peanuts`,`food`,``],[`🥝`,`kiwifruit`,`food`,`猕猴桃,奇异果`],[`🥞`,`pancakes`,`food`,`松饼,煎饼`],[`🥟`,`dumpling`,`food`,`饺子,锅贴`],[`🥠`,`fortune cookie`,`food`,`幸运饼干`],[`🥡`,`takeout box`,`food`,``],[`🥢`,`chopsticks`,`food`,`筷子`],[`🥣`,`bowl with spoon`,`food`,``],[`🥤`,`cup with straw`,`food`,`饮料,杯`],[`🥥`,`coconut`,`food`,`椰子`],[`🥦`,`broccoli`,`food`,`西兰花`],[`🥧`,`pie`,`food`,`派,馅饼`],[`🥨`,`pretzel`,`food`,`椒盐卷饼`],[`🥩`,`cut of meat`,`food`,`牛排,肉`],[`🥪`,`sandwich`,`food`,`三明治`],[`🥫`,`canned food`,`food`,`罐头,罐装`],[`🥬`,`leafy green`,`symbols`,`青菜,白菜,生菜`],[`🥭`,`mango`,`symbols`,`芒果`],[`🥮`,`moon cake`,`symbols`,``],[`🥯`,`bagel`,`symbols`,`贝果,面包圈`],[`🥰`,`smiling face with smiling eyes and three hearts`,`smileys`,`爱,微笑,爱心`],[`🥱`,`yawning face`,`smileys`,`打哈欠,困,无聊`],[`🥲`,`smiling face with tear`,`smileys`,``],[`🥳`,`face with party horn and party hat`,`smileys`,`庆祝,派对,欢呼`],[`🥴`,`face with uneven eyes and wavy mouth`,`smileys`,`晕,醉,头昏`],[`🥵`,`overheated face`,`smileys`,`热`],[`🥶`,`freezing face`,`smileys`,`冷`],[`🥷`,`ninja`,`people`,`忍者,忍者`],[`🥸`,`disguised face`,`symbols`,`伪装`],[`🥹`,`face holding back tears`,`symbols`,`感动,忍住,哭,泪目`],[`🥺`,`face with pleading eyes`,`smileys`,`可怜,委屈,求`],[`🥻`,`sari`,`symbols`,`纱丽,印度`],[`🥼`,`lab coat`,`symbols`,``],[`🥽`,`goggles`,`symbols`,``],[`🥾`,`hiking boot`,`symbols`,`靴子,登山鞋`],[`🥿`,`flat shoe`,`symbols`,`平底鞋,鞋`],[`🦀`,`crab`,`animals`,`螃蟹,海鲜`],[`🦁`,`lion face`,`animals`,``],[`🦂`,`scorpion`,`animals`,``],[`🦃`,`turkey`,`animals`,`火鸡,感恩节`],[`🦄`,`unicorn face`,`animals`,`独角兽,梦幻`],[`🦅`,`eagle`,`animals`,`老鹰,鹰`],[`🦆`,`duck`,`animals`,`鸭子,鸭`],[`🦇`,`bat`,`animals`,`蝙蝠`],[`🦈`,`shark`,`animals`,`鲨鱼,鱼`],[`🦉`,`owl`,`animals`,`猫头鹰,智慧`],[`🦊`,`fox face`,`animals`,``],[`🦋`,`butterfly`,`animals`,``],[`🦌`,`deer`,`animals`,`鹿,麋鹿`],[`🦍`,`gorilla`,`animals`,``],[`🦎`,`lizard`,`animals`,`蜥蜴,爬行动物`],[`🦏`,`rhinoceros`,`animals`,`犀牛`],[`🦐`,`shrimp`,`animals`,`虾,海鲜`],[`🦑`,`squid`,`animals`,`鱿鱼,海鲜`],[`🦒`,`giraffe face`,`animals`,`长颈鹿`],[`🦓`,`zebra face`,`animals`,`斑马`],[`🦔`,`hedgehog`,`animals`,`刺猬`],[`🦕`,`sauropod`,`animals`,`恐龙,雷龙`],[`🦖`,`t-rex`,`animals`,`恐龙,霸王龙`],[`🦗`,`cricket`,`animals`,``],[`🦘`,`kangaroo`,`animals`,`袋鼠`],[`🦙`,`llama`,`animals`,`羊驼,草泥马`],[`🦚`,`peacock`,`animals`,`孔雀,开屏`],[`🦛`,`hippopotamus`,`animals`,`河马`],[`🦜`,`parrot`,`animals`,`鹦鹉`],[`🦝`,`raccoon`,`animals`,`浣熊`],[`🦞`,`lobster`,`animals`,`龙虾,海鲜`],[`🦟`,`mosquito`,`animals`,``],[`🦠`,`microbe`,`animals`,``],[`🦡`,`badger`,`animals`,`獾`],[`🦢`,`swan`,`animals`,`天鹅,鹅`],[`🦣`,`mammoth`,`animals`,`猛犸象`],[`🦤`,`dodo`,`animals`,`渡渡鸟`],[`🦥`,`sloth`,`animals`,`树懒`],[`🦦`,`otter`,`animals`,`水獭`],[`🦧`,`orangutan`,`animals`,``],[`🦨`,`skunk`,`animals`,`臭鼬`],[`🦩`,`flamingo`,`animals`,`火烈鸟,红鹤`],[`🦪`,`oyster`,`animals`,`生蚝,牡蛎`],[`🦫`,`beaver`,`animals`,`河狸,海狸`],[`🦬`,`bison`,`animals`,`野牛,水牛`],[`🦭`,`seal`,`animals`,`海豹,海狮`],[`🦮`,`guide dog`,`animals`,`导盲犬,狗`],[`🦯`,`probing cane`,`symbols`,``],[`🦰`,`emoji component red hair`,`people`,`红发,头发,发色`],[`🦱`,`emoji component curly hair`,`people`,`卷发,头发`],[`🦲`,`emoji component bald`,`people`,`光头,秃头`],[`🦳`,`emoji component white hair`,`people`,`白发,头发`],[`🦴`,`bone`,`people`,``],[`🦵`,`leg`,`people`,`腿,大腿`],[`🦶`,`foot`,`people`,`脚,足`],[`🦷`,`tooth`,`people`,`牙齿,牙`],[`🦸`,`superhero`,`people`,`英雄`],[`🦹`,`supervillain`,`people`,`超级反派,坏人,反派`],[`🦺`,`safety vest`,`symbols`,``],[`🦻`,`ear with hearing aid`,`symbols`,`助听器,耳朵`],[`🦼`,`motorized wheelchair`,`people`,``],[`🦽`,`manual wheelchair`,`people`,``],[`🦾`,`mechanical arm`,`people`,`机械臂,机器人,义肢`],[`🦿`,`mechanical leg`,`people`,`机械腿,义肢`],[`🧀`,`cheese wedge`,`food`,`奶酪,芝士`],[`🧁`,`cupcake`,`food`,`纸杯蛋糕,杯子蛋糕`],[`🧂`,`salt shaker`,`food`,``],[`🧃`,`beverage box`,`food`,`果汁盒,饮料`],[`🧄`,`garlic`,`food`,`大蒜,蒜`],[`🧅`,`onion`,`food`,`洋葱`],[`🧆`,`falafel`,`food`,`鹰嘴豆丸子`],[`🧇`,`waffle`,`food`,`华夫饼`],[`🧈`,`butter`,`food`,`黄油,奶油`],[`🧉`,`mate drink`,`food`,`马黛茶`],[`🧊`,`ice cube`,`food`,`冰块,冰`],[`🧋`,`bubble tea`,`food`,`奶茶,珍珠奶茶`],[`🧌`,`troll`,`symbols`,`巨魔,妖怪`],[`🧍`,`standing person`,`symbols`,`站立,站着,人`],[`🧎`,`kneeling person`,`symbols`,`跪,跪下,祈祷`],[`🧏`,`deaf person`,`symbols`,``],[`🧐`,`face with monocle`,`people`,`检查,研究,眼镜`],[`🧑`,`adult`,`people`,`人`],[`🧒`,`child`,`people`,``],[`🧓`,`older adult`,`people`,`老人,奶奶,爷爷`],[`🧔`,`bearded person`,`people`,`胡子,胡须,大叔`],[`🧕`,`person with headscarf`,`people`,`头巾`],[`🧖`,`person in steamy room`,`people`,`桑拿,蒸汽,洗澡`],[`🧗`,`person climbing`,`people`,`攀岩`],[`🧘`,`person in lotus position`,`people`,`打坐`],[`🧙`,`mage`,`people`,`巫师,魔法师,法师`],[`🧚`,`fairy`,`people`,`仙女,精灵,小仙女`],[`🧛`,`vampire`,`people`,`吸血鬼,德古拉`],[`🧜`,`merperson`,`people`,`美人鱼,人鱼`],[`🧝`,`elf`,`people`,`精灵,耳朵`],[`🧞`,`genie`,`people`,`灯神,精灵,神灯`],[`🧟`,`zombie`,`people`,`僵尸,丧尸`],[`🧠`,`brain`,`people`,`大脑,思考,记忆,AI`],[`🧡`,`orange heart`,`people`,``],[`🧢`,`billed cap`,`people`,`棒球帽,帽子`],[`🧣`,`scarf`,`people`,`围巾,冬天`],[`🧤`,`gloves`,`people`,`手套,冬天`],[`🧥`,`coat`,`people`,`大衣,外套`],[`🧦`,`socks`,`people`,`袜子`],[`🧧`,`red gift envelope`,`objects`,`红包,利是,新年`],[`🧨`,`firecracker`,`objects`,``],[`🧩`,`jigsaw puzzle piece`,`objects`,`拼图,拼图游戏`],[`🧪`,`test tube`,`objects`,`试管,实验,化学,科学`],[`🧫`,`petri dish`,`objects`,`培养皿,实验,细菌`],[`🧬`,`dna double helix`,`objects`,`DNA,基因,生物`],[`🧭`,`compass`,`objects`,`指南针`],[`🧮`,`abacus`,`objects`,`算盘,计算`],[`🧯`,`fire extinguisher`,`objects`,`灭火器,消防`],[`🧰`,`toolbox`,`objects`,`工具箱,工具`],[`🧱`,`brick`,`objects`,`砖`],[`🧲`,`magnet`,`objects`,`磁铁,磁性`],[`🧳`,`luggage`,`objects`,`行李箱`],[`🧴`,`lotion bottle`,`objects`,`乳液,护肤,防晒`],[`🧵`,`spool of thread`,`objects`,`线,针线,缝纫`],[`🧶`,`ball of yarn`,`objects`,`毛线,织毛衣`],[`🧷`,`safety pin`,`objects`,`别针,安全别针`],[`🧸`,`teddy bear`,`objects`,`泰迪熊,玩具熊`],[`🧹`,`broom`,`objects`,`扫帚`],[`🧺`,`basket`,`objects`,`篮子`],[`🧻`,`roll of paper`,`objects`,`纸巾`],[`🧼`,`bar of soap`,`objects`,`肥皂,洗手,清洁`],[`🧽`,`sponge`,`objects`,`海绵,清洁`],[`🧾`,`receipt`,`objects`,`收据`],[`🧿`,`nazar amulet`,`objects`,`护身符`],[`🩰`,`ballet shoes`,`activity`,`芭蕾`],[`🩱`,`one-piece swimsuit`,`activity`,`泳衣`],[`🩲`,`briefs`,`activity`,`泳裤`],[`🩳`,`shorts`,`activity`,`短裤`],[`🩴`,`thong sandal`,`activity`,`凉拖`],[`🩵`,`light blue heart`,`activity`,`浅蓝`],[`🩶`,`grey heart`,`activity`,`灰心`],[`🩷`,`pink heart`,`activity`,`粉色`],[`🩸`,`drop of blood`,`activity`,`血`],[`🩹`,`adhesive bandage`,`activity`,`创可贴`],[`🩺`,`stethoscope`,`activity`,`听诊器`],[`🩻`,`x-ray`,`activity`,`X光`],[`🩼`,`crutch`,`activity`,`拐杖`],[`🪀`,`yo-yo`,`objects`,`玩具`],[`🪁`,`kite`,`objects`,`风筝`],[`🪂`,`parachute`,`objects`,`跳伞`],[`🪃`,`boomerang`,`objects`,``],[`🪄`,`magic wand`,`objects`,`魔杖,魔法,魔术`],[`🪅`,`pinata`,`objects`,`皮纳塔`],[`🪆`,`nesting dolls`,`objects`,``],[`🪇`,`maracas`,`objects`,`沙锤`],[`🪈`,`flute`,`objects`,`笛子`],[`🪐`,`ringed planet`,`objects`,``],[`🪑`,`chair`,`objects`,`椅子`],[`🪒`,`razor`,`objects`,`剃须刀,剃刀`],[`🪓`,`axe`,`objects`,`斧头,斧子`],[`🪔`,`diya lamp`,`objects`,`油灯`],[`🪕`,`banjo`,`objects`,`班卓琴`],[`🪖`,`military helmet`,`objects`,`军盔`],[`🪗`,`accordion`,`objects`,`手风琴`],[`🪘`,`long drum`,`objects`,`鼓`],[`🪙`,`coin`,`objects`,`金币`],[`🪚`,`carpentry saw`,`objects`,`锯子,锯`],[`🪛`,`screwdriver`,`objects`,`螺丝刀`],[`🪜`,`ladder`,`objects`,`梯子`],[`🪝`,`hook`,`objects`,`钩子,挂钩`],[`🪞`,`mirror`,`objects`,`镜子`],[`🪟`,`window`,`objects`,`窗户`],[`🪠`,`plunger`,`objects`,`皮搋子,通马桶`],[`🪡`,`sewing needle`,`objects`,`针,缝纫,刺绣`],[`🪢`,`knot`,`objects`,``],[`🪣`,`bucket`,`objects`,`水桶,桶`],[`🪤`,`mouse trap`,`objects`,`捕鼠器`],[`🪥`,`toothbrush`,`objects`,`牙刷,刷牙`],[`🪦`,`headstone`,`objects`,`墓碑`],[`🪧`,`placard`,`objects`,`告示牌`],[`🪨`,`rock`,`objects`,`石头,岩石`],[`🪩`,`mirror ball`,`objects`,`迪斯科球`],[`🪪`,`identification card`,`objects`,`身份证`],[`🪫`,`low battery`,`objects`,`电池,没电,低电量`],[`🪬`,`hamsa`,`objects`,`手掌印,护身符`],[`🪭`,`folding hand fan`,`objects`,``],[`🪮`,`hair pick`,`objects`,`梳子`],[`🪯`,`khanda`,`objects`,``],[`🪰`,`fly`,`objects`,`苍蝇,飞虫`],[`🪱`,`worm`,`objects`,``],[`🪲`,`beetle`,`objects`,`甲虫,昆虫`],[`🪳`,`cockroach`,`objects`,`蟑螂,虫子`],[`🪴`,`potted plant`,`objects`,`盆栽,植物,绿植`],[`🪵`,`wood`,`objects`,`木头,柴火,木`],[`🪶`,`feather`,`objects`,`羽毛,羽毛笔`],[`🪷`,`lotus`,`objects`,`莲花`],[`🪸`,`coral`,`objects`,`珊瑚`],[`🪹`,`empty nest`,`objects`,`鸟巢`],[`🪺`,`nest with eggs`,`objects`,`鸟巢`],[`🪻`,`hyacinth`,`objects`,`风信子`],[`🪼`,`jellyfish`,`objects`,`水母`],[`🪽`,`wing`,`objects`,`翅膀`],[`🪿`,`goose`,`objects`,`鹅`],[`🫀`,`anatomical heart`,`objects`,`心脏,心跳`],[`🫁`,`lungs`,`objects`,`肺,呼吸`],[`🫂`,`people hugging`,`objects`,`拥抱,人,朋友`],[`🫃`,`pregnant man`,`objects`,`孕妇,怀孕`],[`🫄`,`pregnant person`,`objects`,`孕妇,怀孕`],[`🫅`,`person with crown`,`objects`,`国王,王子,皇冠`],[`🫎`,`moose`,`objects`,`驼鹿,麋鹿`],[`🫏`,`donkey`,`objects`,`驴,动物`],[`🫐`,`blueberries`,`food`,`蓝莓`],[`🫑`,`bell pepper`,`food`,`甜椒,彩椒`],[`🫒`,`olive`,`food`,`橄榄`],[`🫓`,`flatbread`,`food`,`薄饼,饼`],[`🫔`,`tamale`,`food`,`玉米粉蒸肉`],[`🫕`,`fondue`,`food`,`奶酪火锅`],[`🫖`,`teapot`,`food`,`茶壶,茶`],[`🫗`,`pouring liquid`,`food`,`倒,倒水,水杯`],[`🫘`,`beans`,`food`,`豆子,红豆`],[`🫙`,`jar`,`food`,`罐子,玻璃罐`],[`🫚`,`ginger root`,`food`,`姜,生姜`],[`🫛`,`pea pod`,`food`,`豌豆荚,豆`],[`🫠`,`melting face`,`smileys`,`融化`],[`🫡`,`saluting face`,`smileys`,`敬礼`],[`🫢`,`face with open eyes and hand over mouth`,`smileys`,`捂眼`],[`🫣`,`face with peeking eye`,`smileys`,`偷看`],[`🫤`,`face with diagonal mouth`,`smileys`,`撇嘴`],[`🫥`,`dotted line face`,`smileys`,`隐形`],[`🫦`,`biting lip`,`smileys`,`咬唇,嘴唇`],[`🫧`,`bubbles`,`smileys`,`泡泡`],[`🫨`,`shaking face`,`smileys`,`摇晃,震动,抖`],[`🫰`,`hand with index finger and thumb crossed`,`people`,`比心,手指,捏`],[`🫱`,`rightwards hand`,`people`,`手,右边,推`],[`🫲`,`leftwards hand`,`people`,`手,左边,推`],[`🫳`,`palm down hand`,`people`,`手,向下,放`],[`🫴`,`palm up hand`,`people`,`手,向上,举`],[`🫵`,`index pointing at the viewer`,`people`,`指,你`],[`🫶`,`heart hands`,`people`,`比心,爱心,手势`],[`🫷`,`leftwards pushing hand`,`people`,`手,推,右边`],[`🫸`,`rightwards pushing hand`,`people`,`手,推,左边`],[`‼`,`double exclamation mark`,`symbols`,``],[`‼️`,`double exclamation mark`,`symbols`,``],[`⁉`,`exclamation question mark`,`symbols`,``],[`⁉️`,`exclamation question mark`,`symbols`,``],[`™`,`trade mark sign`,`symbols`,``],[`™️`,`trade mark sign`,`symbols`,``],[`ℹ`,`information source`,`symbols`,``],[`ℹ️`,`information source`,`symbols`,``],[`↔`,`left right arrow`,`symbols`,``],[`↔️`,`left right arrow`,`symbols`,``],[`↕`,`up down arrow`,`symbols`,``],[`↕️`,`up down arrow`,`symbols`,``],[`↖`,`north west arrow`,`symbols`,``],[`↖️`,`north west arrow`,`symbols`,``],[`↗`,`north east arrow`,`symbols`,``],[`↗️`,`north east arrow`,`symbols`,``],[`↘`,`south east arrow`,`symbols`,``],[`↘️`,`south east arrow`,`symbols`,``],[`↙`,`south west arrow`,`symbols`,``],[`↙️`,`south west arrow`,`symbols`,``],[`↩`,`leftwards arrow with hook`,`symbols`,``],[`↩️`,`leftwards arrow with hook`,`symbols`,``],[`↪`,`rightwards arrow with hook`,`symbols`,``],[`↪️`,`rightwards arrow with hook`,`symbols`,``],[`⌚`,`watch`,`objects`,`手表`],[`⌚️`,`watch`,`objects`,``],[`⌛`,`hourglass`,`objects`,`沙漏,时间,等待`],[`⌛️`,`hourglass`,`objects`,``],[`⌨`,`keyboard`,`symbols`,``],[`⌨️`,`keyboard`,`symbols`,`键盘,打字`],[`⏏`,`eject symbol`,`symbols`,``],[`⏏️`,`eject symbol`,`symbols`,``],[`⏩`,`black right-pointing double triangle`,`objects`,``],[`⏪`,`black left-pointing double triangle`,`objects`,``],[`⏫`,`black up-pointing double triangle`,`objects`,``],[`⏬`,`black down-pointing double triangle`,`objects`,``],[`⏭`,`black right-pointing double triangle with vertical bar`,`objects`,``],[`⏭️`,`black right-pointing double triangle with vertical bar`,`objects`,``],[`⏮`,`black left-pointing double triangle with vertical bar`,`objects`,``],[`⏮️`,`black left-pointing double triangle with vertical bar`,`objects`,``],[`⏯`,`black right-pointing triangle with double vertical bar`,`objects`,``],[`⏯️`,`black right-pointing triangle with double vertical bar`,`objects`,``],[`⏰`,`alarm clock`,`objects`,`闹钟,时间,起床`],[`⏱`,`stopwatch`,`objects`,``],[`⏱️`,`stopwatch`,`objects`,`秒表`],[`⏲`,`timer clock`,`objects`,``],[`⏲️`,`timer clock`,`objects`,`计时器`],[`⏳`,`hourglass with flowing sand`,`objects`,`沙漏`],[`⏸`,`double vertical bar`,`symbols`,``],[`⏸️`,`double vertical bar`,`symbols`,``],[`⏹`,`black square for stop`,`symbols`,``],[`⏹️`,`black square for stop`,`symbols`,``],[`⏺`,`black circle for record`,`symbols`,``],[`⏺️`,`black circle for record`,`symbols`,``],[`Ⓜ`,`circled latin capital letter m`,`symbols`,``],[`Ⓜ️`,`circled latin capital letter m`,`symbols`,``],[`▪`,`black small square`,`symbols`,``],[`▪️`,`black small square`,`symbols`,``],[`▫`,`white small square`,`symbols`,``],[`▫️`,`white small square`,`symbols`,``],[`▶`,`black right-pointing triangle`,`symbols`,``],[`▶️`,`black right-pointing triangle`,`symbols`,``],[`◀`,`black left-pointing triangle`,`symbols`,``],[`◀️`,`black left-pointing triangle`,`symbols`,``],[`◻`,`white medium square`,`symbols`,``],[`◻️`,`white medium square`,`symbols`,``],[`◼`,`black medium square`,`symbols`,``],[`◼️`,`black medium square`,`symbols`,``],[`◽`,`white medium small square`,`symbols`,``],[`◾`,`black medium small square`,`symbols`,``],[`◾️`,`black medium small square`,`symbols`,``],[`☀`,`black sun with rays`,`symbols`,``],[`☀️`,`black sun with rays`,`symbols`,`太阳,晴天,阳光`],[`☁`,`cloud`,`symbols`,``],[`☁️`,`cloud`,`symbols`,`云,多云,天气`],[`☂`,`umbrella`,`symbols`,``],[`☂️`,`umbrella`,`symbols`,``],[`☃`,`snowman`,`symbols`,``],[`☃️`,`snowman`,`symbols`,`雪人,冬天,雪`],[`☄`,`comet`,`symbols`,``],[`☄️`,`comet`,`symbols`,``],[`☎`,`black telephone`,`symbols`,``],[`☎️`,`black telephone`,`symbols`,`电话`],[`☑`,`ballot box with check`,`symbols`,``],[`☑️`,`ballot box with check`,`symbols`,``],[`☔`,`umbrella with rain drops`,`symbols`,``],[`☔️`,`umbrella with rain drops`,`symbols`,``],[`☕`,`hot beverage`,`food`,`咖啡,热饮`],[`☕️`,`hot beverage`,`food`,``],[`☘`,`shamrock`,`symbols`,``],[`☘️`,`shamrock`,`symbols`,``],[`☝`,`white up pointing index`,`symbols`,``],[`☝️`,`white up pointing index`,`symbols`,`指,上面,向上`],[`☠`,`skull and crossbones`,`symbols`,``],[`☠️`,`skull and crossbones`,`symbols`,`骷髅,死亡,危险`],[`☢`,`radioactive sign`,`symbols`,``],[`☢️`,`radioactive sign`,`symbols`,``],[`☣`,`biohazard sign`,`symbols`,``],[`☣️`,`biohazard sign`,`symbols`,``],[`☦`,`orthodox cross`,`symbols`,``],[`☦️`,`orthodox cross`,`symbols`,``],[`☪`,`star and crescent`,`symbols`,``],[`☪️`,`star and crescent`,`symbols`,``],[`☮`,`peace symbol`,`symbols`,``],[`☮️`,`peace symbol`,`symbols`,``],[`☯`,`yin yang`,`symbols`,``],[`☯️`,`yin yang`,`symbols`,``],[`☸`,`wheel of dharma`,`symbols`,``],[`☸️`,`wheel of dharma`,`symbols`,``],[`☹`,`white frowning face`,`smileys`,``],[`☹️`,`white frowning face`,`smileys`,``],[`☺`,`white smiling face`,`smileys`,``],[`☺️`,`white smiling face`,`smileys`,``],[`♀`,`female sign`,`symbols`,``],[`♀️`,`female sign`,`symbols`,``],[`♂`,`male sign`,`symbols`,``],[`♂️`,`male sign`,`symbols`,``],[`♈`,`aries`,`symbols`,``],[`♈️`,`aries`,`symbols`,``],[`♉`,`taurus`,`symbols`,``],[`♉️`,`taurus`,`symbols`,``],[`♊`,`gemini`,`symbols`,``],[`♊️`,`gemini`,`symbols`,``],[`♋`,`cancer`,`symbols`,``],[`♋️`,`cancer`,`symbols`,``],[`♌`,`leo`,`symbols`,``],[`♌️`,`leo`,`symbols`,``],[`♍`,`virgo`,`symbols`,``],[`♍️`,`virgo`,`symbols`,``],[`♎`,`libra`,`symbols`,``],[`♎️`,`libra`,`symbols`,``],[`♏`,`scorpius`,`symbols`,``],[`♏️`,`scorpius`,`symbols`,``],[`♐`,`sagittarius`,`symbols`,``],[`♐️`,`sagittarius`,`symbols`,``],[`♑`,`capricorn`,`symbols`,``],[`♑️`,`capricorn`,`symbols`,``],[`♒`,`aquarius`,`symbols`,``],[`♒️`,`aquarius`,`symbols`,``],[`♓`,`pisces`,`symbols`,``],[`♓️`,`pisces`,`symbols`,``],[`♟`,`black chess pawn`,`symbols`,``],[`♟️`,`black chess pawn`,`symbols`,`棋子,国际象棋,象棋`],[`♠`,`black spade suit`,`symbols`,``],[`♠️`,`black spade suit`,`symbols`,``],[`♣`,`black club suit`,`symbols`,``],[`♣️`,`black club suit`,`symbols`,``],[`♥`,`black heart suit`,`symbols`,``],[`♥️`,`black heart suit`,`symbols`,``],[`♦`,`black diamond suit`,`symbols`,``],[`♦️`,`black diamond suit`,`symbols`,``],[`♨`,`hot springs`,`symbols`,``],[`♨️`,`hot springs`,`symbols`,`温泉,热泉`],[`♻`,`black universal recycling symbol`,`symbols`,``],[`♻️`,`black universal recycling symbol`,`symbols`,``],[`♾`,`permanent paper sign`,`symbols`,``],[`♾️`,`permanent paper sign`,`symbols`,``],[`♿`,`wheelchair symbol`,`symbols`,``],[`♿️`,`wheelchair symbol`,`symbols`,``],[`⚒`,`hammer and pick`,`symbols`,``],[`⚒️`,`hammer and pick`,`symbols`,`锤子,工具`],[`⚓`,`anchor`,`symbols`,`锚,航海,停泊`],[`⚔`,`crossed swords`,`symbols`,``],[`⚔️`,`crossed swords`,`symbols`,`剑,交叉,战斗`],[`⚕`,`staff of aesculapius`,`symbols`,``],[`⚕️`,`staff of aesculapius`,`symbols`,``],[`⚖`,`scales`,`symbols`,``],[`⚖️`,`scales`,`symbols`,``],[`⚗`,`alembic`,`symbols`,``],[`⚗️`,`alembic`,`symbols`,``],[`⚙`,`gear`,`symbols`,``],[`⚙️`,`gear`,`symbols`,``],[`⚛`,`atom symbol`,`symbols`,``],[`⚛️`,`atom symbol`,`symbols`,``],[`⚜`,`fleur-de-lis`,`symbols`,``],[`⚜️`,`fleur-de-lis`,`symbols`,``],[`⚠`,`warning sign`,`symbols`,``],[`⚠️`,`warning sign`,`symbols`,``],[`⚡`,`high voltage sign`,`symbols`,``],[`⚧`,`male with stroke and male and female sign`,`symbols`,``],[`⚧️`,`male with stroke and male and female sign`,`symbols`,``],[`⚪`,`medium white circle`,`symbols`,``],[`⚪️`,`medium white circle`,`symbols`,``],[`⚫`,`medium black circle`,`symbols`,``],[`⚰`,`coffin`,`symbols`,``],[`⚰️`,`coffin`,`symbols`,`棺材,死亡`],[`⚱`,`funeral urn`,`symbols`,``],[`⚱️`,`funeral urn`,`symbols`,`骨灰盒,死亡`],[`⚽`,`soccer ball`,`activity`,`足球,球`],[`⚽️`,`soccer ball`,`activity`,``],[`⚾`,`baseball`,`activity`,`棒球,球`],[`⚾️`,`baseball`,`activity`,``],[`⛄`,`snowman without snow`,`symbols`,`雪人,冬天`],[`⛄️`,`snowman without snow`,`symbols`,``],[`⛅`,`sun behind cloud`,`symbols`,`太阳,云,多云`],[`⛈`,`thunder cloud and rain`,`symbols`,``],[`⛈️`,`thunder cloud and rain`,`symbols`,`雷雨,雷暴,天气`],[`⛎`,`ophiuchus`,`symbols`,``],[`⛏`,`pick`,`symbols`,``],[`⛏️`,`pick`,`symbols`,`镐,工具`],[`⛑`,`helmet with white cross`,`symbols`,``],[`⛑️`,`helmet with white cross`,`symbols`,`头盔,救援,安全`],[`⛓`,`chains`,`symbols`,``],[`⛓️`,`chains`,`symbols`,``],[`⛔`,`no entry`,`symbols`,``],[`⛩`,`shinto shrine`,`travel`,``],[`⛩️`,`shinto shrine`,`travel`,`鸟居,神社,日本`],[`⛪`,`church`,`travel`,`教堂`],[`⛰`,`mountain`,`travel`,``],[`⛰️`,`mountain`,`travel`,`山,山峰`],[`⛱`,`umbrella on ground`,`travel`,``],[`⛱️`,`umbrella on ground`,`travel`,``],[`⛲`,`fountain`,`travel`,`喷泉`],[`⛲️`,`fountain`,`travel`,``],[`⛳`,`flag in hole`,`activity`,`高尔夫,高尔夫球,球洞`],[`⛳️`,`flag in hole`,`activity`,``],[`⛴`,`ferry`,`travel`,``],[`⛴️`,`ferry`,`travel`,`渡轮,船`],[`⛵`,`sailboat`,`travel`,`帆船,船`],[`⛵️`,`sailboat`,`travel`,``],[`⛷`,`skier`,`activity`,``],[`⛷️`,`skier`,`activity`,``],[`⛸`,`ice skate`,`activity`,``],[`⛸️`,`ice skate`,`activity`,`溜冰,冰刀,滑冰`],[`⛹`,`person with ball`,`activity`,``],[`⛹️`,`person with ball`,`activity`,``],[`⛺`,`tent`,`travel`,`帐篷,露营`],[`⛺️`,`tent`,`travel`,``],[`⛽`,`fuel pump`,`travel`,`加油站,加油,汽油`],[`✂`,`black scissors`,`symbols`,``],[`✂️`,`black scissors`,`symbols`,``],[`✅`,`white heavy check mark`,`symbols`,``],[`✈`,`airplane`,`travel`,``],[`✈️`,`airplane`,`travel`,`飞机,航班,起飞`],[`✉`,`envelope`,`symbols`,``],[`✉️`,`envelope`,`symbols`,`信封,邮件,信`],[`✊`,`raised fist`,`people`,`拳头,加油,力量`],[`✋`,`raised hand`,`people`,`手,举手,停`],[`✌`,`victory hand`,`symbols`,``],[`✌️`,`victory hand`,`symbols`,`胜利,耶,剪刀手`],[`✍`,`writing hand`,`symbols`,``],[`✍️`,`writing hand`,`symbols`,`写字,写作,手`],[`✏`,`pencil`,`symbols`,``],[`✏️`,`pencil`,`symbols`,``],[`✒`,`black nib`,`symbols`,``],[`✒️`,`black nib`,`symbols`,``],[`✔`,`heavy check mark`,`symbols`,``],[`✔️`,`heavy check mark`,`symbols`,``],[`✖`,`heavy multiplication x`,`symbols`,``],[`✖️`,`heavy multiplication x`,`symbols`,``],[`✝`,`latin cross`,`symbols`,``],[`✝️`,`latin cross`,`symbols`,``],[`✡`,`star of david`,`symbols`,``],[`✡️`,`star of david`,`symbols`,``],[`✨`,`sparkles`,`symbols`,`星星,闪光,发光`],[`✳`,`eight spoked asterisk`,`symbols`,``],[`✳️`,`eight spoked asterisk`,`symbols`,``],[`✴`,`eight pointed black star`,`symbols`,``],[`✴️`,`eight pointed black star`,`symbols`,``],[`❄`,`snowflake`,`symbols`,``],[`❄️`,`snowflake`,`symbols`,`雪花,雪,冬天,冷`],[`❇`,`sparkle`,`symbols`,``],[`❇️`,`sparkle`,`symbols`,``],[`❌`,`cross mark`,`symbols`,``],[`❎`,`negative squared cross mark`,`symbols`,``],[`❓`,`black question mark ornament`,`symbols`,``],[`❔`,`white question mark ornament`,`symbols`,``],[`❕`,`white exclamation mark ornament`,`symbols`,``],[`❗`,`heavy exclamation mark symbol`,`symbols`,``],[`❗️`,`heavy exclamation mark symbol`,`symbols`,``],[`❣`,`heavy heart exclamation mark ornament`,`symbols`,``],[`❣️`,`heavy heart exclamation mark ornament`,`symbols`,`爱心,感叹号`],[`❤`,`heavy black heart`,`smileys`,``],[`❤️`,`heavy black heart`,`smileys`,`爱心,红心,爱`],[`➕`,`heavy plus sign`,`symbols`,``],[`➖`,`heavy minus sign`,`symbols`,``],[`➗`,`heavy division sign`,`symbols`,``],[`➡`,`black rightwards arrow`,`symbols`,``],[`➡️`,`black rightwards arrow`,`symbols`,``],[`➰`,`curly loop`,`symbols`,``],[`➿`,`double curly loop`,`symbols`,``],[`⬅`,`leftwards black arrow`,`symbols`,``],[`⬅️`,`leftwards black arrow`,`symbols`,``],[`⬆`,`upwards black arrow`,`symbols`,``],[`⬆️`,`upwards black arrow`,`symbols`,``],[`⬇`,`downwards black arrow`,`symbols`,``],[`⬇️`,`downwards black arrow`,`symbols`,``],[`⬛`,`black large square`,`symbols`,``],[`⬛️`,`black large square`,`symbols`,``],[`⬜`,`white large square`,`symbols`,``],[`⬜️`,`white large square`,`symbols`,``],[`⭐`,`white medium star`,`symbols`,`星星,五星,评分`],[`⭕`,`heavy large circle`,`symbols`,``],[`⭕️`,`heavy large circle`,`symbols`,``],[`⤴`,`arrow pointing rightwards then curving upwards`,`symbols`,``],[`⤴️`,`arrow pointing rightwards then curving upwards`,`symbols`,``],[`⤵`,`arrow pointing rightwards then curving downwards`,`symbols`,``],[`⤵️`,`arrow pointing rightwards then curving downwards`,`symbols`,``],[`〰`,`wavy dash`,`symbols`,``],[`〰️`,`wavy dash`,`symbols`,``],[`〽`,`part alternation mark`,`symbols`,``],[`〽️`,`part alternation mark`,`symbols`,``],[`㊗`,`circled ideograph congratulation`,`symbols`,``],[`㊗️`,`circled ideograph congratulation`,`symbols`,``],[`㊙`,`circled ideograph secret`,`symbols`,``],[`㊙️`,`circled ideograph secret`,`symbols`,``],[`©`,`copyright sign`,`symbols`,``],[`©️`,`copyright sign`,`symbols`,``],[`®`,`registered sign`,`symbols`,``],[`®️`,`registered sign`,`symbols`,``],[`👨💻`,`man technologist`,`people`,`程序员,开发者,工程师,码农`],[`👩💻`,`woman technologist`,`people`,`程序员,开发者,工程师`],[`🧑💻`,`technologist`,`people`,`程序员,开发者,工程师`],[`👨🔧`,`man mechanic`,`people`,``],[`👩🔧`,`woman mechanic`,`people`,``],[`👨🎨`,`man artist`,`people`,``],[`👩🎨`,`woman artist`,`people`,``],[`👨🚀`,`man astronaut`,`people`,``],[`👩🚀`,`woman astronaut`,`people`,``],[`👨⚕️`,`man health worker`,`people`,``],[`👩⚕️`,`woman health worker`,`people`,``],[`👨🏫`,`man teacher`,`people`,``],[`👩🏫`,`woman teacher`,`people`,``],[`👨🍳`,`man cook`,`people`,``],[`👩🍳`,`woman cook`,`people`,``],[`👨🌾`,`man farmer`,`people`,``],[`👩🌾`,`woman farmer`,`people`,``],[`👩🏭`,`woman factory worker`,`people`,``],[`👨🎓`,`man student`,`people`,``],[`👩🎓`,`woman student`,`people`,``],[`👨🚒`,`man firefighter`,`people`,``],[`👩🚒`,`woman firefighter`,`people`,``],[`👨⚖️`,`man judge`,`people`,``],[`👩⚖️`,`woman judge`,`people`,``],[`👨💼`,`man office worker`,`people`,``],[`👩💼`,`woman office worker`,`people`,``],[`👨🎤`,`man singer`,`people`,``],[`👩🎤`,`woman singer`,`people`,``],[`👨🦰`,`man red hair`,`people`,``],[`👩🦰`,`woman red hair`,`people`,``],[`👨🦱`,`man curly hair`,`people`,``],[`👩🦱`,`woman curly hair`,`people`,``],[`👩🦲`,`woman bald`,`people`,``],[`👨🦳`,`man white hair`,`people`,``],[`👩🦳`,`woman white hair`,`people`,``],[`👩❤️👨`,`couple with heart`,`people`,``],[`👨❤️👨`,`couple with heart`,`people`,``],[`👩❤️👩`,`couple with heart`,`people`,``],[`👨👩👧`,`family man woman girl`,`people`,``],[`👨👩👦`,`family man woman boy`,`people`,``],[`👨👩👧👦`,`family man woman girl boy`,`people`,``],[`👨👩👦👦`,`man`,`people`,``],[`👨👩👧👧`,`family man woman girl girl`,`people`,``],[`👩👩👧`,`family woman woman girl`,`people`,``],[`👨👨👧`,`family man man girl`,`people`,``],[`👨👦`,`family man boy`,`people`,``],[`👩👧`,`family woman girl`,`people`,``],[`👨👧👦`,`family man girl boy`,`people`,``],[`👩❤️💋👨`,`kiss woman man`,`people`,``],[`🧑🤝🧑`,`people holding hands`,`people`,``],[`❤️🔥`,`heart on fire`,`smileys`,``],[`🧑🚒`,`firefighter`,`people`,`消防员`],[`🧑🏭`,`factory worker`,`people`,``],[`🧑🎓`,`student`,`people`,`学生,毕业生,大学生`],[`🧑🏫`,`teacher`,`people`,`老师,教师,教授`],[`🧑🎤`,`singer`,`people`,`歌手,歌星`],[`🧑⚕️`,`health worker`,`people`,`医生,医疗`],[`🧑⚖️`,`judge`,`people`,`法官,审判`],[`🧑🍳`,`cook`,`people`,`厨师,大厨`],[`🧑🌾`,`farmer`,`people`,`农民,农夫`],[`🧑🎨`,`artist`,`people`,`画家,艺术家`],[`🧑🔬`,`scientist`,`people`,``],[`🧑🔧`,`mechanic`,`people`,`技工,维修工`],[`🧑💼`,`office worker`,`people`,`白领,上班族,职员`],[`🧑🚀`,`astronaut`,`people`,`宇航员,太空人`],[`🏃♂️`,`man running`,`activity`,``],[`🏃♀️`,`woman running`,`activity`,``],[`🚶♂️`,`man walking`,`travel`,``],[`🚶♀️`,`woman walking`,`travel`,``],[`🧎♂️`,`man kneeling`,`symbols`,``],[`🧎♀️`,`woman kneeling`,`symbols`,``],[`🏋️♂️`,`man lifting weights`,`activity`,``],[`🏋️♀️`,`woman lifting weights`,`activity`,``],[`🤸♂️`,`man cartwheeling`,`people`,``],[`🤸♀️`,`woman cartwheeling`,`people`,``],[`⛹️♂️`,`man bouncing ball`,`activity`,``],[`⛹️♀️`,`woman bouncing ball`,`activity`,``],[`🤾♂️`,`man playing handball`,`activity`,``],[`🤾♀️`,`woman playing handball`,`activity`,``],[`🧘♀️`,`woman in lotus position`,`people`,``],[`🏄♂️`,`man surfing`,`activity`,``],[`🏄♀️`,`woman surfing`,`activity`,``],[`🏊♂️`,`man swimming`,`activity`,``],[`🏊♀️`,`woman swimming`,`activity`,``],[`🚴♂️`,`man biking`,`travel`,``],[`🚴♀️`,`woman biking`,`travel`,``],[`🚵♂️`,`man mountain biking`,`travel`,``],[`🚵♀️`,`woman mountain biking`,`travel`,``],[`👯♂️`,`men with bunny ears`,`people`,``],[`👯♀️`,`women with bunny ears`,`people`,``],[`🧖♂️`,`man in steamy room`,`people`,``],[`🧖♀️`,`woman in steamy room`,`people`,``],[`🧗♂️`,`man climbing`,`people`,``],[`🧗♀️`,`woman climbing`,`people`,``],[`🤦♂️`,`man facepalming`,`smileys`,``],[`🤦♀️`,`woman facepalming`,`smileys`,``],[`🤷♂️`,`man shrugging`,`people`,``],[`🤷♀️`,`woman shrugging`,`people`,``],[`🙍♂️`,`person frowning`,`smileys`,``],[`🙍♀️`,`woman frowning`,`smileys`,``],[`🙎♂️`,`man pouting`,`smileys`,``],[`🙎♀️`,`woman pouting`,`smileys`,``],[`🙅♂️`,`man gesturing no`,`smileys`,``],[`🙅♀️`,`woman gesturing no`,`smileys`,``],[`🙆♂️`,`man gesturing ok`,`smileys`,``],[`🙆♀️`,`woman gesturing ok`,`smileys`,``],[`💁♂️`,`man tipping hand`,`people`,``],[`💁♀️`,`woman tipping hand`,`people`,``],[`🙋♂️`,`man raising hand`,`smileys`,``],[`🙋♀️`,`woman raising hand`,`smileys`,``],[`🙇♂️`,`man bowing`,`smileys`,``],[`🙇♀️`,`woman bowing`,`smileys`,``],[`💆♂️`,`man getting massage`,`people`,``],[`💆♀️`,`woman getting massage`,`people`,``],[`💇♂️`,`man getting haircut`,`people`,``],[`💇♀️`,`woman getting haircut`,`people`,``],[`🧞♂️`,`man genie`,`people`,``],[`🧞♀️`,`woman genie`,`people`,``],[`🧟♂️`,`man zombie`,`people`,``],[`🧟♀️`,`woman zombie`,`people`,``],[`🧜♂️`,`merman`,`people`,``],[`🧚♂️`,`man fairy`,`people`,``],[`🧚♀️`,`woman fairy`,`people`,``],[`🧛♂️`,`man vampire`,`people`,``],[`🧛♀️`,`woman vampire`,`people`,``],[`🧙♂️`,`man mage`,`people`,``],[`🧙♀️`,`mage`,`people`,``],[`🧝♂️`,`man elf`,`people`,``],[`🧝♀️`,`woman elf`,`people`,``],[`🦸♂️`,`man superhero`,`people`,``],[`🦸♀️`,`woman superhero`,`people`,``],[`🦹♂️`,`man supervillain`,`people`,``],[`🦹♀️`,`woman supervillain`,`people`,``],[`0️⃣`,`keycap 0`,`symbols`,``],[`1️⃣`,`keycap 1`,`symbols`,``],[`2️⃣`,`keycap 2`,`symbols`,``],[`3️⃣`,`keycap 3`,`symbols`,``],[`4️⃣`,`keycap 4`,`symbols`,``],[`5️⃣`,`keycap 5`,`symbols`,``],[`6️⃣`,`keycap 6`,`symbols`,``],[`7️⃣`,`keycap 7`,`symbols`,``],[`8️⃣`,`keycap 8`,`symbols`,``],[`9️⃣`,`keycap 9`,`symbols`,``],[`#️⃣`,`keycap #`,`symbols`,``],[`*️⃣`,`keycap *`,`symbols`,``],[`🇨🇳`,`flag china`,`flags`,`中国,国旗,五星红旗`],[`🇺🇸`,`flag united states`,`flags`,`美国,国旗,USA`],[`🇬🇧`,`flag united kingdom`,`flags`,`英国,国旗,UK`],[`🇯🇵`,`flag japan`,`flags`,`日本,国旗`],[`🇫🇷`,`flag france`,`flags`,`法国,国旗`],[`🇩🇪`,`flag germany`,`flags`,`德国,国旗`],[`🇮🇹`,`flag italy`,`flags`,`意大利,国旗`],[`🇪🇸`,`flag spain`,`flags`,`西班牙,国旗`],[`🇷🇺`,`flag russia`,`flags`,`俄罗斯,国旗`],[`🇮🇳`,`regional indicator symbol letter i`,`flags`,`印度,国旗`],[`🇧🇷`,`flag brazil`,`flags`,`巴西,国旗`],[`🇨🇦`,`flag canada`,`flags`,`加拿大,国旗`],[`🇦🇺`,`flag australia`,`flags`,`澳大利亚,国旗`],[`🇸🇬`,`flag singapore`,`flags`,`新加坡,国旗`],[`🇭🇰`,`flag hong kong`,`flags`,`香港,国旗,区旗`],[`🇹🇼`,`flag taiwan`,`flags`,`台湾,国旗`],[`🇲🇴`,`flag macau`,`flags`,`澳门,国旗`],[`🇻🇳`,`flag vietnam`,`flags`,`越南,国旗`],[`🇲🇾`,`regional indicator symbol letter m`,`flags`,`马来西亚,国旗`],[`🇮🇩`,`flag indonesia`,`flags`,`印尼,国旗`],[`🇵🇭`,`flag philippines`,`flags`,`菲律宾,国旗`],[`🇹🇷`,`flag turkey`,`flags`,`土耳其,国旗`],[`🇸🇦`,`flag saudi arabia`,`flags`,`沙特,国旗`],[`🇦🇪`,`flag united arab emirates`,`flags`,`阿联酋,国旗`],[`🇳🇱`,`flag netherlands`,`flags`,`荷兰,国旗`],[`🇸🇪`,`flag sweden`,`flags`,`瑞典,国旗`],[`🇨🇭`,`flag switzerland`,`flags`,`瑞士,国旗`],[`🇦🇹`,`flag austria`,`flags`,`奥地利,国旗`],[`🇧🇪`,`flag belgium`,`flags`,`比利时,国旗`],[`🇵🇹`,`flag portugal`,`flags`,`葡萄牙,国旗`],[`🇬🇷`,`flag greece`,`flags`,`希腊,国旗`],[`🇳🇴`,`flag norway`,`flags`,`挪威,国旗`],[`🇩🇰`,`flag denmark`,`flags`,`丹麦,国旗`],[`🇫🇮`,`flag finland`,`flags`,`芬兰,国旗`],[`🇵🇱`,`flag poland`,`flags`,`波兰,国旗`],[`🇺🇦`,`flag ukraine`,`flags`,`乌克兰,国旗`],[`🇮🇱`,`flag israel`,`flags`,`以色列,国旗`],[`🇪🇬`,`flag egypt`,`flags`,`埃及,国旗`],[`🇿🇦`,`flag south africa`,`flags`,`南非,国旗`],[`🇳🇬`,`flag nigeria`,`flags`,`尼日利亚,国旗`],[`🇲🇽`,`flag mexico`,`flags`,`墨西哥,国旗`],[`🇦🇷`,`flag argentina`,`flags`,``],[`🇨🇱`,`flag chile`,`flags`,`智利,国旗`],[`🇰🇿`,`flag kazakhstan`,`flags`,`哈萨克斯坦,国旗`],[`🇺🇿`,`flag uzbekistan`,`flags`,`乌兹别克斯坦,国旗`],[`🇳🇿`,`flag new zealand`,`flags`,`新西兰,国旗`],[`🇮🇪`,`flag ireland`,`flags`,`爱尔兰,国旗`],[`🇨🇿`,`flag czechia`,`flags`,`捷克,国旗`],[`👍🏻`,`thumbs up light skin`,`people`,``],[`👍🏽`,`thumbs up sign`,`people`,``],[`👍🏾`,`thumbs up medium dark skin`,`people`,``],[`👍🏿`,`thumbs up dark skin`,`people`,``],[`👏🏻`,`clapping hands light skin`,`people`,``],[`👏🏼`,`clapping hands medium light skin`,`people`,``],[`👏🏽`,`clapping hands medium skin`,`people`,``],[`👏🏾`,`clapping hands medium dark skin`,`people`,``],[`👏🏿`,`clapping hands dark skin`,`people`,``],[`🙏🏻`,`folded hands light skin`,`smileys`,``],[`🙏🏼`,`folded hands medium light skin`,`smileys`,``],[`🙏🏽`,`folded hands medium skin`,`smileys`,``],[`🙏🏾`,`folded hands medium dark skin`,`smileys`,``],[`🙏🏿`,`folded hands dark skin`,`smileys`,``],[`🏳️🌈`,`rainbow flag`,`flags`,``],[`🏴☠️`,`pirate flag`,`flags`,`海盗旗,海盗`]];n(`zh`,{agentMgr:{allTools:`全部`,defaultAgentName:`默认助手`,defaultAgentDesc:`全能 AI 助手,拥有所有工具能力`,switchedTo:`已切换到:{name}`,editAgent:`编辑助手`,templateLoaded:`已加载模板:{name}`,noSkillsHint:`暂无启用技能(请先确认 Agent 已连接且技能开关已开启)`,nameRequired:`请输入助手名称`,agentUpdated:`助手已更新`,agentCreated:`助手 "{name}" 已创建`,saveFailed:`保存失败:{message}`,confirmDeleteAgentMessage:`确定要删除助手 "{name}" 吗?
|
|
2034
2041
|
正在使用该助手的会话将恢复为默认助手。`,deleteAgentTitle:`删除助手`,agentDeleted:`助手已删除`,deleteFailed:`删除失败:{message}`,cannotDeleteDefault:`默认助手不支持删除`,emojiCatSmileys:`笑脸与表情`,emojiCatPeople:`人物与身体`,emojiCatAnimals:`动物与自然`,emojiCatFood:`食物与饮品`,emojiCatTravel:`旅行与交通`,emojiCatActivity:`活动与运动`,emojiCatObjects:`物品`,emojiCatSymbols:`符号`,emojiCatFlags:`旗帜`,emojiSearchPlaceholder:`搜索 Emoji(英文名 / 中文关键词)`,emojiSearchClear:`清空搜索`,emojiNoMatch:`未找到匹配的 Emoji`,confirm:`确认`},agentTemplates:{codeReviewName:`代码审查专家`,codeReviewDesc:`专注于代码审查和质量保证`,webAutomationName:`网页自动化助手`,webAutomationDesc:`专注于网页交互和自动化`,dataAnalystName:`数据分析师`,dataAnalystDesc:`专注于数据提取、分析和可视化`,documentationName:`文档助手`,documentationDesc:`专注于技术文档和内容整理`}}),n(`en`,{agentMgr:{allTools:`All`,defaultAgentName:`Default Assistant`,defaultAgentDesc:`All-purpose AI assistant with all tool capabilities`,switchedTo:`Switched to: {name}`,editAgent:`Edit assistant`,templateLoaded:`Template loaded: {name}`,noSkillsHint:`No enabled skills (please confirm Agent is connected and skill switch is on)`,nameRequired:`Please enter assistant name`,agentUpdated:`Assistant updated`,agentCreated:`Assistant "{name}" created`,saveFailed:`Save failed: {message}`,confirmDeleteAgentMessage:`Are you sure you want to delete assistant "{name}"?
|
|
2035
|
-
Sessions using this assistant will revert to the default assistant.`,deleteAgentTitle:`Delete assistant`,agentDeleted:`Assistant deleted`,deleteFailed:`Delete failed: {message}`,cannotDeleteDefault:`Default assistant cannot be deleted`,emojiCatSmileys:`Smileys & Emotion`,emojiCatPeople:`People & Body`,emojiCatAnimals:`Animals & Nature`,emojiCatFood:`Food & Drink`,emojiCatTravel:`Travel & Places`,emojiCatActivity:`Activities`,emojiCatObjects:`Objects`,emojiCatSymbols:`Symbols`,emojiCatFlags:`Flags`,emojiSearchPlaceholder:`Search emoji (name / keyword)`,emojiSearchClear:`Clear search`,emojiNoMatch:`No matching emoji`,confirm:`Confirm`},agentTemplates:{codeReviewName:`Code Review Expert`,codeReviewDesc:`Focused on code review and quality assurance`,webAutomationName:`Web Automation Assistant`,webAutomationDesc:`Focused on web interaction and automation`,dataAnalystName:`Data Analyst`,dataAnalystDesc:`Focused on data extraction, analysis, and visualization`,documentationName:`Documentation Assistant`,documentationDesc:`Focused on technical documentation and content organization`}});async function
|
|
2042
|
+
Sessions using this assistant will revert to the default assistant.`,deleteAgentTitle:`Delete assistant`,agentDeleted:`Assistant deleted`,deleteFailed:`Delete failed: {message}`,cannotDeleteDefault:`Default assistant cannot be deleted`,emojiCatSmileys:`Smileys & Emotion`,emojiCatPeople:`People & Body`,emojiCatAnimals:`Animals & Nature`,emojiCatFood:`Food & Drink`,emojiCatTravel:`Travel & Places`,emojiCatActivity:`Activities`,emojiCatObjects:`Objects`,emojiCatSymbols:`Symbols`,emojiCatFlags:`Flags`,emojiSearchPlaceholder:`Search emoji (name / keyword)`,emojiSearchClear:`Clear search`,emojiNoMatch:`No matching emoji`,confirm:`Confirm`},agentTemplates:{codeReviewName:`Code Review Expert`,codeReviewDesc:`Focused on code review and quality assurance`,webAutomationName:`Web Automation Assistant`,webAutomationDesc:`Focused on web interaction and automation`,dataAnalystName:`Data Analyst`,dataAnalystDesc:`Focused on data extraction, analysis, and visualization`,documentationName:`Documentation Assistant`,documentationDesc:`Focused on technical documentation and content organization`}});async function fC(){await pC(),await mC(),_C(),yC(),a.debug(`[AgentMgr] Agent managerinitialization complete, activeAgentId:`,N.activeAgentId)}async function pC(){let[e,t]=await Promise.all([st(),lt()]);N.activeSessionId||(N.activeAgentId=e),N.customAgents=t.filter(e=>!e.isBuiltin);let n=N.activeAgentId||e,r=t.find(e=>e.id===n||!n&&e.id==="default");N.activeAgentToolIds=r?r.toolIds:null,a.debug(`[AgentMgr] Agent state loaded, activeAgentId:`,N.activeAgentId,`total:`,t.length,`toolIds:`,N.activeAgentToolIds)}async function mC(){let e=document.getElementById(`agentListItems`),t=document.getElementById(`agentDropdownFooter`);if(!e)return;let n=await lt(),i=N.activeAgentId,a=``;for(let e of n){let t=e.id===i||!i&&e.id==="default",n=e.toolIds?e.toolIds.length:r(`agentMgr.allTools`),o=e.id==="default"?r(`agentMgr.defaultAgentName`):e.name,s=e.id==="default"?r(`agentMgr.defaultAgentDesc`):e.description||r(`agentConfig.toolCount`,{count:n});a+=`
|
|
2036
2043
|
<div class="agent-item ${t?`active`:``} ${e.isBuiltin?``:`is-editable`}" data-agent-id="${$(e.id)}">
|
|
2037
|
-
<span class="agent-item-icon">${
|
|
2044
|
+
<span class="agent-item-icon">${tw(e.icon)}</span>
|
|
2038
2045
|
<div class="agent-item-info">
|
|
2039
|
-
<span class="agent-item-name">${
|
|
2040
|
-
<span class="agent-item-desc" title="${$(s)}">${
|
|
2046
|
+
<span class="agent-item-name">${tw(o)}</span>
|
|
2047
|
+
<span class="agent-item-desc" title="${$(s)}">${tw(s)}</span>
|
|
2041
2048
|
</div>
|
|
2042
2049
|
<div class="agent-item-actions">
|
|
2043
2050
|
${e.isBuiltin?``:`<button class="agent-item-edit" data-action="edit" data-agent-id="${$(e.id)}" title="${$(r(`common.edit`))}">✎</button>`}
|
|
@@ -2048,25 +2055,25 @@ Sessions using this assistant will revert to the default assistant.`,deleteAgent
|
|
|
2048
2055
|
<div class="agent-item" id="agentAddBtn" style="color:var(--brand-500);">
|
|
2049
2056
|
<span class="agent-item-icon" style="color:var(--brand-500);">+</span>
|
|
2050
2057
|
<span class="agent-item-name">${r(`agentEditor.createNew`)}</span>
|
|
2051
|
-
</div>`),fC(n,i)}function fC(e,t){let n=document.getElementById(`agentSelectorBtn`),i=document.getElementById(`agentSelectorText`),a=document.getElementById(`agentSelectorEmoji`);if(!n||!i)return;let o=e.find(e=>e.id===t)||e.find(e=>e.id==="default");if(o){let e=o.id==="default"?r(`agentMgr.defaultAgentName`):o.name;i.textContent=`${o.icon} ${e}`,a&&(a.textContent=o.icon),n.title=`${r(`header.switchAgent`)}: ${o.icon} ${e}`}else i.textContent=r(`header.defaultAssistant`),a&&(a.textContent=`🤖`),n.title=r(`header.switchAgent`)}function pC(){let e=document.getElementById(`agentSelectorBtn`),t=document.getElementById(`agentSelectorDropdown`),n=document.getElementById(`agentSelectorWrapper`);if(!e||!t||!n)return;let r=n.getBoundingClientRect(),i=document.body.clientWidth;t.style.left=``,t.style.right=`auto`,t.style.maxWidth=Math.min(320,i-16)+`px`;let a=t.getBoundingClientRect().width,o=Math.min(a,i-16),s=e.getBoundingClientRect(),c=s.left+s.width/2,l=i-o-8,u=Math.max(8,Math.min(l,c-o/2));t.style.left=u-r.left+`px`}function mC(){let e=document.getElementById(`agentSelectorBtn`),t=document.getElementById(`agentSelectorDropdown`);!e||!t||(e.addEventListener(`click`,async e=>{if(e.stopPropagation(),t.style.display===`flex`)t.style.display=`none`;else{t.style.left=``,t.style.right=`auto`,t.style.maxWidth=Math.min(320,document.body.clientWidth-16)+`px`,t.style.display=`flex`,pC();try{await dC()}catch{}pC()}}),document.addEventListener(`click`,()=>{t.style.display=`none`}),t.addEventListener(`click`,async e=>{let n=e.target.closest(`.agent-item`);if(!n)return;let r=e.target.closest(`[data-action]`);if(r&&r.dataset.action===`edit`){e.stopPropagation();let t=r.dataset.agentId;kC(t);return}if(r&&r.dataset.action===`delete`){e.stopPropagation(),await YC(r.dataset.agentId);return}if(n.id===`agentAddBtn`){kC(null);return}let i=n.dataset.agentId;i&&(await hC(i),t.style.display=`none`)}))}async function hC(e){let t=e?await at(e):null;if(N.activeAgentId=e,N.activeAgentToolIds=t?t.toolIds:null,N.activeAgentMcpExcludedServerIds=t?t.mcpExcludedServerIds??null:null,await dt(e),_i().catch(()=>{}),t&&!t.isBuiltin)t.model&&(N.currentModel=t.model),t.temperature!==null&&t.temperature!==void 0&&(N.temperature=t.temperature,N.topP=t.topP!==null&&t.topP!==void 0?t.topP:1),document.dispatchEvent(new CustomEvent(`agent-model-changed`));else if(!t||t.isBuiltin)try{let e=await chrome.storage.local.get([`modelName`,`temperature`,`topP`]);e.modelName&&(N.currentModel=e.modelName),e.temperature!==void 0&&(N.temperature=e.temperature),e.topP!==void 0&&(N.topP=e.topP),document.dispatchEvent(new CustomEvent(`agent-model-changed`))}catch{}await dC();let n=`agentMcpClosedServers_${e||`default`}`,i=await chrome.storage.local.get([n,`ragTools`,`ragToolsIntroduced`]),o=i.ragTools||[];N.mcpClosedServers=i[n]||[];let s=`agentEnabledTools_${e||`default`}`,c=await chrome.storage.local.get([s,`enabledTools`]),l=!!c[s],u=c[s]||c.enabledTools;if(l||u&&u.length>0){let e=da(o),t=u.filter(t=>e.has(t));if(l)N.enabledTools=t;else{let e=b.filter(e=>e.enabled&&!t.includes(e.id)).map(e=>e.id);N.enabledTools=[...t,...e]}let n=ua(N.enabledTools,o,i.ragToolsIntroduced);N.enabledTools=n.tools,N.enabledTools.length!==u.length&&chrome.storage.local.set({[s]:N.enabledTools,...n.migrated?{ragToolsIntroduced:!0}:{}})}else{N.enabledTools=b.filter(e=>e.enabled).map(e=>e.id);let e=ua(N.enabledTools,o,i.ragToolsIntroduced);N.enabledTools=e.tools,e.migrated&&chrome.storage.local.set({ragToolsIntroduced:!0,[s]:N.enabledTools})}let d=document.getElementById(`toolsPopupOverlay`);d&&d.classList.contains(`show`)&&(Xi(),ia(),aa()),ca();let f=t&&t.id!=="default"?t.name:r(`agentMgr.defaultAgentName`);P(r(`agentMgr.switchedTo`,{name:f}),`info`,2e3),a.debug(`[AgentMgr] switched Agent:`,e,f)}function gC(){let e=document.getElementById(`agentEditModal`);if(!e)return;e.querySelector(`#agentModalCloseBtn`)?.addEventListener(`click`,AC),e.querySelector(`#agentSaveBtn`)?.addEventListener(`click`,qC),e.querySelector(`#agentDeleteBtn`)?.addEventListener(`click`,JC),e.querySelector(`#agentTemplateSelect`)?.addEventListener(`change`,MC),xC();let t=document.getElementById(`agentToolActions`);t&&t.addEventListener(`click`,e=>{let t=e.target.closest(`button`);if(!t)return;let n=t.dataset.action;n===`selectAll`?SC():n===`deselectAll`?CC():n===`toggleSelectedOnly`&&(NC.selectedOnly=!NC.selectedOnly,FC())});let n=document.getElementById(`agentToolSearchInput`);if(n){let e=null,t=document.getElementById(`agentToolSearchClear`),r=()=>{t&&(t.style.display=n.value?`block`:`none`)};n.addEventListener(`input`,()=>{r(),clearTimeout(e),e=setTimeout(()=>{NC.searchText=n.value,FC()},150)}),t&&t.addEventListener(`click`,()=>{clearTimeout(e),n.value=``,r(),NC.searchText=``,FC(),n.focus()}),r()}let r=document.getElementById(`agentSkillActions`);r&&r.addEventListener(`click`,e=>{let t=e.target.closest(`button`);if(!t)return;let n=t.dataset.action;n===`selectAllSkills`?wC():n===`deselectAllSkills`?TC():n===`toggleSelectedOnlySkills`&&(zC.selectedOnly=!zC.selectedOnly,VC())});let i=document.getElementById(`agentSkillSearchInput`);if(i){let e=null,t=document.getElementById(`agentSkillSearchClear`),n=()=>{t&&(t.style.display=i.value?`block`:`none`)};i.addEventListener(`input`,()=>{n(),clearTimeout(e),e=setTimeout(()=>{zC.searchText=i.value,VC()},150)}),t&&t.addEventListener(`click`,()=>{clearTimeout(e),i.value=``,n(),zC.searchText=``,VC(),i.focus()}),n()}let a=document.getElementById(`agentToolList`);a&&(a.addEventListener(`click`,e=>{let t=e.target.closest(`.agent-mcp-expand-btn`);if(t){e.preventDefault(),IC(t.dataset.serverId,t);return}let n=e.target.closest(`.agent-mcp-service-item`);if(n&&!e.target.closest(`input[type="checkbox"]`)){e.preventDefault(),IC(n.dataset.mcpServerId,n.querySelector(`.agent-mcp-expand-btn`));return}let r=e.target.closest(`.agent-tool-category-clickable`);r&&EC(r.dataset.category)}),a.addEventListener(`change`,e=>{if(!e.target.matches(`input[type="checkbox"]`))return;let t=NC,n=e.target.dataset.toolId,r=e.target.dataset.mcpServerId;t.inheritMode=!1,n?e.target.checked?t.selectedSet.add(n):t.selectedSet.delete(n):r&&(e.target.checked?t.excludedSet.delete(r):t.excludedSet.add(r)),t.selectedOnly?FC():DC()}));let o=document.getElementById(`agentSkillList`);o&&o.addEventListener(`change`,e=>{if(!e.target.matches(`input[type="checkbox"]`))return;let t=zC;t.inheritMode=!1,e.target.checked?t.selectedSet.add(e.target.value):t.selectedSet.delete(e.target.value),t.selectedOnly&&!e.target.checked?VC():OC()}),document.addEventListener(`click`,e=>{let t=document.getElementById(`emojiPicker`),n=document.getElementById(`agentEditIconBtn`);t&&n&&t.style.display===`block`&&!n.contains(e.target)&&!t.contains(e.target)&&(t.style.display=`none`)})}var _C=[[`smileys`,`emojiCatSmileys`],[`people`,`emojiCatPeople`],[`animals`,`emojiCatAnimals`],[`food`,`emojiCatFood`],[`travel`,`emojiCatTravel`],[`activity`,`emojiCatActivity`],[`objects`,`emojiCatObjects`],[`symbols`,`emojiCatSymbols`],[`flags`,`emojiCatFlags`]];function vC(e,t){return!!(e[1].includes(t)||e[3]&&e[3].includes(t))}function yC(e){let t=``;for(let[e,n]of _C){let i=cC.filter(t=>t[2]===e);if(i.length){t+=`<div class="emoji-category-label">${r(`agentMgr.`+n)}</div>`,t+=`<div class="emoji-picker-grid">`;for(let e of i)t+=`<button type="button" class="emoji-picker-item" data-emoji="${$(e[0])}" title="${$(e[1])}">${e[0]}</button>`;t+=`</div>`}}e.innerHTML=t}function bC(e,t){let n=cC.filter(e=>vC(e,t));if(!n.length){e.innerHTML=`<div class="emoji-picker-empty">${r(`agentMgr.emojiNoMatch`)}</div>`;return}let i=`<div class="emoji-picker-grid">`;for(let e of n)i+=`<button type="button" class="emoji-picker-item" data-emoji="${$(e[0])}" title="${$(e[1])}">${e[0]}</button>`;i+=`</div>`,e.innerHTML=i}function xC(){let e=document.getElementById(`emojiPicker`),t=document.getElementById(`agentEditIconBtn`),n=document.getElementById(`agentEditIcon`),r=document.getElementById(`emojiSearchInput`),i=document.getElementById(`emojiSearchClear`),a=document.getElementById(`emojiPickerBody`);if(!e||!t)return;let o=()=>{let e=r?r.value.trim().toLowerCase():``;e?bC(a,e):yC(a),i&&(i.style.display=e?`flex`:`none`)};t.addEventListener(`click`,n=>{if(n.stopPropagation(),e.style.display===`block`){e.style.display=`none`;return}r&&(r.value=``),o();let i=t.getBoundingClientRect();document.body.clientWidth-i.left>=330?(e.style.left=`0`,e.style.right=`auto`):(e.style.left=`auto`,e.style.right=`0`),e.style.display=`block`}),r&&r.addEventListener(`input`,o),i&&i.addEventListener(`click`,e=>{e.stopPropagation(),r&&(r.value=``),o(),r&&r.focus()}),e.addEventListener(`click`,r=>{let i=r.target.closest(`.emoji-picker-item`);if(!i)return;let a=i.dataset.emoji;t.textContent=a,n&&(n.value=a),e.style.display=`none`})}function SC(){let e=NC;e.inheritMode=!1,e.allTools.forEach(t=>e.selectedSet.add(t.id)),e.mcpServices.forEach(t=>e.excludedSet.delete(t.serverId)),FC()}function CC(){let e=NC;e.inheritMode=!1,e.allTools.forEach(t=>e.selectedSet.delete(t.id)),e.mcpServices.forEach(t=>e.excludedSet.add(t.serverId)),FC()}function wC(){let e=zC;e.inheritMode=!1,e.skills.forEach(t=>e.selectedSet.add(t.name)),VC()}function TC(){let e=zC;e.inheritMode=!1,e.selectedSet.clear(),VC()}function EC(e){let t=NC;if(e===`mcp`){if(t.mcpServices.length===0)return;t.inheritMode=!1;let e=t.mcpServices.every(e=>!t.excludedSet.has(e.serverId));t.mcpServices.forEach(n=>{e?t.excludedSet.add(n.serverId):t.excludedSet.delete(n.serverId)}),document.querySelectorAll(`#agentToolList .agent-mcp-service-item input[type="checkbox"]`).forEach(t=>{t.checked=!e})}else{let n=t.allTools.filter(t=>(t.category||`other`)===e);if(n.length===0)return;t.inheritMode=!1;let r=n.every(e=>t.selectedSet.has(e.id));n.forEach(e=>{r?t.selectedSet.delete(e.id):t.selectedSet.add(e.id)}),document.querySelectorAll(`#agentToolList .agent-tool-item[data-category="${e}"] input[type="checkbox"]`).forEach(e=>{e.checked=!r})}t.selectedOnly?FC():DC()}function DC(){let e=NC,t=document.getElementById(`agentToolList`);if(!t)return;let n=e.mcpServices.filter(t=>!e.excludedSet.has(t.serverId)).length;t.querySelectorAll(`.agent-tool-category-clickable`).forEach(t=>{let r=t.dataset.category,i=t.querySelector(`.agent-tool-cat-count`);if(i)if(r===`mcp`)i.textContent=`${n}/${e.mcpServices.length}`;else{let t=e.allTools.filter(e=>(e.category||`other`)===r);i.textContent=`${t.filter(t=>e.selectedSet.has(t.id)).length}/${t.length}`}});let i=document.getElementById(`agentToolCount`);if(i){let t=e.allTools.filter(t=>e.selectedSet.has(t.id)).length,a=e.allTools.length+e.mcpServices.length;i.textContent=r(`agentConfig.selectedTotalCount`,{selected:e.inheritMode?a:t+n,total:a})}}function OC(){let e=document.getElementById(`agentSkillCount`);if(!e)return;let t=zC,n=t.skills.length;e.textContent=r(`agentConfig.selectedTotalCount`,{selected:t.inheritMode?n:t.selectedSet.size,total:n})}async function kC(e){let t=document.getElementById(`agentEditModal`);if(!t)return;await UC(),WC(-1),t.querySelector(`#agentEditId`).value=``,t.querySelector(`#agentEditName`).value=``,t.querySelector(`#agentEditIcon`).value=`🤖`;let n=t.querySelector(`#agentEditIconBtn`);n&&(n.textContent=`🤖`),t.querySelector(`#agentEditDesc`).value=``,t.querySelector(`#agentEditPrompt`).value=``,t.querySelector(`#agentEditAllowSub`).checked=!1,t.querySelector(`#agentTemplateSelect`).value=``,t.querySelector(`#agentEditModel`).value=``;let i=t.querySelector(`#agentDeleteBtn`),a=t.querySelector(`#agentEditTitle`);if(e){let n=await at(e);if(!n||n.isBuiltin)return;a.textContent=r(`agentMgr.editAgent`),t.querySelector(`#agentEditId`).value=n.id,t.querySelector(`#agentEditName`).value=n.name,t.querySelector(`#agentEditIcon`).value=n.icon||`🤖`;let o=t.querySelector(`#agentEditIconBtn`);o&&(o.textContent=n.icon||`🤖`),t.querySelector(`#agentEditDesc`).value=n.description||``,t.querySelector(`#agentEditPrompt`).value=n.systemPrompt||``,t.querySelector(`#agentEditAllowSub`).checked=n.allowSubDispatch||!1,t.querySelector(`#agentEditModel`).value=n.model||``,WC(KC(n.temperature,n.topP)),i.style.display=`block`,PC(n.toolIds,n.mcpExcludedServerIds??[]),BC(n.skillIds)}else a.textContent=r(`agentEditor.createNew`),i.style.display=`none`,PC(null,[]),BC(null);jC(),t.style.display=`flex`;let o=t.querySelector(`#agentEditModel`);if(o){let e=o.value,t=o.cloneNode(!0);o.parentNode.replaceChild(t,o),t.value=e,t.addEventListener(`mousedown`,()=>{let e=t.value;e&&(t.dataset._saved=e,t.value=``)}),t.addEventListener(`blur`,()=>{setTimeout(()=>{t.value||=t.dataset._saved||``},150)})}}function AC(){let e=document.getElementById(`agentEditModal`);e&&(e.style.display=`none`)}function jC(){let e=document.getElementById(`agentTemplateSelect`);if(!e)return;let t=[r(`agentTemplates.codeReviewName`),r(`agentTemplates.webAutomationName`),r(`agentTemplates.dataAnalystName`),r(`agentTemplates.documentationName`)],n=`<option value="">${r(`agentEditor.selectTemplate`)}</option>`;for(let e=0;e<j.length;e++){let r=j[e];n+=`<option value="${e}">${r.icon} ${t[e]}</option>`}e.innerHTML=n}function MC(e){let t=parseInt(e.target.value);if(isNaN(t)||t<0||t>=j.length)return;let n=j[t],i=document.getElementById(`agentEditModal`);if(!i)return;let a=[`agentTemplates.codeReviewName`,`agentTemplates.webAutomationName`,`agentTemplates.dataAnalystName`,`agentTemplates.documentationName`],o=[`agentTemplates.codeReviewDesc`,`agentTemplates.webAutomationDesc`,`agentTemplates.dataAnalystDesc`,`agentTemplates.documentationDesc`];i.querySelector(`#agentEditName`).value=r(a[t]),i.querySelector(`#agentEditIcon`).value=n.icon;let c=i.querySelector(`#agentEditIconBtn`);c&&(c.textContent=n.icon),i.querySelector(`#agentEditDesc`).value=r(o[t]),i.querySelector(`#agentEditPrompt`).value=s()===`en`?n.systemPrompt:n.systemPromptZh||n.systemPrompt,i.querySelector(`#agentEditAllowSub`).checked=n.allowSubDispatch||!1,i.querySelector(`#agentEditModel`).value=n.model||``,WC(KC(n.temperature,n.topP)),PC(n.toolIds,[]),BC(n.skillIds||null),P(r(`agentMgr.templateLoaded`,{name:n.name}),`info`,2e3)}var NC={allTools:[],mcpServices:[],selectedSet:new Set,excludedSet:new Set,searchText:``,selectedOnly:!1,inheritMode:!1};async function PC(e,t){if(!document.getElementById(`agentToolList`))return;let n=[];try{n=(await chrome.storage.local.get([`mcpTools`])).mcpTools||[]}catch{}let{mcpEnabled:r,skillsEnabled:i,ragTools:a}=await chrome.storage.local.get([`mcpEnabled`,`skillsEnabled`,`ragTools`]),o=N.agentPlatform?.connected===!0,s=[...b,...a||[]];o||(s=s.filter(e=>!e.id.startsWith(`agent_`)&&!e.id.startsWith(`knowledge_`))),i===!1&&(s=s.filter(e=>e.id!==`agent_skill`));let c=[];if(r===!0&&o){let e=new Map;for(let t of n){let n=t.serverId||`unknown`;e.has(n)||e.set(n,{serverId:n,serverName:t.serverName||n,tools:[]}),e.get(n).tools.push(t)}c=Array.from(e.values())}let l=new Set(Array.isArray(t)?t:[]),u=NC;u.allTools=s,u.mcpServices=c,u.selectedSet=new Set(e||[]),u.excludedSet=l,u.searchText=``,u.selectedOnly=!1,u.inheritMode=!e;let d=document.getElementById(`agentToolSearchInput`);d&&(d.value=``);let f=document.getElementById(`agentToolSearchClear`);f&&(f.style.display=`none`),FC()}function FC(){let e=document.getElementById(`agentToolList`);if(!e)return;let t=NC,n=ha({tools:t.allTools,services:t.mcpServices,selectedSet:t.selectedSet,excludedSet:t.excludedSet,query:t.searchText,selectedOnly:t.selectedOnly,getDesc:ji}),i=t.mcpServices.filter(e=>!t.excludedSet.has(e.serverId)).length,a={};for(let e of n.tools){let t=e.category||`other`;a[t]||(a[t]=[]),a[t].push(e)}let o=``;for(let[e,n]of Object.entries(a)){let i=r(`toolCategory.${e}`)===`toolCategory.${e}`?e:r(`toolCategory.${e}`),a=t.allTools.filter(t=>(t.category||`other`)===e),s=a.filter(e=>t.selectedSet.has(e.id)).length;o+=`<div class="agent-tool-category agent-tool-category-clickable" data-category="${$(e)}" title="${$(r(`agentConfig.toggleCategoryAll`))}">${i} <span class="agent-tool-cat-count" style="font-weight:400;color:var(--text-tertiary);">${s}/${a.length}</span></div>`;for(let r of n){let n=t.selectedSet.has(r.id)?`checked`:``,i=ji(r),a=i.length>40?i.substring(0,40)+`...`:i;o+=`
|
|
2058
|
+
</div>`),hC(n,i)}function hC(e,t){let n=document.getElementById(`agentSelectorBtn`),i=document.getElementById(`agentSelectorText`),a=document.getElementById(`agentSelectorEmoji`);if(!n||!i)return;let o=e.find(e=>e.id===t)||e.find(e=>e.id==="default");if(o){let e=o.id==="default"?r(`agentMgr.defaultAgentName`):o.name;i.textContent=`${o.icon} ${e}`,a&&(a.textContent=o.icon),n.title=`${r(`header.switchAgent`)}: ${o.icon} ${e}`}else i.textContent=r(`header.defaultAssistant`),a&&(a.textContent=`🤖`),n.title=r(`header.switchAgent`)}function gC(){let e=document.getElementById(`agentSelectorBtn`),t=document.getElementById(`agentSelectorDropdown`),n=document.getElementById(`agentSelectorWrapper`);if(!e||!t||!n)return;let r=n.getBoundingClientRect(),i=document.body.clientWidth;t.style.left=``,t.style.right=`auto`,t.style.maxWidth=Math.min(320,i-16)+`px`;let a=t.getBoundingClientRect().width,o=Math.min(a,i-16),s=e.getBoundingClientRect(),c=s.left+s.width/2,l=i-o-8,u=Math.max(8,Math.min(l,c-o/2));t.style.left=u-r.left+`px`}function _C(){let e=document.getElementById(`agentSelectorBtn`),t=document.getElementById(`agentSelectorDropdown`);!e||!t||(e.addEventListener(`click`,async e=>{if(e.stopPropagation(),t.style.display===`flex`)t.style.display=`none`;else{t.style.left=``,t.style.right=`auto`,t.style.maxWidth=Math.min(320,document.body.clientWidth-16)+`px`,t.style.display=`flex`,gC();try{await mC()}catch{}gC()}}),document.addEventListener(`click`,()=>{t.style.display=`none`}),t.addEventListener(`click`,async e=>{let n=e.target.closest(`.agent-item`);if(!n)return;let r=e.target.closest(`[data-action]`);if(r&&r.dataset.action===`edit`){e.stopPropagation();let t=r.dataset.agentId;MC(t);return}if(r&&r.dataset.action===`delete`){e.stopPropagation(),await QC(r.dataset.agentId);return}if(n.id===`agentAddBtn`){MC(null);return}let i=n.dataset.agentId;i&&(await vC(i),t.style.display=`none`)}))}async function vC(e){let t=e?await at(e):null;if(N.activeAgentId=e,N.activeAgentToolIds=t?t.toolIds:null,N.activeAgentMcpExcludedServerIds=t?t.mcpExcludedServerIds??null:null,await dt(e),_i().catch(()=>{}),t&&!t.isBuiltin)t.model&&(N.currentModel=t.model),t.temperature!==null&&t.temperature!==void 0&&(N.temperature=t.temperature,N.topP=t.topP!==null&&t.topP!==void 0?t.topP:1),document.dispatchEvent(new CustomEvent(`agent-model-changed`));else if(!t||t.isBuiltin)try{let e=await chrome.storage.local.get([`modelName`,`temperature`,`topP`]);e.modelName&&(N.currentModel=e.modelName),e.temperature!==void 0&&(N.temperature=e.temperature),e.topP!==void 0&&(N.topP=e.topP),document.dispatchEvent(new CustomEvent(`agent-model-changed`))}catch{}await mC();let n=`agentMcpClosedServers_${e||`default`}`,i=await chrome.storage.local.get([n,`ragTools`,`ragToolsIntroduced`]),o=i.ragTools||[];N.mcpClosedServers=i[n]||[];let s=`agentEnabledTools_${e||`default`}`,c=await chrome.storage.local.get([s,`enabledTools`]),l=!!c[s],u=c[s]||c.enabledTools;if(l||u&&u.length>0){let e=da(o),t=u.filter(t=>e.has(t));if(l)N.enabledTools=t;else{let e=b.filter(e=>e.enabled&&!t.includes(e.id)).map(e=>e.id);N.enabledTools=[...t,...e]}let n=ua(N.enabledTools,o,i.ragToolsIntroduced);N.enabledTools=n.tools,N.enabledTools.length!==u.length&&chrome.storage.local.set({[s]:N.enabledTools,...n.migrated?{ragToolsIntroduced:!0}:{}})}else{N.enabledTools=b.filter(e=>e.enabled).map(e=>e.id);let e=ua(N.enabledTools,o,i.ragToolsIntroduced);N.enabledTools=e.tools,e.migrated&&chrome.storage.local.set({ragToolsIntroduced:!0,[s]:N.enabledTools})}let d=document.getElementById(`toolsPopupOverlay`);d&&d.classList.contains(`show`)&&(Xi(),ia(),aa()),ca();let f=t&&t.id!=="default"?t.name:r(`agentMgr.defaultAgentName`);P(r(`agentMgr.switchedTo`,{name:f}),`info`,2e3),a.debug(`[AgentMgr] switched Agent:`,e,f)}function yC(){let e=document.getElementById(`agentEditModal`);if(!e)return;e.querySelector(`#agentModalCloseBtn`)?.addEventListener(`click`,NC),e.querySelector(`#agentSaveBtn`)?.addEventListener(`click`,XC),e.querySelector(`#agentDeleteBtn`)?.addEventListener(`click`,ZC),e.querySelector(`#agentTemplateSelect`)?.addEventListener(`change`,FC),wC();let t=document.getElementById(`agentToolActions`);t&&t.addEventListener(`click`,e=>{let t=e.target.closest(`button`);if(!t)return;let n=t.dataset.action;n===`selectAll`?TC():n===`deselectAll`?EC():n===`toggleSelectedOnly`&&(IC.selectedOnly=!IC.selectedOnly,RC())});let n=document.getElementById(`agentToolSearchInput`);if(n){let e=null,t=document.getElementById(`agentToolSearchClear`),r=()=>{t&&(t.style.display=n.value?`block`:`none`)};n.addEventListener(`input`,()=>{r(),clearTimeout(e),e=setTimeout(()=>{IC.searchText=n.value,RC()},150)}),t&&t.addEventListener(`click`,()=>{clearTimeout(e),n.value=``,r(),IC.searchText=``,RC(),n.focus()}),r()}let r=document.getElementById(`agentSkillActions`);r&&r.addEventListener(`click`,e=>{let t=e.target.closest(`button`);if(!t)return;let n=t.dataset.action;n===`selectAllSkills`?DC():n===`deselectAllSkills`?OC():n===`toggleSelectedOnlySkills`&&(HC.selectedOnly=!HC.selectedOnly,WC())});let i=document.getElementById(`agentSkillSearchInput`);if(i){let e=null,t=document.getElementById(`agentSkillSearchClear`),n=()=>{t&&(t.style.display=i.value?`block`:`none`)};i.addEventListener(`input`,()=>{n(),clearTimeout(e),e=setTimeout(()=>{HC.searchText=i.value,WC()},150)}),t&&t.addEventListener(`click`,()=>{clearTimeout(e),i.value=``,n(),HC.searchText=``,WC(),i.focus()}),n()}let a=document.getElementById(`agentToolList`);a&&(a.addEventListener(`click`,e=>{let t=e.target.closest(`.agent-mcp-expand-btn`);if(t){e.preventDefault(),zC(t.dataset.serverId,t);return}let n=e.target.closest(`.agent-mcp-service-item`);if(n&&!e.target.closest(`input[type="checkbox"]`)){e.preventDefault(),zC(n.dataset.mcpServerId,n.querySelector(`.agent-mcp-expand-btn`));return}let r=e.target.closest(`.agent-tool-category-clickable`);r&&kC(r.dataset.category)}),a.addEventListener(`change`,e=>{if(!e.target.matches(`input[type="checkbox"]`))return;let t=IC,n=e.target.dataset.toolId,r=e.target.dataset.mcpServerId;t.inheritMode=!1,n?e.target.checked?t.selectedSet.add(n):t.selectedSet.delete(n):r&&(e.target.checked?t.excludedSet.delete(r):t.excludedSet.add(r)),t.selectedOnly?RC():AC()}));let o=document.getElementById(`agentSkillList`);o&&o.addEventListener(`change`,e=>{if(!e.target.matches(`input[type="checkbox"]`))return;let t=HC;t.inheritMode=!1,e.target.checked?t.selectedSet.add(e.target.value):t.selectedSet.delete(e.target.value),t.selectedOnly&&!e.target.checked?WC():jC()}),document.addEventListener(`click`,e=>{let t=document.getElementById(`emojiPicker`),n=document.getElementById(`agentEditIconBtn`);t&&n&&t.style.display===`block`&&!n.contains(e.target)&&!t.contains(e.target)&&(t.style.display=`none`)})}var bC=[[`smileys`,`emojiCatSmileys`],[`people`,`emojiCatPeople`],[`animals`,`emojiCatAnimals`],[`food`,`emojiCatFood`],[`travel`,`emojiCatTravel`],[`activity`,`emojiCatActivity`],[`objects`,`emojiCatObjects`],[`symbols`,`emojiCatSymbols`],[`flags`,`emojiCatFlags`]];function xC(e,t){return!!(e[1].includes(t)||e[3]&&e[3].includes(t))}function SC(e){let t=``;for(let[e,n]of bC){let i=dC.filter(t=>t[2]===e);if(i.length){t+=`<div class="emoji-category-label">${r(`agentMgr.`+n)}</div>`,t+=`<div class="emoji-picker-grid">`;for(let e of i)t+=`<button type="button" class="emoji-picker-item" data-emoji="${$(e[0])}" title="${$(e[1])}">${e[0]}</button>`;t+=`</div>`}}e.innerHTML=t}function CC(e,t){let n=dC.filter(e=>xC(e,t));if(!n.length){e.innerHTML=`<div class="emoji-picker-empty">${r(`agentMgr.emojiNoMatch`)}</div>`;return}let i=`<div class="emoji-picker-grid">`;for(let e of n)i+=`<button type="button" class="emoji-picker-item" data-emoji="${$(e[0])}" title="${$(e[1])}">${e[0]}</button>`;i+=`</div>`,e.innerHTML=i}function wC(){let e=document.getElementById(`emojiPicker`),t=document.getElementById(`agentEditIconBtn`),n=document.getElementById(`agentEditIcon`),r=document.getElementById(`emojiSearchInput`),i=document.getElementById(`emojiSearchClear`),a=document.getElementById(`emojiPickerBody`);if(!e||!t)return;let o=()=>{let e=r?r.value.trim().toLowerCase():``;e?CC(a,e):SC(a),i&&(i.style.display=e?`flex`:`none`)};t.addEventListener(`click`,n=>{if(n.stopPropagation(),e.style.display===`block`){e.style.display=`none`;return}r&&(r.value=``),o();let i=t.getBoundingClientRect();document.body.clientWidth-i.left>=330?(e.style.left=`0`,e.style.right=`auto`):(e.style.left=`auto`,e.style.right=`0`),e.style.display=`block`}),r&&r.addEventListener(`input`,o),i&&i.addEventListener(`click`,e=>{e.stopPropagation(),r&&(r.value=``),o(),r&&r.focus()}),e.addEventListener(`click`,r=>{let i=r.target.closest(`.emoji-picker-item`);if(!i)return;let a=i.dataset.emoji;t.textContent=a,n&&(n.value=a),e.style.display=`none`})}function TC(){let e=IC;e.inheritMode=!1,e.allTools.forEach(t=>e.selectedSet.add(t.id)),e.mcpServices.forEach(t=>e.excludedSet.delete(t.serverId)),RC()}function EC(){let e=IC;e.inheritMode=!1,e.allTools.forEach(t=>e.selectedSet.delete(t.id)),e.mcpServices.forEach(t=>e.excludedSet.add(t.serverId)),RC()}function DC(){let e=HC;e.inheritMode=!1,e.skills.forEach(t=>e.selectedSet.add(t.name)),WC()}function OC(){let e=HC;e.inheritMode=!1,e.selectedSet.clear(),WC()}function kC(e){let t=IC;if(e===`mcp`){if(t.mcpServices.length===0)return;t.inheritMode=!1;let e=t.mcpServices.every(e=>!t.excludedSet.has(e.serverId));t.mcpServices.forEach(n=>{e?t.excludedSet.add(n.serverId):t.excludedSet.delete(n.serverId)}),document.querySelectorAll(`#agentToolList .agent-mcp-service-item input[type="checkbox"]`).forEach(t=>{t.checked=!e})}else{let n=t.allTools.filter(t=>(t.category||`other`)===e);if(n.length===0)return;t.inheritMode=!1;let r=n.every(e=>t.selectedSet.has(e.id));n.forEach(e=>{r?t.selectedSet.delete(e.id):t.selectedSet.add(e.id)}),document.querySelectorAll(`#agentToolList .agent-tool-item[data-category="${e}"] input[type="checkbox"]`).forEach(e=>{e.checked=!r})}t.selectedOnly?RC():AC()}function AC(){let e=IC,t=document.getElementById(`agentToolList`);if(!t)return;let n=e.mcpServices.filter(t=>!e.excludedSet.has(t.serverId)).length;t.querySelectorAll(`.agent-tool-category-clickable`).forEach(t=>{let r=t.dataset.category,i=t.querySelector(`.agent-tool-cat-count`);if(i)if(r===`mcp`)i.textContent=`${n}/${e.mcpServices.length}`;else{let t=e.allTools.filter(e=>(e.category||`other`)===r);i.textContent=`${t.filter(t=>e.selectedSet.has(t.id)).length}/${t.length}`}});let i=document.getElementById(`agentToolCount`);if(i){let t=e.allTools.filter(t=>e.selectedSet.has(t.id)).length,a=e.allTools.length+e.mcpServices.length;i.textContent=r(`agentConfig.selectedTotalCount`,{selected:e.inheritMode?a:t+n,total:a})}}function jC(){let e=document.getElementById(`agentSkillCount`);if(!e)return;let t=HC,n=t.skills.length;e.textContent=r(`agentConfig.selectedTotalCount`,{selected:t.inheritMode?n:t.selectedSet.size,total:n})}async function MC(e){let t=document.getElementById(`agentEditModal`);if(!t)return;await KC(),qC(-1),t.querySelector(`#agentEditId`).value=``,t.querySelector(`#agentEditName`).value=``,t.querySelector(`#agentEditIcon`).value=`🤖`;let n=t.querySelector(`#agentEditIconBtn`);n&&(n.textContent=`🤖`),t.querySelector(`#agentEditDesc`).value=``,t.querySelector(`#agentEditPrompt`).value=``,t.querySelector(`#agentEditAllowSub`).checked=!1,t.querySelector(`#agentTemplateSelect`).value=``,t.querySelector(`#agentEditModel`).value=``;let i=t.querySelector(`#agentDeleteBtn`),a=t.querySelector(`#agentEditTitle`);if(e){let n=await at(e);if(!n||n.isBuiltin)return;a.textContent=r(`agentMgr.editAgent`),t.querySelector(`#agentEditId`).value=n.id,t.querySelector(`#agentEditName`).value=n.name,t.querySelector(`#agentEditIcon`).value=n.icon||`🤖`;let o=t.querySelector(`#agentEditIconBtn`);o&&(o.textContent=n.icon||`🤖`),t.querySelector(`#agentEditDesc`).value=n.description||``,t.querySelector(`#agentEditPrompt`).value=n.systemPrompt||``,t.querySelector(`#agentEditAllowSub`).checked=n.allowSubDispatch||!1,t.querySelector(`#agentEditModel`).value=n.model||``,qC(YC(n.temperature,n.topP)),i.style.display=`block`,LC(n.toolIds,n.mcpExcludedServerIds??[]),UC(n.skillIds)}else a.textContent=r(`agentEditor.createNew`),i.style.display=`none`,LC(null,[]),UC(null);PC(),t.style.display=`flex`;let o=t.querySelector(`#agentEditModel`);if(o){let e=o.value,t=o.cloneNode(!0);o.parentNode.replaceChild(t,o),t.value=e,t.addEventListener(`mousedown`,()=>{let e=t.value;e&&(t.dataset._saved=e,t.value=``)}),t.addEventListener(`blur`,()=>{setTimeout(()=>{t.value||=t.dataset._saved||``},150)})}}function NC(){let e=document.getElementById(`agentEditModal`);e&&(e.style.display=`none`)}function PC(){let e=document.getElementById(`agentTemplateSelect`);if(!e)return;let t=[r(`agentTemplates.codeReviewName`),r(`agentTemplates.webAutomationName`),r(`agentTemplates.dataAnalystName`),r(`agentTemplates.documentationName`)],n=`<option value="">${r(`agentEditor.selectTemplate`)}</option>`;for(let e=0;e<j.length;e++){let r=j[e];n+=`<option value="${e}">${r.icon} ${t[e]}</option>`}e.innerHTML=n}function FC(e){let t=parseInt(e.target.value);if(isNaN(t)||t<0||t>=j.length)return;let n=j[t],i=document.getElementById(`agentEditModal`);if(!i)return;let a=[`agentTemplates.codeReviewName`,`agentTemplates.webAutomationName`,`agentTemplates.dataAnalystName`,`agentTemplates.documentationName`],o=[`agentTemplates.codeReviewDesc`,`agentTemplates.webAutomationDesc`,`agentTemplates.dataAnalystDesc`,`agentTemplates.documentationDesc`];i.querySelector(`#agentEditName`).value=r(a[t]),i.querySelector(`#agentEditIcon`).value=n.icon;let c=i.querySelector(`#agentEditIconBtn`);c&&(c.textContent=n.icon),i.querySelector(`#agentEditDesc`).value=r(o[t]),i.querySelector(`#agentEditPrompt`).value=s()===`en`?n.systemPrompt:n.systemPromptZh||n.systemPrompt,i.querySelector(`#agentEditAllowSub`).checked=n.allowSubDispatch||!1,i.querySelector(`#agentEditModel`).value=n.model||``,qC(YC(n.temperature,n.topP)),LC(n.toolIds,[]),UC(n.skillIds||null),P(r(`agentMgr.templateLoaded`,{name:n.name}),`info`,2e3)}var IC={allTools:[],mcpServices:[],selectedSet:new Set,excludedSet:new Set,searchText:``,selectedOnly:!1,inheritMode:!1};async function LC(e,t){if(!document.getElementById(`agentToolList`))return;let n=[];try{n=(await chrome.storage.local.get([`mcpTools`])).mcpTools||[]}catch{}let{mcpEnabled:r,skillsEnabled:i,ragTools:a}=await chrome.storage.local.get([`mcpEnabled`,`skillsEnabled`,`ragTools`]),o=N.agentPlatform?.connected===!0,s=[...b,...a||[]];o||(s=s.filter(e=>!e.id.startsWith(`agent_`)&&!e.id.startsWith(`knowledge_`))),i===!1&&(s=s.filter(e=>e.id!==`agent_skill`));let c=[];if(r===!0&&o){let e=new Map;for(let t of n){let n=t.serverId||`unknown`;e.has(n)||e.set(n,{serverId:n,serverName:t.serverName||n,tools:[]}),e.get(n).tools.push(t)}c=Array.from(e.values())}let l=new Set(Array.isArray(t)?t:[]),u=IC;u.allTools=s,u.mcpServices=c,u.selectedSet=new Set(e||[]),u.excludedSet=l,u.searchText=``,u.selectedOnly=!1,u.inheritMode=!e;let d=document.getElementById(`agentToolSearchInput`);d&&(d.value=``);let f=document.getElementById(`agentToolSearchClear`);f&&(f.style.display=`none`),RC()}function RC(){let e=document.getElementById(`agentToolList`);if(!e)return;let t=IC,n=ha({tools:t.allTools,services:t.mcpServices,selectedSet:t.selectedSet,excludedSet:t.excludedSet,query:t.searchText,selectedOnly:t.selectedOnly,getDesc:ji}),i=t.mcpServices.filter(e=>!t.excludedSet.has(e.serverId)).length,a={};for(let e of n.tools){let t=e.category||`other`;a[t]||(a[t]=[]),a[t].push(e)}let o=``;for(let[e,n]of Object.entries(a)){let i=r(`toolCategory.${e}`)===`toolCategory.${e}`?e:r(`toolCategory.${e}`),a=t.allTools.filter(t=>(t.category||`other`)===e),s=a.filter(e=>t.selectedSet.has(e.id)).length;o+=`<div class="agent-tool-category agent-tool-category-clickable" data-category="${$(e)}" title="${$(r(`agentConfig.toggleCategoryAll`))}">${i} <span class="agent-tool-cat-count" style="font-weight:400;color:var(--text-tertiary);">${s}/${a.length}</span></div>`;for(let r of n){let n=t.selectedSet.has(r.id)?`checked`:``,i=ji(r),a=i.length>40?i.substring(0,40)+`...`:i;o+=`
|
|
2052
2059
|
<label class="agent-tool-item" data-category="${$(e)}">
|
|
2053
2060
|
<input type="checkbox" value="${$(r.id)}" ${n} data-tool-id="${$(r.id)}">
|
|
2054
|
-
<span class="agent-tool-name" title="${$(r.name)}">${
|
|
2055
|
-
<span class="agent-tool-desc" title="${$(i)}">${
|
|
2056
|
-
</label>`}}if(n.services.length>0){let e=r(`toolCategory.mcp`)===`toolCategory.mcp`?`mcp`:r(`toolCategory.mcp`);o+=`<div class="agent-tool-category agent-tool-category-clickable" data-category="mcp" title="${$(r(`agentConfig.toggleCategoryAll`))}">${e} <span class="agent-tool-cat-count" style="font-weight:400;color:var(--text-tertiary);">${i}/${t.mcpServices.length}</span></div>`;for(let e of n.services){let n=t.excludedSet.has(e.serverId)?``:`checked`,i=r(`toolPanel.mcpServiceToolCount`,{count:e.tools.length}),a=e.tools.map(e=>e.name).join(`, `),s=e.tools.map(e=>{let t=e.name||``,n=Mi(e);return`<div class="agent-mcp-tool-row" title="${$(n?`${t}:${n}`:t)}"><div class="agent-mcp-tool-name">${
|
|
2061
|
+
<span class="agent-tool-name" title="${$(r.name)}">${tw(r.name)}</span>
|
|
2062
|
+
<span class="agent-tool-desc" title="${$(i)}">${tw(a)}</span>
|
|
2063
|
+
</label>`}}if(n.services.length>0){let e=r(`toolCategory.mcp`)===`toolCategory.mcp`?`mcp`:r(`toolCategory.mcp`);o+=`<div class="agent-tool-category agent-tool-category-clickable" data-category="mcp" title="${$(r(`agentConfig.toggleCategoryAll`))}">${e} <span class="agent-tool-cat-count" style="font-weight:400;color:var(--text-tertiary);">${i}/${t.mcpServices.length}</span></div>`;for(let e of n.services){let n=t.excludedSet.has(e.serverId)?``:`checked`,i=r(`toolPanel.mcpServiceToolCount`,{count:e.tools.length}),a=e.tools.map(e=>e.name).join(`, `),s=e.tools.map(e=>{let t=e.name||``,n=Mi(e);return`<div class="agent-mcp-tool-row" title="${$(n?`${t}:${n}`:t)}"><div class="agent-mcp-tool-name">${tw(t)}</div>`+(n?`<div class="agent-mcp-tool-desc">${tw(n)}</div>`:``)+`</div>`}).join(``);o+=`
|
|
2057
2064
|
<label class="agent-tool-item agent-mcp-service-item" data-category="mcp" data-mcp-server-id="${$(e.serverId)}">
|
|
2058
2065
|
<input type="checkbox" ${n} data-mcp-server-id="${$(e.serverId)}">
|
|
2059
|
-
<span class="agent-tool-name" title="${$(e.serverName)}">${
|
|
2060
|
-
<span class="agent-tool-desc" title="${$(a)}">${
|
|
2061
|
-
<span class="agent-mcp-service-id" title="ID: ${$(e.serverId)}">ID: ${
|
|
2066
|
+
<span class="agent-tool-name" title="${$(e.serverName)}">${tw(e.serverName)}</span>
|
|
2067
|
+
<span class="agent-tool-desc" title="${$(a)}">${tw(i)}</span>
|
|
2068
|
+
<span class="agent-mcp-service-id" title="ID: ${$(e.serverId)}">ID: ${tw(e.serverId)}</span>
|
|
2062
2069
|
<button type="button" class="agent-mcp-expand-btn" data-server-id="${$(e.serverId)}" title="${$(r(`toolPanel.mcpServiceExpand`))}">▶</button>
|
|
2063
2070
|
</label>
|
|
2064
|
-
<div class="agent-mcp-tool-list collapsed" data-server-id="${$(e.serverId)}">${s}</div>`}}o||=`<div class="agent-tool-empty">${
|
|
2071
|
+
<div class="agent-mcp-tool-list collapsed" data-server-id="${$(e.serverId)}">${s}</div>`}}o||=`<div class="agent-tool-empty">${tw(r(`toolPanel.noMatch`))}</div>`,e.innerHTML=o;let s=document.getElementById(`agentToolSelectedOnlyBtn`);if(s){s.classList.toggle(`active`,t.selectedOnly),s.textContent=r(t.selectedOnly?`agentEditor.showAllTools`:`agentEditor.selectedOnlyFilter`);let e=t.allTools.filter(e=>t.selectedSet.has(e.id)).length;s.title=r(`agentToolFilter.selectedCountHint`,{count:e+i})}AC()}function zC(e,t){let n=document.getElementById(`agentToolList`);if(!n||!e)return;let r=Array.from(n.querySelectorAll(`.agent-mcp-tool-list`)).find(t=>t.dataset.serverId===e);if(!r)return;let i=r.classList.toggle(`collapsed`),a=t||r.previousElementSibling?.querySelector(`.agent-mcp-expand-btn`);a&&(a.textContent=i?`▶`:`▼`)}function BC(){let e=IC,t=e.allTools.filter(t=>e.selectedSet.has(t.id)).map(e=>e.id),n=new Set(t),r=[...e.selectedSet].filter(e=>!n.has(e)),i=[...t,...r];return i.length>0?i:null}function VC(){let e=IC;if(e.mcpServices.length!==0)return e.mcpServices.filter(t=>e.excludedSet.has(t.serverId)).map(e=>e.serverId)}var HC={skills:[],selectedSet:new Set,searchText:``,selectedOnly:!1,inheritMode:!1};async function UC(e){if(!document.getElementById(`agentSkillList`))return;let t=[];try{t=await BS()}catch{}let n=HC;n.skills=t,n.selectedSet=new Set(e||[]),n.searchText=``,n.selectedOnly=!1,n.inheritMode=e==null;let r=document.getElementById(`agentSkillSearchInput`);r&&(r.value=``);let i=document.getElementById(`agentSkillSearchClear`);i&&(i.style.display=`none`),WC()}function WC(){let e=document.getElementById(`agentSkillList`);if(!e)return;let t=HC;if(t.skills.length===0)e.innerHTML=`<div style="color:var(--text-tertiary);font-size:12px;padding:8px;text-align:center;">${r(`agentMgr.noSkillsHint`)}</div>`;else{let n=ha({tools:t.skills.map(e=>({id:e.name,name:e.name,description:e.description||``})),services:[],selectedSet:t.selectedSet,excludedSet:new Set,query:t.searchText,selectedOnly:t.selectedOnly}).tools;n.length===0?e.innerHTML=`<div class="agent-tool-empty">${tw(r(`toolPanel.noMatch`))}</div>`:e.innerHTML=n.map(e=>{let n=t.selectedSet.has(e.name)?`checked`:``,r=e.description||``;return`
|
|
2065
2072
|
<label class="agent-tool-item">
|
|
2066
2073
|
<input type="checkbox" value="${$(e.name)}" ${n}>
|
|
2067
|
-
<span class="agent-tool-name" title="${$(e.name)}">${
|
|
2068
|
-
<span class="agent-tool-desc" title="${$(r)}">${
|
|
2069
|
-
</label>`}).join(``)}let n=document.getElementById(`agentSkillSelectedOnlyBtn`);n&&(n.classList.toggle(`active`,t.selectedOnly),n.textContent=r(t.selectedOnly?`agentEditor.showAllSkills`:`agentEditor.selectedOnlyFilter`),n.title=r(`agentToolFilter.selectedCountHint`,{count:t.selectedSet.size})),OC()}function HC(){let e=zC,t=e.skills.filter(t=>e.selectedSet.has(t.name)).map(e=>e.name),n=new Set(t),r=[...e.selectedSet].filter(e=>!n.has(e)),i=[...t,...r];return i.length>0?i:null}async function UC(){let e=document.getElementById(`agentModelList`);if(e)return new Promise(t=>{chrome.storage.local.get([`customModels`],n=>{let r=[];(n.customModels||[]).forEach(e=>{let t;typeof e==`string`?t=e:e&&e.name&&(t=e.name),t&&!r.includes(t)&&r.push(t)}),e.innerHTML=r.map(e=>`<option value="${$(e)}">`).join(``),t()})})}function WC(e){let t=document.getElementById(`agentEditTempPreset`);if(t){for(;t.options.length>1;)t.remove(1);Tn.forEach((e,n)=>{let i=document.createElement(`option`);i.value=n,i.textContent=`${r(e.labelKey)}(${e.temp.toFixed(2)})`,t.appendChild(i)}),e!==void 0&&e>=0?t.value=e:t.value=``}}function GC(){let e=document.getElementById(`agentEditTempPreset`);if(!e||e.value===``)return{temperature:null,topP:null};let t=parseInt(e.value);if(isNaN(t)||t<0||t>=Tn.length)return{temperature:null,topP:null};let n=Tn[t];return{temperature:n.temp,topP:n.topP}}function KC(e,t){if(e==null)return-1;for(let n=0;n<Tn.length;n++){let r=Tn[n];if(Math.abs(r.temp-e)<.001&&Math.abs(r.topP-(t||1))<.001)return n}return-1}async function qC(){let e=document.getElementById(`agentEditModal`);if(!e)return;let t=e.querySelector(`#agentEditId`).value,n=e.querySelector(`#agentEditName`).value.trim(),i=e.querySelector(`#agentEditIcon`).value.trim()||`🤖`,o=e.querySelector(`#agentEditDesc`).value.trim(),s=e.querySelector(`#agentEditPrompt`).value.trim(),c=e.querySelector(`#agentEditAllowSub`).checked,l=LC(),u=RC(),d=HC(),f=e.querySelector(`#agentEditModel`).value.trim()||null,{temperature:p,topP:m}=GC();if(!n){P(r(`agentMgr.nameRequired`),`warning`);return}let h={name:n,icon:i,description:o,systemPrompt:s,allowSubDispatch:c,toolIds:l,skillIds:d,model:f,temperature:p,topP:m};u!==void 0&&(h.mcpExcludedServerIds=u);try{t?(await ot(t,h),t===N.activeAgentId&&u!==void 0&&(N.activeAgentMcpExcludedServerIds=u),P(r(`agentMgr.agentUpdated`),`success`)):P(r(`agentMgr.agentCreated`,{name:(await ct(h)).name}),`success`),await uC(),await dC(),AC(),ca()}catch(e){a.error(`[AgentMgr] save Agent failed:`,e),P(r(`agentMgr.saveFailed`,{message:e.message}),`error`)}}async function JC(){let e=document.getElementById(`agentEditModal`);if(!e)return;let t=e.querySelector(`#agentEditId`)?.value;if(!t)return;let n=await at(t);if(await $C(r(`agentMgr.confirmDeleteAgentMessage`,{name:n?n.name:``}),r(`agentMgr.deleteAgentTitle`)))try{await ut(t),P(r(`agentMgr.agentDeleted`),`success`),await uC(),await dC(),AC()}catch(e){a.error(`[AgentMgr] delete Agent failed:`,e),P(r(`agentMgr.deleteFailed`,{message:e.message}),`error`)}}async function YC(e){if(!e)return!1;let t=await at(e);if(!t||t.isBuiltin)return P(r(`agentMgr.cannotDeleteDefault`),`warning`),!1;if(!await $C(r(`agentMgr.confirmDeleteAgentMessage`,{name:t.name}),r(`agentMgr.deleteAgentTitle`)))return!1;try{return await ut(e),P(r(`agentMgr.agentDeleted`),`success`),await uC(),await dC(),!0}catch(e){return a.error(`[AgentMgr] delete Agent failed:`,e),P(r(`agentMgr.deleteFailed`,{message:e.message}),`error`),!1}}async function XC(e=N.activeAgentId){return e?await at(e):null}function ZC(e){return e?e.toolIds:null}function QC(e){if(!e)return``;let t=document.createElement(`div`);return t.textContent=e,t.innerHTML}function $(e){return e?e.replace(/["&<>]/g,e=>({'"':`"`,"&":`&`,"<":`<`,">":`>`})[e]):``}async function $C(e,t){return typeof window.showCustomConfirm==`function`?window.showCustomConfirm(e,t):new Promise(n=>{let i=document.getElementById(`agentConfirmModal`);if(!i){n(confirm(e));return}i.querySelector(`#agentConfirmMessage`).textContent=e,i.querySelector(`#agentConfirmTitle`).textContent=t||r(`agentMgr.confirm`),i.style.display=`flex`;let a=()=>{i.style.display=`none`,i.querySelector(`#agentConfirmOk`).removeEventListener(`click`,o),i.querySelector(`#agentConfirmCancel`).removeEventListener(`click`,s),i.removeEventListener(`click`,c)},o=()=>{a(),n(!0)},s=()=>{a(),n(!1)},c=e=>{e.target===i&&(a(),n(!1))};i.querySelector(`#agentConfirmOk`).addEventListener(`click`,o),i.querySelector(`#agentConfirmCancel`).addEventListener(`click`,s),i.addEventListener(`click`,c)})}n(`zh`,{contextUsage:{indicatorTitle:`上下文占用 {percent}%({used} / {total} tokens)· 点击查看详情`,memoryOffToast:`记忆已关闭,无可压缩内容`,generatingToast:`正在生成回复,请稍后再试`,nothingToCompactToast:`没有新的消息可压缩`,confirmTitle:`压缩上下文`,confirmMessage:`将压缩 {count} 条历史消息(约 {tokens} tokens)为一份摘要{summaryHint}。原始消息仍保留在会话中,发送新消息前可撤销。`,confirmWithOldSummary:`(含已有摘要,将合并为新摘要)`,confirmOk:`开始压缩`,compactingTitle:`正在压缩上下文`,compactingHint:`正在调用模型生成摘要,请稍候…(通常需要几秒到十几秒)`,compactDone:`压缩完成,节约约 {saved} tokens`,compactErrConfig:`无法压缩:API 配置缺失`,compactErrFailed:`压缩失败,请稍后重试`,compactErrEmpty:`模型未返回摘要内容`,compactErrHttp:`接口错误 HTTP {status}`,compactErrTimeout:`请求超时`,autoCompactedToast:`上下文接近上限,已自动压缩(预计省 {saved} tokens)`,undoTitle:`撤销压缩`,undoMessage:`撤销后,发送将恢复携带完整历史。确定撤销吗?`,undoOk:`撤销`,undoDone:`已撤销压缩`,dividerText:`⬆ 上方 {count} 条消息已压缩为摘要`,dividerView:`查看`,dividerUndo:`撤销`,popupTitle:`上下文占用明细`,rowSystem:`系统提示词`,rowTools:`工具定义`,rowHistory:`历史消息`,rowInput:`当前输入`,historyMeta:`选中 {selected} 条 / 共 {total} 条`,historyTrimmed:`为控制预算裁剪了 {count} 条(以规则摘要替代)`,refInfo:`输出预留 {output} · 安全余量 {safety}(不计入上方占用)`,memoryLabel:`记忆设置`,memoryAll:`携带全部历史`,memoryLimited:`携带最近 {n} 条`,memoryOff:`不携带历史(仅当前消息)`,compactionActive:`已压缩 {count} 条历史 · 摘要约 {tokens} tokens`,compactionInvalidHint:`压缩点已失效(对应消息已被删除),本次发送未使用压缩`,removeInvalid:`移除失效的压缩记录`,btnCompact:`压缩上下文`,btnCompactAgain:`再次压缩`,btnUndoCompact:`撤销压缩`,undoExpiredToast:`已发送新消息,无法再撤销压缩(可再次压缩合并更新)`,summaryTitle:`上下文摘要(压缩 {count} 条历史)`,summaryTabPreview:`预览`,summaryTabSource:`源码`}}),n(`en`,{contextUsage:{indicatorTitle:`Context usage {percent}% ({used} / {total} tokens) · Click for details`,memoryOffToast:`Memory is off, nothing to compact`,generatingToast:`Generating a reply, please try again later`,nothingToCompactToast:`No new messages to compact`,confirmTitle:`Compact Context`,confirmMessage:`Compact {count} history messages (~{tokens} tokens) into a summary{summaryHint}. Original messages remain in the session; undo is available before sending new messages.`,confirmWithOldSummary:` (including the existing summary, which will be merged into a new one)`,confirmOk:`Start Compaction`,compactingTitle:`Compacting Context`,compactingHint:`Generating a summary with the model, please wait… (usually takes a few seconds)`,compactDone:`Compaction complete, saved ~{saved} tokens`,compactErrConfig:`Cannot compact: API configuration missing`,compactErrFailed:`Compaction failed, please try again later`,compactErrEmpty:`the model returned no summary`,compactErrHttp:`API error HTTP {status}`,compactErrTimeout:`request timed out`,autoCompactedToast:`Context is near its limit; auto-compacted (est. {saved} tokens saved)`,undoTitle:`Undo Compaction`,undoMessage:`After undo, sending will include the full history again. Undo?`,undoOk:`Undo`,undoDone:`Compaction undone`,dividerText:`⬆ {count} messages above compacted into a summary`,dividerView:`View`,dividerUndo:`Undo`,popupTitle:`Context Usage Details`,rowSystem:`System prompt`,rowTools:`Tool definitions`,rowHistory:`History messages`,rowInput:`Current input`,historyMeta:`Selected {selected} / {total} total`,historyTrimmed:`{count} messages trimmed for budget (replaced by rule summary)`,refInfo:`Output reserve {output} · Safety margin {safety} (not counted above)`,memoryLabel:`Memory setting`,memoryAll:`Carry all history`,memoryLimited:`Carry latest {n} messages`,memoryOff:`No history (current message only)`,compactionActive:`{count} messages compacted · summary ~{tokens} tokens`,compactionInvalidHint:`Compaction point is stale (its message was deleted); this send ignores the compaction`,removeInvalid:`Remove stale compaction record`,btnCompact:`Compact Context`,btnCompactAgain:`Compact Again`,btnUndoCompact:`Undo Compaction`,undoExpiredToast:`New messages have been sent; compaction can no longer be undone (you can compact again)`,summaryTitle:`Context Summary ({count} messages compacted)`,summaryTabPreview:`Preview`,summaryTabSource:`Source`}});var ew=300,tw=``,nw=0,rw=null;async function iw(){try{let{mcpTools:e}=await chrome.storage.local.get([`mcpTools`]),t=e||[],n=new Set(Array.isArray(N.mcpClosedServers)?N.mcpClosedServers:[]),r=new Set(Array.isArray(N.activeAgentMcpExcludedServerIds)?N.activeAgentMcpExcludedServerIds:[]);return t.filter(e=>{let t=e.serverId||`unknown`;return!n.has(t)&&!r.has(t)}).length}catch{return 0}}function aw(){let e=document.getElementById(`userInput`)?.value||``;return{usage:Mn({model:N.currentModel,customModelMap:N.customModelMap,systemPromptText:tw,toolCount:(N.useTools?N.enabledTools.length:0)+nw,history:N.messageHistory,inputText:e,maxMemoryMessages:N.chatConfig?.maxMemoryMessages??null,compaction:N.activeCompaction,isolateChat:N.isolateChat}),inputText:e}}function ow(e){let t=document.getElementById(`contextUsageIndicator`);if(!t)return;t._lastUsage=e,t.dataset.level=e.level;let n=Math.round(e.ratio*100),i=t.querySelector(`.context-usage-percent`);i&&(i.textContent=`${n}%`),t.style.setProperty(`--usage-ratio`,String(Math.min(Math.max(e.ratio,0),1))),t.title=r(`contextUsage.indicatorTitle`,{percent:n,used:I(e.usedTokens),total:I(e.contextWindow)})}function sw(){try{let{usage:e}=aw();return ow(e),yw(),e}catch(e){return a.warn(`[ContextIndicator] update failed:`,e?.message),null}}function cw(){clearTimeout(rw),rw=setTimeout(()=>sw(),ew)}async function lw(e=null){let t=e===null?N.activeSessionId:e;try{tw=await kt(await XC(),{sessionId:t})}catch(e){a.warn(`[ContextIndicator] refresh system prompt failed:`,e?.message)}try{nw=await iw()}catch{nw=0}sw()}function uw(){let e=document.getElementById(`contextUsageIndicator`);e&&(e.addEventListener(`click`,()=>Cw()),document.getElementById(`userInput`)?.addEventListener(`input`,cw),document.addEventListener(`generating-state-changed`,()=>{lw()}),document.addEventListener(`agent-model-changed`,()=>{lw()}),document.addEventListener(`session-switched`,()=>{lw()}),document.addEventListener(`session-workdir-changed`,()=>{lw()}),chrome.storage.onChanged.addListener((e,t)=>{t===`local`&&((e.chatMaxMemoryMessages||e.isolateChat)&&cw(),(e.modelName||e.customModels)&&cw(),(e.isolateChat||e.mcpTools||e.mcpEnabled||e.enabledTools||e.enableTools)&&lw())}),lw())}function dw({title:e,message:t,okText:n}){return new Promise(i=>{let a=document.createElement(`div`);a.className=`modal-overlay show`,a.style.zIndex=`10200`,a.innerHTML=`
|
|
2074
|
+
<span class="agent-tool-name" title="${$(e.name)}">${tw(e.name)}</span>
|
|
2075
|
+
<span class="agent-tool-desc" title="${$(r)}">${tw(r.substring(0,40))}${r.length>40?`...`:``}</span>
|
|
2076
|
+
</label>`}).join(``)}let n=document.getElementById(`agentSkillSelectedOnlyBtn`);n&&(n.classList.toggle(`active`,t.selectedOnly),n.textContent=r(t.selectedOnly?`agentEditor.showAllSkills`:`agentEditor.selectedOnlyFilter`),n.title=r(`agentToolFilter.selectedCountHint`,{count:t.selectedSet.size})),jC()}function GC(){let e=HC,t=e.skills.filter(t=>e.selectedSet.has(t.name)).map(e=>e.name),n=new Set(t),r=[...e.selectedSet].filter(e=>!n.has(e)),i=[...t,...r];return i.length>0?i:null}async function KC(){let e=document.getElementById(`agentModelList`);if(e)return new Promise(t=>{chrome.storage.local.get([`customModels`],n=>{let r=[];(n.customModels||[]).forEach(e=>{let t;typeof e==`string`?t=e:e&&e.name&&(t=e.name),t&&!r.includes(t)&&r.push(t)}),e.innerHTML=r.map(e=>`<option value="${$(e)}">`).join(``),t()})})}function qC(e){let t=document.getElementById(`agentEditTempPreset`);if(t){for(;t.options.length>1;)t.remove(1);Tn.forEach((e,n)=>{let i=document.createElement(`option`);i.value=n,i.textContent=`${r(e.labelKey)}(${e.temp.toFixed(2)})`,t.appendChild(i)}),e!==void 0&&e>=0?t.value=e:t.value=``}}function JC(){let e=document.getElementById(`agentEditTempPreset`);if(!e||e.value===``)return{temperature:null,topP:null};let t=parseInt(e.value);if(isNaN(t)||t<0||t>=Tn.length)return{temperature:null,topP:null};let n=Tn[t];return{temperature:n.temp,topP:n.topP}}function YC(e,t){if(e==null)return-1;for(let n=0;n<Tn.length;n++){let r=Tn[n];if(Math.abs(r.temp-e)<.001&&Math.abs(r.topP-(t||1))<.001)return n}return-1}async function XC(){let e=document.getElementById(`agentEditModal`);if(!e)return;let t=e.querySelector(`#agentEditId`).value,n=e.querySelector(`#agentEditName`).value.trim(),i=e.querySelector(`#agentEditIcon`).value.trim()||`🤖`,o=e.querySelector(`#agentEditDesc`).value.trim(),s=e.querySelector(`#agentEditPrompt`).value.trim(),c=e.querySelector(`#agentEditAllowSub`).checked,l=BC(),u=VC(),d=GC(),f=e.querySelector(`#agentEditModel`).value.trim()||null,{temperature:p,topP:m}=JC();if(!n){P(r(`agentMgr.nameRequired`),`warning`);return}let h={name:n,icon:i,description:o,systemPrompt:s,allowSubDispatch:c,toolIds:l,skillIds:d,model:f,temperature:p,topP:m};u!==void 0&&(h.mcpExcludedServerIds=u);try{t?(await ot(t,h),t===N.activeAgentId&&u!==void 0&&(N.activeAgentMcpExcludedServerIds=u),P(r(`agentMgr.agentUpdated`),`success`)):P(r(`agentMgr.agentCreated`,{name:(await ct(h)).name}),`success`),await pC(),await mC(),NC(),ca()}catch(e){a.error(`[AgentMgr] save Agent failed:`,e),P(r(`agentMgr.saveFailed`,{message:e.message}),`error`)}}async function ZC(){let e=document.getElementById(`agentEditModal`);if(!e)return;let t=e.querySelector(`#agentEditId`)?.value;if(!t)return;let n=await at(t);if(await nw(r(`agentMgr.confirmDeleteAgentMessage`,{name:n?n.name:``}),r(`agentMgr.deleteAgentTitle`)))try{await ut(t),P(r(`agentMgr.agentDeleted`),`success`),await pC(),await mC(),NC()}catch(e){a.error(`[AgentMgr] delete Agent failed:`,e),P(r(`agentMgr.deleteFailed`,{message:e.message}),`error`)}}async function QC(e){if(!e)return!1;let t=await at(e);if(!t||t.isBuiltin)return P(r(`agentMgr.cannotDeleteDefault`),`warning`),!1;if(!await nw(r(`agentMgr.confirmDeleteAgentMessage`,{name:t.name}),r(`agentMgr.deleteAgentTitle`)))return!1;try{return await ut(e),P(r(`agentMgr.agentDeleted`),`success`),await pC(),await mC(),!0}catch(e){return a.error(`[AgentMgr] delete Agent failed:`,e),P(r(`agentMgr.deleteFailed`,{message:e.message}),`error`),!1}}async function $C(e=N.activeAgentId){return e?await at(e):null}function ew(e){return e?e.toolIds:null}function tw(e){if(!e)return``;let t=document.createElement(`div`);return t.textContent=e,t.innerHTML}function $(e){return e?e.replace(/["&<>]/g,e=>({'"':`"`,"&":`&`,"<":`<`,">":`>`})[e]):``}async function nw(e,t){return typeof window.showCustomConfirm==`function`?window.showCustomConfirm(e,t):new Promise(n=>{let i=document.getElementById(`agentConfirmModal`);if(!i){n(confirm(e));return}i.querySelector(`#agentConfirmMessage`).textContent=e,i.querySelector(`#agentConfirmTitle`).textContent=t||r(`agentMgr.confirm`),i.style.display=`flex`;let a=()=>{i.style.display=`none`,i.querySelector(`#agentConfirmOk`).removeEventListener(`click`,o),i.querySelector(`#agentConfirmCancel`).removeEventListener(`click`,s),i.removeEventListener(`click`,c)},o=()=>{a(),n(!0)},s=()=>{a(),n(!1)},c=e=>{e.target===i&&(a(),n(!1))};i.querySelector(`#agentConfirmOk`).addEventListener(`click`,o),i.querySelector(`#agentConfirmCancel`).addEventListener(`click`,s),i.addEventListener(`click`,c)})}n(`zh`,{contextUsage:{indicatorTitle:`上下文占用 {percent}%({used} / {total} tokens)· 点击查看详情`,memoryOffToast:`记忆已关闭,无可压缩内容`,generatingToast:`正在生成回复,请稍后再试`,nothingToCompactToast:`没有新的消息可压缩`,confirmTitle:`压缩上下文`,confirmMessage:`将压缩 {count} 条历史消息(约 {tokens} tokens)为一份摘要{summaryHint}。原始消息仍保留在会话中,发送新消息前可撤销。`,confirmWithOldSummary:`(含已有摘要,将合并为新摘要)`,confirmOk:`开始压缩`,compactingTitle:`正在压缩上下文`,compactingHint:`正在调用模型生成摘要,请稍候…(通常需要几秒到十几秒)`,compactDone:`压缩完成,节约约 {saved} tokens`,compactErrConfig:`无法压缩:API 配置缺失`,compactErrFailed:`压缩失败,请稍后重试`,compactErrEmpty:`模型未返回摘要内容`,compactErrHttp:`接口错误 HTTP {status}`,compactErrTimeout:`请求超时`,autoCompactedToast:`上下文接近上限,已自动压缩(预计省 {saved} tokens)`,undoTitle:`撤销压缩`,undoMessage:`撤销后,发送将恢复携带完整历史。确定撤销吗?`,undoOk:`撤销`,undoDone:`已撤销压缩`,dividerText:`⬆ 上方 {count} 条消息已压缩为摘要`,dividerView:`查看`,dividerUndo:`撤销`,popupTitle:`上下文占用明细`,rowSystem:`系统提示词`,rowTools:`工具定义`,rowHistory:`历史消息`,rowInput:`当前输入`,historyMeta:`选中 {selected} 条 / 共 {total} 条`,historyTrimmed:`为控制预算裁剪了 {count} 条(以规则摘要替代)`,refInfo:`输出预留 {output} · 安全余量 {safety}(不计入上方占用)`,memoryLabel:`记忆设置`,memoryAll:`携带全部历史`,memoryLimited:`携带最近 {n} 条`,memoryOff:`不携带历史(仅当前消息)`,compactionActive:`已压缩 {count} 条历史 · 摘要约 {tokens} tokens`,compactionInvalidHint:`压缩点已失效(对应消息已被删除),本次发送未使用压缩`,removeInvalid:`移除失效的压缩记录`,btnCompact:`压缩上下文`,btnCompactAgain:`再次压缩`,btnUndoCompact:`撤销压缩`,undoExpiredToast:`已发送新消息,无法再撤销压缩(可再次压缩合并更新)`,summaryTitle:`上下文摘要(压缩 {count} 条历史)`,summaryTabPreview:`预览`,summaryTabSource:`源码`}}),n(`en`,{contextUsage:{indicatorTitle:`Context usage {percent}% ({used} / {total} tokens) · Click for details`,memoryOffToast:`Memory is off, nothing to compact`,generatingToast:`Generating a reply, please try again later`,nothingToCompactToast:`No new messages to compact`,confirmTitle:`Compact Context`,confirmMessage:`Compact {count} history messages (~{tokens} tokens) into a summary{summaryHint}. Original messages remain in the session; undo is available before sending new messages.`,confirmWithOldSummary:` (including the existing summary, which will be merged into a new one)`,confirmOk:`Start Compaction`,compactingTitle:`Compacting Context`,compactingHint:`Generating a summary with the model, please wait… (usually takes a few seconds)`,compactDone:`Compaction complete, saved ~{saved} tokens`,compactErrConfig:`Cannot compact: API configuration missing`,compactErrFailed:`Compaction failed, please try again later`,compactErrEmpty:`the model returned no summary`,compactErrHttp:`API error HTTP {status}`,compactErrTimeout:`request timed out`,autoCompactedToast:`Context is near its limit; auto-compacted (est. {saved} tokens saved)`,undoTitle:`Undo Compaction`,undoMessage:`After undo, sending will include the full history again. Undo?`,undoOk:`Undo`,undoDone:`Compaction undone`,dividerText:`⬆ {count} messages above compacted into a summary`,dividerView:`View`,dividerUndo:`Undo`,popupTitle:`Context Usage Details`,rowSystem:`System prompt`,rowTools:`Tool definitions`,rowHistory:`History messages`,rowInput:`Current input`,historyMeta:`Selected {selected} / {total} total`,historyTrimmed:`{count} messages trimmed for budget (replaced by rule summary)`,refInfo:`Output reserve {output} · Safety margin {safety} (not counted above)`,memoryLabel:`Memory setting`,memoryAll:`Carry all history`,memoryLimited:`Carry latest {n} messages`,memoryOff:`No history (current message only)`,compactionActive:`{count} messages compacted · summary ~{tokens} tokens`,compactionInvalidHint:`Compaction point is stale (its message was deleted); this send ignores the compaction`,removeInvalid:`Remove stale compaction record`,btnCompact:`Compact Context`,btnCompactAgain:`Compact Again`,btnUndoCompact:`Undo Compaction`,undoExpiredToast:`New messages have been sent; compaction can no longer be undone (you can compact again)`,summaryTitle:`Context Summary ({count} messages compacted)`,summaryTabPreview:`Preview`,summaryTabSource:`Source`}});var rw=300,iw=``,aw=0,ow=null;async function sw(){try{let{mcpTools:e}=await chrome.storage.local.get([`mcpTools`]),t=e||[],n=new Set(Array.isArray(N.mcpClosedServers)?N.mcpClosedServers:[]),r=new Set(Array.isArray(N.activeAgentMcpExcludedServerIds)?N.activeAgentMcpExcludedServerIds:[]);return t.filter(e=>{let t=e.serverId||`unknown`;return!n.has(t)&&!r.has(t)}).length}catch{return 0}}function cw(){let e=document.getElementById(`userInput`)?.value||``;return{usage:Mn({model:N.currentModel,customModelMap:N.customModelMap,systemPromptText:iw,toolCount:(N.useTools?N.enabledTools.length:0)+aw,history:N.messageHistory,inputText:e,maxMemoryMessages:N.chatConfig?.maxMemoryMessages??null,compaction:N.activeCompaction,isolateChat:N.isolateChat}),inputText:e}}function lw(e){let t=document.getElementById(`contextUsageIndicator`);if(!t)return;t._lastUsage=e,t.dataset.level=e.level;let n=Math.round(e.ratio*100),i=t.querySelector(`.context-usage-percent`);i&&(i.textContent=`${n}%`),t.style.setProperty(`--usage-ratio`,String(Math.min(Math.max(e.ratio,0),1))),t.title=r(`contextUsage.indicatorTitle`,{percent:n,used:I(e.usedTokens),total:I(e.contextWindow)})}function uw(){try{let{usage:e}=cw();return lw(e),Sw(),e}catch(e){return a.warn(`[ContextIndicator] update failed:`,e?.message),null}}function dw(){clearTimeout(ow),ow=setTimeout(()=>uw(),rw)}async function fw(e=null){let t=e===null?N.activeSessionId:e;try{iw=await kt(await $C(),{sessionId:t})}catch(e){a.warn(`[ContextIndicator] refresh system prompt failed:`,e?.message)}try{aw=await sw()}catch{aw=0}uw()}function pw(){let e=document.getElementById(`contextUsageIndicator`);e&&(e.addEventListener(`click`,()=>Ew()),document.getElementById(`userInput`)?.addEventListener(`input`,dw),document.addEventListener(`generating-state-changed`,()=>{fw()}),document.addEventListener(`agent-model-changed`,()=>{fw()}),document.addEventListener(`session-switched`,()=>{fw()}),document.addEventListener(`session-workdir-changed`,()=>{fw()}),chrome.storage.onChanged.addListener((e,t)=>{t===`local`&&((e.chatMaxMemoryMessages||e.isolateChat)&&dw(),(e.modelName||e.customModels)&&dw(),(e.isolateChat||e.mcpTools||e.mcpEnabled||e.enabledTools||e.enableTools)&&fw())}),fw())}function mw({title:e,message:t,okText:n}){return new Promise(i=>{let a=document.createElement(`div`);a.className=`modal-overlay show`,a.style.zIndex=`10200`,a.innerHTML=`
|
|
2070
2077
|
<div class="modal-container">
|
|
2071
2078
|
<div class="modal-title"></div>
|
|
2072
2079
|
<div class="modal-message"></div>
|
|
@@ -2074,20 +2081,20 @@ Sessions using this assistant will revert to the default assistant.`,deleteAgent
|
|
|
2074
2081
|
<button class="modal-btn cancel">${r(`common.cancel`)}</button>
|
|
2075
2082
|
</div>
|
|
2076
2083
|
</div>
|
|
2077
|
-
`,a.querySelector(`.modal-title`).textContent=e,a.querySelector(`.modal-message`).textContent=t;let o=a.querySelector(`.modal-actions`),s=document.createElement(`button`);s.className=`modal-btn confirm`,s.textContent=n,o.appendChild(s),document.body.appendChild(a);let c=e=>{a.remove(),i(e)};a.querySelector(`.modal-btn.cancel`).addEventListener(`click`,()=>c(!1)),s.addEventListener(`click`,()=>c(!0)),a.addEventListener(`click`,e=>{e.target===a&&c(!1)})})}function
|
|
2084
|
+
`,a.querySelector(`.modal-title`).textContent=e,a.querySelector(`.modal-message`).textContent=t;let o=a.querySelector(`.modal-actions`),s=document.createElement(`button`);s.className=`modal-btn confirm`,s.textContent=n,o.appendChild(s),document.body.appendChild(a);let c=e=>{a.remove(),i(e)};a.querySelector(`.modal-btn.cancel`).addEventListener(`click`,()=>c(!1)),s.addEventListener(`click`,()=>c(!0)),a.addEventListener(`click`,e=>{e.target===a&&c(!1)})})}function hw(){let e=document.createElement(`div`);return e.className=`modal-overlay show context-usage-compacting-overlay`,e.style.zIndex=`10200`,e.innerHTML=`
|
|
2078
2085
|
<div class="modal-container context-usage-compacting-modal">
|
|
2079
2086
|
<div class="context-usage-compacting-spinner"></div>
|
|
2080
2087
|
<div class="modal-title"></div>
|
|
2081
2088
|
<div class="modal-message"></div>
|
|
2082
2089
|
</div>
|
|
2083
|
-
`,e.querySelector(`.modal-title`).textContent=r(`contextUsage.compactingTitle`),e.querySelector(`.modal-message`).textContent=r(`contextUsage.compactingHint`),document.body.appendChild(e),{close:()=>e.remove()}}function
|
|
2090
|
+
`,e.querySelector(`.modal-title`).textContent=r(`contextUsage.compactingTitle`),e.querySelector(`.modal-message`).textContent=r(`contextUsage.compactingHint`),document.body.appendChild(e),{close:()=>e.remove()}}function gw(e){let t=String(e||``);if(t===`empty_summary`)return r(`contextUsage.compactErrEmpty`);if(t.includes(`CHAT_STREAM_IDLE_TIMEOUT`))return r(`contextUsage.compactErrTimeout`);if(t.startsWith(`http_`)){let e=t.slice(5),n=e.indexOf(`:`),i=r(`contextUsage.compactErrHttp`,{status:n<0?e:e.slice(0,n)}),a=n<0?``:e.slice(n+1).trim();if(!a)return i;let o=a;try{let e=JSON.parse(a);o=e?.error?.message||e?.message||a}catch{}return`${i}: ${String(o).slice(0,200)}`}return t.includes(`超时`)||/timeout/i.test(t)?r(`contextUsage.compactErrTimeout`):t}async function _w({silent:e=!1}={}){if(!N.isolateChat)return e||P(r(`contextUsage.memoryOffToast`),`warning`),{success:!1,reason:`memory_off`};if(N.isGenerating)return e||P(r(`contextUsage.generatingToast`),`warning`),{success:!1,reason:`generating`};let t=N.messageHistory;if(!t.length)return e||P(r(`contextUsage.nothingToCompactToast`),`warning`),{success:!1,reason:`nothing_to_compact`};let n=N.activeCompaction,{material:i,includedCount:o,hasOldSummary:s}=Nn(t,{maxMemoryMessages:N.chatConfig?.maxMemoryMessages??null,compaction:n});if(o===0)return e||P(r(`contextUsage.nothingToCompactToast`),`warning`),{success:!1,reason:`nothing_to_compact`};let c=y(i.map(e=>({role:e.role,content:e.content})));if(!e&&!await mw({title:r(`contextUsage.confirmTitle`),message:r(`contextUsage.confirmMessage`,{count:o,tokens:I(c),summaryHint:s?r(`contextUsage.confirmWithOldSummary`):``}),okText:r(`contextUsage.confirmOk`)}))return{success:!1,reason:`cancelled`};let l=e?null:hw();try{let a=await chrome.runtime.sendMessage({type:`COMPACT_CONTEXT_SUMMARY`,material:i,model:N.currentModel,sessionId:N.activeSessionId,persistSummaryToMemory:N.chatConfig?.persistSummaryToMemory!==!1,compressedCount:(n?.compressedCount||0)+o,revision:(n?.revision||0)+1,memoryId:n?.memoryId||null});if(!a?.success||!a.summary){if(!e)if(a?.error===`config_missing`)P(r(`contextUsage.compactErrConfig`),`error`);else{let e=gw(a?.error);P(`${r(`contextUsage.compactErrFailed`)}${e?`(${e})`:``}`,`error`)}return{success:!1,reason:a?.error||`failed`}}let s=t[t.length-1],l=d(a.summary);return N.activeCompaction={summary:a.summary,upToMessageId:s?.messageId,compressedCount:(n?.compressedCount||0)+o,summaryTokens:l,savedTokens:Math.max(c-l,0),model:N.currentModel,createdAt:Date.now(),revision:(n?.revision||0)+1,memoryId:a.memoryId||n?.memoryId||null},await _i(),Cw(),uw(),ic(),e?P(r(`contextUsage.autoCompactedToast`,{saved:I(N.activeCompaction.savedTokens)}),`info`):P(r(`contextUsage.compactDone`,{saved:I(N.activeCompaction.savedTokens)}),`success`),{success:!0,savedTokens:N.activeCompaction.savedTokens}}catch(t){if(a.warn(`[ContextIndicator] compaction failed:`,t?.message),!e){let e=gw(t?.message);P(`${r(`contextUsage.compactErrFailed`)}${e?`(${e})`:``}`,`error`)}return{success:!1,reason:`exception`}}finally{l?.close()}}async function vw(){await _w({silent:!1})}function yw(){let e=N.activeCompaction;if(!e?.upToMessageId)return!1;let t=N.messageHistory||[],n=t.findIndex(t=>t.messageId===e.upToMessageId);return n>=0&&n<t.length-1}async function bw(e=!1){if(N.activeCompaction){if(yw()){P(r(`contextUsage.undoExpiredToast`),`warning`);return}!e&&!await mw({title:r(`contextUsage.undoTitle`),message:r(`contextUsage.undoMessage`),okText:r(`contextUsage.undoOk`)})||(N.activeCompaction=null,await _i(),xw(),uw(),P(r(`contextUsage.undoDone`),`success`))}}function xw(){document.querySelectorAll(`.compaction-divider`).forEach(e=>e.remove())}function Sw(){let e=yw();document.querySelectorAll(`.compaction-divider [data-action="undo"]`).forEach(t=>{t.style.display=e?`none`:``})}function Cw(){xw();let e=N.activeCompaction;if(!e?.upToMessageId)return;let t=document.getElementById(`chatContainer`);if(!t)return;let n=t.querySelector(`[data-message-id="${CSS.escape(e.upToMessageId)}"]`);if(!n)return;let i=document.createElement(`div`);i.className=`compaction-divider`;let a=!yw();i.innerHTML=`
|
|
2084
2091
|
<span class="compaction-divider-text">${r(`contextUsage.dividerText`,{count:e.compressedCount})}</span>
|
|
2085
2092
|
<button class="compaction-divider-btn" data-action="view">${r(`contextUsage.dividerView`)}</button>
|
|
2086
2093
|
${a?`<button class="compaction-divider-btn" data-action="undo">${r(`contextUsage.dividerUndo`)}</button>`:``}
|
|
2087
|
-
`,i.querySelector(`[data-action="view"]`).addEventListener(`click`,()=>
|
|
2094
|
+
`,i.querySelector(`[data-action="view"]`).addEventListener(`click`,()=>Dw(e)),i.querySelector(`[data-action="undo"]`)?.addEventListener(`click`,()=>bw()),n.after(i)}var ww=null;function Tw(){document.querySelectorAll(`.context-usage-popup`).forEach(e=>e.remove());let e=document.getElementById(`contextUsageIndicator`);e&&(e._ctxPopupOpen=!1),ww&&=(document.removeEventListener(`click`,ww),null)}function Ew(){let e=document.getElementById(`contextUsageIndicator`);if(!e)return;if(e._ctxPopupOpen){Tw();return}Tw(),e._ctxPopupOpen=!0;let{usage:t}=cw(),n=t.breakdown,i=Math.round(t.ratio*100),a;a=N.isolateChat?N.chatConfig?.maxMemoryMessages>0?r(`contextUsage.memoryLimited`,{n:N.chatConfig.maxMemoryMessages}):r(`contextUsage.memoryAll`):r(`contextUsage.memoryOff`);let o=N.activeCompaction,s;s=o&&n.compactionApplied?`
|
|
2088
2095
|
<div class="context-usage-compaction">
|
|
2089
2096
|
<div class="context-usage-dim">${r(`contextUsage.compactionActive`,{count:o.compressedCount,tokens:I(o.summaryTokens)})}</div>
|
|
2090
|
-
${
|
|
2097
|
+
${yw()?`<button class="context-usage-btn primary" data-action="compact">${r(`contextUsage.btnCompactAgain`)}</button>`:`<button class="context-usage-btn danger-ghost" data-action="undo">${r(`contextUsage.btnUndoCompact`)}</button>`}
|
|
2091
2098
|
</div>`:n.compactionInvalid?`
|
|
2092
2099
|
<div class="context-usage-compaction">
|
|
2093
2100
|
<div class="context-usage-warn">${r(`contextUsage.compactionInvalidHint`)}</div>
|
|
@@ -2120,7 +2127,7 @@ Sessions using this assistant will revert to the default assistant.`,deleteAgent
|
|
|
2120
2127
|
</div>
|
|
2121
2128
|
${s}
|
|
2122
2129
|
</div>
|
|
2123
|
-
`,document.body.appendChild(u);let d=e.getBoundingClientRect();u.style.left=`${Math.max(d.left,8)}px`,u.style.bottom=`${window.innerHeight-d.top+6}px`,u.querySelector(`.context-usage-popup-close`).addEventListener(`click`,()=>
|
|
2130
|
+
`,document.body.appendChild(u);let d=e.getBoundingClientRect();u.style.left=`${Math.max(d.left,8)}px`,u.style.bottom=`${window.innerHeight-d.top+6}px`,u.querySelector(`.context-usage-popup-close`).addEventListener(`click`,()=>Tw()),u.querySelector(`[data-action="compact"]`)?.addEventListener(`click`,()=>{Tw(),vw()}),u.querySelector(`[data-action="undo"]`)?.addEventListener(`click`,()=>{Tw(),bw(!0)}),u.querySelector(`[data-action="remove-invalid"]`)?.addEventListener(`click`,async()=>{Tw(),N.activeCompaction=null,await _i(),xw(),uw()}),ww=e=>{e.target.closest(`.context-usage-popup, #contextUsageIndicator`)||Tw()},setTimeout(()=>document.addEventListener(`click`,ww),0)}function Dw(e=N.activeCompaction){if(!e?.summary)return;let t=document.createElement(`div`);t.className=`modal-overlay show`,t.style.zIndex=`10200`,t.innerHTML=`
|
|
2124
2131
|
<div class="modal-container context-usage-summary-modal">
|
|
2125
2132
|
<button type="button" class="context-usage-summary-close" title="${r(`common.close`)}">×</button>
|
|
2126
2133
|
<div class="modal-title">${r(`contextUsage.summaryTitle`,{count:e.compressedCount})}
|
|
@@ -2131,7 +2138,7 @@ Sessions using this assistant will revert to the default assistant.`,deleteAgent
|
|
|
2131
2138
|
</div>
|
|
2132
2139
|
<div class="context-usage-summary-body"></div>
|
|
2133
2140
|
</div>
|
|
2134
|
-
`,document.body.appendChild(t);let n=t.querySelector(`.context-usage-summary-body`),i=t.querySelectorAll(`.context-usage-summary-tab`),a=t=>{i.forEach(e=>e.classList.toggle(`active`,e.dataset.mode===t)),t===`preview`?(n.classList.add(`markdown-body`),n.innerHTML=Kt(e.summary),qt()):(n.classList.remove(`markdown-body`),n.textContent=e.summary)};i.forEach(e=>e.addEventListener(`click`,()=>a(e.dataset.mode))),a(`preview`),t.querySelector(`.context-usage-summary-close`).addEventListener(`click`,()=>t.remove()),t.addEventListener(`click`,e=>{e.target===t&&t.remove()})}function
|
|
2141
|
+
`,document.body.appendChild(t);let n=t.querySelector(`.context-usage-summary-body`),i=t.querySelectorAll(`.context-usage-summary-tab`),a=t=>{i.forEach(e=>e.classList.toggle(`active`,e.dataset.mode===t)),t===`preview`?(n.classList.add(`markdown-body`),n.innerHTML=Kt(e.summary),qt()):(n.classList.remove(`markdown-body`),n.textContent=e.summary)};i.forEach(e=>e.addEventListener(`click`,()=>a(e.dataset.mode))),a(`preview`),t.querySelector(`.context-usage-summary-close`).addEventListener(`click`,()=>t.remove()),t.addEventListener(`click`,e=>{e.target===t&&t.remove()})}function Ow(){let e=document.getElementById(`chatNavUp`),t=document.getElementById(`chatNavDown`),n=document.getElementById(`chatNavHotzone`),i=document.getElementById(`chatNavButtons`),a=document.getElementById(`chatNavQuestionPanel`),o=[],s=!1,c=null,l=``,u=!1,d=!1;function f(){let e=document.getElementById(`chatContainer`);return e?e.getBoundingClientRect().top:0}function p(e,t){let n=document.getElementById(`chatContainer`);if(!n)return`noop`;let r=Et(n);if(r.length===0)return`noop`;let i=n.getBoundingClientRect().top;if(t){if(e===`prev`)r[0].start.scrollIntoView({behavior:`smooth`,block:`start`});else{let e=r[r.length-1].elements;e[e.length-1].scrollIntoView({behavior:`smooth`,block:`end`})}return`jumped`}let a=ft(r.length,St(r,i),e);return a===null?(m(e),`blocked`):(r[a].start.scrollIntoView({behavior:`smooth`,block:`start`}),`jumped`)}function m(n){let r=n===`prev`?e:t;r&&(r.classList.remove(`blocked`),r.offsetWidth,r.classList.add(`blocked`),r.addEventListener(`animationend`,()=>r.classList.remove(`blocked`),{once:!0}))}function h(e,t){let n=a.querySelectorAll(`.chat-nav-question-item`);n.forEach(t=>{Number(t.dataset.groupIndex)===e?(t.classList.add(`current`),t.setAttribute(`aria-current`,`true`)):(t.classList.remove(`current`),t.setAttribute(`aria-current`,`false`))});let i=a.querySelector(`.chat-nav-question-header .count`);i&&(i.textContent=r(`chat.navPosition`,{current:e>=0?e+1:t,total:t}));let o=Array.from(n).find(t=>Number(t.dataset.groupIndex)===e);!d&&e>=0&&o&&o.scrollIntoView({block:`nearest`})}function g(){if(!a||!a.classList.contains(`expanded`))return;o=Et(document.getElementById(`chatContainer`));let e=l?Et(document.getElementById(`chatContainer`)).length:a.querySelectorAll(`.chat-nav-question-item`).length;if(o.length===0){a.innerHTML=``,a.classList.remove(`expanded`);return}if(!l&&e!==o.length){_();return}h(St(o,f()),o.length)}function _(){if(!a)return!1;if(o=Et(document.getElementById(`chatContainer`)),o.length===0)return a.innerHTML=``,!1;let e=St(o,f()),t=document.activeElement===a.querySelector(`[data-role="nav-search"]`);a.innerHTML=jt(o,e,s,l),a.querySelector(`.chat-nav-pin`).addEventListener(`click`,e=>{e.stopPropagation(),w()});let n=a.querySelector(`[data-role="nav-search"]`);if(n){let e=()=>{l!==n.value&&(l=n.value,_())};n.addEventListener(`input`,t=>{t.isComposing||e()}),n.addEventListener(`compositionend`,e),t&&(n.focus(),n.setSelectionRange(n.value.length,n.value.length))}if(e>=0){let t=a.querySelector(`.chat-nav-question-item[data-group-index="${e}"]`);t&&t.scrollIntoView({block:`nearest`})}return!0}function v(){let e=document.activeElement;return e?[n,i,a].some(t=>t&&(t===e||t.contains(e))):!1}function y(){i.classList.remove(`expanded`),a&&a.classList.remove(`expanded`)}function b(){let e=v();y(),e&&n&&(u=!0,n.focus({preventScroll:!0}),u=!1)}function x(){if(clearTimeout(c),i.classList.add(`expanded`),a){if(a.classList.contains(`expanded`)){g();return}_()?a.classList.add(`expanded`):a.classList.remove(`expanded`)}}function S(e){clearTimeout(c),!s&&(v()||(e?y():c=setTimeout(y,300)))}function C(e){if(s=e,n&&(n.classList.toggle(`pinned`,e),n.setAttribute(`aria-pressed`,String(e))),a){a.classList.toggle(`pinned`,e);let t=a.querySelector(`.chat-nav-pin`);if(t){let n=r(e?`chat.navUnpinLabel`:`chat.navPinLabel`);t.textContent=n,t.title=n,t.setAttribute(`aria-pressed`,String(e)),t.classList.toggle(`on`,e)}}}function w(){C(!s)}e&&e.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),p(`prev`,e.ctrlKey||e.metaKey),g()}),t&&t.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),p(`next`,e.ctrlKey||e.metaKey),g()}),n&&i&&(n.addEventListener(`mouseenter`,x),n.addEventListener(`mouseleave`,()=>S(!1)),n.addEventListener(`click`,()=>w()),n.addEventListener(`focus`,()=>{u||x()}),n.addEventListener(`blur`,()=>S(!1)),n.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),w())}),i.addEventListener(`mouseenter`,x),i.addEventListener(`mouseleave`,()=>S(!1)),i.addEventListener(`focusin`,x),a&&(a.addEventListener(`mouseenter`,()=>{d=!0,x()}),a.addEventListener(`mouseleave`,()=>{d=!1,S(!1)}),a.addEventListener(`focusin`,x),a.addEventListener(`keydown`,e=>{if(e.target.matches(`[data-role="nav-search"]`))return;let t=Array.from(a.querySelectorAll(`.chat-nav-question-item`));if(t.length===0)return;let n=t.indexOf(document.activeElement),r=null;e.key===`ArrowDown`?r=Math.min(n+1,t.length-1):e.key===`ArrowUp`?r=n<=0?0:n-1:e.key===`Home`?r=0:e.key===`End`&&(r=t.length-1),r!==null&&(e.preventDefault(),t[r].focus())}),a.addEventListener(`click`,e=>{let t=e.target.closest(`.chat-nav-question-item`);if(!t||!t.dataset.messageId)return;let n=o.find(e=>(e.userElement||e.start).dataset.messageId===t.dataset.messageId);if(!n)return;let r=n.userElement||n.start;r.scrollIntoView({behavior:`instant`,block:`start`}),r.classList.add(`bookmark-highlight`),setTimeout(()=>r.classList.remove(`bookmark-highlight`),2e3),s?g():b()})));{let e=document.getElementById(`chatContainer`);if(e){let t=!1;e.addEventListener(`scroll`,()=>{!a||!a.classList.contains(`expanded`)||t||(t=!0,requestAnimationFrame(()=>{t=!1,g()}))},{passive:!0})}}function T(){let e=a&&a.classList.contains(`expanded`);if(!s&&!e)return!1;if(a&&a.querySelector(`[data-role="nav-search"]`)&&l){l=``,_();let e=a.querySelector(`[data-role="nav-search"]`);return e&&e.focus(),!0}return C(!1),b(),!0}return{jumpToMessage:p,updateActiveQuestion:g,handleEscape:T,isPinned:()=>s}}n(`zh`,{searchPanel:{toggleTitle:`消息搜索`,title:`消息搜索`,closeTitle:`关闭`,inputPlaceholder:`搜索消息(支持 & | 组合搜索)...`,clearTitle:`清除`,globalSearchTitle:`在所有会话中搜索`,globalSearch:`全局搜索`,currentSessionTitle:`仅在当前会话中搜索`,currentSession:`当前会话`,startSearchHint:`输入关键词开始搜索`,searching:`搜索中...`,searchingWithCount:`搜索中... {count} 条`,searchError:`搜索出错`,noActiveSession:`没有活跃会话`,noSessionData:`没有会话数据`,noMatch:`未找到匹配消息`,unknownSession:`未知会话`,countResult:`{count} 条`,noResult:`无结果`,searchingSuffix:` (搜索中...)`,currentSessionResults:`当前会话{label} · {count} 条`,otherSessionsResults:`其他会话 · {count} 条`,roleUser:`你`,roleAssistant:`助手`,sessionNotExist:`会话已不存在`,messageDeleted:`消息已被删除`}}),n(`en`,{searchPanel:{toggleTitle:`Search messages`,title:`Message search`,closeTitle:`Close`,inputPlaceholder:`Search messages (supports & | combined search)...`,clearTitle:`Clear`,globalSearchTitle:`Search in all sessions`,globalSearch:`Global search`,currentSessionTitle:`Search in current session only`,currentSession:`Current session`,startSearchHint:`Enter keywords to start searching`,searching:`Searching...`,searchingWithCount:`Searching... {count} found`,searchError:`Search error`,noActiveSession:`No active session`,noSessionData:`No session data`,noMatch:`No matching messages found`,unknownSession:`Unknown session`,countResult:`{count} found`,noResult:`No results`,searchingSuffix:` (searching...)`,currentSessionResults:`Current session{label} · {count} found`,otherSessionsResults:`Other sessions · {count} found`,roleUser:`You`,roleAssistant:`Assistant`,sessionNotExist:`Session no longer exists`,messageDeleted:`Message has been deleted`}});var kw=!1,Aw=!1,jw=[],Mw=``;function Nw(){N.searchInputHistory=[],N.searchInputHistoryIndex=-1;try{chrome.storage.local.get([`searchInputHistory`],e=>{e.searchInputHistory&&(N.searchInputHistory=e.searchInputHistory)})}catch{}let e=document.createElement(`div`);e.className=`search-panel-container`,e.id=`searchPanelContainer`,e.innerHTML=`
|
|
2135
2142
|
<button class="search-panel-toggle" id="searchPanelToggle" title="${r(`searchPanel.toggleTitle`)}">
|
|
2136
2143
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2137
2144
|
<circle cx="11" cy="11" r="8"/>
|
|
@@ -2166,13 +2173,13 @@ Sessions using this assistant will revert to the default assistant.`,deleteAgent
|
|
|
2166
2173
|
<div class="search-panel-empty">${r(`searchPanel.startSearchHint`)}</div>
|
|
2167
2174
|
</div>
|
|
2168
2175
|
</div>
|
|
2169
|
-
`,Vn(`search`).appendChild(e),
|
|
2176
|
+
`,Vn(`search`).appendChild(e),Pw(),a.debug(`[SearchPanel] search panelinitializing`)}function Pw(){document.getElementById(`searchPanelContainer`);let e=document.getElementById(`searchPanel`),t=document.getElementById(`searchPanelToggle`),n=document.getElementById(`searchPanelInput`),r=document.getElementById(`searchPanelClear`),i=document.getElementById(`searchPanelClose`),a=document.getElementById(`searchModeGlobal`),o=document.getElementById(`searchModeCurrent`);t.addEventListener(`click`,()=>{e.classList.contains(`expanded`)?Iw():Fw()}),i.addEventListener(`click`,()=>{Iw()}),r.addEventListener(`click`,()=>{n.value=``,r.style.display=`none`,Lw(),n.focus()}),n.addEventListener(`input`,()=>{let e=n.value.trim();r.style.display=e?``:`none`,e||Lw()}),n.addEventListener(`keydown`,e=>{if(e.key===`Enter`){e.stopPropagation();let t=n.value.trim();t&&(s(t),Rw(t))}else if(e.key===`Escape`)N.searchInputHistoryIndex>=0?(N.searchInputHistoryIndex=-1,n.value=``):(e.stopPropagation(),Iw());else if(e.key===`ArrowUp`){e.preventDefault(),e.stopPropagation();let t=N.searchInputHistory;if(t.length===0)return;N.searchInputHistoryIndex===-1?N.searchInputHistoryIndex=t.length-1:N.searchInputHistoryIndex>0&&N.searchInputHistoryIndex--,n.value=t[N.searchInputHistoryIndex]||``,r.style.display=n.value?``:`none`,n.selectionStart=n.selectionEnd=n.value.length}else if(e.key===`ArrowDown`){e.preventDefault(),e.stopPropagation();let t=N.searchInputHistory;N.searchInputHistoryIndex>=0&&N.searchInputHistoryIndex<t.length-1?(N.searchInputHistoryIndex++,n.value=t[N.searchInputHistoryIndex]||``,n.selectionStart=n.selectionEnd=n.value.length):(N.searchInputHistoryIndex=-1,n.value=``),r.style.display=n.value?``:`none`}});function s(e){if(!e||!e.trim())return;let t=e.trim(),n=N.searchInputHistory,r=n.indexOf(t);r!==-1&&n.splice(r,1),n.push(t),n.length>20&&n.shift(),N.searchInputHistoryIndex=-1;try{chrome.storage.local.set({searchInputHistory:n})}catch{}}a.addEventListener(`click`,()=>{a.classList.contains(`active`)||(a.classList.add(`active`),o.classList.remove(`active`));let e=n.value.trim();e&&Rw(e)}),o.addEventListener(`click`,()=>{o.classList.contains(`active`)||(o.classList.add(`active`),a.classList.remove(`active`));let e=n.value.trim();e&&Rw(e)}),document.getElementById(`searchPanelContent`).addEventListener(`click`,async e=>{let t=e.target.closest(`.search-result-item`);if(!t)return;let n=t.dataset.sessionId,r=t.dataset.messageId;await Kw(n,r)})}function Fw(){let e=document.getElementById(`searchPanel`),t=document.getElementById(`searchPanelInput`);e.classList.add(`expanded`),xt(e),t.value.trim()&&jw.length===0&&Rw(t.value.trim()),setTimeout(()=>t.focus(),100)}function Iw(){let e=document.getElementById(`searchPanel`);e.classList.remove(`expanded`),gt(e),Aw=!0,kw=!1}function Lw(){Aw=!0,kw=!1,jw=[],Mw=``;let e=document.getElementById(`searchPanelContent`),t=document.getElementById(`searchPanelCount`);e&&(e.innerHTML=`<div class="search-panel-empty">${r(`searchPanel.startSearchHint`)}</div>`),t&&(t.textContent=``)}async function Rw(e){if(!e||!e.trim()||(e=e.trim().toLowerCase(),kw&&Mw===e))return;Aw=!0,await new Promise(e=>setTimeout(e,50)),kw=!0,Aw=!1,jw=[],Mw=e;let t=document.getElementById(`searchPanelContent`),n=document.getElementById(`searchPanelCount`);t.innerHTML=`<div class="search-panel-loading">${r(`searchPanel.searching`)}</div>`,n.textContent=``;let i=document.getElementById(`searchModeGlobal`).classList.contains(`active`);try{i?await Bw(e,t,n):await zw(e,t,n)}catch(e){a.error(`[SearchPanel] search error:`,e),Aw||(t.innerHTML=`<div class="search-panel-empty">${r(`searchPanel.searchError`)}</div>`)}Aw||(kw=!1)}async function zw(e,t,n){let i=N.activeSessionId;if(!i){t.innerHTML=`<div class="search-panel-empty">${r(`searchPanel.noActiveSession`)}</div>`;return}let a=Vw(N.messageHistory||[],e,i);if(!Aw){if(jw=a,n.textContent=a.length>0?r(`searchPanel.countResult`,{count:a.length}):r(`searchPanel.noResult`),a.length===0){t.innerHTML=`<div class="search-panel-empty">${r(`searchPanel.noMatch`)}</div>`;return}Uw(a,e,t)}}async function Bw(e,t,n){let i=N.activeSessionId,o=await ge();if(Aw)return;if(!o||o.length===0){t.innerHTML=`<div class="search-panel-empty">${r(`searchPanel.noSessionData`)}</div>`;return}let s=[],c=[];if(i){let a=Vw(N.messageHistory||[],e,i);if(Aw)return;let c=o.find(e=>e.id===i)?.title||r(`searchPanel.currentSession`);for(let e of a)s.push({...e,sessionTitle:c});jw=[...s],n.textContent=r(`searchPanel.searchingWithCount`,{count:s.length}),Uw(jw,e,t,!0)}let l=o.filter(e=>e.id!==i);for(let i of l){if(Aw)return;try{let a=await Ge(i.id);if(!a||!a.messageHistory)continue;let o=Vw(a.messageHistory||[],e,i.id);if(o.length>0){for(let e of o)c.push({...e,sessionTitle:i.title||r(`searchPanel.unknownSession`)});jw=[...s,...c];let a=s.length+c.length;n.textContent=a>0?r(`searchPanel.countResult`,{count:a}):r(`searchPanel.noResult`),Uw(jw,e,t)}}catch(e){a.warn(`[SearchPanel] searchsession failed:`,i.id,e)}await new Promise(e=>setTimeout(e,10))}if(Aw)return;let u=jw.length;if(n.textContent=u>0?r(`searchPanel.countResult`,{count:u}):r(`searchPanel.noResult`),u===0){t.innerHTML=`<div class="search-panel-empty">${r(`searchPanel.noMatch`)}</div>`;return}Uw(jw,e,t)}function Vw(e,t,n){let r=[];if(!e||e.length===0)return r;let i=t.includes(`&`)||t.includes(`|`);for(let a of e){if(a.role!==`assistant`&&a.role!==`user`)continue;let e=a.messageId||a.id;if(!e)continue;let o=Hw(a.content);if(!o)continue;let s=o.toLowerCase(),c=-1,l=t;if(i){let e=t.split(`|`).map(e=>e.trim()).filter(Boolean),n=!1;for(let t of e){let e=t.split(`&`).map(e=>e.trim()).filter(Boolean);if(e.length!==0&&e.every(e=>s.includes(e))){n=!0,l=e[0],c=s.indexOf(l);break}}if(!n)continue}else{if(!s.includes(t))continue;c=s.indexOf(t)}let u=l.length,d=Math.max(0,c-30),f=Math.min(o.length,c+u+30),p=o.substring(d,f);d>0&&(p=`...`+p),f<o.length&&(p+=`...`),r.push({messageId:e,content:o.substring(0,200),role:a.role,sessionId:n,matchPreview:p,query:t})}return r}function Hw(e){return e?typeof e==`string`?e.replace(/<[^>]*>/g,``):Array.isArray(e)?e.filter(e=>e.type===`text`).map(e=>e.text||``).join(` `):String(e):``}function Uw(e,t,n,i){if(n||=document.getElementById(`searchPanelContent`),!n)return;if(e.length===0){n.innerHTML=`<div class="search-panel-empty">${r(`searchPanel.noMatch`)}</div>`;return}let a=N.activeSessionId,o=e.filter(e=>e.sessionId===a),s=e.filter(e=>e.sessionId!==a),c=``,l=i?r(`searchPanel.searchingSuffix`):``;o.length>0&&(c+=`<div class="search-section">
|
|
2170
2177
|
<div class="search-section-title">${r(`searchPanel.currentSessionResults`,{label:l,count:o.length})}</div>
|
|
2171
|
-
${
|
|
2178
|
+
${Ww(o,t)}
|
|
2172
2179
|
</div>`),s.length>0&&(c+=`<div class="search-section">
|
|
2173
2180
|
<div class="search-section-title">${r(`searchPanel.otherSessionsResults`,{count:s.length})}</div>
|
|
2174
|
-
${
|
|
2175
|
-
</div>`),n.innerHTML=c}function
|
|
2181
|
+
${Ww(s,t)}
|
|
2182
|
+
</div>`),n.innerHTML=c}function Ww(e,t){return e.map((e,n)=>{let i=e.role===`user`?`👤`:`🤖`,a=e.role===`user`?r(`searchPanel.roleUser`):r(`searchPanel.roleAssistant`),o=e.sessionTitle||``,s=e.sessionId===N.activeSessionId,c=Gw(F(e.matchPreview),t);return`
|
|
2176
2183
|
<div class="search-result-item" data-session-id="${e.sessionId}" data-message-id="${e.messageId}" title="${F(e.content)}">
|
|
2177
2184
|
<div class="search-result-header">
|
|
2178
2185
|
<span class="search-result-role">${i} ${a}</span>
|
|
@@ -2180,7 +2187,7 @@ Sessions using this assistant will revert to the default assistant.`,deleteAgent
|
|
|
2180
2187
|
</div>
|
|
2181
2188
|
<div class="search-result-preview">${c}</div>
|
|
2182
2189
|
</div>
|
|
2183
|
-
`}).join(``)}function
|
|
2190
|
+
`}).join(``)}function Gw(e,t){if(!t)return e;let n=t.split(/[&|]/).map(e=>e.trim()).filter(Boolean);if(n.length===0)return e;let r=n.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)),i=RegExp(`(${r.join(`|`)})`,`gi`);return e.replace(i,`<mark class="search-highlight-match">$1</mark>`)}async function Kw(e,t){if(!(!e||!t)){if(N.activeSessionId!==e)try{let t=N.activeSessionId;if(await xi(e)===!1||N.activeSessionId!==e){P(r(`searchPanel.sessionNotExist`),`warning`);return}document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:e,previousSessionId:t,skipScrollRestore:!0}}));try{let{renderSessionTabs:e}=await M(async()=>{let{renderSessionTabs:e}=await Promise.resolve().then(()=>Co);return{renderSessionTabs:e}},void 0);e()}catch(e){a.warn(`[SearchPanel] refreshsessionTab failed:`,e)}}catch(e){a.error(`[SearchPanel] switchsession failed:`,e);return}setTimeout(async()=>{let n=document.getElementById(`chatContainer`);if(!n){a.warn(`[SearchPanel] chatContainer not found`);return}let i=n.querySelector(`.message[data-message-id="${t}"]`);if(i||=n.querySelector(`[data-message-id="${t}"]`),!i){let r=Array.from(n.querySelectorAll(`[data-message-id]`),e=>e.dataset.messageId);a.warn(`[SearchPanel] positionmessage failed`,{targetSessionId:e,activeSessionId:N.activeSessionId,targetMessageId:t,typeOfMessageId:typeof t,messageIdLength:t.length,domMessageIds:r,chatContainerHtmlLen:n.innerHTML.length})}if(i)i.scrollIntoView({behavior:`instant`,block:`nearest`}),i.classList.add(`bookmark-highlight`),setTimeout(()=>{i.classList.remove(`bookmark-highlight`)},2e3);else{P(r(`searchPanel.messageDeleted`),`warning`);try{if(await be(e,t)){jw=jw.filter(n=>!(n.sessionId===e&&n.messageId===t));let n=document.getElementById(`searchPanelContent`),i=document.getElementById(`searchPanelCount`);n&&jw.length>0?(Uw(jw,Mw,n),i.textContent=r(`searchPanel.countResult`,{count:jw.length})):n&&jw.length===0&&(n.innerHTML=`<div class="search-panel-empty">${r(`searchPanel.noMatch`)}</div>`,i&&(i.textContent=r(`searchPanel.noResult`))),a.debug(`[SearchPanel] cleaned IndexedDB dirtydata:`,e,t)}}catch(e){a.warn(`[SearchPanel] cleanupdirtydata failed:`,e)}}},500)}}n(`zh`,{schedPanel:{toggleTitle:`定时任务`,toggleRunning:`执行中`,title:`定时任务`,newTask:`新建任务`,close:`关闭`,empty:`暂无定时任务`,nameLabel:`任务名称`,descLabel:`任务描述(可选)`,promptLabel:`任务指令`,scheduleLabel:`定时规则`,scheduleTypeOnce:`一次性`,scheduleTypeInterval:`间隔`,scheduleTypeCron:`Cron 表达式`,intervalValuePlaceholder:`例如:30m / 2h / 1d`,cronValuePlaceholder:`例如:0 9 * * *`,relativeValuePlaceholder:`例如:30`,onceModeLabel:`执行方式`,onceModeRelative:`多少分钟后`,onceModeAbsolute:`指定时间点`,valueLabelInterval:`间隔时间`,valueLabelCron:`Cron 表达式`,minutesSuffix:` 分钟后`,contextUrlLabel:`上下文网页地址(可选)`,useCurrentPage:`使用当前页面`,sessionLabel:`宿主会话`,sessionAuto:`自动(会话被删时自动新建)`,save:`保存`,cancel:`取消`,edit:`编辑`,editTitle:`编辑任务`,delete:`删除`,runNow:`立即执行`,enable:`启用`,disable:`停用`,statusSuccess:`成功`,statusFailed:`失败`,statusRunning:`运行中`,statusDisabled:`已停用`,nextRun:`下次执行`,deleted:`任务已删除`,saved:`任务已保存`,runNowToast:`已触发执行`,deleteConfirmTitle:`删除定时任务`,deleteConfirmMsg:`确定删除任务「{name}」吗?`,createFailed:`创建任务失败`,nameRequired:`请填写任务名称`,promptRequired:`请填写任务指令`,scheduleRequired:`请填写定时规则`,loading:`加载中...`,contextModeLabel:`网页上下文方式`,contextModeFetch:`抓取网页正文`,contextModeUrlOnly:`仅使用 URL(不抓正文)`,maxRunsLabel:`最多执行次数(可选)`,endAtLabel:`截止时间(可选)`,runHistoryLabel:`运行历史`,runHistoryEmpty:`暂无运行记录`,runCountLabel:`运行历史 ({count})`}}),n(`en`,{schedPanel:{toggleTitle:`Scheduled tasks`,toggleRunning:`Running`,title:`Scheduled tasks`,newTask:`New task`,close:`Close`,empty:`No scheduled tasks`,nameLabel:`Name`,descLabel:`Description (optional)`,promptLabel:`Prompt`,scheduleLabel:`Schedule`,scheduleTypeOnce:`Once`,scheduleTypeInterval:`Interval`,scheduleTypeCron:`Cron expression`,intervalValuePlaceholder:`e.g. 30m / 2h / 1d`,cronValuePlaceholder:`e.g. 0 9 * * *`,relativeValuePlaceholder:`e.g. 30`,onceModeLabel:`Run mode`,onceModeRelative:`After some minutes`,onceModeAbsolute:`At specific time`,valueLabelInterval:`Interval`,valueLabelCron:`Cron expression`,minutesSuffix:` minutes later`,contextUrlLabel:`Context page URL (optional)`,useCurrentPage:`Use current page`,sessionLabel:`Host session`,sessionAuto:`Auto (recreate if deleted)`,save:`Save`,cancel:`Cancel`,edit:`Edit`,editTitle:`Edit task`,delete:`Delete`,runNow:`Run now`,enable:`Enable`,disable:`Disable`,statusSuccess:`Success`,statusFailed:`Failed`,statusRunning:`Running`,statusDisabled:`Disabled`,nextRun:`Next run`,deleted:`Task deleted`,saved:`Task saved`,runNowToast:`Execution triggered`,deleteConfirmTitle:`Delete scheduled task`,deleteConfirmMsg:`Delete task "{name}"?`,createFailed:`Failed to create task`,nameRequired:`Name is required`,promptRequired:`Prompt is required`,scheduleRequired:`Schedule is required`,loading:`Loading...`,contextModeLabel:`Page context mode`,contextModeFetch:`Fetch page content`,contextModeUrlOnly:`URL only`,maxRunsLabel:`Max runs (optional)`,endAtLabel:`End time (optional)`,runHistoryLabel:`Run history`,runHistoryEmpty:`No runs yet`,runCountLabel:`Run history ({count})`}});function qw(e){return chrome.runtime.sendMessage(e)}function Jw(e){return e?new Date(e).toLocaleString(void 0,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`}):`—`}function Yw(e){return e==null?``:e<1e3?e+`ms`:e<6e4?(e/1e3).toFixed(1).replace(/\.0$/,``)+`s`:(e/6e4).toFixed(1).replace(/\.0$/,``)+`min`}function Xw(e){return e===`success`?r(`schedPanel.statusSuccess`):e===`failed`?r(`schedPanel.statusFailed`):e===`running`?r(`schedPanel.statusRunning`):``}function Zw(e){if(!e)return``;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function Qw(e){let t=e.schedule||{};return t.type===`once`?t.onceMode===`relative`?r(`schedPanel.scheduleTypeOnce`)+` · `+(t.value||``)+r(`schedPanel.minutesSuffix`):r(`schedPanel.scheduleTypeOnce`)+` · `+Jw(new Date(t.value).getTime()):t.type===`interval`?r(`schedPanel.scheduleTypeInterval`)+` · `+(t.value||``):t.type===`cron`?r(`schedPanel.scheduleTypeCron`)+` · `+(t.value||``):``}function $w(e){return e.enabled?e.lastStatus===`running`?`<span class="sched-badge running">${r(`schedPanel.statusRunning`)}</span>`:e.lastStatus===`failed`?`<span class="sched-badge failed">${r(`schedPanel.statusFailed`)}</span>`:e.lastStatus===`success`?`<span class="sched-badge success">${r(`schedPanel.statusSuccess`)}</span>`:``:`<span class="sched-badge muted">${r(`schedPanel.statusDisabled`)}</span>`}function eT(){let e=document.getElementById(`chatContainer`);e&&(e.scrollTop=e.scrollHeight)}async function tT(e){if(e){if(N.activeSessionId!==e){let t=N.activeSessionId;try{if(await xi(e)===!1||N.activeSessionId!==e)return}catch{return}document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:e,previousSessionId:t,skipScrollRestore:!0}}));try{let{renderSessionTabs:e}=await M(async()=>{let{renderSessionTabs:e}=await Promise.resolve().then(()=>Co);return{renderSessionTabs:e}},void 0);e()}catch{}}setTimeout(eT,500)}}function nT(){let e=document.createElement(`div`);e.className=`schedule-panel-container`,e.id=`schedulePanelContainer`,e.innerHTML=`
|
|
2184
2191
|
<style>
|
|
2185
2192
|
.schedule-panel-container { position: relative; display: flex; justify-content: flex-end; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; width: 100%; background: transparent; }
|
|
2186
2193
|
.schedule-panel-toggle { background: rgba(var(--success-rgb), 0.14); color: var(--success-strong); border: none; border-radius: 6px 0 0 6px; padding: 8px 4px; cursor: pointer; font-size: 14px; box-shadow: -1px 1px 4px rgba(var(--overlay-rgb), 0.12); transition: all 0.3s ease; display: flex; align-items: center; justify-content: center; }
|
|
@@ -2190,7 +2197,7 @@ Sessions using this assistant will revert to the default assistant.`,deleteAgent
|
|
|
2190
2197
|
.schedule-panel-toggle.running { animation: sched-btn-glow 1.4s ease-in-out infinite; }
|
|
2191
2198
|
@keyframes sched-icon-spin { to { transform: rotate(360deg); } }
|
|
2192
2199
|
@keyframes sched-btn-glow { 0%, 100% { box-shadow: -2px 2px 8px rgba(var(--success-rgb), 0.3); } 50% { box-shadow: -2px 2px 18px rgba(var(--success-rgb), 0.85); } }
|
|
2193
|
-
.schedule-panel { position: absolute; right: 26px; bottom: -40px; width: 360px; max-height: 70vh; background: rgba(var(--surface-rgb), 1); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid
|
|
2200
|
+
.schedule-panel { position: absolute; right: 26px; bottom: -40px; width: 360px; max-height: 70vh; background: rgba(var(--surface-rgb), 1); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: 0 8px 32px rgba(var(--overlay-rgb), 0.18); display: none; flex-direction: column; overflow: hidden; transform: translateY(var(--clamp-y, 0px)); }
|
|
2194
2201
|
.schedule-panel.open { display: flex; }
|
|
2195
2202
|
.schedule-panel-header { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--border-subtle); flex-shrink: 0; }
|
|
2196
2203
|
.schedule-panel-header .title { font-weight: 600; font-size: 13px; color: var(--text-primary); flex: 1; }
|
|
@@ -2311,23 +2318,23 @@ Sessions using this assistant will revert to the default assistant.`,deleteAgent
|
|
|
2311
2318
|
<button class="primary" id="scheduleModalSave">${r(`schedPanel.save`)}</button>
|
|
2312
2319
|
</div>
|
|
2313
2320
|
</div>
|
|
2314
|
-
`,document.body.appendChild(t);let n=document.getElementById(`schedulePanelToggle`),i=document.getElementById(`schedulePanel`),a=new Set;function o(){let e=a.size>0;n.classList.toggle(`running`,e),n.title=e?`${r(`schedPanel.toggleTitle`)} · ${r(`schedPanel.toggleRunning`)}`:r(`schedPanel.toggleTitle`)}let s=document.getElementById(`schedulePanelClose`),c=document.getElementById(`scheduleNewTask`),l=document.getElementById(`schedulePanelList`),u=document.getElementById(`scheduleModalOverlay`),d=document.getElementById(`scheduleModalTitle`),f=document.getElementById(`scheduleModalCancel`),p=document.getElementById(`scheduleModalSave`),m=document.getElementById(`schedFormType`),h=document.getElementById(`schedFormValue`),g=document.getElementById(`schedFormOnceMode`),_=document.getElementById(`schedOnceModeWrap`),v=document.getElementById(`schedValueLabel`),y=document.getElementById(`schedEndWrap`),b=null;function x(){let e=m.value,t=g.value;_.style.display=e===`once`?``:`none`,y.style.display=e===`interval`?``:`none`,e===`once`?t===`relative`?(v.textContent=r(`schedPanel.onceModeRelative`),h.type=`text`,h.placeholder=r(`schedPanel.relativeValuePlaceholder`)):(v.textContent=r(`schedPanel.onceModeAbsolute`),h.type=`datetime-local`,h.placeholder=``):e===`interval`?(v.textContent=r(`schedPanel.valueLabelInterval`),h.type=`text`,h.placeholder=r(`schedPanel.intervalValuePlaceholder`)):(v.textContent=r(`schedPanel.valueLabelCron`),h.type=`text`,h.placeholder=r(`schedPanel.cronValuePlaceholder`))}function S(e){e?(i.classList.add(`open`),xt(i),C()):(i.classList.remove(`open`),gt(i))}n.addEventListener(`click`,()=>{S(!i.classList.contains(`open`))}),s.addEventListener(`click`,()=>S(!1)),m.addEventListener(`change`,x),g.addEventListener(`change`,x),document.getElementById(`scheduleModalCloseBtn`).addEventListener(`click`,O),f.addEventListener(`click`,O),p.addEventListener(`click`,k),c.addEventListener(`click`,()=>D(null)),document.getElementById(`schedUseCurrentPage`).addEventListener(`click`,async()=>{try{let e=(await chrome.tabs.query({active:!0,currentWindow:!0}))?.[0]?.url||``;e&&(document.getElementById(`schedFormUrl`).value=e)}catch{}});async function C(){try{let e=(await
|
|
2321
|
+
`,document.body.appendChild(t);let n=document.getElementById(`schedulePanelToggle`),i=document.getElementById(`schedulePanel`),a=new Set;function o(){let e=a.size>0;n.classList.toggle(`running`,e),n.title=e?`${r(`schedPanel.toggleTitle`)} · ${r(`schedPanel.toggleRunning`)}`:r(`schedPanel.toggleTitle`)}let s=document.getElementById(`schedulePanelClose`),c=document.getElementById(`scheduleNewTask`),l=document.getElementById(`schedulePanelList`),u=document.getElementById(`scheduleModalOverlay`),d=document.getElementById(`scheduleModalTitle`),f=document.getElementById(`scheduleModalCancel`),p=document.getElementById(`scheduleModalSave`),m=document.getElementById(`schedFormType`),h=document.getElementById(`schedFormValue`),g=document.getElementById(`schedFormOnceMode`),_=document.getElementById(`schedOnceModeWrap`),v=document.getElementById(`schedValueLabel`),y=document.getElementById(`schedEndWrap`),b=null;function x(){let e=m.value,t=g.value;_.style.display=e===`once`?``:`none`,y.style.display=e===`interval`?``:`none`,e===`once`?t===`relative`?(v.textContent=r(`schedPanel.onceModeRelative`),h.type=`text`,h.placeholder=r(`schedPanel.relativeValuePlaceholder`)):(v.textContent=r(`schedPanel.onceModeAbsolute`),h.type=`datetime-local`,h.placeholder=``):e===`interval`?(v.textContent=r(`schedPanel.valueLabelInterval`),h.type=`text`,h.placeholder=r(`schedPanel.intervalValuePlaceholder`)):(v.textContent=r(`schedPanel.valueLabelCron`),h.type=`text`,h.placeholder=r(`schedPanel.cronValuePlaceholder`))}function S(e){e?(i.classList.add(`open`),xt(i),C()):(i.classList.remove(`open`),gt(i))}n.addEventListener(`click`,()=>{S(!i.classList.contains(`open`))}),s.addEventListener(`click`,()=>S(!1)),m.addEventListener(`change`,x),g.addEventListener(`change`,x),document.getElementById(`scheduleModalCloseBtn`).addEventListener(`click`,O),f.addEventListener(`click`,O),p.addEventListener(`click`,k),c.addEventListener(`click`,()=>D(null)),document.getElementById(`schedUseCurrentPage`).addEventListener(`click`,async()=>{try{let e=(await chrome.tabs.query({active:!0,currentWindow:!0}))?.[0]?.url||``;e&&(document.getElementById(`schedFormUrl`).value=e)}catch{}});async function C(){try{let e=(await qw({type:`SCHEDULED_TASK_LIST`}))?.tasks||[],t=document.getElementById(`schedulePanelCount`);t&&(t.textContent=e.length>0?`(${e.length})`:``),T(e),a.clear(),e.forEach(e=>{e.lastStatus===`running`&&a.add(e.id)}),o()}catch(e){l.innerHTML=`<div class="sched-empty">${F(String(e?.message||e))}</div>`}}function w(e){return!e||!e.length?`<div class="sched-history"><div class="sched-run">${r(`schedPanel.runHistoryEmpty`)}</div></div>`:`<div class="sched-history">${e.slice().reverse().map(e=>`
|
|
2315
2322
|
<div class="sched-run">
|
|
2316
2323
|
<span class="dot ${F(e.status||``)}"></span>
|
|
2317
|
-
<span class="time">${F(
|
|
2318
|
-
<span>${F(
|
|
2319
|
-
<span class="dur">${F(
|
|
2324
|
+
<span class="time">${F(Jw(e.startedAt))}</span>
|
|
2325
|
+
<span>${F(Xw(e.status))}</span>
|
|
2326
|
+
<span class="dur">${F(Yw(e.durationMs))}</span>
|
|
2320
2327
|
${e.error?`<span class="err" title="${F(e.error)}">${F(e.error)}</span>`:``}
|
|
2321
2328
|
</div>
|
|
2322
2329
|
`).join(``)}</div>`}function T(e){if(!e.length){l.innerHTML=`<div class="sched-empty">${r(`schedPanel.empty`)}</div>`;return}l.innerHTML=e.map(e=>{let t=e.runHistory?.length||0,n=t>0?`<button class="sched-history-btn" data-act="history">${r(`schedPanel.runCountLabel`,{count:t})}</button>`:``;return`
|
|
2323
2330
|
<div class="sched-item" data-id="${F(e.id)}">
|
|
2324
2331
|
<div class="row1">
|
|
2325
2332
|
<span class="name" title="${F(e.name)}">${F(e.name)}</span>
|
|
2326
|
-
${
|
|
2333
|
+
${$w(e)}
|
|
2327
2334
|
</div>
|
|
2328
2335
|
${e.description?`<div class="desc">${F(e.description)}</div>`:``}
|
|
2329
|
-
<div class="meta">${F(
|
|
2330
|
-
<div class="meta">${r(`schedPanel.nextRun`)}: ${F(
|
|
2336
|
+
<div class="meta">${F(Qw(e))}</div>
|
|
2337
|
+
<div class="meta">${r(`schedPanel.nextRun`)}: ${F(Jw(e.nextRunAt))}</div>
|
|
2331
2338
|
${n}
|
|
2332
2339
|
<div class="sched-history" data-history style="display:none;">${w(e.runHistory)}</div>
|
|
2333
2340
|
<div class="actions">
|
|
@@ -2337,16 +2344,16 @@ Sessions using this assistant will revert to the default assistant.`,deleteAgent
|
|
|
2337
2344
|
<button data-act="delete" class="danger">${r(`schedPanel.delete`)}</button>
|
|
2338
2345
|
</div>
|
|
2339
2346
|
</div>
|
|
2340
|
-
`}).join(``)}l.addEventListener(`click`,async e=>{let t=e.target.closest(`button[data-act]`);if(!t)return;let n=t.closest(`.sched-item`),i=n?.dataset.id;if(!i)return;let a=t.dataset.act;if(a===`toggle`){let e=(await E())[i];if(!e)return;await
|
|
2341
|
-
`)}function
|
|
2347
|
+
`}).join(``)}l.addEventListener(`click`,async e=>{let t=e.target.closest(`button[data-act]`);if(!t)return;let n=t.closest(`.sched-item`),i=n?.dataset.id;if(!i)return;let a=t.dataset.act;if(a===`toggle`){let e=(await E())[i];if(!e)return;await qw({type:`SCHEDULED_TASK_TOGGLE`,id:i,enabled:!e.enabled}),C()}else if(a===`run`){let e=await qw({type:`SCHEDULED_TASK_RUN_NOW`,id:i});e?.success?(P(r(`schedPanel.runNowToast`),`success`),tT(e.sessionId),setTimeout(C,1500)):P(e?.error||r(`schedPanel.createFailed`),`error`)}else if(a===`history`){let e=n.querySelector(`[data-history]`);e&&(e.style.display=e.style.display===`none`?``:`none`)}else if(a===`edit`)D((await E())[i]);else if(a===`delete`){let e=(await E())[i];await window.showCustomConfirm(r(`schedPanel.deleteConfirmMsg`,{name:e?.name||``}),r(`schedPanel.deleteConfirmTitle`))&&(await qw({type:`SCHEDULED_TASK_DELETE`,id:i}),P(r(`schedPanel.deleted`),`success`),C())}});async function E(){let e=await qw({type:`SCHEDULED_TASK_LIST`}),t={};return(e?.tasks||[]).forEach(e=>{t[e.id]=e}),t}async function D(e){b=e||null,d.textContent=r(e?`schedPanel.editTitle`:`schedPanel.newTask`),document.getElementById(`schedFormName`).value=e?.name||``,document.getElementById(`schedFormDesc`).value=e?.description||``,document.getElementById(`schedFormPrompt`).value=e?.prompt||``,document.getElementById(`schedFormUrl`).value=e?.contextUrl||``,m.value=e?.schedule?.type||`interval`,g.value=e?.schedule?.onceMode||`relative`,x(),h.value=e?.schedule?.value||``,document.getElementById(`schedFormContextMode`).value=e?.contextMode||`fetch`,document.getElementById(`schedFormMaxRuns`).value=e?.maxRuns??``,document.getElementById(`schedFormEndAt`).value=e?.endAt?Zw(e.endAt):``;let t=document.getElementById(`schedFormSession`),n=`<option value="">${r(`schedPanel.sessionAuto`)}</option>`;try{let{list:t}=await je(),r=[...t].sort((e,t)=>{let n=e.order??0,r=t.order??0;return n===r?new Date(t.createdAt||0)-new Date(e.createdAt||0):r-n});for(let t of r){let r=e?.sessionId===t.id?`selected`:``,i=F(t.title||t.id);n+=`<option value="${F(t.id)}" ${r}>${i}</option>`}}catch{}t.innerHTML=n,u.classList.add(`open`)}function O(){u.classList.remove(`open`),b=null}async function k(){let e=document.getElementById(`schedFormName`).value.trim(),t=document.getElementById(`schedFormPrompt`).value.trim(),n=m.value,i=h.value.trim();if(!e){P(r(`schedPanel.nameRequired`),`warning`);return}if(!t){P(r(`schedPanel.promptRequired`),`warning`);return}if(!i){P(r(`schedPanel.scheduleRequired`),`warning`);return}let a=n===`interval`&&parseInt(document.getElementById(`schedFormMaxRuns`).value,10)||null,o=n===`interval`?document.getElementById(`schedFormEndAt`).value:``,s=o?new Date(o).getTime():null,c={name:e,description:document.getElementById(`schedFormDesc`).value.trim(),prompt:t,schedule:n===`once`?{type:n,value:i,onceMode:g.value}:{type:n,value:i},contextUrl:document.getElementById(`schedFormUrl`).value.trim()||null,contextMode:document.getElementById(`schedFormContextMode`).value||`fetch`,sessionId:document.getElementById(`schedFormSession`).value||null,maxRuns:a,endAt:s,enabled:b?b.enabled:!0};try{let e=await qw({type:b?`SCHEDULED_TASK_UPDATE`:`SCHEDULED_TASK_CREATE`,task:b?{...c,id:b.id}:c});e?.success?(P(r(`schedPanel.saved`),`success`),O(),C()):P(e?.error||r(`schedPanel.createFailed`),`error`)}catch(e){P(e?.message||r(`schedPanel.createFailed`),`error`)}}chrome.runtime.onMessage.addListener(e=>{e.type===`SCHEDULED_TASK_RUN_STATE`&&e.taskId&&(e.running?a.add(e.taskId):a.delete(e.taskId),o())}),chrome.runtime.onMessage.addListener(e=>{e.type===`SCHEDULED_SESSION_UPDATED`&&(i.classList.contains(`open`)&&C().catch(()=>{}),e.sessionId&&e.sessionId===N.activeSessionId&&setTimeout(eT,600))}),x(),S(!1),C().catch(()=>{})}var rT=`—`,iT=[{labelKey:`versionInfo.website`,url:`https://xiweicheng.github.io/ai-helper/`,icon:`<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z"/></svg>`},{labelKey:`versionInfo.discussions`,url:`https://github.com/xiweicheng/ai-helper/discussions`,icon:`<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z"/></svg>`},{labelKey:`versionInfo.reportIssue`,url:`https://github.com/xiweicheng/ai-helper/issues/new`,icon:`<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z"/></svg>`},{labelKey:`versionInfo.githubRepo`,url:`https://github.com/xiweicheng/ai-helper`,icon:`<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M12 .5C5.73.5.5 5.73.5 12c0 5.08 3.29 9.39 7.86 10.91.58.11.79-.25.79-.56 0-.28-.01-1.02-.02-2-3.2.7-3.88-1.54-3.88-1.54-.52-1.33-1.28-1.69-1.28-1.69-1.04-.71.08-.7.08-.7 1.15.08 1.76 1.19 1.76 1.19 1.03 1.76 2.7 1.25 3.36.96.1-.75.4-1.25.72-1.54-2.55-.29-5.24-1.28-5.24-5.68 0-1.26.45-2.28 1.19-3.09-.12-.29-.52-1.46.11-3.05 0 0 .97-.31 3.18 1.18a11.1 11.1 0 012.9-.39c.98 0 1.97.13 2.9.39 2.2-1.49 3.17-1.18 3.17-1.18.63 1.59.23 2.76.11 3.05.74.81 1.19 1.83 1.19 3.09 0 4.41-2.69 5.38-5.25 5.67.41.35.78 1.05.78 2.12 0 1.53-.01 2.76-.01 3.14 0 .31.21.68.8.56A11.51 11.51 0 0023.5 12C23.5 5.73 18.27.5 12 .5z"/></svg>`},{labelKey:`versionInfo.giteeRepo`,url:`https://gitee.com/xiweicheng/ai-helper`,icon:`<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M11.984 0A12 12 0 000 12a12 12 0 0012 12 12 12 0 0012-12A12 12 0 0012 0zm6.09 5.333c.328 0 .593.266.592.593v1.482a.594.594 0 01-.593.592H9.777c-.982 0-1.778.796-1.778 1.778v5.63c0 .327.266.592.593.592h5.63c.982 0 1.778-.796 1.778-1.778v-.296a.593.593 0 00-.592-.593h-4.15a.592.592 0 01-.592-.592v-1.482a.593.593 0 01.593-.592h6.815c.327 0 .593.265.593.592v3.408a4 4 0 01-4 4H8.444a3.556 3.556 0 01-3.555-3.556V8.89a3.556 3.556 0 013.555-3.556h9.63z"/></svg>`}];function aT(e){let t=e=>typeof e==`string`?e.trim():``,n=e&&typeof e==`object`?e:{};return{version:t(n.version),tag:t(n.tag),commitId:t(n.commitId),publishedAt:t(n.publishedAt)}}function oT(e){if(!e)return rT;let t=Date.parse(e);return Number.isNaN(t)?rT:new Date(t).toLocaleString()}function sT(e){let t=aT(rt),n=[{label:r(`versionInfo.version`),value:t.version?`v${t.version}`:rT},{label:r(`versionInfo.tag`),value:t.tag||rT},{label:r(`versionInfo.commit`),value:t.commitId?t.commitId.slice(0,8):rT,title:t.commitId,mono:!0},{label:r(`versionInfo.publishedAt`),value:oT(t.publishedAt)}];e.textContent=``;for(let t of n){let n=document.createElement(`div`);n.className=`version-info-row`;let r=document.createElement(`div`);r.className=`version-info-label`,r.textContent=t.label;let i=document.createElement(`div`);i.className=t.mono?`version-info-value mono`:`version-info-value`,i.textContent=t.value,t.title&&(i.title=t.title),n.appendChild(r),n.appendChild(i),e.appendChild(n)}}function cT(e){e.textContent=``;for(let t of iT){let n=document.createElement(`div`);n.className=`version-info-link`,n.title=t.url;let i=document.createElement(`span`);i.className=`version-info-link-icon`,i.innerHTML=t.icon;let a=document.createElement(`span`);a.className=`version-info-link-label`,a.textContent=r(t.labelKey);let o=document.createElement(`span`);o.className=`version-info-link-arrow`,o.textContent=`↗`,n.appendChild(i),n.appendChild(a),n.appendChild(o),n.addEventListener(`click`,()=>{chrome.tabs.create({url:t.url})}),e.appendChild(n)}}function lT(){let e=aT(rt);return[`AI Helper v${e.version||rT}`,`${r(`versionInfo.tag`)}: ${e.tag||rT}`,`${r(`versionInfo.commit`)}: ${e.commitId||rT}`,`${r(`versionInfo.publishedAt`)}: ${oT(e.publishedAt)}`].join(`
|
|
2348
|
+
`)}function uT(){let e=document.getElementById(`versionInfoBtn`),t=document.getElementById(`versionInfoModal`),n=document.getElementById(`versionInfoCloseBtn`),i=document.getElementById(`versionInfoCopyBtn`),a=document.getElementById(`versionInfoList`),o=document.getElementById(`versionInfoLinks`);if(!e||!t||!a)return;let s=()=>{t.style.display=`none`};e.addEventListener(`click`,e=>{e.stopPropagation();let n=document.getElementById(`headerMoreDropdown`);n&&n.classList.remove(`show`),sT(a),o&&cT(o),t.style.display=`flex`}),n&&n.addEventListener(`click`,s),t.addEventListener(`click`,e=>{e.target===t&&s()}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&t.style.display===`flex`&&s()}),i&&i.addEventListener(`click`,async()=>{try{await navigator.clipboard.writeText(lT()),P(r(`common.copySuccess`),`success`)}catch{P(r(`common.copyFailed`),`error`)}})}var dT=null;function fT(){if(!dT)return;dT.classList.remove(`open`);let e=dT.parentElement?dT.parentElement.querySelector(`.section-select-row`):null;e&&e.classList.remove(`open`),dT=null}function pT(){return`<input type="search" class="section-select-search" placeholder="${r(`sectionSelect.searchPlaceholder`)}" data-i18n-placeholder="sectionSelect.searchPlaceholder" spellcheck="false">`}function mT(e,t){if(!e)return;let n=String(t||``).trim().toLowerCase(),i=Array.from(e.children).filter(e=>e.hasAttribute(`data-value`)),a=0;for(let e of i){let t=!n||e.textContent.toLowerCase().includes(n);e.style.display=t?``:`none`,t&&(a+=1)}let o=e.querySelector(`.section-select-empty`);n&&a===0?(o||(o=document.createElement(`div`),o.className=`section-select-empty`,e.appendChild(o)),o.textContent=r(`sectionSelect.noMatch`)):o&&o.remove()}function hT(e,t){fT(),e.classList.add(`open`),t.classList.add(`open`),dT=e;let n=e.querySelector(`.section-select-search`);n&&(n.value=``,mT(e,``),n.focus())}document.addEventListener(`click`,e=>{let t=e.target.closest(`.section-select-row`);if(t){let e=t.parentElement.querySelector(`.section-select-list`);if(!e)return;e===dT?fT():hT(e,t);return}dT&&!dT.parentElement.contains(e.target)&&fT()}),document.addEventListener(`input`,e=>{let t=e.target;if(!t||!t.classList||!t.classList.contains(`section-select-search`))return;let n=t.closest(`.section-select-list`);n&&mT(n,t.value)});var gT=!1;async function _T(){document.getElementById(`providerList`)&&(gT||(gT=!0,bT(),xT()),await vT())}async function vT(){let e=document.getElementById(`providerList`),t=document.getElementById(`providerSelectValue`),n=document.getElementById(`providerSelectHost`);if(!e)return;let r=await C(),i=r.profiles.find(e=>e.id===r.activeProfileId)||r.profiles[0];t&&(t.textContent=i?i.name:``),n&&(n.textContent=i?D(i.apiBase):``),e.innerHTML=pT();let a=[...r.profiles].sort((e,t)=>w(e.name,t.name));for(let t of a){let n=!!i&&t.id===i.id,r=document.createElement(`div`);r.className=`provider-option`+(n?` selected`:``),r.dataset.value=t.id;let a=document.createElement(`span`);a.className=`provider-option-check`,a.textContent=n?`✓`:``,r.appendChild(a);let o=document.createElement(`span`);o.className=`provider-option-left`,o.textContent=t.name,r.appendChild(o);let s=D(t.apiBase);if(s){let e=document.createElement(`span`);e.className=`provider-option-right`,e.textContent=s,r.appendChild(e)}r.addEventListener(`click`,e=>{e.stopPropagation(),fT(),yT(t.id)}),e.appendChild(r)}}async function yT(e){if(e===(await C()).activeProfileId)return;let t=await E(e);t&&(await vT(),a.debug(`[SidePanel] provider switched:`,t.name))}function bT(){let e=document.getElementById(`providerManageBtn`);e&&e.addEventListener(`click`,async e=>{e.stopPropagation();let t=chrome.runtime.getURL(`options.html#basic`),n=await chrome.tabs.query({url:chrome.runtime.getURL(`options.html`)});n.length>0?await chrome.tabs.update(n[0].id,{active:!0,url:t}):await chrome.tabs.create({url:t})})}function xT(){chrome.storage.onChanged.addListener((e,t)=>{t===`local`&&(e.modelProfiles||e.activeProfileId)&&vT()})}var ST=0;function CT(e,t){let n=e&&e.nodeType===1?e:e?e.parentElement:null;for(let e=n;e&&e!==t;e=e.parentElement)if(getComputedStyle(e).position===`absolute`)return!0;return!1}function wT(e){let t=[];return e.querySelectorAll(`*`).forEach(e=>{getComputedStyle(e).position===`absolute`&&e.getClientRects().length>0&&t.push(e)}),t}function TT(e){e.forEach(e=>{(e.getAnimations?.()||[]).forEach(e=>{e.playState!==`idle`&&e.finish?.()})})}function ET(){ST||=requestAnimationFrame(()=>{ST=0,kT()})}function DT(){let e=document.getElementById(`selectionToggleGroup`),t=document.getElementById(`inputAddMenuSwitches`);e&&t&&e.parentElement!==t&&t.appendChild(e)}function OT(){let e=document.getElementById(`selectionToggleGroup`),t=document.querySelector(`.input-bottom-left`);e&&t&&e.parentElement!==t&&t.appendChild(e)}function kT(){let e=document.querySelector(`.input-bottom-row`),t=e?.closest(`.input-container`)||null;if(!(!e||!t)){t.classList.add(`measuring`);try{AT(e,t)}finally{t.classList.remove(`measuring`)}}}function AT(e,t){t.classList.remove(`temp-collapsed`,`agent-collapsed`,`switches-icon`,`selection-in-menu`),OT();let n=wT(e),r=n.map(e=>e.style.display);n.forEach(e=>{e.style.display=`none`});let i=()=>{n.forEach((e,t)=>{e.style.display=r[t]}),TT(n)};if(e.scrollWidth<=e.clientWidth){i();return}if(t.classList.add(`temp-collapsed`),e.scrollWidth<=e.clientWidth){i();return}if(t.classList.add(`agent-collapsed`),e.scrollWidth<=e.clientWidth){i();return}if(t.classList.add(`switches-icon`),e.scrollWidth<=e.clientWidth){i();return}t.classList.add(`selection-in-menu`),DT(),i()}function jT(){kT(),window.addEventListener(`resize`,ET);let e=document.querySelector(`.input-bottom-row`);e&&typeof MutationObserver<`u`&&new MutationObserver(t=>{let n=document.getElementById(`selectionToggleGroup`),r=e=>!!n&&[...e.addedNodes,...e.removedNodes].includes(n);t.some(t=>!CT(t.target,e)&&!r(t))&&ET()}).observe(e,{subtree:!0,childList:!0,characterData:!0})}n(`zh`,{fileSelector:{workspaceTitle:`工作目录`,switchHint:`方向键切换 · Enter添加到文件问答 · Esc取消`,searching:`搜索中...`,noMatch:`没有匹配的文件或目录`,noWorkspace:`暂无工作目录,请先连接 Agent`,loadFailed:`加载失败: {error}`,truncated:`仅显示前 {count} 条,请继续输入以缩小范围`}}),n(`en`,{fileSelector:{workspaceTitle:`Workspace`,switchHint:`↑↓ navigate · Enter attach · Esc cancel`,searching:`Searching...`,noMatch:`No matching file or directory`,noWorkspace:`No workspace directory. Connect an Agent first.`,loadFailed:`Load failed: {error}`,truncated:`Showing top {count} results. Keep typing to narrow down.`}});var MT=50,NT=200,PT=200,FT=0,IT=null,LT=[];function RT(e){return(e||``).replace(/\\/g,`/`).replace(/\/+/g,`/`)}function zT(e){let t=document.getElementById(`fileAtTitlePath`);if(!t)return;let n=e?RT(e):``;t.textContent=n,t.title=n}async function BT(e=``){let t=document.getElementById(`fileAtSelector`),n=document.getElementById(`fileAtDropdown`);if(!t||!n)return;n.dataset.focusGuard||(n.dataset.focusGuard=`1`,n.addEventListener(`mousedown`,e=>{e.target.closest(`.prompt-item`)&&e.preventDefault()}));let r=document.getElementById(`fileAtWorkspaceOpenBtn`);r&&!r.dataset.bound&&(r.dataset.bound=`1`,r.addEventListener(`click`,async e=>{e.stopPropagation(),VT(),await hm()})),pt(),t.style.display=`block`,n.classList.add(`show`),await HT(e)}function VT(){let e=document.getElementById(`fileAtSelector`),t=document.getElementById(`fileAtDropdown`);e&&(e.style.display=`none`),t&&t.classList.remove(`show`),N.selectedFileAtIndex=-1,IT&&=(clearTimeout(IT),null),FT++}function HT(e=``){let t=document.getElementById(`fileAtList`);if(!t)return;let n=++FT,i=e.trim();IT&&clearTimeout(IT);let o=async()=>{try{let e=await sn();if(n!==FT)return;if(zT(e),!e){t.innerHTML=`<div class="prompt-empty">${r(`fileSelector.noWorkspace`)}</div>`,N.selectedFileAtIndex=-1;return}let a;if(a=i?await bn(e,i,NT):((await en(e)).entries||[]).map(t=>({name:t.name,type:t.type||`file`,size:t.size,mtime:t.mtime,fullPath:RT(`${e}/${t.name}`)})),n!==FT)return;WT(a,i,t,e)}catch(e){if(n!==FT)return;a.warn(`[FileAtSelector] search failed:`,e.message),t.innerHTML=`<div class="prompt-empty">${r(`fileSelector.loadFailed`,{error:e.message})}</div>`,N.selectedFileAtIndex=-1}};i?(t.innerHTML=`<div class="prompt-empty">${r(`fileSelector.searching`)}</div>`,IT=setTimeout(o,PT)):IT=setTimeout(o,0)}function UT(e,t){let n=t.toLowerCase();return[...e].sort((e,t)=>{let r=(e.name||``).toLowerCase(),i=(t.name||``).toLowerCase();if(n){let e=+!!r.startsWith(n),t=+!!i.startsWith(n);if(e!==t)return t-e}let a=e.mtime||0,o=t.mtime||0;if(a!==o)return o-a;let s=e.type===`directory`?0:1,c=t.type===`directory`?0:1;return s===c?r.localeCompare(i):s-c})}function WT(e,t,n,i){let a=UT(e,t),o=a.slice(0,MT),s=a.length>MT,c=RT(i);if(o.length===0){n.innerHTML=`<div class="prompt-empty">${r(`fileSelector.noMatch`)}</div>`,N.selectedFileAtIndex=-1;return}if(N.selectedFileAtIndex=0,LT=o,n.innerHTML=o.map((e,t)=>{let n=an(e.name,e.type),r=RT(e.fullPath),i=r.startsWith(c)?r.substring(c.length).replace(/^\//,``):r;return`
|
|
2342
2349
|
<div class="prompt-item ${t===0?`selected`:``}" data-index="${t}" data-path="${F(r)}" title="${F(r)}">
|
|
2343
2350
|
<span class="prompt-item-index">${t+1}</span>
|
|
2344
2351
|
<span class="prompt-item-icon">${n}</span>
|
|
2345
2352
|
<span class="prompt-item-content">${F(e.name)}</span>
|
|
2346
2353
|
<span class="file-at-path">${F(i)}</span>
|
|
2347
2354
|
</div>
|
|
2348
|
-
`}).join(``),s){let e=document.createElement(`div`);e.className=`file-at-truncated`,e.textContent=r(`fileSelector.truncated`,{count:
|
|
2349
|
-
<span class="input-add-panel-item-title"><span class="input-add-panel-item-inline-icon">${
|
|
2355
|
+
`}).join(``),s){let e=document.createElement(`div`);e.className=`file-at-truncated`,e.textContent=r(`fileSelector.truncated`,{count:MT}),n.appendChild(e)}n.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,()=>{GT(LT.find(t=>t.fullPath===e.dataset.path)||e.dataset.path)})})}function GT(e){if(!(typeof e==`string`?e:e&&e.fullPath))return;let t=document.getElementById(`userInput`),n=t?t.value:``,r=n.lastIndexOf(`$`);r!==-1&&(t.value=n.substring(0,r)),t&&(t.focus(),t.selectionStart=t.selectionEnd=t.value.length),VT(),N_([e]),Dt()}function KT(e){let t=N.selectedFileAtIndex;e.forEach((e,n)=>{n===t?(e.classList.add(`selected`),e.scrollIntoView({block:`nearest`})):e.classList.remove(`selected`)})}n(`zh`,{input:{addMenuPanelSearchPlaceholder:`搜索…`,addMenuPanelClear:`清除`,addMenuPanelLoading:`加载中…`,addMenuPanelEmpty:`暂无可用内容`,addMenuPanelNoMatch:`没有匹配项`}}),n(`en`,{input:{addMenuPanelSearchPlaceholder:`Search…`,addMenuPanelClear:`Clear`,addMenuPanelLoading:`Loading…`,addMenuPanelEmpty:`No items available`,addMenuPanelNoMatch:`No matches`}});var qT=null,JT=null,YT=null,XT=null,ZT=null,QT=null,$T=null,eE=[],tE=0,nE=()=>{},rE=[{action:`full`,icon:`📷`,nameKey:`input.addMenuScreenshotFull`,descKey:`input.addMenuScreenshotFullDesc`,kbd:`Alt+S`},{action:`region`,icon:`✂️`,nameKey:`input.addMenuScreenshotRegion`,descKey:`input.addMenuScreenshotRegionDesc`,kbd:`Alt+Shift+S`}],iE=new Set([`screenshot`]),aE={prompts:{titleKey:`promptManager.title`,action:()=>wS()},skills:{titleKey:`promptSelector.skillManageTitle`,action:()=>oE(`toolbox`)},mcp:{titleKey:`promptSelector.mcpManageTitle`,action:()=>oE(`toolbox`)},pages:{titleKey:`pageSelector.openNewTab`,action:()=>chrome.tabs.create({})},knowledge:{titleKey:`header.manageKnowledge`,action:()=>oE(`knowledge`)},agents:{titleKey:`header.addEditAssistant`,action:()=>MC(null)},proxies:{titleKey:`header.addEditAgent`,action:()=>oE(`agent`)},workspace:{titleKey:`workspace.openPanel`,action:()=>hm()}};function oE(e){chrome.runtime.sendMessage({type:`OPEN_OPTIONS_PAGE`,hash:e})}function sE(){if(!ZT)return;let e=$T?aE[$T]:null;if(!e){ZT.style.display=`none`;return}let t=r(e.titleKey);ZT.title=t,ZT.setAttribute(`aria-label`,t),ZT.style.display=`flex`}function cE(){XT&&(XT.style.display=iE.has($T)?`none`:``)}function lE(e={}){if(nE=typeof e.onRequestClose==`function`?e.onRequestClose:()=>{},qT=document.getElementById(`inputAddPanel`),JT=document.getElementById(`inputAddPanelSearch`),YT=document.getElementById(`inputAddPanelSearchClear`),ZT=document.getElementById(`inputAddPanelManage`),XT=document.getElementById(`inputAddPanelSearchWrap`),QT=document.getElementById(`inputAddPanelList`),!(!qT||!JT||!QT)){if(ZT&&ZT.addEventListener(`click`,()=>{let e=$T?aE[$T]:null;e&&(nE(),e.action())}),YT){let e=r(`input.addMenuPanelClear`);YT.title=e,YT.setAttribute(`aria-label`,e),YT.addEventListener(`click`,()=>{JT.value=``,yE(),uE(),JT.focus()})}JT.addEventListener(`input`,()=>{yE(),uE()})}}function uE(){YT&&JT&&(YT.style.display=JT.value?`flex`:`none`)}function dE(){return!!$T}function fE(){return $T}function pE(){return!!JT&&document.activeElement===JT}async function mE(e){if(!qT||!e||$T===e&&qT.style.display!==`none`)return;$T=e,sE(),cE(),JT&&(JT.value=``,JT.placeholder=r(`input.addMenuPanelSearchPlaceholder`),uE()),qT.style.display=`flex`;let t=++tE;QT&&(QT.innerHTML=`<div class="prompt-empty">${r(`input.addMenuPanelLoading`)}</div>`);try{let n=await gE(e);if(t!==tE)return;eE=Array.isArray(n)?n:[],yE()}catch(e){if(t!==tE)return;a.warn(`[InputAddPanel] load failed:`,e&&e.message),eE=[],QT&&(QT.innerHTML=`<div class="prompt-empty">${r(`input.addMenuPanelEmpty`)}</div>`)}}function hE(){$T=null,sE(),cE(),eE=[],tE++,JT&&(JT.value=``,uE()),QT&&(QT.innerHTML=``),qT&&(qT.style.display=`none`)}function gE(e){switch(e){case`prompts`:return Promise.resolve(N.customPrompts||[]);case`skills`:return VS(!0);case`mcp`:return tC();case`pages`:return my();case`knowledge`:return cy().then(e=>e.ok?e.collections:[]);case`agents`:return lt();case`proxies`:return kv();case`workspace`:return _E();case`screenshot`:return Promise.resolve(rE);default:return Promise.resolve([])}}async function _E(){let e=await sn();if(!e)return[];let t=await en(e),n=t&&t.entries||[],r=String(e).replace(/\\/g,`/`).replace(/\/+/g,`/`);return n.map(e=>({name:e.name,type:e.type||`file`,size:e.size,mtime:e.mtime,fullPath:`${r}/${e.name}`.replace(/\/+/g,`/`)})).sort((e,t)=>{let n=e.mtime||0,r=t.mtime||0;if(n!==r)return r-n;let i=e.type===`directory`?0:1,a=t.type===`directory`?0:1;return i===a?String(e.name).localeCompare(String(t.name)):i-a})}function vE(e){if(!e)return eE;let t=e.toLowerCase();return eE.filter(e=>{switch($T){case`prompts`:return String(e.code||``).toLowerCase().includes(t)||String(e.content||``).toLowerCase().includes(t);case`skills`:return String(e.name||``).toLowerCase().includes(t)||String(e.description||``).toLowerCase().includes(t);case`mcp`:return String(e.serverName||``).toLowerCase().includes(t)||String(e.serverId||``).toLowerCase().includes(t);case`pages`:return String(e.title||``).toLowerCase().includes(t)||String(e.url||``).toLowerCase().includes(t);case`knowledge`:return String(e.name||``).toLowerCase().includes(t)||String(e.description||``).toLowerCase().includes(t);case`agents`:return String(Rv(e)||``).toLowerCase().includes(t)||String(zv(e)||``).toLowerCase().includes(t);case`proxies`:return String(e.name||``).toLowerCase().includes(t)||String(e.url||``).toLowerCase().includes(t);case`workspace`:return String(e.name||``).toLowerCase().includes(t);case`screenshot`:return r(e.nameKey).toLowerCase().includes(t)||r(e.descKey).toLowerCase().includes(t);default:return!0}})}function yE(){if(!QT)return;let e=JT?JT.value.trim():``,t=vE(e);if(t.length===0){QT.innerHTML=`<div class="prompt-empty">${r(e?`input.addMenuPanelNoMatch`:`input.addMenuPanelEmpty`)}</div>`;return}QT.innerHTML=t.map(e=>bE(e)).join(``),QT.querySelectorAll(`.input-add-panel-item`).forEach(e=>{e.addEventListener(`click`,t=>xE(t,e))}),QT.querySelectorAll(`img.favicon-img`).forEach(e=>{e.addEventListener(`error`,()=>{e.style.display=`none`})}),$T===`proxies`&&t.forEach(e=>Kv(e)),$T===`skills`&&JS(),$T===`mcp`&&cC(),$T===`knowledge`&&ey()}function bE(e){switch($T){case`prompts`:return`<div class="prompt-item input-add-panel-item input-add-panel-item-two-line" data-code="${F(e.code)}" title="${L(e.content||``)}">
|
|
2356
|
+
<span class="input-add-panel-item-title"><span class="input-add-panel-item-inline-icon">${dS}</span>/${F(e.code)}</span>
|
|
2350
2357
|
<span class="input-add-panel-item-sub">${F(e.content||``)}</span>
|
|
2351
2358
|
</div>`;case`skills`:{let t=e.enabled===!1,n=t?`${e.name}\n${r(`skillSelector.disabledTooltip`)}`:e.name,i=e.description||``;return`<div class="skill-list-item input-add-panel-item input-add-panel-item-two-line${t?` skill-list-item-disabled`:``}" data-skill-name="${F(e.name)}" title="${L(n)}">
|
|
2352
2359
|
<span class="input-add-panel-item-title">🧩 ${F(e.name)}</span>
|
|
@@ -2361,12 +2368,12 @@ Sessions using this assistant will revert to the default assistant.`,deleteAgent
|
|
|
2361
2368
|
</div>`}case`knowledge`:{let t=e.enabled===!1,n=r(`knowledgeSelector.docChunk`,{docs:e.documentCount||0,chunks:e.chunkCount||0});return`<div class="prompt-item input-add-panel-item input-add-panel-item-two-line prompt-item-knowledge${t?` knowledge-item-disabled`:``}" data-kb-id="${F(e.id)}" data-kb-name="${F(e.name||``)}" data-kb-disabled="${t?`1`:`0`}"${t?` title="${L(r(`knowledgeSelector.disabledTooltip`))}"`:``}>
|
|
2362
2369
|
<span class="input-add-panel-item-title">📚 ${F(e.name||``)}${t?` <span class="knowledge-item-badge badge-disabled">${r(`knowledgeSelector.disabledBadge`)}</span>`:``}</span>
|
|
2363
2370
|
<span class="input-add-panel-item-sub">${F(n)}</span>
|
|
2364
|
-
</div>`}case`agents`:{let t=
|
|
2371
|
+
</div>`}case`agents`:{let t=Rv(e),n=zv(e),i=e.id===N.activeAgentId||!N.activeAgentId&&e.id==="default",a=e.toolIds?e.toolIds.length:e.toolIds===null?null:0,o=a===null?r(`promptSelector.inheritGlobal`):r(`promptSelector.toolCount`,{count:a});return`<div class="prompt-item input-add-panel-item input-add-panel-item-two-line" data-agent-id="${F(e.id)}">
|
|
2365
2372
|
<span class="input-add-panel-item-title">${F([e.icon,t].filter(Boolean).join(` `))}</span>
|
|
2366
2373
|
<span class="input-add-panel-item-sub">${F(n||o)}</span>
|
|
2367
2374
|
${i?`<span class="input-add-panel-item-mark">✓</span>`:``}
|
|
2368
|
-
</div>`}case`proxies`:{let t=e.name||r(`promptSelector.unnamedProxy`),n=
|
|
2369
|
-
<span class="input-add-panel-item-title"><span class="agent-at-dot agent-at-dot-${
|
|
2375
|
+
</div>`}case`proxies`:{let t=e.name||r(`promptSelector.unnamedProxy`),n=Wv(e),i=n?n.online:!1;return`<div class="prompt-item prompt-item-proxy input-add-panel-item input-add-panel-item-two-line${e.isDisabled?` agent-disabled`:``}" data-proxy-id="${F(e.id)}">
|
|
2376
|
+
<span class="input-add-panel-item-title"><span class="agent-at-dot agent-at-dot-${Gv(e,i)}"></span>${F(t)}</span>
|
|
2370
2377
|
<span class="input-add-panel-item-sub">${F(e.url||``)}</span>
|
|
2371
2378
|
${e.isActive?`<span class="input-add-panel-item-mark">✓</span>`:``}
|
|
2372
2379
|
</div>`}case`workspace`:{let t=e.type===`directory`;return`<div class="prompt-item input-add-panel-item" data-path="${F(e.fullPath)}" title="${L(e.fullPath)}">
|
|
@@ -2377,9 +2384,9 @@ Sessions using this assistant will revert to the default assistant.`,deleteAgent
|
|
|
2377
2384
|
<span class="input-add-panel-item-title">${e.icon} ${F(r(e.nameKey))}</span>
|
|
2378
2385
|
<span class="input-add-panel-item-sub">${F(r(e.descKey))}</span>
|
|
2379
2386
|
<kbd class="input-add-panel-item-kbd">${F(e.kbd)}</kbd>
|
|
2380
|
-
</div>`;default:return``}}async function
|
|
2387
|
+
</div>`;default:return``}}async function xE(e,t){let n=e.ctrlKey||e.metaKey;switch($T){case`prompts`:{let e=t.dataset.code;n?SS(e,{skipTriggerStrip:!0}):CS(e),nE();break}case`skills`:GS(t.dataset.skillName,eE,{clearTrigger:!1}),n&&nE();break;case`mcp`:iC(t.dataset.serverId,t.dataset.serverName,eE,{clearTrigger:!1}),n&&nE();break;case`pages`:{let e=eE.find(e=>String(e.id)===t.dataset.tabId);if(e){_y(e);let t=document.getElementById(`userInput`);t&&t.focus(),Dt()}nE();break}case`knowledge`:ty({id:t.dataset.kbId,name:t.dataset.kbName,enabled:t.dataset.kbDisabled!==`1`},{clearTrigger:!1}),n&&nE();break;case`agents`:await Qv(t.dataset.agentId,{clearTrigger:!1}),nE();break;case`proxies`:await uy(t.dataset.proxyId,{clearTrigger:!1}),nE();break;case`workspace`:{let e=eE.find(e=>e.fullPath===t.dataset.path);if(e){let t=document.getElementById(`userInput`);t&&t.focus(),await N_([e]),Dt()}nE();break}case`screenshot`:nE(),await(t.dataset.shotAction===`region`?Sp:xp)();break;default:break}}var SE=0,CE=200,wE=150,TE={promptTriggerBtn:`prompts`,addMenuSkillBtn:`skills`,addMenuMcpBtn:`mcp`,addMenuPageBtn:`pages`,addMenuKnowledgeBtn:`knowledge`,addMenuAgentBtn:`agents`,addMenuProxyBtn:`proxies`,addMenuWorkspaceBtn:`workspace`,screenshotBtn:`screenshot`};async function EE(){let e=[{id:`addMenuSkillBtn`,available:()=>zS()},{id:`addMenuMcpBtn`,available:()=>eC()},{id:`addMenuKnowledgeBtn`,available:async()=>(await cy()).ok},{id:`addMenuProxyBtn`,available:async()=>(await kv()).length>0},{id:`addMenuWorkspaceBtn`,available:async()=>!!await sn()}],t=++SE;await Promise.all(e.map(async({id:e,available:n})=>{let r=document.getElementById(e);if(!r)return;let i=!0;try{i=await n()}catch{i=!0}t===SE&&(r.style.display=i?``:`none`)}))}function DE(){let e=document.getElementById(`inputAddBtn`),t=document.getElementById(`inputAddMenu`);if(!e||!t)return;let n=e.closest(`.input-add-wrapper`),r=t.querySelector(`.input-add-nav`),i=null,a=null,o=!1,s=()=>{let e=dE()?fE():null;t.querySelectorAll(`.input-add-item`).forEach(t=>{t.classList.toggle(`panel-active`,!!e&&TE[t.id]===e)})},c=e=>{let n=document.getElementById(`inputAddPanel`);if(!n||n.style.display===`none`)return;n.style.left=``;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=r.right+8;a+i.width>window.innerWidth-8&&(a=window.innerWidth-8-i.width),a<8&&(a=8),n.style.left=`${Math.round(a-r.left)}px`;let o=e||t.querySelector(`.input-add-item.panel-active`),s=(o?o.getBoundingClientRect():r).top;s+i.height>r.bottom&&(s=r.bottom-i.height),s<8&&(s=8),n.style.top=`${Math.round(s-r.top-t.clientTop)}px`},l=n=>{t.style.display=n?``:`none`,e.classList.toggle(`open`,n),e.setAttribute(`aria-expanded`,String(n)),n?(hE(),s(),EE()):(i&&=(clearTimeout(i),null),a&&=(clearTimeout(a),null),hE(),s())},u=()=>t.style.display!==`none`;lE({onRequestClose:()=>l(!1)}),e.addEventListener(`click`,e=>{e.stopPropagation();let t=!u();t&&(gS(),Nv(),VT()),l(t)}),t.addEventListener(`click`,e=>{e.target.closest&&e.target.closest(`.input-add-item`)&&l(!1)},!0),document.addEventListener(`click`,e=>{u()&&(n&&n.contains(e.target)||l(!1))});let d=()=>{i&&=(clearTimeout(i),null),a&&clearTimeout(a),a=setTimeout(()=>{a=null,!pE()&&(hE(),s())},wE)};r&&r.addEventListener(`mouseover`,e=>{if(!u())return;let t=e.target.closest(`.input-add-item`),n=t?TE[t.id]:null;if(!n){d();return}a&&=(clearTimeout(a),null),!(dE()&&fE()===n)&&(i&&clearTimeout(i),i=setTimeout(async()=>{i=null;let e=mE(n);c(t);try{await e}catch{}c(t),s()},CE))}),t.addEventListener(`mouseenter`,()=>{o=!0,a&&=(clearTimeout(a),null)}),t.addEventListener(`mouseleave`,()=>{o=!1,d()});let f=document.getElementById(`inputAddPanelSearch`);f&&f.addEventListener(`blur`,()=>{o||d()}),window.addEventListener(`resize`,()=>{dE()&&c()}),[{id:`promptTriggerBtn`,open:()=>hS(``,`prompts`)},{id:`addMenuSkillBtn`,open:()=>hS(``,`skills`)},{id:`addMenuMcpBtn`,open:()=>hS(``,`mcp`)},{id:`addMenuPageBtn`,open:()=>jv(``,`pages`)},{id:`addMenuKnowledgeBtn`,open:()=>jv(``,`knowledge`)},{id:`addMenuAgentBtn`,open:()=>jv(``,`agents`)},{id:`addMenuProxyBtn`,open:()=>jv(``,`proxies`)},{id:`addMenuWorkspaceBtn`,open:()=>BT(``)}].forEach(({id:e,open:t})=>{let n=document.getElementById(e);n&&n.addEventListener(`click`,async e=>{e.stopPropagation(),n.blur(),gS(),Nv(),VT();try{await t()}catch{}let r=document.getElementById(`userInput`);r&&r.focus()})});let p=document.getElementById(`inputAddMenuSwitches`),m=()=>{let t=p?.querySelector(`input[type="checkbox"]`);e.classList.toggle(`has-active-switch`,!!(t&&t.checked))};p&&(typeof MutationObserver<`u`&&new MutationObserver(m).observe(p,{subtree:!0,childList:!0}),p.addEventListener(`change`,m)),m()}function OE({key:e,value:t=``,caret:n,history:r=[],index:i=-1}={}){if(e!==`ArrowUp`&&e!==`ArrowDown`||!Array.isArray(r)||r.length===0)return{handled:!1};let a=String(t??``),o=Number.isInteger(n)&&n>=0?n:a.length,s=Number.isInteger(i)&&i>=0;if(e===`ArrowUp`){let e=a.lastIndexOf(`
|
|
2381
2388
|
`,o-1)===-1;if(!s&&!e)return{handled:!1};let t=s?Math.min(i,r.length-1):r.length,n=Math.max(0,t-1);return{handled:!0,index:n,value:r[n]}}if(!s||a.indexOf(`
|
|
2382
|
-
`,o)!==-1)return{handled:!1};let c=Math.min(i,r.length-1);if(c<r.length-1){let e=c+1;return{handled:!0,index:e,value:r[e]}}return{handled:!0,index:-1,value:``}}function
|
|
2389
|
+
`,o)!==-1)return{handled:!1};let c=Math.min(i,r.length-1);if(c<r.length-1){let e=c+1;return{handled:!0,index:e,value:r[e]}}return{handled:!0,index:-1,value:``}}function kE(e,t){let n;return function(...r){clearTimeout(n),n=setTimeout(()=>{clearTimeout(n),e(...r)},t)}}var AE=null,jE=null,ME=null,NE=null,PE=null,FE=null,IE=null,LE=null,RE=null,zE=null,BE=!1,VE=!1,HE=null,UE={[R.DISPATCHING]:`queue.statusDispatching`,[R.INJECTING]:`queue.statusInjecting`,[R.INJECTED]:`queue.statusInjected`,[R.DONE]:`queue.statusDone`,[R.FAILED]:`queue.statusFailed`};function WE(e){if(e.status===R.QUEUED)return e.interrupted?r(`queue.statusRecovered`):``;let t=UE[e.status];return t?r(t):``}function GE(){return N.activeSessionId}function KE(e){let t=e.attachmentSummary||e.contextSnapshot&&e.contextSnapshot.attachmentSummary||null,n=[];t&&(t.imageCount&&n.push(r(`queue.withImages`,{count:t.imageCount})),t.fileCount&&n.push(r(`queue.withFiles`,{count:t.fileCount})));let i=n.length?n.join(` · `):au(e.contextSnapshot)?r(`queue.withContext`):``;return i?`<span class="queue-chip-ctx" title="${F(t&&(t.fileNames||[]).length?t.fileNames.join(`、`):i)}">${F(i)}</span>`:``}function qE(e,t){let n=KE(e),i=e.status===R.DISPATCHING,a=WE(e),o=(a?`<span class="queue-chip-status${i?` running`:``}${e.interrupted?` warning`:``}"${i?` title="${F(r(`queue.statusRunningHint`))}"`:``}>${F(a)}</span>`:``)+n,s=N.isGenerating===!0;return`
|
|
2383
2390
|
<div class="queue-chip" draggable="true" data-id="${F(e.id)}" data-status="${F(e.status)}">
|
|
2384
2391
|
<span class="queue-chip-index">${t+1}</span>
|
|
2385
2392
|
<div class="queue-chip-main">
|
|
@@ -2391,13 +2398,13 @@ Sessions using this assistant will revert to the default assistant.`,deleteAgent
|
|
|
2391
2398
|
<button class="queue-chip-btn" type="button" data-act="edit" title="${F(r(`queue.editBack`))}">✎</button>
|
|
2392
2399
|
<button class="queue-chip-btn danger" type="button" data-act="remove" title="${F(r(`queue.delete`))}">✕</button>
|
|
2393
2400
|
</div>
|
|
2394
|
-
</div>`}function
|
|
2401
|
+
</div>`}function JE(e){return e.length?e.map(e=>`
|
|
2395
2402
|
<div class="queue-recent-item" data-id="${F(e.id)}">
|
|
2396
|
-
<span class="queue-recent-status">${F(
|
|
2403
|
+
<span class="queue-recent-status">${F(WE(e))}</span>
|
|
2397
2404
|
<span class="queue-recent-text" title="${F(e.text)}">${F(e.text)}</span>
|
|
2398
2405
|
<button class="queue-chip-btn" type="button" data-act="requeue" title="${F(r(`queue.requeue`))}">↺</button>
|
|
2399
2406
|
<button class="queue-chip-btn danger" type="button" data-act="forget" title="${F(r(`queue.forgetRecent`))}">✕</button>
|
|
2400
|
-
</div>`).join(``):`<div class="queue-recent-empty">${F(r(`queue.recentEmpty`))}</div>`}function KE(e={}){if(!DE||zE)return;let t=HE();if(!t){DE.style.display=`none`;return}let n=Dr(t),i=n.items,a=i.length>0,o=n.recent.filter(e=>e.status===R.FAILED).length,s=o>0;if(!a&&!s&&(!RE||n.recent.length===0)){DE.style.display=`none`;return}if(DE.style.display=``,DE.classList.toggle(`empty`,!a),DE.classList.toggle(`expanded`,LE&&a),DE.classList.toggle(`paused`,n.paused),kE&&(a?(kE.textContent=r(`queue.summary`,{count:i.length}),kE.classList.remove(`failed`),kE.removeAttribute(`title`)):s?(kE.textContent=r(`queue.summaryFailed`,{count:o}),kE.classList.add(`failed`),kE.title=r(`queue.summaryFailedHint`)):(kE.textContent=r(`queue.summaryEmpty`),kE.classList.remove(`failed`),kE.removeAttribute(`title`))),AE&&(AE.style.display=n.paused?``:`none`,AE.title=n.pausedReason===`user_stopped`?r(`queue.pausedByStop`):r(`queue.pausedHint`)),jE){let e=n.paused&&i.length>0;jE.style.display=e?``:`none`,jE.textContent=r(`queue.resumeQueue`)}if(ME){let e=N.isGenerating===!0&&a&&!n.paused;ME.style.display=e?``:`none`}NE&&(NE.classList.toggle(`active`,RE),NE.title=r(`queue.recentTitle`)),FE&&(FE.style.display=a?``:`none`,FE.setAttribute(`aria-expanded`,LE?`true`:`false`),FE.textContent=LE?`▲`:`▼`),OE&&(OE.style.display=LE&&a?``:`none`,OE.innerHTML=a?i.map((e,t)=>WE(e,t)).join(``):``),PE&&(PE.style.display=RE?``:`none`,PE.innerHTML=RE?GE(n.recent):``),e.flash&&(DE.classList.remove(`queue-flash`),DE.offsetWidth,DE.classList.add(`queue-flash`))}async function qE(e,t={}){let n=HE();if(!n||!e)return!1;let i=jr(n,e);if(!i)return!1;let a=document.getElementById(`userInput`);if(a&&a.value.trim()){let e=await hu({autoDrain:!1});if(!e.ok)return P(e.error===`queue_full`?r(`queue.queueFull`,{limit:e.limit}):r(`queue.enqueueFailed`),`warning`),!1}else if(ou())return P(r(`queue.inputHasUnsavedContext`),`warning`,4e3),!1;let o=await pu(i);return a&&(a.value=i.text,a.style.height=`auto`,a.dispatchEvent(new Event(`input`)),a.focus()),await Fr(n,e),await mu(e),o.wantsAttachments?P(o.attachments?r(`queue.editBackWithAttachments`):r(`queue.attachmentsMissing`),o.attachments?`success`:`warning`,2500):t.viaShortcut&&P(r(`queue.editTailHint`),`info`,2e3),!0}function JE(){let e=HE();if(!e)return!1;let t=Ar(e);return t?(qE(t.id,{viaShortcut:!0}),!0):!1}async function YE(e,t){let n=HE();if(!(!n||!t)&&!(Tr(n).findIndex(e=>e.id===t)<0))switch(e){case`edit`:await qE(t);break;case`inject`:await Nu(t,n);break;case`remove`:await Fr(n,t),await mu(t),P(r(`queue.deleted`),`info`,1500);break;default:break}}async function XE(e){let t=HE();t&&await Ir(t,e)}async function ZE(e,t){if(e.preventDefault(),!zE)return;let n=t?.dataset?.id;if(!n||n===zE)return;let r=HE();if(!r)return;let i=Tr(r).map(e=>e.id),a=i.indexOf(zE);if(a<0)return;i.splice(a,1);let o=t.getBoundingClientRect(),s=e.clientY-o.top>o.height/2,c=i.indexOf(n);c<0?c=i.length:s&&(c+=1),i.splice(c,0,zE),await XE(i)}function QE(){OE&&(OE.addEventListener(`dragstart`,e=>{let t=e.target.closest?.(`.queue-chip`);if(t){zE=t.dataset.id,t.classList.add(`dragging`);try{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,zE)}catch{}}}),OE.addEventListener(`dragend`,e=>{let t=e.target.closest?.(`.queue-chip`);t&&t.classList.remove(`dragging`),zE=null,OE.querySelectorAll(`.drag-over-top, .drag-over-bottom`).forEach(e=>{e.classList.remove(`drag-over-top`,`drag-over-bottom`)}),KE()}),OE.addEventListener(`dragover`,e=>{let t=e.target.closest?.(`.queue-chip`);if(!t||!zE||t.dataset.id===zE)return;e.preventDefault();let n=t.getBoundingClientRect(),r=e.clientY-n.top>n.height/2;t.classList.toggle(`drag-over-bottom`,r),t.classList.toggle(`drag-over-top`,!r)}),OE.addEventListener(`dragleave`,e=>{let t=e.target.closest?.(`.queue-chip`);t&&t.classList.remove(`drag-over-top`,`drag-over-bottom`)}),OE.addEventListener(`drop`,e=>{let t=e.target.closest?.(`.queue-chip`);ZE(e,t)}))}function $E(){OE?.addEventListener(`click`,e=>{let t=e.target.closest?.(`.queue-chip-btn`);if(!t||t.disabled)return;let n=t.closest(`.queue-chip`);n&&YE(t.dataset.act,n.dataset.id)}),PE?.addEventListener(`click`,async e=>{let t=e.target.closest?.(`.queue-chip-btn`),n=t?.closest(`.queue-recent-item`),i=HE();if(!t||!n||!i)return;if(t.dataset.act===`forget`){await Hr(i,n.dataset.id)&&P(r(`queue.forgotRecent`),`success`,1500);return}if(t.dataset.act!==`requeue`)return;let a=Er(i).find(e=>e.id===n.dataset.id),o=!!(a&&a.attachmentSummary),s=await Vr(i,n.dataset.id);if(!s.ok){P(s.error===`queue_full`?r(`queue.queueFull`,{limit:s.limit}):r(`queue.enqueueFailed`),`warning`);return}P(r(o?`queue.requeuedNoAttachments`:`queue.requeued`),o?`warning`:`success`,2500)}),FE?.addEventListener(`click`,()=>{LE=!LE,KE()}),IE?.addEventListener(`click`,e=>{e.target.closest?.(`button`)||Tr(HE()||``).length&&(LE=!LE,KE())}),NE?.addEventListener(`click`,()=>{RE=!RE,RE&&(LE=!0),KE()}),jE?.addEventListener(`click`,async()=>{await Xu(),P(r(`queue.resumed`),`success`,1500)}),ME?.addEventListener(`click`,()=>{document.dispatchEvent(new CustomEvent(`queue-stop-and-send`))}),QE(),wr(()=>KE()),document.addEventListener(`queue-enqueued`,()=>{LE=!0,KE({flash:!0})}),document.addEventListener(`session-switched`,()=>{KE()}),document.addEventListener(`generation-ended`,()=>KE()),document.addEventListener(`generating-state-changed`,()=>KE())}async function eD(){await Sr(),KE()}async function tD(){if(await Sr(),DE=document.getElementById(`queueStrip`),!DE){a.warn(`[QueuePanel] #queueStrip not found, queue UI disabled`);return}OE=document.getElementById(`queueList`),kE=document.getElementById(`queueSummary`),AE=document.getElementById(`queuePausedTag`),jE=document.getElementById(`queueResumeBtn`),ME=document.getElementById(`queueStopSendBtn`),NE=document.getElementById(`queueRecentBtn`),PE=document.getElementById(`queueRecent`),FE=document.getElementById(`queueToggleBtn`),IE=DE.querySelector(`.queue-strip-head`),$E(),KE()}var nD=new Set,rD=new Set,iD=new Map,aD=30*1e3;function oD(e){let t=iD.get(e);return t?Date.now()-t<aD?!0:(iD.delete(e),!1):!1}async function sD(e){let t=le(e)||e;if(!t||nD.has(t)||rD.has(t)||oD(t))return null;rD.add(t);try{let e=await Ce();if(!e)return null;let n=null;try{let r=await he(`${e.url}/api/status/detail`,{headers:{Authorization:`Bearer ${e.token}`,"X-AIH-Session-Id":t}});if(!r.ok)return iD.set(t,Date.now()),null;n=await r.json()}catch(e){return a.debug(`[WorkdirReconcile] fetch detail failed:`,e?.message||e),iD.set(t,Date.now()),null}if(!n?.success||!n.sessionWorkdirSupported)return iD.set(t,Date.now()),null;let r=n.sessionWorkdir||null,i=n.defaultWorkdir||n.workdir||null;if(!r||r===i)return iD.set(t,Date.now()),null;let o=await Ie(t);return o.scope===`session`?(iD.set(t,Date.now()),null):o.boundWorkdir?await Oe(t)?(nD.add(t),a.debug(`[WorkdirReconcile] cleared stale agent binding:`,t,r),{cleaned:!0,workdir:r}):null:await Ee(t,r,o.agentId||e.id||null)?(nD.add(t),a.debug(`[WorkdirReconcile] restored session workdir:`,t,r),{adopted:!0,workdir:r}):null}finally{rD.delete(t)}}n(`zh`,{tokenStats:{clearConfirmMessage:`确定要清空所有 Token 使用统计吗?此操作不可撤销。`,loadFailed:`加载失败`,currentSessionNoData:`当前会话暂无数据`,totalTokenUsage:`总 Token 消耗`,apiCallCount:`API 调用次数`,contextUsageRate:`上下文使用率`,max:`最大`,avg:`平均`,min:`最小`,totalTokens:`总 Token`,totalSessions:`总会话数`,totalApiCalls:`总 API 调用`,callTypeNonStream:`普通`,callTypeStream:`流式`,callTypeReflection:`反思`,callTypeToolReflection:`工具反思`,callTypeSubtaskReflection:`子任务反思`,tabTrend:`趋势`,tabDistribution:`分布`,tabGlobal:`全局`,topCardSessionTokens:`本次 Token`,topCardSessionCalls:`本次调用`,topCardContextPeak:`上下文峰值`,sparklineTitle:`最近 20 次调用趋势`,distPromptVsCompletion:`Prompt / Completion 占比`,distPrompt:`Prompt`,distCompletion:`Completion`,distByModel:`按模型分布`,distByCallType:`按调用类型分布`,distNoData:`暂无分布数据`,globalSparklineTitle:`最近 30 天趋势`,globalNoDailyData:`所选范围内暂无数据`,globalTotalTokens:`总 Token`,globalTotalSessions:`总会话数`,globalTotalApiCalls:`总 API 调用`}}),n(`en`,{tokenStats:{clearConfirmMessage:`Are you sure you want to clear all Token usage statistics? This action cannot be undone.`,loadFailed:`Load failed`,currentSessionNoData:`No data for current session`,totalTokenUsage:`Total Token Usage`,apiCallCount:`API Call Count`,contextUsageRate:`Context Usage Rate`,max:`Max`,avg:`Avg`,min:`Min`,totalTokens:`Total Tokens`,totalSessions:`Total Sessions`,totalApiCalls:`Total API Calls`,callTypeNonStream:`Normal`,callTypeStream:`Stream`,callTypeReflection:`Reflection`,callTypeToolReflection:`Tool Reflection`,callTypeSubtaskReflection:`Subtask Reflection`,tabTrend:`Trend`,tabDistribution:`Distribution`,tabGlobal:`Global`,topCardSessionTokens:`Session Tokens`,topCardSessionCalls:`Session Calls`,topCardContextPeak:`Context Peak`,sparklineTitle:`Last 20 Calls Trend`,distPromptVsCompletion:`Prompt / Completion Ratio`,distPrompt:`Prompt`,distCompletion:`Completion`,distByModel:`By Model`,distByCallType:`By Call Type`,distNoData:`No distribution data`,globalSparklineTitle:`Last 30 Days Trend`,globalNoDailyData:`No data in selected range`,globalTotalTokens:`Total Tokens`,globalTotalSessions:`Total Sessions`,globalTotalApiCalls:`Total API Calls`}});function cD(e,t){let n=document.getElementById(`tokenStatsOverlay`),i=document.getElementById(`tokenStatsClose`),o=document.getElementById(`tokenStatsRefreshBtn`),s=document.getElementById(`tokenStatsClearBtn`),c=document.getElementById(`tokenStatsTabNav`),l=document.getElementById(`tokenStatsTopCards`);if(!n)return;let u=`trend`,d=`month`;function f(){n.style.display=`flex`,h()}function p(){n.style.display=`none`}if(window.openTokenStats=f,i&&i.addEventListener(`click`,p),n&&n.addEventListener(`click`,e=>{e.target===n&&p()}),o&&o.addEventListener(`click`,h),s&&s.addEventListener(`click`,async()=>{await t(r(`tokenStats.clearConfirmMessage`),r(`toolStats.clearTitle`))&&(await se(),h())}),c){c.addEventListener(`click`,e=>{let t=e.target.closest(`.token-tab-btn`);if(!t)return;let n=t.dataset.tab;if(n===u)return;c.querySelectorAll(`.token-tab-btn`).forEach(e=>{e.classList.remove(`active`),e.style.borderBottomColor=`transparent`,e.style.color=`var(--text-secondary)`}),t.classList.add(`active`),t.style.borderBottomColor=`var(--brand-500)`,t.style.color=`var(--brand-500)`,document.querySelectorAll(`.token-tab-content`).forEach(e=>{e.style.display=`none`});let r=document.getElementById(`tokenTab${n.charAt(0).toUpperCase()+n.slice(1)}`);r&&(r.style.display=n===`global`?`flex`:``),u=n});let e=c.querySelector(`.token-tab-btn.active`);e&&(e.style.borderBottomColor=`var(--brand-500)`,e.style.color=`var(--brand-500)`)}let m=document.querySelectorAll(`.token-time-range-btn`);m.forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.range;t!==d&&(d=t,m.forEach(e=>{e.classList.remove(`active`),e.style.border=`1px solid var(--border-default)`,e.style.background=`var(--bg-surface)`,e.style.color=`var(--text-secondary)`}),e.classList.add(`active`),e.style.border=`1px solid var(--brand-500)`,e.style.background=`var(--brand-500)`,e.style.color=`var(--text-on-brand)`,w())})});async function h(){let t=e(),n=document.getElementById(`tokenStatsLoading`),i=document.getElementById(`tokenStatsEmpty`),o=document.getElementById(`tokenStatsContent`);n&&(n.style.display=``),i&&(i.style.display=`none`),o&&(o.style.display=`none`),c&&(c.style.display=`none`),l&&(l.style.display=`none`);try{let[e,r]=await Promise.all([oe(t),ie()]);if(n&&(n.style.display=`none`),!(r&&r.totalApiCalls>0)){i&&(i.style.display=``);return}o&&(o.style.display=``),c&&(c.style.display=`flex`),l&&(l.style.display=``),g(e),_(e),E(e.records||[]),x(r),w()}catch(e){a.error(`[TokenStats] load stats failed:`,e),n&&(n.style.display=`none`),i&&(i.textContent=r(`tokenStats.loadFailed`),i.style.display=``)}}function g(e){if(!l)return;if(!e||e.apiCallCount===0){l.innerHTML=``;return}let t=e.maxContextUsageRate||0,n=O(t);l.innerHTML=`
|
|
2407
|
+
</div>`).join(``):`<div class="queue-recent-empty">${F(r(`queue.recentEmpty`))}</div>`}function YE(e={}){if(!AE||HE)return;let t=GE();if(!t){AE.style.display=`none`;return}let n=Dr(t),i=n.items,a=i.length>0,o=n.recent.filter(e=>e.status===R.FAILED).length,s=o>0;if(!a&&!s&&(!VE||n.recent.length===0)){AE.style.display=`none`;return}if(AE.style.display=``,AE.classList.toggle(`empty`,!a),AE.classList.toggle(`expanded`,BE&&a),AE.classList.toggle(`paused`,n.paused),ME&&(a?(ME.textContent=r(`queue.summary`,{count:i.length}),ME.classList.remove(`failed`),ME.removeAttribute(`title`)):s?(ME.textContent=r(`queue.summaryFailed`,{count:o}),ME.classList.add(`failed`),ME.title=r(`queue.summaryFailedHint`)):(ME.textContent=r(`queue.summaryEmpty`),ME.classList.remove(`failed`),ME.removeAttribute(`title`))),NE&&(NE.style.display=n.paused?``:`none`,NE.title=n.pausedReason===`user_stopped`?r(`queue.pausedByStop`):r(`queue.pausedHint`)),PE){let e=n.paused&&i.length>0;PE.style.display=e?``:`none`,PE.textContent=r(`queue.resumeQueue`)}if(FE){let e=N.isGenerating===!0&&a&&!n.paused;FE.style.display=e?``:`none`}IE&&(IE.classList.toggle(`active`,VE),IE.title=r(`queue.recentTitle`)),RE&&(RE.style.display=a?``:`none`,RE.setAttribute(`aria-expanded`,BE?`true`:`false`),RE.textContent=BE?`▲`:`▼`),jE&&(jE.style.display=BE&&a?``:`none`,jE.innerHTML=a?i.map((e,t)=>qE(e,t)).join(``):``),LE&&(LE.style.display=VE?``:`none`,LE.innerHTML=VE?JE(n.recent):``),e.flash&&(AE.classList.remove(`queue-flash`),AE.offsetWidth,AE.classList.add(`queue-flash`))}async function XE(e,t={}){let n=GE();if(!n||!e)return!1;let i=jr(n,e);if(!i)return!1;let a=document.getElementById(`userInput`);if(a&&a.value.trim()){let e=await hu({autoDrain:!1});if(!e.ok)return P(e.error===`queue_full`?r(`queue.queueFull`,{limit:e.limit}):r(`queue.enqueueFailed`),`warning`),!1}else if(ou())return P(r(`queue.inputHasUnsavedContext`),`warning`,4e3),!1;let o=await pu(i);return a&&(a.value=i.text,a.style.height=`auto`,a.dispatchEvent(new Event(`input`)),a.focus()),await Fr(n,e),await mu(e),o.wantsAttachments?P(o.attachments?r(`queue.editBackWithAttachments`):r(`queue.attachmentsMissing`),o.attachments?`success`:`warning`,2500):t.viaShortcut&&P(r(`queue.editTailHint`),`info`,2e3),!0}function ZE(){let e=GE();if(!e)return!1;let t=Ar(e);return t?(XE(t.id,{viaShortcut:!0}),!0):!1}async function QE(e,t){let n=GE();if(!(!n||!t)&&!(Tr(n).findIndex(e=>e.id===t)<0))switch(e){case`edit`:await XE(t);break;case`inject`:await Nu(t,n);break;case`remove`:await Fr(n,t),await mu(t),P(r(`queue.deleted`),`info`,1500);break;default:break}}async function $E(e){let t=GE();t&&await Ir(t,e)}async function eD(e,t){if(e.preventDefault(),!HE)return;let n=t?.dataset?.id;if(!n||n===HE)return;let r=GE();if(!r)return;let i=Tr(r).map(e=>e.id),a=i.indexOf(HE);if(a<0)return;i.splice(a,1);let o=t.getBoundingClientRect(),s=e.clientY-o.top>o.height/2,c=i.indexOf(n);c<0?c=i.length:s&&(c+=1),i.splice(c,0,HE),await $E(i)}function tD(){jE&&(jE.addEventListener(`dragstart`,e=>{let t=e.target.closest?.(`.queue-chip`);if(t){HE=t.dataset.id,t.classList.add(`dragging`);try{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,HE)}catch{}}}),jE.addEventListener(`dragend`,e=>{let t=e.target.closest?.(`.queue-chip`);t&&t.classList.remove(`dragging`),HE=null,jE.querySelectorAll(`.drag-over-top, .drag-over-bottom`).forEach(e=>{e.classList.remove(`drag-over-top`,`drag-over-bottom`)}),YE()}),jE.addEventListener(`dragover`,e=>{let t=e.target.closest?.(`.queue-chip`);if(!t||!HE||t.dataset.id===HE)return;e.preventDefault();let n=t.getBoundingClientRect(),r=e.clientY-n.top>n.height/2;t.classList.toggle(`drag-over-bottom`,r),t.classList.toggle(`drag-over-top`,!r)}),jE.addEventListener(`dragleave`,e=>{let t=e.target.closest?.(`.queue-chip`);t&&t.classList.remove(`drag-over-top`,`drag-over-bottom`)}),jE.addEventListener(`drop`,e=>{let t=e.target.closest?.(`.queue-chip`);eD(e,t)}))}function nD(){jE?.addEventListener(`click`,e=>{let t=e.target.closest?.(`.queue-chip-btn`);if(!t||t.disabled)return;let n=t.closest(`.queue-chip`);n&&QE(t.dataset.act,n.dataset.id)}),LE?.addEventListener(`click`,async e=>{let t=e.target.closest?.(`.queue-chip-btn`),n=t?.closest(`.queue-recent-item`),i=GE();if(!t||!n||!i)return;if(t.dataset.act===`forget`){await Hr(i,n.dataset.id)&&P(r(`queue.forgotRecent`),`success`,1500);return}if(t.dataset.act!==`requeue`)return;let a=Er(i).find(e=>e.id===n.dataset.id),o=!!(a&&a.attachmentSummary),s=await Vr(i,n.dataset.id);if(!s.ok){P(s.error===`queue_full`?r(`queue.queueFull`,{limit:s.limit}):r(`queue.enqueueFailed`),`warning`);return}P(r(o?`queue.requeuedNoAttachments`:`queue.requeued`),o?`warning`:`success`,2500)}),RE?.addEventListener(`click`,()=>{BE=!BE,YE()}),zE?.addEventListener(`click`,e=>{e.target.closest?.(`button`)||Tr(GE()||``).length&&(BE=!BE,YE())}),IE?.addEventListener(`click`,()=>{VE=!VE,VE&&(BE=!0),YE()}),PE?.addEventListener(`click`,async()=>{await Xu(),P(r(`queue.resumed`),`success`,1500)}),FE?.addEventListener(`click`,()=>{document.dispatchEvent(new CustomEvent(`queue-stop-and-send`))}),tD(),wr(()=>YE()),document.addEventListener(`queue-enqueued`,()=>{BE=!0,YE({flash:!0})}),document.addEventListener(`session-switched`,()=>{YE()}),document.addEventListener(`generation-ended`,()=>YE()),document.addEventListener(`generating-state-changed`,()=>YE())}async function rD(){await Sr(),YE()}async function iD(){if(await Sr(),AE=document.getElementById(`queueStrip`),!AE){a.warn(`[QueuePanel] #queueStrip not found, queue UI disabled`);return}jE=document.getElementById(`queueList`),ME=document.getElementById(`queueSummary`),NE=document.getElementById(`queuePausedTag`),PE=document.getElementById(`queueResumeBtn`),FE=document.getElementById(`queueStopSendBtn`),IE=document.getElementById(`queueRecentBtn`),LE=document.getElementById(`queueRecent`),RE=document.getElementById(`queueToggleBtn`),zE=AE.querySelector(`.queue-strip-head`),nD(),YE()}var aD=new Set,oD=new Set,sD=new Map,cD=30*1e3;function lD(e){let t=sD.get(e);return t?Date.now()-t<cD?!0:(sD.delete(e),!1):!1}async function uD(e){let t=le(e)||e;if(!t||aD.has(t)||oD.has(t)||lD(t))return null;oD.add(t);try{let e=await Ce();if(!e)return null;let n=null;try{let r=await he(`${e.url}/api/status/detail`,{headers:{Authorization:`Bearer ${e.token}`,"X-AIH-Session-Id":t}});if(!r.ok)return sD.set(t,Date.now()),null;n=await r.json()}catch(e){return a.debug(`[WorkdirReconcile] fetch detail failed:`,e?.message||e),sD.set(t,Date.now()),null}if(!n?.success||!n.sessionWorkdirSupported)return sD.set(t,Date.now()),null;let r=n.sessionWorkdir||null,i=n.defaultWorkdir||n.workdir||null;if(!r||r===i)return sD.set(t,Date.now()),null;let o=await Ie(t);return o.scope===`session`?(sD.set(t,Date.now()),null):o.boundWorkdir?await Oe(t)?(aD.add(t),a.debug(`[WorkdirReconcile] cleared stale agent binding:`,t,r),{cleaned:!0,workdir:r}):null:await Ee(t,r,o.agentId||e.id||null)?(aD.add(t),a.debug(`[WorkdirReconcile] restored session workdir:`,t,r),{adopted:!0,workdir:r}):null}finally{oD.delete(t)}}n(`zh`,{tokenStats:{clearConfirmMessage:`确定要清空所有 Token 使用统计吗?此操作不可撤销。`,loadFailed:`加载失败`,currentSessionNoData:`当前会话暂无数据`,totalTokenUsage:`总 Token 消耗`,apiCallCount:`API 调用次数`,contextUsageRate:`上下文使用率`,max:`最大`,avg:`平均`,min:`最小`,totalTokens:`总 Token`,totalSessions:`总会话数`,totalApiCalls:`总 API 调用`,callTypeNonStream:`普通`,callTypeStream:`流式`,callTypeReflection:`反思`,callTypeToolReflection:`工具反思`,callTypeSubtaskReflection:`子任务反思`,tabTrend:`趋势`,tabDistribution:`分布`,tabGlobal:`全局`,topCardSessionTokens:`本次 Token`,topCardSessionCalls:`本次调用`,topCardContextPeak:`上下文峰值`,sparklineTitle:`最近 20 次调用趋势`,distPromptVsCompletion:`Prompt / Completion 占比`,distPrompt:`Prompt`,distCompletion:`Completion`,distByModel:`按模型分布`,distByCallType:`按调用类型分布`,distNoData:`暂无分布数据`,globalSparklineTitle:`最近 30 天趋势`,globalNoDailyData:`所选范围内暂无数据`,globalTotalTokens:`总 Token`,globalTotalSessions:`总会话数`,globalTotalApiCalls:`总 API 调用`}}),n(`en`,{tokenStats:{clearConfirmMessage:`Are you sure you want to clear all Token usage statistics? This action cannot be undone.`,loadFailed:`Load failed`,currentSessionNoData:`No data for current session`,totalTokenUsage:`Total Token Usage`,apiCallCount:`API Call Count`,contextUsageRate:`Context Usage Rate`,max:`Max`,avg:`Avg`,min:`Min`,totalTokens:`Total Tokens`,totalSessions:`Total Sessions`,totalApiCalls:`Total API Calls`,callTypeNonStream:`Normal`,callTypeStream:`Stream`,callTypeReflection:`Reflection`,callTypeToolReflection:`Tool Reflection`,callTypeSubtaskReflection:`Subtask Reflection`,tabTrend:`Trend`,tabDistribution:`Distribution`,tabGlobal:`Global`,topCardSessionTokens:`Session Tokens`,topCardSessionCalls:`Session Calls`,topCardContextPeak:`Context Peak`,sparklineTitle:`Last 20 Calls Trend`,distPromptVsCompletion:`Prompt / Completion Ratio`,distPrompt:`Prompt`,distCompletion:`Completion`,distByModel:`By Model`,distByCallType:`By Call Type`,distNoData:`No distribution data`,globalSparklineTitle:`Last 30 Days Trend`,globalNoDailyData:`No data in selected range`,globalTotalTokens:`Total Tokens`,globalTotalSessions:`Total Sessions`,globalTotalApiCalls:`Total API Calls`}});function dD(e,t){let n=document.getElementById(`tokenStatsOverlay`),i=document.getElementById(`tokenStatsClose`),o=document.getElementById(`tokenStatsRefreshBtn`),s=document.getElementById(`tokenStatsClearBtn`),c=document.getElementById(`tokenStatsTabNav`),l=document.getElementById(`tokenStatsTopCards`);if(!n)return;let u=`trend`,d=`month`;function f(){n.style.display=`flex`,h()}function p(){n.style.display=`none`}if(window.openTokenStats=f,i&&i.addEventListener(`click`,p),n&&n.addEventListener(`click`,e=>{e.target===n&&p()}),o&&o.addEventListener(`click`,h),s&&s.addEventListener(`click`,async()=>{await t(r(`tokenStats.clearConfirmMessage`),r(`toolStats.clearTitle`))&&(await se(),h())}),c){c.addEventListener(`click`,e=>{let t=e.target.closest(`.token-tab-btn`);if(!t)return;let n=t.dataset.tab;if(n===u)return;c.querySelectorAll(`.token-tab-btn`).forEach(e=>{e.classList.remove(`active`),e.style.borderBottomColor=`transparent`,e.style.color=`var(--text-secondary)`}),t.classList.add(`active`),t.style.borderBottomColor=`var(--brand-500)`,t.style.color=`var(--brand-500)`,document.querySelectorAll(`.token-tab-content`).forEach(e=>{e.style.display=`none`});let r=document.getElementById(`tokenTab${n.charAt(0).toUpperCase()+n.slice(1)}`);r&&(r.style.display=n===`global`?`flex`:``),u=n});let e=c.querySelector(`.token-tab-btn.active`);e&&(e.style.borderBottomColor=`var(--brand-500)`,e.style.color=`var(--brand-500)`)}let m=document.querySelectorAll(`.token-time-range-btn`);m.forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.range;t!==d&&(d=t,m.forEach(e=>{e.classList.remove(`active`),e.style.border=`1px solid var(--border-default)`,e.style.background=`var(--bg-surface)`,e.style.color=`var(--text-secondary)`}),e.classList.add(`active`),e.style.border=`1px solid var(--brand-500)`,e.style.background=`var(--brand-500)`,e.style.color=`var(--text-on-brand)`,w())})});async function h(){let t=e(),n=document.getElementById(`tokenStatsLoading`),i=document.getElementById(`tokenStatsEmpty`),o=document.getElementById(`tokenStatsContent`);n&&(n.style.display=``),i&&(i.style.display=`none`),o&&(o.style.display=`none`),c&&(c.style.display=`none`),l&&(l.style.display=`none`);try{let[e,r]=await Promise.all([oe(t),ie()]);if(n&&(n.style.display=`none`),!(r&&r.totalApiCalls>0)){i&&(i.style.display=``);return}o&&(o.style.display=``),c&&(c.style.display=`flex`),l&&(l.style.display=``),g(e),_(e),E(e.records||[]),x(r),w()}catch(e){a.error(`[TokenStats] load stats failed:`,e),n&&(n.style.display=`none`),i&&(i.textContent=r(`tokenStats.loadFailed`),i.style.display=``)}}function g(e){if(!l)return;if(!e||e.apiCallCount===0){l.innerHTML=``;return}let t=e.maxContextUsageRate||0,n=O(t);l.innerHTML=`
|
|
2401
2408
|
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;">
|
|
2402
2409
|
<div style="background: var(--brand-soft-bg); border-radius: 8px; padding: 10px; text-align: center;">
|
|
2403
2410
|
<div style="font-size: 10px; color: var(--text-tertiary); margin-bottom: 4px;">${r(`tokenStats.topCardSessionTokens`)}</div>
|
|
@@ -2508,7 +2515,7 @@ Sessions using this assistant will revert to the default assistant.`,deleteAgent
|
|
|
2508
2515
|
<span style="background:var(--bg-subtle);padding:1px 5px;border-radius:3px;font-size:9px;color:var(--text-secondary);">${F(i)}</span>
|
|
2509
2516
|
<span style="font-weight:500;color:var(--text-primary);margin-left:auto;">${D(e.totalTokens)}</span>
|
|
2510
2517
|
<span style="color:${o};font-size:9px;font-weight:500;width:35px;text-align:right;">${((e.contextUsageRate||0)*100).toFixed(1)}%</span>
|
|
2511
|
-
</div>`}).join(``)}function D(e){return e>=1e6?(e/1e6).toFixed(1)+`M`:e>=1e3?(e/1e3).toFixed(1)+`K`:String(e)}function O(e){return e>=.8?`#ef4444`:e>=.5?`#f59e0b`:`#10b981`}}function
|
|
2518
|
+
</div>`}).join(``)}function D(e){return e>=1e6?(e/1e6).toFixed(1)+`M`:e>=1e3?(e/1e3).toFixed(1)+`K`:String(e)}function O(e){return e>=.8?`#ef4444`:e>=.5?`#f59e0b`:`#10b981`}}function fD(e){return(e||[]).map(e=>e.token?{...e,token:x(e.token)}:e)}n(`zh`,{sidePanel:{confirmAction:`确认操作`,memoryLimitAll:`全`,memoryLimitTitle:`点击设置记忆历史限制条数`,configUpdated:`✅ 配置已更新`,selectedPrefix:`📌 已选中`,askBasedOnSelection:`基于选中内容提问`,selectedContentLabel:`选中内容`,selectedContentSummary:`摘要`,userQuestionLabel:`用户问题`,requestFailed:`❌ 请求失败:`,unknownError:`未知错误`,notConnected:`未连接`,noPairedAgents:`暂无已配对代理`,agentDisabled:`已停用`,agentConnected:`已连接`,agentChecking:`检测中...`,agentOnline:`在线`,agentOffline:`离线`,enableAgent:`启用`,disableAgent:`停用`,disconnectAgent:`断开`,connectAgent:`连接`,deleteAgentBtn:`删除`,workingDirectory:`工作目录: {path}`,agentAddressCopied:`已复制代理地址`,unknownAgent:`未知`,restartAgentConfirm:`代理名称:{name}
|
|
2512
2519
|
代理地址:{url}
|
|
2513
2520
|
|
|
2514
2521
|
确定要重启代理服务吗?重启期间服务将短暂不可用。`,restartAgentTitle:`重启代理`,agentRestarting:`代理服务正在重启...`,restartFailed:`重启失败: {error}`,restartRequestFailed:`重启请求失败: {error}`,updateAgentConfirm:`代理名称:{name}
|
|
@@ -2526,7 +2533,7 @@ Agent address: {url}
|
|
|
2526
2533
|
Are you sure you want to update the agent? It will install the latest version via npm, then restart the service. The service will be unavailable during update.`,updateAgentTitle:`Update Agent`,agentUpdating:`Updating agent (may take a few minutes)...`,agentUpdateRestarting:`Agent is updating and restarting...`,updateFailed:`Update failed: {error}`,updateRequestFailed:`Update request failed: {error}`,stopAgentConfirm:`Agent name: {name}
|
|
2527
2534
|
Agent address: {url}
|
|
2528
2535
|
|
|
2529
|
-
Are you sure you want to stop the agent service? You will not be able to connect and will need to manually restart it.`,stopAgentTitle:`Stop Agent`,agentStopped:`Agent service stopped, agent is offline`,stopFailed:`Stop failed: {error}`,stopRequestFailed:`Stop request failed: {error}`,agentStatusRefreshed:`Agent status refreshed`,deleteAgentTitle:`Delete Agent`,deleteAgentConfirm:`Are you sure you want to delete agent "{name}"? This action cannot be undone.`,welcomeTitle:`Start a Conversation`,welcomeSubtitle:`Enter your question and the AI assistant will help you`,sendBtnStop:`Stop generating`,sendBtnSend:`Send`,imageNotEnabled:`Image recognition not enabled, image attached as file`,screenshotFailed:`Screenshot failed, please retry`,auditCategoryAuth:`Auth`,auditCategoryFs:`File`,auditCategoryExec:`Command`,auditCategorySecurity:`Security`,auditCategorySystem:`System`,auditDetailSeparator:`; `,auditQueryFailed:`Query failed: {error}`,auditLoadFailed:`Load failed: {error}`,auditNoMatch:`No matching audit logs`,auditEmpty:`No audit logs`,clearStatsConfirm:`Are you sure you want to clear all tool usage stats? This action cannot be undone.`,clearStatsTitle:`Clear Stats`,toolStatsSummary:`Used {used} tools, unused {unused} tools`,toolStatsLoadFailed:`Load failed`,toolNameDescSeparator:`: `}}),window.showCustomConfirm=function(e,t=r(`sidePanel.confirmAction`)){return new Promise(n=>{let r=document.getElementById(`customConfirmOverlay`),i=document.getElementById(`customConfirmTitle`),a=document.getElementById(`customConfirmMessage`),o=document.getElementById(`customConfirmCancelBtn`),s=document.getElementById(`customConfirmOkBtn`);if(!r||!i||!a||!o||!s){n(confirm(e));return}let c=()=>{r.style.display=`none`,s.removeEventListener(`click`,l),o.removeEventListener(`click`,u),r.removeEventListener(`click`,d),document.removeEventListener(`keydown`,f)},l=()=>{c(),n(!0)},u=()=>{c(),n(!1)},d=e=>{e.target===r&&(c(),n(!1))},f=e=>{e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),l()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),u())};i.textContent=t,a.innerHTML=e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/\n/g,`<br>`),r.style.display=`flex`,s.addEventListener(`click`,l),o.addEventListener(`click`,u),r.addEventListener(`click`,d),document.addEventListener(`keydown`,f),requestAnimationFrame(()=>s.focus())})},chrome.storage.onChanged.addListener((e,t)=>{t===`local`&&e.chatAutoCompaction&&(N.chatConfig.autoCompaction=e.chatAutoCompaction.newValue===!0,dD(),a.debug(`[SidePanel] auto-compaction config updated:`,N.chatConfig.autoCompaction)),t===`local`&&e.chatPersistSummaryToMemory&&(N.chatConfig.persistSummaryToMemory=e.chatPersistSummaryToMemory.newValue!==!1,fD(),a.debug(`[SidePanel] persist-summary config updated:`,N.chatConfig.persistSummaryToMemory)),t===`local`&&e.chatMaxMemoryMessages&&(N.chatConfig.maxMemoryMessages=e.chatMaxMemoryMessages.newValue,uD(),a.debug(`[SidePanel] memory limitconfiguration updated:`,N.chatConfig.maxMemoryMessages)),t===`local`&&e.queueAutoCarry&&(N.chatConfig.queueAutoCarry=e.queueAutoCarry.newValue!==!1,a.debug(`[SidePanel] queue auto-carry updated:`,N.chatConfig.queueAutoCarry)),t===`local`&&e.queueAutoCarryEveryNIterations&&(N.chatConfig.queueAutoCarryEveryNIterations=e.queueAutoCarryEveryNIterations.newValue,a.debug(`[SidePanel] queue auto-carry interval updated:`,N.chatConfig.queueAutoCarryEveryNIterations))});function uD(){let e=document.getElementById(`memoryLimitLabel`);e&&(N.chatConfig.maxMemoryMessages!==null&&N.chatConfig.maxMemoryMessages!==void 0&&N.chatConfig.maxMemoryMessages>0?e.textContent=N.chatConfig.maxMemoryMessages:e.textContent=r(`sidePanel.memoryLimitAll`),e.title=r(`sidePanel.memoryLimitTitle`))}function dD(){let e=document.getElementById(`autoCompactBtn`);e&&(e.checked=N.chatConfig.autoCompaction===!0)}function fD(){let e=document.getElementById(`persistSummaryBtn`);e&&(e.checked=N.chatConfig.persistSummaryToMemory!==!1)}function pD(e){e.preventDefault(),e.stopPropagation();let t=document.getElementById(`memoryLimitDropdown`);if(t.classList.toggle(`show`),t.classList.contains(`show`)){let e=N.chatConfig.maxMemoryMessages;t.querySelectorAll(`.memory-limit-option`).forEach(t=>{t.classList.remove(`selected`);let n=parseInt(t.dataset.value);(e===null&&n===0||e!==null&&e>0&&n===e)&&t.classList.add(`selected`)});let n=t.querySelector(`#memoryLimitInput`);e!==null&&e>0?n.value=e:n.value=``}}function mD(){let e=document.getElementById(`memoryLimitDropdown`),t=document.getElementById(`memoryLimitLabel`),n=e?.querySelector(`#memoryLimitInput`);if(!e||!t)return;uD(),t.addEventListener(`click`,pD);let i=document.getElementById(`autoCompactBtn`);i&&(i.checked=N.chatConfig.autoCompaction===!0,i.addEventListener(`change`,()=>{let e=i.checked;chrome.storage.local.set({chatAutoCompaction:e},()=>{N.chatConfig.autoCompaction=e,P(r(`sidePanel.configUpdated`),`success`)})}));let a=document.getElementById(`persistSummaryBtn`);a&&(a.checked=N.chatConfig.persistSummaryToMemory!==!1,a.addEventListener(`change`,()=>{let e=a.checked;chrome.storage.local.set({chatPersistSummaryToMemory:e},()=>{N.chatConfig.persistSummaryToMemory=e,P(r(`sidePanel.configUpdated`),`success`)})}));let o=e.querySelectorAll(`.memory-limit-option`);o.forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let i=parseInt(e.dataset.value),a=i===0?null:i;o.forEach(e=>e.classList.remove(`selected`)),e.classList.add(`selected`),n&&(n.value=i===0?``:i),chrome.storage.local.set({chatMaxMemoryMessages:a},()=>{N.chatConfig.maxMemoryMessages=a,uD(),P(r(`sidePanel.configUpdated`),`success`)})})}),n&&(n.addEventListener(`click`,e=>e.stopPropagation()),n.addEventListener(`mousedown`,e=>e.stopPropagation()),n.addEventListener(`change`,e=>{e.stopPropagation();let t=e.target.value.trim(),n=t&&parseInt(t)>0?parseInt(t):null;o.forEach(e=>e.classList.remove(`selected`)),chrome.storage.local.set({chatMaxMemoryMessages:n},()=>{N.chatConfig.maxMemoryMessages=n,uD(),P(r(`sidePanel.configUpdated`),`success`)})})),document.getElementById(`memoryLimitConfigEntry`)?.addEventListener(`click`,()=>{chrome.runtime.sendMessage({type:`OPEN_OPTIONS_PAGE`,hash:`memory`})}),document.addEventListener(`click`,n=>{!e.contains(n.target)&&n.target!==t&&e.classList.remove(`show`)})}async function hD(e){if(N.activeAgentId&&N.activeAgentId!=="default")try{let{updateAgent:t}=await M(async()=>{let{updateAgent:e}=await import(`./agent-store-xMTBHsla.js`).then(e=>e.t);return{updateAgent:e}},__vite__mapDeps([0,1,2,3,4]));await t(N.activeAgentId,{model:e})}catch{}else chrome.storage.local.set({modelName:e}),k(e)}async function gD(){try{let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),t=lD(e.pairedAgents),n=e.activeAgentId,r=t.find(e=>e.id===n&&!e.disabled);if(!r){N.agentPlatform={connected:!1},kD(N.agentPlatform);return}if(r.token)try{let e=await fetch(`${r.url}/api/status/detail`,{cache:`no-cache`,headers:{Authorization:`Bearer ${r.token}`}});if(e.ok){let t=await e.json();if(t.success){N.agentPlatform={platformName:t.platformName||`Unknown`,platform:t.platform||`unknown`,arch:t.arch||`unknown`,shell:t.shell||`/bin/sh`,homeDir:t.homeDir||``,workdir:t.workdir||``,connected:!0},t.version&&N.agentVersions.set(n,t.version),t.workdir&&N.agentWorkdirs.set(n,t.workdir),t.homeDir&&N.agentHomeDirs.set(n,t.homeDir);let e=ND(t.platformName||t.platform,t.arch);e&&N.agentSystemInfos.set(n,e)}else N.agentPlatform={connected:!1}}else N.agentPlatform={connected:!1}}catch{N.agentPlatform={connected:!1}}else N.agentPlatform={connected:!1};kD(N.agentPlatform),yp()}catch{}}async function _D(e,t,n){if(N.activeAgentId&&N.activeAgentId!=="default")try{let{updateAgent:n}=await M(async()=>{let{updateAgent:e}=await import(`./agent-store-xMTBHsla.js`).then(e=>e.t);return{updateAgent:e}},__vite__mapDeps([0,1,2,3,4]));await n(N.activeAgentId,{temperature:e,topP:t})}catch{}else chrome.storage.local.set({temperature:e,topP:t,selectedTempIndex:n})}function vD(){let e=document.getElementById(`currentModelTag`);if(!e)return;let t=N.currentModel||``;e.textContent=t,e.title=t,e.style.display=t?``:`none`}var yD=new Set,bD=0;async function xD(){let e=++bD,t=document.getElementById(`workdirTag`),n=document.getElementById(`workdirTagName`);if(!t||!n)return;let i=N.activeSessionId||null,o=Array.isArray(N.enabledTools)&&N.enabledTools.includes(`agent_exec`);if(N.agentPlatform?.connected!==!0||!o){t.style.display=`none`;return}let s=null;try{s=await Ie(i)}catch(e){a.debug(`[WorkdirTag] resolve failed:`,e&&e.message)}if(e!==bD)return;let c=s&&s.workdir||``;if(!c){t.style.display=`none`;return}t.style.display=``,n.textContent=me(c,{homeDir:N.agentPlatform?.homeDir||``}),t.dataset.locked=N.generatingSessionIds?.has(i)||xu(i)?`true`:`false`;try{let{getWorkspaceRoot:e}=await M(async()=>{let{getWorkspaceRoot:e}=await import(`./workspace-manager-CovVLj3v.js`).then(e=>e.D);return{getWorkspaceRoot:e}},__vite__mapDeps([15,1,2,3,4])),n=await e(i),r=!!(n&&n!==c);r&&s.scope==="default"?(t.dataset.invalid=`false`,sD(i).then(e=>{e&&xD()}).catch(e=>a.debug(`[WorkdirTag] reconcile failed:`,e&&e.message))):t.dataset.invalid=r?`true`:`false`}catch{t.dataset.invalid=`false`}if(e===bD&&(t.title=`${c}${s.scope===`session`?r(`workdirTag.sessionScope`):r(`workdirTag.defaultScope`)}${t.dataset.invalid===`true`?r(`workdirTag.pathMissing`):``}`,s.boundWorkdir&&s.scope==="default")){let e=`${i||``}::${s.agentId||``}`;yD.has(e)||(yD.add(e),P(r(`workdirTag.agentSwitched`),`warning`))}}function SD(){let e=document.getElementById(`workdirTag`);e&&(e.setAttribute(`aria-label`,r(`workdirTag.tagHint`)),e.addEventListener(`click`,async t=>{if(t.stopPropagation(),e.dataset.locked===`true`){P(r(`workdirTag.lockedHint`),`warning`);return}let{showSwitchWorkdirDialog:n}=await M(async()=>{let{showSwitchWorkdirDialog:e}=await Promise.resolve().then(()=>Tp);return{showSwitchWorkdirDialog:e}},void 0);await n({sessionId:N.activeSessionId||null})})),xD(),document.addEventListener(`session-switched`,()=>{xD()}),document.addEventListener(`session-workdir-changed`,()=>{xD()}),document.addEventListener(`agent-model-changed`,()=>{xD()}),document.addEventListener(`agent-tools-changed`,()=>{xD()})}function CD(){let e=document.getElementById(`currentModelTag`);e&&e.addEventListener(`click`,e=>{e.stopPropagation(),document.getElementById(`tempDisplay`)?.click()}),vD()}function wD(e){let t=0;document.querySelectorAll(`.model-option`).forEach(n=>{n.dataset.value===e?(n.classList.add(`selected`),n.querySelector(`.model-option-check`).textContent=`✓`,t=parseInt(n.dataset.contextWindow,10)||0):(n.classList.remove(`selected`),n.querySelector(`.model-option-check`).textContent=``)});let n=document.getElementById(`modelSelectValue`);n&&e&&(n.textContent=e);let r=document.getElementById(`modelSelectCtxBadge`);r&&(t>0?(r.textContent=T(t),r.style.display=``):r.style.display=`none`),vD()}function TD(e,t){let n=document.getElementById(`tempDropdown`);if(!n){typeof t==`function`&&t();return}let i=n.querySelector(`.model-section`),a=[];if((Array.isArray(e)?e:[]).forEach(e=>{typeof e==`string`?a.push({name:e,contextWindow:0}):e&&typeof e==`object`&&e.name&&a.push({name:e.name,contextWindow:e.contextWindow||0})}),i){i.innerHTML=`
|
|
2536
|
+
Are you sure you want to stop the agent service? You will not be able to connect and will need to manually restart it.`,stopAgentTitle:`Stop Agent`,agentStopped:`Agent service stopped, agent is offline`,stopFailed:`Stop failed: {error}`,stopRequestFailed:`Stop request failed: {error}`,agentStatusRefreshed:`Agent status refreshed`,deleteAgentTitle:`Delete Agent`,deleteAgentConfirm:`Are you sure you want to delete agent "{name}"? This action cannot be undone.`,welcomeTitle:`Start a Conversation`,welcomeSubtitle:`Enter your question and the AI assistant will help you`,sendBtnStop:`Stop generating`,sendBtnSend:`Send`,imageNotEnabled:`Image recognition not enabled, image attached as file`,screenshotFailed:`Screenshot failed, please retry`,auditCategoryAuth:`Auth`,auditCategoryFs:`File`,auditCategoryExec:`Command`,auditCategorySecurity:`Security`,auditCategorySystem:`System`,auditDetailSeparator:`; `,auditQueryFailed:`Query failed: {error}`,auditLoadFailed:`Load failed: {error}`,auditNoMatch:`No matching audit logs`,auditEmpty:`No audit logs`,clearStatsConfirm:`Are you sure you want to clear all tool usage stats? This action cannot be undone.`,clearStatsTitle:`Clear Stats`,toolStatsSummary:`Used {used} tools, unused {unused} tools`,toolStatsLoadFailed:`Load failed`,toolNameDescSeparator:`: `}}),window.showCustomConfirm=function(e,t=r(`sidePanel.confirmAction`)){return new Promise(n=>{let r=document.getElementById(`customConfirmOverlay`),i=document.getElementById(`customConfirmTitle`),a=document.getElementById(`customConfirmMessage`),o=document.getElementById(`customConfirmCancelBtn`),s=document.getElementById(`customConfirmOkBtn`);if(!r||!i||!a||!o||!s){n(confirm(e));return}let c=()=>{r.style.display=`none`,s.removeEventListener(`click`,l),o.removeEventListener(`click`,u),r.removeEventListener(`click`,d),document.removeEventListener(`keydown`,f)},l=()=>{c(),n(!0)},u=()=>{c(),n(!1)},d=e=>{e.target===r&&(c(),n(!1))},f=e=>{e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),l()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),u())};i.textContent=t,a.innerHTML=e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/\n/g,`<br>`),r.style.display=`flex`,s.addEventListener(`click`,l),o.addEventListener(`click`,u),r.addEventListener(`click`,d),document.addEventListener(`keydown`,f),requestAnimationFrame(()=>s.focus())})},chrome.storage.onChanged.addListener((e,t)=>{t===`local`&&e.chatAutoCompaction&&(N.chatConfig.autoCompaction=e.chatAutoCompaction.newValue===!0,mD(),a.debug(`[SidePanel] auto-compaction config updated:`,N.chatConfig.autoCompaction)),t===`local`&&e.chatPersistSummaryToMemory&&(N.chatConfig.persistSummaryToMemory=e.chatPersistSummaryToMemory.newValue!==!1,hD(),a.debug(`[SidePanel] persist-summary config updated:`,N.chatConfig.persistSummaryToMemory)),t===`local`&&e.chatMaxMemoryMessages&&(N.chatConfig.maxMemoryMessages=e.chatMaxMemoryMessages.newValue,pD(),a.debug(`[SidePanel] memory limitconfiguration updated:`,N.chatConfig.maxMemoryMessages)),t===`local`&&e.queueAutoCarry&&(N.chatConfig.queueAutoCarry=e.queueAutoCarry.newValue!==!1,a.debug(`[SidePanel] queue auto-carry updated:`,N.chatConfig.queueAutoCarry)),t===`local`&&e.queueAutoCarryEveryNIterations&&(N.chatConfig.queueAutoCarryEveryNIterations=e.queueAutoCarryEveryNIterations.newValue,a.debug(`[SidePanel] queue auto-carry interval updated:`,N.chatConfig.queueAutoCarryEveryNIterations))});function pD(){let e=document.getElementById(`memoryLimitLabel`);e&&(N.chatConfig.maxMemoryMessages!==null&&N.chatConfig.maxMemoryMessages!==void 0&&N.chatConfig.maxMemoryMessages>0?e.textContent=N.chatConfig.maxMemoryMessages:e.textContent=r(`sidePanel.memoryLimitAll`),e.title=r(`sidePanel.memoryLimitTitle`))}function mD(){let e=document.getElementById(`autoCompactBtn`);e&&(e.checked=N.chatConfig.autoCompaction===!0)}function hD(){let e=document.getElementById(`persistSummaryBtn`);e&&(e.checked=N.chatConfig.persistSummaryToMemory!==!1)}function gD(e){e.preventDefault(),e.stopPropagation();let t=document.getElementById(`memoryLimitDropdown`);if(t.classList.toggle(`show`),t.classList.contains(`show`)){let e=N.chatConfig.maxMemoryMessages;t.querySelectorAll(`.memory-limit-option`).forEach(t=>{t.classList.remove(`selected`);let n=parseInt(t.dataset.value);(e===null&&n===0||e!==null&&e>0&&n===e)&&t.classList.add(`selected`)});let n=t.querySelector(`#memoryLimitInput`);e!==null&&e>0?n.value=e:n.value=``}}function _D(){let e=document.getElementById(`memoryLimitDropdown`),t=document.getElementById(`memoryLimitLabel`),n=e?.querySelector(`#memoryLimitInput`);if(!e||!t)return;pD(),t.addEventListener(`click`,gD);let i=document.getElementById(`autoCompactBtn`);i&&(i.checked=N.chatConfig.autoCompaction===!0,i.addEventListener(`change`,()=>{let e=i.checked;chrome.storage.local.set({chatAutoCompaction:e},()=>{N.chatConfig.autoCompaction=e,P(r(`sidePanel.configUpdated`),`success`)})}));let a=document.getElementById(`persistSummaryBtn`);a&&(a.checked=N.chatConfig.persistSummaryToMemory!==!1,a.addEventListener(`change`,()=>{let e=a.checked;chrome.storage.local.set({chatPersistSummaryToMemory:e},()=>{N.chatConfig.persistSummaryToMemory=e,P(r(`sidePanel.configUpdated`),`success`)})}));let o=e.querySelectorAll(`.memory-limit-option`);o.forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let i=parseInt(e.dataset.value),a=i===0?null:i;o.forEach(e=>e.classList.remove(`selected`)),e.classList.add(`selected`),n&&(n.value=i===0?``:i),chrome.storage.local.set({chatMaxMemoryMessages:a},()=>{N.chatConfig.maxMemoryMessages=a,pD(),P(r(`sidePanel.configUpdated`),`success`)})})}),n&&(n.addEventListener(`click`,e=>e.stopPropagation()),n.addEventListener(`mousedown`,e=>e.stopPropagation()),n.addEventListener(`change`,e=>{e.stopPropagation();let t=e.target.value.trim(),n=t&&parseInt(t)>0?parseInt(t):null;o.forEach(e=>e.classList.remove(`selected`)),chrome.storage.local.set({chatMaxMemoryMessages:n},()=>{N.chatConfig.maxMemoryMessages=n,pD(),P(r(`sidePanel.configUpdated`),`success`)})})),document.getElementById(`memoryLimitConfigEntry`)?.addEventListener(`click`,()=>{chrome.runtime.sendMessage({type:`OPEN_OPTIONS_PAGE`,hash:`memory`})}),document.addEventListener(`click`,n=>{!e.contains(n.target)&&n.target!==t&&e.classList.remove(`show`)})}async function vD(e){if(N.activeAgentId&&N.activeAgentId!=="default")try{let{updateAgent:t}=await M(async()=>{let{updateAgent:e}=await import(`./agent-store-DR_A4rFm.js`).then(e=>e.t);return{updateAgent:e}},__vite__mapDeps([0,1,2,3,4]));await t(N.activeAgentId,{model:e})}catch{}else chrome.storage.local.set({modelName:e}),k(e)}async function yD(){try{let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),t=fD(e.pairedAgents),n=e.activeAgentId,r=t.find(e=>e.id===n&&!e.disabled);if(!r){N.agentPlatform={connected:!1},MD(N.agentPlatform);return}if(r.token)try{let e=await fetch(`${r.url}/api/status/detail`,{cache:`no-cache`,headers:{Authorization:`Bearer ${r.token}`}});if(e.ok){let t=await e.json();if(t.success){N.agentPlatform={platformName:t.platformName||`Unknown`,platform:t.platform||`unknown`,arch:t.arch||`unknown`,shell:t.shell||`/bin/sh`,homeDir:t.homeDir||``,workdir:t.workdir||``,connected:!0},t.version&&N.agentVersions.set(n,t.version),t.workdir&&N.agentWorkdirs.set(n,t.workdir),t.homeDir&&N.agentHomeDirs.set(n,t.homeDir);let e=ID(t.platformName||t.platform,t.arch);e&&N.agentSystemInfos.set(n,e)}else N.agentPlatform={connected:!1}}else N.agentPlatform={connected:!1}}catch{N.agentPlatform={connected:!1}}else N.agentPlatform={connected:!1};MD(N.agentPlatform),yp()}catch{}}async function bD(e,t,n){if(N.activeAgentId&&N.activeAgentId!=="default")try{let{updateAgent:n}=await M(async()=>{let{updateAgent:e}=await import(`./agent-store-DR_A4rFm.js`).then(e=>e.t);return{updateAgent:e}},__vite__mapDeps([0,1,2,3,4]));await n(N.activeAgentId,{temperature:e,topP:t})}catch{}else chrome.storage.local.set({temperature:e,topP:t,selectedTempIndex:n})}function xD(){let e=document.getElementById(`currentModelTag`);if(!e)return;let t=N.currentModel||``;e.textContent=t,e.title=t,e.style.display=t?``:`none`}var SD=new Set,CD=0;async function wD(){let e=++CD,t=document.getElementById(`workdirTag`),n=document.getElementById(`workdirTagName`);if(!t||!n)return;let i=N.activeSessionId||null,o=Array.isArray(N.enabledTools)&&N.enabledTools.includes(`agent_exec`);if(N.agentPlatform?.connected!==!0||!o){t.style.display=`none`;return}let s=null;try{s=await Ie(i)}catch(e){a.debug(`[WorkdirTag] resolve failed:`,e&&e.message)}if(e!==CD)return;let c=s&&s.workdir||``;if(!c){t.style.display=`none`;return}t.style.display=``,n.textContent=me(c,{homeDir:N.agentPlatform?.homeDir||``}),t.dataset.locked=N.generatingSessionIds?.has(i)||xu(i)?`true`:`false`;try{let{getWorkspaceRoot:e}=await M(async()=>{let{getWorkspaceRoot:e}=await import(`./workspace-manager-BtQbbwPc.js`).then(e=>e.D);return{getWorkspaceRoot:e}},__vite__mapDeps([15,1,2,3,4])),n=await e(i),r=!!(n&&n!==c);r&&s.scope==="default"?(t.dataset.invalid=`false`,uD(i).then(e=>{e&&wD()}).catch(e=>a.debug(`[WorkdirTag] reconcile failed:`,e&&e.message))):t.dataset.invalid=r?`true`:`false`}catch{t.dataset.invalid=`false`}if(e===CD&&(t.title=`${c}${s.scope===`session`?r(`workdirTag.sessionScope`):r(`workdirTag.defaultScope`)}${t.dataset.invalid===`true`?r(`workdirTag.pathMissing`):``}`,s.boundWorkdir&&s.scope==="default")){let e=`${i||``}::${s.agentId||``}`;SD.has(e)||(SD.add(e),P(r(`workdirTag.agentSwitched`),`warning`))}}function TD(){let e=document.getElementById(`workdirTag`);e&&(e.setAttribute(`aria-label`,r(`workdirTag.tagHint`)),e.addEventListener(`click`,async t=>{if(t.stopPropagation(),e.dataset.locked===`true`){P(r(`workdirTag.lockedHint`),`warning`);return}let{showSwitchWorkdirDialog:n}=await M(async()=>{let{showSwitchWorkdirDialog:e}=await Promise.resolve().then(()=>Tp);return{showSwitchWorkdirDialog:e}},void 0);await n({sessionId:N.activeSessionId||null})})),wD(),document.addEventListener(`session-switched`,()=>{wD()}),document.addEventListener(`session-workdir-changed`,()=>{wD()}),document.addEventListener(`agent-model-changed`,()=>{wD()}),document.addEventListener(`agent-tools-changed`,()=>{wD()})}function ED(){let e=document.getElementById(`currentModelTag`);e&&e.addEventListener(`click`,e=>{e.stopPropagation(),document.getElementById(`tempDisplay`)?.click()}),xD()}function DD(e){let t=0;document.querySelectorAll(`.model-option`).forEach(n=>{n.dataset.value===e?(n.classList.add(`selected`),n.querySelector(`.model-option-check`).textContent=`✓`,t=parseInt(n.dataset.contextWindow,10)||0):(n.classList.remove(`selected`),n.querySelector(`.model-option-check`).textContent=``)});let n=document.getElementById(`modelSelectValue`);n&&e&&(n.textContent=e);let r=document.getElementById(`modelSelectCtxBadge`);r&&(t>0?(r.textContent=T(t),r.style.display=``):r.style.display=`none`),xD()}function OD(e,t){let n=document.getElementById(`tempDropdown`);if(!n){typeof t==`function`&&t();return}let i=n.querySelector(`.model-section`),a=[];if((Array.isArray(e)?e:[]).forEach(e=>{typeof e==`string`?a.push({name:e,contextWindow:0}):e&&typeof e==`object`&&e.name&&a.push({name:e.name,contextWindow:e.contextWindow||0})}),i){i.innerHTML=`
|
|
2530
2537
|
<div class="model-section-title" data-i18n="model.selectModel">${r(`model.selectModel`)}</div>
|
|
2531
2538
|
<div class="section-select" id="modelSelect">
|
|
2532
2539
|
<div class="section-select-row" id="modelSelectRow">
|
|
@@ -2535,15 +2542,15 @@ Are you sure you want to stop the agent service? You will not be able to connect
|
|
|
2535
2542
|
<span class="section-select-caret"></span>
|
|
2536
2543
|
</div>
|
|
2537
2544
|
<div class="section-select-list" id="modelSelectList"></div>
|
|
2538
|
-
</div>`;let e=i.querySelector(`#modelSelectList`);e.innerHTML=
|
|
2545
|
+
</div>`;let e=i.querySelector(`#modelSelectList`);e.innerHTML=pT();let t=[...a].sort((e,t)=>w(e.name,t.name));for(let n of t){let t=document.createElement(`div`);t.className=`model-option`,t.dataset.value=n.name,n.contextWindow&&n.contextWindow>0&&(t.dataset.contextWindow=n.contextWindow),t.innerHTML=`<span class="model-option-check"></span><span class="model-option-left">${F(n.name)}</span>`;let i=document.createElement(`span`);i.className=`model-option-right`;let a=document.createElement(`span`);a.className=`model-ctx-badge`;let o=n.contextWindow&&n.contextWindow>0;a.textContent=T(o?n.contextWindow:f(n.name)),o||(a.classList.add(`is-auto`),a.title=r(`settings.ctxBadgeAutoTip`)),i.appendChild(a),t.appendChild(i),t.addEventListener(`click`,e=>{e.stopPropagation(),fT(),N.currentModel=n.name,DD(n.name),vD(n.name),uw()}),e.appendChild(t)}}N.customModelMap=m(e),typeof t==`function`&&t()}function kD(e,t=r(`sidePanel.selectedPrefix`)){if(!N.enableSelectionQuery)return;N.quotedContextText=``,N.selectedContextText=e;let n=document.getElementById(`selectionIndicator`),i=document.getElementById(`selectionText`),a=document.getElementById(`userInput`);if(n&&i&&a){let r;r=e.length>100?e.substring(0,100)+`...`:e.length>50?e.substring(0,50)+`...`:e,i.textContent=`${t}: ${r}`,n.classList.add(`show`)}}function AD(e,t,n=0,i=0){if(!N.enableSelectionQuery)return;let o=document.getElementById(`selectionFloatingMenu`),s=document.getElementById(`selectionMenuItems`);if(!o||!s){let e=document.getElementById(`chatContainer`);if(!e)return;o=document.createElement(`div`),o.className=`selection-floating-menu`,o.id=`selectionFloatingMenu`,o.innerHTML=`
|
|
2539
2546
|
<div class="menu-header">${r(`sidePanel.askBasedOnSelection`)}</div>
|
|
2540
2547
|
<div id="selectionMenuItems"></div>
|
|
2541
2548
|
`,e.appendChild(o),s=document.getElementById(`selectionMenuItems`)}let c=N.customPrompts.filter(e=>e.enabledInMenu===!0);if(c.length===0){a.debug(`[SidePanel] showFloatingMenu skipped: no prompts enabled in menu`);return}s.innerHTML=``,c.forEach(e=>{let n=e.content.length>10?e.content.substring(0,10)+`...`:e.content,r=document.createElement(`div`);r.className=`menu-item`,r.innerHTML=`
|
|
2542
2549
|
<span>${n}</span>
|
|
2543
2550
|
<span class="menu-item-code">/${e.code}</span>
|
|
2544
|
-
`,r.addEventListener(`click`,n=>{n.stopPropagation(),
|
|
2551
|
+
`,r.addEventListener(`click`,n=>{n.stopPropagation(),jD(e,t)}),s.appendChild(r)});let l=document.body.getBoundingClientRect(),u=40+c.length*36,d=i-l.top-u-30,f=n-l.left-20;d<l.top+10&&(d=i-l.top+30),f<l.left+10&&(f=n-l.left+20),f+180>l.right-10&&(f=n-l.left-180-30,f<l.left+10&&(f=n-l.left+20)),d+u>l.bottom-10&&(d=i-l.top-u-30,d<l.top+10&&(d=i-l.top+30)),o.style.top=d+`px`,o.style.left=f+`px`,o.style.maxHeight=l.bottom-d-20+`px`,o.classList.add(`show`)}window.hideFloatingMenu=function(){let e=document.getElementById(`selectionFloatingMenu`);e&&e.classList.remove(`show`),N.lastSelectedText=``,N.currentSelectionRange=null};async function jD(e,t){if(!N.enableSelectionQuery)return;if(window.hideFloatingMenu(),N.isGenerating){a.debug(`[SidePanel] generating,please wait...`);return}await ac({state:N,getRatio:()=>cw().usage?.ratio??0,compact:_w}),N.selectedContextText=t,px();let n=document.getElementById(`chatContainer`).querySelector(`.welcome-message`);n&&n.remove(),Gx(`selected`,t,!1);let{compressed:i,wasCompressed:o}=O(t),s=`[${r(`sidePanel.selectedContentLabel`)}${o?r(`sidePanel.selectedContentSummary`):``}]\n${i}\n\n[${r(`sidePanel.userQuestionLabel`)}]\n${e.content}`,{messageId:c,timestamp:l}=Jx(`user`,e.content,!0,[],null,!1,s);N.messageHistory.push({role:`user`,content:s,messageId:c,timestamp:l}),yx(),Pn(e.content),N.isGenerating=!0;let u=eS(),f=N.activeSessionId,p=N.currentModel;try{await Tt(),a.debug(`[SidePanel] sendmessagedebuginfo:`),a.debug(` - isolateChat:`,N.isolateChat),a.debug(` - chatConfig:`,N.chatConfig),a.debug(` - messageHistory.length:`,N.messageHistory.length);let t=[{role:`system`,content:await kt(null,{sessionId:f})}];if(N.isolateChat){let e=d(t[0]?.content||``),n=h(p,0,N.customModelMap)-e-4096-2e3,r=Math.floor(n*.7),i=N.messageHistory[N.messageHistory.length-1],o=kn(N.messageHistory.slice(0,-1),{isolateChat:!0,maxMemoryMessages:N.chatConfig.maxMemoryMessages,compaction:N.activeCompaction,historyBudget:r,currentMessage:i});jn(t,o,N.activeCompaction,a),o.historySummaryText&&(t[0]={...t[0],content:t[0].content+`
|
|
2545
2552
|
|
|
2546
|
-
`+o.historySummaryText}),t=[...t,...o.messages];for(let e=0;e<t.length-1;e++)t[e]={...t[e],content:_(t[e].content)}}else t.push({role:`user`,content:s});let n=await bt(),i,o;try{let r=await
|
|
2553
|
+
`+o.historySummaryText}),t=[...t,...o.messages];for(let e=0;e<t.length-1;e++)t[e]={...t[e],content:_(t[e].content)}}else t.push({role:`user`,content:s});let n=await bt(),i,o;try{let r=await lS(t,p,N.useTools,n);if(i=r.content,o=r.executionLog||[],tS(u),r.wasStreamed)r.streamingMsgId&&(N.messageHistory.push({role:`assistant`,content:i,executionLog:o,messageId:r.streamingMsgId}),yx());else{let{element:e,messageId:t}=Jx(`assistant`,i,!0,o);await Jt(e),N.messageHistory.push({role:`assistant`,content:i,executionLog:o,messageId:t}),yx()}Ic(f,e.content);return}catch(t){tS(u),i=r(`sidePanel.requestFailed`)+(t.message||r(`sidePanel.unknownError`)),o=t.executionLog||[];let{element:n,messageId:a}=Jx(`assistant`,i,!0,o);throw N.messageHistory.push({role:`assistant`,content:i,executionLog:o,messageId:a}),yx(),t.message!==r(`chatMsg.errTaskStopped`)&&Lc(f,i,e.content),t}}catch{}finally{Bc(f),document.getElementById(`userInput`).focus()}}async function MD(e,t=!1){let n=document.getElementById(`headerAgentDot`),i=document.getElementById(`headerAgentName`),a=document.getElementById(`headerAgentTrigger`);if(!n||!i)return;let o=null,s=[];try{let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]);s=fD(e.pairedAgents),o=s.find(t=>t.id===e.activeAgentId)}catch{}let c=e?.connected===!0;if(!c||!o?(n.className=`header-agent-dot disconnected`,i.textContent=o?o.name.length>12?o.name.substring(0,12)+`...`:o.name:r(`sidePanel.notConnected`),i.classList.toggle(`truncated`,!!o),a.title=o?o.name:``):(n.className=`header-agent-dot connected`,i.textContent=o.name.length>12?o.name.substring(0,12)+`...`:o.name,i.classList.toggle(`truncated`,o.name.length>12),a.title=o.name),ND(o,s,c),!t){let e=document.getElementById(`headerAgentDropdown`);e&&e.style.display!==`none`&&zD()}Jg(c),wD()}function ND(e,t,n){let i=document.getElementById(`agentDdList`),a=document.getElementById(`agentDdCopyRow`);if(!i||!a)return;if(e?.url?(a.style.display=``,a.querySelector(`.agent-dd-copy-label`).textContent=e.url):a.style.display=`none`,t.length===0){i.innerHTML=`<div class="agent-dd-empty">`+r(`sidePanel.noPairedAgents`)+`</div>`;let e=document.getElementById(`agentDdRestartBtn`),t=document.getElementById(`agentDdUpdateBtn`),n=document.getElementById(`agentDdStopBtn`);e&&(e.disabled=!0),t&&(t.disabled=!0),n&&(n.disabled=!0);return}i.innerHTML=t.map(t=>{let i=t.id===e?.id,a=!!t.disabled,o=N.agentVersions.get(t.id),s,c;a?(s=`disabled`,c=r(`sidePanel.agentDisabled`)):i?(s=n?`connected`:`disconnected`,c=r(n?`sidePanel.agentConnected`:`sidePanel.notConnected`)):(s=`checking`,c=r(`sidePanel.agentChecking`));let l=N.agentWorkdirs.get(t.id),u=FD(l,N.agentHomeDirs.get(t.id)),d=N.agentSystemInfos.get(t.id);return`
|
|
2547
2554
|
<div class="agent-dd-item${i?` active`:``}${a?` disabled`:``}" data-agent-id="${t.id}">
|
|
2548
2555
|
<span class="agent-dd-item-dot ${s}"></span>
|
|
2549
2556
|
<div class="agent-dd-item-info">
|
|
@@ -2560,7 +2567,7 @@ Are you sure you want to stop the agent service? You will not be able to connect
|
|
|
2560
2567
|
<button class="agent-dd-tool-btn delete" data-action="delete" data-id="${t.id}" title="${r(`sidePanel.deleteAgentBtn`)}">🗑</button>
|
|
2561
2568
|
</div>
|
|
2562
2569
|
</div>
|
|
2563
|
-
`}).join(``);let o=document.getElementById(`agentDdRestartBtn`),s=document.getElementById(`agentDdUpdateBtn`),c=document.getElementById(`agentDdStopBtn`),l=!!(e&&n);o&&(o.disabled=!l),s&&(s.disabled=!l),c&&(c.disabled=!l)}async function jD(e,t){if(t)try{let n=new AbortController;setTimeout(()=>n.abort(),2e3);let r=await fetch(`${e}/api/status/detail`,{signal:n.signal,headers:{Authorization:`Bearer ${t}`}});if(r.ok){let e=await r.json();if(e.success)return{online:!0,version:e.version||null,workdir:e.workdir||null,homeDir:e.homeDir||null,platformName:e.platformName||e.platform||null,arch:e.arch||null}}}catch{}try{let t=new AbortController;setTimeout(()=>t.abort(),2e3);let n=await fetch(`${e}/api/status`,{signal:t.signal});if(!n.ok)return{online:!1,version:null,workdir:null,homeDir:null,platformName:null,arch:null};let r=await n.json();return{online:!0,version:r.version||null,workdir:null,homeDir:null,platformName:r.platformName||r.platform||null,arch:r.arch||null}}catch{return{online:!1,version:null,workdir:null,homeDir:null,platformName:null,arch:null}}}function MD(e,t){return e?t&&e.startsWith(t)?`~`+e.substring(t.length):e:``}function ND(e,t){return e||``}function PD(e,t){let n=document.querySelector(`.agent-dd-item[data-agent-id="${e}"]`);if(!n)return;let i=n.querySelector(`.agent-dd-item-dot`),a=n.querySelector(`.agent-dd-item-status`),o=n.classList.contains(`active`);i&&(i.classList.remove(`checking`,`connected`,`disconnected`,`online`,`offline`),i.classList.add(o?t?`connected`:`disconnected`:t?`online`:`offline`)),a&&(o?a.textContent=r(t?`sidePanel.agentConnected`:`sidePanel.notConnected`):a.textContent===r(`sidePanel.agentChecking`)&&(a.textContent=r(t?`sidePanel.agentOnline`:`sidePanel.agentOffline`)))}function FD(e,t){if(!t)return;let n=document.querySelector(`.agent-dd-item[data-agent-id="${e}"]`);if(!n)return;let i=n.querySelector(`.agent-dd-item-info`);if(!i)return;let a=MD(t,N.agentHomeDirs.get(e)),o=i.querySelector(`.agent-dd-item-workdir`);o?(o.textContent=a,o.title=r(`sidePanel.workingDirectory`,{path:t})):(o=document.createElement(`span`),o.className=`agent-dd-item-workdir`,o.title=r(`sidePanel.workingDirectory`,{path:t}),o.textContent=a,i.appendChild(o))}window.updateAgentItemWorkdir=FD;async function ID(){try{let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),t=lD(e.pairedAgents),n=e.activeAgentId;await Promise.all(t.filter(e=>!e.disabled).map(async e=>{let t=await jD(e.url,e.token),r=t.online;t.version&&N.agentVersions.set(e.id,t.version),t.workdir&&N.agentWorkdirs.set(e.id,t.workdir),t.homeDir&&N.agentHomeDirs.set(e.id,t.homeDir);let i=ND(t.platformName,t.arch);i&&N.agentSystemInfos.set(e.id,i),t.workdir&&FD(e.id,t.workdir),PD(e.id,r),e.id===n&&r!==(N.agentPlatform?.connected===!0)&&(N.agentPlatform={...N.agentPlatform,connected:r},kD(N.agentPlatform,!0),r&&LD(e))}))}catch{}}async function LD(e){try{let t=e;if(!t){let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=lD(e.pairedAgents),r=e.activeAgentId;t=n.find(e=>e.id===r&&!e.disabled)}if(!t||!t.url){N.agentPlatform={...N.agentPlatform,connected:!0},kD(N.agentPlatform),yp();return}if(t.token)try{let e=new AbortController;setTimeout(()=>e.abort(),3e3);let n=await fetch(`${t.url}/api/status/detail`,{signal:e.signal,headers:{Authorization:`Bearer ${t.token}`}});if(n.ok){let e=await n.json();if(e.success){N.agentPlatform={platformName:e.platformName||`Unknown`,platform:e.platform||`unknown`,arch:e.arch||`unknown`,shell:e.shell||`/bin/sh`,homeDir:e.homeDir||``,workdir:e.workdir||``,connected:!0},e.version&&N.agentVersions.set(t.id,e.version),e.workdir&&(N.agentWorkdirs.set(t.id,e.workdir),FD(t.id,e.workdir)),e.homeDir&&N.agentHomeDirs.set(t.id,e.homeDir);let n=ND(e.platformName||e.platform,e.arch);n&&N.agentSystemInfos.set(t.id,n),kD(N.agentPlatform),yp();return}}}catch{}try{let e=new AbortController;setTimeout(()=>e.abort(),3e3);let n=await fetch(`${t.url}/api/status`,{signal:e.signal});if(n.ok){let e=await n.json();N.agentPlatform={platformName:e.platformName||e.platform||`Unknown`,platform:e.platform||`unknown`,arch:e.arch||`unknown`,connected:!0},kD(N.agentPlatform),yp();return}}catch{}N.agentPlatform={...N.agentPlatform,connected:!0},kD(N.agentPlatform),yp()}catch{N.agentPlatform={...N.agentPlatform,connected:!0},kD(N.agentPlatform),yp()}}var RD=null;function zD(e,t=20){RD&&clearInterval(RD);let n=0;RD=setInterval(async()=>{if(n++,n>t||!e){clearInterval(RD),RD=null;return}try{let t=lD((await chrome.storage.local.get([`pairedAgents`])).pairedAgents).find(t=>t.id===e);if(!t){clearInterval(RD),RD=null;return}let n=await jD(t.url,t.token);if(n.online){clearInterval(RD),RD=null,n.version&&N.agentVersions.set(e,n.version),n.workdir&&N.agentWorkdirs.set(e,n.workdir),n.homeDir&&N.agentHomeDirs.set(e,n.homeDir);let r=ND(n.platformName,n.arch);r&&N.agentSystemInfos.set(e,r),n.workdir&&FD(e,n.workdir),await LD(t),PD(e,!0)}}catch{}},3e3)}function BD(){let e=document.getElementById(`headerAgentDropdown`),t=document.getElementById(`headerAgentWrapper`);if(!e||!t)return;let n=document.body.clientWidth,r=t.getBoundingClientRect(),i=e.offsetWidth;n<312?(e.style.minWidth=n-16+`px`,e.style.maxWidth=n-16+`px`):(e.style.minWidth=``,e.style.maxWidth=``);let a=r.right+20-i,o=n-i-8;a=Math.max(8,Math.min(o,a)),e.style.left=a-r.left+`px`}async function VD(){let e=document.getElementById(`headerAgentTrigger`),t=document.getElementById(`headerAgentDropdown`),n=document.getElementById(`agentDdCopyBtn`),i=document.getElementById(`agentDdAddBtn`),a=document.getElementById(`agentDdRestartBtn`),o=document.getElementById(`agentDdUpdateBtn`),s=document.getElementById(`agentDdStopBtn`),c=document.getElementById(`agentDdRefreshBtn`);if(!e||!t)return;e.addEventListener(`click`,e=>{e.stopPropagation();let n=t.style.display!==`none`;t.style.display=n?`none`:``,n||(BD(),kD(N.agentPlatform||{}),ID())}),document.addEventListener(`click`,n=>{!t.contains(n.target)&&n.target!==e&&(t.style.display=`none`)}),n.addEventListener(`click`,async e=>{e.stopPropagation(),N.activeAgentId;let t=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=lD(t.pairedAgents).find(e=>e.id===t.activeAgentId);n?.url&&(await navigator.clipboard.writeText(n.url),P(r(`sidePanel.agentAddressCopied`),`success`))}),i.addEventListener(`click`,async()=>{t.style.display=`none`,await chrome.storage.local.set({optionsInitialTab:`agent`});let e=await chrome.tabs.query({}),n=chrome.runtime.getURL(`options/index.html`),r=e.find(e=>e.url&&e.url.startsWith(n));if(r){chrome.tabs.update(r.id,{active:!0});try{chrome.tabs.sendMessage(r.id,{type:`SWITCH_TAB`,tab:`agent`})}catch{}}else chrome.runtime.openOptionsPage()}),a.addEventListener(`click`,async()=>{t.style.display=`none`;let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=lD(e.pairedAgents).find(t=>t.id===e.activeAgentId),i=n?.name||r(`sidePanel.unknownAgent`),a=n?.url||r(`sidePanel.unknownAgent`);if(await window.showCustomConfirm(r(`sidePanel.restartAgentConfirm`,{name:i,url:a}),r(`sidePanel.restartAgentTitle`)))try{chrome.runtime.sendMessage({type:`AGENT_RESTART`},async e=>{e?.success?(P(r(`sidePanel.agentRestarting`),`success`),N.agentPlatform={...N.agentPlatform,connected:!1},await kD(N.agentPlatform,!0),n?.id&&PD(n.id,!1),zD(n?.id)):P(r(`sidePanel.restartFailed`,{error:e?.error||r(`sidePanel.unknownError`)}),`error`)})}catch(e){P(r(`sidePanel.restartRequestFailed`,{error:e.message}),`error`)}}),o.addEventListener(`click`,async()=>{t.style.display=`none`;let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=lD(e.pairedAgents).find(t=>t.id===e.activeAgentId),i=n?.name||r(`sidePanel.unknownAgent`),a=n?.url||r(`sidePanel.unknownAgent`);if(await window.showCustomConfirm(r(`sidePanel.updateAgentConfirm`,{name:i,url:a}),r(`sidePanel.updateAgentTitle`))){P(r(`sidePanel.agentUpdating`),`info`);try{chrome.runtime.sendMessage({type:`AGENT_UPDATE`},async e=>{e?.success?(P(r(`sidePanel.agentUpdateRestarting`),`success`),N.agentPlatform={...N.agentPlatform,connected:!1},await kD(N.agentPlatform,!0),n?.id&&PD(n.id,!1),zD(n?.id)):P(r(`sidePanel.updateFailed`,{error:e?.error||r(`sidePanel.unknownError`)}),`error`)})}catch(e){P(r(`sidePanel.updateRequestFailed`,{error:e.message}),`error`)}}}),s.addEventListener(`click`,async()=>{t.style.display=`none`;let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=lD(e.pairedAgents).find(t=>t.id===e.activeAgentId),i=n?.name||r(`sidePanel.unknownAgent`),a=n?.url||r(`sidePanel.unknownAgent`);if(await window.showCustomConfirm(r(`sidePanel.stopAgentConfirm`,{name:i,url:a}),r(`sidePanel.stopAgentTitle`)))try{chrome.runtime.sendMessage({type:`AGENT_STOP`},async e=>{e?.success?(P(r(`sidePanel.agentStopped`),`success`),N.agentPlatform={...N.agentPlatform,connected:!1},await kD(N.agentPlatform,!0),n?.id&&PD(n.id,!1)):P(r(`sidePanel.stopFailed`,{error:e?.error||r(`sidePanel.unknownError`)}),`error`)})}catch(e){P(r(`sidePanel.stopRequestFailed`,{error:e.message}),`error`)}}),c&&c.addEventListener(`click`,async()=>{document.querySelectorAll(`.agent-dd-item-dot`).forEach(e=>{e.classList.remove(`online`,`offline`),e.classList.add(`checking`)}),document.querySelectorAll(`.agent-dd-item-status`).forEach(e=>{e.textContent=r(`sidePanel.agentChecking`)}),await ID(),P(r(`sidePanel.agentStatusRefreshed`),`success`)}),document.getElementById(`agentDdList`).addEventListener(`click`,async e=>{let t=e.target.closest(`.agent-dd-tool-btn`),n=e.target.closest(`.agent-dd-item`);if(t){e.stopPropagation(),l(t.dataset.action,t.dataset.id);return}n&&!n.classList.contains(`disabled`)&&!n.classList.contains(`active`)&&(e.stopPropagation(),l(`switch`,n.dataset.agentId))});async function l(e,t){let n=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),i=lD(n.pairedAgents);switch(e){case`enable`:i=i.map(e=>e.id===t?{...e,disabled:!1}:e),await chrome.storage.local.set({pairedAgents:i});break;case`disable`:{i=i.map(e=>e.id===t?{...e,disabled:!0}:e);let e=n.activeAgentId;n.activeAgentId===t&&(e=i.find(e=>e.id!==t&&!e.disabled)?.id||null),await chrome.storage.local.set({pairedAgents:i,activeAgentId:e||``}),e?chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!0,agentId:e}):chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!1});break}case`switch`:await chrome.storage.local.set({activeAgentId:t}),chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!0,agentId:t});break;case`disconnect`:await chrome.storage.local.set({activeAgentId:``}),chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!1});break;case`delete`:{let e=i.find(e=>e.id===t);if(!await window.showCustomConfirm(r(`sidePanel.deleteAgentTitle`),r(`sidePanel.deleteAgentConfirm`,{name:e?.name||t})))return;i=i.filter(e=>e.id!==t);let a=n.activeAgentId===t?i.find(e=>!e.disabled)?.id||null:n.activeAgentId;await chrome.storage.local.set({pairedAgents:i,activeAgentId:a||``}),a?chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!0,agentId:a}):chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!1});break}}let a=document.getElementById(`headerAgentDropdown`);a&&(a.style.display=`none`)}}var HD=new Map,UD=8;function WD(e,t){for(HD.has(e)&&HD.delete(e),HD.set(e,t);HD.size>UD;)HD.delete(HD.keys().next().value)}function GD(e){let t=HD.get(e);if(t!==void 0)return HD.delete(e),HD.set(e,t),t}function KD(e){HD.delete(e)}document.addEventListener(`DOMContentLoaded`,async()=>{await it(),et(()=>{Ft()}),lc(),await Promise.allSettled([i().then(()=>{o(),la(),c(()=>{o(),la()})}),yt(),ox(),fi()]),window.__tableBlocks=[],chrome.runtime.onMessage.addListener(e=>{if(e.type===`SCHEDULED_SESSION_UPDATED`){let t=e.sessionId;t===N.activeSessionId?mx().catch(()=>{}):t&&(mi(t).catch(()=>{}),document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:t}})));return}if(e.type===`CLOSE_SIDEPANEL`){a.debug(`[SidePanel] recei to CLOSE_SIDEPANEL,closesidebar`);try{window.close()}catch{}return}if(e.type===`SELECTION_AI_SEARCH`&&e.prompt&&(a.debug(`[SidePanel] received selectedtext AI search:`,e.selectedText?.substring(0,50)),e.selectedText&&ED(e.selectedText),zx(e.prompt,e.selectedText),chrome.storage.session.remove(`pendingSelectionSearch`).catch(()=>{})),e.type===`FILL_SIDEPANEL_INPUT`&&e.text&&(a.debug(`[SidePanel] received follow-upfill:`,e.text?.substring(0,50)),Bx(e.text),chrome.storage.session.remove(`pendingFillInput`).catch(()=>{})),e.type===`DIRECT_SEND`&&e.text&&(a.debug(`[SidePanel] received directsend:`,e.text?.substring(0,50)),e.selectedText&&ED(e.selectedText),Vx(e.text,e.selectedText||``),chrome.storage.session.remove(`pendingDirectSend`).catch(()=>{})),e.type===`AGENT_STATUS_CHANGE`&&(a.debug(`[SidePanel] recei to Agent status change:`,e.connected,e.status),N.agentPlatform={...N.agentPlatform,connected:e.connected},kD(N.agentPlatform),yp(),fa(),e.connected&&LD()),e.type===`AGENT_CONNECTION_CHANGED`){if(a.debug(`[SidePanel] recei to Agent connection statuschanged:`,e.connected,e.agentId),!e.connected){N.agentPlatform={connected:!1},kD(N.agentPlatform),yp(),fa();return}e.agentId&&(async()=>{try{let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),t=lD(e.pairedAgents).find(t=>t.id===e.activeAgentId&&!t.disabled);if(!t){N.agentPlatform={connected:!1},kD(N.agentPlatform),yp(),fa(),qg();return}if(t.token)try{let n=await fetch(`${t.url}/api/status/detail`,{cache:`no-cache`,headers:{Authorization:`Bearer ${t.token}`}});if(n.ok){let t=await n.json();if(t.success){N.agentPlatform={platformName:t.platformName||`Unknown`,platform:t.platform||`unknown`,arch:t.arch||`unknown`,shell:t.shell||`/bin/sh`,homeDir:t.homeDir||``,workdir:t.workdir||``,connected:!0},t.version&&N.agentVersions.set(e.activeAgentId,t.version),t.workdir&&N.agentWorkdirs.set(e.activeAgentId,t.workdir),t.homeDir&&N.agentHomeDirs.set(e.activeAgentId,t.homeDir);let n=ND(t.platformName||t.platform,t.arch);n&&N.agentSystemInfos.set(e.activeAgentId,n)}else N.agentPlatform={connected:!1}}else N.agentPlatform={connected:!1}}catch{N.agentPlatform={connected:!1}}else try{let n=await fetch(`${t.url}/api/status`,{cache:`no-cache`});if(n.ok){let t=await n.json();N.agentPlatform={platformName:t.platformName||`Unknown`,platform:t.platform||`unknown`,arch:t.arch||`unknown`,shell:t.shell||`/bin/sh`,homeDir:t.homeDir||``,workdir:t.workdir||``,connected:!0},t.version&&N.agentVersions.set(e.activeAgentId,t.version);let r=ND(t.platformName||t.platform,t.arch);r&&N.agentSystemInfos.set(e.activeAgentId,r)}else N.agentPlatform={connected:!1}}catch{N.agentPlatform={connected:!1}}}catch{N.agentPlatform={connected:!1}}kD(N.agentPlatform),yp(),fa(),qg()})()}e.type===`SCREENSHOT_RESULT`&&e.dataUrl&&(a.debug(`[SidePanel] received pageshortcutscreenshotresult:`,e.mode),wp(e.dataUrl,e.mode,e.rect))});async function e(e){try{let t=await chrome.sidePanel.getOptions({tabId:e});return typeof t?.enabled==`boolean`?t.enabled:(await chrome.sidePanel.getOptions({}))?.enabled!==!1}catch{return!0}}chrome.tabs.onActivated.addListener(async t=>{if(a.debug(`[SidePanel] Tab switch, new Tab ID:`,t.tabId),!await e(t.tabId)){a.debug(`[SidePanel] Tab 无侧边栏,保持 currentTabId:`,N.currentTabId);return}N.currentTabId=t.tabId}),chrome.tabs.onUpdated.addListener(async(e,t)=>{t.status===`complete`&&N.currentTabId===e&&a.debug(`[SidePanel] current Tab page update:`,t)}),typeof marked<`u`&&(marked.setOptions({breaks:!0,gfm:!0}),a.debug(`[SidePanel] Marked library loaded`));let t=document.getElementById(`userInput`),n=document.getElementById(`sendBtn`),s=document.getElementById(`clearChatBtn`),l=document.getElementById(`exportChatBtn`),u=document.getElementById(`chatContainer`),d=document.getElementById(`tempDisplay`),f=document.getElementById(`tempDropdown`),p=document.getElementById(`tempPresetList`),m=document.getElementById(`tempSlider`),h=document.getElementById(`tempNumberInput`);function g(){if(!t||N.isScrolling)return;t.style.height=`auto`;let e=t.scrollHeight;e<=50?t.style.height=``:t.style.height=Math.min(e,100)+`px`,pt()}chrome.storage.local.get([`temperature`,`topP`,`selectedTempIndex`],e=>{(!N.activeAgentId||N.activeAgentId==="default")&&(e.temperature!==void 0&&(N.temperature=e.temperature),e.topP!==void 0&&(N.topP=e.topP),e.selectedTempIndex!==void 0&&(N.selectedTempIndex=e.selectedTempIndex)),_()});function _(){m&&(m.value=N.temperature),h&&(h.value=N.temperature.toFixed(2));let e=document.getElementById(`tempIconValue`);e&&(e.textContent=N.temperature.toFixed(2)),y()}function v(){let e=0,t=Math.abs(Tn[0].temp-N.temperature);for(let n=1;n<Tn.length;n++){let r=Math.abs(Tn[n].temp-N.temperature);r<t&&(t=r,e=n)}return e}function y(){let e=v();p.innerHTML=Tn.map((t,n)=>`
|
|
2570
|
+
`}).join(``);let o=document.getElementById(`agentDdRestartBtn`),s=document.getElementById(`agentDdUpdateBtn`),c=document.getElementById(`agentDdStopBtn`),l=!!(e&&n);o&&(o.disabled=!l),s&&(s.disabled=!l),c&&(c.disabled=!l)}async function PD(e,t){if(t)try{let n=new AbortController;setTimeout(()=>n.abort(),2e3);let r=await fetch(`${e}/api/status/detail`,{signal:n.signal,headers:{Authorization:`Bearer ${t}`}});if(r.ok){let e=await r.json();if(e.success)return{online:!0,version:e.version||null,workdir:e.workdir||null,homeDir:e.homeDir||null,platformName:e.platformName||e.platform||null,arch:e.arch||null}}}catch{}try{let t=new AbortController;setTimeout(()=>t.abort(),2e3);let n=await fetch(`${e}/api/status`,{signal:t.signal});if(!n.ok)return{online:!1,version:null,workdir:null,homeDir:null,platformName:null,arch:null};let r=await n.json();return{online:!0,version:r.version||null,workdir:null,homeDir:null,platformName:r.platformName||r.platform||null,arch:r.arch||null}}catch{return{online:!1,version:null,workdir:null,homeDir:null,platformName:null,arch:null}}}function FD(e,t){return e?t&&e.startsWith(t)?`~`+e.substring(t.length):e:``}function ID(e,t){return e||``}function LD(e,t){let n=document.querySelector(`.agent-dd-item[data-agent-id="${e}"]`);if(!n)return;let i=n.querySelector(`.agent-dd-item-dot`),a=n.querySelector(`.agent-dd-item-status`),o=n.classList.contains(`active`);i&&(i.classList.remove(`checking`,`connected`,`disconnected`,`online`,`offline`),i.classList.add(o?t?`connected`:`disconnected`:t?`online`:`offline`)),a&&(o?a.textContent=r(t?`sidePanel.agentConnected`:`sidePanel.notConnected`):a.textContent===r(`sidePanel.agentChecking`)&&(a.textContent=r(t?`sidePanel.agentOnline`:`sidePanel.agentOffline`)))}function RD(e,t){if(!t)return;let n=document.querySelector(`.agent-dd-item[data-agent-id="${e}"]`);if(!n)return;let i=n.querySelector(`.agent-dd-item-info`);if(!i)return;let a=FD(t,N.agentHomeDirs.get(e)),o=i.querySelector(`.agent-dd-item-workdir`);o?(o.textContent=a,o.title=r(`sidePanel.workingDirectory`,{path:t})):(o=document.createElement(`span`),o.className=`agent-dd-item-workdir`,o.title=r(`sidePanel.workingDirectory`,{path:t}),o.textContent=a,i.appendChild(o))}window.updateAgentItemWorkdir=RD;async function zD(){try{let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),t=fD(e.pairedAgents),n=e.activeAgentId;await Promise.all(t.filter(e=>!e.disabled).map(async e=>{let t=await PD(e.url,e.token),r=t.online;t.version&&N.agentVersions.set(e.id,t.version),t.workdir&&N.agentWorkdirs.set(e.id,t.workdir),t.homeDir&&N.agentHomeDirs.set(e.id,t.homeDir);let i=ID(t.platformName,t.arch);i&&N.agentSystemInfos.set(e.id,i),t.workdir&&RD(e.id,t.workdir),LD(e.id,r),e.id===n&&r!==(N.agentPlatform?.connected===!0)&&(N.agentPlatform={...N.agentPlatform,connected:r},MD(N.agentPlatform,!0),r&&BD(e))}))}catch{}}async function BD(e){try{let t=e;if(!t){let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=fD(e.pairedAgents),r=e.activeAgentId;t=n.find(e=>e.id===r&&!e.disabled)}if(!t||!t.url){N.agentPlatform={...N.agentPlatform,connected:!0},MD(N.agentPlatform),yp();return}if(t.token)try{let e=new AbortController;setTimeout(()=>e.abort(),3e3);let n=await fetch(`${t.url}/api/status/detail`,{signal:e.signal,headers:{Authorization:`Bearer ${t.token}`}});if(n.ok){let e=await n.json();if(e.success){N.agentPlatform={platformName:e.platformName||`Unknown`,platform:e.platform||`unknown`,arch:e.arch||`unknown`,shell:e.shell||`/bin/sh`,homeDir:e.homeDir||``,workdir:e.workdir||``,connected:!0},e.version&&N.agentVersions.set(t.id,e.version),e.workdir&&(N.agentWorkdirs.set(t.id,e.workdir),RD(t.id,e.workdir)),e.homeDir&&N.agentHomeDirs.set(t.id,e.homeDir);let n=ID(e.platformName||e.platform,e.arch);n&&N.agentSystemInfos.set(t.id,n),MD(N.agentPlatform),yp();return}}}catch{}try{let e=new AbortController;setTimeout(()=>e.abort(),3e3);let n=await fetch(`${t.url}/api/status`,{signal:e.signal});if(n.ok){let e=await n.json();N.agentPlatform={platformName:e.platformName||e.platform||`Unknown`,platform:e.platform||`unknown`,arch:e.arch||`unknown`,connected:!0},MD(N.agentPlatform),yp();return}}catch{}N.agentPlatform={...N.agentPlatform,connected:!0},MD(N.agentPlatform),yp()}catch{N.agentPlatform={...N.agentPlatform,connected:!0},MD(N.agentPlatform),yp()}}var VD=null;function HD(e,t=20){VD&&clearInterval(VD);let n=0;VD=setInterval(async()=>{if(n++,n>t||!e){clearInterval(VD),VD=null;return}try{let t=fD((await chrome.storage.local.get([`pairedAgents`])).pairedAgents).find(t=>t.id===e);if(!t){clearInterval(VD),VD=null;return}let n=await PD(t.url,t.token);if(n.online){clearInterval(VD),VD=null,n.version&&N.agentVersions.set(e,n.version),n.workdir&&N.agentWorkdirs.set(e,n.workdir),n.homeDir&&N.agentHomeDirs.set(e,n.homeDir);let r=ID(n.platformName,n.arch);r&&N.agentSystemInfos.set(e,r),n.workdir&&RD(e,n.workdir),await BD(t),LD(e,!0)}}catch{}},3e3)}function UD(){let e=document.getElementById(`headerAgentDropdown`),t=document.getElementById(`headerAgentWrapper`);if(!e||!t)return;let n=document.body.clientWidth,r=t.getBoundingClientRect(),i=e.offsetWidth;n<312?(e.style.minWidth=n-16+`px`,e.style.maxWidth=n-16+`px`):(e.style.minWidth=``,e.style.maxWidth=``);let a=r.right+20-i,o=n-i-8;a=Math.max(8,Math.min(o,a)),e.style.left=a-r.left+`px`}async function WD(){let e=document.getElementById(`headerAgentTrigger`),t=document.getElementById(`headerAgentDropdown`),n=document.getElementById(`agentDdCopyBtn`),i=document.getElementById(`agentDdAddBtn`),a=document.getElementById(`agentDdRestartBtn`),o=document.getElementById(`agentDdUpdateBtn`),s=document.getElementById(`agentDdStopBtn`),c=document.getElementById(`agentDdRefreshBtn`);if(!e||!t)return;e.addEventListener(`click`,e=>{e.stopPropagation();let n=t.style.display!==`none`;t.style.display=n?`none`:``,n||(UD(),MD(N.agentPlatform||{}),zD())}),document.addEventListener(`click`,n=>{!t.contains(n.target)&&n.target!==e&&(t.style.display=`none`)}),n.addEventListener(`click`,async e=>{e.stopPropagation(),N.activeAgentId;let t=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=fD(t.pairedAgents).find(e=>e.id===t.activeAgentId);n?.url&&(await navigator.clipboard.writeText(n.url),P(r(`sidePanel.agentAddressCopied`),`success`))}),i.addEventListener(`click`,async()=>{t.style.display=`none`,await chrome.storage.local.set({optionsInitialTab:`agent`});let e=await chrome.tabs.query({}),n=chrome.runtime.getURL(`options/index.html`),r=e.find(e=>e.url&&e.url.startsWith(n));if(r){chrome.tabs.update(r.id,{active:!0});try{chrome.tabs.sendMessage(r.id,{type:`SWITCH_TAB`,tab:`agent`})}catch{}}else chrome.runtime.openOptionsPage()}),a.addEventListener(`click`,async()=>{t.style.display=`none`;let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=fD(e.pairedAgents).find(t=>t.id===e.activeAgentId),i=n?.name||r(`sidePanel.unknownAgent`),a=n?.url||r(`sidePanel.unknownAgent`);if(await window.showCustomConfirm(r(`sidePanel.restartAgentConfirm`,{name:i,url:a}),r(`sidePanel.restartAgentTitle`)))try{chrome.runtime.sendMessage({type:`AGENT_RESTART`},async e=>{e?.success?(P(r(`sidePanel.agentRestarting`),`success`),N.agentPlatform={...N.agentPlatform,connected:!1},await MD(N.agentPlatform,!0),n?.id&&LD(n.id,!1),HD(n?.id)):P(r(`sidePanel.restartFailed`,{error:e?.error||r(`sidePanel.unknownError`)}),`error`)})}catch(e){P(r(`sidePanel.restartRequestFailed`,{error:e.message}),`error`)}}),o.addEventListener(`click`,async()=>{t.style.display=`none`;let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=fD(e.pairedAgents).find(t=>t.id===e.activeAgentId),i=n?.name||r(`sidePanel.unknownAgent`),a=n?.url||r(`sidePanel.unknownAgent`);if(await window.showCustomConfirm(r(`sidePanel.updateAgentConfirm`,{name:i,url:a}),r(`sidePanel.updateAgentTitle`))){P(r(`sidePanel.agentUpdating`),`info`);try{chrome.runtime.sendMessage({type:`AGENT_UPDATE`},async e=>{e?.success?(P(r(`sidePanel.agentUpdateRestarting`),`success`),N.agentPlatform={...N.agentPlatform,connected:!1},await MD(N.agentPlatform,!0),n?.id&&LD(n.id,!1),HD(n?.id)):P(r(`sidePanel.updateFailed`,{error:e?.error||r(`sidePanel.unknownError`)}),`error`)})}catch(e){P(r(`sidePanel.updateRequestFailed`,{error:e.message}),`error`)}}}),s.addEventListener(`click`,async()=>{t.style.display=`none`;let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=fD(e.pairedAgents).find(t=>t.id===e.activeAgentId),i=n?.name||r(`sidePanel.unknownAgent`),a=n?.url||r(`sidePanel.unknownAgent`);if(await window.showCustomConfirm(r(`sidePanel.stopAgentConfirm`,{name:i,url:a}),r(`sidePanel.stopAgentTitle`)))try{chrome.runtime.sendMessage({type:`AGENT_STOP`},async e=>{e?.success?(P(r(`sidePanel.agentStopped`),`success`),N.agentPlatform={...N.agentPlatform,connected:!1},await MD(N.agentPlatform,!0),n?.id&&LD(n.id,!1)):P(r(`sidePanel.stopFailed`,{error:e?.error||r(`sidePanel.unknownError`)}),`error`)})}catch(e){P(r(`sidePanel.stopRequestFailed`,{error:e.message}),`error`)}}),c&&c.addEventListener(`click`,async()=>{document.querySelectorAll(`.agent-dd-item-dot`).forEach(e=>{e.classList.remove(`online`,`offline`),e.classList.add(`checking`)}),document.querySelectorAll(`.agent-dd-item-status`).forEach(e=>{e.textContent=r(`sidePanel.agentChecking`)}),await zD(),P(r(`sidePanel.agentStatusRefreshed`),`success`)}),document.getElementById(`agentDdList`).addEventListener(`click`,async e=>{let t=e.target.closest(`.agent-dd-tool-btn`),n=e.target.closest(`.agent-dd-item`);if(t){e.stopPropagation(),l(t.dataset.action,t.dataset.id);return}n&&!n.classList.contains(`disabled`)&&!n.classList.contains(`active`)&&(e.stopPropagation(),l(`switch`,n.dataset.agentId))});async function l(e,t){let n=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),i=fD(n.pairedAgents);switch(e){case`enable`:i=i.map(e=>e.id===t?{...e,disabled:!1}:e),await chrome.storage.local.set({pairedAgents:i});break;case`disable`:{i=i.map(e=>e.id===t?{...e,disabled:!0}:e);let e=n.activeAgentId;n.activeAgentId===t&&(e=i.find(e=>e.id!==t&&!e.disabled)?.id||null),await chrome.storage.local.set({pairedAgents:i,activeAgentId:e||``}),e?chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!0,agentId:e}):chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!1});break}case`switch`:await chrome.storage.local.set({activeAgentId:t}),chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!0,agentId:t});break;case`disconnect`:await chrome.storage.local.set({activeAgentId:``}),chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!1});break;case`delete`:{let e=i.find(e=>e.id===t);if(!await window.showCustomConfirm(r(`sidePanel.deleteAgentTitle`),r(`sidePanel.deleteAgentConfirm`,{name:e?.name||t})))return;i=i.filter(e=>e.id!==t);let a=n.activeAgentId===t?i.find(e=>!e.disabled)?.id||null:n.activeAgentId;await chrome.storage.local.set({pairedAgents:i,activeAgentId:a||``}),a?chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!0,agentId:a}):chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!1});break}}let a=document.getElementById(`headerAgentDropdown`);a&&(a.style.display=`none`)}}var GD=new Map,KD=8;function qD(e,t){for(GD.has(e)&&GD.delete(e),GD.set(e,t);GD.size>KD;)GD.delete(GD.keys().next().value)}function JD(e){let t=GD.get(e);if(t!==void 0)return GD.delete(e),GD.set(e,t),t}function YD(e){GD.delete(e)}document.addEventListener(`DOMContentLoaded`,async()=>{await Qe(),nt(()=>{Ft()}),lc(),await Promise.allSettled([i().then(()=>{o(),la(),c(()=>{o(),la()})}),yt(),lx(),fi()]),window.__tableBlocks=[],chrome.runtime.onMessage.addListener(e=>{if(e.type===`SCHEDULED_SESSION_UPDATED`){let t=e.sessionId;t===N.activeSessionId?_x().catch(()=>{}):t&&(mi(t).catch(()=>{}),document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:t}})));return}if(e.type===`CLOSE_SIDEPANEL`){a.debug(`[SidePanel] recei to CLOSE_SIDEPANEL,closesidebar`);try{window.close()}catch{}return}if(e.type===`SELECTION_AI_SEARCH`&&e.prompt&&(a.debug(`[SidePanel] received selectedtext AI search:`,e.selectedText?.substring(0,50)),e.selectedText&&kD(e.selectedText),Hx(e.prompt,e.selectedText),chrome.storage.session.remove(`pendingSelectionSearch`).catch(()=>{})),e.type===`FILL_SIDEPANEL_INPUT`&&e.text&&(a.debug(`[SidePanel] received follow-upfill:`,e.text?.substring(0,50)),Ux(e.text),chrome.storage.session.remove(`pendingFillInput`).catch(()=>{})),e.type===`DIRECT_SEND`&&e.text&&(a.debug(`[SidePanel] received directsend:`,e.text?.substring(0,50)),e.selectedText&&kD(e.selectedText),Wx(e.text,e.selectedText||``),chrome.storage.session.remove(`pendingDirectSend`).catch(()=>{})),e.type===`AGENT_STATUS_CHANGE`&&(a.debug(`[SidePanel] recei to Agent status change:`,e.connected,e.status),N.agentPlatform={...N.agentPlatform,connected:e.connected},MD(N.agentPlatform),yp(),fa(),e.connected&&BD()),e.type===`AGENT_CONNECTION_CHANGED`){if(a.debug(`[SidePanel] recei to Agent connection statuschanged:`,e.connected,e.agentId),!e.connected){N.agentPlatform={connected:!1},MD(N.agentPlatform),yp(),fa();return}e.agentId&&(async()=>{try{let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),t=fD(e.pairedAgents).find(t=>t.id===e.activeAgentId&&!t.disabled);if(!t){N.agentPlatform={connected:!1},MD(N.agentPlatform),yp(),fa(),qg();return}if(t.token)try{let n=await fetch(`${t.url}/api/status/detail`,{cache:`no-cache`,headers:{Authorization:`Bearer ${t.token}`}});if(n.ok){let t=await n.json();if(t.success){N.agentPlatform={platformName:t.platformName||`Unknown`,platform:t.platform||`unknown`,arch:t.arch||`unknown`,shell:t.shell||`/bin/sh`,homeDir:t.homeDir||``,workdir:t.workdir||``,connected:!0},t.version&&N.agentVersions.set(e.activeAgentId,t.version),t.workdir&&N.agentWorkdirs.set(e.activeAgentId,t.workdir),t.homeDir&&N.agentHomeDirs.set(e.activeAgentId,t.homeDir);let n=ID(t.platformName||t.platform,t.arch);n&&N.agentSystemInfos.set(e.activeAgentId,n)}else N.agentPlatform={connected:!1}}else N.agentPlatform={connected:!1}}catch{N.agentPlatform={connected:!1}}else try{let n=await fetch(`${t.url}/api/status`,{cache:`no-cache`});if(n.ok){let t=await n.json();N.agentPlatform={platformName:t.platformName||`Unknown`,platform:t.platform||`unknown`,arch:t.arch||`unknown`,shell:t.shell||`/bin/sh`,homeDir:t.homeDir||``,workdir:t.workdir||``,connected:!0},t.version&&N.agentVersions.set(e.activeAgentId,t.version);let r=ID(t.platformName||t.platform,t.arch);r&&N.agentSystemInfos.set(e.activeAgentId,r)}else N.agentPlatform={connected:!1}}catch{N.agentPlatform={connected:!1}}}catch{N.agentPlatform={connected:!1}}MD(N.agentPlatform),yp(),fa(),qg()})()}e.type===`SCREENSHOT_RESULT`&&e.dataUrl&&(a.debug(`[SidePanel] received pageshortcutscreenshotresult:`,e.mode),wp(e.dataUrl,e.mode,e.rect))});async function e(e){try{let t=await chrome.sidePanel.getOptions({tabId:e});return typeof t?.enabled==`boolean`?t.enabled:(await chrome.sidePanel.getOptions({}))?.enabled!==!1}catch{return!0}}chrome.tabs.onActivated.addListener(async t=>{if(a.debug(`[SidePanel] Tab switch, new Tab ID:`,t.tabId),!await e(t.tabId)){a.debug(`[SidePanel] Tab 无侧边栏,保持 currentTabId:`,N.currentTabId);return}N.currentTabId=t.tabId}),chrome.tabs.onUpdated.addListener(async(e,t)=>{t.status===`complete`&&N.currentTabId===e&&a.debug(`[SidePanel] current Tab page update:`,t)}),typeof marked<`u`&&(marked.setOptions({breaks:!0,gfm:!0}),a.debug(`[SidePanel] Marked library loaded`));let t=document.getElementById(`userInput`),n=document.getElementById(`sendBtn`),s=document.getElementById(`clearChatBtn`),l=document.getElementById(`exportChatBtn`),u=document.getElementById(`chatContainer`),d=document.getElementById(`tempDisplay`),f=document.getElementById(`tempDropdown`),p=document.getElementById(`tempPresetList`),m=document.getElementById(`tempSlider`),h=document.getElementById(`tempNumberInput`);function g(){if(!t||N.isScrolling)return;t.style.height=`auto`;let e=t.scrollHeight;e<=50?t.style.height=``:t.style.height=Math.min(e,100)+`px`,pt()}chrome.storage.local.get([`temperature`,`topP`,`selectedTempIndex`],e=>{(!N.activeAgentId||N.activeAgentId==="default")&&(e.temperature!==void 0&&(N.temperature=e.temperature),e.topP!==void 0&&(N.topP=e.topP),e.selectedTempIndex!==void 0&&(N.selectedTempIndex=e.selectedTempIndex)),_()});function _(){m&&(m.value=N.temperature),h&&(h.value=N.temperature.toFixed(2));let e=document.getElementById(`tempIconValue`);e&&(e.textContent=N.temperature.toFixed(2)),y()}function v(){let e=0,t=Math.abs(Tn[0].temp-N.temperature);for(let n=1;n<Tn.length;n++){let r=Math.abs(Tn[n].temp-N.temperature);r<t&&(t=r,e=n)}return e}function y(){let e=v();p.innerHTML=Tn.map((t,n)=>`
|
|
2564
2571
|
<div class="temp-preset-item ${n===e?`selected`:``}" data-index="${n}">
|
|
2565
2572
|
<div class="temp-preset-radio"></div>
|
|
2566
2573
|
<div class="temp-preset-info">
|
|
@@ -2569,15 +2576,15 @@ Are you sure you want to stop the agent service? You will not be able to connect
|
|
|
2569
2576
|
</div>
|
|
2570
2577
|
<div class="temp-preset-value">${t.temp.toFixed(2)}</div>
|
|
2571
2578
|
</div>
|
|
2572
|
-
`).join(``),p.querySelectorAll(`.temp-preset-item`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),C(parseInt(e.dataset.index))})})}function C(e){let t=Tn[e];t&&(N.selectedTempIndex=e,N.temperature=t.temp,_(),
|
|
2579
|
+
`).join(``),p.querySelectorAll(`.temp-preset-item`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),C(parseInt(e.dataset.index))})})}function C(e){let t=Tn[e];t&&(N.selectedTempIndex=e,N.temperature=t.temp,_(),bD(N.temperature,N.topP,N.selectedTempIndex))}m.addEventListener(`input`,e=>{e.stopPropagation();let t=parseFloat(e.target.value);isNaN(t)&&(t=0),t=Math.max(0,Math.min(1,t)),N.temperature=t,h.value=t.toFixed(2);let n=document.getElementById(`tempIconValue`);n&&(n.textContent=t.toFixed(2)),y(),bD(N.temperature,N.topP,v())}),h.addEventListener(`change`,e=>{e.stopPropagation();let t=parseFloat(e.target.value);isNaN(t)&&(t=0),t=Math.max(0,Math.min(1,t)),N.temperature=t,m.value=t,h.value=t.toFixed(2);let n=document.getElementById(`tempIconValue`);n&&(n.textContent=t.toFixed(2)),y(),bD(N.temperature,N.topP,v())}),d&&f&&(d.addEventListener(`click`,e=>{e.stopPropagation(),f.classList.toggle(`show`)}),document.addEventListener(`click`,e=>{let t=document.querySelector(`.temp-selector`);t&&!t.contains(e.target)&&f.classList.remove(`show`)})),u.addEventListener(`mousedown`,e=>{N.lastMouseX=e.clientX,N.lastMouseY=e.clientY}),u.addEventListener(`mouseup`,e=>{N.lastMouseX=e.clientX,N.lastMouseY=e.clientY,N.enableSelectionQuery&&setTimeout(()=>{let e=window.getSelection();if(e&&!e.isCollapsed&&e.toString().trim()){let t=e.toString().trim();u.contains(e.anchorNode)&&(N.lastSelectedText=t,N.currentSelectionRange=e.getRangeAt(0).cloneRange(),kD(t),AD(e,t,N.lastMouseX,N.lastMouseY))}else u.contains(e.anchorNode)||(N.lastSelectedText=``,N.currentSelectionRange=null,window.hideFloatingMenu())},50)});let w=``,T=null;async function E(){try{let e=await new Promise(e=>{chrome.tabs.query({active:!0,currentWindow:!0},t=>e(t))});if(e&&e.length>0){let t=await new Promise(t=>{chrome.tabs.sendMessage(e[0].id,{action:`getSelectedText`},e=>{chrome.runtime.lastError?(console.debug(`[SidePanel] content script not loaded or unreachable:`,chrome.runtime.lastError.message),t(null)):t(e)})});if(!t)return;let n=t?.text||``;n&&n.trim()?n!==w&&(w=n,kD(n.trim())):w=``}}catch{}}function D(){T&&=(clearInterval(T),null),N.enableSelectionQuery&&(T=setInterval(E,500))}D(),chrome.storage.onChanged.addListener((e,t)=>{if(t===`local`&&`enableSelectionQuery`in e){N.enableSelectionQuery=e.enableSelectionQuery.newValue;let t=document.getElementById(`enableSelectionQueryBtn`);t&&(t.checked=N.enableSelectionQuery),D()}}),await S(),_T(),chrome.storage.local.get([`modelName`,`customModels`,`customPrompts`,`systemPrompt`,`inputHistory`,`agentPlatform`,`enableImageInput`,`imageModelName`,`imageApiBase`,`imageApiKey`,`enableFileInput`],e=>{let t=e.modelName;t&&(N.currentModel=t),N.customPrompts=e.customPrompts||[],N.systemPrompt=e.systemPrompt||``,N.inputHistory=e.inputHistory||[],e.agentPlatform&&(N.agentPlatform=e.agentPlatform),MD(N.agentPlatform),chrome.runtime.sendMessage({type:`TRIGGER_AGENT_HEALTH_CHECK`}).catch(()=>{}),yD(),N.enableImageInput=e.enableImageInput||!1,N.imageModelName=e.imageModelName||``,N.imageApiBase=e.imageApiBase||``,N.imageApiKey=x(e.imageApiKey)||``,N.enableFileInput=!0,_p(),yp(),mS(),OD(e.customModels,()=>{t&&DD(t)})}),chrome.storage.onChanged.addListener((e,t)=>{if(t===`local`){if(e.customModels&&OD(e.customModels.newValue||[],()=>{DD(N.currentModel)}),e.modelName){let t=e.modelName.newValue;t&&(!N.activeAgentId||N.activeAgentId==="default")&&(N.currentModel=t,DD(t))}if(e.enableImageInput&&(N.enableImageInput=e.enableImageInput.newValue,_p()),e.enableFileInput&&(N.enableFileInput=e.enableFileInput.newValue,yp()),e.enableExecutionLog&&(N.chatConfig.enableExecutionLog=e.enableExecutionLog.newValue),e.showMessageTimestamp){let t=e.showMessageTimestamp.newValue!==!1;N.chatConfig.showMessageTimestamp=t,Yx(t)}e.systemPrompt&&(N.systemPrompt=e.systemPrompt.newValue||``),e.imageModelName&&(N.imageModelName=e.imageModelName.newValue||``),e.imageApiBase&&(N.imageApiBase=e.imageApiBase.newValue||``),e.imageApiKey&&(N.imageApiKey=x(e.imageApiKey.newValue)||``)}}),await _x(),await rD();let O=await chrome.storage.session.get([`pendingSelectionSearch`,`pendingFillInput`,`pendingDirectSend`]),k=[];if(O.pendingSelectionSearch&&O.pendingSelectionSearch.selectedText){let{prompt:e,selectedText:t}=O.pendingSelectionSearch;a.debug(`[SidePanel] pending selected textsearch:`,t?.substring(0,50)),kD(t),setTimeout(()=>{Hx(e,t)},500),k.push(`pendingSelectionSearch`)}if(O.pendingFillInput&&O.pendingFillInput.text){let{text:e}=O.pendingFillInput;a.debug(`[SidePanel] pending fill trackasktext:`,e?.substring(0,50)),setTimeout(()=>{Ux(e)},500),k.push(`pendingFillInput`)}if(O.pendingDirectSend&&O.pendingDirectSend.text){let{text:e,selectedText:t}=O.pendingDirectSend;a.debug(`[SidePanel] pending directsend text:`,e?.substring(0,50)),t&&kD(t),setTimeout(()=>{Wx(e,t||``)},500),k.push(`pendingDirectSend`)}k.length>0&&await chrome.storage.session.remove(k);let A=document.getElementById(`userInput`);A&&A.focus(),document.addEventListener(`session-switched`,e=>{let{sessionId:t,previousSessionId:n}=e.detail||{},i=document.getElementById(`chatContainer`),o=document.getElementById(`userInput`);if(!i)return;let s=n&&N.messageHistory?.some(e=>e.resumable);if(n&&!N.pendingCallApiSessionIds.has(n)&&!s){let e=Iy(i);e&&qD(n,e)}let c=document.getElementById(`imagePreviewBar`);N.attachedImages.length>0&&c&&c.style.display===`none`&&(N.attachedImages=[]),N.executionLogListener&&=(chrome.runtime.onMessage.removeListener(N.executionLogListener),null),te(),o&&o.focus();let l=N.pendingCallApiSessionIds.has(t)&&!!N.pendingCancelApi,u=JD(t),d=N.messageHistory&&N.messageHistory.length>0;if(u&&!l&&d){if(i.innerHTML=u,iS(i),Bt(),qt(),!e.detail?.skipScrollRestore){let e=`scrollPosition_`+(t||`default`);chrome.storage.local.get([e],t=>{t[e]!==void 0&&setTimeout(()=>{let n=document.getElementById(`chatContainer`);n&&(n.scrollTop=t[e])},150)})}vb();return}if(i.innerHTML=``,d){if(N.messageHistory.forEach(e=>{e.htmlContent?rS(e.htmlContent,e.messageId,e.resumable):Jx(e.role,e.content,!1,e.executionLog||[],e.reflectionScore,e.wasRevised,null,e.messageId,[],!1,e.timestamp??null)}),Zx(),$x(),Bt(),qt(),!N.pendingCallApiSessionIds.has(t)){let e=Iy(i);e&&qD(t,e)}vb()}else{let e=document.createElement(`div`);e.className=`welcome-message`,e.innerHTML=`
|
|
2573
2580
|
<div class="icon-wrapper">
|
|
2574
2581
|
<div class="icon">💬</div>
|
|
2575
2582
|
</div>
|
|
2576
2583
|
<h2>${r(`sidePanel.welcomeTitle`)}</h2>
|
|
2577
2584
|
<p>${r(`sidePanel.welcomeSubtitle`)}</p>
|
|
2578
|
-
`,i.appendChild(e)}if(a.debug(`[SidePanel] session-switched: pendingTask?`,l,`pendingSessionIds:`,[...N.pendingCallApiSessionIds],`activeSessionId:`,t,`hasCancelApi:`,!!N.pendingCancelApi),l&&(a.debug(`[SidePanel] switch back tobackground task session,rebuildstreamingoutput element`),Yb(t)),!e.detail?.skipScrollRestore){let e=`scrollPosition_`+(t||`default`);chrome.storage.local.get([e],t=>{t[e]!==void 0&&setTimeout(async()=>{let n=document.getElementById(`chatContainer`);n&&(n.scrollTop=t[e]);let{updateScrollButtonState:r}=await M(async()=>{let{updateScrollButtonState:e}=await Promise.resolve().then(()=>vb);return{updateScrollButtonState:e}},void 0);r()},150)})}}),document.addEventListener(`session-cache-invalidate`,e=>{let{sessionId:t}=e.detail||{};t&&KD(t)}),document.querySelectorAll(`.model-option`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let n=e.dataset.value;N.currentModel=n,wD(n),hD(n),sw()})}),document.addEventListener(`agent-model-changed`,()=>{wD(N.currentModel);let e=document.getElementById(`tempSlider`),t=document.getElementById(`tempNumberInput`),n=document.getElementById(`tempIconValue`);e&&(e.value=N.temperature),t&&(t.value=N.temperature.toFixed(2)),n&&(n.textContent=N.temperature.toFixed(2)),y()}),document.addEventListener(`click`,e=>{let t=document.getElementById(`promptDropdown`),n=document.getElementById(`promptSelector`),r=document.getElementById(`agentAtSelector`),i=document.getElementById(`selectionFloatingMenu`);n.contains(e.target)||(t.classList.remove(`show`),pS()),r&&!r.contains(e.target)&&jv();let a=document.getElementById(`fileAtSelector`);if(a&&!a.contains(e.target)&&RT(),i&&!i.contains(e.target)){let t=window.getSelection(),n=u.contains(e.target),r=t&&!t.isCollapsed&&u.contains(t.anchorNode);(!n||!r)&&window.hideFloatingMenu()}});let j=document.getElementById(`stopCompanionBtn`);function ee(){let e=!!(t&&t.value&&t.value.trim());return N.isGenerating&&e}function te(){t&&t.value&&t.value.trim();let e=N.isGenerating,i=ee();n.classList.toggle(`queue-mode`,i),n.classList.toggle(`stop-mode`,e&&!i),i?(n.innerHTML=`<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h11"/><path d="M3 12h11"/><path d="M3 18h7"/><path d="M17.5 10v8"/><path d="M14.5 15.5L17.5 18.5l3-3"/></svg>`,n.title=r(`queue.enqueueBtn`)):e?(n.innerHTML=`<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect></svg>`,n.title=r(`sidePanel.sendBtnStop`)):(n.innerHTML=`<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor"><path d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8-8-8z"/></svg>`,n.title=r(`sidePanel.sendBtnSend`)),n.disabled=!1,n.style.opacity=``,n.style.cursor=``,j&&(j.style.display=i?``:`none`,j.disabled=!1,j.style.opacity=``,j.style.cursor=``)}n.addEventListener(`click`,()=>{if(!N.isGenerating){Rx();return}t&&t.value&&t.value.trim()?hu():nx(n)}),j?.addEventListener(`click`,()=>nx(j));function ne(e){if(!N.isGenerating)return!1;let t=N.activeSessionId;return t?xu(t)?(bu(t),nx(j&&j.style.display!==`none`?j:e||n)?(P(r(`queue.stopAndSendStarted`),`success`,2500),!0):(Su(t),!0)):(P(r(`queue.stopAndSendEmpty`),`warning`,3e3),!1):!1}function re(e,{isPrimarySend:t=!1}={}){if(!e)return;let n=()=>t&&ee();e.addEventListener(`contextmenu`,t=>{n()||!N.isGenerating||!xu(N.activeSessionId)||(t.preventDefault(),ne(e))});let r=null,i=()=>{r&&=(clearTimeout(r),null)};e.addEventListener(`pointerdown`,t=>{t.pointerType===`mouse`&&t.button!==0||n()||!N.isGenerating||!xu(N.activeSessionId)||(i(),r=setTimeout(()=>{r=null,ne(e)},600))});for(let t of[`pointerup`,`pointerleave`,`pointercancel`])e.addEventListener(t,i)}re(n,{isPrimarySend:!0}),re(j),document.addEventListener(`queue-stop-and-send`,()=>{ne(j&&j.style.display!==`none`?j:n)}),document.addEventListener(`generating-state-changed`,te),t.addEventListener(`input`,te),document.addEventListener(`voice-draft-written`,te);let ie=document.getElementById(`shortcutsBtn`),ae=document.getElementById(`shortcutsModal`),oe=document.getElementById(`shortcutsCloseBtn`);function se(){ae&&(ae.style.display=`flex`)}function ce(){ae&&(ae.style.display=`none`)}ie&&ie.addEventListener(`click`,e=>{e.stopPropagation(),se();let t=document.getElementById(`headerMoreDropdown`);t&&t.classList.remove(`show`)}),oe&&oe.addEventListener(`click`,ce),ae&&ae.addEventListener(`click`,e=>{e.target===ae&&ce()});let le=Tw();Qy(),Jl({adjustInputHeight:g}).catch(e=>{a.warn(`[SidePanel] initVoiceInput failed:`,e?.message||e)}),document.addEventListener(`keydown`,e=>{if((e.ctrlKey||e.metaKey)&&e.key===`t`){e.preventDefault();let t=document.getElementById(`toolsPopup`);t&&t.style.display!==`none`?Yi():Ji()}if(e.key===`Escape`&&Ul()){e.preventDefault();return}if(!(e.key===`Escape`&&le.handleEscape())){if(e.key===`Escape`&&ae&&ae.style.display!==`none`){ce();return}if(e.altKey&&e.code===`Slash`){e.preventDefault(),se();return}if(e.altKey&&!e.shiftKey&&e.code===`KeyS`&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),xp();return}if(e.altKey&&e.shiftKey&&e.code===`KeyS`&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),Sp();return}if(sl(e)){e.preventDefault(),Vl();return}if(e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyN`){e.preventDefault(),Ao();return}if(e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyW`){e.preventDefault(),ms();return}if(e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyE`){e.preventDefault();let t=document.querySelectorAll(`#chatContainer .message.user`),n=t[t.length-1];if(n){sS(n);let e=document.getElementById(`userInput`);e&&e.focus()}return}if(e.altKey&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){e.preventDefault();let t=e.key===`ArrowUp`?`prev`:`next`;le.jumpToMessage(t,e.ctrlKey||e.metaKey),le.updateActiveQuestion();return}}}),t.addEventListener(`keydown`,e=>{let n=document.getElementById(`promptSelector`),r=document.getElementById(`promptDropdown`),i=document.getElementById(`agentAtSelector`),a=document.getElementById(`agentAtDropdown`);if(i.style.display!==`none`&&a.classList.contains(`show`)){let t=document.getElementById(`agentAtTabs`),n=t&&t.classList.contains(`merged-mode`);if(!n&&e.key===`Tab`){e.preventDefault();let t=Array.from(document.querySelectorAll(`#agentAtTabs .prompt-tab`)).map(e=>e.dataset.tab),n=e=>{let t=document.querySelector(`#agentAtTabs .prompt-tab[data-tab="${e}"]`);return!!t&&t.style.display!==`none`},r=t.indexOf(Q);for(let e=0;e<t.length;e++)if(r=(r+1)%t.length,n(t[r])){Nv(t[r]);break}return}let r,i;n?(r=document.getElementById(`agentAtList`),i=N.selectedAgentAtIndex):Q===`pages`?(r=document.getElementById(`agentPageList`),i=N.selectedPageIndex):Q===`proxies`?(r=document.getElementById(`agentProxyList`),i=N.selectedProxyAtIndex):Q===`knowledge`?(r=document.getElementById(`agentKnowledgeList`),i=N.selectedKnowledgeAtIndex):(r=document.getElementById(`agentAtList`),i=N.selectedAgentAtIndex);let a=r?r.querySelectorAll(`.prompt-item`):[],o=a.length;if(o!==0){if(e.key===`ArrowDown`){e.preventDefault();let t=i<0?0:(i+1)%o;n?(N.selectedAgentAtIndex=t,qv(a)):Q===`proxies`?(N.selectedProxyAtIndex=t,qv(a)):Q===`knowledge`?(N.selectedKnowledgeAtIndex=t,qv(a)):Q===`pages`?(N.selectedPageIndex=t,my(a)):(N.selectedAgentAtIndex=t,qv(a));return}else if(e.key===`ArrowUp`){e.preventDefault();let t=i<0||i===0?o-1:i-1;n?(N.selectedAgentAtIndex=t,qv(a)):Q===`proxies`?(N.selectedProxyAtIndex=t,qv(a)):Q===`knowledge`?(N.selectedKnowledgeAtIndex=t,qv(a)):Q===`pages`?(N.selectedPageIndex=t,my(a)):(N.selectedAgentAtIndex=t,qv(a));return}else if(e.key===`Enter`&&i>=0){e.preventDefault(),a[i].click(),(e.ctrlKey||e.metaKey)&&jv();return}else if(e.key===`Escape`){jv();return}}}let o=document.getElementById(`fileAtSelector`),s=document.getElementById(`fileAtDropdown`);if(o&&s&&o.style.display!==`none`&&s.classList.contains(`show`)){let t=document.getElementById(`fileAtList`),n=t?t.querySelectorAll(`.prompt-item`):[],r=n.length;if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),r>0&&(N.selectedFileAtIndex=e.key===`ArrowDown`?N.selectedFileAtIndex<0?0:(N.selectedFileAtIndex+1)%r:N.selectedFileAtIndex<0||N.selectedFileAtIndex===0?r-1:N.selectedFileAtIndex-1,UT(n));return}if(e.key===`Enter`&&r>0&&N.selectedFileAtIndex>=0){e.preventDefault(),n[N.selectedFileAtIndex].click();return}if(e.key===`Escape`){e.preventDefault(),RT();return}}if(n.style.display!==`none`&&r.classList.contains(`show`)){if(N.showMergedList){let t=r.querySelectorAll(`#promptList .prompt-item`),n=t.length;if(e.key===`ArrowDown`){e.preventDefault(),N.selectedPromptIndex<0?N.selectedPromptIndex=0:N.selectedPromptIndex=(N.selectedPromptIndex+1)%n,vS(t);return}if(e.key===`ArrowUp`){e.preventDefault(),N.selectedPromptIndex<0||N.selectedPromptIndex===0?N.selectedPromptIndex=n-1:--N.selectedPromptIndex,vS(t);return}if(e.key===`Enter`&&N.selectedPromptIndex>=0){e.preventDefault();let n=t[N.selectedPromptIndex];n.dataset.type===`skill`||n.dataset.type===`mcp`?(n.click(),(e.ctrlKey||e.metaKey)&&pS()):e.ctrlKey||e.metaKey?yS(n.dataset.code):bS(n.dataset.code);return}if(e.key===`Escape`){pS();return}return}if(N.activeDropdownTab===`skills`){let t=r.querySelectorAll(`#skillList .skill-list-item`),n=t.length;if(e.key===`ArrowDown`){e.preventDefault(),N.selectedSkillIndex<0?N.selectedSkillIndex=0:N.selectedSkillIndex=(N.selectedSkillIndex+1)%n,BS(t);return}if(e.key===`ArrowUp`){e.preventDefault(),N.selectedSkillIndex<0||N.selectedSkillIndex===0?N.selectedSkillIndex=n-1:--N.selectedSkillIndex,BS(t);return}if(e.key===`Enter`&&N.selectedSkillIndex>=0){e.preventDefault(),t[N.selectedSkillIndex].click(),(e.ctrlKey||e.metaKey)&&pS();return}if(e.key===`Escape`){pS();return}if(e.key===`Tab`){e.preventDefault();let t=document.getElementById(`mcpTab`);t&&t.style.display!==`none`?qS(`mcp`):qS(`prompts`);return}return}if(N.activeDropdownTab===`mcp`){let t=r.querySelectorAll(`#mcpList .mcp-list-item`),n=t.length;if(e.key===`ArrowDown`){e.preventDefault(),N.selectedMcpServiceIndex<0?N.selectedMcpServiceIndex=0:N.selectedMcpServiceIndex=(N.selectedMcpServiceIndex+1)%n,eC(t);return}if(e.key===`ArrowUp`){e.preventDefault(),N.selectedMcpServiceIndex<0||N.selectedMcpServiceIndex===0?N.selectedMcpServiceIndex=n-1:--N.selectedMcpServiceIndex,eC(t);return}if(e.key===`Enter`&&N.selectedMcpServiceIndex>=0){e.preventDefault(),t[N.selectedMcpServiceIndex].click(),(e.ctrlKey||e.metaKey)&&pS();return}if(e.key===`Escape`){pS();return}if(e.key===`Tab`){e.preventDefault(),qS(`prompts`);return}return}let t=r.querySelectorAll(`#promptList .prompt-item`),n=t.length;if(e.key===`Tab`){let t=document.getElementById(`skillsTab`),n=document.getElementById(`mcpTab`);if(t&&t.style.display!==`none`){e.preventDefault(),qS(`skills`);return}if(n&&n.style.display!==`none`){e.preventDefault(),qS(`mcp`);return}}if(n!==0&&e.key===`ArrowDown`){e.preventDefault(),N.selectedPromptIndex<0?N.selectedPromptIndex=0:N.selectedPromptIndex=(N.selectedPromptIndex+1)%n,vS(t);return}if(e.key===`ArrowUp`){e.preventDefault(),N.selectedPromptIndex<0||N.selectedPromptIndex===0?N.selectedPromptIndex=n-1:--N.selectedPromptIndex,vS(t);return}if(e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&N.selectedPromptIndex>=0){e.preventDefault();let n=t[N.selectedPromptIndex].dataset.code;yS(n);return}if(e.key===`Enter`&&N.selectedPromptIndex>=0){e.preventDefault();let n=t[N.selectedPromptIndex].dataset.code;bS(n);return}if(e.key===`Escape`){pS();return}}if(e.key===`Escape`){N.inputHistoryIndex>=0&&(N.inputHistoryIndex=-1),t.value&&(t.value=``,t.style.height=`auto`,t.dispatchEvent(new Event(`input`))),e.preventDefault();return}let c=n.style.display!==`none`&&r.classList.contains(`show`),l=i.style.display!==`none`&&a.classList.contains(`show`),u=o.style.display!==`none`&&s.classList.contains(`show`);if(e.key===`ArrowUp`&&N.inputHistoryIndex===-1&&!t.value.trim()&&!ou()&&JE()){e.preventDefault();return}if(!c&&!l&&!u){let n=TE({key:e.key,value:t.value,caret:t.selectionStart,history:N.inputHistory,index:N.inputHistoryIndex});if(n.handled){e.preventDefault(),N.inputHistoryIndex=n.index,t.value=n.value,t.dispatchEvent(new Event(`input`)),t.setSelectionRange(n.value.length,n.value.length);return}}if(e.key===`Enter`&&!e.shiftKey){if(N.isComposing)return;if(e.preventDefault(),RT(),N.isGenerating){if(e.altKey){Fu(t.value);return}hu();return}Rx()}}),t.addEventListener(`compositionstart`,()=>{N.isComposing=!0}),t.addEventListener(`compositionend`,()=>{N.isComposing=!1}),t.addEventListener(`paste`,e=>{let t=e.clipboardData?.items;if(t)for(let n of t){if(n.type.startsWith(`image/`)&&N.enableImageInput){e.preventDefault();let t=n.getAsFile();t&&lf(t);break}if(n.kind===`file`&&N.enableFileInput){e.preventDefault();let t=n.getAsFile();t&&Xf([t]);break}}});let ue=document.getElementById(`fileAttachBtn`),de=document.getElementById(`fileInput`);ue&&de&&(ue.addEventListener(`click`,()=>{de.click()}),de.addEventListener(`change`,async()=>{if(de.files.length>0){let e=Array.from(de.files),t=e.filter(e=>e.type.startsWith(`image/`)),n=e.filter(e=>!e.type.startsWith(`image/`));if(t.length>0)if(N.enableImageInput)for(let e of t)await lf(e);else P(r(`sidePanel.imageNotEnabled`)),Xf(t);n.length>0&&Xf(n),de.value=``}}));let fe=document.querySelector(`.input-wrapper`),pe=0;fe&&(fe.addEventListener(`dragenter`,e=>{e.preventDefault(),e.stopPropagation(),pe++,fe.classList.add(`drag-over`)}),fe.addEventListener(`dragleave`,e=>{e.preventDefault(),e.stopPropagation(),pe--,pe<=0&&(pe=0,fe.classList.remove(`drag-over`))}),fe.addEventListener(`dragover`,e=>{e.preventDefault(),e.stopPropagation()}),fe.addEventListener(`drop`,async e=>{e.preventDefault(),e.stopPropagation(),pe=0,fe.classList.remove(`drag-over`);let n=e.dataTransfer.getData(`application/x-workspace-file`);if(n){e.preventDefault();try{let{path:e}=JSON.parse(n);if(e){j_([e]);return}}catch(e){a.warn(`[SidePanel] parse workspace dragdata failed:`,e)}}let i=Array.from(e.dataTransfer.files);if(i.length>0){e.preventDefault();let t=i.filter(e=>e.type.startsWith(`image/`)),n=i.filter(e=>!e.type.startsWith(`image/`));if(t.length>0)if(N.enableImageInput)for(let e of t)await lf(e);else P(r(`sidePanel.imageNotEnabled`)),Xf(t);n.length>0&&Xf(n);return}let o=e.dataTransfer.getData(`text/plain`);if(o&&(e.preventDefault(),t)){t.focus();let e=t.selectionStart??t.value.length,n=t.selectionEnd??t.value.length;t.value=t.value.slice(0,e)+o+t.value.slice(n),t.selectionStart=t.selectionEnd=e+o.length,t.dispatchEvent(new Event(`input`))}}));let me=document.getElementById(`screenshotBtn`);me&&me.addEventListener(`click`,async()=>{if(N.enableImageInput)try{await xp()}catch(e){a.error(`[SidePanel] screenshot failed:`,e),P(r(`sidePanel.screenshotFailed`))}}),sf(),t.addEventListener(`wheel`,e=>{N.isScrolling=!0;let n=t.style.height||t.offsetHeight+`px`;t.style.height=n,t.scrollHeight<=t.clientHeight+10&&(e.preventDefault(),e.stopPropagation()),setTimeout(()=>{N.isScrolling=!1},100)},{passive:!1}),t.addEventListener(`input`,e=>{let n=t.value,r=document.getElementById(`promptSelector`),i=document.getElementById(`promptDropdown`);document.getElementById(`agentAtSelector`),document.getElementById(`agentAtDropdown`);let a=n.lastIndexOf(`/`),o=n.lastIndexOf(`@`),s=n.lastIndexOf(`$`),c=e=>{if(e===-1||e!==0&&n[e-1]!==`
|
|
2585
|
+
`,i.appendChild(e)}if(a.debug(`[SidePanel] session-switched: pendingTask?`,l,`pendingSessionIds:`,[...N.pendingCallApiSessionIds],`activeSessionId:`,t,`hasCancelApi:`,!!N.pendingCancelApi),l&&(a.debug(`[SidePanel] switch back tobackground task session,rebuildstreamingoutput element`),Zb(t)),!e.detail?.skipScrollRestore){let e=`scrollPosition_`+(t||`default`);chrome.storage.local.get([e],t=>{t[e]!==void 0&&setTimeout(async()=>{let n=document.getElementById(`chatContainer`);n&&(n.scrollTop=t[e]);let{updateScrollButtonState:r}=await M(async()=>{let{updateScrollButtonState:e}=await Promise.resolve().then(()=>bb);return{updateScrollButtonState:e}},void 0);r()},150)})}}),document.addEventListener(`session-cache-invalidate`,e=>{let{sessionId:t}=e.detail||{};t&&YD(t)}),document.querySelectorAll(`.model-option`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let n=e.dataset.value;N.currentModel=n,DD(n),vD(n),uw()})}),document.addEventListener(`agent-model-changed`,()=>{DD(N.currentModel);let e=document.getElementById(`tempSlider`),t=document.getElementById(`tempNumberInput`),n=document.getElementById(`tempIconValue`);e&&(e.value=N.temperature),t&&(t.value=N.temperature.toFixed(2)),n&&(n.textContent=N.temperature.toFixed(2)),y()}),document.addEventListener(`click`,e=>{let t=document.getElementById(`promptDropdown`),n=document.getElementById(`promptSelector`),r=document.getElementById(`agentAtSelector`),i=document.getElementById(`selectionFloatingMenu`);n.contains(e.target)||(t.classList.remove(`show`),gS()),r&&!r.contains(e.target)&&Nv();let a=document.getElementById(`fileAtSelector`);if(a&&!a.contains(e.target)&&VT(),i&&!i.contains(e.target)){let t=window.getSelection(),n=u.contains(e.target),r=t&&!t.isCollapsed&&u.contains(t.anchorNode);(!n||!r)&&window.hideFloatingMenu()}});let j=document.getElementById(`stopCompanionBtn`);function ee(){let e=!!(t&&t.value&&t.value.trim());return N.isGenerating&&e}function te(){t&&t.value&&t.value.trim();let e=N.isGenerating,i=ee();n.classList.toggle(`queue-mode`,i),n.classList.toggle(`stop-mode`,e&&!i),i?(n.innerHTML=`<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h11"/><path d="M3 12h11"/><path d="M3 18h7"/><path d="M17.5 10v8"/><path d="M14.5 15.5L17.5 18.5l3-3"/></svg>`,n.title=r(`queue.enqueueBtn`)):e?(n.innerHTML=`<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect></svg>`,n.title=r(`sidePanel.sendBtnStop`)):(n.innerHTML=`<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor"><path d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8-8-8z"/></svg>`,n.title=r(`sidePanel.sendBtnSend`)),n.disabled=!1,n.style.opacity=``,n.style.cursor=``,j&&(j.style.display=i?``:`none`,j.disabled=!1,j.style.opacity=``,j.style.cursor=``)}n.addEventListener(`click`,()=>{if(!N.isGenerating){Vx();return}t&&t.value&&t.value.trim()?hu():ax(n)}),j?.addEventListener(`click`,()=>ax(j));function ne(e){if(!N.isGenerating)return!1;let t=N.activeSessionId;return t?xu(t)?(bu(t),ax(j&&j.style.display!==`none`?j:e||n)?(P(r(`queue.stopAndSendStarted`),`success`,2500),!0):(Su(t),!0)):(P(r(`queue.stopAndSendEmpty`),`warning`,3e3),!1):!1}function re(e,{isPrimarySend:t=!1}={}){if(!e)return;let n=()=>t&&ee();e.addEventListener(`contextmenu`,t=>{n()||!N.isGenerating||!xu(N.activeSessionId)||(t.preventDefault(),ne(e))});let r=null,i=()=>{r&&=(clearTimeout(r),null)};e.addEventListener(`pointerdown`,t=>{t.pointerType===`mouse`&&t.button!==0||n()||!N.isGenerating||!xu(N.activeSessionId)||(i(),r=setTimeout(()=>{r=null,ne(e)},600))});for(let t of[`pointerup`,`pointerleave`,`pointercancel`])e.addEventListener(t,i)}re(n,{isPrimarySend:!0}),re(j),document.addEventListener(`queue-stop-and-send`,()=>{ne(j&&j.style.display!==`none`?j:n)}),document.addEventListener(`generating-state-changed`,te),t.addEventListener(`input`,te),document.addEventListener(`voice-draft-written`,te);let ie=document.getElementById(`shortcutsBtn`),ae=document.getElementById(`shortcutsModal`),oe=document.getElementById(`shortcutsCloseBtn`);function se(){ae&&(ae.style.display=`flex`)}function ce(){ae&&(ae.style.display=`none`)}ie&&ie.addEventListener(`click`,e=>{e.stopPropagation(),se();let t=document.getElementById(`headerMoreDropdown`);t&&t.classList.remove(`show`)}),oe&&oe.addEventListener(`click`,ce),ae&&ae.addEventListener(`click`,e=>{e.target===ae&&ce()});let le=Ow();eb(),Jl({adjustInputHeight:g}).catch(e=>{a.warn(`[SidePanel] initVoiceInput failed:`,e?.message||e)}),document.addEventListener(`keydown`,e=>{if((e.ctrlKey||e.metaKey)&&e.key===`t`){e.preventDefault();let t=document.getElementById(`toolsPopup`);t&&t.style.display!==`none`?Yi():Ji()}if(e.key===`Escape`&&Ul()){e.preventDefault();return}if(!(e.key===`Escape`&&le.handleEscape())){if(e.key===`Escape`&&ae&&ae.style.display!==`none`){ce();return}if(e.altKey&&e.code===`Slash`){e.preventDefault(),se();return}if(e.altKey&&!e.shiftKey&&e.code===`KeyS`&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),xp();return}if(e.altKey&&e.shiftKey&&e.code===`KeyS`&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),Sp();return}if(sl(e)){e.preventDefault(),Vl();return}if(e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyN`){e.preventDefault(),Ao();return}if(e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyW`){e.preventDefault(),ms();return}if(e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyE`){e.preventDefault();let t=document.querySelectorAll(`#chatContainer .message.user`),n=t[t.length-1];if(n){uS(n);let e=document.getElementById(`userInput`);e&&e.focus()}return}if(e.altKey&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){e.preventDefault();let t=e.key===`ArrowUp`?`prev`:`next`;le.jumpToMessage(t,e.ctrlKey||e.metaKey),le.updateActiveQuestion();return}}}),t.addEventListener(`keydown`,e=>{let n=document.getElementById(`promptSelector`),r=document.getElementById(`promptDropdown`),i=document.getElementById(`agentAtSelector`),a=document.getElementById(`agentAtDropdown`);if(i.style.display!==`none`&&a.classList.contains(`show`)){let t=document.getElementById(`agentAtTabs`),n=t&&t.classList.contains(`merged-mode`);if(!n&&e.key===`Tab`){e.preventDefault();let t=Array.from(document.querySelectorAll(`#agentAtTabs .prompt-tab`)).map(e=>e.dataset.tab),n=e=>{let t=document.querySelector(`#agentAtTabs .prompt-tab[data-tab="${e}"]`);return!!t&&t.style.display!==`none`},r=t.indexOf(Q);for(let e=0;e<t.length;e++)if(r=(r+1)%t.length,n(t[r])){Fv(t[r]);break}return}let r,i;n?(r=document.getElementById(`agentAtList`),i=N.selectedAgentAtIndex):Q===`pages`?(r=document.getElementById(`agentPageList`),i=N.selectedPageIndex):Q===`proxies`?(r=document.getElementById(`agentProxyList`),i=N.selectedProxyAtIndex):Q===`knowledge`?(r=document.getElementById(`agentKnowledgeList`),i=N.selectedKnowledgeAtIndex):(r=document.getElementById(`agentAtList`),i=N.selectedAgentAtIndex);let a=r?r.querySelectorAll(`.prompt-item`):[],o=a.length;if(o!==0){if(e.key===`ArrowDown`){e.preventDefault();let t=i<0?0:(i+1)%o;n?(N.selectedAgentAtIndex=t,Yv(a)):Q===`proxies`?(N.selectedProxyAtIndex=t,Yv(a)):Q===`knowledge`?(N.selectedKnowledgeAtIndex=t,Yv(a)):Q===`pages`?(N.selectedPageIndex=t,gy(a)):(N.selectedAgentAtIndex=t,Yv(a));return}else if(e.key===`ArrowUp`){e.preventDefault();let t=i<0||i===0?o-1:i-1;n?(N.selectedAgentAtIndex=t,Yv(a)):Q===`proxies`?(N.selectedProxyAtIndex=t,Yv(a)):Q===`knowledge`?(N.selectedKnowledgeAtIndex=t,Yv(a)):Q===`pages`?(N.selectedPageIndex=t,gy(a)):(N.selectedAgentAtIndex=t,Yv(a));return}else if(e.key===`Enter`&&i>=0){e.preventDefault(),a[i].click(),(e.ctrlKey||e.metaKey)&&Nv();return}else if(e.key===`Escape`){Nv();return}}}let o=document.getElementById(`fileAtSelector`),s=document.getElementById(`fileAtDropdown`);if(o&&s&&o.style.display!==`none`&&s.classList.contains(`show`)){let t=document.getElementById(`fileAtList`),n=t?t.querySelectorAll(`.prompt-item`):[],r=n.length;if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),r>0&&(N.selectedFileAtIndex=e.key===`ArrowDown`?N.selectedFileAtIndex<0?0:(N.selectedFileAtIndex+1)%r:N.selectedFileAtIndex<0||N.selectedFileAtIndex===0?r-1:N.selectedFileAtIndex-1,KT(n));return}if(e.key===`Enter`&&r>0&&N.selectedFileAtIndex>=0){e.preventDefault(),n[N.selectedFileAtIndex].click();return}if(e.key===`Escape`){e.preventDefault(),VT();return}}if(n.style.display!==`none`&&r.classList.contains(`show`)){if(N.showMergedList){let t=r.querySelectorAll(`#promptList .prompt-item`),n=t.length;if(e.key===`ArrowDown`){e.preventDefault(),N.selectedPromptIndex<0?N.selectedPromptIndex=0:N.selectedPromptIndex=(N.selectedPromptIndex+1)%n,xS(t);return}if(e.key===`ArrowUp`){e.preventDefault(),N.selectedPromptIndex<0||N.selectedPromptIndex===0?N.selectedPromptIndex=n-1:--N.selectedPromptIndex,xS(t);return}if(e.key===`Enter`&&N.selectedPromptIndex>=0){e.preventDefault();let n=t[N.selectedPromptIndex];n.dataset.type===`skill`||n.dataset.type===`mcp`?(n.click(),(e.ctrlKey||e.metaKey)&&gS()):e.ctrlKey||e.metaKey?SS(n.dataset.code):CS(n.dataset.code);return}if(e.key===`Escape`){gS();return}return}if(N.activeDropdownTab===`skills`){let t=r.querySelectorAll(`#skillList .skill-list-item`),n=t.length;if(e.key===`ArrowDown`){e.preventDefault(),N.selectedSkillIndex<0?N.selectedSkillIndex=0:N.selectedSkillIndex=(N.selectedSkillIndex+1)%n,US(t);return}if(e.key===`ArrowUp`){e.preventDefault(),N.selectedSkillIndex<0||N.selectedSkillIndex===0?N.selectedSkillIndex=n-1:--N.selectedSkillIndex,US(t);return}if(e.key===`Enter`&&N.selectedSkillIndex>=0){e.preventDefault(),t[N.selectedSkillIndex].click(),(e.ctrlKey||e.metaKey)&&gS();return}if(e.key===`Escape`){gS();return}if(e.key===`Tab`){e.preventDefault();let t=document.getElementById(`mcpTab`);t&&t.style.display!==`none`?XS(`mcp`):XS(`prompts`);return}return}if(N.activeDropdownTab===`mcp`){let t=r.querySelectorAll(`#mcpList .mcp-list-item`),n=t.length;if(e.key===`ArrowDown`){e.preventDefault(),N.selectedMcpServiceIndex<0?N.selectedMcpServiceIndex=0:N.selectedMcpServiceIndex=(N.selectedMcpServiceIndex+1)%n,rC(t);return}if(e.key===`ArrowUp`){e.preventDefault(),N.selectedMcpServiceIndex<0||N.selectedMcpServiceIndex===0?N.selectedMcpServiceIndex=n-1:--N.selectedMcpServiceIndex,rC(t);return}if(e.key===`Enter`&&N.selectedMcpServiceIndex>=0){e.preventDefault(),t[N.selectedMcpServiceIndex].click(),(e.ctrlKey||e.metaKey)&&gS();return}if(e.key===`Escape`){gS();return}if(e.key===`Tab`){e.preventDefault(),XS(`prompts`);return}return}let t=r.querySelectorAll(`#promptList .prompt-item`),n=t.length;if(e.key===`Tab`){let t=document.getElementById(`skillsTab`),n=document.getElementById(`mcpTab`);if(t&&t.style.display!==`none`){e.preventDefault(),XS(`skills`);return}if(n&&n.style.display!==`none`){e.preventDefault(),XS(`mcp`);return}}if(n!==0&&e.key===`ArrowDown`){e.preventDefault(),N.selectedPromptIndex<0?N.selectedPromptIndex=0:N.selectedPromptIndex=(N.selectedPromptIndex+1)%n,xS(t);return}if(e.key===`ArrowUp`){e.preventDefault(),N.selectedPromptIndex<0||N.selectedPromptIndex===0?N.selectedPromptIndex=n-1:--N.selectedPromptIndex,xS(t);return}if(e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&N.selectedPromptIndex>=0){e.preventDefault();let n=t[N.selectedPromptIndex].dataset.code;SS(n);return}if(e.key===`Enter`&&N.selectedPromptIndex>=0){e.preventDefault();let n=t[N.selectedPromptIndex].dataset.code;CS(n);return}if(e.key===`Escape`){gS();return}}if(e.key===`Escape`){N.inputHistoryIndex>=0&&(N.inputHistoryIndex=-1),t.value&&(t.value=``,t.style.height=`auto`,t.dispatchEvent(new Event(`input`))),e.preventDefault();return}let c=n.style.display!==`none`&&r.classList.contains(`show`),l=i.style.display!==`none`&&a.classList.contains(`show`),u=o.style.display!==`none`&&s.classList.contains(`show`);if(e.key===`ArrowUp`&&N.inputHistoryIndex===-1&&!t.value.trim()&&!ou()&&ZE()){e.preventDefault();return}if(!c&&!l&&!u){let n=OE({key:e.key,value:t.value,caret:t.selectionStart,history:N.inputHistory,index:N.inputHistoryIndex});if(n.handled){e.preventDefault(),N.inputHistoryIndex=n.index,t.value=n.value,t.dispatchEvent(new Event(`input`)),t.setSelectionRange(n.value.length,n.value.length);return}}if(e.key===`Enter`&&!e.shiftKey){if(N.isComposing)return;if(e.preventDefault(),VT(),N.isGenerating){if(e.altKey){Fu(t.value);return}hu();return}Vx()}}),t.addEventListener(`compositionstart`,()=>{N.isComposing=!0}),t.addEventListener(`compositionend`,()=>{N.isComposing=!1}),t.addEventListener(`paste`,e=>{let t=e.clipboardData?.items;if(t)for(let n of t){if(n.type.startsWith(`image/`)&&N.enableImageInput){e.preventDefault();let t=n.getAsFile();t&&lf(t);break}if(n.kind===`file`&&N.enableFileInput){e.preventDefault();let t=n.getAsFile();t&&Xf([t]);break}}});let ue=document.getElementById(`fileAttachBtn`),de=document.getElementById(`fileInput`);ue&&de&&(ue.addEventListener(`click`,()=>{de.click()}),de.addEventListener(`change`,async()=>{if(de.files.length>0){let e=Array.from(de.files),t=e.filter(e=>e.type.startsWith(`image/`)),n=e.filter(e=>!e.type.startsWith(`image/`));if(t.length>0)if(N.enableImageInput)for(let e of t)await lf(e);else P(r(`sidePanel.imageNotEnabled`)),Xf(t);n.length>0&&Xf(n),de.value=``}}));let fe=document.querySelector(`.input-wrapper`),pe=0;fe&&(fe.addEventListener(`dragenter`,e=>{e.preventDefault(),e.stopPropagation(),pe++,fe.classList.add(`drag-over`)}),fe.addEventListener(`dragleave`,e=>{e.preventDefault(),e.stopPropagation(),pe--,pe<=0&&(pe=0,fe.classList.remove(`drag-over`))}),fe.addEventListener(`dragover`,e=>{e.preventDefault(),e.stopPropagation()}),fe.addEventListener(`drop`,async e=>{e.preventDefault(),e.stopPropagation(),pe=0,fe.classList.remove(`drag-over`);let n=e.dataTransfer.getData(`application/x-workspace-file`);if(n){e.preventDefault();try{let{path:e}=JSON.parse(n);if(e){N_([e]);return}}catch(e){a.warn(`[SidePanel] parse workspace dragdata failed:`,e)}}let i=Array.from(e.dataTransfer.files);if(i.length>0){e.preventDefault();let t=i.filter(e=>e.type.startsWith(`image/`)),n=i.filter(e=>!e.type.startsWith(`image/`));if(t.length>0)if(N.enableImageInput)for(let e of t)await lf(e);else P(r(`sidePanel.imageNotEnabled`)),Xf(t);n.length>0&&Xf(n);return}let o=e.dataTransfer.getData(`text/plain`);if(o&&(e.preventDefault(),t)){t.focus();let e=t.selectionStart??t.value.length,n=t.selectionEnd??t.value.length;t.value=t.value.slice(0,e)+o+t.value.slice(n),t.selectionStart=t.selectionEnd=e+o.length,t.dispatchEvent(new Event(`input`))}}));let me=document.getElementById(`screenshotBtn`);me&&me.addEventListener(`click`,async()=>{if(N.enableImageInput)try{await xp()}catch(e){a.error(`[SidePanel] screenshot failed:`,e),P(r(`sidePanel.screenshotFailed`))}}),sf(),t.addEventListener(`wheel`,e=>{N.isScrolling=!0;let n=t.style.height||t.offsetHeight+`px`;t.style.height=n,t.scrollHeight<=t.clientHeight+10&&(e.preventDefault(),e.stopPropagation()),setTimeout(()=>{N.isScrolling=!1},100)},{passive:!1}),t.addEventListener(`input`,e=>{let n=t.value,r=document.getElementById(`promptSelector`),i=document.getElementById(`promptDropdown`);document.getElementById(`agentAtSelector`),document.getElementById(`agentAtDropdown`);let a=n.lastIndexOf(`/`),o=n.lastIndexOf(`@`),s=n.lastIndexOf(`$`),c=e=>{if(e===-1||e!==0&&n[e-1]!==`
|
|
2579
2586
|
`&&n[e-1]!==` `)return!1;let t=n.substring(e+1);return!(t.includes(` `)||t.includes(`
|
|
2580
|
-
`))},l=c(a),u=c(o),d=c(s),f=null;if(l&&(f={key:`slash`,index:a}),u&&(!f||o>f.index)&&(f={key:`at`,index:o}),d&&(!f||s>f.index)&&(f={key:`dollar`,index:s}),f&&f.key===`dollar`)
|
|
2587
|
+
`))},l=c(a),u=c(o),d=c(s),f=null;if(l&&(f={key:`slash`,index:a}),u&&(!f||o>f.index)&&(f={key:`at`,index:o}),d&&(!f||s>f.index)&&(f={key:`dollar`,index:s}),f&&f.key===`dollar`)gS(),Nv(),BT(n.substring(s+1));else if(f&&f.key===`at`)gS(),VT(),jv(n.substring(o+1));else if(f&&f.key===`slash`){Nv(),VT();let e=n.substring(a+1);r.style.display!==`none`&&i.classList.contains(`show`)?vS(e):hS(e)}else gS(),Nv(),VT();g()});let he=kE((e,t)=>{chrome.storage.local.set({[e]:t})},200);u.addEventListener(`scroll`,()=>{he(`scrollPosition_`+(N.activeSessionId||`default`),u.scrollTop)}),window.addEventListener(`pagehide`,()=>{chrome.storage.local.set({[`scrollPosition_`+(N.activeSessionId||`default`)]:u.scrollTop})});let ge=document.getElementById(`headerMoreBtn`),_e=document.getElementById(`headerMoreDropdown`);ge&&_e&&(ge.addEventListener(`click`,e=>{e.stopPropagation(),_e.classList.toggle(`show`)}),document.addEventListener(`click`,e=>{!_e.contains(e.target)&&e.target!==ge&&Ce()}));let ve=document.getElementById(`themeToggleBtn`),ye=document.getElementById(`themeToggleLabel`),be=document.getElementById(`themeSubmenu`),xe=e=>r(e===`dark`?`settings.themeDark`:e===`system`?`settings.themeSystem`:`settings.themeLight`),Se=()=>{let e=it();ye&&(ye.textContent=r(`header.themeToggle`,{theme:xe(e)})),be&&be.querySelectorAll(`.theme-submenu-item`).forEach(t=>{t.classList.toggle(`active`,t.dataset.themeValue===e)}),ve&&ve.setAttribute(`aria-expanded`,String(!!(be&&be.classList.contains(`show`))))};function Ce(){be&&be.classList.remove(`show`),_e&&_e.classList.remove(`show`),ve&&ve.setAttribute(`aria-expanded`,`false`)}ve&&be&&(ve.addEventListener(`click`,e=>{e.stopPropagation(),be.classList.toggle(`show`),Se()}),be.querySelectorAll(`.theme-submenu-item`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),$e(e.dataset.themeValue),Ce()})})),Se(),nt(Se),c(Se),s.addEventListener(`click`,e=>{e.stopPropagation(),Ce(),Sx()}),l&&l.addEventListener(`click`,e=>{e.stopPropagation(),Ce(),xd()});let we=document.getElementById(`importChatBtn`);we&&we.addEventListener(`click`,e=>{e.stopPropagation(),Ce(),Ed()});let Te=document.getElementById(`importSessionsFile`);Te&&Te.addEventListener(`change`,e=>{let t=e.target.files[0];t&&Dd(t)});let Ee=document.getElementById(`settingsBtn`);Ee&&Ee.addEventListener(`click`,()=>{chrome.runtime.openOptionsPage()});let De=document.getElementById(`headerAgentIndicator`);De&&De.addEventListener(`click`,async()=>{let e=chrome.runtime.getURL(`options.html#agent`),t=await chrome.tabs.query({url:chrome.runtime.getURL(`options.html`)});t.length>0?await chrome.tabs.update(t[0].id,{active:!0,url:e}):await chrome.tabs.create({url:e})});let Oe=document.getElementById(`prototypeLibraryBtn`);Oe&&Oe.addEventListener(`click`,e=>{e.stopPropagation(),Ce(),Ps()});let ke=document.getElementById(`tokenStatsHeaderBtn`);ke&&ke.addEventListener(`click`,e=>{e.stopPropagation(),Ce(),window.openTokenStats&&window.openTokenStats()});let Ae=document.getElementById(`auditLogBtn`),je=document.getElementById(`auditLogOverlay`),Me=document.getElementById(`auditLogClose`),Ne=document.getElementById(`auditLogRefreshBtn`),Pe=document.getElementById(`auditLogCategoryFilter`),Fe=document.getElementById(`auditLogLimit`),Ie=document.getElementById(`auditLogSearch`),Le=document.getElementById(`auditLogSearchClear`),Re=document.getElementById(`auditLogLoading`),ze=document.getElementById(`auditLogEmpty`),Be=document.getElementById(`auditLogList`),Ve=[],He={auth:r(`sidePanel.auditCategoryAuth`),fs:r(`sidePanel.auditCategoryFs`),exec:r(`sidePanel.auditCategoryExec`),security:r(`sidePanel.auditCategorySecurity`),system:r(`sidePanel.auditCategorySystem`)},Ue={info:`INFO`,warn:`WARN`,error:`ERROR`},We={info:`audit-level-info`,warn:`audit-level-warn`,error:`audit-level-error`};function Ge(e){if(!e)return`-`;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function Ke(e){let t=new Set([`timestamp`,`level`,`category`,`action`]),n=[];for(let[r,i]of Object.entries(e)){if(t.has(r))continue;let e=typeof i==`string`?i:JSON.stringify(i),a=e.length>60?e.slice(0,60)+`...`:e;n.push(`${r}: ${a}`)}return n.join(r(`sidePanel.auditDetailSeparator`))}async function qe(){if(!Re||!ze||!Be)return;Re.style.display=`block`,ze.style.display=`none`,Be.style.display=`none`;let e=Pe?.value||null,t=parseInt(Fe?.value||`200`,10);try{let n=await new Promise((n,r)=>{chrome.runtime.sendMessage({type:`QUERY_AUDIT_LOGS`,category:e,limit:t},e=>{chrome.runtime.lastError?r(Error(chrome.runtime.lastError.message)):n(e)})});if(Re.style.display=`none`,!n||!n.success){ze.style.display=`block`,ze.textContent=r(`sidePanel.auditQueryFailed`,{error:n?.error||r(`sidePanel.unknownError`)});return}Ve=n.entries||[],Je()}catch(e){Re.style.display=`none`,ze.style.display=`block`,ze.textContent=r(`sidePanel.auditLoadFailed`,{error:e.message})}}function Je(){if(!Be)return;let e=(Ie?.value||``).trim().toLowerCase(),t=Ve;if(e&&(t=t.filter(t=>[t.action||``,t.category||``,...Object.entries(t).filter(([e])=>![`timestamp`,`level`,`category`,`action`].includes(e)).map(([,e])=>typeof e==`string`?e:JSON.stringify(e))].join(` `).toLowerCase().includes(e))),Le&&(Le.style.display=e?`block`:`none`),Re.style.display=`none`,t.length===0){ze.style.display=`block`,ze.textContent=r(e?`sidePanel.auditNoMatch`:`sidePanel.auditEmpty`),Be.style.display=`none`;return}ze.style.display=`none`,Be.style.display=`block`,Be.innerHTML=t.map(e=>{let t=F(He[e.category]||e.category||`-`),n=F(Ue[e.level]||e.level?.toUpperCase()||`INFO`),r=We[e.level]||`audit-level-info`,i=Ge(e.timestamp),a=F(Ke(e));return`<div class="audit-entry">
|
|
2581
2588
|
<div class="audit-entry-header">
|
|
2582
2589
|
<span class="audit-time">${i}</span>
|
|
2583
2590
|
<span class="audit-level ${r}">${n}</span>
|
|
@@ -2585,7 +2592,7 @@ Are you sure you want to stop the agent service? You will not be able to connect
|
|
|
2585
2592
|
<span class="audit-action">${F(e.action||`-`)}</span>
|
|
2586
2593
|
</div>
|
|
2587
2594
|
${a?`<div class="audit-details">${a}</div>`:``}
|
|
2588
|
-
</div>`}).join(``)}function Ye(){je&&(je.style.display=`flex`,qe())}function Xe(){je&&(je.style.display=`none`)}Ae&&Ae.addEventListener(`click`,e=>{e.stopPropagation(),Ce(),Ye()}),Me&&Me.addEventListener(`click`,Xe),Ne&&Ne.addEventListener(`click`,qe),Pe&&Pe.addEventListener(`change`,qe),Fe&&Fe.addEventListener(`change`,qe),Ie&&Ie.addEventListener(`input`,()=>{Je()}),Le&&Le.addEventListener(`click`,()=>{Ie&&(Ie.value=``),Je()}),
|
|
2595
|
+
</div>`}).join(``)}function Ye(){je&&(je.style.display=`flex`,qe())}function Xe(){je&&(je.style.display=`none`)}Ae&&Ae.addEventListener(`click`,e=>{e.stopPropagation(),Ce(),Ye()}),Me&&Me.addEventListener(`click`,Xe),Ne&&Ne.addEventListener(`click`,qe),Pe&&Pe.addEventListener(`change`,qe),Fe&&Fe.addEventListener(`change`,qe),Ie&&Ie.addEventListener(`input`,()=>{Je()}),Le&&Le.addEventListener(`click`,()=>{Ie&&(Ie.value=``),Je()}),dD(()=>N.activeSessionId,window.showCustomConfirm);let Ze=document.getElementById(`isolateChatBtn`),et=document.getElementById(`enableToolsBtn`),tt=document.getElementById(`toolsConfigBtn`),rt=`agentEnabledTools_${N.activeAgentId||`default`}`,at=`agentMcpClosedServers_${N.activeAgentId||`default`}`;chrome.storage.local.get([rt,`enabledTools`,`isolateChat`,`enableSelectionQuery`,`enableTools`,at,`mcpTools`,`mcpEnabled`,`ragTools`,`ragToolsIntroduced`],e=>{e.isolateChat!==void 0&&(N.isolateChat=e.isolateChat),Ze.checked=N.isolateChat,e.enableSelectionQuery!==void 0&&(N.enableSelectionQuery=e.enableSelectionQuery);let t=document.getElementById(`enableSelectionQueryBtn`);t&&(t.checked=N.enableSelectionQuery),e.enableTools!==void 0&&(N.useTools=e.enableTools),N.activeAgentId&&M(async()=>{let{getAgent:e}=await import(`./agent-store-DR_A4rFm.js`).then(e=>e.t);return{getAgent:e}},__vite__mapDeps([0,1,2,3,4])).then(({getAgent:e})=>e(N.activeAgentId)).then(e=>{N.activeAgentMcpExcludedServerIds=e?e.mcpExcludedServerIds??null:null,ca()}).catch(()=>{}),N.mcpClosedServers=e[at]||[];let n=e.ragTools||[],r=e[rt],i=e.enabledTools;if(Array.isArray(r)){let t=da(n);N.enabledTools=r.filter(e=>t.has(e));let i=ua(N.enabledTools,n,e.ragToolsIntroduced);N.enabledTools=i.tools,i.migrated?chrome.storage.local.set({ragToolsIntroduced:!0,[rt]:N.enabledTools}):N.enabledTools.length!==r.length&&chrome.storage.local.set({[rt]:N.enabledTools})}else if(i&&i.length>0){let t=da(n),r=i.filter(e=>t.has(e)),a=b.filter(e=>e.enabled&&!r.includes(e.id)).map(e=>e.id);N.enabledTools=[...r,...a];let o=ua(N.enabledTools,n,e.ragToolsIntroduced);N.enabledTools=o.tools,chrome.storage.local.set({[rt]:N.enabledTools,...o.migrated?{ragToolsIntroduced:!0}:{}})}else{N.enabledTools=b.filter(e=>e.enabled).map(e=>e.id);let t=ua(N.enabledTools,n,e.ragToolsIntroduced);N.enabledTools=t.tools,t.migrated&&chrome.storage.local.set({ragToolsIntroduced:!0,[rt]:N.enabledTools})}et&&(et.checked=N.useTools),ca(),wD(),D()}),Ze.addEventListener(`change`,()=>{N.isolateChat=Ze.checked,chrome.storage.local.set({isolateChat:N.isolateChat}),a.debug(`[SidePanel] conv memory:`,N.isolateChat?`enabled`:`disabled`)});let ot=document.getElementById(`enableSelectionQueryBtn`);ot&&ot.addEventListener(`change`,()=>{N.enableSelectionQuery=ot.checked,chrome.storage.local.set({enableSelectionQuery:N.enableSelectionQuery}),a.debug(`[SidePanel] text Q&A:`,N.enableSelectionQuery?`enabled`:`disabled`),!N.enableSelectionQuery&&N.selectedContextText&&px()}),et&&et.addEventListener(`change`,()=>{N.useTools=et.checked,chrome.storage.local.set({enableTools:N.useTools}),a.debug(`[SidePanel] tool master switch:`,N.useTools?`enabled`:`disabled`),ca()}),tt&&tt.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),Ji()});let st=document.getElementById(`toolsPopupOverlay`),ct=document.getElementById(`toolsPopupClose`),lt=st?st.querySelector(`.modal-container`):null;ct&&ct.addEventListener(`click`,Yi),lt&<.addEventListener(`click`,e=>{e.stopPropagation()});let ut=document.getElementById(`toolsSearchInput`),dt=document.getElementById(`toolsSearchClear`);ut&&ut.addEventListener(`input`,e=>{N.currentSearch=e.target.value.toLowerCase(),dt&&(dt.style.display=e.target.value?``:`none`),Xi()}),dt&&dt.addEventListener(`click`,()=>{ut&&(ut.value=``,dt.style.display=`none`,N.currentSearch=``,Xi())});let ft=document.querySelectorAll(`.category-btn`);ft.forEach(e=>{e.addEventListener(`click`,()=>{ft.forEach(e=>{e.classList.remove(`active`),e.classList.contains(`category-all`)?(e.style.background=`var(--brand-violet-soft-bg)`,e.style.color=`var(--brand-500)`,e.style.borderColor=`var(--brand-violet-soft-border)`):(e.style.background=`var(--bg-surface)`,e.style.color=`var(--text-secondary)`,e.style.borderColor=`var(--border-subtle)`)}),e.classList.add(`active`),e.style.background=`linear-gradient(135deg, var(--brand-500) 0%, var(--brand-accent) 100%)`,e.style.color=`var(--text-on-brand)`,e.style.borderColor=`transparent`,N.currentCategory=e.dataset.category,Xi()})});let mt=document.getElementById(`toolsCategories`);mt&&mt.addEventListener(`wheel`,e=>{e.preventDefault(),mt.scrollLeft+=e.deltaY*2},{passive:!1});let ht=document.getElementById(`toolsSelectAll`),gt=document.getElementById(`toolsSelectNone`);ht&&ht.addEventListener(`click`,()=>{na().forEach(e=>{let t=document.getElementById(`tool_`+e.id);t&&(t.checked=!0),N.enabledTools.includes(e.id)||N.enabledTools.push(e.id)}),sa(!0),ra(),ia(),aa()}),gt&>.addEventListener(`click`,()=>{na().forEach(e=>{let t=document.getElementById(`tool_`+e.id);t&&(t.checked=!1);let n=N.enabledTools.indexOf(e.id);n>-1&&N.enabledTools.splice(n,1)}),sa(!1),ra(),ia(),aa()});let _t=document.getElementById(`toolsPopupSave`);_t&&_t.addEventListener(`click`,()=>{oa(),aa()});let bt=document.getElementById(`toolsPreselectToggle`);bt&&bt.addEventListener(`change`,()=>{chrome.storage.local.set({enableToolPreselect:bt.checked},()=>{a.debug(`[SidePanel] toolpre-filter toggle updated:`,bt.checked)})});let xt=document.getElementById(`toolConfirmToggle`);xt&&xt.addEventListener(`change`,()=>{chrome.storage.local.set({toolConfirmationEnabled:xt.checked},()=>{a.debug(`[SidePanel] sensitive-operation confirmation toggle updated:`,xt.checked)})});let St=document.getElementById(`toolsPopupCancel`);St&&St.addEventListener(`click`,()=>{Yi()});let Ct=document.getElementById(`modalCancelBtn`),wt=document.getElementById(`modalConfirmBtn`),Tt=document.getElementById(`toolStatsOverlay`),I=document.getElementById(`toolStatsClose`),Et=document.getElementById(`toolStatsBtn`);function L(){Tt&&(Tt.style.display=`flex`,jt())}function Dt(){Tt&&(Tt.style.display=`none`)}Et&&Et.addEventListener(`click`,e=>{e.stopPropagation(),L()}),I&&I.addEventListener(`click`,Dt),Tt&&Tt.addEventListener(`click`,e=>{e.target===Tt&&Dt()});let Ot=document.getElementById(`toolStatsRefreshBtn`);Ot&&Ot.addEventListener(`click`,jt);let kt=document.getElementById(`toolStatsClearBtn`);kt&&kt.addEventListener(`click`,async()=>{await window.showCustomConfirm(r(`sidePanel.clearStatsConfirm`),r(`sidePanel.clearStatsTitle`))&&(await chrome.storage.local.remove([`toolUsageStats`]),jt())});let At={column:`callCount`,asc:!1};async function jt(){let e=document.getElementById(`toolStatsTable`),t=document.getElementById(`toolStatsTableBody`),n=document.getElementById(`toolStatsLoading`),i=document.getElementById(`toolStatsEmpty`),o=document.getElementById(`toolStatsSummary`),s=document.getElementById(`toolStatsUnusedSection`),c=document.getElementById(`toolStatsUnusedList`);if(!(!e||!t||!n||!i)){e.style.display=`none`,i.style.display=`none`,s&&(s.style.display=`none`),o&&(o.textContent=``),n.style.display=``;try{let t=(await chrome.storage.local.get([`toolUsageStats`])).toolUsageStats||{},a=Object.entries(t);if(a.length===0){n.style.display=`none`,i.style.display=``;return}let l={};b.forEach(e=>{l[e.id]=e.name?`${e.name}${r(`sidePanel.toolNameDescSeparator`)}${e.description||``}`:e.description||e.id}),Mt(a,l);let u=b.map(e=>e.id),d=new Set(a.map(([e])=>e)),f=u.filter(e=>!d.has(e)),p=a.length,m=f.length;o&&(o.textContent=r(`sidePanel.toolStatsSummary`,{used:p,unused:m})),s&&c&&m>0&&(c.innerHTML=f.sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())).map(e=>`<code title="${F(l[e]||e)}" style="padding: 3px 10px; background: var(--bg-subtle); color: var(--text-disabled); border: 1px solid var(--border-subtle); border-radius: 4px; font-size: 11px;">${e}</code>`).join(``),s.style.display=``),n.style.display=`none`,e.style.display=``}catch(e){a.error(`[SidePanel] loadstats failed:`,e),n.style.display=`none`,i.textContent=r(`sidePanel.toolStatsLoadFailed`),i.style.display=``}}}function Mt(e,t){let n=document.getElementById(`toolStatsTableBody`);if(!n)return;let{column:r,asc:i}=At;n.innerHTML=[...e].sort((e,t)=>{let[n,a]=e,[o,s]=t,c=a.callCount>0?a.successCount/a.callCount*100:0,l=s.callCount>0?s.successCount/s.callCount*100:0,u=a.callCount>0?a.totalDuration/a.callCount:0,d=s.callCount>0?s.totalDuration/s.callCount:0,f=0;switch(r){case`name`:f=n.toLowerCase().localeCompare(o.toLowerCase());break;case`callCount`:f=a.callCount-s.callCount;break;case`successCount`:f=a.successCount-s.successCount;break;case`successRate`:f=c-l;break;case`duration`:f=u-d;break}return i?f:-f}).map(([e,n])=>{let r=n.callCount>0?n.successCount/n.callCount*100:0,i=n.callCount>0?n.totalDuration/n.callCount:0,a=t[e]||e,o=`#38a169`;r<60?o=`#e53e3e`:r<85&&(o=`#d69e2e`);let s=vt(i);return`<tr>
|
|
2589
2596
|
<td style="padding: 6px 10px; border-bottom: 1px solid var(--border-subtle); color: var(--text-primary);"><code title="${F(a)}">${e}</code></td>
|
|
2590
2597
|
<td style="padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--border-subtle); color: var(--text-secondary);">${n.callCount}</td>
|
|
2591
2598
|
<td style="padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--border-subtle); color: var(--text-secondary);">${n.successCount}</td>
|
|
@@ -2596,4 +2603,4 @@ Are you sure you want to stop the agent service? You will not be able to connect
|
|
|
2596
2603
|
<span style="font-size: 12px; color: ${o}; font-weight: 500;">${r.toFixed(0)}%</span>
|
|
2597
2604
|
</td>
|
|
2598
2605
|
<td style="padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--border-subtle); color: var(--text-tertiary); font-size: 12px;">${s}</td>
|
|
2599
|
-
</tr>`}).join(``),Nt()}function Nt(){let{column:e,asc:t}=At,n=[`name`,`callCount`,`successCount`,`successRate`,`duration`],r={name:`sortByName`,callCount:`sortByCallCount`,successCount:`sortBySuccessCount`,successRate:`sortBySuccessRate`,duration:`sortByDuration`};n.forEach(n=>{let i=document.getElementById(r[n]);if(!i)return;let a=i.querySelector(`.sort-indicator`);a&&(n===e?(a.textContent=t?`▲`:`▼`,a.style.color=`var(--brand-500)`):(a.textContent=``,a.style.color=``))})}document.querySelectorAll(`#toolStatsTable th[data-sort]`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.sort;At.column===t?At.asc=!At.asc:(At.column=t,At.asc=!1),jt()})}),Ct.addEventListener(`click`,()=>{
|
|
2606
|
+
</tr>`}).join(``),Nt()}function Nt(){let{column:e,asc:t}=At,n=[`name`,`callCount`,`successCount`,`successRate`,`duration`],r={name:`sortByName`,callCount:`sortByCallCount`,successCount:`sortBySuccessCount`,successRate:`sortBySuccessRate`,duration:`sortByDuration`};n.forEach(n=>{let i=document.getElementById(r[n]);if(!i)return;let a=i.querySelector(`.sort-indicator`);a&&(n===e?(a.textContent=t?`▲`:`▼`,a.style.color=`var(--brand-500)`):(a.textContent=``,a.style.color=``))})}document.querySelectorAll(`#toolStatsTable th[data-sort]`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.sort;At.column===t?At.asc=!At.asc:(At.column=t,At.asc=!1),jt()})}),Ct.addEventListener(`click`,()=>{Cx()}),wt.addEventListener(`click`,()=>{Cx(),xx()});let Pt=document.getElementById(`confirmModal`);Pt.addEventListener(`click`,e=>{e.target===Pt&&Cx()});let It=document.getElementById(`selectionClose`);It&&It.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),a.debug(`[SidePanel] user clickcloseselected content by button`),px(),window.hideFloatingMenu(),N.lastSelectedText=``,N.currentSelectionRange=null}),t.addEventListener(`input`,()=>{})}),Mt().then(()=>{pD(),Yx(N.chatConfig.showMessageTimestamp!==!1),mD(),hD()}),document.addEventListener(`DOMContentLoaded`,()=>{_D()}),document.addEventListener(`DOMContentLoaded`,Wn),document.addEventListener(`DOMContentLoaded`,pw),document.addEventListener(`DOMContentLoaded`,ED),document.addEventListener(`DOMContentLoaded`,TD),document.addEventListener(`DOMContentLoaded`,jT),document.addEventListener(`DOMContentLoaded`,DE),document.addEventListener(`DOMContentLoaded`,async()=>{Bn(),await tp(),lp(),Nw(),nT(),WD(),Jp(),uT();let{updateBookmarkButtons:e,updateBookmarkBadge:t}=await M(async()=>{let{updateBookmarkButtons:e,updateBookmarkBadge:t}=await Promise.resolve().then(()=>cp);return{updateBookmarkButtons:e,updateBookmarkBadge:t}},void 0);e(),t()}),document.addEventListener(`DOMContentLoaded`,async()=>{nu(e=>Vx(e)),await Yu(),await iD()});function XD(){px(),KS(),aC(),ry(),vy(),Qf();let e=document.getElementById(`imagePreviewBar`);e&&(e.innerHTML=``,e.style.display=`none`)}function ZD(e){let t=e||{};t.quotedContextText&&dx(t.quotedContextText),t.selectedPage&&_y(t.selectedPage),!t.quotedContextText&&N.selectedContextText&&fx(),qS(),sC(),iy(),bp(),$f()}document.addEventListener(`queue-context-cleared`,XD),document.addEventListener(`queue-context-restored`,e=>{ZD(e&&e.detail?e.detail.snapshot:null)}),document.addEventListener(`DOMContentLoaded`,PS),document.addEventListener(`DOMContentLoaded`,YS),document.addEventListener(`DOMContentLoaded`,QS),document.addEventListener(`DOMContentLoaded`,lC),document.addEventListener(`DOMContentLoaded`,xy),document.addEventListener(`DOMContentLoaded`,no),document.addEventListener(`DOMContentLoaded`,So),document.addEventListener(`DOMContentLoaded`,Zs),document.addEventListener(`DOMContentLoaded`,Td),document.addEventListener(`DOMContentLoaded`,()=>fC()),document.addEventListener(`DOMContentLoaded`,async()=>{let{refreshAgentNames:e,initScrollToBottomBtn:t}=await M(async()=>{let{refreshAgentNames:e,initScrollToBottomBtn:t}=await Promise.resolve().then(()=>bb);return{refreshAgentNames:e,initScrollToBottomBtn:t}},void 0);e(),t()}),document.addEventListener(`DOMContentLoaded`,()=>{let e=new URLSearchParams(window.location.search).has(`popup`),t=document.getElementById(`detachBtn`),n=document.getElementById(`attachBtn`),i=e?n:t;e?n&&(n.style.display=`flex`):t&&(t.style.display=`flex`);let o=()=>{if(!i)return;let t=N.pendingCallApiSessionIds&&N.pendingCallApiSessionIds.size>0;i.disabled=t,i.style.opacity=t?`0.35`:``,i.style.cursor=t?`not-allowed`:`pointer`,i.title=r(t?`detach.taskRunning`:e?`header.attachTitle`:`header.detachTitle`)};o(),document.addEventListener(`generating-state-changed`,o),t&&t.addEventListener(`click`,async()=>{if(N.pendingCallApiSessionIds&&N.pendingCallApiSessionIds.size>0){P(r(`detach.taskRunning`),`warning`);return}try{if((await chrome.runtime.sendMessage({type:`DETACH_SIDEPANEL`,width:window.innerWidth}))?.success)try{window.close()}catch{}}catch(e){a.warn(`[SidePanel] detach failed:`,e?.message)}}),n&&n.addEventListener(`click`,async()=>{if(N.pendingCallApiSessionIds&&N.pendingCallApiSessionIds.size>0){P(r(`detach.taskRunning`),`warning`);return}try{let e=(await chrome.windows.getCurrent()).id;await chrome.runtime.sendMessage({type:`ATTACH_SIDEPANEL`,windowId:e});try{window.close()}catch{}}catch(e){a.warn(`[SidePanel] attach failed:`,e?.message)}})});export{Tp as t};
|