ai-helper-agent 2.7.8 → 2.7.9
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-sKnc7YcJ.js → agent-store-CuK2pMqc.js} +1 -1
- package/dist/assets/background.js +72 -72
- package/dist/assets/{chat-export-BSv2Jn2H.js → chat-export-BjO4Cgaj.js} +1 -1
- package/dist/assets/content.js +20 -20
- package/dist/assets/{i18n-NkRsFRG_.js → i18n-DDhHR2eT.js} +2 -2
- package/dist/assets/{markdown-render-lNxIpqR5.js → markdown-render-BIVttniD.js} +3 -3
- package/dist/assets/{model-profiles-DH6uFSiB.js → model-profiles-9Pkrdr9U.js} +1 -1
- package/dist/assets/{network-scope-CNRYXk74.js → network-scope-0d6MoKgI.js} +1 -1
- package/dist/assets/options.js +1 -1
- package/dist/assets/{page-snapshot-renderer-xd8FypSv.js → page-snapshot-renderer-DiPOIyTm.js} +1 -1
- package/dist/assets/{session-store-BXelxKzG.js → session-store-XFFEUHgS.js} +3 -3
- package/dist/assets/side_panel.js +15 -15
- package/dist/assets/{utils-CMkztLa1.js → utils-qEM6ytxe.js} +1 -1
- package/dist/assets/{version-C8Rq9nMu.js → version-CeLsZH0f.js} +1 -1
- package/dist/assets/{workspace-manager-CTFkcx87.js → workspace-manager-C4IYPHx6.js} +1 -1
- package/dist/manifest.json +1 -1
- package/dist/offscreen/offscreen.js +2 -2
- package/dist/options.html +4 -4
- package/dist/side_panel.html +11 -11
- package/package.json +1 -1
|
@@ -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-CuK2pMqc.js","assets/chunk-CMxvf4Kt.js","assets/session-store-XFFEUHgS.js","assets/model-profiles-9Pkrdr9U.js","assets/i18n-DDhHR2eT.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-BjO4Cgaj.js","assets/dist-BUuoW_84.js","assets/markdown-render-BIVttniD.js","assets/version-CeLsZH0f.js","assets/utils-qEM6ytxe.js","assets/workspace-manager-C4IYPHx6.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-DDhHR2eT.js";import{A as l,C as u,D as d,E as f,F as p,G as m,I as h,N as g,P as _,R as v,S as y,T as b,W as x,b as S,c as C,d as w,i as T,k as E,r as D,u as O,w as k,y as A,z as j}from"./model-profiles-9Pkrdr9U.js";import{A as ee,At as te,C as ne,D as re,E as ie,Et as ae,F as oe,G as se,Ht as ce,Kt as le,Lt as ue,M as de,N as M,Nt as fe,O as pe,Ot as me,P as he,Pt as ge,Rt as _e,S as ve,T as ye,Tt as be,Ut as xe,Vt as Se,Xt as Ce,Yt as we,_ as Te,a as Ee,an as De,b as N,c as Oe,d as ke,dt as Ae,en as je,f as Me,ft as Ne,h as Pe,ht as Fe,j as Ie,k as Le,l as Re,lt as ze,m as Be,mt as Ve,n as He,nn as Ue,o as We,on as Ge,p as Ke,pt as qe,r as Je,rn as Ye,s as Xe,t as Ze,tn as Qe,u as $e,un as et,ut as tt,v as nt,w as rt,x as it,y as at}from"./session-store-XFFEUHgS.js";import{a as ot,n as st,r as ct,t as lt}from"./voice-shortcut-Dtt3nhkz.js";import{d as ut,f as dt,i as ft,l as pt,m as mt,n as ht,p as gt,t as _t}from"./version-CeLsZH0f.js";import{a as vt,c as yt,i as bt,n as xt,o as St,r as Ct,s as wt}from"./agent-store-CuK2pMqc.js";import{C as Tt,E as Et,S as Dt,T as Ot,_ as kt,a as At,b as jt,c as P,d as Mt,f as Nt,g as Pt,h as Ft,i as It,l as Lt,m as F,n as Rt,o as zt,p as Bt,r as Vt,s as I,t as Ht,u as Ut,v as Wt,w as L,x as Gt,y as Kt}from"./utils-qEM6ytxe.js";import{a as qt,c as Jt,d as Yt,f as Xt,h as Zt,i as Qt,l as $t,m as en,n as tn,o as nn,p as rn,r as an,s as on,t as sn,u as cn}from"./markdown-render-BIVttniD.js";import{C as ln,E as un,O as dn,S as fn,T as pn,_ as mn,a as hn,b as gn,c as _n,d as vn,f as yn,g as bn,h as xn,i as Sn,l as Cn,m as wn,n as Tn,o as En,p as Dn,r as On,s as kn,t as An,u as jn,v as Mn,w as Nn,x as Pn,y as Fn}from"./workspace-manager-C4IYPHx6.js";var In=he.map(e=>e.id),Ln=[...new Set([...m,`mcp`,`knowledge`])],Rn=[{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 zn=2e3,Bn=.7,Vn=1e3;function Hn(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 d=s,p=s.map((e,t)=>t);n&&n>0&&s.length>n&&(d=s.slice(s.length-n),p=p.slice(s.length-n));let m=[];for(let e=0;e<d.length;e++)c&&p[e]<=u||m.push(d[e]);let h=[],g=b([o]);for(let e=m.length-1;e>=0;e--){let t=m[e],n=b([{...t,content:v(t.content)}]);if(g+n<=i)h.unshift(t),g+=n;else break}let _=null,y=m.length-h.length;if(y>0){let e=l(m.slice(0,y));e&&(_=f(e)>Vn?e.substring(0,Vn*4)+`
|
|
3
3
|
...[历史摘要已截断]`:e)}return{messages:[...h,o],keptHistory:h,compactionApplied:c,trimmedCount:y,historySummaryText:_}}function Un(e,t){return!t||!t.summary?e:`${e}\n\n${r(`contextUsage.compactionInjection`,{count:t.compressedCount||0})}\n${t.summary}`}function Wn(e,t,n,r){return t?.compactionApplied&&n?.summary?e[0]={...e[0],content:Un(e[0].content,n)}:n?.summary&&r?.warn(`[SidePanel] contextCompaction invalid (upToMessageId not found), ignored this send`),e}function Gn({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 d=g(e,l,t),p=d-f(n)-y-zn,m=Math.floor(Math.max(p,0)*Bn),h={role:`user`,content:a},_=c?s:null,v=Hn(i,{isolateChat:c,maxMemoryMessages:o,compaction:_,historyBudget:m,currentMessage:h}),x=f(v.compactionApplied?Un(n,_):n),S=r*200,C=b(v.keptHistory),w=a&&a.trim()?b([h]):0,T=x+S+C+w,E=u(T,d);return{usedTokens:T,contextWindow:d,ratio:d>0?T/d:0,level:E.level,breakdown:{system:x,tools:S,history:C,input:w,outputReserve:y,safetyMargin:zn,selectedCount:v.keptHistory.length,totalCount:i.length,trimmedCount:v.trimmedCount,compactionApplied:v.compactionApplied,compactionInvalid:!!(_&&_.summary&&!v.compactionApplied),historyBudget:m}}}function Kn(e,{maxMemoryMessages:t=null,compaction:n=null}={}){let r=Hn(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=v(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 qn(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(),Jn()}function Jn(){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 Yn=[`workspace`,`bookmark`,`toc`,`search`,`todo`,`schedule`],Xn=`.workspace-panel.expanded, .bookmark-panel.expanded, .message-toc-panel.expanded, .search-panel.expanded, .schedule-panel.open`,Zn=null,Qn=null;function $n(){if(Zn)return Zn;Zn=document.createElement(`div`),Zn.className=`side-rail`,Zn.id=`sideRail`,Zn.innerHTML=Yn.map(e=>`<div class="side-rail-slot" data-slot="${e}"></div>`).join(``),document.body.appendChild(Zn),tr();let e=document.getElementById(`chatContainer`);return e&&typeof ResizeObserver<`u`&&new ResizeObserver(tr).observe(e),window.addEventListener(`resize`,tr),Zn}function er(e){return(Zn||$n()).querySelector(`.side-rail-slot[data-slot="${e}"]`)}function tr(){if(!Zn)return;let e=document.getElementById(`chatContainer`);if(!e)return;let t=e.getBoundingClientRect(),n=window.innerHeight;Zn.style.top=`${Math.max(0,Math.round(t.top))}px`,Zn.style.bottom=`${Math.max(0,Math.round(n-t.bottom))}px`,nr()}function nr(){Qn&&clearTimeout(Qn),Qn=setTimeout(()=>{Qn=null,document.querySelectorAll(Xn).forEach(It)},120)}n(`zh`,{messageToc:{toggleTitle:`显示目录(H{count}个标题)`,title:`目录`,headingCount:`{count} 个`,lock:`锁定目录(不自动收起)`,unlock:`解锁目录`,close:`关闭目录`}}),n(`en`,{messageToc:{toggleTitle:`Show table of contents (H{count} headings)`,title:`Contents`,headingCount:`{count}`,lock:`Pin table of contents`,unlock:`Unpin table of contents`,close:`Close table of contents`}});var rr=`messageTocLocked`,ir=!1,ar=`<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 9.9-1"/></svg>`,or=`<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>`;function sr(e){e&&(e.innerHTML=ir?or:ar,e.title=r(ir?`messageToc.unlock`:`messageToc.lock`),e.classList.toggle(`locked`,ir))}function cr(){try{let e=chrome.storage?.local?.set?.({[rr]:ir});e&&typeof e.catch==`function`&&e.catch(()=>{})}catch{}}function lr(){document.addEventListener(`mouseover`,ur,!0),document.addEventListener(`mouseout`,dr,!0);try{let e=chrome.storage?.local?.get?.(rr);e&&typeof e.then==`function`?e.then(e=>{ir=!!(e&&e[rr])}).catch(()=>{}):e&&typeof e==`object`&&(ir=!!e[rr])}catch{}a.debug(`[SidePanel] messagedirectory featureinitializing`)}function ur(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){ir||pr();return}fr(r,i)}function dr(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||ir)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||pr(),N.tocHideTimer=null},800))}function fr(e,t){let n=Array.from(t);N.messageTocContainer&&pr(),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}"
|
|
@@ -26,7 +26,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
|
|
|
26
26
|
</ul>
|
|
27
27
|
</div>
|
|
28
28
|
</div>
|
|
29
|
-
`;let s=e.closest(`.message-fullscreen-overlay`),c=e.closest(`.workspace-preview-overlay.fullscreen`);(s?s.querySelector(`.message-fullscreen-rail`)||er(`toc`):c&&c.querySelector(`.workspace-preview-rail`)||er(`toc`)).appendChild(i),N.messageTocContainer=i;let l=i.querySelector(`.message-toc-toggle`),u=i.querySelector(`.message-toc-panel`);ir&&(u.classList.add(`expanded`,`locked`),It(u));let d=i.querySelector(`.message-toc-lock`);d.addEventListener(`click`,e=>{e.stopPropagation(),ir=!ir,cr(),sr(d),ir?(u.classList.add(`expanded`,`locked`),It(u)):u.classList.remove(`locked`)}),i.querySelector(`.message-toc-close`).addEventListener(`click`,e=>{e.stopPropagation(),ir&&(ir=!1,cr()),pr()}),l.addEventListener(`mouseenter`,()=>{u.classList.add(`expanded`),It(u)}),l.addEventListener(`click`,()=>{u.classList.toggle(`expanded`)?It(u):Gt(u)}),u.addEventListener(`mouseenter`,()=>{u.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 pr(){N.tocHideTimer&&=(clearTimeout(N.tocHideTimer),null),N.messageTocContainer&&=(N.messageTocContainer.remove(),null)}var mr=`promptQueues`,hr=1,gr=30*1e3,_r=15*1e3,vr=20,R={QUEUED:`queued`,DISPATCHING:`dispatching`,INJECTING:`injecting`,INJECTED:`injected`,DONE:`done`,FAILED:`failed`};new Set([R.INJECTED,R.DONE,R.FAILED]);var yr={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 br(){return{version:hr,sessions:{}}}var z=br(),xr=!1,Sr=null,Cr=!1,wr=``,Tr=new Set,Er=new Set;function Dr(){return{items:[],recent:[],paused:!1,pausedReason:null}}function Or(e){return e?(z.sessions[e]||(z.sessions[e]=Dr()),z.sessions[e]):Dr()}function kr(){return JSON.stringify(z)}function Ar(e,t){for(let n of Er)try{n(e,t)}catch(e){a.error(`[QueueStore] listener failed:`,e?.message)}}function jr(){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 Nr(e,t){let n=e.indexOf(t);n<0||(e.splice(n,1),e.unshift(t),Pr(e))}function Pr(e){e.forEach((e,t)=>{e.order=t+1})}function Fr(e){return e.slice().sort((e,t)=>(Number(e.order)||0)-(Number(t.order)||0))}async function Ir(e){if(Cr)return a.error(`[QueueStore] persist skipped in degraded mode:`,e),!1;let t=kr();wr=t,Lr(t);try{await yr.set({[mr]:z})}catch(e){a.error(`[QueueStore] persist failed:`,e?.message)}Ar(e)}function Lr(e){if(Tr.add(e),Tr.size<=vr)return;let t=Tr.values().next().value;Tr.delete(t)}function Rr(e,{recoverInterrupted:t=!0}={}){let n=br();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=Fr(r);if(o){let e=s.filter(e=>e.interrupted),t=s.filter(e=>!e.interrupted);s.splice(0,s.length,...e,...t)}Pr(s);let c=s.slice(0,20),l=s.slice(20);for(let e of l.reverse())a.unshift(si({...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 zr(){return Cr}async function Br(){return xr?z:Sr||(Sr=(async()=>{let e;try{e=await yr.get(mr)}catch(e){return Cr=!0,Sr=null,a.error(`[QueueStore] load failed, enter degraded mode:`,e?.message),z}return z=Rr(e),xr=!0,Cr=!1,wr=kr(),z})(),Sr)}function Vr(){typeof chrome>`u`||!chrome.storage?.onChanged?.addListener||chrome.storage.onChanged.addListener((e,t)=>{if(t!==`local`||!e?.[mr])return;let n=e[mr].newValue;if(!n)return;let r=JSON.stringify(n);Tr.has(r)||r===wr||(z=Rr(n,{recoverInterrupted:!1}),xr=!0,wr=r,Ar(`external`,null))})}function Hr(e){return typeof e==`function`?(Er.add(e),()=>Er.delete(e)):()=>{}}function Ur(e){let t=z.sessions[e];return t?Fr(t.items):[]}function Wr(e,t=30){let n=z.sessions[e];return n?n.recent.slice(0,t):[]}function Gr(e){let t=z.sessions[e];return t?{items:Fr(t.items),recent:t.recent.slice(),paused:t.paused===!0,pausedReason:t.pausedReason||null}:Dr()}function Kr(e){return Ur(e).filter(e=>e.status===R.QUEUED).length}function qr(e){return Ur(e).find(e=>e.status===R.QUEUED)||null}function Jr(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 Yr(e,t){let n=z.sessions[e];return n&&n.items.find(e=>e.id===t)||null}function Xr(){return Object.keys(z.sessions).filter(e=>(z.sessions[e]?.items?.length||0)>0)}function Zr(e){return z.sessions[e]?.paused===!0}async function Qr({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 Br(),Cr)return{ok:!1,error:`storage_unavailable`};let s=Or(e);if(s.items.length>=20)return{ok:!1,error:`queue_full`,limit:20};let c={id:jr(),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 Ir(`enqueue`),{ok:!0,item:c,position:s.items.length}}async function $r(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),Pr(n.items),await Ir(`remove`),!0)}async function ei(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 Fr(n.items))i.includes(e)||i.push(e);return n.items=i,Pr(n.items),await Ir(`reorder`),!0}async function ti(e,t,n,r={}){let i=Yr(e,t);return i?(i.status=n,Object.assign(i,r,{updatedAt:Date.now()}),await Ir(`status`),!0):!1}async function ni(e,t,n=_r){let r=Yr(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 Ir(`inject:request`),!0):!1}async function ri(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,Nr(i.items,a),await Ir(`inject:rollback`),!0):!1}async function ii(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 Pr(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(si(c)),o.recent=o.recent.slice(0,30),await Ir(`settle`),!0}async function ai(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 Ir(`requeue`),{ok:!0,item:a}}async function oi(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 Ir(`recent-remove`),!0)}function si(e){let{leaseOwner:t,leaseUntil:n,injectDeadlineAt:r,contextSnapshot:i,...a}=e;return{...a,hasContext:e.hasContext===!0,contextDropped:!!i}}async function ci(e,t=`user_stopped`){let n=Or(e);return n.paused?!1:(n.paused=!0,n.pausedReason=t,await Ir(`pause`),!0)}async function li(e){let t=z.sessions[e];return!t||!t.paused?!1:(t.paused=!1,t.pausedReason=null,await Ir(`resume`),!0)}async function ui(e,t,n){let r=Yr(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+gr,await Ir(`lease`),!0)}async function di(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 Ir(`drop-session`),n}var fi=`ai-helper-queue-attachments`,pi=1,mi=`attachments`,hi=null,gi=null;function _i(){return new Promise((e,t)=>{let n=indexedDB.open(fi,pi);n.onupgradeneeded=e=>{let t=e.target.result;t.objectStoreNames.contains(mi)||t.createObjectStore(mi,{keyPath:`id`}).createIndex(`sessionId`,`sessionId`,{unique:!1})},n.onsuccess=t=>{let n=t.target.result;n.onversionchange=()=>{try{n.close()}catch{}hi=null},e(n)},n.onerror=()=>t(n.error||Error(`idb_open_failed`)),n.onblocked=()=>{}})}function vi(){return hi||=_i(),hi}function yi(e,t){return vi().then(n=>new Promise((r,i)=>{let a;try{a=n.transaction(mi,e)}catch(e){hi=null,i(e);return}let o=a.objectStore(mi),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 bi(){return{async put(e){await yi(`readwrite`,t=>{t.put(e)})},async get(e){return yi(`readonly`,(t,n)=>{let r=t.get(e);r.onsuccess=()=>n(r.result||null)})},async remove(e){await yi(`readwrite`,t=>{t.delete(e)})},async removeBySession(e){await yi(`readwrite`,t=>{let n=t.index(`sessionId`).getAllKeys(e);n.onsuccess=()=>{for(let e of n.result||[])t.delete(e)}})},async allKeys(){return yi(`readonly`,(e,t)=>{let n=e.getAllKeys();n.onsuccess=()=>t(n.result||[])})}}}function xi(){return gi||bi()}function Si(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+Si(t),0):typeof e==`object`?Object.values(e).reduce((e,t)=>e+Si(t),0):0}function Ci(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 wi(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=Si(n)+Si(r);if(i>26214400)return{ok:!1,reason:`too_large`,size:i};try{return await xi().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 Ti(e){if(!e)return null;try{let t=await xi().get(e);return t?{images:t.images||[],files:t.files||[]}:null}catch{return null}}async function Ei(e){if(!e)return!1;try{return await xi().remove(e),!0}catch{return!1}}async function Di(e){if(!e)return!1;try{return await xi().removeBySession(e),!0}catch{return!1}}async function Oi(e){let t=e instanceof Set?e:new Set(e||[]);try{let e=await xi().allKeys(),n=0;for(let r of e||[])t.has(r)||(await xi().remove(r),n+=1);return n}catch{return 0}}var ki=t({appendMessageToSession:()=>Zi,archiveCurrentSession:()=>Wi,archiveSession:()=>qi,clearSessionCompleted:()=>Pi,createSession:()=>zi,deleteArchivedSession:()=>Yi,deleteSession:()=>Vi,duplicateSession:()=>Qi,hydrateSessionWorkdir:()=>Li,importSessions:()=>Xi,isSessionArchivable:()=>Ki,loadArchivedSessions:()=>Gi,loadSessions:()=>Fi,markSessionCompleted:()=>Ni,persistSessionState:()=>Ri,renameSession:()=>Hi,reorderSessions:()=>Ui,restoreCompletedSessions:()=>ji,restoreSession:()=>Ji,saveCurrentSession:()=>Ii,switchToSession:()=>Bi}),Ai=`completedSessionIds`;async function ji(){try{let e=(await chrome.storage.local.get([Ai]))[Ai]||[];N.completedSessionIds=new Set(e)}catch(e){a.warn(`[SessionManager] restore completedSessionIds failed:`,e)}}async function Mi(){try{await chrome.storage.local.set({[Ai]:Array.from(N.completedSessionIds)})}catch(e){a.warn(`[SessionManager] persist completedSessionIds failed:`,e)}}async function Ni(e){e&&e!==N.activeSessionId&&(N.completedSessionIds.has(e)||(N.completedSessionIds.add(e),await Mi(),document.dispatchEvent(new CustomEvent(`generating-state-changed`))))}async function Pi(e){e&&N.completedSessionIds.has(e)&&(N.completedSessionIds.delete(e),await Mi(),document.dispatchEvent(new CustomEvent(`generating-state-changed`)))}async function Fi(){return ke()}async function Ii(){return Pe()}function Li(e){return Oe(e)}async function Ri(e,t){return Me(e,t)}async function zi(){return Ee()}async function Bi(e){return nt(e)}async function Vi(e){await di(e)>0&&Di(e);let t=await We(e);try{chrome.runtime.sendMessage({type:`DROP_GOAL`,sessionId:e},()=>{chrome.runtime.lastError&&a.debug(`[SessionManager] DROP_GOAL skipped:`,chrome.runtime.lastError.message)})}catch(e){a.debug(`[SessionManager] DROP_GOAL send failed:`,e?.message)}return N.completedSessionIds.has(e)&&(N.completedSessionIds.delete(e),await Mi()),t}async function Hi(e,t){return Ke(e,t)}async function Ui(e){return Be(e)}async function Wi(){return He()}async function Gi(){return $e()}function Ki(e){return e?N.generatingSessionIds.has(e)||N.pendingCallApiSessionIds.has(e)?{ok:!1,reason:`running`}:Kr(e)>0?{ok:!1,reason:`queued`}:{ok:!0}:{ok:!1,reason:`missing`}}async function qi(e){let t=Ki(e);return t.ok?await Je(e)?(N.completedSessionIds.has(e)&&(N.completedSessionIds.delete(e),await Mi(),document.dispatchEvent(new CustomEvent(`generating-state-changed`))),{ok:!0}):{ok:!1,reason:`missing`}:t}async function Ji(e){return at(e)}async function Yi(e){return Vi(e)}async function Xi(e){return Re(e)}async function Zi(e,t){return Ze(e,t)}async function Qi(e,t=null){return Xe(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 $i=[],ea=[];function ta(e){if(!e)return``;let t=`tool.${e.id}`,n=r(t);return n===t?e.description||``:n}function na(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 ra(){try{let e=await chrome.runtime.sendMessage({type:`GET_MCP_TOOLS`});if(e?.success&&e.tools)return $i=e.tools,$i}catch{}try{return $i=(await chrome.storage.local.get([`mcpTools`])).mcpTools||[],$i}catch{return $i=[],[]}}async function ia(){try{ea=(await chrome.storage.local.get([`ragTools`])).ragTools||[]}catch{ea=[]}return ea}async function aa(){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-sKnc7YcJ.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 oa=!1,sa=!0;chrome.storage.local.get([`enableToolPreselect`,`toolConfirmationEnabled`],e=>{oa=e.enableToolPreselect===!0,sa=e.toolConfirmationEnabled!==!1,Na()}),chrome.storage.onChanged.addListener((e,t)=>{if(t!==`local`)return;let n=!1;e.mcpTools&&($i=e.mcpTools.newValue||[],a.debug(`[SidePanel] MCP toolcache updated:`,$i.length,``),n=!0),e.ragTools&&(ea=e.ragTools.newValue||[],a.debug(`[SidePanel] RAG toolcache updated:`,ea.length),n=!0),e.mcpEnabled&&(ca=e.mcpEnabled.newValue===!0,a.debug(`[SidePanel] MCP globaltoggle changed:`,ca),n=!0),e.skillsEnabled&&(la=e.skillsEnabled.newValue!==!1,a.debug(`[SidePanel] Skill global toggle changed:`,la),n=!0),e.enableImageInput&&(ua=e.enableImageInput.newValue===!0,a.debug(`[SidePanel] 图片识别全局开关变更:`,ua),n=!0);let r=!1;e.enableToolPreselect&&(oa=e.enableToolPreselect.newValue===!0,r=!0),e.toolConfirmationEnabled&&(sa=e.toolConfirmationEnabled.newValue!==!1,r=!0),r&&Na(),n&&(document.getElementById(`toolsPopupOverlay`)?.classList.contains(`show`)&&(Oa(),ka(),ba()),Ma())}),ra().then(()=>Ma()),ia().then(()=>Ma());var ca=!1,la=!0,ua=!1;chrome.storage.local.get([`mcpEnabled`,`skillsEnabled`,`enableImageInput`],e=>{ca=e.mcpEnabled===!0,la=e.skillsEnabled!==!1,ua=e.enableImageInput===!0,Ma()});function da(){let e=[...x,...ea],t=N.activeAgentToolIds,n=e;if(t!=null){let r=new Set(t);n=e.filter(e=>r.has(e.id))}return la||(n=n.filter(e=>e.id!==`agent_skill`)),N.agentPlatform?.connected!==!0&&(n=n.filter(e=>!e.id.startsWith(`agent_`)&&!e.id.startsWith(`knowledge_`))),ua||(n=n.filter(e=>e.id!==`read_image`)),n}function fa(){if(!ca||N.agentPlatform?.connected!==!0)return[];let e=new Map;return $i.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 pa(e){return Array.isArray(N.mcpClosedServers)&&N.mcpClosedServers.includes(e)}function ma(e){return Array.isArray(N.activeAgentMcpExcludedServerIds)&&N.activeAgentMcpExcludedServerIds.includes(e)}function ha(e){return!pa(e)&&!ma(e)}function ga(){if(N.currentCategory!==`all`&&N.currentCategory!==`mcp`)return[];let e=fa();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)||ta(e).toLowerCase().includes(t)))}return e}function _a(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 va(){let e=document.getElementById(`toolsPopupOverlay`);if(!e)return;N.currentCategory=`all`,N.currentSearch=``;let t=document.getElementById(`toolsSearchInput`);t&&(t.value=``),await ra(),await ia(),await aa(),Oa(),ka(),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)`)}),ba(),e.classList.add(`show`),a.debug(`[SidePanel] opentool popup`)}function ya(){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 ba(){let e=document.getElementById(`toolsPopupList`);if(!e)return;e.innerHTML=``;let t=da();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=ta(e).toLowerCase().includes(N.currentSearch);if(!t&&!n)return}let t=e.category||`other`;n[t]||(n[t]=[]),n[t].push(e)});let i=ga();if(Ln.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=>ha(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=`
|
|
29
|
+
`;let s=e.closest(`.message-fullscreen-overlay`),c=e.closest(`.workspace-preview-overlay.fullscreen`);(s?s.querySelector(`.message-fullscreen-rail`)||er(`toc`):c&&c.querySelector(`.workspace-preview-rail`)||er(`toc`)).appendChild(i),N.messageTocContainer=i;let l=i.querySelector(`.message-toc-toggle`),u=i.querySelector(`.message-toc-panel`);ir&&(u.classList.add(`expanded`,`locked`),It(u));let d=i.querySelector(`.message-toc-lock`);d.addEventListener(`click`,e=>{e.stopPropagation(),ir=!ir,cr(),sr(d),ir?(u.classList.add(`expanded`,`locked`),It(u)):u.classList.remove(`locked`)}),i.querySelector(`.message-toc-close`).addEventListener(`click`,e=>{e.stopPropagation(),ir&&(ir=!1,cr()),pr()}),l.addEventListener(`mouseenter`,()=>{u.classList.add(`expanded`),It(u)}),l.addEventListener(`click`,()=>{u.classList.toggle(`expanded`)?It(u):Gt(u)}),u.addEventListener(`mouseenter`,()=>{u.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 pr(){N.tocHideTimer&&=(clearTimeout(N.tocHideTimer),null),N.messageTocContainer&&=(N.messageTocContainer.remove(),null)}var mr=`promptQueues`,hr=1,gr=30*1e3,_r=15*1e3,vr=20,R={QUEUED:`queued`,DISPATCHING:`dispatching`,INJECTING:`injecting`,INJECTED:`injected`,DONE:`done`,FAILED:`failed`};new Set([R.INJECTED,R.DONE,R.FAILED]);var yr={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 br(){return{version:hr,sessions:{}}}var z=br(),xr=!1,Sr=null,Cr=!1,wr=``,Tr=new Set,Er=new Set;function Dr(){return{items:[],recent:[],paused:!1,pausedReason:null}}function Or(e){return e?(z.sessions[e]||(z.sessions[e]=Dr()),z.sessions[e]):Dr()}function kr(){return JSON.stringify(z)}function Ar(e,t){for(let n of Er)try{n(e,t)}catch(e){a.error(`[QueueStore] listener failed:`,e?.message)}}function jr(){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 Nr(e,t){let n=e.indexOf(t);n<0||(e.splice(n,1),e.unshift(t),Pr(e))}function Pr(e){e.forEach((e,t)=>{e.order=t+1})}function Fr(e){return e.slice().sort((e,t)=>(Number(e.order)||0)-(Number(t.order)||0))}async function Ir(e){if(Cr)return a.error(`[QueueStore] persist skipped in degraded mode:`,e),!1;let t=kr();wr=t,Lr(t);try{await yr.set({[mr]:z})}catch(e){a.error(`[QueueStore] persist failed:`,e?.message)}Ar(e)}function Lr(e){if(Tr.add(e),Tr.size<=vr)return;let t=Tr.values().next().value;Tr.delete(t)}function Rr(e,{recoverInterrupted:t=!0}={}){let n=br();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=Fr(r);if(o){let e=s.filter(e=>e.interrupted),t=s.filter(e=>!e.interrupted);s.splice(0,s.length,...e,...t)}Pr(s);let c=s.slice(0,20),l=s.slice(20);for(let e of l.reverse())a.unshift(si({...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 zr(){return Cr}async function Br(){return xr?z:Sr||(Sr=(async()=>{let e;try{e=await yr.get(mr)}catch(e){return Cr=!0,Sr=null,a.error(`[QueueStore] load failed, enter degraded mode:`,e?.message),z}return z=Rr(e),xr=!0,Cr=!1,wr=kr(),z})(),Sr)}function Vr(){typeof chrome>`u`||!chrome.storage?.onChanged?.addListener||chrome.storage.onChanged.addListener((e,t)=>{if(t!==`local`||!e?.[mr])return;let n=e[mr].newValue;if(!n)return;let r=JSON.stringify(n);Tr.has(r)||r===wr||(z=Rr(n,{recoverInterrupted:!1}),xr=!0,wr=r,Ar(`external`,null))})}function Hr(e){return typeof e==`function`?(Er.add(e),()=>Er.delete(e)):()=>{}}function Ur(e){let t=z.sessions[e];return t?Fr(t.items):[]}function Wr(e,t=30){let n=z.sessions[e];return n?n.recent.slice(0,t):[]}function Gr(e){let t=z.sessions[e];return t?{items:Fr(t.items),recent:t.recent.slice(),paused:t.paused===!0,pausedReason:t.pausedReason||null}:Dr()}function Kr(e){return Ur(e).filter(e=>e.status===R.QUEUED).length}function qr(e){return Ur(e).find(e=>e.status===R.QUEUED)||null}function Jr(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 Yr(e,t){let n=z.sessions[e];return n&&n.items.find(e=>e.id===t)||null}function Xr(){return Object.keys(z.sessions).filter(e=>(z.sessions[e]?.items?.length||0)>0)}function Zr(e){return z.sessions[e]?.paused===!0}async function Qr({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 Br(),Cr)return{ok:!1,error:`storage_unavailable`};let s=Or(e);if(s.items.length>=20)return{ok:!1,error:`queue_full`,limit:20};let c={id:jr(),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 Ir(`enqueue`),{ok:!0,item:c,position:s.items.length}}async function $r(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),Pr(n.items),await Ir(`remove`),!0)}async function ei(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 Fr(n.items))i.includes(e)||i.push(e);return n.items=i,Pr(n.items),await Ir(`reorder`),!0}async function ti(e,t,n,r={}){let i=Yr(e,t);return i?(i.status=n,Object.assign(i,r,{updatedAt:Date.now()}),await Ir(`status`),!0):!1}async function ni(e,t,n=_r){let r=Yr(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 Ir(`inject:request`),!0):!1}async function ri(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,Nr(i.items,a),await Ir(`inject:rollback`),!0):!1}async function ii(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 Pr(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(si(c)),o.recent=o.recent.slice(0,30),await Ir(`settle`),!0}async function ai(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 Ir(`requeue`),{ok:!0,item:a}}async function oi(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 Ir(`recent-remove`),!0)}function si(e){let{leaseOwner:t,leaseUntil:n,injectDeadlineAt:r,contextSnapshot:i,...a}=e;return{...a,hasContext:e.hasContext===!0,contextDropped:!!i}}async function ci(e,t=`user_stopped`){let n=Or(e);return n.paused?!1:(n.paused=!0,n.pausedReason=t,await Ir(`pause`),!0)}async function li(e){let t=z.sessions[e];return!t||!t.paused?!1:(t.paused=!1,t.pausedReason=null,await Ir(`resume`),!0)}async function ui(e,t,n){let r=Yr(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+gr,await Ir(`lease`),!0)}async function di(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 Ir(`drop-session`),n}var fi=`ai-helper-queue-attachments`,pi=1,mi=`attachments`,hi=null,gi=null;function _i(){return new Promise((e,t)=>{let n=indexedDB.open(fi,pi);n.onupgradeneeded=e=>{let t=e.target.result;t.objectStoreNames.contains(mi)||t.createObjectStore(mi,{keyPath:`id`}).createIndex(`sessionId`,`sessionId`,{unique:!1})},n.onsuccess=t=>{let n=t.target.result;n.onversionchange=()=>{try{n.close()}catch{}hi=null},e(n)},n.onerror=()=>t(n.error||Error(`idb_open_failed`)),n.onblocked=()=>{}})}function vi(){return hi||=_i(),hi}function yi(e,t){return vi().then(n=>new Promise((r,i)=>{let a;try{a=n.transaction(mi,e)}catch(e){hi=null,i(e);return}let o=a.objectStore(mi),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 bi(){return{async put(e){await yi(`readwrite`,t=>{t.put(e)})},async get(e){return yi(`readonly`,(t,n)=>{let r=t.get(e);r.onsuccess=()=>n(r.result||null)})},async remove(e){await yi(`readwrite`,t=>{t.delete(e)})},async removeBySession(e){await yi(`readwrite`,t=>{let n=t.index(`sessionId`).getAllKeys(e);n.onsuccess=()=>{for(let e of n.result||[])t.delete(e)}})},async allKeys(){return yi(`readonly`,(e,t)=>{let n=e.getAllKeys();n.onsuccess=()=>t(n.result||[])})}}}function xi(){return gi||bi()}function Si(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+Si(t),0):typeof e==`object`?Object.values(e).reduce((e,t)=>e+Si(t),0):0}function Ci(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 wi(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=Si(n)+Si(r);if(i>26214400)return{ok:!1,reason:`too_large`,size:i};try{return await xi().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 Ti(e){if(!e)return null;try{let t=await xi().get(e);return t?{images:t.images||[],files:t.files||[]}:null}catch{return null}}async function Ei(e){if(!e)return!1;try{return await xi().remove(e),!0}catch{return!1}}async function Di(e){if(!e)return!1;try{return await xi().removeBySession(e),!0}catch{return!1}}async function Oi(e){let t=e instanceof Set?e:new Set(e||[]);try{let e=await xi().allKeys(),n=0;for(let r of e||[])t.has(r)||(await xi().remove(r),n+=1);return n}catch{return 0}}var ki=t({appendMessageToSession:()=>Zi,archiveCurrentSession:()=>Wi,archiveSession:()=>qi,clearSessionCompleted:()=>Pi,createSession:()=>zi,deleteArchivedSession:()=>Yi,deleteSession:()=>Vi,duplicateSession:()=>Qi,hydrateSessionWorkdir:()=>Li,importSessions:()=>Xi,isSessionArchivable:()=>Ki,loadArchivedSessions:()=>Gi,loadSessions:()=>Fi,markSessionCompleted:()=>Ni,persistSessionState:()=>Ri,renameSession:()=>Hi,reorderSessions:()=>Ui,restoreCompletedSessions:()=>ji,restoreSession:()=>Ji,saveCurrentSession:()=>Ii,switchToSession:()=>Bi}),Ai=`completedSessionIds`;async function ji(){try{let e=(await chrome.storage.local.get([Ai]))[Ai]||[];N.completedSessionIds=new Set(e)}catch(e){a.warn(`[SessionManager] restore completedSessionIds failed:`,e)}}async function Mi(){try{await chrome.storage.local.set({[Ai]:Array.from(N.completedSessionIds)})}catch(e){a.warn(`[SessionManager] persist completedSessionIds failed:`,e)}}async function Ni(e){e&&e!==N.activeSessionId&&(N.completedSessionIds.has(e)||(N.completedSessionIds.add(e),await Mi(),document.dispatchEvent(new CustomEvent(`generating-state-changed`))))}async function Pi(e){e&&N.completedSessionIds.has(e)&&(N.completedSessionIds.delete(e),await Mi(),document.dispatchEvent(new CustomEvent(`generating-state-changed`)))}async function Fi(){return ke()}async function Ii(){return Pe()}function Li(e){return Oe(e)}async function Ri(e,t){return Me(e,t)}async function zi(){return Ee()}async function Bi(e){return nt(e)}async function Vi(e){await di(e)>0&&Di(e);let t=await We(e);try{chrome.runtime.sendMessage({type:`DROP_GOAL`,sessionId:e},()=>{chrome.runtime.lastError&&a.debug(`[SessionManager] DROP_GOAL skipped:`,chrome.runtime.lastError.message)})}catch(e){a.debug(`[SessionManager] DROP_GOAL send failed:`,e?.message)}return N.completedSessionIds.has(e)&&(N.completedSessionIds.delete(e),await Mi()),t}async function Hi(e,t){return Ke(e,t)}async function Ui(e){return Be(e)}async function Wi(){return He()}async function Gi(){return $e()}function Ki(e){return e?N.generatingSessionIds.has(e)||N.pendingCallApiSessionIds.has(e)?{ok:!1,reason:`running`}:Kr(e)>0?{ok:!1,reason:`queued`}:{ok:!0}:{ok:!1,reason:`missing`}}async function qi(e){let t=Ki(e);return t.ok?await Je(e)?(N.completedSessionIds.has(e)&&(N.completedSessionIds.delete(e),await Mi(),document.dispatchEvent(new CustomEvent(`generating-state-changed`))),{ok:!0}):{ok:!1,reason:`missing`}:t}async function Ji(e){return at(e)}async function Yi(e){return Vi(e)}async function Xi(e){return Re(e)}async function Zi(e,t){return Ze(e,t)}async function Qi(e,t=null){return Xe(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 $i=[],ea=[];function ta(e){if(!e)return``;let t=`tool.${e.id}`,n=r(t);return n===t?e.description||``:n}function na(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 ra(){try{let e=await chrome.runtime.sendMessage({type:`GET_MCP_TOOLS`});if(e?.success&&e.tools)return $i=e.tools,$i}catch{}try{return $i=(await chrome.storage.local.get([`mcpTools`])).mcpTools||[],$i}catch{return $i=[],[]}}async function ia(){try{ea=(await chrome.storage.local.get([`ragTools`])).ragTools||[]}catch{ea=[]}return ea}async function aa(){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-CuK2pMqc.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 oa=!1,sa=!0;chrome.storage.local.get([`enableToolPreselect`,`toolConfirmationEnabled`],e=>{oa=e.enableToolPreselect===!0,sa=e.toolConfirmationEnabled!==!1,Na()}),chrome.storage.onChanged.addListener((e,t)=>{if(t!==`local`)return;let n=!1;e.mcpTools&&($i=e.mcpTools.newValue||[],a.debug(`[SidePanel] MCP toolcache updated:`,$i.length,``),n=!0),e.ragTools&&(ea=e.ragTools.newValue||[],a.debug(`[SidePanel] RAG toolcache updated:`,ea.length),n=!0),e.mcpEnabled&&(ca=e.mcpEnabled.newValue===!0,a.debug(`[SidePanel] MCP globaltoggle changed:`,ca),n=!0),e.skillsEnabled&&(la=e.skillsEnabled.newValue!==!1,a.debug(`[SidePanel] Skill global toggle changed:`,la),n=!0),e.enableImageInput&&(ua=e.enableImageInput.newValue===!0,a.debug(`[SidePanel] 图片识别全局开关变更:`,ua),n=!0);let r=!1;e.enableToolPreselect&&(oa=e.enableToolPreselect.newValue===!0,r=!0),e.toolConfirmationEnabled&&(sa=e.toolConfirmationEnabled.newValue!==!1,r=!0),r&&Na(),n&&(document.getElementById(`toolsPopupOverlay`)?.classList.contains(`show`)&&(Oa(),ka(),ba()),Ma())}),ra().then(()=>Ma()),ia().then(()=>Ma());var ca=!1,la=!0,ua=!1;chrome.storage.local.get([`mcpEnabled`,`skillsEnabled`,`enableImageInput`],e=>{ca=e.mcpEnabled===!0,la=e.skillsEnabled!==!1,ua=e.enableImageInput===!0,Ma()});function da(){let e=[...x,...ea],t=N.activeAgentToolIds,n=e;if(t!=null){let r=new Set(t);n=e.filter(e=>r.has(e.id))}return la||(n=n.filter(e=>e.id!==`agent_skill`)),N.agentPlatform?.connected!==!0&&(n=n.filter(e=>!e.id.startsWith(`agent_`)&&!e.id.startsWith(`knowledge_`))),ua||(n=n.filter(e=>e.id!==`read_image`)),n}function fa(){if(!ca||N.agentPlatform?.connected!==!0)return[];let e=new Map;return $i.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 pa(e){return Array.isArray(N.mcpClosedServers)&&N.mcpClosedServers.includes(e)}function ma(e){return Array.isArray(N.activeAgentMcpExcludedServerIds)&&N.activeAgentMcpExcludedServerIds.includes(e)}function ha(e){return!pa(e)&&!ma(e)}function ga(){if(N.currentCategory!==`all`&&N.currentCategory!==`mcp`)return[];let e=fa();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)||ta(e).toLowerCase().includes(t)))}return e}function _a(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 va(){let e=document.getElementById(`toolsPopupOverlay`);if(!e)return;N.currentCategory=`all`,N.currentSearch=``;let t=document.getElementById(`toolsSearchInput`);t&&(t.value=``),await ra(),await ia(),await aa(),Oa(),ka(),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)`)}),ba(),e.classList.add(`show`),a.debug(`[SidePanel] opentool popup`)}function ya(){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 ba(){let e=document.getElementById(`toolsPopupList`);if(!e)return;e.innerHTML=``;let t=da();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=ta(e).toLowerCase().includes(N.currentSearch);if(!t&&!n)return}let t=e.category||`other`;n[t]||(n[t]=[]),n[t].push(e)});let i=ga();if(Ln.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=>ha(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=`
|
|
30
30
|
<span class="category-expand-icon">${f?`▶`:`▼`}</span>
|
|
31
31
|
<span class="category-name">${r(`toolCategory.`+a)}</span>
|
|
32
32
|
<span class="category-count">${l}</span>
|
|
@@ -57,7 +57,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
|
|
|
57
57
|
`,i.addEventListener(`click`,()=>Co(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=`
|
|
58
58
|
<div class="clarify-option-radio"></div>
|
|
59
59
|
<div class="clarify-option-content clarify-option-other">${r(`clarify.otherOption`)}</div>
|
|
60
|
-
`,e.addEventListener(`click`,()=>Co(-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`),to=null,no=!1,co(),oo(s),a.debug(`[SidePanel] clarification dialogshown:`,e.toolCallId,t),!0}function ho(){if(eo)return!0;if($a.length===0)return!1;let e=$a.shift();return mo(e)?(eo=e,Za(Qa,e),!0):(a.error(`[SidePanel] clarify overlay missing, settle as unanswered:`,e.toolCallId),go(e),L(r(`clarify.dropped`),`warning`),!1)}function go(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 _o(){if($a.length>0){Ga(Qa);return}vo(),Ka(Qa)}function vo(){let e=document.getElementById(`clarifyOverlay`);e&&e.classList.remove(`show`),N.currentClarifyToolCallId=null,N.currentClarifySessionId=null,so()}function yo(){eo=null,_o()}function bo(e,t){return!!e.toolCallId&&e.toolCallId===t.toolCallId&&(e.sessionId||null)===(t.sessionId||null)&&e.question===t.question}function xo(e){let t={...e,sessionId:e.sessionId||null};if(a.debug(`[SidePanel] showclarification dialog:`,t.toolCallId,e),eo&&bo(eo,t)){a.debug(`[SidePanel] duplicate clarify request, ignored:`,t.toolCallId);return}if($a.some(e=>bo(e,t))){a.debug(`[SidePanel] queued duplicate clarify, ignored:`,t.toolCallId);return}$a.push(t),Ga(Qa),po(),Ya(Qa)}function So(){if(eo){yo();return}vo()}function Co(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 wo(){if(!eo){a.error(`[SidePanel] no has currenttool callID`);return}let e=eo.toolCallId,t=eo.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),yo()}function To(){if(eo){let e={type:`CLARIFY_RESPONSE`,toolCallId:eo.toolCallId,sessionId:eo.sessionId,selectedOption:-1,customInput:``,additionalInfo:``};chrome.runtime.sendMessage(e)}So()}function Eo(e){return e?.reason===`timeout`&&e?.defaultOption||null}function Do(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(!eo)return;Oo(Eo(e));return}if(eo&&eo.toolCallId===t){Oo(Eo(e));return}let n=$a.findIndex(e=>e.toolCallId===t);n>=0&&(a.debug(`[SidePanel] drop queued clarify (already settled by background):`,t),$a.splice(n,1),po(),Ya(Qa))}function Oo(e=null){let t=eo?.question;yo(),L(e?r(`clarify.timedOutDefaulted`,{option:e}):`${r(`clarify.timedOut`)}${t?`:${t}`:``}`,`warning`),io(`error`)}Wa(Qa,{present:ho,pendingCount:()=>$a.length,refresh:po});function ko(){let e=document.getElementById(`clarifyConfirmBtn`);e&&e.addEventListener(`click`,wo);let t=document.getElementById(`clarifyCancelBtn`);t&&t.addEventListener(`click`,To);let n=document.getElementById(`clarifyExtendBtn`);n&&n.addEventListener(`click`,lo);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),xo(e.data),n({success:!0})):e.type===`PLAY_NOTIFICATION_SOUND`?(a.debug(`[SidePanel] recei to play soundrequested :`,e),io(e.soundType),n({success:!0})):e.type===`CLARIFY_TIMEOUT`?Do(e):e.type===`CLARIFY_EXTENDED`&&uo(e)}),a.debug(`[SidePanel] clarification dialogeventinitializing`)}var Ao=Ba.CONFIRM,jo=[],Mo=null,No=null,Po=null;function Fo(e){let t=Math.floor(e/60),n=e%60;return`${t}:${String(n).padStart(2,`0`)}`}function Io(){No&&=(clearInterval(No),null),Po&&=(clearTimeout(Po),null)}function Lo(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 Ro(e){let t=e.message||r(`dialog.confirmAction`,{name:e.toolLabel||e.toolName}),n=jo.length,i=Xa(Ao),a=t;return n>0&&(a+=` ${r(`dialog.pendingQueue`,{count:n})}`),i>0&&(a+=` ${r(`dialog.otherPending`,{count:i})}`),a}function zo(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=Ro(e)),Io();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:Fo(u)}),No=setInterval(()=>{if(u--,u<=0){clearInterval(No),No=null,d.textContent=r(`dialog.remainingTime`,{time:`0:00`});return}d.textContent=r(`dialog.remainingTime`,{time:Fo(u)}),u<=30&&f.classList.add(`warning`)},1e3)),s.style.display=`flex`,Po=setTimeout(()=>{a.debug(`[SidePanel] confirm dialogtimeout,autodeny`),Go(!1,`single`)},o),!0}function Bo(){if(Mo)return!0;if(jo.length===0)return!1;let e=jo.shift();return zo(e)?(Mo=e,Za(Ao,e),!0):(e.resolve&&e.resolve(!1),!1)}function Vo(){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 Ho(){if(jo.length>0){Ga(Ao);return}Vo(),Ka(Ao)}function Uo(e){let t=Mo?.resolve;Mo=null,Io(),t&&t(e),Ho()}function Wo(e){let t={...e,sessionId:e.sessionId||null};return a.debug(`[SidePanel] showconfirm dialog:`,t.toolName,e),Mo&&Lo(Mo,t)?(a.debug(`[SidePanel] duplicate confirm request, ignored:`,t.toolCallId),Promise.resolve(!1)):jo.some(e=>Lo(e,t))?(a.debug(`[SidePanel] queued duplicate confirm, ignored:`,t.toolCallId),Promise.resolve(!1)):new Promise(e=>{jo.push({...t,resolve:e}),Ga(Ao),Mo&&Ko(),Ya(Ao)})}function Go(e,t=`single`){if(!Mo)return;let n=Mo.toolCallId,r=Mo.sessionId;Io(),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)}),Uo(e)}function Ko(){if(!Mo)return;let e=document.getElementById(`confirmMessage`);e&&(e.textContent=Ro(Mo))}function qo(e){let t=e?.toolCallId;if(!t)return;if(Mo&&Mo.toolCallId===t){a.debug(`[SidePanel] dismiss active confirm dialog (already settled by background):`,t),Uo(!1);return}let n=jo.findIndex(e=>e.toolCallId===t);if(n>=0){a.debug(`[SidePanel] drop queued confirm dialog (already settled by background):`,t);let[e]=jo.splice(n,1);e.resolve&&e.resolve(!1),Ko(),Ya(Ao)}}Wa(Ao,{present:Bo,pendingCount:()=>jo.length,refresh:()=>{Mo&&Ko()}});function Jo(){let e=document.getElementById(`confirmApproveOnceBtn`),t=document.getElementById(`confirmApproveLoopBtn`),n=document.getElementById(`confirmDenyBtn`);e&&e.addEventListener(`click`,()=>Go(!0,`single`)),t&&t.addEventListener(`click`,()=>Go(!0,`loop`)),n&&n.addEventListener(`click`,()=>Go(!1,`single`)),chrome.runtime.onMessage.addListener((e,t,n)=>e.type===`SHOW_CONFIRM_DIALOG`?(Wo(e.data),n({received:!0}),!1):e.type===`DISMISS_CONFIRM_DIALOG`?(qo(e.data),n({received:!0}),!1):!1)}var Yo=t({closeCurrentSession:()=>Bc,handleDuplicateSession:()=>jc,handleSessionSwitch:()=>Ac,newSession:()=>ns,renderSessionTabs:()=>es});n(`zh`,{session:{newSession:`新会话`,closeSession:`关闭会话`,taskCompleted:`任务已完成`,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} 天前`,archive:`归档会话`,archiveEntry:`归档区`,archiveEntryTitle:`查看归档会话`,archivePanelTitle:`归档区`,archiveSearchPlaceholder:`搜索归档会话...`,archiveEmpty:`暂无归档会话`,archiveNoMatch:`未找到匹配的归档会话`,archiveHint:`归档只是移出视野,随时可以恢复`,archiveBusyRunning:`该会话任务还在执行,完成后再归档`,archiveBusyQueued:`该会话还有排队任务,先清空队列再归档`,archived:`已归档到归档区`,archivedRestored:`已恢复会话「{title}」`,archivedAt:`归档于 {time}`,restore:`恢复`,restoreTitle:`恢复到会话列表`,deleteForever:`彻底删除`,confirmDeleteForeverTitle:`彻底删除会话`,confirmDeleteForeverMessage:`「{title}」将被彻底删除,消息与执行记录都无法恢复。确定继续吗?`,archiveDeleted:`已彻底删除会话「{title}」`,backToSessionList:`返回会话列表`,expandSidebar:`展开会话列表`,collapseSidebar:`收起会话列表`,searchSessions:`搜索会话`,sortModeTitle:`会话排序`,sortManual:`手动排序(拖拽调整,与标签栏一致)`,sortRecent:`最近更新优先(按时间倒序,带时间分组)`}}),n(`en`,{session:{newSession:`New Session`,closeSession:`Close Session`,taskCompleted:`Task completed`,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:`{hour}:{minute}`,yesterdayFormat:`Yesterday {hour}:{minute}`,daysAgo:`{count}d ago`,archive:`Archive session`,archiveEntry:`Archived`,archiveEntryTitle:`View archived sessions`,archivePanelTitle:`Archived sessions`,archiveSearchPlaceholder:`Search archived sessions...`,archiveEmpty:`No archived sessions`,archiveNoMatch:`No archived sessions found`,archiveHint:`Archiving only hides a session — you can restore it anytime`,archiveBusyRunning:`This session is still running. Archive it when it finishes`,archiveBusyQueued:`This session still has queued tasks. Clear the queue first`,archived:`Moved to archive`,archivedRestored:`Session "{title}" restored`,archivedAt:`Archived {time}`,restore:`Restore`,restoreTitle:`Restore to session list`,deleteForever:`Delete permanently`,confirmDeleteForeverTitle:`Delete session permanently`,confirmDeleteForeverMessage:`"{title}" will be permanently deleted. Messages and execution logs cannot be recovered. Continue?`,archiveDeleted:`Session "{title}" permanently deleted`,backToSessionList:`Back to sessions`,expandSidebar:`Expand session list`,collapseSidebar:`Collapse session list`,searchSessions:`Search sessions`,sortModeTitle:`Session order`,sortManual:`Manual order (drag to arrange, same as tabs)`,sortRecent:`Most recent first (time order with day groups)`}});var B={visible:!1,highlightIndex:-1,filteredSessions:[]},Xo={draggedId:null,sourceType:null};function Zo(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 Qo(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 $o(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 es(e=null){let t=e||await Fi({withActiveHistory:!1});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.messageCount??e.messageHistory?.length??0)===0){ks(await Os(e.id)),await zc();return}Ic(e,async()=>{await zc()})}),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=Kr(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&&!Ec){Ec=!0,i.querySelectorAll(`.session-tab.active`).forEach(e=>e.classList.remove(`active`)),t.classList.add(`active`);try{await Ac(e.id)}finally{Ec=!1,N.activeSessionId!==e.id&&es({list:N.sessions,activeSessionId:N.activeSessionId})}}}),t.addEventListener(`contextmenu`,t=>{t.preventDefault(),Lc(t,e)}),t.addEventListener(`mousedown`,async t=>{t.button===1&&(t.preventDefault(),t.stopPropagation(),ks(await Os(e.id)),await zc())}),t.draggable=!0,t.addEventListener(`dragstart`,t=>ds(t,e.id)),t.addEventListener(`dragover`,e=>fs(e)),t.addEventListener(`dragleave`,e=>ps(e)),t.addEventListener(`drop`,t=>ms(t,e.id)),t.addEventListener(`dragend`,e=>hs(e)),i.appendChild(t)}),ts(),rs(),Ns(),Tc(),Pc(i),os(i),ss(i),us(i),ic(),dc())}function ts(){let e=document.getElementById(`sessionTabsMore`);if(!e)return;let t=e.cloneNode(!0);e.parentNode.replaceChild(t,e),t.addEventListener(`click`,e=>{e.stopPropagation(),$s()})}async function ns(){let e=N.activeSessionId;await Ii();let t=await zi();N.activeSessionId=t.id,N.messageHistory=[],N.activeCompaction=null,Li(t),document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:t.id,previousSessionId:e}})),es()}function rs(){let e=document.getElementById(`sessionTabsAdd`);if(!e)return;let t=e.cloneNode(!0);e.parentNode.replaceChild(t,e),t.addEventListener(`click`,()=>ns())}var is=0,as=0;function os(e){let t=document.getElementById(`sessionTabsMore`);if(!t)return;if(!qs()){t.style.display=`none`;return}let n=e.scrollWidth>e.clientWidth;t.style.display=n||is>0?`flex`:`none`}async function ss(e){let t=++as,n;try{n=await Gi()}catch{return}t===as&&(is=n.length,os(e))}var cs=null;function ls(){if(cs)return;let e=document.getElementById(`sessionTabsScroll`);e&&(cs=new ResizeObserver(()=>{requestAnimationFrame(()=>{os(e)})}),cs.observe(e))}function us(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 ds(e,t){Xo.draggedId=t,Xo.sourceType=`tab`,e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t),e.currentTarget.classList.add(`dragging`)}function fs(e){e.preventDefault(),e.dataTransfer.dropEffect=`move`,e.currentTarget.classList.add(`drag-over`)}function ps(e){e.currentTarget.classList.remove(`drag-over`)}async function ms(e,t){e.preventDefault(),e.currentTarget.classList.remove(`drag-over`);let n=Xo.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 Ui(o.map(e=>e.id)),es()}function hs(e){e.currentTarget.classList.remove(`dragging`),document.querySelectorAll(`.session-tab.drag-over`).forEach(e=>e.classList.remove(`drag-over`)),Xo.draggedId=null,Xo.sourceType=null}function gs(){B.visible?vs():_s()}async function _s(){let e=document.getElementById(`sessionTabsMore`),t=document.getElementById(`sessionDropdown`);if(!e||!t)return;let n=await Fi();N.sessions=n.list,N.activeSessionId=n.activeSessionId,B.filteredSessions=Qo([...n.list]),B.highlightIndex=-1,B.visible=!0,_c(),bs(),t.classList.add(`show`);let r=document.getElementById(`sessionDropdownCloseBtn`);r&&(r.onclick=()=>vs());let i=document.getElementById(`sessionDropdownSearch`),a=document.getElementById(`sessionDropdownSearchClear`);i&&(i.value=B.lastSearchText||``,ys(),B.lastSearchText&&Es(B.lastSearchText),setTimeout(()=>i.focus(),50),i.oninput=()=>{B.lastSearchText=i.value,ys(),Es(i.value)},i.onkeydown=e=>{Ps(e)}),a&&(a.onclick=()=>{i&&(i.value=``,B.lastSearchText=``,ys(),Es(``),i.focus())}),e.classList.add(`active`)}function vs(){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&&(B.lastSearchText=n.value,n.oninput=null,n.onkeydown=null);let r=document.getElementById(`sessionDropdownSearchClear`);r&&(r.onclick=null),B.visible=!1,B.highlightIndex=-1,B.filteredSessions=[]}function ys(){let e=document.getElementById(`sessionDropdownSearch`),t=document.getElementById(`sessionDropdownSearchClear`);t&&e&&(t.style.display=e.value?`flex`:`none`)}function bs(){xs({listEl:document.getElementById(`sessionDropdownList`),filteredSessions:B.filteredSessions,highlightIndex:B.highlightIndex,onSelect:e=>Ds(e)})}function xs({listEl:e,filteredSessions:t,highlightIndex:n,onSelect:i,grouped:a=!0,draggable:o=!1}){if(!e)return;if(e.innerHTML=``,t.length===0){let t=document.createElement(`div`);t.className=`session-dropdown-empty`,t.textContent=r(`session.noMatch`),e.appendChild(t);return}let s={today:r(`session.today`),yesterday:r(`session.yesterday`),last7Days:r(`session.last7Days`),earlier:r(`session.earlier`)},c={};a&&t.forEach(e=>{let t=$o(e.updatedAt);c[t]=(c[t]||0)+1});let l=null;t.forEach((t,u)=>{if(a){let n=$o(t.updatedAt);if(n!==l){l=n;let t=document.createElement(`div`);t.className=`session-dropdown-group-header`;let i=document.createElement(`span`);if(i.textContent=s[n]||n,t.appendChild(i),(c[n]||0)>0){let e=document.createElement(`button`);e.className=`session-dropdown-group-close`,e.textContent=r(`session.closeGroupAll`),e.onclick=e=>{e.stopPropagation(),Ms(n,s[n]||n)},t.appendChild(e)}e.appendChild(t)}}let d=Ts(t,{index:u,highlightIndex:n,onSelect:i});o&&Cs(d,t.id),e.appendChild(d)})}var Ss=null;function Cs(e,t){e.draggable=!0,e.classList.add(`draggable`),e.addEventListener(`dragstart`,n=>{Ss=t,n.dataTransfer.effectAllowed=`move`,n.dataTransfer.setData(`text/plain`,t),e.classList.add(`dragging`)}),e.addEventListener(`dragover`,n=>{!Ss||Ss===t||(n.preventDefault(),n.dataTransfer.dropEffect=`move`,e.classList.add(`drag-over`))}),e.addEventListener(`dragleave`,()=>e.classList.remove(`drag-over`)),e.addEventListener(`drop`,n=>{n.preventDefault(),n.stopPropagation(),e.classList.remove(`drag-over`),ws(Ss,t)}),e.addEventListener(`dragend`,()=>{e.classList.remove(`dragging`),document.querySelectorAll(`.session-dropdown-item.drag-over`).forEach(e=>e.classList.remove(`drag-over`)),Ss=null})}async function ws(e,t){let n=e;if(Ss=null,!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 Ui(o.map(e=>e.id)),await es()}function Ts(e,{index:t,highlightIndex:n,onSelect:i}){let a=document.createElement(`div`);a.className=`session-dropdown-item`,a.dataset.sessionId=e.id,a.dataset.index=t,e.id===N.activeSessionId&&a.classList.add(`active`),t===n&&a.classList.add(`highlighted`);let o=e.isGenerating||N.generatingSessionIds.has(e.id);if(N.completedSessionIds.has(e.id)&&e.id!==N.activeSessionId&&!o){let e=document.createElement(`span`);e.className=`session-dropdown-item-completed`,e.title=r(`session.taskCompleted`),a.appendChild(e)}let s=Kr(e.id);if(s>0){let e=document.createElement(`span`);e.className=`session-dropdown-item-queue`,e.textContent=String(s>99?`99+`:s),e.title=r(`queue.badgeTitle`,{count:s}),a.appendChild(e)}let c=document.createElement(`span`);if(c.className=`session-dropdown-item-icon`,o){let e=document.createElement(`span`);e.className=`session-dropdown-item-running`,c.appendChild(e)}else c.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>`;a.appendChild(c);let l=document.createElement(`span`);if(l.className=`session-dropdown-item-title`,l.textContent=e.title||r(`session.newSession`),l.title=e.title||r(`session.newSession`),a.appendChild(l),e.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>`,a.appendChild(e)}let u=document.createElement(`span`);u.className=`session-dropdown-item-time`,u.textContent=Zo(e.updatedAt),a.appendChild(u);let d=document.createElement(`span`);d.className=`session-dropdown-item-actions`;let f=document.createElement(`span`);f.className=`session-dropdown-item-rename`,f.title=r(`session.rename`),f.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>`,f.addEventListener(`click`,t=>{t.stopPropagation(),t.preventDefault(),Fc(e)}),d.appendChild(f);let p=document.createElement(`span`);p.className=`session-dropdown-item-duplicate`,p.title=r(`session.duplicate`),p.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>`,p.addEventListener(`click`,async t=>{t.stopPropagation(),t.preventDefault(),await jc(e.id);let n=await Fi({withActiveHistory:!1});N.sessions=n.list,N.activeSessionId=n.activeSessionId,Es(document.getElementById(`sessionDropdownSearch`)?.value||``)}),d.appendChild(p);let m=document.createElement(`span`);m.className=`session-dropdown-item-archive`,m.title=r(`session.archive`),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="M21 8v13H3V8"/><rect x="1" y="3" width="22" height="5"/><line x1="10" y1="12" x2="14" y2="12"/></svg>`,m.addEventListener(`click`,async t=>{t.stopPropagation(),t.preventDefault(),await hc(e.id),Es(document.getElementById(`sessionDropdownSearch`)?.value||``)}),d.appendChild(m);let h=document.createElement(`span`);return h.className=`session-dropdown-item-close`,h.innerHTML=`✕`,h.title=r(`session.closeSession`),h.addEventListener(`click`,async t=>{t.stopPropagation(),t.preventDefault(),await As(e.id)}),d.appendChild(h),a.appendChild(d),a.addEventListener(`click`,async t=>{t.preventDefault(),await i(e.id)}),a}function Es(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))}B.filteredSessions=Qo(n),B.highlightIndex=-1,bs()}async function Ds(e){vs(),e!==N.activeSessionId&&await Ac(e)}async function Os(e){let t=Kr(e)+Wr(e).length;return await Vi(e),t}function ks(e){e<=0||L(r(`queue.sessionDropped`,{count:e}),`info`,3e3)}async function As(e){let t=(N.sessions||[]).find(t=>t.id===e);t&&((e===N.activeSessionId?N.messageHistory?.length||0:t.messageCount??t.messageHistory?.length??0)>0&&!await fc(r(`session.confirmCloseMessageWithTitle`,{title:t.title}),r(`session.closeSession`))||(ks(await Os(e)),await zc(),Es(document.getElementById(`sessionDropdownSearch`)?.value||``)))}async function js(){let e=N.sessions||[];if(e.length===0||!await fc(r(`session.confirmCloseAllMessage`,{count:e.length}),r(`session.confirmCloseAllTitle`)))return;let t=0;for(let n of e)t+=await Os(n.id);ks(t),await zc(),Es(document.getElementById(`sessionDropdownSearch`)?.value||``)}async function Ms(e,t){let n=(N.sessions||[]).filter(t=>$o(t.updatedAt)===e);if(n.length===0||!await fc(r(`session.confirmCloseGroupMessage`,{group:t,count:n.length}),r(`session.closeSession`)))return;let i=0;for(let e of n)i+=await Os(e.id);ks(i),await zc(),Es(document.getElementById(`sessionDropdownSearch`)?.value||``)}function Ns(){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 js()})}t.addEventListener(`click`,e=>{e.stopPropagation()})}}function Ps(e){if(!B.visible)return;let t=B.filteredSessions.length;if(t===0){e.key===`Escape`&&vs();return}switch(e.key){case`ArrowDown`:e.preventDefault(),B.highlightIndex=Math.min(B.highlightIndex+1,t-1),bs(),Fs(document.getElementById(`sessionDropdownList`));break;case`ArrowUp`:e.preventDefault(),B.highlightIndex=Math.max(B.highlightIndex-1,0),bs(),Fs(document.getElementById(`sessionDropdownList`));break;case`Enter`:if(e.preventDefault(),B.highlightIndex>=0&&B.highlightIndex<t){let e=B.filteredSessions[B.highlightIndex];Ds(e.id)}break;case`Escape`:e.preventDefault(),vs();break}}function Fs(e){let t=(e||document).querySelector(`.session-dropdown-item.highlighted`);t&&t.scrollIntoView({block:`nearest`})}var Is=560,Ls=200,Rs=480,zs=360,Bs=240,Vs=`sessionSidebarExpanded`,Hs=`sessionSidebarWidth`,Us=`sessionSidebarSortMode`,Ws=`manual`,Gs=`recent`,V={expanded:!1,width:Bs,sortMode:Ws,narrow:!1,pendingRestore:!1,highlightIndex:-1,filteredSessions:[],inited:!1,lastActiveId:null};function Ks(e){let t=document.getElementById(`mainRow`),n=t?Math.max(Ls,t.clientWidth-zs):Rs;return Math.max(Ls,Math.min(e,Rs,n))}function qs(){let e=document.getElementById(`mainRow`);return e?e.clientWidth<Is:!0}function Js(){let e=document.getElementById(`sessionSidebar`);if(!e)return;V.narrow=qs(),e.classList.toggle(`sidebar-hidden`,V.narrow),e.classList.toggle(`expanded`,!V.narrow&&V.expanded),e.style.setProperty(`--session-sidebar-width`,`${V.width}px`),Ys();let t=document.getElementById(`sessionSidebarToggle`);t&&t.classList.toggle(`sidebar-hidden`,V.narrow||V.expanded);let n=document.getElementById(`sessionTabs`);if(n){let e=!V.narrow&&V.expanded;if(n.classList.toggle(`tabs-hidden`,e),!e){let e=document.getElementById(`sessionTabsScroll`);e&&us(e)}}}function Ys(){let e=!V.narrow&&V.expanded?V.width:0;document.body.style.setProperty(`--session-sidebar-offset`,`${e}px`)}async function Xs(){try{await chrome.storage.local.set({[Vs]:V.expanded,[Hs]:V.width,[Us]:V.sortMode})}catch{}}function Zs(){qs()||(V.expanded=!0,Js(),Xs(),ic())}function Qs(){V.expanded=!1,Js(),Xs()}function $s(){if(qs()){gs();return}V.expanded?Qs():Zs()}function ec(){let e=document.getElementById(`sessionSidebarList`),t=V.sortMode===Gs,n=!!(document.getElementById(`sessionSidebarSearch`)?.value||``).trim();xs({listEl:e,filteredSessions:V.filteredSessions,highlightIndex:V.highlightIndex,onSelect:e=>ac(e),grouped:t,draggable:!t&&!n});let r=N.activeSessionId;r&&V.lastActiveId!==r&&(V.lastActiveId=r,e?.querySelector(`.session-dropdown-item.active`)?.scrollIntoView({block:`nearest`}))}function tc(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=V.sortMode===Gs?Qo(n):n.reverse(),V.highlightIndex=-1,ec()}function nc(){document.querySelectorAll(`.session-sidebar-sort-btn`).forEach(e=>{let t=e.dataset.mode===V.sortMode;e.classList.toggle(`active`,t),e.setAttribute(`aria-pressed`,t?`true`:`false`)})}function rc(e){e!==Ws&&e!==Gs||V.sortMode!==e&&(V.sortMode=e,nc(),V.lastActiveId=null,tc(document.getElementById(`sessionSidebarSearch`)?.value||``),Xs())}function ic(){let e=document.getElementById(`sessionSidebar`);!e||!e.classList.contains(`expanded`)||tc(document.getElementById(`sessionSidebarSearch`)?.value||``)}async function ac(e){e!==N.activeSessionId&&await Ac(e)}function oc(e){let t=V.filteredSessions,n=t.length;if(n===0){e.key===`Escape`&&Qs();return}switch(e.key){case`ArrowDown`:e.preventDefault(),V.highlightIndex=Math.min(V.highlightIndex+1,n-1),ec(),Fs(document.getElementById(`sessionSidebarList`));break;case`ArrowUp`:e.preventDefault(),V.highlightIndex=Math.max(V.highlightIndex-1,0),ec(),Fs(document.getElementById(`sessionSidebarList`));break;case`Enter`:e.preventDefault(),V.highlightIndex>=0&&V.highlightIndex<n&&ac(t[V.highlightIndex].id);break;case`Escape`:e.preventDefault(),Qs();break}}function sc(){let e=document.getElementById(`sessionSidebarSearch`),t=document.getElementById(`sessionSidebarSearchClear`);t&&e&&(t.style.display=e.value?`flex`:`none`)}function cc(){let e=document.getElementById(`sessionSidebar`),t=document.getElementById(`sessionSidebarGrip`);!e||!t||t.addEventListener(`mousedown`,t=>{t.preventDefault();let n=t.clientX,r=V.width;e.classList.add(`resizing`);function i(t){let i=Ks(r+(t.clientX-n));V.width=i,e.style.setProperty(`--session-sidebar-width`,`${i}px`),Ys()}function a(){document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,a),e.classList.remove(`resizing`),Xs()}document.addEventListener(`mousemove`,i),document.addEventListener(`mouseup`,a)})}function lc(){let e=document.getElementById(`mainRow`);!e||typeof ResizeObserver>`u`||new ResizeObserver(()=>{requestAnimationFrame(()=>{let e=qs();e!==V.narrow&&(e&&V.expanded?V.pendingRestore=!0:!e&&V.pendingRestore&&(V.pendingRestore=!1),Js(),!e&&V.expanded&&ic())})}).observe(e)}function uc(){qs()?_s():Zs()}async function dc(){if(V.inited||!document.getElementById(`sessionSidebar`))return;V.inited=!0;try{let e=await chrome.storage.local.get([Vs,Hs,Us]);V.expanded=e[Vs]===!0,typeof e[Hs]==`number`&&(V.width=Ks(e[Hs])),(e[Us]===Gs||e[Us]===Ws)&&(V.sortMode=e[Us])}catch{}nc(),qs()&&V.expanded&&(V.pendingRestore=!0),Js(),ic(),document.getElementById(`sessionSidebarToggle`)?.addEventListener(`click`,()=>$s()),document.getElementById(`sessionSidebarAdd`)?.addEventListener(`click`,()=>{ns()}),document.getElementById(`sessionSidebarCollapse`)?.addEventListener(`click`,()=>Qs()),document.querySelectorAll(`.session-sidebar-sort-btn`).forEach(e=>{e.addEventListener(`click`,()=>rc(e.dataset.mode))}),document.getElementById(`sessionSidebarArchiveEntry`)?.addEventListener(`click`,()=>{vc()}),document.getElementById(`sessionSidebarCloseAll`)?.addEventListener(`click`,async e=>{e.stopPropagation(),await js()});let e=document.getElementById(`sessionSidebarSearch`),t=document.getElementById(`sessionSidebarSearchClear`);e&&(e.addEventListener(`input`,()=>{sc(),tc(e.value)}),e.addEventListener(`keydown`,e=>{oc(e)})),t&&t.addEventListener(`click`,()=>{e&&(e.value=``,sc(),tc(``),e.focus())}),cc(),lc(),_c()}function fc(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 pc=``,mc=!1;async function hc(e){if(!e)return;let t=Ki(e);if(!t.ok){t.reason===`running`?L(r(`session.archiveBusyRunning`),`warning`):t.reason===`queued`&&L(r(`session.archiveBusyQueued`),`warning`);return}let n=e===N.activeSessionId,i=await qi(e);if(!i?.ok){i?.reason===`running`?L(r(`session.archiveBusyRunning`),`warning`):i?.reason===`queued`?L(r(`session.archiveBusyQueued`),`warning`):L(r(`session.operationFailed`,{message:i?.reason||`unknown`}),`error`);return}if(document.dispatchEvent(new CustomEvent(`session-archived`,{detail:{sessionId:e}})),n)await gc(e);else{let e=await Fi();N.sessions=e.list,es(e)}await _c(),L(r(`session.archived`),`info`)}async function gc(e){let t=Qo([...(await Fi()).list]).filter(t=>t.id!==e);if(t.length>0){await Ac(t[0].id);return}await zi(),await zc()}async function _c(){let e=[`sessionArchiveEntryLabel`,`sessionSidebarArchiveLabel`].map(e=>document.getElementById(e));if(!e.some(Boolean))return;is=(await Gi()).length;let t=document.getElementById(`sessionTabsScroll`);t&&os(t);let n=r(`session.archiveEntry`);e.forEach(e=>{e&&(e.textContent=n)})}async function vc(){let e=document.getElementById(`sessionArchivePanel`);if(!e)return;Tc(),pc=``;let t=document.getElementById(`sessionArchiveSearch`);t&&(t.value=``),bc(),await xc(),e.classList.add(`show`),vs()}function yc(){let e=document.getElementById(`sessionArchivePanel`);e&&e.classList.remove(`show`)}function bc(){let e=document.getElementById(`sessionArchiveSearchClear`);e&&(e.style.display=pc?`flex`:`none`)}async function xc(){let e=document.getElementById(`sessionArchiveList`);if(!e)return;let t=await Gi(),n=pc.trim().toLowerCase(),i=n?t.filter(e=>(e.title||``).toLowerCase().includes(n)):t;if(e.innerHTML=``,i.length===0){let t=document.createElement(`div`);t.className=`session-dropdown-empty`,t.textContent=r(n?`session.archiveNoMatch`:`session.archiveEmpty`),e.appendChild(t);return}let a={today:r(`session.today`),yesterday:r(`session.yesterday`),last7Days:r(`session.last7Days`),earlier:r(`session.earlier`)},o=null;i.forEach(t=>{let n=$o(t.archivedAt);if(n!==o){o=n;let t=document.createElement(`div`);t.className=`session-dropdown-group-header`;let r=document.createElement(`span`);r.textContent=a[n]||n,t.appendChild(r),e.appendChild(t)}e.appendChild(Sc(t))})}function Sc(e){let t=document.createElement(`div`);t.className=`session-dropdown-item session-archive-item`,t.dataset.sessionId=e.id,t.title=e.title||r(`session.newSession`);let n=document.createElement(`span`);n.className=`session-dropdown-item-icon`,n.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 8v13H3V8"/><rect x="1" y="3" width="22" height="5"/><line x1="10" y1="12" x2="14" y2="12"/></svg>`,t.appendChild(n);let i=document.createElement(`span`);i.className=`session-dropdown-item-title`,i.textContent=e.title||r(`session.newSession`),t.appendChild(i);let a=document.createElement(`span`);a.className=`session-dropdown-item-time`,a.textContent=r(`session.archivedAt`,{time:Zo(e.archivedAt)}),t.appendChild(a);let o=document.createElement(`span`);o.className=`session-dropdown-item-actions`;let s=document.createElement(`span`);s.className=`session-dropdown-item-restore`,s.title=r(`session.restoreTitle`),s.innerHTML=`<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 14 4 9 9 4"/><path d="M20 20v-7a4 4 0 0 0-4-4H4"/></svg>`,s.addEventListener(`click`,async t=>{t.stopPropagation(),await Cc(e.id)}),o.appendChild(s);let c=document.createElement(`span`);return c.className=`session-dropdown-item-delete`,c.title=r(`session.deleteForever`),c.innerHTML=`✕`,c.addEventListener(`click`,async t=>{t.stopPropagation(),await wc(e)}),o.appendChild(c),t.appendChild(o),t.addEventListener(`click`,async()=>{await Cc(e.id,{enter:!0})}),t}async function Cc(e,{enter:t=!1}={}){if(!await Ji(e)){L(r(`session.operationFailed`,{message:`not found`}),`error`),await xc();return}let n=await Fi();N.sessions=n.list;let i=n.list.find(t=>t.id===e)?.title||r(`session.newSession`);yc(),await xc(),await _c(),t?await Ac(e):es(n),L(r(`session.archivedRestored`,{title:i}),`success`)}async function wc(e){let t=e.title||r(`session.newSession`);await fc(r(`session.confirmDeleteForeverMessage`,{title:t}),r(`session.confirmDeleteForeverTitle`))&&(await Yi(e.id),await xc(),await _c(),document.dispatchEvent(new CustomEvent(`session-deleted`,{detail:{sessionId:e.id}})),L(r(`session.archiveDeleted`,{title:t}),`success`))}function Tc(){if(mc)return;let e=document.getElementById(`sessionArchivePanel`),t=document.getElementById(`sessionArchiveEntry`);if(!e||!t)return;mc=!0,t.addEventListener(`click`,()=>{vc()});let n=document.getElementById(`sessionArchiveBackBtn`);n&&n.addEventListener(`click`,()=>{yc(),uc()});let r=document.getElementById(`sessionArchiveCloseBtn`);r&&r.addEventListener(`click`,()=>yc());let i=document.getElementById(`sessionArchiveSearch`),a=document.getElementById(`sessionArchiveSearchClear`);i&&(i.addEventListener(`input`,()=>{pc=i.value,bc(),xc()}),i.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.stopPropagation(),yc(),uc())})),a&&a.addEventListener(`click`,()=>{i&&(i.value=``,pc=``,bc(),xc(),i.focus())}),document.addEventListener(`session-archived`,()=>{e.classList.contains(`show`)&&xc()}),document.addEventListener(`session-deleted`,()=>{e.classList.contains(`show`)&&xc()})}var Ec=!1,Dc=500;function Oc(e){let t=`scrollPosition_${e||`default`}`;chrome.storage.local.get([t],e=>{let n=document.getElementById(`chatContainer`);n&&e[t]!==void 0&&(n.scrollTop=e[t]),M(async()=>{let{updateScrollButtonState:e}=await Promise.resolve().then(()=>XS);return{updateScrollButtonState:e}},void 0).then(({updateScrollButtonState:e})=>e()).catch(()=>{})})}function kc(e,t){setTimeout(()=>{N.activeSessionId===e&&(Ut(t)||Oc(e))},Dc)}async function Ac(e,{focusMessageId:t=null}={}){let n=N.activeSessionId;if(!await Bi(e))return;let r=`agentEnabledTools_${N.activeAgentId||`default`}`,i=`agentMcpClosedServers_${N.activeAgentId||`default`}`,[a,o,s,c]=await Promise.all([Fi(),chrome.storage.local.get([i,`ragTools`,`ragToolsIntroduced`]),chrome.storage.local.get([r,`enabledTools`]),N.activeAgentId?vt(N.activeAgentId):Promise.resolve(null)]);N.sessions=a.list,N.activeSessionId=e;let l=o.ragTools||[];N.mcpClosedServers=o[i]||[];let u=!!s[r],d=s[r]||s.enabledTools;if(u||d&&d.length>0){let e=Fa(l),t=d.filter(t=>e.has(t));if(u)N.enabledTools=t;else{let e=x.filter(e=>e.enabled&&!t.includes(e.id)).map(e=>e.id);N.enabledTools=[...t,...e]}let n=Pa(N.enabledTools,l,o.ragToolsIntroduced);N.enabledTools=n.tools,N.enabledTools.length!==d.length&&chrome.storage.local.set({[r]:N.enabledTools,...n.migrated?{ragToolsIntroduced:!0}:{}})}else{N.enabledTools=x.filter(e=>e.enabled).map(e=>e.id);let e=Pa(N.enabledTools,l,o.ragToolsIntroduced);N.enabledTools=e.tools,e.migrated&&chrome.storage.local.set({ragToolsIntroduced:!0,[r]:N.enabledTools})}N.activeAgentToolIds=c?c.toolIds:null,N.activeAgentMcpExcludedServerIds=c?c.mcpExcludedServerIds??null:null,document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:e,previousSessionId:n,...t?{skipScrollRestore:!0}:{}}})),Pi(e),es(a),Mc(),aE();try{let{refreshBookmarkPanel:e,updateBookmarkButtons:t}=await M(async()=>{let{refreshBookmarkPanel:e,updateBookmarkButtons:t}=await Promise.resolve().then(()=>yh);return{refreshBookmarkPanel:e,updateBookmarkButtons:t}},void 0);e(),setTimeout(()=>t(),100)}catch{}let f=document.getElementById(`toolsPopupOverlay`);f&&f.classList.contains(`show`)&&(ba(),Oa(),ka()),Ma(),t&&kc(e,t)}async function jc(e,t=null){if(e)try{let n=await Qi(e,t);await Ac(n.id),L(r(t?`session.forkedFrom`:`session.forkedSession`,{title:n.title}),`success`)}catch(e){a.error(`[SessionUI] copy/forksession failed:`,e),L(r(`session.operationFailed`,{message:e.message}),`error`)}}function Mc(){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 Nc=new WeakSet;function Pc(e){Nc.has(e)||(Nc.add(e),e.addEventListener(`wheel`,t=>{e.scrollWidth<=e.clientWidth||(t.preventDefault(),e.scrollLeft+=t.deltaY)},{passive:!1}))}function Fc(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 Hi(e.id,t),es();let n=await Fi();N.sessions=n.list,N.activeSessionId=n.activeSessionId,Es(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 Ic(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()=>{ks(await Os(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 Lc(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=Rc(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(),Fc(t)});i.appendChild(a);let o=Rc(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(),jc(t.id)});i.appendChild(o);let s=Rc(r(`session.archive`),`<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="M21 8v13H3V8"/><rect x="1" y="3" width="22" height="5"/><line x1="10" y1="12" x2="14" y2="12"/></svg>`,async()=>{i.remove(),await hc(t.id)});i.appendChild(s);let c=Rc(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.messageCount??t.messageHistory?.length??0)===0){ks(await Os(t.id)),await zc();return}Ic(t,async()=>{await zc()})},`danger`);i.appendChild(c),document.body.appendChild(i);let l=e=>{i.contains(e.target)||(i.remove(),document.removeEventListener(`click`,l))};setTimeout(()=>document.addEventListener(`click`,l),0)}function Rc(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 zc(){let e=N.activeSessionId,t=await Fi();t.activeSessionId||(await zi(),t=await Fi()),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,Li(n),N.activeAgentId=n&&n.agentId||null,N.activeAgentId){let e=await vt(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}})),es(),await aE()}async function Bc(){let e=N.activeSessionId;if(!e)return;let t=N.sessions?.find(t=>t.id===e);if(t){if((N.messageHistory?.length||0)===0){ks(await Os(e)),await zc();return}Ic(t,async()=>{await zc()})}}document.addEventListener(`generating-state-changed`,()=>{es()}),document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>{ls(),dc()}):(ls(),dc()),[`<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 Vc=`<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>`,Hc=`<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>`,Uc=`<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>`,Wc=`<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>`,Gc=`<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>`,Kc=`<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 qc=null,Jc=1,Yc=.25,Xc=2,Zc=.1;function Qc(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>
|
|
60
|
+
`,e.addEventListener(`click`,()=>Co(-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`),to=null,no=!1,co(),oo(s),a.debug(`[SidePanel] clarification dialogshown:`,e.toolCallId,t),!0}function ho(){if(eo)return!0;if($a.length===0)return!1;let e=$a.shift();return mo(e)?(eo=e,Za(Qa,e),!0):(a.error(`[SidePanel] clarify overlay missing, settle as unanswered:`,e.toolCallId),go(e),L(r(`clarify.dropped`),`warning`),!1)}function go(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 _o(){if($a.length>0){Ga(Qa);return}vo(),Ka(Qa)}function vo(){let e=document.getElementById(`clarifyOverlay`);e&&e.classList.remove(`show`),N.currentClarifyToolCallId=null,N.currentClarifySessionId=null,so()}function yo(){eo=null,_o()}function bo(e,t){return!!e.toolCallId&&e.toolCallId===t.toolCallId&&(e.sessionId||null)===(t.sessionId||null)&&e.question===t.question}function xo(e){let t={...e,sessionId:e.sessionId||null};if(a.debug(`[SidePanel] showclarification dialog:`,t.toolCallId,e),eo&&bo(eo,t)){a.debug(`[SidePanel] duplicate clarify request, ignored:`,t.toolCallId);return}if($a.some(e=>bo(e,t))){a.debug(`[SidePanel] queued duplicate clarify, ignored:`,t.toolCallId);return}$a.push(t),Ga(Qa),po(),Ya(Qa)}function So(){if(eo){yo();return}vo()}function Co(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 wo(){if(!eo){a.error(`[SidePanel] no has currenttool callID`);return}let e=eo.toolCallId,t=eo.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),yo()}function To(){if(eo){let e={type:`CLARIFY_RESPONSE`,toolCallId:eo.toolCallId,sessionId:eo.sessionId,selectedOption:-1,customInput:``,additionalInfo:``};chrome.runtime.sendMessage(e)}So()}function Eo(e){return e?.reason===`timeout`&&e?.defaultOption||null}function Do(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(!eo)return;Oo(Eo(e));return}if(eo&&eo.toolCallId===t){Oo(Eo(e));return}let n=$a.findIndex(e=>e.toolCallId===t);n>=0&&(a.debug(`[SidePanel] drop queued clarify (already settled by background):`,t),$a.splice(n,1),po(),Ya(Qa))}function Oo(e=null){let t=eo?.question;yo(),L(e?r(`clarify.timedOutDefaulted`,{option:e}):`${r(`clarify.timedOut`)}${t?`:${t}`:``}`,`warning`),io(`error`)}Wa(Qa,{present:ho,pendingCount:()=>$a.length,refresh:po});function ko(){let e=document.getElementById(`clarifyConfirmBtn`);e&&e.addEventListener(`click`,wo);let t=document.getElementById(`clarifyCancelBtn`);t&&t.addEventListener(`click`,To);let n=document.getElementById(`clarifyExtendBtn`);n&&n.addEventListener(`click`,lo);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),xo(e.data),n({success:!0})):e.type===`PLAY_NOTIFICATION_SOUND`?(a.debug(`[SidePanel] recei to play soundrequested :`,e),io(e.soundType),n({success:!0})):e.type===`CLARIFY_TIMEOUT`?Do(e):e.type===`CLARIFY_EXTENDED`&&uo(e)}),a.debug(`[SidePanel] clarification dialogeventinitializing`)}var Ao=Ba.CONFIRM,jo=[],Mo=null,No=null,Po=null;function Fo(e){let t=Math.floor(e/60),n=e%60;return`${t}:${String(n).padStart(2,`0`)}`}function Io(){No&&=(clearInterval(No),null),Po&&=(clearTimeout(Po),null)}function Lo(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 Ro(e){let t=e.message||r(`dialog.confirmAction`,{name:e.toolLabel||e.toolName}),n=jo.length,i=Xa(Ao),a=t;return n>0&&(a+=` ${r(`dialog.pendingQueue`,{count:n})}`),i>0&&(a+=` ${r(`dialog.otherPending`,{count:i})}`),a}function zo(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=e.variant===`network`,l=document.getElementById(`confirmTitle`);l&&(l.textContent=r(c?`dialog.networkTitle`:`dialog.operationConfirm`));let u=document.getElementById(`confirmApproveLoopBtn`);u&&(u.textContent=r(c?`dialog.approveWhitelist`:`dialog.approveLoop`));let d=document.getElementById(`confirmArgsSummary`);if(d&&i){let e=Object.entries(i).filter(([e,t])=>t!=null&&t!==``).slice(0,5);e.length>0?(d.textContent=``,e.forEach(([e,t],n)=>{n>0&&d.appendChild(document.createTextNode(`、 `));let r=typeof t==`string`?t:JSON.stringify(t),i=r.length>80?r.substring(0,80)+`...`:r,a=document.createElement(`span`);a.className=`confirm-arg`,a.style.marginRight=`8px`,r.length>80&&(a.title=r);let o=document.createElement(`strong`);o.textContent=`${e}:`,a.appendChild(o),a.appendChild(document.createTextNode(` ${i}`)),d.appendChild(a)}),d.style.display=`block`):d.style.display=`none`}let f=document.getElementById(`confirmMessage`);f&&(f.textContent=Ro(e)),Io();let p=Math.floor(o/1e3),m=document.getElementById(`confirmCountdownText`),h=document.getElementById(`confirmCountdown`);return m&&h&&(h.classList.remove(`warning`),h.style.display=`flex`,m.textContent=r(`dialog.remainingTime`,{time:Fo(p)}),No=setInterval(()=>{if(p--,p<=0){clearInterval(No),No=null,m.textContent=r(`dialog.remainingTime`,{time:`0:00`});return}m.textContent=r(`dialog.remainingTime`,{time:Fo(p)}),p<=30&&h.classList.add(`warning`)},1e3)),s.style.display=`flex`,Po=setTimeout(()=>{a.debug(`[SidePanel] confirm dialogtimeout,autodeny`),Go(!1,`single`)},o),!0}function Bo(){if(Mo)return!0;if(jo.length===0)return!1;let e=jo.shift();return zo(e)?(Mo=e,Za(Ao,e),!0):(e.resolve&&e.resolve(!1),!1)}function Vo(){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 Ho(){if(jo.length>0){Ga(Ao);return}Vo(),Ka(Ao)}function Uo(e){let t=Mo?.resolve;Mo=null,Io(),t&&t(e),Ho()}function Wo(e){let t={...e,sessionId:e.sessionId||null};return a.debug(`[SidePanel] showconfirm dialog:`,t.toolName,e),Mo&&Lo(Mo,t)?(a.debug(`[SidePanel] duplicate confirm request, ignored:`,t.toolCallId),Promise.resolve(!1)):jo.some(e=>Lo(e,t))?(a.debug(`[SidePanel] queued duplicate confirm, ignored:`,t.toolCallId),Promise.resolve(!1)):new Promise(e=>{jo.push({...t,resolve:e}),Ga(Ao),Mo&&Ko(),Ya(Ao)})}function Go(e,t=`single`){if(!Mo)return;let n=Mo.toolCallId,r=Mo.sessionId;Io(),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)}),Uo(e)}function Ko(){if(!Mo)return;let e=document.getElementById(`confirmMessage`);e&&(e.textContent=Ro(Mo))}function qo(e){let t=e?.toolCallId;if(!t)return;if(Mo&&Mo.toolCallId===t){a.debug(`[SidePanel] dismiss active confirm dialog (already settled by background):`,t),Uo(!1);return}let n=jo.findIndex(e=>e.toolCallId===t);if(n>=0){a.debug(`[SidePanel] drop queued confirm dialog (already settled by background):`,t);let[e]=jo.splice(n,1);e.resolve&&e.resolve(!1),Ko(),Ya(Ao)}}Wa(Ao,{present:Bo,pendingCount:()=>jo.length,refresh:()=>{Mo&&Ko()}});function Jo(){let e=document.getElementById(`confirmApproveOnceBtn`),t=document.getElementById(`confirmApproveLoopBtn`),n=document.getElementById(`confirmDenyBtn`);e&&e.addEventListener(`click`,()=>Go(!0,`single`)),t&&t.addEventListener(`click`,()=>{Go(!0,Mo?.variant===`network`?`whitelist`:`loop`)}),n&&n.addEventListener(`click`,()=>Go(!1,`single`)),chrome.runtime.onMessage.addListener((e,t,n)=>e.type===`SHOW_CONFIRM_DIALOG`?(Wo(e.data),n({received:!0}),!1):e.type===`DISMISS_CONFIRM_DIALOG`?(qo(e.data),n({received:!0}),!1):!1)}var Yo=t({closeCurrentSession:()=>Bc,handleDuplicateSession:()=>jc,handleSessionSwitch:()=>Ac,newSession:()=>ns,renderSessionTabs:()=>es});n(`zh`,{session:{newSession:`新会话`,closeSession:`关闭会话`,taskCompleted:`任务已完成`,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} 天前`,archive:`归档会话`,archiveEntry:`归档区`,archiveEntryTitle:`查看归档会话`,archivePanelTitle:`归档区`,archiveSearchPlaceholder:`搜索归档会话...`,archiveEmpty:`暂无归档会话`,archiveNoMatch:`未找到匹配的归档会话`,archiveHint:`归档只是移出视野,随时可以恢复`,archiveBusyRunning:`该会话任务还在执行,完成后再归档`,archiveBusyQueued:`该会话还有排队任务,先清空队列再归档`,archived:`已归档到归档区`,archivedRestored:`已恢复会话「{title}」`,archivedAt:`归档于 {time}`,restore:`恢复`,restoreTitle:`恢复到会话列表`,deleteForever:`彻底删除`,confirmDeleteForeverTitle:`彻底删除会话`,confirmDeleteForeverMessage:`「{title}」将被彻底删除,消息与执行记录都无法恢复。确定继续吗?`,archiveDeleted:`已彻底删除会话「{title}」`,backToSessionList:`返回会话列表`,expandSidebar:`展开会话列表`,collapseSidebar:`收起会话列表`,searchSessions:`搜索会话`,sortModeTitle:`会话排序`,sortManual:`手动排序(拖拽调整,与标签栏一致)`,sortRecent:`最近更新优先(按时间倒序,带时间分组)`}}),n(`en`,{session:{newSession:`New Session`,closeSession:`Close Session`,taskCompleted:`Task completed`,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:`{hour}:{minute}`,yesterdayFormat:`Yesterday {hour}:{minute}`,daysAgo:`{count}d ago`,archive:`Archive session`,archiveEntry:`Archived`,archiveEntryTitle:`View archived sessions`,archivePanelTitle:`Archived sessions`,archiveSearchPlaceholder:`Search archived sessions...`,archiveEmpty:`No archived sessions`,archiveNoMatch:`No archived sessions found`,archiveHint:`Archiving only hides a session — you can restore it anytime`,archiveBusyRunning:`This session is still running. Archive it when it finishes`,archiveBusyQueued:`This session still has queued tasks. Clear the queue first`,archived:`Moved to archive`,archivedRestored:`Session "{title}" restored`,archivedAt:`Archived {time}`,restore:`Restore`,restoreTitle:`Restore to session list`,deleteForever:`Delete permanently`,confirmDeleteForeverTitle:`Delete session permanently`,confirmDeleteForeverMessage:`"{title}" will be permanently deleted. Messages and execution logs cannot be recovered. Continue?`,archiveDeleted:`Session "{title}" permanently deleted`,backToSessionList:`Back to sessions`,expandSidebar:`Expand session list`,collapseSidebar:`Collapse session list`,searchSessions:`Search sessions`,sortModeTitle:`Session order`,sortManual:`Manual order (drag to arrange, same as tabs)`,sortRecent:`Most recent first (time order with day groups)`}});var B={visible:!1,highlightIndex:-1,filteredSessions:[]},Xo={draggedId:null,sourceType:null};function Zo(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 Qo(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 $o(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 es(e=null){let t=e||await Fi({withActiveHistory:!1});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.messageCount??e.messageHistory?.length??0)===0){ks(await Os(e.id)),await zc();return}Ic(e,async()=>{await zc()})}),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=Kr(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&&!Ec){Ec=!0,i.querySelectorAll(`.session-tab.active`).forEach(e=>e.classList.remove(`active`)),t.classList.add(`active`);try{await Ac(e.id)}finally{Ec=!1,N.activeSessionId!==e.id&&es({list:N.sessions,activeSessionId:N.activeSessionId})}}}),t.addEventListener(`contextmenu`,t=>{t.preventDefault(),Lc(t,e)}),t.addEventListener(`mousedown`,async t=>{t.button===1&&(t.preventDefault(),t.stopPropagation(),ks(await Os(e.id)),await zc())}),t.draggable=!0,t.addEventListener(`dragstart`,t=>ds(t,e.id)),t.addEventListener(`dragover`,e=>fs(e)),t.addEventListener(`dragleave`,e=>ps(e)),t.addEventListener(`drop`,t=>ms(t,e.id)),t.addEventListener(`dragend`,e=>hs(e)),i.appendChild(t)}),ts(),rs(),Ns(),Tc(),Pc(i),os(i),ss(i),us(i),ic(),dc())}function ts(){let e=document.getElementById(`sessionTabsMore`);if(!e)return;let t=e.cloneNode(!0);e.parentNode.replaceChild(t,e),t.addEventListener(`click`,e=>{e.stopPropagation(),$s()})}async function ns(){let e=N.activeSessionId;await Ii();let t=await zi();N.activeSessionId=t.id,N.messageHistory=[],N.activeCompaction=null,Li(t),document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:t.id,previousSessionId:e}})),es()}function rs(){let e=document.getElementById(`sessionTabsAdd`);if(!e)return;let t=e.cloneNode(!0);e.parentNode.replaceChild(t,e),t.addEventListener(`click`,()=>ns())}var is=0,as=0;function os(e){let t=document.getElementById(`sessionTabsMore`);if(!t)return;if(!qs()){t.style.display=`none`;return}let n=e.scrollWidth>e.clientWidth;t.style.display=n||is>0?`flex`:`none`}async function ss(e){let t=++as,n;try{n=await Gi()}catch{return}t===as&&(is=n.length,os(e))}var cs=null;function ls(){if(cs)return;let e=document.getElementById(`sessionTabsScroll`);e&&(cs=new ResizeObserver(()=>{requestAnimationFrame(()=>{os(e)})}),cs.observe(e))}function us(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 ds(e,t){Xo.draggedId=t,Xo.sourceType=`tab`,e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t),e.currentTarget.classList.add(`dragging`)}function fs(e){e.preventDefault(),e.dataTransfer.dropEffect=`move`,e.currentTarget.classList.add(`drag-over`)}function ps(e){e.currentTarget.classList.remove(`drag-over`)}async function ms(e,t){e.preventDefault(),e.currentTarget.classList.remove(`drag-over`);let n=Xo.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 Ui(o.map(e=>e.id)),es()}function hs(e){e.currentTarget.classList.remove(`dragging`),document.querySelectorAll(`.session-tab.drag-over`).forEach(e=>e.classList.remove(`drag-over`)),Xo.draggedId=null,Xo.sourceType=null}function gs(){B.visible?vs():_s()}async function _s(){let e=document.getElementById(`sessionTabsMore`),t=document.getElementById(`sessionDropdown`);if(!e||!t)return;let n=await Fi();N.sessions=n.list,N.activeSessionId=n.activeSessionId,B.filteredSessions=Qo([...n.list]),B.highlightIndex=-1,B.visible=!0,_c(),bs(),t.classList.add(`show`);let r=document.getElementById(`sessionDropdownCloseBtn`);r&&(r.onclick=()=>vs());let i=document.getElementById(`sessionDropdownSearch`),a=document.getElementById(`sessionDropdownSearchClear`);i&&(i.value=B.lastSearchText||``,ys(),B.lastSearchText&&Es(B.lastSearchText),setTimeout(()=>i.focus(),50),i.oninput=()=>{B.lastSearchText=i.value,ys(),Es(i.value)},i.onkeydown=e=>{Ps(e)}),a&&(a.onclick=()=>{i&&(i.value=``,B.lastSearchText=``,ys(),Es(``),i.focus())}),e.classList.add(`active`)}function vs(){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&&(B.lastSearchText=n.value,n.oninput=null,n.onkeydown=null);let r=document.getElementById(`sessionDropdownSearchClear`);r&&(r.onclick=null),B.visible=!1,B.highlightIndex=-1,B.filteredSessions=[]}function ys(){let e=document.getElementById(`sessionDropdownSearch`),t=document.getElementById(`sessionDropdownSearchClear`);t&&e&&(t.style.display=e.value?`flex`:`none`)}function bs(){xs({listEl:document.getElementById(`sessionDropdownList`),filteredSessions:B.filteredSessions,highlightIndex:B.highlightIndex,onSelect:e=>Ds(e)})}function xs({listEl:e,filteredSessions:t,highlightIndex:n,onSelect:i,grouped:a=!0,draggable:o=!1}){if(!e)return;if(e.innerHTML=``,t.length===0){let t=document.createElement(`div`);t.className=`session-dropdown-empty`,t.textContent=r(`session.noMatch`),e.appendChild(t);return}let s={today:r(`session.today`),yesterday:r(`session.yesterday`),last7Days:r(`session.last7Days`),earlier:r(`session.earlier`)},c={};a&&t.forEach(e=>{let t=$o(e.updatedAt);c[t]=(c[t]||0)+1});let l=null;t.forEach((t,u)=>{if(a){let n=$o(t.updatedAt);if(n!==l){l=n;let t=document.createElement(`div`);t.className=`session-dropdown-group-header`;let i=document.createElement(`span`);if(i.textContent=s[n]||n,t.appendChild(i),(c[n]||0)>0){let e=document.createElement(`button`);e.className=`session-dropdown-group-close`,e.textContent=r(`session.closeGroupAll`),e.onclick=e=>{e.stopPropagation(),Ms(n,s[n]||n)},t.appendChild(e)}e.appendChild(t)}}let d=Ts(t,{index:u,highlightIndex:n,onSelect:i});o&&Cs(d,t.id),e.appendChild(d)})}var Ss=null;function Cs(e,t){e.draggable=!0,e.classList.add(`draggable`),e.addEventListener(`dragstart`,n=>{Ss=t,n.dataTransfer.effectAllowed=`move`,n.dataTransfer.setData(`text/plain`,t),e.classList.add(`dragging`)}),e.addEventListener(`dragover`,n=>{!Ss||Ss===t||(n.preventDefault(),n.dataTransfer.dropEffect=`move`,e.classList.add(`drag-over`))}),e.addEventListener(`dragleave`,()=>e.classList.remove(`drag-over`)),e.addEventListener(`drop`,n=>{n.preventDefault(),n.stopPropagation(),e.classList.remove(`drag-over`),ws(Ss,t)}),e.addEventListener(`dragend`,()=>{e.classList.remove(`dragging`),document.querySelectorAll(`.session-dropdown-item.drag-over`).forEach(e=>e.classList.remove(`drag-over`)),Ss=null})}async function ws(e,t){let n=e;if(Ss=null,!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 Ui(o.map(e=>e.id)),await es()}function Ts(e,{index:t,highlightIndex:n,onSelect:i}){let a=document.createElement(`div`);a.className=`session-dropdown-item`,a.dataset.sessionId=e.id,a.dataset.index=t,e.id===N.activeSessionId&&a.classList.add(`active`),t===n&&a.classList.add(`highlighted`);let o=e.isGenerating||N.generatingSessionIds.has(e.id);if(N.completedSessionIds.has(e.id)&&e.id!==N.activeSessionId&&!o){let e=document.createElement(`span`);e.className=`session-dropdown-item-completed`,e.title=r(`session.taskCompleted`),a.appendChild(e)}let s=Kr(e.id);if(s>0){let e=document.createElement(`span`);e.className=`session-dropdown-item-queue`,e.textContent=String(s>99?`99+`:s),e.title=r(`queue.badgeTitle`,{count:s}),a.appendChild(e)}let c=document.createElement(`span`);if(c.className=`session-dropdown-item-icon`,o){let e=document.createElement(`span`);e.className=`session-dropdown-item-running`,c.appendChild(e)}else c.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>`;a.appendChild(c);let l=document.createElement(`span`);if(l.className=`session-dropdown-item-title`,l.textContent=e.title||r(`session.newSession`),l.title=e.title||r(`session.newSession`),a.appendChild(l),e.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>`,a.appendChild(e)}let u=document.createElement(`span`);u.className=`session-dropdown-item-time`,u.textContent=Zo(e.updatedAt),a.appendChild(u);let d=document.createElement(`span`);d.className=`session-dropdown-item-actions`;let f=document.createElement(`span`);f.className=`session-dropdown-item-rename`,f.title=r(`session.rename`),f.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>`,f.addEventListener(`click`,t=>{t.stopPropagation(),t.preventDefault(),Fc(e)}),d.appendChild(f);let p=document.createElement(`span`);p.className=`session-dropdown-item-duplicate`,p.title=r(`session.duplicate`),p.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>`,p.addEventListener(`click`,async t=>{t.stopPropagation(),t.preventDefault(),await jc(e.id);let n=await Fi({withActiveHistory:!1});N.sessions=n.list,N.activeSessionId=n.activeSessionId,Es(document.getElementById(`sessionDropdownSearch`)?.value||``)}),d.appendChild(p);let m=document.createElement(`span`);m.className=`session-dropdown-item-archive`,m.title=r(`session.archive`),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="M21 8v13H3V8"/><rect x="1" y="3" width="22" height="5"/><line x1="10" y1="12" x2="14" y2="12"/></svg>`,m.addEventListener(`click`,async t=>{t.stopPropagation(),t.preventDefault(),await hc(e.id),Es(document.getElementById(`sessionDropdownSearch`)?.value||``)}),d.appendChild(m);let h=document.createElement(`span`);return h.className=`session-dropdown-item-close`,h.innerHTML=`✕`,h.title=r(`session.closeSession`),h.addEventListener(`click`,async t=>{t.stopPropagation(),t.preventDefault(),await As(e.id)}),d.appendChild(h),a.appendChild(d),a.addEventListener(`click`,async t=>{t.preventDefault(),await i(e.id)}),a}function Es(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))}B.filteredSessions=Qo(n),B.highlightIndex=-1,bs()}async function Ds(e){vs(),e!==N.activeSessionId&&await Ac(e)}async function Os(e){let t=Kr(e)+Wr(e).length;return await Vi(e),t}function ks(e){e<=0||L(r(`queue.sessionDropped`,{count:e}),`info`,3e3)}async function As(e){let t=(N.sessions||[]).find(t=>t.id===e);t&&((e===N.activeSessionId?N.messageHistory?.length||0:t.messageCount??t.messageHistory?.length??0)>0&&!await fc(r(`session.confirmCloseMessageWithTitle`,{title:t.title}),r(`session.closeSession`))||(ks(await Os(e)),await zc(),Es(document.getElementById(`sessionDropdownSearch`)?.value||``)))}async function js(){let e=N.sessions||[];if(e.length===0||!await fc(r(`session.confirmCloseAllMessage`,{count:e.length}),r(`session.confirmCloseAllTitle`)))return;let t=0;for(let n of e)t+=await Os(n.id);ks(t),await zc(),Es(document.getElementById(`sessionDropdownSearch`)?.value||``)}async function Ms(e,t){let n=(N.sessions||[]).filter(t=>$o(t.updatedAt)===e);if(n.length===0||!await fc(r(`session.confirmCloseGroupMessage`,{group:t,count:n.length}),r(`session.closeSession`)))return;let i=0;for(let e of n)i+=await Os(e.id);ks(i),await zc(),Es(document.getElementById(`sessionDropdownSearch`)?.value||``)}function Ns(){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 js()})}t.addEventListener(`click`,e=>{e.stopPropagation()})}}function Ps(e){if(!B.visible)return;let t=B.filteredSessions.length;if(t===0){e.key===`Escape`&&vs();return}switch(e.key){case`ArrowDown`:e.preventDefault(),B.highlightIndex=Math.min(B.highlightIndex+1,t-1),bs(),Fs(document.getElementById(`sessionDropdownList`));break;case`ArrowUp`:e.preventDefault(),B.highlightIndex=Math.max(B.highlightIndex-1,0),bs(),Fs(document.getElementById(`sessionDropdownList`));break;case`Enter`:if(e.preventDefault(),B.highlightIndex>=0&&B.highlightIndex<t){let e=B.filteredSessions[B.highlightIndex];Ds(e.id)}break;case`Escape`:e.preventDefault(),vs();break}}function Fs(e){let t=(e||document).querySelector(`.session-dropdown-item.highlighted`);t&&t.scrollIntoView({block:`nearest`})}var Is=560,Ls=200,Rs=480,zs=360,Bs=240,Vs=`sessionSidebarExpanded`,Hs=`sessionSidebarWidth`,Us=`sessionSidebarSortMode`,Ws=`manual`,Gs=`recent`,V={expanded:!1,width:Bs,sortMode:Ws,narrow:!1,pendingRestore:!1,highlightIndex:-1,filteredSessions:[],inited:!1,lastActiveId:null};function Ks(e){let t=document.getElementById(`mainRow`),n=t?Math.max(Ls,t.clientWidth-zs):Rs;return Math.max(Ls,Math.min(e,Rs,n))}function qs(){let e=document.getElementById(`mainRow`);return e?e.clientWidth<Is:!0}function Js(){let e=document.getElementById(`sessionSidebar`);if(!e)return;V.narrow=qs(),e.classList.toggle(`sidebar-hidden`,V.narrow),e.classList.toggle(`expanded`,!V.narrow&&V.expanded),e.style.setProperty(`--session-sidebar-width`,`${V.width}px`),Ys();let t=document.getElementById(`sessionSidebarToggle`);t&&t.classList.toggle(`sidebar-hidden`,V.narrow||V.expanded);let n=document.getElementById(`sessionTabs`);if(n){let e=!V.narrow&&V.expanded;if(n.classList.toggle(`tabs-hidden`,e),!e){let e=document.getElementById(`sessionTabsScroll`);e&&us(e)}}}function Ys(){let e=!V.narrow&&V.expanded?V.width:0;document.body.style.setProperty(`--session-sidebar-offset`,`${e}px`)}async function Xs(){try{await chrome.storage.local.set({[Vs]:V.expanded,[Hs]:V.width,[Us]:V.sortMode})}catch{}}function Zs(){qs()||(V.expanded=!0,Js(),Xs(),ic())}function Qs(){V.expanded=!1,Js(),Xs()}function $s(){if(qs()){gs();return}V.expanded?Qs():Zs()}function ec(){let e=document.getElementById(`sessionSidebarList`),t=V.sortMode===Gs,n=!!(document.getElementById(`sessionSidebarSearch`)?.value||``).trim();xs({listEl:e,filteredSessions:V.filteredSessions,highlightIndex:V.highlightIndex,onSelect:e=>ac(e),grouped:t,draggable:!t&&!n});let r=N.activeSessionId;r&&V.lastActiveId!==r&&(V.lastActiveId=r,e?.querySelector(`.session-dropdown-item.active`)?.scrollIntoView({block:`nearest`}))}function tc(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=V.sortMode===Gs?Qo(n):n.reverse(),V.highlightIndex=-1,ec()}function nc(){document.querySelectorAll(`.session-sidebar-sort-btn`).forEach(e=>{let t=e.dataset.mode===V.sortMode;e.classList.toggle(`active`,t),e.setAttribute(`aria-pressed`,t?`true`:`false`)})}function rc(e){e!==Ws&&e!==Gs||V.sortMode!==e&&(V.sortMode=e,nc(),V.lastActiveId=null,tc(document.getElementById(`sessionSidebarSearch`)?.value||``),Xs())}function ic(){let e=document.getElementById(`sessionSidebar`);!e||!e.classList.contains(`expanded`)||tc(document.getElementById(`sessionSidebarSearch`)?.value||``)}async function ac(e){e!==N.activeSessionId&&await Ac(e)}function oc(e){let t=V.filteredSessions,n=t.length;if(n===0){e.key===`Escape`&&Qs();return}switch(e.key){case`ArrowDown`:e.preventDefault(),V.highlightIndex=Math.min(V.highlightIndex+1,n-1),ec(),Fs(document.getElementById(`sessionSidebarList`));break;case`ArrowUp`:e.preventDefault(),V.highlightIndex=Math.max(V.highlightIndex-1,0),ec(),Fs(document.getElementById(`sessionSidebarList`));break;case`Enter`:e.preventDefault(),V.highlightIndex>=0&&V.highlightIndex<n&&ac(t[V.highlightIndex].id);break;case`Escape`:e.preventDefault(),Qs();break}}function sc(){let e=document.getElementById(`sessionSidebarSearch`),t=document.getElementById(`sessionSidebarSearchClear`);t&&e&&(t.style.display=e.value?`flex`:`none`)}function cc(){let e=document.getElementById(`sessionSidebar`),t=document.getElementById(`sessionSidebarGrip`);!e||!t||t.addEventListener(`mousedown`,t=>{t.preventDefault();let n=t.clientX,r=V.width;e.classList.add(`resizing`);function i(t){let i=Ks(r+(t.clientX-n));V.width=i,e.style.setProperty(`--session-sidebar-width`,`${i}px`),Ys()}function a(){document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,a),e.classList.remove(`resizing`),Xs()}document.addEventListener(`mousemove`,i),document.addEventListener(`mouseup`,a)})}function lc(){let e=document.getElementById(`mainRow`);!e||typeof ResizeObserver>`u`||new ResizeObserver(()=>{requestAnimationFrame(()=>{let e=qs();e!==V.narrow&&(e&&V.expanded?V.pendingRestore=!0:!e&&V.pendingRestore&&(V.pendingRestore=!1),Js(),!e&&V.expanded&&ic())})}).observe(e)}function uc(){qs()?_s():Zs()}async function dc(){if(V.inited||!document.getElementById(`sessionSidebar`))return;V.inited=!0;try{let e=await chrome.storage.local.get([Vs,Hs,Us]);V.expanded=e[Vs]===!0,typeof e[Hs]==`number`&&(V.width=Ks(e[Hs])),(e[Us]===Gs||e[Us]===Ws)&&(V.sortMode=e[Us])}catch{}nc(),qs()&&V.expanded&&(V.pendingRestore=!0),Js(),ic(),document.getElementById(`sessionSidebarToggle`)?.addEventListener(`click`,()=>$s()),document.getElementById(`sessionSidebarAdd`)?.addEventListener(`click`,()=>{ns()}),document.getElementById(`sessionSidebarCollapse`)?.addEventListener(`click`,()=>Qs()),document.querySelectorAll(`.session-sidebar-sort-btn`).forEach(e=>{e.addEventListener(`click`,()=>rc(e.dataset.mode))}),document.getElementById(`sessionSidebarArchiveEntry`)?.addEventListener(`click`,()=>{vc()}),document.getElementById(`sessionSidebarCloseAll`)?.addEventListener(`click`,async e=>{e.stopPropagation(),await js()});let e=document.getElementById(`sessionSidebarSearch`),t=document.getElementById(`sessionSidebarSearchClear`);e&&(e.addEventListener(`input`,()=>{sc(),tc(e.value)}),e.addEventListener(`keydown`,e=>{oc(e)})),t&&t.addEventListener(`click`,()=>{e&&(e.value=``,sc(),tc(``),e.focus())}),cc(),lc(),_c()}function fc(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 pc=``,mc=!1;async function hc(e){if(!e)return;let t=Ki(e);if(!t.ok){t.reason===`running`?L(r(`session.archiveBusyRunning`),`warning`):t.reason===`queued`&&L(r(`session.archiveBusyQueued`),`warning`);return}let n=e===N.activeSessionId,i=await qi(e);if(!i?.ok){i?.reason===`running`?L(r(`session.archiveBusyRunning`),`warning`):i?.reason===`queued`?L(r(`session.archiveBusyQueued`),`warning`):L(r(`session.operationFailed`,{message:i?.reason||`unknown`}),`error`);return}if(document.dispatchEvent(new CustomEvent(`session-archived`,{detail:{sessionId:e}})),n)await gc(e);else{let e=await Fi();N.sessions=e.list,es(e)}await _c(),L(r(`session.archived`),`info`)}async function gc(e){let t=Qo([...(await Fi()).list]).filter(t=>t.id!==e);if(t.length>0){await Ac(t[0].id);return}await zi(),await zc()}async function _c(){let e=[`sessionArchiveEntryLabel`,`sessionSidebarArchiveLabel`].map(e=>document.getElementById(e));if(!e.some(Boolean))return;is=(await Gi()).length;let t=document.getElementById(`sessionTabsScroll`);t&&os(t);let n=r(`session.archiveEntry`);e.forEach(e=>{e&&(e.textContent=n)})}async function vc(){let e=document.getElementById(`sessionArchivePanel`);if(!e)return;Tc(),pc=``;let t=document.getElementById(`sessionArchiveSearch`);t&&(t.value=``),bc(),await xc(),e.classList.add(`show`),vs()}function yc(){let e=document.getElementById(`sessionArchivePanel`);e&&e.classList.remove(`show`)}function bc(){let e=document.getElementById(`sessionArchiveSearchClear`);e&&(e.style.display=pc?`flex`:`none`)}async function xc(){let e=document.getElementById(`sessionArchiveList`);if(!e)return;let t=await Gi(),n=pc.trim().toLowerCase(),i=n?t.filter(e=>(e.title||``).toLowerCase().includes(n)):t;if(e.innerHTML=``,i.length===0){let t=document.createElement(`div`);t.className=`session-dropdown-empty`,t.textContent=r(n?`session.archiveNoMatch`:`session.archiveEmpty`),e.appendChild(t);return}let a={today:r(`session.today`),yesterday:r(`session.yesterday`),last7Days:r(`session.last7Days`),earlier:r(`session.earlier`)},o=null;i.forEach(t=>{let n=$o(t.archivedAt);if(n!==o){o=n;let t=document.createElement(`div`);t.className=`session-dropdown-group-header`;let r=document.createElement(`span`);r.textContent=a[n]||n,t.appendChild(r),e.appendChild(t)}e.appendChild(Sc(t))})}function Sc(e){let t=document.createElement(`div`);t.className=`session-dropdown-item session-archive-item`,t.dataset.sessionId=e.id,t.title=e.title||r(`session.newSession`);let n=document.createElement(`span`);n.className=`session-dropdown-item-icon`,n.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 8v13H3V8"/><rect x="1" y="3" width="22" height="5"/><line x1="10" y1="12" x2="14" y2="12"/></svg>`,t.appendChild(n);let i=document.createElement(`span`);i.className=`session-dropdown-item-title`,i.textContent=e.title||r(`session.newSession`),t.appendChild(i);let a=document.createElement(`span`);a.className=`session-dropdown-item-time`,a.textContent=r(`session.archivedAt`,{time:Zo(e.archivedAt)}),t.appendChild(a);let o=document.createElement(`span`);o.className=`session-dropdown-item-actions`;let s=document.createElement(`span`);s.className=`session-dropdown-item-restore`,s.title=r(`session.restoreTitle`),s.innerHTML=`<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 14 4 9 9 4"/><path d="M20 20v-7a4 4 0 0 0-4-4H4"/></svg>`,s.addEventListener(`click`,async t=>{t.stopPropagation(),await Cc(e.id)}),o.appendChild(s);let c=document.createElement(`span`);return c.className=`session-dropdown-item-delete`,c.title=r(`session.deleteForever`),c.innerHTML=`✕`,c.addEventListener(`click`,async t=>{t.stopPropagation(),await wc(e)}),o.appendChild(c),t.appendChild(o),t.addEventListener(`click`,async()=>{await Cc(e.id,{enter:!0})}),t}async function Cc(e,{enter:t=!1}={}){if(!await Ji(e)){L(r(`session.operationFailed`,{message:`not found`}),`error`),await xc();return}let n=await Fi();N.sessions=n.list;let i=n.list.find(t=>t.id===e)?.title||r(`session.newSession`);yc(),await xc(),await _c(),t?await Ac(e):es(n),L(r(`session.archivedRestored`,{title:i}),`success`)}async function wc(e){let t=e.title||r(`session.newSession`);await fc(r(`session.confirmDeleteForeverMessage`,{title:t}),r(`session.confirmDeleteForeverTitle`))&&(await Yi(e.id),await xc(),await _c(),document.dispatchEvent(new CustomEvent(`session-deleted`,{detail:{sessionId:e.id}})),L(r(`session.archiveDeleted`,{title:t}),`success`))}function Tc(){if(mc)return;let e=document.getElementById(`sessionArchivePanel`),t=document.getElementById(`sessionArchiveEntry`);if(!e||!t)return;mc=!0,t.addEventListener(`click`,()=>{vc()});let n=document.getElementById(`sessionArchiveBackBtn`);n&&n.addEventListener(`click`,()=>{yc(),uc()});let r=document.getElementById(`sessionArchiveCloseBtn`);r&&r.addEventListener(`click`,()=>yc());let i=document.getElementById(`sessionArchiveSearch`),a=document.getElementById(`sessionArchiveSearchClear`);i&&(i.addEventListener(`input`,()=>{pc=i.value,bc(),xc()}),i.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.stopPropagation(),yc(),uc())})),a&&a.addEventListener(`click`,()=>{i&&(i.value=``,pc=``,bc(),xc(),i.focus())}),document.addEventListener(`session-archived`,()=>{e.classList.contains(`show`)&&xc()}),document.addEventListener(`session-deleted`,()=>{e.classList.contains(`show`)&&xc()})}var Ec=!1,Dc=500;function Oc(e){let t=`scrollPosition_${e||`default`}`;chrome.storage.local.get([t],e=>{let n=document.getElementById(`chatContainer`);n&&e[t]!==void 0&&(n.scrollTop=e[t]),M(async()=>{let{updateScrollButtonState:e}=await Promise.resolve().then(()=>XS);return{updateScrollButtonState:e}},void 0).then(({updateScrollButtonState:e})=>e()).catch(()=>{})})}function kc(e,t){setTimeout(()=>{N.activeSessionId===e&&(Ut(t)||Oc(e))},Dc)}async function Ac(e,{focusMessageId:t=null}={}){let n=N.activeSessionId;if(!await Bi(e))return;let r=`agentEnabledTools_${N.activeAgentId||`default`}`,i=`agentMcpClosedServers_${N.activeAgentId||`default`}`,[a,o,s,c]=await Promise.all([Fi(),chrome.storage.local.get([i,`ragTools`,`ragToolsIntroduced`]),chrome.storage.local.get([r,`enabledTools`]),N.activeAgentId?vt(N.activeAgentId):Promise.resolve(null)]);N.sessions=a.list,N.activeSessionId=e;let l=o.ragTools||[];N.mcpClosedServers=o[i]||[];let u=!!s[r],d=s[r]||s.enabledTools;if(u||d&&d.length>0){let e=Fa(l),t=d.filter(t=>e.has(t));if(u)N.enabledTools=t;else{let e=x.filter(e=>e.enabled&&!t.includes(e.id)).map(e=>e.id);N.enabledTools=[...t,...e]}let n=Pa(N.enabledTools,l,o.ragToolsIntroduced);N.enabledTools=n.tools,N.enabledTools.length!==d.length&&chrome.storage.local.set({[r]:N.enabledTools,...n.migrated?{ragToolsIntroduced:!0}:{}})}else{N.enabledTools=x.filter(e=>e.enabled).map(e=>e.id);let e=Pa(N.enabledTools,l,o.ragToolsIntroduced);N.enabledTools=e.tools,e.migrated&&chrome.storage.local.set({ragToolsIntroduced:!0,[r]:N.enabledTools})}N.activeAgentToolIds=c?c.toolIds:null,N.activeAgentMcpExcludedServerIds=c?c.mcpExcludedServerIds??null:null,document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:e,previousSessionId:n,...t?{skipScrollRestore:!0}:{}}})),Pi(e),es(a),Mc(),aE();try{let{refreshBookmarkPanel:e,updateBookmarkButtons:t}=await M(async()=>{let{refreshBookmarkPanel:e,updateBookmarkButtons:t}=await Promise.resolve().then(()=>yh);return{refreshBookmarkPanel:e,updateBookmarkButtons:t}},void 0);e(),setTimeout(()=>t(),100)}catch{}let f=document.getElementById(`toolsPopupOverlay`);f&&f.classList.contains(`show`)&&(ba(),Oa(),ka()),Ma(),t&&kc(e,t)}async function jc(e,t=null){if(e)try{let n=await Qi(e,t);await Ac(n.id),L(r(t?`session.forkedFrom`:`session.forkedSession`,{title:n.title}),`success`)}catch(e){a.error(`[SessionUI] copy/forksession failed:`,e),L(r(`session.operationFailed`,{message:e.message}),`error`)}}function Mc(){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 Nc=new WeakSet;function Pc(e){Nc.has(e)||(Nc.add(e),e.addEventListener(`wheel`,t=>{e.scrollWidth<=e.clientWidth||(t.preventDefault(),e.scrollLeft+=t.deltaY)},{passive:!1}))}function Fc(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 Hi(e.id,t),es();let n=await Fi();N.sessions=n.list,N.activeSessionId=n.activeSessionId,Es(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 Ic(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()=>{ks(await Os(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 Lc(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=Rc(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(),Fc(t)});i.appendChild(a);let o=Rc(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(),jc(t.id)});i.appendChild(o);let s=Rc(r(`session.archive`),`<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="M21 8v13H3V8"/><rect x="1" y="3" width="22" height="5"/><line x1="10" y1="12" x2="14" y2="12"/></svg>`,async()=>{i.remove(),await hc(t.id)});i.appendChild(s);let c=Rc(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.messageCount??t.messageHistory?.length??0)===0){ks(await Os(t.id)),await zc();return}Ic(t,async()=>{await zc()})},`danger`);i.appendChild(c),document.body.appendChild(i);let l=e=>{i.contains(e.target)||(i.remove(),document.removeEventListener(`click`,l))};setTimeout(()=>document.addEventListener(`click`,l),0)}function Rc(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 zc(){let e=N.activeSessionId,t=await Fi();t.activeSessionId||(await zi(),t=await Fi()),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,Li(n),N.activeAgentId=n&&n.agentId||null,N.activeAgentId){let e=await vt(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}})),es(),await aE()}async function Bc(){let e=N.activeSessionId;if(!e)return;let t=N.sessions?.find(t=>t.id===e);if(t){if((N.messageHistory?.length||0)===0){ks(await Os(e)),await zc();return}Ic(t,async()=>{await zc()})}}document.addEventListener(`generating-state-changed`,()=>{es()}),document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>{ls(),dc()}):(ls(),dc()),[`<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 Vc=`<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>`,Hc=`<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>`,Uc=`<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>`,Wc=`<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>`,Gc=`<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>`,Kc=`<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 qc=null,Jc=1,Yc=.25,Xc=2,Zc=.1;function Qc(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>
|
|
61
61
|
<html>
|
|
62
62
|
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"></head>
|
|
63
63
|
<body style="margin:0;padding:0;overflow:auto;">${t}</body>
|
|
@@ -1110,7 +1110,7 @@ It is this session's directory or the agent default, so it stays accessible (wor
|
|
|
1110
1110
|
<source src="${c}" type="${Y(o)}">
|
|
1111
1111
|
</audio>
|
|
1112
1112
|
<div id="mediaUnsupportedHint" style="display:none;">${u}</div>
|
|
1113
|
-
</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 nv=!1;function rv(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 iv(e,t){rv(e,t),t.classList.add(`show`)}function av(){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`):iv(t,n)});let r=null,i=null;e.addEventListener(`mouseenter`,()=>{i&&=(clearTimeout(i),null),r=setTimeout(()=>{iv(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`),sv(r)})}),document.addEventListener(`click`,t=>{!e.contains(t.target)&&!n.contains(t.target)&&n.classList.remove(`show`)});let a=()=>{n.classList.contains(`show`)&&rv(t,n)};document.getElementById(`workspacePreviewContent`)?.addEventListener(`scroll`,a),window.addEventListener(`resize`,a)}function ov(){return document.getElementById(`workspacePreviewArea`).dataset.markdownText||``}async function sv(e){if(nv)return;nv=!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 uv(i);break;case`pdf`:await fv(i);break;case`image`:await pv(i);break;case`md`:mv(i);break}}catch(e){a.error(`[WorkspacePanel] export failed:`,e),L(r(`chatExport.exportFailed`,{message:e.message}),`error`)}finally{nv=!1,t.innerHTML=o,t.disabled=!1,t.style.opacity=`1`,n.classList.remove(`show`)}}async function cv(e){if(typeof mermaid>`u`)return;let{renderMermaidInContainer:t,convertSvgsToImages:n}=await M(async()=>{let{renderMermaidInContainer:e,convertSvgsToImages:t}=await import(`./chat-export-
|
|
1113
|
+
</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 nv=!1;function rv(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 iv(e,t){rv(e,t),t.classList.add(`show`)}function av(){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`):iv(t,n)});let r=null,i=null;e.addEventListener(`mouseenter`,()=>{i&&=(clearTimeout(i),null),r=setTimeout(()=>{iv(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`),sv(r)})}),document.addEventListener(`click`,t=>{!e.contains(t.target)&&!n.contains(t.target)&&n.classList.remove(`show`)});let a=()=>{n.classList.contains(`show`)&&rv(t,n)};document.getElementById(`workspacePreviewContent`)?.addEventListener(`scroll`,a),window.addEventListener(`resize`,a)}function ov(){return document.getElementById(`workspacePreviewArea`).dataset.markdownText||``}async function sv(e){if(nv)return;nv=!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 uv(i);break;case`pdf`:await fv(i);break;case`image`:await pv(i);break;case`md`:mv(i);break}}catch(e){a.error(`[WorkspacePanel] export failed:`,e),L(r(`chatExport.exportFailed`,{message:e.message}),`error`)}finally{nv=!1,t.innerHTML=o,t.disabled=!1,t.style.opacity=`1`,n.classList.remove(`show`)}}async function cv(e){if(typeof mermaid>`u`)return;let{renderMermaidInContainer:t,convertSvgsToImages:n}=await M(async()=>{let{renderMermaidInContainer:e,convertSvgsToImages:t}=await import(`./chat-export-BjO4Cgaj.js`);return{renderMermaidInContainer:e,convertSvgsToImages:t}},__vite__mapDeps([10,11,1,4,12,2,3,13,14,0]));await t(e),await n(e)}async function lv(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-BjO4Cgaj.js`);return{renderMermaidInContainer:e,convertSvgsToImages:t}},__vite__mapDeps([10,11,1,4,12,2,3,13,14,0]));try{let r=on(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 uv(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-BjO4Cgaj.js`);return{createDocxDocument:e}},__vite__mapDeps([10,11,1,4,12,2,3,13,14,0])),i=ov();if(!i){L(r(`chatExport.noContent`),`error`);return}i=await lv(i);let a=n(await dv(i)),o=await t.toBlob(a),s=`word-${new Date().getTime()}.docx`;hv(o,s),L(r(`workspace.downloaded`,{name:s}),`success`)}async function dv(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-BjO4Cgaj.js`);return{createTextRuns:e,sanitizeDocxText:t,nextDocxImageId:n,isDocxEmbeddableImageType:r}},__vite__mapDeps([10,11,1,4,12,2,3,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(`
|
|
1114
1114
|
`),n=[];for(let e of t){if(/^[\s\|:\-]+$/.test(e.replace(/\|/g,``)))continue;let t=Xt(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(`
|
|
1115
1115
|
`);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(`
|
|
1116
1116
|
`).map(e=>e.replace(/^>\s?/,``)).join(`
|
|
@@ -1203,7 +1203,7 @@ It is this session's directory or the agent default, so it stays accessible (wor
|
|
|
1203
1203
|
<span style="flex:1;">${Y(e)}</span>
|
|
1204
1204
|
${t?a:``}${n?o:``}
|
|
1205
1205
|
${i?`<button class="switch-workdir-remove" data-remove-path="${Y(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>`:``}
|
|
1206
|
-
</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 Pn(e);n.success?(u=Array.isArray(n.allowedPaths)?n.allowedPaths:u.filter(t=>t!==e),C(),L(r(t?`workspace.removedStillUsable`:`workspace.removedFromAllowed`),`success`)):L(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){L(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 zy(n));return}L(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 By(n,{sessionId:d,setAsDefault:s})))}y&&y.addEventListener(`click`,async()=>{y.disabled=!0,S(),e(await Vy(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 Py(){Rh=null,q=null,zh=[],J.clear(),vy=``,yy=[],by=!1,jg.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 Fy=0;async function Iy(){let e=++Fy;if(N.agentPlatform?.connected!==!0){ln(),Py();return}await Zv();let t=Rh;ln();let n=null;try{n=await bn()}catch(e){a.warn(`[WorkspacePanel] resolve root for session failed:`,e?.message||e)}if(e!==Fy||t&&n&&t===n)return;Py();let r=document.getElementById(`workspacePreviewArea`);if(r&&r.dataset.previewPath&&(rg=!1,await Dv(!0)),await Promise.resolve(),e!==Fy)return;let i=document.getElementById(`workspacePanel`);!i||!i.classList.contains(`expanded`)||await kg()}async function Ly(e,t){document.dispatchEvent(new CustomEvent(`session-workdir-changed`,{detail:{sessionId:e,workdir:t}}))}async function Ry(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 zy(e){let t=await un(e,{sessionId:null});return t.success?(await Ry(t.workdir),await Ly(null,t.workdir),L(r(`workspace.setAsDefaultDone`,{path:t.workdir}),`success`),!0):(L(r(`workspace.switchFailedWithError`,{error:t.error||r(`workspace.unknownError`)}),`error`),!1)}async function By(e,t={}){let n=t.sessionId===void 0?N.activeSessionId||null:t.sessionId,i=t.setAsDefault===!0,o=await un(e,{sessionId:n});if(!o.success)return L(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-BXelxKzG.js`).then(e=>e.g);return{setSessionWorkdirBinding:e}},__vite__mapDeps([2,1,3,4])),t=(await Cn())?.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 un(o.workdir,{sessionId:null});e.success?s=!0:L(r(`workspace.switchFailedWithError`,{error:e.error||r(`workspace.unknownError`)}),`error`)}return(!n||i)&&await Ry(o.workdir),await Ly(n,o.workdir),L(r(s?`workspace.switchedToAndSetDefault`:`workspace.switchedTo`,{path:o.workdir}),`success`),!0}async function Vy(e,t={}){if(!e)return!1;let{unbindSessionWorkdirRemote:n}=await M(async()=>{let{unbindSessionWorkdirRemote:e}=await import(`./session-store-BXelxKzG.js`).then(e=>e.Ft);return{unbindSessionWorkdirRemote:e}},__vite__mapDeps([2,1,3,4]));if(await n(e)===null&&t.sessionSupported)return L(r(`workspace.switchFailedWithError`,{error:r(`workspace.unknownError`)}),`error`),!1;try{let{setSessionWorkdirBinding:t}=await M(async()=>{let{setSessionWorkdirBinding:e}=await import(`./session-store-BXelxKzG.js`).then(e=>e.g);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 Ly(e,``),L(r(`workdirTag.restoredDefault`),`success`),!0}async function Hy(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 My(r(n===`directory`?`workspace.renameDir`:`workspace.renameFile`),i,r(`workspace.inputNewName`));if(!s||s===i)return;let c=s+a;try{let t=await fn(e,c);t.success?(L(r(`workspace.renamedTo`,{name:c}),`success`),Rg(q),await ey(),qy(c)):L(r(`workspace.renameFailedWithError`,{error:t.error}),`error`)}catch(e){L(r(`workspace.renameFailedWithError`,{error:e.message}),`error`)}}async function Uy(){if(!q)return;let e=await My(r(`workspace.newFolderTitle`),``,r(`workspace.inputFolderName`));if(!e)return;let t=Lg(`${q}/${e}`);try{let n=await Tn(t);n.success?(L(r(`workspace.folderCreated`,{name:e}),`success`),Rg(q),await ey(),qy(e)):L(r(`workspace.createFailedWithError`,{error:n.error}),`error`)}catch(e){L(r(`workspace.createFailedWithError`,{error:e.message}),`error`)}}async function Wy(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 Gy(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=cg.find(e=>e.path===i),o||=yy.find(e=>e.fullPath===i));let s=o?o.size:0,c=wn(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 Cn();if(t){let n=await fetch(`${t.url}/api/fs/download-stream`,{method:`POST`,headers:{"Content-Type":`application/json`,...An(t)},body:JSON.stringify({path:e.path})});if(n.ok){let{originalUrl:e,compressedUrl:t}=await Wy(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);uh(),Mh();let i=t.length+n.length;i>0&&(!N.enableImageInput&&t.some(e=>e.type?.startsWith(`image/`))?L(r(`workspace.addedFilesToQuestionNoImage`,{count:i}),`success`):L(r(`workspace.addedFilesToQuestion`,{count:i}),`success`))}async function Ky(){J.size!==0&&await Gy(Array.from(J))}function qy(e,t=0){let n=document.getElementById(`workspacePanelContent`);if(!n)return;if(Hg){let t=Hg.sorted.findIndex(t=>t.name===e);if(t>=0){let r=Hg.itemHeight;n.scrollTop=Math.max(0,t*r-n.clientHeight/2+r/2),Gg();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(()=>qy(e,t+1),150)}function Jy(){let e=document.getElementById(`workspaceAskBtn`);J.size===0?e.style.display=`none`:e.style.display=``}function Yy(){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=eg),Jy()}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 Xy(e){let t=(e||``).replace(/\\/g,`/`).replace(/\/+/g,`/`),n=t.replace(/\/+$/,``);return n?/^[A-Za-z]:$/.test(n)?n+`/`:n:t?`/`:``}function Zy(e){if(!e)return``;let t=Xy(e).replace(/\/+$/,``).split(`/`);return t[t.length-1]||``}function Qy(e){if(!e)return``;let t=Zy(e),n=t.lastIndexOf(`.`);return n>0?t.substring(n+1).toLowerCase():``}function $y(e){return String(e??``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function eb(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 tb(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=eb(a,`,`).map(e=>e.trim());if(s.length<=1)return[e];let c=[];for(let e of s)for(let t of tb(e))for(let e of tb(o))c.push(i+t+e);return c}function nb(e,t){let n=[],r=new Set;for(let i of e)if(i)for(let e of tb(i)){if(!e)continue;let i=t(e);!i||r.has(i)||(r.add(i),n.push(i))}return n}function rb(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 ib(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=ab(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 ab(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 ob(e){let t=Xy(e||``).replace(/\/$/,``);if(!t)return``;let n=t.lastIndexOf(`/`);return n>0?t.substring(0,n):``}var sb=new Set([`du`,`df`,`stat`,`wc`,`file`,`cat`,`head`,`tail`,`grep`,`rg`]);function cb(e){if(!e||typeof e!=`string`)return!1;let t=ib(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()),!sb.has(n))return!1}return!0}function lb(e,t){let n=t=>e===t||e.startsWith(t.endsWith(`/`)?t:t+`/`);return[...t].some(n)}function ub(e,t){if(!e||typeof e!=`string`)return t||``;let n=t||``;for(let t of ib(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?Xy(n).replace(/\/[^/]+$/,``)||`/`:`..`:Xy(n?n.replace(/\/$/,``)+`/`+r:r)}return n}function db(e,t){if(!e||typeof e!=`string`)return[];let n=[],r=t||``,i=ib(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?Xy(r).replace(/\/[^/]+$/,``)||`/`:`..`:Xy(r?r.replace(/\/$/,``)+`/`+e:e);continue}let o=e=>(e=e.replace(/^['"]|['"]$/g,``),!e.startsWith(`/`)&&!e.startsWith(`~/`)&&r&&(e=Xy(r.replace(/\/$/,``)+`/`+e)),Xy(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 fb(t,r))e&&n.push({path:o(e),isDir:!1});continue}}let c=i.match(/^mkdir\s+(?:-[a-z]+\s+)*(.+?)$/);if(c){let e=nb(eb(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=nb(eb(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=nb([u],o);for(let t of e)n.push({path:t,isDir:!1})}}return n}function fb(e,t){if(!e||typeof e!=`string`)return[];let n=[],r=e.split(`
|
|
1206
|
+
</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 Pn(e);n.success?(u=Array.isArray(n.allowedPaths)?n.allowedPaths:u.filter(t=>t!==e),C(),L(r(t?`workspace.removedStillUsable`:`workspace.removedFromAllowed`),`success`)):L(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){L(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 zy(n));return}L(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 By(n,{sessionId:d,setAsDefault:s})))}y&&y.addEventListener(`click`,async()=>{y.disabled=!0,S(),e(await Vy(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 Py(){Rh=null,q=null,zh=[],J.clear(),vy=``,yy=[],by=!1,jg.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 Fy=0;async function Iy(){let e=++Fy;if(N.agentPlatform?.connected!==!0){ln(),Py();return}await Zv();let t=Rh;ln();let n=null;try{n=await bn()}catch(e){a.warn(`[WorkspacePanel] resolve root for session failed:`,e?.message||e)}if(e!==Fy||t&&n&&t===n)return;Py();let r=document.getElementById(`workspacePreviewArea`);if(r&&r.dataset.previewPath&&(rg=!1,await Dv(!0)),await Promise.resolve(),e!==Fy)return;let i=document.getElementById(`workspacePanel`);!i||!i.classList.contains(`expanded`)||await kg()}async function Ly(e,t){document.dispatchEvent(new CustomEvent(`session-workdir-changed`,{detail:{sessionId:e,workdir:t}}))}async function Ry(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 zy(e){let t=await un(e,{sessionId:null});return t.success?(await Ry(t.workdir),await Ly(null,t.workdir),L(r(`workspace.setAsDefaultDone`,{path:t.workdir}),`success`),!0):(L(r(`workspace.switchFailedWithError`,{error:t.error||r(`workspace.unknownError`)}),`error`),!1)}async function By(e,t={}){let n=t.sessionId===void 0?N.activeSessionId||null:t.sessionId,i=t.setAsDefault===!0,o=await un(e,{sessionId:n});if(!o.success)return L(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-XFFEUHgS.js`).then(e=>e.g);return{setSessionWorkdirBinding:e}},__vite__mapDeps([2,1,3,4])),t=(await Cn())?.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 un(o.workdir,{sessionId:null});e.success?s=!0:L(r(`workspace.switchFailedWithError`,{error:e.error||r(`workspace.unknownError`)}),`error`)}return(!n||i)&&await Ry(o.workdir),await Ly(n,o.workdir),L(r(s?`workspace.switchedToAndSetDefault`:`workspace.switchedTo`,{path:o.workdir}),`success`),!0}async function Vy(e,t={}){if(!e)return!1;let{unbindSessionWorkdirRemote:n}=await M(async()=>{let{unbindSessionWorkdirRemote:e}=await import(`./session-store-XFFEUHgS.js`).then(e=>e.Ft);return{unbindSessionWorkdirRemote:e}},__vite__mapDeps([2,1,3,4]));if(await n(e)===null&&t.sessionSupported)return L(r(`workspace.switchFailedWithError`,{error:r(`workspace.unknownError`)}),`error`),!1;try{let{setSessionWorkdirBinding:t}=await M(async()=>{let{setSessionWorkdirBinding:e}=await import(`./session-store-XFFEUHgS.js`).then(e=>e.g);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 Ly(e,``),L(r(`workdirTag.restoredDefault`),`success`),!0}async function Hy(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 My(r(n===`directory`?`workspace.renameDir`:`workspace.renameFile`),i,r(`workspace.inputNewName`));if(!s||s===i)return;let c=s+a;try{let t=await fn(e,c);t.success?(L(r(`workspace.renamedTo`,{name:c}),`success`),Rg(q),await ey(),qy(c)):L(r(`workspace.renameFailedWithError`,{error:t.error}),`error`)}catch(e){L(r(`workspace.renameFailedWithError`,{error:e.message}),`error`)}}async function Uy(){if(!q)return;let e=await My(r(`workspace.newFolderTitle`),``,r(`workspace.inputFolderName`));if(!e)return;let t=Lg(`${q}/${e}`);try{let n=await Tn(t);n.success?(L(r(`workspace.folderCreated`,{name:e}),`success`),Rg(q),await ey(),qy(e)):L(r(`workspace.createFailedWithError`,{error:n.error}),`error`)}catch(e){L(r(`workspace.createFailedWithError`,{error:e.message}),`error`)}}async function Wy(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 Gy(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=cg.find(e=>e.path===i),o||=yy.find(e=>e.fullPath===i));let s=o?o.size:0,c=wn(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 Cn();if(t){let n=await fetch(`${t.url}/api/fs/download-stream`,{method:`POST`,headers:{"Content-Type":`application/json`,...An(t)},body:JSON.stringify({path:e.path})});if(n.ok){let{originalUrl:e,compressedUrl:t}=await Wy(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);uh(),Mh();let i=t.length+n.length;i>0&&(!N.enableImageInput&&t.some(e=>e.type?.startsWith(`image/`))?L(r(`workspace.addedFilesToQuestionNoImage`,{count:i}),`success`):L(r(`workspace.addedFilesToQuestion`,{count:i}),`success`))}async function Ky(){J.size!==0&&await Gy(Array.from(J))}function qy(e,t=0){let n=document.getElementById(`workspacePanelContent`);if(!n)return;if(Hg){let t=Hg.sorted.findIndex(t=>t.name===e);if(t>=0){let r=Hg.itemHeight;n.scrollTop=Math.max(0,t*r-n.clientHeight/2+r/2),Gg();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(()=>qy(e,t+1),150)}function Jy(){let e=document.getElementById(`workspaceAskBtn`);J.size===0?e.style.display=`none`:e.style.display=``}function Yy(){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=eg),Jy()}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 Xy(e){let t=(e||``).replace(/\\/g,`/`).replace(/\/+/g,`/`),n=t.replace(/\/+$/,``);return n?/^[A-Za-z]:$/.test(n)?n+`/`:n:t?`/`:``}function Zy(e){if(!e)return``;let t=Xy(e).replace(/\/+$/,``).split(`/`);return t[t.length-1]||``}function Qy(e){if(!e)return``;let t=Zy(e),n=t.lastIndexOf(`.`);return n>0?t.substring(n+1).toLowerCase():``}function $y(e){return String(e??``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function eb(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 tb(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=eb(a,`,`).map(e=>e.trim());if(s.length<=1)return[e];let c=[];for(let e of s)for(let t of tb(e))for(let e of tb(o))c.push(i+t+e);return c}function nb(e,t){let n=[],r=new Set;for(let i of e)if(i)for(let e of tb(i)){if(!e)continue;let i=t(e);!i||r.has(i)||(r.add(i),n.push(i))}return n}function rb(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 ib(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=ab(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 ab(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 ob(e){let t=Xy(e||``).replace(/\/$/,``);if(!t)return``;let n=t.lastIndexOf(`/`);return n>0?t.substring(0,n):``}var sb=new Set([`du`,`df`,`stat`,`wc`,`file`,`cat`,`head`,`tail`,`grep`,`rg`]);function cb(e){if(!e||typeof e!=`string`)return!1;let t=ib(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()),!sb.has(n))return!1}return!0}function lb(e,t){let n=t=>e===t||e.startsWith(t.endsWith(`/`)?t:t+`/`);return[...t].some(n)}function ub(e,t){if(!e||typeof e!=`string`)return t||``;let n=t||``;for(let t of ib(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?Xy(n).replace(/\/[^/]+$/,``)||`/`:`..`:Xy(n?n.replace(/\/$/,``)+`/`+r:r)}return n}function db(e,t){if(!e||typeof e!=`string`)return[];let n=[],r=t||``,i=ib(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?Xy(r).replace(/\/[^/]+$/,``)||`/`:`..`:Xy(r?r.replace(/\/$/,``)+`/`+e:e);continue}let o=e=>(e=e.replace(/^['"]|['"]$/g,``),!e.startsWith(`/`)&&!e.startsWith(`~/`)&&r&&(e=Xy(r.replace(/\/$/,``)+`/`+e)),Xy(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 fb(t,r))e&&n.push({path:o(e),isDir:!1});continue}}let c=i.match(/^mkdir\s+(?:-[a-z]+\s+)*(.+?)$/);if(c){let e=nb(eb(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=nb(eb(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=nb([u],o);for(let t of e)n.push({path:t,isDir:!1})}}return n}function fb(e,t){if(!e||typeof e!=`string`)return[];let n=[],r=e.split(`
|
|
1207
1207
|
`);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=eb(i[1],` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`-`));n.push(...e)}let a=t.match(/^touch\s+(.+)$/);if(a){let e=eb(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 pb(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(`/`)?Xy(e):Xy((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 mb(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=Qy(e);[`sh`,`bash`,`zsh`,`bat`,`cmd`,`ps1`,`py`].includes(n)&&t.push({path:Xy(e),content:r[3],ext:n})}return t}function hb(e,t){if(!e||typeof e!=`string`)return null;let n=e.trim();for(let e of t){let t=Zy(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 gb(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=Xy(r.replace(/\/$/,``)+`/`+e)),Xy(e)),a=ib(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)?Xy(e):e.startsWith(`~/`)?e:e===`..`?r?Xy(r).replace(/\/[^/]+$/,``)||`/`:`..`:Xy(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=nb(eb(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=nb(eb(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=nb(eb(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=nb([...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 _b(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=Xy(t.path||t.filePath||``),r=Qy(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 mb(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=hb(u,a);if(d&&e.status!==`failed`){let a=i.get(d);if(a){let i=fb(a.content,a.ext);for(let a of i){if(!a)continue;let i=(a.startsWith(`/`),Xy(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:Zy(i),toolName:r,action:`typeCreate`,size:0,timestamp:e.timestamp||null,status:e.status||`unknown`,type:`file`})}}}if(e.status!==`failed`){let t=gb(u,s.cwd);for(let n of t)o.set(n.path,{isDir:n.isDir,timestamp:e.timestamp})}let f=db(u,s.cwd);for(let e of f)if(e&&e.path){let t=e.isDir?e.path:ob(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:Zy(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=ub(u,s.cwd);/\bcd\s/.test(u)&&i&&(p||l)&&c.add(Xy(i));let a=pb(e.observation,i,u);a.length>0&&!p&&(a=cb(u)?[]:a.filter(e=>lb(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:Zy(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=Xy(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=Xy(rb(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=ob(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:Zy(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 vb(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=yb(e);!a||n.has(a)||(n.add(a),t.push({path:e,note:r}))}return t}function yb(e){return Xy(e).replace(/^\.\//,``)}function bb(e,t){let n=(e||[]).map(e=>({...e,source:e.source||`static`})),r=n.map(e=>yb(e.path));for(let e of t||[]){let t=yb(e.path);if(!t)continue;let i=Zy(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 xb(e,t){return bb(_b(e),vb(t))}function Sb(e){try{return pn(e)}catch{return!1}}var Cb=null,wb=null,Tb=null,Eb=1;function Db(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 Ob(e){if(!Tb)return e;let t=Eb;return[...e].sort((e,n)=>{let r,i;return Tb===`name`?(r=(e.fileName||e.path||``).toLowerCase(),i=(n.fileName||n.path||``).toLowerCase()):Tb===`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 kb(e,t){let n=vn(e.fileName,e.type),i=r(`artifacts.${e.action}`),a=Db(e.timestamp),o=Sb(e.fileName),s=`${$y(e.path)} · ${r(`artifacts.dblClickHint`)}`;return`
|
|
1208
1208
|
<tr class="artifacts-row" data-idx="${t}" data-path="${$y(e.path)}" data-name="${$y(e.fileName)}">
|
|
1209
1209
|
<td class="col-index">${t+1}</td>
|
|
@@ -1365,7 +1365,7 @@ It is this session's directory or the agent default, so it stays accessible (wor
|
|
|
1365
1365
|
<span class="page-action-btn" data-action="translate" data-tab-id="${e.id}" title="${r(`pageSelector.translatePage`)}">${r(`pageSelector.translatePage`)}</span>
|
|
1366
1366
|
</span>
|
|
1367
1367
|
</div>
|
|
1368
|
-
`}).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(),Px(parseInt(n.dataset.tabId),n.dataset.action);return}Nx(parseInt(e.dataset.tabId))})})}function Ax(e){e.forEach((e,t)=>{t===N.selectedPageIndex?(e.classList.add(`selected`),e.scrollIntoView({block:`nearest`})):e.classList.remove(`selected`)})}function jx(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 Mx(){N.selectedPage=null,N.selectedPageIndex=-1;let e=document.getElementById(`pageIndicator`);e&&(e.style.display=`none`)}function Nx(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}jx(e),qb(),t&&(t.focus(),Ht())})}function Px(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}jx(e),qb();let t=document.getElementById(`userInput`);t&&(t.value=n,Ht()),jw()})}function Fx(){let e=document.getElementById(`pageIndicatorClose`);e&&e.addEventListener(`click`,()=>{Mx()})}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 Ix=`messageFullscreenOverlay`,Lx=`messageFullscreenBody`,Rx=`messageFullscreenTitle`,zx=`messageFullscreenCopyBtn`,Bx=`messageFullscreenCloseBtn`,Vx=`messageFullscreenExportBtn`,Hx=`messageFullscreenExportDropdown`,Ux=null,Wx=null,Gx=null,Kx=!1,qx=null,Jx=!1;function Yx(){return Ux!==null}function Xx(e){return!e||Yx()?null:e.innerHTML}function Zx(){let e=document.querySelectorAll(`#chatContainer .message.assistant`);return e.length?e[e.length-1]:null}function Qx(){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 $x(){let e=document.getElementById(Ix),t=document.getElementById(Lx);return!e||!t?(a.warn(`[MsgFullscreen] overlay/body element missing`),null):{overlay:e,body:t,title:document.getElementById(Rx),copyBtn:document.getElementById(zx),closeBtn:document.getElementById(Bx)}}function eS(e){if(!e)return;let t=$x();if(t&&Ux!==e){if(!Ux){let e=document.getElementById(`chatContainer`);qx=e?e.scrollTop:null}Ux&&(Jx=!0,tS(),Jx=!1),Wx=document.createComment(`msg-fullscreen-anchor`),e.parentNode.insertBefore(Wx,e),e.dataset.fullscreen=`1`,t.body.appendChild(e),Ux=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`)),dS(),rS(t.body)}}function tS(){if(!Ux)return;let e=$x();if(aS(),fS(),Wx&&Wx.parentNode)Wx.parentNode.insertBefore(Ux,Wx);else if(e){let e=document.getElementById(`chatContainer`);e&&e.appendChild(Ux)}if(Wx&&Wx.parentNode&&Wx.parentNode.removeChild(Wx),delete Ux.dataset.fullscreen,Ux=null,Wx=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`),!Jx&&qx!==null){let e=document.getElementById(`chatContainer`);e&&(e.scrollTop=qx),qx=null}}function nS(e){if(Ux&&Ux===e){tS();return}eS(e||Zx())}function rS(e){aS(),Kx=!1,e.scrollTop=e.scrollHeight,e.addEventListener(`scroll`,iS,{passive:!0}),typeof ResizeObserver<`u`&&(Gx=new ResizeObserver(()=>{Kx||(e.scrollTop=e.scrollHeight)}),Gx.observe(e.firstElementChild||e))}function iS(){let e=document.getElementById(Lx);e&&(Kx=e.scrollHeight-e.scrollTop-e.clientHeight>60)}function aS(){let e=document.getElementById(Lx);e&&e.removeEventListener(`scroll`,iS),Gx&&=(Gx.disconnect(),null)}function oS(e){if(e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&e.code===`KeyF`){e.preventDefault(),Ux?tS():eS(Zx());return}e.key===`Escape`&&Ux&&(e.preventDefault(),e.stopImmediatePropagation(),tS())}function sS(e){if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return;let t=e.target.closest?.(`#chatContainer .message.assistant`);t&&(e.preventDefault(),nS(t))}async function cS(e){if(!Ux)return;let{copyAssistantMessage:t}=await M(async()=>{let{copyAssistantMessage:e}=await Promise.resolve().then(()=>hS);return{copyAssistantMessage:e}},void 0);t(Ux,document.getElementById(zx),e)}var lS={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 uS(){let e=document.createElement(`div`);e.className=`message-fullscreen-export`;let t=document.createElement(`button`);t.className=`message-fullscreen-icon-btn`,t.id=Vx,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=Hx;let i=e=>`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round">${lS[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(),Ux&&(n.classList.remove(`show`),(await M(()=>import(`./chat-export-BSv2Jn2H.js`),__vite__mapDeps([10,11,1,4,12,2,3,13,14,0])))[t](Ux,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 dS(){if(document.getElementById(Vx))return;let e=document.getElementById(Bx),t=e?e.parentNode:document.querySelector(`.message-fullscreen-actions`);t&&t.insertBefore(uS(),e||null)}function fS(){let e=document.getElementById(Hx);e&&e.classList.remove(`show`)}var pS=!1;function mS(){pS||(pS=!0,document.addEventListener(`click`,e=>{let t=document.getElementById(Hx);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(),nS(n.closest(`.message`));return}if(e.target.closest?.(`#messageFullscreenCloseBtn`)){e.stopPropagation(),tS();return}e.target.closest?.(`#messageFullscreenCopyBtn`)&&(e.stopPropagation(),cS(e))},!0),document.addEventListener(`keydown`,oS,!0),document.addEventListener(`dblclick`,sS,!0))}var hS=t({copyAssistantMessage:()=>vS,copyMessage:()=>_S,copyRichText:()=>xS,fallbackCopyRichText:()=>CS,fallbackCopyText:()=>bS,quoteAndAsk:()=>ES,setQuoteContextInjector:()=>TS,showCopySuccess:()=>yS,wrapHtmlWithStyles:()=>SS});n(`zh`,{chatCopy:{copiedMarkdown:`已复制 Markdown`,copiedRich:`已复制富文本`,copyFailedManual:`复制失败,请手动复制`}}),n(`en`,{chatCopy:{copiedMarkdown:`Markdown copied`,copiedRich:`Rich text copied`,copyFailedManual:`Copy failed, please copy manually`}});function gS(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(`
|
|
1368
|
+
`}).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(),Px(parseInt(n.dataset.tabId),n.dataset.action);return}Nx(parseInt(e.dataset.tabId))})})}function Ax(e){e.forEach((e,t)=>{t===N.selectedPageIndex?(e.classList.add(`selected`),e.scrollIntoView({block:`nearest`})):e.classList.remove(`selected`)})}function jx(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 Mx(){N.selectedPage=null,N.selectedPageIndex=-1;let e=document.getElementById(`pageIndicator`);e&&(e.style.display=`none`)}function Nx(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}jx(e),qb(),t&&(t.focus(),Ht())})}function Px(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}jx(e),qb();let t=document.getElementById(`userInput`);t&&(t.value=n,Ht()),jw()})}function Fx(){let e=document.getElementById(`pageIndicatorClose`);e&&e.addEventListener(`click`,()=>{Mx()})}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 Ix=`messageFullscreenOverlay`,Lx=`messageFullscreenBody`,Rx=`messageFullscreenTitle`,zx=`messageFullscreenCopyBtn`,Bx=`messageFullscreenCloseBtn`,Vx=`messageFullscreenExportBtn`,Hx=`messageFullscreenExportDropdown`,Ux=null,Wx=null,Gx=null,Kx=!1,qx=null,Jx=!1;function Yx(){return Ux!==null}function Xx(e){return!e||Yx()?null:e.innerHTML}function Zx(){let e=document.querySelectorAll(`#chatContainer .message.assistant`);return e.length?e[e.length-1]:null}function Qx(){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 $x(){let e=document.getElementById(Ix),t=document.getElementById(Lx);return!e||!t?(a.warn(`[MsgFullscreen] overlay/body element missing`),null):{overlay:e,body:t,title:document.getElementById(Rx),copyBtn:document.getElementById(zx),closeBtn:document.getElementById(Bx)}}function eS(e){if(!e)return;let t=$x();if(t&&Ux!==e){if(!Ux){let e=document.getElementById(`chatContainer`);qx=e?e.scrollTop:null}Ux&&(Jx=!0,tS(),Jx=!1),Wx=document.createComment(`msg-fullscreen-anchor`),e.parentNode.insertBefore(Wx,e),e.dataset.fullscreen=`1`,t.body.appendChild(e),Ux=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`)),dS(),rS(t.body)}}function tS(){if(!Ux)return;let e=$x();if(aS(),fS(),Wx&&Wx.parentNode)Wx.parentNode.insertBefore(Ux,Wx);else if(e){let e=document.getElementById(`chatContainer`);e&&e.appendChild(Ux)}if(Wx&&Wx.parentNode&&Wx.parentNode.removeChild(Wx),delete Ux.dataset.fullscreen,Ux=null,Wx=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`),!Jx&&qx!==null){let e=document.getElementById(`chatContainer`);e&&(e.scrollTop=qx),qx=null}}function nS(e){if(Ux&&Ux===e){tS();return}eS(e||Zx())}function rS(e){aS(),Kx=!1,e.scrollTop=e.scrollHeight,e.addEventListener(`scroll`,iS,{passive:!0}),typeof ResizeObserver<`u`&&(Gx=new ResizeObserver(()=>{Kx||(e.scrollTop=e.scrollHeight)}),Gx.observe(e.firstElementChild||e))}function iS(){let e=document.getElementById(Lx);e&&(Kx=e.scrollHeight-e.scrollTop-e.clientHeight>60)}function aS(){let e=document.getElementById(Lx);e&&e.removeEventListener(`scroll`,iS),Gx&&=(Gx.disconnect(),null)}function oS(e){if(e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&e.code===`KeyF`){e.preventDefault(),Ux?tS():eS(Zx());return}e.key===`Escape`&&Ux&&(e.preventDefault(),e.stopImmediatePropagation(),tS())}function sS(e){if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return;let t=e.target.closest?.(`#chatContainer .message.assistant`);t&&(e.preventDefault(),nS(t))}async function cS(e){if(!Ux)return;let{copyAssistantMessage:t}=await M(async()=>{let{copyAssistantMessage:e}=await Promise.resolve().then(()=>hS);return{copyAssistantMessage:e}},void 0);t(Ux,document.getElementById(zx),e)}var lS={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 uS(){let e=document.createElement(`div`);e.className=`message-fullscreen-export`;let t=document.createElement(`button`);t.className=`message-fullscreen-icon-btn`,t.id=Vx,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=Hx;let i=e=>`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round">${lS[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(),Ux&&(n.classList.remove(`show`),(await M(()=>import(`./chat-export-BjO4Cgaj.js`),__vite__mapDeps([10,11,1,4,12,2,3,13,14,0])))[t](Ux,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 dS(){if(document.getElementById(Vx))return;let e=document.getElementById(Bx),t=e?e.parentNode:document.querySelector(`.message-fullscreen-actions`);t&&t.insertBefore(uS(),e||null)}function fS(){let e=document.getElementById(Hx);e&&e.classList.remove(`show`)}var pS=!1;function mS(){pS||(pS=!0,document.addEventListener(`click`,e=>{let t=document.getElementById(Hx);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(),nS(n.closest(`.message`));return}if(e.target.closest?.(`#messageFullscreenCloseBtn`)){e.stopPropagation(),tS();return}e.target.closest?.(`#messageFullscreenCopyBtn`)&&(e.stopPropagation(),cS(e))},!0),document.addEventListener(`keydown`,oS,!0),document.addEventListener(`dblclick`,sS,!0))}var hS=t({copyAssistantMessage:()=>vS,copyMessage:()=>_S,copyRichText:()=>xS,fallbackCopyRichText:()=>CS,fallbackCopyText:()=>bS,quoteAndAsk:()=>ES,setQuoteContextInjector:()=>TS,showCopySuccess:()=>yS,wrapHtmlWithStyles:()=>SS});n(`zh`,{chatCopy:{copiedMarkdown:`已复制 Markdown`,copiedRich:`已复制富文本`,copyFailedManual:`复制失败,请手动复制`}}),n(`en`,{chatCopy:{copiedMarkdown:`Markdown copied`,copiedRich:`Rich text copied`,copyFailedManual:`Copy failed, please copy manually`}});function gS(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(`
|
|
1369
1369
|
`),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 _S(e,t){try{let n=e.dataset.textContent_||e.dataset.rawContent||``;navigator.clipboard.writeText(n).then(()=>{let e=t.innerHTML;t.innerHTML=`
|
|
1370
1370
|
<svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor">
|
|
1371
1371
|
<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"/>
|
|
@@ -1569,7 +1569,7 @@ It is this session's directory or the agent default, so it stays accessible (wor
|
|
|
1569
1569
|
... (点击展开查看完整输出)`,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}
|
|
1570
1570
|
点击查看评估详情`,reflectionFailedTitle:`反思评估失败(点击查看执行日志)`,reflectionFailedBadge:`⚠️ 反思失败`,prototypeOpenedLocal:`已在本地浏览器打开,点击可在面板内查看`,viewUiPrototype:`查看 UI 原型`,bookmarkMessage:`收藏消息`,removeBookmark:`取消收藏`,forkSession:`从此处分叉会话(仅复制到此条消息)`,deleteMessage:`删除消息`,stopping:`停止中...`,taskStopped:`任务已被用户停止`,cancelled:`已取消`}}),n(`en`,{chatStream:{thinking:`Thinking...`,outputting:`Outputting...`,retrying:`Connection unstable, retrying ({attempt}/{max})...`,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:`
|
|
1571
1571
|
... (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}
|
|
1572
|
-
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 ZS=new Map,QS=!1,$S=!1,eC=!1,tC=!1;function nC(){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`),tC=!1):e.classList.add(`visible`),t&&(tC&&!r?(t.classList.add(`active`),N.isGenerating?t.classList.add(`pulsing`):t.classList.remove(`pulsing`)):t.classList.remove(`active`,`pulsing`))}function rC(){if(eC)return;let e=document.getElementById(`chatContainer`);e&&(eC=!0,e.addEventListener(`scroll`,()=>{if(QS)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<80;$S=!t,t?tC=!1:N.isGenerating&&(tC=!0),nC()},{passive:!0}),document.addEventListener(`generating-state-changed`,()=>{N.isGenerating&&(tC=!0),requestAnimationFrame(()=>nC())}))}function iC(e,t={}){if(!e)return;rC();let{force:n=!1,smooth:r=!1}=t;if(!n&&$S){tC=!0,nC();return}if(QS=!0,r){e.scrollTo({top:e.scrollHeight,behavior:`smooth`}),requestAnimationFrame(()=>{QS=!1});return}e.scrollTop=e.scrollHeight,requestAnimationFrame(()=>{$S||(e.scrollTop=e.scrollHeight),requestAnimationFrame(()=>{QS=!1})})}function aC(e){if(!e||!e.isConnected)return;let t=document.getElementById(`chatContainer`);t&&iC(t)}function oC(){$S=!1,tC=!1,N.isGenerating&&(tC=!0),nC()}function sC(){rC();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&&($S=!1,tC=!1,nC(),iC(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),nC()}function cC(){rC();let e=document.getElementById(`chatContainer`);e&&(e.scrollHeight-e.scrollTop-e.clientHeight<80||(tC=!0),nC())}function lC(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 uC(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=Rt(t?JSON.parse(t):[]);r&&Ot(r,n)}catch{}return}n&&n.dataset.filter?lC(r,r.dataset.activeFilter===n.dataset.filter?`all`:n.dataset.filter):r.classList.toggle(`collapsed`)}});let n=e.closest(`.thinking-process`);n&&lC(n,n.dataset.activeFilter||`all`)}async function dC(){try{let{getAllAgents:e}=await M(async()=>{let{getAllAgents:e}=await import(`./agent-store-
|
|
1572
|
+
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 ZS=new Map,QS=!1,$S=!1,eC=!1,tC=!1;function nC(){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`),tC=!1):e.classList.add(`visible`),t&&(tC&&!r?(t.classList.add(`active`),N.isGenerating?t.classList.add(`pulsing`):t.classList.remove(`pulsing`)):t.classList.remove(`active`,`pulsing`))}function rC(){if(eC)return;let e=document.getElementById(`chatContainer`);e&&(eC=!0,e.addEventListener(`scroll`,()=>{if(QS)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<80;$S=!t,t?tC=!1:N.isGenerating&&(tC=!0),nC()},{passive:!0}),document.addEventListener(`generating-state-changed`,()=>{N.isGenerating&&(tC=!0),requestAnimationFrame(()=>nC())}))}function iC(e,t={}){if(!e)return;rC();let{force:n=!1,smooth:r=!1}=t;if(!n&&$S){tC=!0,nC();return}if(QS=!0,r){e.scrollTo({top:e.scrollHeight,behavior:`smooth`}),requestAnimationFrame(()=>{QS=!1});return}e.scrollTop=e.scrollHeight,requestAnimationFrame(()=>{$S||(e.scrollTop=e.scrollHeight),requestAnimationFrame(()=>{QS=!1})})}function aC(e){if(!e||!e.isConnected)return;let t=document.getElementById(`chatContainer`);t&&iC(t)}function oC(){$S=!1,tC=!1,N.isGenerating&&(tC=!0),nC()}function sC(){rC();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&&($S=!1,tC=!1,nC(),iC(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),nC()}function cC(){rC();let e=document.getElementById(`chatContainer`);e&&(e.scrollHeight-e.scrollTop-e.clientHeight<80||(tC=!0),nC())}function lC(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 uC(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=Rt(t?JSON.parse(t):[]);r&&Ot(r,n)}catch{}return}n&&n.dataset.filter?lC(r,r.dataset.activeFilter===n.dataset.filter?`all`:n.dataset.filter):r.classList.toggle(`collapsed`)}});let n=e.closest(`.thinking-process`);n&&lC(n,n.dataset.activeFilter||`all`)}async function dC(){try{let{getAllAgents:e}=await M(async()=>{let{getAllAgents:e}=await import(`./agent-store-CuK2pMqc.js`).then(e=>e.t);return{getAllAgents:e}},__vite__mapDeps([0,1,2,3,4])),t=await e();ZS.clear();for(let e of t)ZS.set(e.id,e.name||e.id)}catch{}}function fC(e){return ZS.get(e)||e}var pC=new Map,mC=new Map,hC=null,gC=0,_C=0,vC=``;function yC(e){return t=>t===void 0?pC.get(e)||null:(pC.set(e,t),t)}function bC(e){pC.delete(e),mC.delete(e),YS(e)}function xC(e){return mC.get(e)||``}function SC(e,t){if(mC.set(e,t),!t){KS(e);return}PC(pC.get(e))}function CC(){return hC}function wC(e){hC=e}function TC(){return gC}function EC(e){gC=e}function DC(){return _C}function OC(e){_C=e}function kC(){return vC}function AC(e){vC=e}function jC(){return`
|
|
1573
1573
|
<svg class="thinking-icon pulse-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1574
1574
|
<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"/>
|
|
1575
1575
|
<circle cx="8" cy="12" r="1.5"/>
|
|
@@ -1726,7 +1726,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1726
1726
|
<svg class="thinking-process-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
1727
1727
|
<polyline points="6 9 12 15 18 9"/>
|
|
1728
1728
|
</svg>
|
|
1729
|
-
`,d){let e=p.querySelector(`.token-stat`);e&&(e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Ot(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=Jt(e));let n=c.querySelector(`.thinking-indicator`);n&&n.remove(),c.appendChild(f),c.appendChild(t),uC(p)}else{let t=c.querySelector(`.thinking-indicator`);t&&t.remove(),e&&e.trim()&&(l.innerHTML=Jt(e))}}else e&&e.trim()&&(l.innerHTML=Jt(e))}e.classList.add(`assistant`,`message`),e.dataset.rawContent=typeof t==`string`?rn(t):JSON.stringify(t),e.dataset.textContent_=rn(ew(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(),vS(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(),ES(e)}),f.appendChild(m),f.appendChild(Qx());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-BSv2Jn2H.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([10,11,1,4,12,2,3,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-BSv2Jn2H.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([10,11,1,4,12,2,3,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-BSv2Jn2H.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([10,11,1,4,12,2,3,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-BSv2Jn2H.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([10,11,1,4,12,2,3,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=Rt(n);if(w){let e=document.createElement(`span`);e.className=`token-usage-tag`,e.title=r(`chatStream.tokenUsageTitle`,{total:F(w.totalTokens),prompt:F(w.promptTokens),completion:F(w.completionTokens)}),e.innerHTML=`<span class="token-tag-icon">⬤</span><span class="token-tag-value">${F(w.totalTokens)}</span>`,e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Ot(w,e)}),C.appendChild(e)}let T=vb(t),E=xb(n,t);if(T.length&&(e.dataset.declaredArtifacts=JSON.stringify(T)),zb(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=`
|
|
1729
|
+
`,d){let e=p.querySelector(`.token-stat`);e&&(e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Ot(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=Jt(e));let n=c.querySelector(`.thinking-indicator`);n&&n.remove(),c.appendChild(f),c.appendChild(t),uC(p)}else{let t=c.querySelector(`.thinking-indicator`);t&&t.remove(),e&&e.trim()&&(l.innerHTML=Jt(e))}}else e&&e.trim()&&(l.innerHTML=Jt(e))}e.classList.add(`assistant`,`message`),e.dataset.rawContent=typeof t==`string`?rn(t):JSON.stringify(t),e.dataset.textContent_=rn(ew(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(),vS(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(),ES(e)}),f.appendChild(m),f.appendChild(Qx());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-BjO4Cgaj.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([10,11,1,4,12,2,3,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-BjO4Cgaj.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([10,11,1,4,12,2,3,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-BjO4Cgaj.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([10,11,1,4,12,2,3,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-BjO4Cgaj.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([10,11,1,4,12,2,3,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=Rt(n);if(w){let e=document.createElement(`span`);e.className=`token-usage-tag`,e.title=r(`chatStream.tokenUsageTitle`,{total:F(w.totalTokens),prompt:F(w.promptTokens),completion:F(w.completionTokens)}),e.innerHTML=`<span class="token-tag-icon">⬤</span><span class="token-tag-value">${F(w.totalTokens)}</span>`,e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Ot(w,e)}),C.appendChild(e)}let T=vb(t),E=xb(n,t);if(T.length&&(e.dataset.declaredArtifacts=JSON.stringify(T)),zb(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=`
|
|
1730
1730
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="14" height="14">
|
|
1731
1731
|
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
|
|
1732
1732
|
<polyline points="14 2 14 8 20 8"/>
|
|
@@ -1752,7 +1752,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1752
1752
|
点击查看评估详情`,reflectionFailedTitle:`反思评估失败(点击查看执行日志)`,reflectionFailedBadge:`⚠️ 反思失败`,prototypeLocalOpened:`已在本地浏览器打开,点击可在面板内查看`,prototypeView:`查看 UI 原型`,bookmarkMessage:`收藏消息`,unbookmarkMessage:`取消收藏`,forkSession:`从此处分叉会话(仅复制到此条消息)`,deleteMessageTitle:`删除消息`,resumeTaskTitle:`从上次中断处继续执行任务`,resumeTaskTitleBudget:`执行预算已用完(部分完成):点击后可在新的预算下接着未完成的部分继续`,resumeTaskBtn:`继续执行`,clickToEnlarge:`点击查看大图`,fileExtracting:` 提取中...`,fileFailed:` 失败`,fileExtractFailed:`提取失败`,copyMessageTitle:`复制消息内容`,editAndResend:`编辑后重新发送`,thinking:`思考中...`,stopTask:`停止任务`,viewExecutionLog:`查看执行日志`,preparing:`准备中...`,emptyModelReply:`模型未返回任何内容。若你发送了图片,请确认所选模型支持视觉识别(图片识别需选择支持多模态视觉的模型),或更换模型后重试。`,stopping:`停止中...`,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}
|
|
1753
1753
|
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`,resumeTaskTitleBudget:`Execution budget exhausted (partially complete): click to continue the unfinished parts with a fresh budget`,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...`,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 ZC=`pendingCallApiSessions`;function QC(){chrome.storage.session.set({[ZC]:[...N.pendingCallApiSessionIds]}).catch(()=>{})}async function $C(){try{let e=await chrome.storage.session.get([ZC]);e[ZC]&&Array.isArray(e[ZC])&&(N.pendingCallApiSessionIds=new Set(e[ZC]))}catch{}}function ew(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 tw(e){let t=ew(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 nw(){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 rw(){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(`
|
|
1754
1754
|
`),n=e.findIndex(e=>e.startsWith(`[用户问题]`));n===-1?t.value=``:t.value=e.slice(n+1).join(`
|
|
1755
|
-
`).trim()}}var iw,aw=new Promise(e=>{iw=e});function ow(){N.activeSessionId&&document.dispatchEvent(new CustomEvent(`session-hydrated`,{detail:{sessionId:N.activeSessionId,workdir:N.sessionWorkdir||null}}))}async function sw(){try{await cw()}finally{iw(),document.dispatchEvent(new CustomEvent(`chat-history-rendered`,{detail:{sessionId:N.activeSessionId||null}}))}}async function cw(){let e=await Fi();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,Li(t),ow(),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-
|
|
1755
|
+
`).trim()}}var iw,aw=new Promise(e=>{iw=e});function ow(){N.activeSessionId&&document.dispatchEvent(new CustomEvent(`session-hydrated`,{detail:{sessionId:N.activeSessionId,workdir:N.sessionWorkdir||null}}))}async function sw(){try{await cw()}finally{iw(),document.dispatchEvent(new CustomEvent(`chat-history-rendered`,{detail:{sessionId:N.activeSessionId||null}}))}}async function cw(){let e=await Fi();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,Li(t),ow(),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-CuK2pMqc.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} (${qm(e.size||0)})`;break;case`knowledge`:{let t=Array.isArray(e.refs)?e.refs:[];t.length>0&&gw(t,e.failed===!0);break}}t&&e.type!==`file`&&Fw(e.type,t,!1)}),e.htmlContent)Jw(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||``}));zw(e.role,e.content,!1,e.executionLog||[],e.reflectionScore,t,null,e.messageId,n,e.resumable,e.timestamp??null)}}),Hw(),Ww(),qt();let i=document.querySelector(`.welcome-message`);i&&N.messageHistory.length>0&&i.remove(),$t(),sn(),mD(),e.activeSessionId===N.activeSessionId?es(e):es(),await NS();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 zi();let e=await Fi();e.activeSessionId&&(N.activeSessionId=e.activeSessionId,N.sessions=e.list,Li(e.list.find(t=>t.id===e.activeSessionId)),ow()),es(e)}}function lw(){try{Ii().catch(e=>{a.error(`[SidePanel] save currentsession failed:`,e)})}catch(e){a.error(`[SidePanel] save conversationhistory exception:`,e)}}async function uw(){try{await Ii()}catch(e){a.error(`[SidePanel] save conversationhistory exception:`,e)}}function dw(){N.messageHistory&&N.messageHistory.length>0&&Wi().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=`
|
|
1756
1756
|
<div class="icon-wrapper">
|
|
1757
1757
|
<div class="icon">💬</div>
|
|
1758
1758
|
</div>
|
|
@@ -1776,7 +1776,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1776
1776
|
</div>
|
|
1777
1777
|
<div class="context-bubble-content">${l}</div>
|
|
1778
1778
|
</div>
|
|
1779
|
-
`;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 Iw(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 Lw(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}var Rw=e=>!!e&&e.dataset.resumable===`budget`;function zw(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=e===`user`?de(_):_,y=Array.isArray(t)&&t.some(e=>e.type===`image_url`);m.dataset.rawContent=Array.isArray(t)?JSON.stringify(t):rn(t),m.dataset.textContent_=rn(e===`user`?de(c||v):c||v);let b=v;if(m.dataset.executionLog=JSON.stringify(i),s&&(m.dataset.wasRevised=`true`),e===`assistant`){m.innerHTML=Jt(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(),vS(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(),ES(m)}),e.appendChild(c),e.appendChild(Qx());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-BSv2Jn2H.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([10,11,1,4,12,2,3,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-BSv2Jn2H.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([10,11,1,4,12,2,3,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-BSv2Jn2H.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([10,11,1,4,12,2,3,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-BSv2Jn2H.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([10,11,1,4,12,2,3,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=Rt(i);if(x){let e=document.createElement(`span`);e.className=`token-usage-tag`,e.title=r(`chatStream.tokenUsageTitle`,{total:F(x.totalTokens),prompt:F(x.promptTokens),completion:F(x.completionTokens)}),e.innerHTML=`<span class="token-tag-icon">⬤</span><span class="token-tag-value">${F(x.totalTokens)}</span>`,e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Ot(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;Hw(),Ww(),qt();let T=i?.find(e=>e.nodeType===`reflection`&&e.reflectionType===`post`),E=vb(t),D=xb(i,t);if(E.length&&(m.dataset.declaredArtifacts=JSON.stringify(E)),zb(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=`
|
|
1779
|
+
`;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 Iw(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 Lw(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}var Rw=e=>!!e&&e.dataset.resumable===`budget`;function zw(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=e===`user`?de(_):_,y=Array.isArray(t)&&t.some(e=>e.type===`image_url`);m.dataset.rawContent=Array.isArray(t)?JSON.stringify(t):rn(t),m.dataset.textContent_=rn(e===`user`?de(c||v):c||v);let b=v;if(m.dataset.executionLog=JSON.stringify(i),s&&(m.dataset.wasRevised=`true`),e===`assistant`){m.innerHTML=Jt(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(),vS(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(),ES(m)}),e.appendChild(c),e.appendChild(Qx());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-BjO4Cgaj.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([10,11,1,4,12,2,3,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-BjO4Cgaj.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([10,11,1,4,12,2,3,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-BjO4Cgaj.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([10,11,1,4,12,2,3,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-BjO4Cgaj.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([10,11,1,4,12,2,3,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=Rt(i);if(x){let e=document.createElement(`span`);e.className=`token-usage-tag`,e.title=r(`chatStream.tokenUsageTitle`,{total:F(x.totalTokens),prompt:F(x.promptTokens),completion:F(x.completionTokens)}),e.innerHTML=`<span class="token-tag-icon">⬤</span><span class="token-tag-value">${F(x.totalTokens)}</span>`,e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Ot(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;Hw(),Ww(),qt();let T=i?.find(e=>e.nodeType===`reflection`&&e.reflectionType===`post`),E=vb(t),D=xb(i,t);if(E.length&&(m.dataset.declaredArtifacts=JSON.stringify(E)),zb(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=`
|
|
1780
1780
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="14" height="14">
|
|
1781
1781
|
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
|
|
1782
1782
|
<polyline points="14 2 14 8 20 8"/>
|
|
@@ -1839,11 +1839,11 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1839
1839
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
1840
1840
|
<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"/>
|
|
1841
1841
|
</svg>
|
|
1842
|
-
</button>`,e.parentElement.insertBefore(t,e),t.appendChild(e)}),s.querySelectorAll(`.subtask-progress`).forEach(e=>{Ew(e)}),s.querySelectorAll(`.tool-call-terminate-btn, .agent-stream-terminate-btn`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation(),Xw(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(),vS(s,e,t)});let t=l.querySelector(`.quote-btn`);t&&t.addEventListener(`click`,e=>{e.stopPropagation(),ES(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-
|
|
1842
|
+
</button>`,e.parentElement.insertBefore(t,e),t.appendChild(e)}),s.querySelectorAll(`.subtask-progress`).forEach(e=>{Ew(e)}),s.querySelectorAll(`.tool-call-terminate-btn, .agent-stream-terminate-btn`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation(),Xw(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(),vS(s,e,t)});let t=l.querySelector(`.quote-btn`);t&&t.addEventListener(`click`,e=>{e.stopPropagation(),ES(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-BjO4Cgaj.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([10,11,1,4,12,2,3,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-BjO4Cgaj.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([10,11,1,4,12,2,3,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-BjO4Cgaj.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([10,11,1,4,12,2,3,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-BjO4Cgaj.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([10,11,1,4,12,2,3,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?il(t):a.error(`[SidePanel] not found prototypeId,entry keys:`,Object.keys(e),`observation:`,e.observation)})}let o=l.querySelector(`.bookmark-btn`);o&&(Dh(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 hh(t,n),Dh(o,t,n);let{refreshBookmarkPanel:e}=await M(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>yh);return{refreshBookmarkPanel:e}},void 0);e()}else{await mh(t,n,s.dataset.textContent_||``,N.sessions.find(e=>e.id===t)?.title||``),Dh(o,t,n);let{refreshBookmarkPanel:e}=await M(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>yh);return{refreshBookmarkPanel:e}},void 0);e()}}));let c=l.querySelector(`.delete-btn`);c&&c.addEventListener(`click`,e=>{e.stopPropagation(),Qw(s)});let u=l.querySelector(`.fork-btn`);u&&u.addEventListener(`click`,async e=>{e.stopPropagation();let t=s.dataset.messageId;t&&await jc(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 kS({budgetEnded:Rw(s)});t!==null&&(d.disabled=!0,d.style.opacity=`0.6`,d.style.cursor=`not-allowed`,PS(N.activeSessionId,t).finally(()=>{d.disabled=!1,d.style.opacity=``,d.style.cursor=``}))}),qw(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=Rt(e?JSON.parse(e):[]);t&&Ot(t,f)}catch{}}))}let u=s.querySelector(`.message-toolbar`);if(u){let e=u.querySelector(`.edit-btn`);e&&e.addEventListener(`click`,e=>{e.stopPropagation(),tT(s)});let t=u.querySelector(`.copy-btn`);t&&t.addEventListener(`click`,e=>{e.stopPropagation(),_S(s,t)});let n=u.querySelector(`.delete-btn`);n&&n.addEventListener(`click`,e=>{e.stopPropagation(),Qw(s)})}s.querySelectorAll(`.user-message-image`).forEach(e=>{e.addEventListener(`click`,()=>{fm(e.src,e)})}),i.appendChild(s),mD()}function Yw(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`)}">
|
|
1843
1843
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
1844
1844
|
<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"/>
|
|
1845
1845
|
</svg>
|
|
1846
|
-
</button>`,e.parentElement.insertBefore(t,e),t.appendChild(e)}),e.querySelectorAll(`.thinking-process-header`).forEach(e=>{uC(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=>{Ew(e)}),e.querySelectorAll(`.tool-call-terminate-btn, .agent-stream-terminate-btn`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation(),Xw(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(),vS(t,n,e)});let r=e.querySelector(`.quote-btn`);r&&r.addEventListener(`click`,e=>{e.stopPropagation(),ES(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-
|
|
1846
|
+
</button>`,e.parentElement.insertBefore(t,e),t.appendChild(e)}),e.querySelectorAll(`.thinking-process-header`).forEach(e=>{uC(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=>{Ew(e)}),e.querySelectorAll(`.tool-call-terminate-btn, .agent-stream-terminate-btn`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation(),Xw(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(),vS(t,n,e)});let r=e.querySelector(`.quote-btn`);r&&r.addEventListener(`click`,e=>{e.stopPropagation(),ES(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-BjO4Cgaj.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([10,11,1,4,12,2,3,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-BjO4Cgaj.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([10,11,1,4,12,2,3,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-BjO4Cgaj.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([10,11,1,4,12,2,3,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-BjO4Cgaj.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([10,11,1,4,12,2,3,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&&il(t)})}let s=e.querySelector(`.bookmark-btn`);s&&(Dh(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 hh(n,r),Dh(s,n,r);let{refreshBookmarkPanel:e}=await M(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>yh);return{refreshBookmarkPanel:e}},void 0);e()}else{await mh(n,r,t.dataset.textContent_||``,N.sessions.find(e=>e.id===n)?.title||``),Dh(s,n,r);let{refreshBookmarkPanel:e}=await M(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>yh);return{refreshBookmarkPanel:e}},void 0);e()}}));let c=e.querySelector(`.delete-btn`);c&&c.addEventListener(`click`,e=>{e.stopPropagation(),Qw(t)});let l=e.querySelector(`.fork-btn`);l&&l.addEventListener(`click`,async e=>{e.stopPropagation();let n=t.dataset.messageId;n&&await jc(N.activeSessionId,n)});let u=e.querySelector(`.resume-task-btn`);u&&u.addEventListener(`click`,async e=>{if(e.stopPropagation(),u.disabled)return;let n=await kS({budgetEnded:Rw(t)});n!==null&&(u.disabled=!0,u.style.opacity=`0.6`,u.style.cursor=`not-allowed`,PS(N.activeSessionId,n).finally(()=>{u.disabled=!1,u.style.opacity=``,u.style.cursor=``}))}),qw(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=Rt(e?JSON.parse(e):[]);n&&Ot(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(),tT(t)});let r=e.querySelector(`.copy-btn`);r&&r.addEventListener(`click`,e=>{e.stopPropagation(),_S(t,r)});let i=e.querySelector(`.delete-btn`);i&&i.addEventListener(`click`,e=>{e.stopPropagation(),Qw(t)})}),e.querySelectorAll(`.user-message-image`).forEach(e=>{e.addEventListener(`click`,()=>{fm(e.src,e)})}),e.querySelectorAll(`.mermaid-controls`).forEach(e=>e.remove()),an(),Hw(),Ww(),mD()}function Xw(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=`
|
|
1847
1847
|
<div class="command-terminate-modal">
|
|
1848
1848
|
<div class="command-terminate-header">
|
|
1849
1849
|
<div class="command-terminate-icon">⏹</div>
|
|
@@ -2729,7 +2729,7 @@ Agent address: {url}
|
|
|
2729
2729
|
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}
|
|
2730
2730
|
Agent address: {url}
|
|
2731
2731
|
|
|
2732
|
-
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,VL(),a.debug(`[SidePanel] auto-compaction config updated:`,N.chatConfig.autoCompaction)),t===`local`&&e.chatPersistSummaryToMemory&&(N.chatConfig.persistSummaryToMemory=e.chatPersistSummaryToMemory.newValue!==!1,HL(),a.debug(`[SidePanel] persist-summary config updated:`,N.chatConfig.persistSummaryToMemory)),t===`local`&&e.chatMaxMemoryMessages&&(N.chatConfig.maxMemoryMessages=e.chatMaxMemoryMessages.newValue,BL(),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 BL(){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 VL(){let e=document.getElementById(`autoCompactBtn`);e&&(e.checked=N.chatConfig.autoCompaction===!0)}function HL(){let e=document.getElementById(`persistSummaryBtn`);e&&(e.checked=N.chatConfig.persistSummaryToMemory!==!1)}function UL(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 WL(){let e=document.getElementById(`memoryLimitDropdown`),t=document.getElementById(`memoryLimitLabel`),n=e?.querySelector(`#memoryLimitInput`);if(!e||!t)return;BL(),t.addEventListener(`click`,UL);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,L(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,L(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,BL(),L(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,BL(),L(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 GL(e){if(N.activeAgentId&&N.activeAgentId!=="default")try{let{updateAgent:t}=await M(async()=>{let{updateAgent:e}=await import(`./agent-store-sKnc7YcJ.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}),A(e)}async function KL(){try{let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),t=zL(e.pairedAgents),n=e.activeAgentId,r=t.find(e=>e.id===n&&!e.disabled);if(!r){N.agentPlatform={connected:!1},uR(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=mR(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};uR(N.agentPlatform),jh()}catch{}}async function qL(e,t,n){if(N.activeAgentId&&N.activeAgentId!=="default")try{let{updateAgent:n}=await M(async()=>{let{updateAgent:e}=await import(`./agent-store-sKnc7YcJ.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 JL(){let e=document.getElementById(`currentModelTag`);if(!e)return;let t=N.currentModel||``;e.textContent=t,e.title=t,e.style.display=t?``:`none`}var YL=new Set,XL=0;function ZL(){let e=document.getElementById(`workdirTag`);e&&(e.dataset.locked=Oh(N.activeSessionId)?`true`:`false`)}async function QL(){let e=++XL,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 fe(i)}catch(e){a.debug(`[WorkdirTag] resolve failed:`,e&&e.message)}if(e!==XL)return;let c=s&&s.workdir||``;if(!c){t.style.display=`none`;return}t.style.display=``,n.textContent=ae(c,{homeDir:N.agentPlatform?.homeDir||``}),ZL();try{let{getWorkspaceRoot:e}=await M(async()=>{let{getWorkspaceRoot:e}=await import(`./workspace-manager-CTFkcx87.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`,iL(i).then(e=>{e&&QL()}).catch(e=>a.debug(`[WorkdirTag] reconcile failed:`,e&&e.message))):t.dataset.invalid=r?`true`:`false`}catch{t.dataset.invalid=`false`}if(e===XL&&(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||``}`;YL.has(e)||(YL.add(e),L(r(`workdirTag.agentSwitched`),`warning`))}}function $L(){let e=document.getElementById(`workdirTag`);e&&(e.setAttribute(`aria-label`,r(`workdirTag.tagHint`)),e.addEventListener(`click`,async e=>{if(e.stopPropagation(),Oh(N.activeSessionId)){ZL(),L(r(`workdirTag.lockedHint`),`warning`);return}ZL();let{showSwitchWorkdirDialog:t}=await M(async()=>{let{showSwitchWorkdirDialog:e}=await Promise.resolve().then(()=>Lh);return{showSwitchWorkdirDialog:e}},void 0);await t({sessionId:N.activeSessionId||null})})),QL(),document.addEventListener(`session-switched`,()=>{QL()}),document.addEventListener(`session-workdir-changed`,()=>{QL()}),document.addEventListener(`agent-model-changed`,()=>{QL()}),document.addEventListener(`agent-tools-changed`,()=>{QL()}),document.addEventListener(`generating-state-changed`,()=>{ZL()}),document.addEventListener(`generation-ended`,()=>{ZL()}),Hr(()=>{ZL()})}function eR(){let e=document.getElementById(`currentModelTag`);e&&e.addEventListener(`click`,e=>{e.stopPropagation(),document.getElementById(`tempDisplay`)?.click()}),JL()}function tR(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=E(t),r.style.display=``):r.style.display=`none`),JL()}function nR(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=`
|
|
2732
|
+
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,VL(),a.debug(`[SidePanel] auto-compaction config updated:`,N.chatConfig.autoCompaction)),t===`local`&&e.chatPersistSummaryToMemory&&(N.chatConfig.persistSummaryToMemory=e.chatPersistSummaryToMemory.newValue!==!1,HL(),a.debug(`[SidePanel] persist-summary config updated:`,N.chatConfig.persistSummaryToMemory)),t===`local`&&e.chatMaxMemoryMessages&&(N.chatConfig.maxMemoryMessages=e.chatMaxMemoryMessages.newValue,BL(),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 BL(){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 VL(){let e=document.getElementById(`autoCompactBtn`);e&&(e.checked=N.chatConfig.autoCompaction===!0)}function HL(){let e=document.getElementById(`persistSummaryBtn`);e&&(e.checked=N.chatConfig.persistSummaryToMemory!==!1)}function UL(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 WL(){let e=document.getElementById(`memoryLimitDropdown`),t=document.getElementById(`memoryLimitLabel`),n=e?.querySelector(`#memoryLimitInput`);if(!e||!t)return;BL(),t.addEventListener(`click`,UL);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,L(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,L(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,BL(),L(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,BL(),L(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 GL(e){if(N.activeAgentId&&N.activeAgentId!=="default")try{let{updateAgent:t}=await M(async()=>{let{updateAgent:e}=await import(`./agent-store-CuK2pMqc.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}),A(e)}async function KL(){try{let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),t=zL(e.pairedAgents),n=e.activeAgentId,r=t.find(e=>e.id===n&&!e.disabled);if(!r){N.agentPlatform={connected:!1},uR(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=mR(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};uR(N.agentPlatform),jh()}catch{}}async function qL(e,t,n){if(N.activeAgentId&&N.activeAgentId!=="default")try{let{updateAgent:n}=await M(async()=>{let{updateAgent:e}=await import(`./agent-store-CuK2pMqc.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 JL(){let e=document.getElementById(`currentModelTag`);if(!e)return;let t=N.currentModel||``;e.textContent=t,e.title=t,e.style.display=t?``:`none`}var YL=new Set,XL=0;function ZL(){let e=document.getElementById(`workdirTag`);e&&(e.dataset.locked=Oh(N.activeSessionId)?`true`:`false`)}async function QL(){let e=++XL,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 fe(i)}catch(e){a.debug(`[WorkdirTag] resolve failed:`,e&&e.message)}if(e!==XL)return;let c=s&&s.workdir||``;if(!c){t.style.display=`none`;return}t.style.display=``,n.textContent=ae(c,{homeDir:N.agentPlatform?.homeDir||``}),ZL();try{let{getWorkspaceRoot:e}=await M(async()=>{let{getWorkspaceRoot:e}=await import(`./workspace-manager-C4IYPHx6.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`,iL(i).then(e=>{e&&QL()}).catch(e=>a.debug(`[WorkdirTag] reconcile failed:`,e&&e.message))):t.dataset.invalid=r?`true`:`false`}catch{t.dataset.invalid=`false`}if(e===XL&&(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||``}`;YL.has(e)||(YL.add(e),L(r(`workdirTag.agentSwitched`),`warning`))}}function $L(){let e=document.getElementById(`workdirTag`);e&&(e.setAttribute(`aria-label`,r(`workdirTag.tagHint`)),e.addEventListener(`click`,async e=>{if(e.stopPropagation(),Oh(N.activeSessionId)){ZL(),L(r(`workdirTag.lockedHint`),`warning`);return}ZL();let{showSwitchWorkdirDialog:t}=await M(async()=>{let{showSwitchWorkdirDialog:e}=await Promise.resolve().then(()=>Lh);return{showSwitchWorkdirDialog:e}},void 0);await t({sessionId:N.activeSessionId||null})})),QL(),document.addEventListener(`session-switched`,()=>{QL()}),document.addEventListener(`session-workdir-changed`,()=>{QL()}),document.addEventListener(`agent-model-changed`,()=>{QL()}),document.addEventListener(`agent-tools-changed`,()=>{QL()}),document.addEventListener(`generating-state-changed`,()=>{ZL()}),document.addEventListener(`generation-ended`,()=>{ZL()}),Hr(()=>{ZL()})}function eR(){let e=document.getElementById(`currentModelTag`);e&&e.addEventListener(`click`,e=>{e.stopPropagation(),document.getElementById(`tempDisplay`)?.click()}),JL()}function tR(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=E(t),r.style.display=``):r.style.display=`none`),JL()}function nR(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=`
|
|
2733
2733
|
<div class="model-section-title" data-i18n="model.selectModel">${r(`model.selectModel`)}</div>
|
|
2734
2734
|
<div class="section-select" id="modelSelect">
|
|
2735
2735
|
<div class="section-select-row" id="modelSelectRow">
|
|
@@ -2804,7 +2804,7 @@ Are you sure you want to stop the agent service? You will not be able to connect
|
|
|
2804
2804
|
<span class="audit-action">${P(e.action||`-`)}</span>
|
|
2805
2805
|
</div>
|
|
2806
2806
|
${a?`<div class="audit-details">${a}</div>`:``}
|
|
2807
|
-
</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()}),RL(()=>N.activeSessionId,window.showCustomConfirm);let Ze=document.getElementById(`isolateChatBtn`),Qe=document.getElementById(`enableToolsBtn`),$e=document.getElementById(`toolsConfigBtn`),et=`agentEnabledTools_${N.activeAgentId||`default`}`,tt=`agentMcpClosedServers_${N.activeAgentId||`default`}`;chrome.storage.local.get([et,`enabledTools`,`isolateChat`,`enableSelectionQuery`,`enableTools`,tt,`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-
|
|
2807
|
+
</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()}),RL(()=>N.activeSessionId,window.showCustomConfirm);let Ze=document.getElementById(`isolateChatBtn`),Qe=document.getElementById(`enableToolsBtn`),$e=document.getElementById(`toolsConfigBtn`),et=`agentEnabledTools_${N.activeAgentId||`default`}`,tt=`agentMcpClosedServers_${N.activeAgentId||`default`}`;chrome.storage.local.get([et,`enabledTools`,`isolateChat`,`enableSelectionQuery`,`enableTools`,tt,`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-CuK2pMqc.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,Ma()}).catch(()=>{}),N.mcpClosedServers=e[tt]||[];let n=e.ragTools||[],r=e[et],i=e.enabledTools;if(Array.isArray(r)){let t=Fa(n);N.enabledTools=r.filter(e=>t.has(e));let i=Pa(N.enabledTools,n,e.ragToolsIntroduced);N.enabledTools=i.tools,i.migrated?chrome.storage.local.set({ragToolsIntroduced:!0,[et]:N.enabledTools}):N.enabledTools.length!==r.length&&chrome.storage.local.set({[et]:N.enabledTools})}else if(i&&i.length>0){let t=Fa(n),r=i.filter(e=>t.has(e)),a=x.filter(e=>e.enabled&&!r.includes(e.id)).map(e=>e.id);N.enabledTools=[...r,...a];let o=Pa(N.enabledTools,n,e.ragToolsIntroduced);N.enabledTools=o.tools,chrome.storage.local.set({[et]:N.enabledTools,...o.migrated?{ragToolsIntroduced:!0}:{}})}else{N.enabledTools=x.filter(e=>e.enabled).map(e=>e.id);let t=Pa(N.enabledTools,n,e.ragToolsIntroduced);N.enabledTools=t.tools,t.migrated&&chrome.storage.local.set({ragToolsIntroduced:!0,[et]:N.enabledTools})}Qe&&(Qe.checked=N.useTools),Ma(),QL(),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 nt=document.getElementById(`enableSelectionQueryBtn`);nt&&nt.addEventListener(`change`,()=>{N.enableSelectionQuery=nt.checked,chrome.storage.local.set({enableSelectionQuery:N.enableSelectionQuery}),a.debug(`[SidePanel] text Q&A:`,N.enableSelectionQuery?`enabled`:`disabled`),!N.enableSelectionQuery&&N.selectedContextText&&rw()}),Qe&&Qe.addEventListener(`change`,()=>{N.useTools=Qe.checked,chrome.storage.local.set({enableTools:N.useTools}),a.debug(`[SidePanel] tool master switch:`,N.useTools?`enabled`:`disabled`),Ma()}),$e&&$e.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),va()});let rt=document.getElementById(`toolsPopupOverlay`),it=document.getElementById(`toolsPopupClose`),at=rt?rt.querySelector(`.modal-container`):null;it&&it.addEventListener(`click`,ya),at&&at.addEventListener(`click`,e=>{e.stopPropagation()});let ot=document.getElementById(`toolsSearchInput`),st=document.getElementById(`toolsSearchClear`);ot&&ot.addEventListener(`input`,e=>{N.currentSearch=e.target.value.toLowerCase(),st&&(st.style.display=e.target.value?``:`none`),ba()}),st&&st.addEventListener(`click`,()=>{ot&&(ot.value=``,st.style.display=`none`,N.currentSearch=``,ba())});let ct=document.querySelectorAll(`.category-btn`);ct.forEach(e=>{e.addEventListener(`click`,()=>{ct.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,ba()})});let lt=document.getElementById(`toolsCategories`);lt&<.addEventListener(`wheel`,e=>{e.preventDefault(),lt.scrollLeft+=e.deltaY*2},{passive:!1});let ft=document.getElementById(`toolsSelectAll`),pt=document.getElementById(`toolsSelectNone`);ft&&ft.addEventListener(`click`,()=>{Ea().forEach(e=>{let t=document.getElementById(`tool_`+e.id);t&&(t.checked=!0),N.enabledTools.includes(e.id)||N.enabledTools.push(e.id)}),ja(!0),Da(),Oa(),ka()}),pt&&pt.addEventListener(`click`,()=>{Ea().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)}),ja(!1),Da(),Oa(),ka()});let ht=document.getElementById(`toolsPopupSave`);ht&&ht.addEventListener(`click`,()=>{Aa(),ka()});let _t=document.getElementById(`toolsPreselectToggle`);_t&&_t.addEventListener(`change`,()=>{chrome.storage.local.set({enableToolPreselect:_t.checked},()=>{a.debug(`[SidePanel] toolpre-filter toggle updated:`,_t.checked)})});let vt=document.getElementById(`toolConfirmToggle`);vt&&vt.addEventListener(`change`,()=>{chrome.storage.local.set({toolConfirmationEnabled:vt.checked},()=>{a.debug(`[SidePanel] sensitive-operation confirmation toggle updated:`,vt.checked)})});let yt=document.getElementById(`toolsPopupCancel`);yt&&yt.addEventListener(`click`,()=>{ya()});let bt=document.getElementById(`modalCancelBtn`),xt=document.getElementById(`modalConfirmBtn`),St=document.getElementById(`toolStatsOverlay`),Ct=document.getElementById(`toolStatsClose`),wt=document.getElementById(`toolStatsBtn`);function Tt(){St&&(St.style.display=`flex`,Mt())}function Dt(){St&&(St.style.display=`none`)}wt&&wt.addEventListener(`click`,e=>{e.stopPropagation(),Tt()}),Ct&&Ct.addEventListener(`click`,Dt),St&&St.addEventListener(`click`,e=>{e.target===St&&Dt()});let Ot=document.getElementById(`toolStatsRefreshBtn`);Ot&&Ot.addEventListener(`click`,Mt);let At=document.getElementById(`toolStatsClearBtn`);At&&At.addEventListener(`click`,async()=>{await window.showCustomConfirm(r(`sidePanel.clearStatsConfirm`),r(`sidePanel.clearStatsTitle`))&&(await chrome.storage.local.remove([`toolUsageStats`]),Mt())});let jt={column:`callCount`,asc:!1};async function Mt(){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={};x.forEach(e=>{l[e.id]=e.name?`${e.name}${r(`sidePanel.toolNameDescSeparator`)}${e.description||``}`:e.description||e.id}),Nt(a,l);let u=x.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="${P(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 Nt(e,t){let n=document.getElementById(`toolStatsTableBody`);if(!n)return;let{column:r,asc:i}=jt;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=Bt(i);return`<tr>
|
|
2808
2808
|
<td style="padding: 6px 10px; border-bottom: 1px solid var(--border-subtle); color: var(--text-primary);"><code title="${P(a)}">${e}</code></td>
|
|
2809
2809
|
<td style="padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--border-subtle); color: var(--text-secondary);">${n.callCount}</td>
|
|
2810
2810
|
<td style="padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--border-subtle); color: var(--text-secondary);">${n.successCount}</td>
|