ai-helper-agent 2.8.18 → 2.8.19
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/{chat-export-CdcWutsz.js → chat-export-DRUG3mwM.js} +1 -1
- package/dist/assets/{context-indicator-O2JgFDbD.js → context-indicator-ZNMB0fDM.js} +8 -8
- package/dist/assets/options.js +1 -1
- package/dist/assets/side_panel.js +7 -7
- package/dist/assets/{version-BYHbQ47I.js → version-DbUttEL9.js} +2 -2
- package/dist/manifest.json +1 -1
- package/dist/options.html +1 -1
- package/dist/side_panel.html +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,c as t,l as n}from"./i18n-XUUSwfZZ.js";import{C as r,J as i,S as a,b as o,h as s}from"./version-
|
|
1
|
+
import{a as e,c as t,l as n}from"./i18n-XUUSwfZZ.js";import{C as r,J as i,S as a,b as o,h as s}from"./version-DbUttEL9.js";import{AlignmentType as c,BorderStyle as l,Document as u,ExternalHyperlink as d,HeadingLevel as f,ImageRun as p,LevelFormat as m,Packer as h,Paragraph as g,Table as ee,TableCell as te,TableRow as ne,TextRun as _,WidthType as v,convertInchesToTwip as y}from"./dist-BUuoW_84.js";var re=40,b=3e3,x=/^\s{0,3}(`{3,}|~{3,})/,S=/^\s{0,3}(#{1,6})[ \t]+(.*)$/,C=/^\s{0,3}=+\s*$/,w=/^\s{0,3}([-*_])(?:\s*\1){2,}\s*$/,T=/^\s*\|.*\|\s*$/,E=/^\s*(?:\d+(?:\.\d+)+[.、))]?\s*|\d+[.、))]\s*|[一二三四五六七八九十]+[、.]\s*|[((][一二三四五六七八九十\d]+[))]\s*)/,D=/[/\\:*?"<>|]/g,ie=/[\u0000-\u001f\u007f\u200b-\u200f\u2028\u2029\ufeff]/g,O=`
|
|
2
2
|
`;function ae(e){return typeof e==`string`?e.replace(/\r\n?/g,O).replace(/\n{3,}/g,`
|
|
3
3
|
|
|
4
4
|
`):``}function oe(e){return(e.length>b?e.slice(0,b):e).split(O).slice(0,re).join(O)}function se(e){return String(e).replace(/!\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/`+/g,``).replace(/(\*\*|__|\*|_|~~)/g,``).replace(/https?:\/\/\S+/gi,``).replace(/<[^>]+>/g,``)}function k(e){if(typeof e!=`string`||!e.trim())return``;let t=se(e);return t=t.replace(ie,``),t=t.replace(E,``),t=t.replace(D,`_`),t=t.replace(/\s+/g,`-`).replace(/-{2,}/g,`-`),t=t.replace(/^[-_.\s]+/,``).replace(/[-_.\s]+$/,``),t}function A(e,t=40){let n=Array.from(e);return(n.length>t?n.slice(0,t).join(``):e).replace(/[-_.,;:、,。;:\s]+$/u,``)}function ce(e){if(typeof e!=`string`||!e.trim())return``;let t=oe(e).split(O),n=[],r=``;for(let e=0;e<t.length;e++){let i=t[e],a=i.match(x);if(r){a&&a[1][0]===r&&(r=``);continue}if(a){r=a[1][0];continue}let o=i.match(S);if(o){let e=o[2].replace(/[ \t]+#+[ \t]*$/,``).trim();e&&n.push({level:o[1].length,text:e});continue}let s=t[e+1];s&&C.test(s)&&i.trim()&&!w.test(i)&&!T.test(i)&&(n.push({level:1,text:i.trim()}),e++)}return n.length===0?``:A(k((n.find(e=>e.level===1)||n[0]).text))}function le({title:e=``,kind:t,timestamp:n,ext:r}){let i=`${t}-${n}.${r}`,a=A(k(e));return a?`${a}-${i}`:i}function j(e,{kind:t,ext:n,timestamp:r=Date.now()}){return le({title:ce(e),kind:t,timestamp:r,ext:n})}e(`zh`,{chatExport:{exportFailed:`导出失败:{message}`,pdfLibNotLoaded:`PDF 库未加载,无法导出`,noContent:`没有可导出的内容`,imageLibNotLoaded:`图片库未加载,无法导出为图片`,imagePlaceholder:`[图片: {name}]`,canvasFailed:`Canvas 转 DataURL 失败:{message}`,svgLoadFailed:`SVG 图片加载失败`}}),e(`en`,{chatExport:{exportFailed:`Export failed: {message}`,pdfLibNotLoaded:`PDF library not loaded, cannot export`,noContent:`No content to export`,imageLibNotLoaded:`Image library not loaded, cannot export as image`,imagePlaceholder:`[Image: {name}]`,canvasFailed:`Canvas to DataURL failed: {message}`,svgLoadFailed:`SVG image loading failed`}});var M=new Map,N=/Mac|iPhone|iPad|iPod/i.test(typeof navigator<`u`?navigator.userAgent:``)?`Apple Color Emoji`:`Segoe UI Emoji`,P=RegExp(`(?:\\p{Regional_Indicator}{2})|(?:\\p{Emoji_Presentation}|\\p{Extended_Pictographic}\\uFE0F)(?:[\\u{1F3FB}-\\u{1F3FF}]|\\u200D(?:\\p{Emoji_Presentation}|\\p{Extended_Pictographic}\\uFE0F))*`,`gu`),F=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\uFFFE\uFFFF]/g,I=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;function L(e){return e==null||e===``?e:String(e).replace(F,``).replace(I,`�`)}var R=0;function z(){return R+=1,R}var B=new Set([`png`,`jpg`,`jpeg`,`gif`,`bmp`]);function V(e){return B.has(String(e||``).toLowerCase())}function H(e,t={}){if(!e)return[];let n=[];return String(e).split(/\r?\n/).forEach((e,r)=>{r>0&&n.push(new _({...t,break:1}));let i=0;for(let r of e.matchAll(P))r.index>i&&n.push(new _({...t,text:e.slice(i,r.index)})),n.push(new _({...t,text:r[0],font:{name:N}})),i=r.index+r[0].length;i<e.length&&n.push(new _({...t,text:e.slice(i)}))}),n}function U(e){if(!e)return[];let r=/(\*\*(.+?)\*\*|(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)|__(.+?)__|(?<!_)_(?!_)(.+?)(?<!_)_(?!_)|`([^`]+)`|\[([^\]]+)\]\(([^)]+)\)|!\[([^\]]*)\]\(([^)]+)\))/,i=[],a=e;for(;a.length>0;){let e=a.match(r);if(!e){i.push(...H(a));break}let o=e.index;o>0&&i.push(...H(a.slice(0,o)));let s=e[1];if(e[2]!==void 0)i.push(...H(e[2],{bold:!0}));else if(e[3]!==void 0)i.push(...H(e[3],{italics:!0}));else if(e[4]!==void 0)i.push(...H(e[4],{bold:!0}));else if(e[5]!==void 0)i.push(...H(e[5],{italics:!0}));else if(e[6]!==void 0)i.push(new _({text:e[6],font:`Consolas`,size:20}));else if(e[7]!==void 0)i.push(new d({children:[new _({text:e[7],style:`Hyperlink`})],link:e[8]}));else if(e[9]!==void 0){let r=e[10];if(r.startsWith(`data:`))try{let[n,a]=r.split(`,`),o=n.match(/data:(image\/(\w+))/);if(o&&a&&V(o[2])){let t=atob(a),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);let r=o[2],s=ue(n,r),c=s.width,l=s.height;if(c>567){let e=567/c;c=Math.round(c*e),l=Math.round(l*e)}i.push(new p({data:n,transformation:{width:c,height:l},type:r,altText:{id:z(),name:e[9]||`image`}}))}else i.push(new _({text:t(`chatExport.imagePlaceholder`,{name:e[9]||`image`}),italics:!0,color:`999999`}))}catch(r){n.warn(`[ChatExport] ImageRun create failed:`,r.message),i.push(new _({text:t(`chatExport.imagePlaceholder`,{name:e[9]||`image`}),italics:!0,color:`999999`}))}else i.push(new _({text:t(`chatExport.imagePlaceholder`,{name:e[9]||r}),italics:!0,color:`999999`}))}a=a.slice(o+s.length)}return i}function ue(e,t){if(t===`png`&&e.length>24){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);return{width:t.getUint32(16),height:t.getUint32(20)}}if((t===`jpeg`||t===`jpg`)&&e.length>100){let t=2;for(;t<e.length-9;)if(e[t]===255){let n=e[t+1];if(n>=192&&n<=195){let n=new DataView(e.buffer,e.byteOffset,e.byteLength);return{height:n.getUint16(t+5),width:n.getUint16(t+7)}}t+=2+(e[t+2]<<8|e[t+3])}else t++}return{width:600,height:400}}async function W(e){if(!e||!e.trim())return[new g({children:[new _({text:``})]})];let t=[],n=L(e),r=[];n=n.replace(/```(\w*)\n([\s\S]*?)```/g,(e,t,n)=>{let i=r.length;return r.push({lang:t||``,code:n.trimEnd()}),`\n\n%%CODEBLOCK_${i}%%\n\n`});let i=[];n=n.replace(/<table[\s\S]*?<\/table>/gi,e=>{let t=i.length;return i.push(e),`\n\n%%HTMLTABLE_${t}%%\n\n`});let a=[];n=n.replace(/(?:^\|.+\|\s*$\n)+^\|[\s\-:|]+\|\s*$\n(?:^\|.+\|\s*$\n?)+/gm,e=>{let t=a.length;return a.push(e),`\n\n%%MDTABLE_${t}%%\n\n`});let o=n.split(/\n{2,}/).filter(e=>e.trim());for(let e of o){let n=e.trim(),o=n.match(/^%%CODEBLOCK_(\d+)%%$/);if(o){let{lang:e,code:n}=r[parseInt(o[1])],i=e?`${e} code`:`code`;t.push(new g({children:[new _({text:i,bold:!0,font:`Consolas`,size:18})]}));let a=n.split(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/agent-store-_CfonCwg.js","assets/chunk-CMxvf4Kt.js","assets/model-profiles-C7nNtymU.js","assets/i18n-XUUSwfZZ.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-
|
|
2
|
-
import{o as e,r as t}from"./chunk-CMxvf4Kt.js";import{a as n,c as r,l as i,r as a}from"./i18n-XUUSwfZZ.js";import{$ as o,At as s,Dt as c,Et as l,H as u,Ht as d,Jt as f,Lt as p,Ot as m,Pt as h,Rt as g,S as _,St as v,U as y,Ut as b,Y as x,Yt as S,b as C,ct as w,dt as T,kt as E,lt as D,ut as O,wt as k,x as A}from"./model-profiles-C7nNtymU.js";import{A as j,B as M,C as N,D as ee,E as te,M as ne,O as re,S as ie,T as ae,a as oe,at as se,b as ce,c as le,d as ue,f as de,h as fe,j as pe,k as me,l as he,m as ge,n as _e,o as ve,ot as ye,p as be,r as xe,s as Se,t as Ce,u as we,v as Te,w as Ee,x as De,y as Oe}from"./session-store-BU0hS2_b.js";import{a as ke,n as Ae,o as je,r as Me,t as Ne}from"./voice-shortcut-Dx863RGz.js";import{A as P,B as Pe,C as Fe,D as Ie,F as Le,G as Re,H as ze,I as Be,J as F,L as Ve,O as He,P as Ue,R as I,S as We,T as Ge,U as Ke,V as qe,X as Je,Y as Ye,_ as Xe,b as Ze,d as Qe,f as $e,g as et,h as tt,i as nt,j as L,k as rt,l as it,m as at,n as ot,p as st,u as ct,v as lt,w as ut,x as dt,z as ft}from"./version-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/agent-store-_CfonCwg.js","assets/chunk-CMxvf4Kt.js","assets/model-profiles-C7nNtymU.js","assets/i18n-XUUSwfZZ.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-DRUG3mwM.js","assets/dist-BUuoW_84.js","assets/version-DbUttEL9.js","assets/voice-shortcut-Dx863RGz.js","assets/session-store-BU0hS2_b.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,l as i,r as a}from"./i18n-XUUSwfZZ.js";import{$ as o,At as s,Dt as c,Et as l,H as u,Ht as d,Jt as f,Lt as p,Ot as m,Pt as h,Rt as g,S as _,St as v,U as y,Ut as b,Y as x,Yt as S,b as C,ct as w,dt as T,kt as E,lt as D,ut as O,wt as k,x as A}from"./model-profiles-C7nNtymU.js";import{A as j,B as M,C as N,D as ee,E as te,M as ne,O as re,S as ie,T as ae,a as oe,at as se,b as ce,c as le,d as ue,f as de,h as fe,j as pe,k as me,l as he,m as ge,n as _e,o as ve,ot as ye,p as be,r as xe,s as Se,t as Ce,u as we,v as Te,w as Ee,x as De,y as Oe}from"./session-store-BU0hS2_b.js";import{a as ke,n as Ae,o as je,r as Me,t as Ne}from"./voice-shortcut-Dx863RGz.js";import{A as P,B as Pe,C as Fe,D as Ie,F as Le,G as Re,H as ze,I as Be,J as F,L as Ve,O as He,P as Ue,R as I,S as We,T as Ge,U as Ke,V as qe,X as Je,Y as Ye,_ as Xe,b as Ze,d as Qe,f as $e,g as et,h as tt,i as nt,j as L,k as rt,l as it,m as at,n as ot,p as st,u as ct,v as lt,w as ut,x as dt,z as ft}from"./version-DbUttEL9.js";import{a as pt,c as mt,i as ht,n as gt,o as _t,r as vt,s as yt}from"./agent-store-_CfonCwg.js";import{A as bt,C as xt,D as St,E as Ct,M as wt,O as Tt,S as Et,T as Dt,_ as Ot,a as kt,b as At,c as jt,d as Mt,f as Nt,g as Pt,h as Ft,i as It,k as Lt,l as Rt,m as zt,n as Bt,o as Vt,p as Ht,r as Ut,s as Wt,t as Gt,u as Kt,v as qt,w as Jt,x as Yt,y as Xt}from"./workspace-manager-DLH5XabD.js";var Zt=ne.map(e=>e.id),Qt=[...new Set([...S,`mcp`,`knowledge`])],$t=[{labelKey:`presetMode.preciseLabel`,tipKey:`presetMode.preciseTip`,temp:.2,topP:1},{labelKey:`presetMode.generalLabel`,tipKey:`presetMode.generalTip`,temp:.45,topP:.9},{labelKey:`presetMode.divergentLabel`,tipKey:`presetMode.divergentTip`,temp:.65,topP:.9},{labelKey:`presetMode.creativeLabel`,tipKey:`presetMode.creativeTip`,temp:.9,topP:.9}];n(`zh`,{contextUsage:{compactionInjection:`[上下文摘要|压缩了{count}条历史]`}}),n(`en`,{contextUsage:{compactionInjection:`[Context Summary | {count} messages compacted]`}});var en=2e3,tn=.7,nn=1e3;function rn(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 c=Array.isArray(e)?e:[],l=!1,u=-1;r&&r.summary&&r.upToMessageId&&(u=c.findIndex(e=>e.messageId===r.upToMessageId),l=u>=0);let f=c,p=c.map((e,t)=>t);n&&n>0&&c.length>n&&(f=c.slice(c.length-n),p=p.slice(c.length-n));let m=[];for(let e=0;e<f.length;e++)l&&p[e]<=u||m.push(f[e]);let g=[],_=E([o]);for(let e=m.length-1;e>=0;e--){let t=m[e],n=E([{...t,content:d(t.content)}]);if(_+n<=i)g.unshift(t),_+=n;else break}let v=null,y=m.length-g.length;if(y>0){let e=h(m.slice(0,y));e&&(v=s(e)>nn?e.substring(0,nn*4)+`
|
|
3
3
|
...[历史摘要已截断]`:e)}return{messages:[...g,o],keptHistory:g,compactionApplied:l,trimmedCount:y,historySummaryText:v}}function an(e,t){return!t||!t.summary?e:`${e}\n\n${r(`contextUsage.compactionInjection`,{count:t.compressedCount||0})}\n${t.summary}`}function on(e,t,n,r){return t?.compactionApplied&&n?.summary?e[0]={...e[0],content:an(e[0].content,n)}:n?.summary&&r?.warn(`[SidePanel] contextCompaction invalid (upToMessageId not found), ignored this send`),e}function sn({model:e,customModelMap:t=null,systemPromptText:n=``,toolCount:r=0,history:i=[],inputText:a=``,maxMemoryMessages:o=null,compaction:u=null,isolateChat:d=!0,userConfiguredWindow:f=0}={}){let m=p(e,f,t),h=m-s(n)-l-en,g=Math.floor(Math.max(h,0)*tn),_={role:`user`,content:a},v=d?u:null,y=rn(i,{isolateChat:d,maxMemoryMessages:o,compaction:v,historyBudget:g,currentMessage:_}),b=s(y.compactionApplied?an(n,v):n),x=r*200,S=E(y.keptHistory),C=a&&a.trim()?E([_]):0,w=b+x+S+C,T=c(w,m);return{usedTokens:w,contextWindow:m,ratio:m>0?w/m:0,level:T.level,breakdown:{system:b,tools:x,history:S,input:C,outputReserve:l,safetyMargin:en,selectedCount:y.keptHistory.length,totalCount:i.length,trimmedCount:y.trimmedCount,compactionApplied:y.compactionApplied,compactionInvalid:!!(v&&v.summary&&!y.compactionApplied),historyBudget:g}}}function cn(e,{maxMemoryMessages:t=null,compaction:n=null}={}){let r=rn(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=d(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 ln(e){if(!e||!e.trim()||e.trim()==`/`)return;let t=e.trim(),n=C.inputHistory.indexOf(t);n!==-1&&C.inputHistory.splice(n,1),C.inputHistory.push(t),C.inputHistory.length>20&&C.inputHistory.shift(),un()}function un(){try{chrome.storage.local.set({inputHistory:C.inputHistory}),i.debug(`[SidePanel] input history saved,count:`,C.inputHistory.length)}catch(e){i.error(`[SidePanel] saveinput history failed:`,e)}}var dn=[`workspace`,`bookmark`,`toc`,`search`,`todo`,`schedule`],fn=`.workspace-panel.expanded, .bookmark-panel.expanded, .message-toc-panel.expanded, .search-panel.expanded, .schedule-panel.open`,pn=null,mn=null;function hn(){if(pn)return pn;pn=document.createElement(`div`),pn.className=`side-rail`,pn.id=`sideRail`,pn.innerHTML=dn.map(e=>`<div class="side-rail-slot" data-slot="${e}"></div>`).join(``),document.body.appendChild(pn),_n();let e=document.getElementById(`chatContainer`);return e&&typeof ResizeObserver<`u`&&new ResizeObserver(_n).observe(e),window.addEventListener(`resize`,_n),pn}function gn(e){return(pn||hn()).querySelector(`.side-rail-slot[data-slot="${e}"]`)}function _n(){if(!pn)return;let e=document.getElementById(`chatContainer`);if(!e)return;let t=e.getBoundingClientRect(),n=window.innerHeight;pn.style.top=`${Math.max(0,Math.round(t.top))}px`,pn.style.bottom=`${Math.max(0,Math.round(n-t.bottom))}px`,vn()}function vn(){mn&&clearTimeout(mn),mn=setTimeout(()=>{mn=null,document.querySelectorAll(fn).forEach(Ie)},120)}n(`zh`,{panelFs:{enter:`全屏`,exit:`退出全屏`}}),n(`en`,{panelFs:{enter:`Fullscreen`,exit:`Exit fullscreen`}});var yn=`panel-fullscreen`,bn=`<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="M8 3H5a2 2 0 0 0-2 2v3"/><path d="M16 3h3a2 2 0 0 1 2 2v3"/><path d="M8 21H5a2 2 0 0 1-2-2v-3"/><path d="M16 21h3a2 2 0 0 0 2-2v-3"/></svg>`,xn=`<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="M3 8h3a2 2 0 0 0 2-2V3"/><path d="M21 8h-3a2 2 0 0 1-2-2V3"/><path d="M3 16h3a2 2 0 0 1 2 2v3"/><path d="M21 16h-3a2 2 0 0 0-2 2v3"/></svg>`,Sn=new WeakSet;function Cn(e){return!!e&&Sn.has(e)}function wn(e,t){e&&(t?Sn.add(e):Sn.delete(e),e.classList.add(`panel-fs-no-anim`),e.classList.toggle(yn,!!t),e.offsetWidth,requestAnimationFrame(()=>e.classList.remove(`panel-fs-no-anim`)))}function Tn(e){wn(e,!1)}function En(e,t){if(!e)return;let n=r(t?`panelFs.exit`:`panelFs.enter`);e.innerHTML=t?xn:bn,e.title=n,e.setAttribute(`aria-label`,n),e.setAttribute(`aria-pressed`,String(!!t))}function Dn(e=``){let t=document.createElement(`button`);return t.type=`button`,t.className=[`panel-fullscreen-btn`,e].filter(Boolean).join(` `),t.innerHTML=bn,t}function On(e,t,{onToggle:n}={}){if(!e||!t)return()=>{};let r=()=>En(e,Cn(t));return e.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation();let i=!Cn(t);wn(t,i),r(),n&&n(i)}),r(),r}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 kn=`messageTocLocked`,An=!1,jn=null,Mn=null,Nn=null;function Pn(e){Mn=e,Nn={parent:e.parentElement,nextSibling:e.nextSibling},document.body.appendChild(e),e.classList.add(`expanded`),wn(e,!0)}function Fn(){let e=Mn;if(!e)return;Mn=null,wn(e,!1);let t=Nn;Nn=null,t?.parent?.isConnected?t.parent.insertBefore(e,t.nextSibling):e.remove()}var In=`<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>`,Ln=`<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 Rn(e){e&&(e.innerHTML=An?Ln:In,e.title=r(An?`messageToc.unlock`:`messageToc.lock`),e.classList.toggle(`locked`,An))}function zn(){try{let e=chrome.storage?.local?.set?.({[kn]:An});e&&typeof e.catch==`function`&&e.catch(()=>{})}catch{}}function Bn(){document.addEventListener(`mouseover`,Vn,!0),document.addEventListener(`mouseout`,Hn,!0);try{let e=chrome.storage?.local?.get?.(kn);e&&typeof e.then==`function`?e.then(e=>{An=!!(e&&e[kn])}).catch(()=>{}):e&&typeof e==`object`&&(An=!!e[kn])}catch{}i.debug(`[SidePanel] messagedirectory featureinitializing`)}function Vn(e){if(!(e.target instanceof Element))return;if(e.target.closest(`.message-toc-container`)){C.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){!An&&!Mn&&Yn();return}Jn(r,i)}function Hn(e){if(!(e.target instanceof Element))return;if(e.target.closest(`.message-toc-container`)){C.isMouseOverToc=!1,C.tocHideTimer&&=(clearTimeout(C.tocHideTimer),null);return}let t=e.target.closest(`.message.assistant`),n=e.target.closest(`.workspace-preview-markdown`);if(!t&&!n||An)return;let r=e.relatedTarget;r&&(r.closest(`.message-toc-container`)||r.closest(`.message.assistant`)||r.closest(`.workspace-preview-markdown`))||C.isMouseOverToc||(C.tocHideTimer&&clearTimeout(C.tocHideTimer),C.tocHideTimer=setTimeout(()=>{!C.isMouseOverToc&&!Mn&&Yn(),C.tocHideTimer=null},800))}var Un=null,Wn=null;function Gn(e){let t=e.parentElement;for(;t&&t!==document.body&&t!==document.documentElement;){let e=getComputedStyle(t).overflowY;if((e===`auto`||e===`scroll`||e===`overlay`)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function Kn(e,t,n,r){if(qn(),n.length===0)return;let i=Gn(t),a=e.querySelector(`.message-toc-content`),o=Array.from(e.querySelectorAll(`.message-toc-item`)),s=new Map(o.map(e=>[e.dataset.target,e])),c=0,l=null,u=-1,d=e=>{if(!a)return;let t=e.getBoundingClientRect(),n=a.getBoundingClientRect();(t.top<n.top||t.bottom>n.bottom)&&(a.scrollTop+=t.top-n.top-(n.height-t.height)/2)},f=()=>{let e=window.innerHeight||document.documentElement.clientHeight||0;if(!i)return{top:0,bottom:e};let t=i.getBoundingClientRect();return{top:Math.max(t.top,0),bottom:Math.min(t.top+i.clientHeight,e)}},p=()=>{if(i)return i.scrollTop+i.clientHeight>=i.scrollHeight-2;let e=document.documentElement;return window.scrollY+window.innerHeight>=e.scrollHeight-2},m=()=>i?i.scrollTop<=2:window.scrollY<=2,h=()=>{if(c=0,!e.isConnected)return;let t=f(),i=t.top,a=t.bottom,h=Math.max(a-i,1),g=n.map(e=>{let t=e.getBoundingClientRect();if(t.width||t.height)return t.top;let n=e.closest(`.markdown-body`);return n?n.getBoundingClientRect().top:t.top}),_=0;for(let e=0;e<g.length&&g[e]<=i;e++)_=e;let v=i+h*.75,y=_,b=_+1;if(b<g.length){let e=g[b];u===b?e<=a&&(y=b):e<=v&&(y=b)}m()?y=0:p()&&(y=n.length-1);let x=n[y];if(!x||x.id===l)return;u=y,l=x.id,o.forEach(e=>e.classList.toggle(`active`,e.dataset.target===l));let S=s.get(l);S&&r.classList.contains(`expanded`)&&d(S)},g=()=>{c||=requestAnimationFrame(h)};document.addEventListener(`scroll`,g,{capture:!0,passive:!0}),window.addEventListener(`resize`,g,{passive:!0});let _=typeof IntersectionObserver==`function`?new IntersectionObserver(g,{threshold:[0,.25,.5,.75,1]}):null;_&&n.forEach(e=>_.observe(e)),h(),Wn=()=>{if(h(),!l)return;let e=s.get(l);e&&d(e)},Un=()=>{c&&cancelAnimationFrame(c),c=0,document.removeEventListener(`scroll`,g,{capture:!0}),window.removeEventListener(`resize`,g),_&&_.disconnect()}}function qn(){Un&&=(Un(),null),Wn=null}function Jn(e,t){let n=Array.from(t),i=jn;C.messageTocContainer&&Yn(),jn=i,n.forEach((e,t)=>{e.id||=`toc-heading-${Date.now()}-${t}`});let a=document.createElement(`div`);a.className=`message-toc-container`,a.dataset.headingsCount=n.length;let o=0,s=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 o++,`
|
|
4
4
|
<li class="message-toc-item level-${t}"
|
|
5
5
|
data-target="${e.id}"
|
|
@@ -1124,7 +1124,7 @@ It is this session's directory or the agent default, so it stays accessible (wor
|
|
|
1124
1124
|
<source src="${c}" type="${X(o)}">
|
|
1125
1125
|
</audio>
|
|
1126
1126
|
<div id="mediaUnsupportedHint" style="display:none;">${u}</div>
|
|
1127
|
-
</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 K_=!1;function q_(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 J_(e,t){q_(e,t),t.classList.add(`show`)}function Y_(){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`):J_(t,n)});let r=null,i=null;e.addEventListener(`mouseenter`,()=>{i&&=(clearTimeout(i),null),r=setTimeout(()=>{J_(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`),Z_(r)})}),document.addEventListener(`click`,t=>{!e.contains(t.target)&&!n.contains(t.target)&&n.classList.remove(`show`)});let a=()=>{n.classList.contains(`show`)&&q_(t,n)};document.getElementById(`workspacePreviewContent`)?.addEventListener(`scroll`,a),window.addEventListener(`resize`,a)}function X_(){return document.getElementById(`workspacePreviewArea`).dataset.markdownText||``}async function Z_(e){if(K_)return;K_=!0;let t=document.getElementById(`workspacePreviewExportBtn`);document.getElementById(`workspacePreviewExportMenu`);let n=document.getElementById(`workspacePreviewExportDropdown`),a=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 ev(a);break;case`pdf`:await nv(a);break;case`image`:await rv(a);break;case`md`:iv(a);break}}catch(e){i.error(`[WorkspacePanel] export failed:`,e),F(r(`chatExport.exportFailed`,{message:e.message}),`error`)}finally{K_=!1,t.innerHTML=o,t.disabled=!1,t.style.opacity=`1`,n.classList.remove(`show`)}}async function Q_(e){if(typeof mermaid>`u`)return;let{renderMermaidInContainer:t,convertSvgsToImages:n}=await A(async()=>{let{renderMermaidInContainer:e,convertSvgsToImages:t}=await import(`./chat-export-
|
|
1127
|
+
</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 K_=!1;function q_(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 J_(e,t){q_(e,t),t.classList.add(`show`)}function Y_(){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`):J_(t,n)});let r=null,i=null;e.addEventListener(`mouseenter`,()=>{i&&=(clearTimeout(i),null),r=setTimeout(()=>{J_(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`),Z_(r)})}),document.addEventListener(`click`,t=>{!e.contains(t.target)&&!n.contains(t.target)&&n.classList.remove(`show`)});let a=()=>{n.classList.contains(`show`)&&q_(t,n)};document.getElementById(`workspacePreviewContent`)?.addEventListener(`scroll`,a),window.addEventListener(`resize`,a)}function X_(){return document.getElementById(`workspacePreviewArea`).dataset.markdownText||``}async function Z_(e){if(K_)return;K_=!0;let t=document.getElementById(`workspacePreviewExportBtn`);document.getElementById(`workspacePreviewExportMenu`);let n=document.getElementById(`workspacePreviewExportDropdown`),a=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 ev(a);break;case`pdf`:await nv(a);break;case`image`:await rv(a);break;case`md`:iv(a);break}}catch(e){i.error(`[WorkspacePanel] export failed:`,e),F(r(`chatExport.exportFailed`,{message:e.message}),`error`)}finally{K_=!1,t.innerHTML=o,t.disabled=!1,t.style.opacity=`1`,n.classList.remove(`show`)}}async function Q_(e){if(typeof mermaid>`u`)return;let{renderMermaidInContainer:t,convertSvgsToImages:n}=await A(async()=>{let{renderMermaidInContainer:e,convertSvgsToImages:t}=await import(`./chat-export-DRUG3mwM.js`);return{renderMermaidInContainer:e,convertSvgsToImages:t}},__vite__mapDeps([9,10,1,11,2,3,12,0]));await t(e),await n(e)}async function $_(e){if(typeof mermaid>`u`||!/```mermaid/i.test(e))return e;let{renderMermaidInContainer:t,convertSvgsToImages:n}=await A(async()=>{let{renderMermaidInContainer:e,convertSvgsToImages:t}=await import(`./chat-export-DRUG3mwM.js`);return{renderMermaidInContainer:e,convertSvgsToImages:t}},__vite__mapDeps([9,10,1,11,2,3,12,0]));try{let r=tt(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 i.warn(`[WorkspacePanel] Mermaid pre-render failed:`,t.message),e}}async function ev(e){let{Packer:t}=await A(async()=>{let{Packer:e}=await import(`./dist-BUuoW_84.js`);return{Packer:e}},__vite__mapDeps([10,1])),{createDocxDocument:n}=await A(async()=>{let{createDocxDocument:e}=await import(`./chat-export-DRUG3mwM.js`);return{createDocxDocument:e}},__vite__mapDeps([9,10,1,11,2,3,12,0])),i=X_();if(!i){F(r(`chatExport.noContent`),`error`);return}i=await $_(i);let a=n(await tv(i)),o=await t.toBlob(a),s=`word-${new Date().getTime()}.docx`;av(o,s),F(r(`workspace.downloaded`,{name:s}),`success`)}async function tv(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 A(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([10,1])),{createTextRuns:h,sanitizeDocxText:g,nextDocxImageId:_,isDocxEmbeddableImageType:v}=await A(async()=>{let{createTextRuns:e,sanitizeDocxText:t,nextDocxImageId:n,isDocxEmbeddableImageType:r}=await import(`./chat-export-DRUG3mwM.js`);return{createTextRuns:e,sanitizeDocxText:t,nextDocxImageId:n,isDocxEmbeddableImageType:r}},__vite__mapDeps([9,10,1,11,2,3,12,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(`
|
|
1128
1128
|
`),n=[];for(let e of t){if(/^[\s\|:\-]+$/.test(e.replace(/\|/g,``)))continue;let t=Ze(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(`
|
|
1129
1129
|
`);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(`
|
|
1130
1130
|
`).map(e=>e.replace(/^>\s?/,``)).join(`
|
|
@@ -1385,7 +1385,7 @@ It is this session's directory or the agent default, so it stays accessible (wor
|
|
|
1385
1385
|
<span class="page-action-btn" data-action="translate" data-tab-id="${e.id}" title="${r(`pageSelector.translatePage`)}">${r(`pageSelector.translatePage`)}</span>
|
|
1386
1386
|
</span>
|
|
1387
1387
|
</div>
|
|
1388
|
-
`}).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(),Ox(parseInt(n.dataset.tabId),n.dataset.action);return}Dx(parseInt(e.dataset.tabId))})})}function wx(e){e.forEach((e,t)=>{t===C.selectedPageIndex?(e.classList.add(`selected`),e.scrollIntoView({block:`nearest`})):e.classList.remove(`selected`)})}function Tx(e){C.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=C.selectedPage.title&&C.selectedPage.title!==r(`pageSelector.noTitle`)?C.selectedPage.title:``,i=C.selectedPage.url||``;e&&i?n.textContent=`${e} · ${i}`:n.textContent=e||i,t.style.display=`flex`}}function Ex(){C.selectedPage=null,C.selectedPageIndex=-1;let e=document.getElementById(`pageIndicator`);e&&(e.style.display=`none`)}function Dx(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){i.error(`[PageSelector] getlabelpageinfo failed:`,chrome.runtime.lastError);return}Tx(e),zb(),t&&(t.focus(),ut())})}function Ox(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){i.error(`[PageSelector] get tab info failed:`,chrome.runtime.lastError);return}Tx(e),zb();let t=document.getElementById(`userInput`);t&&(t.value=n,ut()),rT()})}function kx(){let e=document.getElementById(`pageIndicatorClose`);e&&e.addEventListener(`click`,()=>{Ex()})}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 Ax=`messageFullscreenOverlay`,jx=`messageFullscreenBody`,Mx=`messageFullscreenTitle`,Nx=`messageFullscreenCopyBtn`,Px=`messageFullscreenCloseBtn`,Fx=`messageFullscreenExportBtn`,Ix=`messageFullscreenExportDropdown`,Lx=null,Rx=null,zx=null,Bx=!1,Vx=null,Hx=!1;function Ux(){return Lx!==null}function Wx(e){return!e||Ux()?null:e.innerHTML}function Gx(){let e=document.querySelectorAll(`#chatContainer .message.assistant`);return e.length?e[e.length-1]:null}function Kx(){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 qx(){let e=document.getElementById(Ax),t=document.getElementById(jx);return!e||!t?(i.warn(`[MsgFullscreen] overlay/body element missing`),null):{overlay:e,body:t,title:document.getElementById(Mx),copyBtn:document.getElementById(Nx),closeBtn:document.getElementById(Px)}}function Jx(e){if(!e)return;let t=qx();if(t&&Lx!==e){if(!Lx){let e=document.getElementById(`chatContainer`);Vx=e?e.scrollTop:null}Lx&&(Hx=!0,Yx(),Hx=!1),Rx=document.createComment(`msg-fullscreen-anchor`),e.parentNode.insertBefore(Rx,e),e.dataset.fullscreen=`1`,t.body.appendChild(e),Lx=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`)),aS(),Zx(t.body)}}function Yx(){if(!Lx)return;let e=qx();if($x(),oS(),Rx&&Rx.parentNode)Rx.parentNode.insertBefore(Lx,Rx);else if(e){let e=document.getElementById(`chatContainer`);e&&e.appendChild(Lx)}if(Rx&&Rx.parentNode&&Rx.parentNode.removeChild(Rx),delete Lx.dataset.fullscreen,Lx=null,Rx=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`),!Hx&&Vx!==null){let e=document.getElementById(`chatContainer`);e&&(e.scrollTop=Vx),Vx=null}}function Xx(e){if(Lx&&Lx===e){Yx();return}Jx(e||Gx())}function Zx(e){$x(),Bx=!1,e.scrollTop=e.scrollHeight,e.addEventListener(`scroll`,Qx,{passive:!0}),typeof ResizeObserver<`u`&&(zx=new ResizeObserver(()=>{Bx||(e.scrollTop=e.scrollHeight)}),zx.observe(e.firstElementChild||e))}function Qx(){let e=document.getElementById(jx);e&&(Bx=e.scrollHeight-e.scrollTop-e.clientHeight>60)}function $x(){let e=document.getElementById(jx);e&&e.removeEventListener(`scroll`,Qx),zx&&=(zx.disconnect(),null)}function eS(e){if(e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&e.code===`KeyF`){e.preventDefault(),Lx?Yx():Jx(Gx());return}e.key===`Escape`&&Lx&&(e.preventDefault(),e.stopImmediatePropagation(),Yx())}function tS(e){if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return;let t=e.target.closest?.(`#chatContainer .message.assistant`);t&&(e.preventDefault(),Xx(t))}async function nS(e){if(!Lx)return;let{copyAssistantMessage:t}=await A(async()=>{let{copyAssistantMessage:e}=await Promise.resolve().then(()=>lS);return{copyAssistantMessage:e}},void 0);t(Lx,document.getElementById(Nx),e)}var rS={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 iS(){let e=document.createElement(`div`);e.className=`message-fullscreen-export`;let t=document.createElement(`button`);t.className=`message-fullscreen-icon-btn`,t.id=Fx,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=Ix;let i=e=>`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round">${rS[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(),Lx&&(n.classList.remove(`show`),(await A(()=>import(`./chat-export-CdcWutsz.js`),__vite__mapDeps([9,10,1,11,2,3,12,0])))[t](Lx,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 aS(){if(document.getElementById(Fx))return;let e=document.getElementById(Px),t=e?e.parentNode:document.querySelector(`.message-fullscreen-actions`);t&&t.insertBefore(iS(),e||null)}function oS(){let e=document.getElementById(Ix);e&&e.classList.remove(`show`)}var sS=!1;function cS(){sS||(sS=!0,document.addEventListener(`click`,e=>{let t=document.getElementById(Ix);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(),Xx(n.closest(`.message`));return}if(e.target.closest?.(`#messageFullscreenCloseBtn`)){e.stopPropagation(),Yx();return}e.target.closest?.(`#messageFullscreenCopyBtn`)&&(e.stopPropagation(),nS(e))},!0),document.addEventListener(`keydown`,eS,!0),document.addEventListener(`dblclick`,tS,!0))}var lS=t({copyAssistantMessage:()=>fS,copyMessage:()=>dS,copyRichText:()=>hS,fallbackCopyRichText:()=>_S,fallbackCopyText:()=>mS,quoteAndAsk:()=>bS,setQuoteContextInjector:()=>yS,showCopySuccess:()=>pS,wrapHtmlWithStyles:()=>gS});n(`zh`,{chatCopy:{copiedMarkdown:`已复制 Markdown`,copiedRich:`已复制富文本`,copyFailedManual:`复制失败,请手动复制`}}),n(`en`,{chatCopy:{copiedMarkdown:`Markdown copied`,copiedRich:`Rich text copied`,copyFailedManual:`Copy failed, please copy manually`}});function uS(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(`
|
|
1388
|
+
`}).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(),Ox(parseInt(n.dataset.tabId),n.dataset.action);return}Dx(parseInt(e.dataset.tabId))})})}function wx(e){e.forEach((e,t)=>{t===C.selectedPageIndex?(e.classList.add(`selected`),e.scrollIntoView({block:`nearest`})):e.classList.remove(`selected`)})}function Tx(e){C.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=C.selectedPage.title&&C.selectedPage.title!==r(`pageSelector.noTitle`)?C.selectedPage.title:``,i=C.selectedPage.url||``;e&&i?n.textContent=`${e} · ${i}`:n.textContent=e||i,t.style.display=`flex`}}function Ex(){C.selectedPage=null,C.selectedPageIndex=-1;let e=document.getElementById(`pageIndicator`);e&&(e.style.display=`none`)}function Dx(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){i.error(`[PageSelector] getlabelpageinfo failed:`,chrome.runtime.lastError);return}Tx(e),zb(),t&&(t.focus(),ut())})}function Ox(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){i.error(`[PageSelector] get tab info failed:`,chrome.runtime.lastError);return}Tx(e),zb();let t=document.getElementById(`userInput`);t&&(t.value=n,ut()),rT()})}function kx(){let e=document.getElementById(`pageIndicatorClose`);e&&e.addEventListener(`click`,()=>{Ex()})}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 Ax=`messageFullscreenOverlay`,jx=`messageFullscreenBody`,Mx=`messageFullscreenTitle`,Nx=`messageFullscreenCopyBtn`,Px=`messageFullscreenCloseBtn`,Fx=`messageFullscreenExportBtn`,Ix=`messageFullscreenExportDropdown`,Lx=null,Rx=null,zx=null,Bx=!1,Vx=null,Hx=!1;function Ux(){return Lx!==null}function Wx(e){return!e||Ux()?null:e.innerHTML}function Gx(){let e=document.querySelectorAll(`#chatContainer .message.assistant`);return e.length?e[e.length-1]:null}function Kx(){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 qx(){let e=document.getElementById(Ax),t=document.getElementById(jx);return!e||!t?(i.warn(`[MsgFullscreen] overlay/body element missing`),null):{overlay:e,body:t,title:document.getElementById(Mx),copyBtn:document.getElementById(Nx),closeBtn:document.getElementById(Px)}}function Jx(e){if(!e)return;let t=qx();if(t&&Lx!==e){if(!Lx){let e=document.getElementById(`chatContainer`);Vx=e?e.scrollTop:null}Lx&&(Hx=!0,Yx(),Hx=!1),Rx=document.createComment(`msg-fullscreen-anchor`),e.parentNode.insertBefore(Rx,e),e.dataset.fullscreen=`1`,t.body.appendChild(e),Lx=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`)),aS(),Zx(t.body)}}function Yx(){if(!Lx)return;let e=qx();if($x(),oS(),Rx&&Rx.parentNode)Rx.parentNode.insertBefore(Lx,Rx);else if(e){let e=document.getElementById(`chatContainer`);e&&e.appendChild(Lx)}if(Rx&&Rx.parentNode&&Rx.parentNode.removeChild(Rx),delete Lx.dataset.fullscreen,Lx=null,Rx=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`),!Hx&&Vx!==null){let e=document.getElementById(`chatContainer`);e&&(e.scrollTop=Vx),Vx=null}}function Xx(e){if(Lx&&Lx===e){Yx();return}Jx(e||Gx())}function Zx(e){$x(),Bx=!1,e.scrollTop=e.scrollHeight,e.addEventListener(`scroll`,Qx,{passive:!0}),typeof ResizeObserver<`u`&&(zx=new ResizeObserver(()=>{Bx||(e.scrollTop=e.scrollHeight)}),zx.observe(e.firstElementChild||e))}function Qx(){let e=document.getElementById(jx);e&&(Bx=e.scrollHeight-e.scrollTop-e.clientHeight>60)}function $x(){let e=document.getElementById(jx);e&&e.removeEventListener(`scroll`,Qx),zx&&=(zx.disconnect(),null)}function eS(e){if(e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&e.code===`KeyF`){e.preventDefault(),Lx?Yx():Jx(Gx());return}e.key===`Escape`&&Lx&&(e.preventDefault(),e.stopImmediatePropagation(),Yx())}function tS(e){if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return;let t=e.target.closest?.(`#chatContainer .message.assistant`);t&&(e.preventDefault(),Xx(t))}async function nS(e){if(!Lx)return;let{copyAssistantMessage:t}=await A(async()=>{let{copyAssistantMessage:e}=await Promise.resolve().then(()=>lS);return{copyAssistantMessage:e}},void 0);t(Lx,document.getElementById(Nx),e)}var rS={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 iS(){let e=document.createElement(`div`);e.className=`message-fullscreen-export`;let t=document.createElement(`button`);t.className=`message-fullscreen-icon-btn`,t.id=Fx,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=Ix;let i=e=>`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round">${rS[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(),Lx&&(n.classList.remove(`show`),(await A(()=>import(`./chat-export-DRUG3mwM.js`),__vite__mapDeps([9,10,1,11,2,3,12,0])))[t](Lx,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 aS(){if(document.getElementById(Fx))return;let e=document.getElementById(Px),t=e?e.parentNode:document.querySelector(`.message-fullscreen-actions`);t&&t.insertBefore(iS(),e||null)}function oS(){let e=document.getElementById(Ix);e&&e.classList.remove(`show`)}var sS=!1;function cS(){sS||(sS=!0,document.addEventListener(`click`,e=>{let t=document.getElementById(Ix);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(),Xx(n.closest(`.message`));return}if(e.target.closest?.(`#messageFullscreenCloseBtn`)){e.stopPropagation(),Yx();return}e.target.closest?.(`#messageFullscreenCopyBtn`)&&(e.stopPropagation(),nS(e))},!0),document.addEventListener(`keydown`,eS,!0),document.addEventListener(`dblclick`,tS,!0))}var lS=t({copyAssistantMessage:()=>fS,copyMessage:()=>dS,copyRichText:()=>hS,fallbackCopyRichText:()=>_S,fallbackCopyText:()=>mS,quoteAndAsk:()=>bS,setQuoteContextInjector:()=>yS,showCopySuccess:()=>pS,wrapHtmlWithStyles:()=>gS});n(`zh`,{chatCopy:{copiedMarkdown:`已复制 Markdown`,copiedRich:`已复制富文本`,copyFailedManual:`复制失败,请手动复制`}}),n(`en`,{chatCopy:{copiedMarkdown:`Markdown copied`,copiedRich:`Rich text copied`,copyFailedManual:`Copy failed, please copy manually`}});function uS(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(`
|
|
1389
1389
|
`),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){i.warn(`[SidePanel] Mermaid chartprocessing failed,remove:`,t.message),e.remove()}return{html:e.innerHTML,firstPngBlob:n}}function dS(e,t){try{let n=e.dataset.textContent_||e.dataset.rawContent||``;navigator.clipboard.writeText(n).then(()=>{let e=t.innerHTML;t.innerHTML=`
|
|
1390
1390
|
<svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor">
|
|
1391
1391
|
<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"/>
|
|
@@ -1749,7 +1749,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1749
1749
|
<svg class="thinking-process-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
1750
1750
|
<polyline points="6 9 12 15 18 9"/>
|
|
1751
1751
|
</svg>
|
|
1752
|
-
`,d){let e=p.querySelector(`.token-stat`);e&&(e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Ye(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=et(e));let n=c.querySelector(`.thinking-indicator`);n&&n.remove(),c.appendChild(f),c.appendChild(t),pC(p)}else{let t=c.querySelector(`.thinking-indicator`);t&&t.remove(),e&&e.trim()&&(l.innerHTML=et(e))}}else e&&e.trim()&&(l.innerHTML=et(e))}e.classList.add(`assistant`,`message`),e.dataset.rawContent=typeof t==`string`?dt(t):JSON.stringify(t),e.dataset.textContent_=dt(Cw(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(),fS(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(),bS(e)}),f.appendChild(m),f.appendChild(Kx());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 A(async()=>{let{exportAssistantMessageToDocx:e}=await import(`./chat-export-CdcWutsz.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(e,v,_)});let y=_.querySelector(`.export-md-item`);y.addEventListener(`click`,async t=>{t.stopPropagation();let{exportAssistantMessageToMarkdown:n}=await A(async()=>{let{exportAssistantMessageToMarkdown:e}=await import(`./chat-export-CdcWutsz.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(e,y,_)});let b=_.querySelector(`.export-pdf-item`);b.addEventListener(`click`,async t=>{t.stopPropagation();let{exportAssistantMessageToPdf:n}=await A(async()=>{let{exportAssistantMessageToPdf:e}=await import(`./chat-export-CdcWutsz.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(e,b,_)});let x=_.querySelector(`.export-image-item`);x.addEventListener(`click`,async t=>{t.stopPropagation();let{exportAssistantMessageToImage:n}=await A(async()=>{let{exportAssistantMessageToImage:e}=await import(`./chat-export-CdcWutsz.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([9,10,1,11,2,3,12,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 w=document.createElement(`div`);w.className=`footer-right-actions`,w.style.marginLeft=`auto`,w.style.display=`flex`,w.style.alignItems=`center`,w.style.gap=`8px`;let T=Ge(n);if(T){let e=document.createElement(`span`);e.className=`token-usage-tag`,e.title=r(`chatStream.tokenUsageTitle`,{total:I(T.totalTokens),prompt:I(T.promptTokens),completion:I(T.completionTokens)}),e.innerHTML=`<span class="token-tag-icon">⬤</span><span class="token-tag-value">${I(T.totalTokens)}</span>`,e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Ye(T,e)}),w.appendChild(e)}let E=ub(t),D=pb(n,t);if(E.length&&(e.dataset.declaredArtifacts=JSON.stringify(E)),jb(D),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=`
|
|
1752
|
+
`,d){let e=p.querySelector(`.token-stat`);e&&(e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Ye(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=et(e));let n=c.querySelector(`.thinking-indicator`);n&&n.remove(),c.appendChild(f),c.appendChild(t),pC(p)}else{let t=c.querySelector(`.thinking-indicator`);t&&t.remove(),e&&e.trim()&&(l.innerHTML=et(e))}}else e&&e.trim()&&(l.innerHTML=et(e))}e.classList.add(`assistant`,`message`),e.dataset.rawContent=typeof t==`string`?dt(t):JSON.stringify(t),e.dataset.textContent_=dt(Cw(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(),fS(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(),bS(e)}),f.appendChild(m),f.appendChild(Kx());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 A(async()=>{let{exportAssistantMessageToDocx:e}=await import(`./chat-export-DRUG3mwM.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(e,v,_)});let y=_.querySelector(`.export-md-item`);y.addEventListener(`click`,async t=>{t.stopPropagation();let{exportAssistantMessageToMarkdown:n}=await A(async()=>{let{exportAssistantMessageToMarkdown:e}=await import(`./chat-export-DRUG3mwM.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(e,y,_)});let b=_.querySelector(`.export-pdf-item`);b.addEventListener(`click`,async t=>{t.stopPropagation();let{exportAssistantMessageToPdf:n}=await A(async()=>{let{exportAssistantMessageToPdf:e}=await import(`./chat-export-DRUG3mwM.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(e,b,_)});let x=_.querySelector(`.export-image-item`);x.addEventListener(`click`,async t=>{t.stopPropagation();let{exportAssistantMessageToImage:n}=await A(async()=>{let{exportAssistantMessageToImage:e}=await import(`./chat-export-DRUG3mwM.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([9,10,1,11,2,3,12,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 w=document.createElement(`div`);w.className=`footer-right-actions`,w.style.marginLeft=`auto`,w.style.display=`flex`,w.style.alignItems=`center`,w.style.gap=`8px`;let T=Ge(n);if(T){let e=document.createElement(`span`);e.className=`token-usage-tag`,e.title=r(`chatStream.tokenUsageTitle`,{total:I(T.totalTokens),prompt:I(T.promptTokens),completion:I(T.completionTokens)}),e.innerHTML=`<span class="token-tag-icon">⬤</span><span class="token-tag-value">${I(T.totalTokens)}</span>`,e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Ye(T,e)}),w.appendChild(e)}let E=ub(t),D=pb(n,t);if(E.length&&(e.dataset.declaredArtifacts=JSON.stringify(E)),jb(D),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=`
|
|
1753
1753
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="14" height="14">
|
|
1754
1754
|
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
|
|
1755
1755
|
<polyline points="14 2 14 8 20 8"/>
|
|
@@ -1815,7 +1815,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1815
1815
|
</div>
|
|
1816
1816
|
<div class="context-bubble-content">${l}</div>
|
|
1817
1817
|
</div>
|
|
1818
|
-
`;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 cT(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 lT(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 uT=e=>!!e&&e.dataset.resumable===`budget`;function dT(e,t,n=!0,a=[],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`?pe(_):_,y=Array.isArray(t)&&t.some(e=>e.type===`image_url`);m.dataset.rawContent=Array.isArray(t)?JSON.stringify(t):dt(t),m.dataset.textContent_=dt(e===`user`?pe(c||v):c||v);let b=v;if(m.dataset.executionLog=JSON.stringify(a),s&&(m.dataset.wasRevised=`true`),e===`assistant`){m.innerHTML=et(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(),fS(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(),bS(m)}),e.appendChild(c),e.appendChild(Kx());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 A(async()=>{let{exportAssistantMessageToDocx:e}=await import(`./chat-export-CdcWutsz.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));t(m,p,f)});let h=f.querySelector(`.export-md-item`);h.addEventListener(`click`,async e=>{e.stopPropagation();let{exportAssistantMessageToMarkdown:t}=await A(async()=>{let{exportAssistantMessageToMarkdown:e}=await import(`./chat-export-CdcWutsz.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));t(m,h,f)});let _=f.querySelector(`.export-pdf-item`);_.addEventListener(`click`,async e=>{e.stopPropagation();let{exportAssistantMessageToPdf:t}=await A(async()=>{let{exportAssistantMessageToPdf:e}=await import(`./chat-export-CdcWutsz.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));t(m,_,f)});let v=f.querySelector(`.export-image-item`);v.addEventListener(`click`,async e=>{e.stopPropagation();let{exportAssistantMessageToImage:t}=await A(async()=>{let{exportAssistantMessageToImage:e}=await import(`./chat-export-CdcWutsz.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([9,10,1,11,2,3,12,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=Ge(a);if(x){let e=document.createElement(`span`);e.className=`token-usage-tag`,e.title=r(`chatStream.tokenUsageTitle`,{total:I(x.totalTokens),prompt:I(x.promptTokens),completion:I(x.completionTokens)}),e.innerHTML=`<span class="token-tag-icon">⬤</span><span class="token-tag-value">${I(x.totalTokens)}</span>`,e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Ye(x,e)}),b.appendChild(e)}let S=a&&a.length>0,w=o!=null,T=a?a.filter(e=>e.nodeType===`reflection`&&e.reflectionType===`post`&&e.status===`success`).length:0;mT(),gT(),st();let E=a?.find(e=>e.nodeType===`reflection`&&e.reflectionType===`post`),D=ub(t),O=pb(a,t);if(D.length&&(m.dataset.declaredArtifacts=JSON.stringify(D)),jb(O),console.log(`[addMessage] executionLog entries:`,a?.length,`| agent_file entries:`,a?.filter(e=>e.nodeType===`tool_exec`&&e.action?.name===`agent_file`).length,`| artifacts:`,O.length),O.length>0){let e=document.createElement(`button`);e.className=`artifacts-btn`,e.type=`button`,e.title=r(`artifacts.btnTitle`,{count:O.length}),e.innerHTML=`
|
|
1818
|
+
`;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 cT(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 lT(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 uT=e=>!!e&&e.dataset.resumable===`budget`;function dT(e,t,n=!0,a=[],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`?pe(_):_,y=Array.isArray(t)&&t.some(e=>e.type===`image_url`);m.dataset.rawContent=Array.isArray(t)?JSON.stringify(t):dt(t),m.dataset.textContent_=dt(e===`user`?pe(c||v):c||v);let b=v;if(m.dataset.executionLog=JSON.stringify(a),s&&(m.dataset.wasRevised=`true`),e===`assistant`){m.innerHTML=et(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(),fS(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(),bS(m)}),e.appendChild(c),e.appendChild(Kx());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 A(async()=>{let{exportAssistantMessageToDocx:e}=await import(`./chat-export-DRUG3mwM.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));t(m,p,f)});let h=f.querySelector(`.export-md-item`);h.addEventListener(`click`,async e=>{e.stopPropagation();let{exportAssistantMessageToMarkdown:t}=await A(async()=>{let{exportAssistantMessageToMarkdown:e}=await import(`./chat-export-DRUG3mwM.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));t(m,h,f)});let _=f.querySelector(`.export-pdf-item`);_.addEventListener(`click`,async e=>{e.stopPropagation();let{exportAssistantMessageToPdf:t}=await A(async()=>{let{exportAssistantMessageToPdf:e}=await import(`./chat-export-DRUG3mwM.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));t(m,_,f)});let v=f.querySelector(`.export-image-item`);v.addEventListener(`click`,async e=>{e.stopPropagation();let{exportAssistantMessageToImage:t}=await A(async()=>{let{exportAssistantMessageToImage:e}=await import(`./chat-export-DRUG3mwM.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([9,10,1,11,2,3,12,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=Ge(a);if(x){let e=document.createElement(`span`);e.className=`token-usage-tag`,e.title=r(`chatStream.tokenUsageTitle`,{total:I(x.totalTokens),prompt:I(x.promptTokens),completion:I(x.completionTokens)}),e.innerHTML=`<span class="token-tag-icon">⬤</span><span class="token-tag-value">${I(x.totalTokens)}</span>`,e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Ye(x,e)}),b.appendChild(e)}let S=a&&a.length>0,w=o!=null,T=a?a.filter(e=>e.nodeType===`reflection`&&e.reflectionType===`post`&&e.status===`success`).length:0;mT(),gT(),st();let E=a?.find(e=>e.nodeType===`reflection`&&e.reflectionType===`post`),D=ub(t),O=pb(a,t);if(D.length&&(m.dataset.declaredArtifacts=JSON.stringify(D)),jb(O),console.log(`[addMessage] executionLog entries:`,a?.length,`| agent_file entries:`,a?.filter(e=>e.nodeType===`tool_exec`&&e.action?.name===`agent_file`).length,`| artifacts:`,O.length),O.length>0){let e=document.createElement(`button`);e.className=`artifacts-btn`,e.type=`button`,e.title=r(`artifacts.btnTitle`,{count:O.length}),e.innerHTML=`
|
|
1819
1819
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="14" height="14">
|
|
1820
1820
|
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
|
|
1821
1821
|
<polyline points="14 2 14 8 20 8"/>
|
|
@@ -1878,11 +1878,11 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1878
1878
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
1879
1879
|
<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"/>
|
|
1880
1880
|
</svg>
|
|
1881
|
-
</button>`,e.parentElement.insertBefore(t,e),t.appendChild(e)}),s.querySelectorAll(`.subtask-progress`).forEach(e=>{Xw(e)}),s.querySelectorAll(`.tool-call-terminate-btn, .agent-stream-terminate-btn`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation(),ST(C.activeSessionId)})}),s.querySelectorAll(`.tool-call-abort-btn`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),chrome.runtime.sendMessage({type:`ABORT_CURRENT_TOOL`,sessionId:C.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(),fS(s,e,t)});let t=l.querySelector(`.quote-btn`);t&&t.addEventListener(`click`,e=>{e.stopPropagation(),bS(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 A(async()=>{let{exportAssistantMessageToDocx:e}=await import(`./chat-export-
|
|
1881
|
+
</button>`,e.parentElement.insertBefore(t,e),t.appendChild(e)}),s.querySelectorAll(`.subtask-progress`).forEach(e=>{Xw(e)}),s.querySelectorAll(`.tool-call-terminate-btn, .agent-stream-terminate-btn`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation(),ST(C.activeSessionId)})}),s.querySelectorAll(`.tool-call-abort-btn`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),chrome.runtime.sendMessage({type:`ABORT_CURRENT_TOOL`,sessionId:C.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(),fS(s,e,t)});let t=l.querySelector(`.quote-btn`);t&&t.addEventListener(`click`,e=>{e.stopPropagation(),bS(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 A(async()=>{let{exportAssistantMessageToDocx:e}=await import(`./chat-export-DRUG3mwM.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(s,t,r)}),r.querySelector(`.export-md-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let t=e.currentTarget,{exportAssistantMessageToMarkdown:n}=await A(async()=>{let{exportAssistantMessageToMarkdown:e}=await import(`./chat-export-DRUG3mwM.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(s,t,r)}),r.querySelector(`.export-pdf-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let t=e.currentTarget,{exportAssistantMessageToPdf:n}=await A(async()=>{let{exportAssistantMessageToPdf:e}=await import(`./chat-export-DRUG3mwM.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(s,t,r)}),r.querySelector(`.export-image-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let t=e.currentTarget,{exportAssistantMessageToImage:n}=await A(async()=>{let{exportAssistantMessageToImage:e}=await import(`./chat-export-DRUG3mwM.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));n(s,t,r)}));let a=l.querySelector(`.prototype-btn-small`);if(a){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&&a.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?Bc(t):i.error(`[SidePanel] not found prototypeId,entry keys:`,Object.keys(e),`observation:`,e.observation)})}let o=l.querySelector(`.bookmark-btn`);o&&(mh(o,C.activeSessionId,s.dataset.messageId),o.addEventListener(`click`,async e=>{e.stopPropagation();let t=C.activeSessionId,n=s.dataset.messageId;if(o.classList.contains(`bookmarked`)){await nh(t,n),mh(o,t,n);let{refreshBookmarkPanel:e}=await A(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>oh);return{refreshBookmarkPanel:e}},void 0);e()}else{await th(t,n,s.dataset.textContent_||``,C.sessions.find(e=>e.id===t)?.title||``),mh(o,t,n);let{refreshBookmarkPanel:e}=await A(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>oh);return{refreshBookmarkPanel:e}},void 0);e()}}));let c=l.querySelector(`.delete-btn`);c&&c.addEventListener(`click`,e=>{e.stopPropagation(),wT(s)});let u=l.querySelector(`.fork-btn`);u&&u.addEventListener(`click`,async e=>{e.stopPropagation();let t=s.dataset.messageId;t&&await pc(C.activeSessionId,t)});let d=l.querySelector(`.resume-task-btn`);d&&d.addEventListener(`click`,async e=>{if(e.stopPropagation(),d.disabled)return;let t=await CS({budgetEnded:uT(s)});t!==null&&(d.disabled=!0,d.style.opacity=`0.6`,d.style.cursor=`not-allowed`,OS(C.activeSessionId,t).finally(()=>{d.disabled=!1,d.style.opacity=``,d.style.cursor=``}))}),yT(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=Ge(e?JSON.parse(e):[]);t&&Ye(t,f)}catch{}}))}let u=s.querySelector(`.message-toolbar`);if(u){let e=u.querySelector(`.edit-btn`);e&&e.addEventListener(`click`,e=>{e.stopPropagation(),OT(s)});let t=u.querySelector(`.copy-btn`);t&&t.addEventListener(`click`,e=>{e.stopPropagation(),dS(s,t)});let n=u.querySelector(`.delete-btn`);n&&n.addEventListener(`click`,e=>{e.stopPropagation(),wT(s)})}s.querySelectorAll(`.user-message-image`).forEach(e=>{e.addEventListener(`click`,()=>{$p(e.src,e)})}),a.appendChild(s),UO()}function xT(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`)}">
|
|
1882
1882
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
1883
1883
|
<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"/>
|
|
1884
1884
|
</svg>
|
|
1885
|
-
</button>`,e.parentElement.insertBefore(t,e),t.appendChild(e)}),e.querySelectorAll(`.thinking-process-header`).forEach(e=>{pC(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=>{Xw(e)}),e.querySelectorAll(`.tool-call-terminate-btn, .agent-stream-terminate-btn`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation(),ST(C.activeSessionId)})}),e.querySelectorAll(`.tool-call-abort-btn`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),chrome.runtime.sendMessage({type:`ABORT_CURRENT_TOOL`,sessionId:C.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(),fS(t,n,e)});let r=e.querySelector(`.quote-btn`);r&&r.addEventListener(`click`,e=>{e.stopPropagation(),bS(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 A(async()=>{let{exportAssistantMessageToDocx:e}=await import(`./chat-export-
|
|
1885
|
+
</button>`,e.parentElement.insertBefore(t,e),t.appendChild(e)}),e.querySelectorAll(`.thinking-process-header`).forEach(e=>{pC(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=>{Xw(e)}),e.querySelectorAll(`.tool-call-terminate-btn, .agent-stream-terminate-btn`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation(),ST(C.activeSessionId)})}),e.querySelectorAll(`.tool-call-abort-btn`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),chrome.runtime.sendMessage({type:`ABORT_CURRENT_TOOL`,sessionId:C.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(),fS(t,n,e)});let r=e.querySelector(`.quote-btn`);r&&r.addEventListener(`click`,e=>{e.stopPropagation(),bS(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 A(async()=>{let{exportAssistantMessageToDocx:e}=await import(`./chat-export-DRUG3mwM.js`);return{exportAssistantMessageToDocx:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));r(t,n,a)}),a.querySelector(`.export-md-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let n=e.currentTarget,{exportAssistantMessageToMarkdown:r}=await A(async()=>{let{exportAssistantMessageToMarkdown:e}=await import(`./chat-export-DRUG3mwM.js`);return{exportAssistantMessageToMarkdown:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));r(t,n,a)}),a.querySelector(`.export-pdf-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let n=e.currentTarget,{exportAssistantMessageToPdf:r}=await A(async()=>{let{exportAssistantMessageToPdf:e}=await import(`./chat-export-DRUG3mwM.js`);return{exportAssistantMessageToPdf:e}},__vite__mapDeps([9,10,1,11,2,3,12,0]));r(t,n,a)}),a.querySelector(`.export-image-item`)?.addEventListener(`click`,async e=>{e.stopPropagation();let n=e.currentTarget,{exportAssistantMessageToImage:r}=await A(async()=>{let{exportAssistantMessageToImage:e}=await import(`./chat-export-DRUG3mwM.js`);return{exportAssistantMessageToImage:e}},__vite__mapDeps([9,10,1,11,2,3,12,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&&Bc(t)})}let s=e.querySelector(`.bookmark-btn`);s&&(mh(s,C.activeSessionId,t.dataset.messageId),s.addEventListener(`click`,async e=>{e.stopPropagation();let n=C.activeSessionId,r=t.dataset.messageId;if(s.classList.contains(`bookmarked`)){await nh(n,r),mh(s,n,r);let{refreshBookmarkPanel:e}=await A(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>oh);return{refreshBookmarkPanel:e}},void 0);e()}else{await th(n,r,t.dataset.textContent_||``,C.sessions.find(e=>e.id===n)?.title||``),mh(s,n,r);let{refreshBookmarkPanel:e}=await A(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>oh);return{refreshBookmarkPanel:e}},void 0);e()}}));let c=e.querySelector(`.delete-btn`);c&&c.addEventListener(`click`,e=>{e.stopPropagation(),wT(t)});let l=e.querySelector(`.fork-btn`);l&&l.addEventListener(`click`,async e=>{e.stopPropagation();let n=t.dataset.messageId;n&&await pc(C.activeSessionId,n)});let u=e.querySelector(`.resume-task-btn`);u&&u.addEventListener(`click`,async e=>{if(e.stopPropagation(),u.disabled)return;let n=await CS({budgetEnded:uT(t)});n!==null&&(u.disabled=!0,u.style.opacity=`0.6`,u.style.cursor=`not-allowed`,OS(C.activeSessionId,n).finally(()=>{u.disabled=!1,u.style.opacity=``,u.style.cursor=``}))}),yT(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=Ge(e?JSON.parse(e):[]);n&&Ye(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(),OT(t)});let r=e.querySelector(`.copy-btn`);r&&r.addEventListener(`click`,e=>{e.stopPropagation(),dS(t,r)});let i=e.querySelector(`.delete-btn`);i&&i.addEventListener(`click`,e=>{e.stopPropagation(),wT(t)})}),e.querySelectorAll(`.user-message-image`).forEach(e=>{e.addEventListener(`click`,()=>{$p(e.src,e)})}),e.querySelectorAll(`.mermaid-controls`).forEach(e=>e.remove()),Qe(),mT(),gT(),UO()}function ST(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=`
|
|
1886
1886
|
<div class="command-terminate-modal">
|
|
1887
1887
|
<div class="command-terminate-header">
|
|
1888
1888
|
<div class="command-terminate-icon">⏹</div>
|
package/dist/assets/options.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c}from"./i18n-XUUSwfZZ.js";import{$t as l,Nt as u,Tt as d,_ as f,a as p,c as m,d as h,g,h as _,i as v,in as y,m as b,n as x,o as S,p as ee,r as te,rn as ne,s as re,t as ie,tn as C,u as w,v as T,wt as E,zt as D}from"./model-profiles-C7nNtymU.js";import{r as ae}from"./network-scope-0d6MoKgI.js";import{i as oe,r as se}from"./voice-shortcut-Dx863RGz.js";import{$ as ce,Q as O,Z as k,_ as le,a as ue,c as de,d as fe,et as pe,h as me,i as he,l as ge,o as _e,r as ve,s as ye,t as be}from"./version-
|
|
1
|
+
import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c}from"./i18n-XUUSwfZZ.js";import{$t as l,Nt as u,Tt as d,_ as f,a as p,c as m,d as h,g,h as _,i as v,in as y,m as b,n as x,o as S,p as ee,r as te,rn as ne,s as re,t as ie,tn as C,u as w,v as T,wt as E,zt as D}from"./model-profiles-C7nNtymU.js";import{r as ae}from"./network-scope-0d6MoKgI.js";import{i as oe,r as se}from"./voice-shortcut-Dx863RGz.js";import{$ as ce,Q as O,Z as k,_ as le,a as ue,c as de,d as fe,et as pe,h as me,i as he,l as ge,o as _e,r as ve,s as ye,t as be}from"./version-DbUttEL9.js";e(`zh`,{optionsConst:{aiSearch:`AI搜索`,explain:`解释`,translate:`翻译`,summary:`总结`,copy:`复制`,defaultSystemPrompt:`AI Helper:IT技术助手。
|
|
2
2
|
|
|
3
3
|
## 能力
|
|
4
4
|
编程开发与调试(Java/Python/JavaScript/Go/C++)、架构优化、性能调优、代码审查、文档编写、浏览器工具调用
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/context-indicator-
|
|
2
|
-
import{a as e,c as t,i as n,l as r,n as i,r as a,s as o}from"./i18n-XUUSwfZZ.js";import{A as s,At as c,Bt as l,Ht as u,J as d,Jt as f,L as p,Lt as m,M as h,Nt as g,Ot as ee,P as te,R as ne,U as _,b as v,c as re,ct as y,d as b,gt as x,ht as ie,i as S,it as C,jt as ae,k as oe,q as w,r as se,rt as ce,u as T,wt as le,x as E,y as ue,zt as de}from"./model-profiles-C7nNtymU.js";import{_ as fe,d as pe}from"./session-store-BU0hS2_b.js";import{A as me,C as he,D as ge,E as _e,M as ve,N as ye,O as be,S as xe,T as Se,_ as Ce,a as we,b as Te,c as Ee,d as De,f as Oe,g as ke,h as Ae,i as je,j as Me,k as Ne,l as Pe,m as Fe,n as D,o as Ie,p as Le,r as Re,s as ze,t as Be,u as Ve,v as He,w as Ue,x as We,y as Ge}from"./todo-model-BKnA8C59.js";import{$ as Ke,A as O,B as qe,D as Je,E as Ye,G as Xe,J as k,K as Ze,L as Qe,M as $e,N as et,O as tt,Q as nt,U as rt,V as it,W as at,X as ot,Z as st,_ as ct,et as lt,g as ut,j as A,k as dt,l as ft,q as pt,t as mt,v as ht,w as gt,y as _t}from"./version-BYHbQ47I.js";import{$ as vt,$n as yt,$t as bt,A as xt,An as St,Ar as Ct,At as wt,B as Tt,Bn as Et,Br as Dt,Bt as Ot,C as kt,Cn as At,Cr as jt,Ct as Mt,D as j,Dn as Nt,Dr as Pt,Dt as Ft,E as It,En as Lt,Er as Rt,Et as zt,F as Bt,Fn as Vt,Fr as Ht,Ft as Ut,G as Wt,Gn as Gt,Gr as Kt,Gt as qt,H as Jt,Hn as Yt,Hr as Xt,Ht as Zt,I as Qt,In as $t,Ir as en,It as tn,J as nn,Jn as rn,Jr as an,Jt as on,K as sn,Kn as cn,Kr as ln,Kt as un,L as dn,Ln as fn,Lr as pn,Lt as mn,M as hn,Mn as gn,Mr as _n,Mt as vn,N as yn,Nn as bn,Nr as xn,Nt as Sn,O as Cn,On as wn,Or as Tn,Ot as En,P as Dn,Pn as On,Pr as kn,Pt as An,Q as jn,Qn as Mn,Qt as Nn,R as Pn,Rn as Fn,Rr as In,Rt as Ln,S as Rn,Sn as zn,St as Bn,T as Vn,Tn as Hn,Tr as Un,Tt as Wn,U as Gn,Un as Kn,Ur as qn,Ut as Jn,Vn as Yn,Vr as Xn,Vt as Zn,W as Qn,Wn as $n,Wr as er,Wt as tr,X as nr,Xn as rr,Xt as ir,Y as ar,Yn as or,Yt as sr,Z as cr,Zn as lr,Zt as ur,_ as dr,_r as fr,_t as pr,a as mr,an as hr,ar as gr,at as _r,b as vr,bn as yr,br,bt as xr,c as Sr,cn as Cr,cr as wr,ct as Tr,d as Er,dn as Dr,dr as Or,dt as kr,en as Ar,er as jr,et as Mr,f as Nr,fn as Pr,fr as Fr,ft as Ir,g as Lr,gn as Rr,gr as zr,gt as Br,h as Vr,hn as Hr,hr as Ur,ht as Wr,i as Gr,in as Kr,ir as qr,it as Jr,j as Yr,jn as Xr,jr as Zr,jt as Qr,k as $r,kn as ei,kr as ti,kt as ni,l as ri,lr as ii,lt as ai,m as oi,mn as si,mr as ci,mt as li,n as ui,nn as di,nr as fi,nt as pi,o as mi,on as hi,or as gi,ot as _i,p as vi,pn as yi,pr as bi,q as xi,qn as Si,qr as Ci,qt as wi,r as Ti,rn as Ei,rt as Di,s as Oi,sn as ki,sr as Ai,st as ji,t as Mi,tn as Ni,tr as Pi,tt as Fi,u as Ii,un as Li,ur as Ri,ut as zi,v as Bi,vn as Vi,vr as Hi,vt as Ui,w as Wi,wn as Gi,wr as Ki,wt as qi,x as Ji,xn as Yi,xr as Xi,xt as Zi,y as Qi,yn as $i,yr as ea,yt as ta,z as na,zn as ra,zr as ia,zt as aa}from"./context-indicator-O2JgFDbD.js";import{o as oa}from"./agent-store-_CfonCwg.js";import{O as sa,b as ca,l as la,p as ua,v as da}from"./workspace-manager-DLH5XabD.js";var fa=`panel-observer-`,pa=new Map,ma=new Set;function ha(e){typeof e==`function`&&ma.add(e)}function ga(e){if(!e)return null;let t=pa.get(e);if(t)return t;let n;try{n=chrome.runtime.connect({name:`${fa}${e}`})}catch(e){return r.debug(`[PanelObserver] 建立观察端口失败(忽略):`,e?.message||e),null}pa.set(e,n);try{n.onMessage.addListener(e=>{for(let t of ma)try{t(e)}catch(e){r.debug(`[PanelObserver] 消息处理异常(忽略):`,e?.message||e)}})}catch(e){r.debug(`[PanelObserver] 观察端口消息监听挂不上(忽略):`,e?.message||e)}try{n.onDisconnect.addListener(()=>{pa.get(e)===n&&pa.delete(e)})}catch(e){r.debug(`[PanelObserver] 观察端口断开监听挂不上(忽略):`,e?.message||e)}return n}function _a(e){if(!e)return;let t=pa.get(e);if(t){pa.delete(e);try{t.disconnect()}catch(e){r.debug(`[PanelObserver] 关闭观察端口异常(忽略):`,e?.message||e)}}}function va({sessionId:e,callId:t,renderer:n,persist:i,onFinished:a=()=>{},emptyFallback:o=``,awaitSnapshot:s=!1}){let c=``,l=!1,u=s,d=[],f=n=>!!n&&n.sessionId===e&&n.callId===t,p=e=>{let t=[];for(let n of e){let e=t[t.length-1];n.type===`STREAM_CHUNK`&&e&&e.type===`STREAM_CHUNK`?t[t.length-1]={...n,delta:(e.delta||``)+(n.delta||``)}:t.push(n)}return t},m=()=>{u=!1;let e=p(d);d=[];for(let t of e)g(t)},h=e=>{l=!0,Promise.resolve().then(()=>i(e)).catch(e=>r.warn(`[ChatReattach] 终态落库失败(忽略):`,e?.message||e)).then(()=>{try{a()}catch{}})};return{sessionId:e,callId:t,get finished(){return l},dispose(){l=!0},restore(e){if(!u)return;u=!1;let r=!!e&&e.callId===t,i=r&&typeof e.accumulated==`string`?e.accumulated:``,a=r&&!!e.html;a&&n.restore?.({html:e.html}),c=i,i&&!a&&n.chunk?.(i);let o=p(d);d=[];for(let e of o)g(e)},handleMessage(e){return l||!f(e)?!1:u?e.type===`STREAM_CHUNK`?(d.push(e),!0):e.type===`API_COMPLETE`||e.type===`API_ERROR`?(m(),g(e)):(d.push(e),!0):g(e)}};function g(r){switch(r.type){case`STREAM_START`:return c=``,n.start?.(),!0;case`STREAM_CHUNK`:return c+=r.delta||``,n.chunk?.(c),!0;case`STREAM_TOOL_CALL`:return n.toolCalls?.(r.toolCalls||[],c),!0;case`STREAM_TOOL_RESULT`:return r.result&&n.toolResult?.(r.result),!0;case`AGENT_STREAM`:return r.execId&&n.agentStream?.(r),!0;case`AGENT_STREAM_DONE`:return r.execId&&n.agentStreamDone?.(r),!0;case`API_RETRYING`:return n.retrying?.(r.attempt,r.maxRetries),!0;case`STREAM_PRESELECT`:return n.preselect?.(r.preselectLog||[]),!0;case`EXECUTION_STATUS_UPDATE`:return!0;case`API_COMPLETE`:{let i=r.content&&String(r.content).trim()?r.content:o||c,a=r.executionLog||[],s={reflectionScore:r.reflectionScore,reasoningContent:r.reasoningContent||null,wasRevised:r.wasRevised||!1,budgetEnded:r.budgetEnded===!0};return n.final?.(i,a,s),h({sessionId:e,callId:t,content:i,executionLog:a,...s}),!0}case`API_ERROR`:return n.error?.(r.error||``,r.executionLog||[]),h({sessionId:e,callId:t,error:r.error||``,executionLog:r.executionLog||[]}),!0;default:return!1}}}function ya({queryRunning:e,hasLocalListener:t,isAttached:n,attach:i}){return{async syncFromBackground(){try{let r=await e(),a=r&&r.activeCallIds?r.activeCallIds:{};for(let[e,r]of Object.entries(a))!e||!r||t(e)||n(e,r)||i(e,r)}catch(e){r.debug(`[ChatReattach] 查询后台运行状态失败(忽略):`,e?.message||e)}}}}var ba=!1,xa=new Map,Sa=null,Ca=!1,wa=null,Ta=null,Ea=null,Da=250,Oa=new Set([`STREAM_START`,`STREAM_CHUNK`,`STREAM_TOOL_CALL`,`STREAM_TOOL_RESULT`,`AGENT_STREAM`,`AGENT_STREAM_DONE`,`API_RETRYING`,`STREAM_PRESELECT`,`EXECUTION_STATUS_UPDATE`,`API_COMPLETE`,`API_ERROR`]);function ka(e=0){return new Promise((t,n)=>{let r=!1,i=null,a=(e,t)=>{r||(r=!0,i&&clearTimeout(i),e(t))};e>0&&(i=setTimeout(()=>a(t,{}),e));try{chrome.runtime.sendMessage({type:`QUERY_SESSION_RUNNING`},e=>{if(chrome.runtime.lastError){a(n,Error(chrome.runtime.lastError.message));return}a(t,e||{})})}catch(e){a(n,e)}})}function Aa(e,t){let n=new Map;return{start(){zt(e,``),Wn(``),Ft(Date.now()),ji(t),Mt(t)},chunk(n){zt(e,n),En(t,n)},restore({html:e}){zi(t,e)},toolCalls(e,n){typeof n==`string`&&n&&Bn(t,n),Tr(t,e)},toolResult(e){ai(e,t)},agentStream(e){Zi(t,n),kr(n,t,e)},agentStreamDone(e){let t=n.get(e.execId);t&&t.element&&e.exitCode!==0&&t.element.classList.add(`agent-stream-error`)},retrying(e,n){Ui(t,e,n)},preselect(e){let n=t.querySelector(`.message-content`);!n||!e.length||e.forEach(e=>n.insertBefore(li(e),n.firstChild))},final(e,n,r={}){pr(t,e,n,r.reflectionScore,r.reasoningContent,r.wasRevised)},error(e,n){pr(t,e,n||[])}}}async function ja(e,t,n){let r=!!e.error,i={role:`assistant`,content:r?e.error:e.content||``,executionLog:e.executionLog||[],reflectionScore:e.reflectionScore,wasRevised:e.wasRevised||!1,callId:e.callId,resumed:!0,resumable:e.budgetEnded?`budget`:!1};if(!r&&n&&(i.messageId=n.dataset.messageId||void 0,i.htmlContent=n.dataset.htmlContent||n.outerHTML),v.activeSessionId===t){v.messageHistory.push(i);try{document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:t}}))}catch{}}let{appendMessageToSession:a}=await E(async()=>{let{appendMessageToSession:e}=await import(`./context-indicator-O2JgFDbD.js`).then(e=>e.Sr);return{appendMessageToSession:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));await a(t,i)}function Ma(){E(()=>import(`./context-indicator-O2JgFDbD.js`).then(e=>e.V).then(e=>e.syncPendingSessionsToStorage()),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).catch(e=>r.debug(`[ChatReattach] 同步生成态失败(忽略):`,e?.message||e))}var Na=1e3;function Pa(e){return Promise.race([ni(e),new Promise(e=>setTimeout(()=>e(null),Na))])}function Fa(e,n){let i=Wr(e);if(i())return!1;let a=_i(e);a.dataset.callId=n,i(a),zt(e,``),Ft(Date.now()),qi(Date.now()),v.pendingCallApiSessionIds.add(e),v.generatingSessionIds.add(e),Ma();try{document.dispatchEvent(new CustomEvent(`generating-state-changed`))}catch{}let o=va({sessionId:e,callId:n,awaitSnapshot:!0,renderer:Aa(e,a),persist:t=>ja(t,e,a),emptyFallback:t(`chatMsg.emptyModelReply`),onFinished:()=>{if(xa.get(e)===o){xa.delete(e),_a(e),v.pendingCallApiSessionIds.delete(e),Ma(),Br(e);try{document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:e}}))}catch{}Si(e)}}});return xa.set(e,o),ga(e),Pa(e).then(t=>{o.finished||xa.get(e)!==o||o.restore(t)}).catch(()=>o.restore(null)),v.activeSessionId===e&&ta(e),r.info(`[ChatReattach] 已接管运行中的任务: sessionId=${e}, callId=${n}`),!0}function Ia(e){let t=xa.get(e);if(!t)return;xa.delete(e),_a(e);try{t.dispose?.()}catch{}let n=Wr(e),r=n();try{r?.remove()}catch{}n(null),Br(e),v.pendingCallApiSessionIds.delete(e),Ma();try{document.dispatchEvent(new CustomEvent(`generating-state-changed`))}catch{}}function La(){let e=Sa;e&&Promise.resolve().then(()=>e.syncFromBackground()).catch(e=>r.debug(`[ChatReattach] 对齐后台状态失败(忽略):`,e?.message||e))}function Ra(){!ba||!Sa||Ea||(Ea=setTimeout(()=>{Ea=null,La()},Da))}var za=new Map,Ba=3e3,Va=100,Ha=new Set,Ua=new Set([`API_COMPLETE`,`API_ERROR`]);function Wa(e,t){let n=`${e}|${t.callId}`;Ha.has(n)||(Ha.add(n),Ha.size>Va&&Ha.delete(Ha.values().next().value),Ia(e),Fa(e,t.callId)&&xa.get(e)?.handleMessage(t))}function Ga(e,t,n){let r=za.get(e);if(r){r.messages.push(n);return}r={callId:t,messages:[n]},za.set(e,r),ka(Ba).then(t=>Ka(e,t&&t.activeCallIds&&t.activeCallIds[e]||null)).catch(()=>Ka(e,null)).finally(()=>{za.delete(e)})}function Ka(e,t){let n=za.get(e);if(!n)return;let{callId:r,messages:i}=n;if(t===r)Ia(e),Fa(e,r);else if(t===null){let t=i.find(e=>Ua.has(e.type));if(!t)return;Wa(e,t);return}else return;let a=xa.get(e);if(!(!a||a.callId!==r))for(let e of i){if(a.finished)break;a.handleMessage(e)}}function qa(){if(Ca)return;Ca=!0;let e=e=>{if(!e)return!1;let t=e.sessionId?xa.get(e.sessionId):null;return t?e.callId&&e.callId!==t.callId?(Ga(e.sessionId,e.callId,e),!1):(ga(e.sessionId),t.handleMessage(e),!1):(e.callId&&Oa.has(e.type)&&Ra(),!1)};chrome.runtime.onMessage.addListener(e),ha(e),wa=e=>{let t=e?.detail?.sessionId;t&&xa.has(t)&&ta(t),Ra()},document.addEventListener(`session-hydrated`,wa),Ta=e=>{let t=e?.detail?.sessionId;t&&xa.has(t)&&ta(t)},document.addEventListener(`chat-history-rendered`,Ta)}function Ja(){return ba?{syncFromBackground:()=>Sa.syncFromBackground()}:(ba=!0,qa(),Sa=ya({queryRunning:ka,hasLocalListener:e=>v.pendingCancelApiMap.has(e),isAttached:(e,t)=>xa.get(e)?.callId===t?(ga(e),!0):!1,attach:(e,t)=>{Fa(e,t)}}),Sa.syncFromBackground(),{syncFromBackground:()=>Sa.syncFromBackground()})}function Ya(e){!ba||!Sa||(e&&v.activeSessionId===e&&ta(e),Sa.syncFromBackground())}e(`zh`,{dock:{ariaLabel:`执行中会话`,running:`正在执行`,node:`正在执行:{node}`,subtask:`子任务 {index}/{total}`,queued:`排队 {count} 条`,done:`已完成,点击查看结果`,doneAt:`已完成 {time}`,scheduled:`定时任务`,dismiss:`从停靠条移除`,dismissStale:`移除失效条目`,stale:`状态可能已失效 · 未在限定时间内收到执行更新`,more:`还有 {count} 个`,moreAria:`还有 {count} 个未显示的执行条目`,overflowTitle:`其他执行中的会话`,openSession:`点击进入该会话`,unknownSession:`未知会话`}}),e(`en`,{dock:{ariaLabel:`Running sessions`,running:`Running`,node:`Running: {node}`,subtask:`Subtask {index}/{total}`,queued:`{count} queued`,done:`Finished — click to review`,doneAt:`Finished {time}`,scheduled:`Scheduled task`,dismiss:`Remove from dock`,dismissStale:`Remove stale entry`,stale:`Status may be stale · no execution update in time`,more:`+{count} more`,moreAria:`{count} more running entries not shown`,overflowTitle:`Other active sessions`,openSession:`Click to open this session`,unknownSession:`Unknown session`}});var Xa=`sessionDockDismissed`,Za=5e3,Qa=250,$a=1200,eo=8,to=eo-1,no=9e4,ro={running:0,queued:1,done:2},io=new Map,ao=new Map,oo=new Map,so=new Map,co=new Set,lo=new Set,uo=new Map,fo=new Map,po=new Set,mo=new Set,ho=[],go=new Set,M=null,N=null,P=null,_o=[],vo=!1,yo=null,bo=null,xo=!1,So=null,Co=null;function wo(e){return e?Array.isArray(e)?e:e instanceof Set?Array.from(e):[]:[]}function To(e){let t=new Set;for(let n of wo(e))n&&t.add(h(String(n))||String(n));return t}function Eo({phase:e=``,sessionId:t=null,backendRunningIds:n=[],startedAt:r=0,lastUpdateAt:i=0,now:a=Date.now(),staleMs:o=no}={}){if(e!==`running`||!t||wo(n).includes(t))return!1;let s=Math.max(Number(r)||0,Number(i)||0);return s?a-s>=o:!1}var Do=160;function Oo(e){let t=String(e??``).replace(/\s+/g,` `).trim();if(!t)return``;let n=Array.from(t);return n.length<=Do?t:`${n.slice(0,Do).join(``).trimEnd()}…`}function ko(e,t){let n=e=>String(e??``).trim().replace(/[…\s.]+$/,``).replace(/\s+/g,``),r=n(e),i=n(t);return!r||!i?!1:r===i||i.startsWith(r)||r.startsWith(i)}function Ao({phase:e=``,queuedText:t=``,questionText:n=``,title:r=``}={}){let i=e===`queued`?Oo(t):``,a=i||Oo(n),o=Oo(r),s=a||o,c=i?`queued`:a?`question`:s?`title`:``;return{primary:s,sub:a&&!ko(o,a)?o:``,isQuestion:!!a,from:c}}function jo(e){let t=Array.isArray(e?.messageHistory)?e.messageHistory:[];for(let e=t.length-1;e>=0;--e){let n=t[e];if(!n||n.role!==`user`)continue;let r=ae(n.content);if(r&&String(r).trim())return{text:String(r),messageId:n.messageId?String(n.messageId):``}}return{text:``,messageId:``}}function Mo({activeSessionId:e=null,titles:t={},questions:n={},anchors:r={},queuedTexts:i={},generatingIds:a=[],pendingIds:o=[],runningIds:s=[],completedIds:c=[],queuedCounts:l={},scheduledIds:u=[],dismissedIds:d=[],nodeInfo:f={},startedAt:p={},doneAt:m={},lastUpdateAt:h={},now:g=Date.now(),staleMs:ee=no}={}){let te=wo(s),ne=new Set([...wo(a),...wo(o),...te]),_=new Set(wo(c)),v=new Set(wo(d)),re=new Set(wo(u)),y=l||{},b=new Set([...ne,..._,...Object.keys(y)]),x=[];for(let a of b){if(!a||a===e)continue;let o=Number(y[a])||0,s;if(ne.has(a))s=`running`;else if(o>0)s=`queued`;else if(_.has(a))s=`done`;else continue;let c=Eo({phase:s,sessionId:a,backendRunningIds:te,startedAt:p?.[a],lastUpdateAt:h?.[a],now:g,staleMs:ee});if(v.has(a)&&(s===`done`||c))continue;let l=f?.[a]||{},u=Ao({phase:s,queuedText:i?.[a]||``,questionText:n?.[a]||``,title:t?.[a]||``});x.push({sessionId:a,title:t?.[a]||``,primary:u.primary,sub:u.sub,isQuestion:u.isQuestion,anchorMessageId:u.from===`question`?String(r?.[a]||``):``,phase:s,stale:c,source:re.has(a)?`scheduled`:`chat`,queuedCount:o,nodeName:l.nodeName||``,subtaskIndex:l.subtaskIndex||0,subtaskTotal:l.subtaskTotal||0,startedAt:p?.[a]||0,doneAt:m?.[a]||0,lastUpdateAt:h?.[a]||0})}return x.sort((e,t)=>{let n=ro[e.phase]-ro[t.phase];if(n!==0)return n;if(e.stale!==t.stale)return e.stale?1:-1;let r=e.phase===`done`?e.doneAt:e.startedAt,i=t.phase===`done`?t.doneAt:t.startedAt;return r===i?String(e.sessionId).localeCompare(String(t.sessionId)):i-r}),x}function No(e){return mo.has(e)||v.generatingSessionIds.has(e)||v.pendingCallApiSessionIds.has(e)}function Po(){let e={};try{let t=Zr();for(let n of t){let t=Tn(n);t>0&&(e[n]=t)}}catch(e){r.debug(`[SessionDock] read queue counts failed:`,e?.message||e)}return e}function Fo(){let e={};for(let t of v.sessions||[])e[t.id]=t.title||``;for(let[t,n]of uo)e[t]||(e[t]=n);return e}function Io(){let e={},t={},n=new Map;for(let e of v.sessions||[])n.set(e.id,e);for(let r of new Set([...mo,...v.generatingSessionIds,...v.pendingCallApiSessionIds,...v.completedSessionIds])){let i=ao.get(r)||oo.get(r)||0,a=fo.get(r);if(i&&a&&a.stamp===i){a.text&&(e[r]=a.text,t[r]=a.messageId||``);continue}let o=jo(n.get(r));o.text&&(e[r]=o.text,t[r]=o.messageId)}return{questions:e,anchors:t}}function Lo(){let e={};try{for(let t of Zr()){let n=_n(t);n?.text&&(e[t]=String(n.text))}}catch(e){r.debug(`[SessionDock] read queued texts failed:`,e?.message||e)}return e}function Ro(e){for(let t of e||[]){let e=t.sessionId;if(!e)continue;let n=t.startedAt||t.doneAt||0,i=fo.get(e),a=!i||i.stamp!==n,o=!t.title;!a&&!o||po.has(e)||(po.add(e),y(e).then(t=>{if(t&&((o||!uo.has(e))&&uo.set(e,t.title||``),a)){let r=jo(t);fo.set(e,{text:r.text,messageId:r.messageId,stamp:n})}}).catch(e=>{r.debug(`[SessionDock] hydrate label failed:`,e?.message||e)}).finally(()=>{po.delete(e),F()}))}}function zo(e){if(!e)return``;let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function Bo(e){if(e.phase===`running`){if(e.stale)return t(`dock.stale`);let n=e.nodeName?t(`dock.node`,{node:e.nodeName}):t(`dock.running`);return e.subtaskTotal>1?`${n} · ${t(`dock.subtask`,{index:e.subtaskIndex,total:e.subtaskTotal})}`:n}return e.phase===`queued`?t(`dock.queued`,{count:e.queuedCount}):e.doneAt?t(`dock.doneAt`,{time:zo(e.doneAt)}):t(`dock.done`)}function Vo(){let e=v.completedSessionIds;for(let e of new Set([...mo,...v.generatingSessionIds,...v.pendingCallApiSessionIds]))ao.has(e)||ao.set(e,Date.now()),oo.delete(e);for(let e of mo)lo.delete(e);for(let t of e)!oo.has(t)&&!No(t)&&oo.set(t,Date.now());let{questions:t,anchors:n}=Io(),r=Mo({activeSessionId:v.activeSessionId,titles:Fo(),questions:t,anchors:n,queuedTexts:Lo(),generatingIds:v.generatingSessionIds,pendingIds:v.pendingCallApiSessionIds,runningIds:mo,completedIds:e,queuedCounts:Po(),scheduledIds:co,dismissedIds:lo,nodeInfo:Object.fromEntries(io),startedAt:Object.fromEntries(ao),doneAt:Object.fromEntries(oo),lastUpdateAt:Object.fromEntries(so),now:Date.now()});return Ro(r),r}function Ho(e){let t=new Set(ho.filter(e=>e.phase===`done`).map(e=>e.sessionId)),n=e.filter(e=>e.phase===`done`&&!t.has(e.sessionId)).map(e=>e.sessionId);n.length!==0&&(go=new Set(n),So&&clearTimeout(So),So=setTimeout(()=>{So=null,go=new Set,F()},$a))}function Uo(){if(M||typeof document>`u`)return M;M=document.createElement(`div`),M.className=`session-dock`,M.id=`sessionDock`,M.setAttribute(`role`,`navigation`),document.body.appendChild(M),N=document.createElement(`div`),N.className=`session-dock-tip`,document.body.appendChild(N),Wo();let e=document.getElementById(`chatContainer`);return e&&typeof ResizeObserver<`u`&&new ResizeObserver(Wo).observe(e),window.addEventListener(`resize`,Wo),M}function Wo(){if(!M)return;let e=document.getElementById(`chatContainer`);if(!e)return;let t=e.getBoundingClientRect();M.style.top=`${Math.max(0,Math.round(t.top+8))}px`}function Go(e){Pi(e.sessionId,{focusMessageId:e.anchorMessageId||null})}function Ko(e){let n=document.createElement(`div`);n.className=`session-dock-item`,n.dataset.sessionId=e.sessionId,n.dataset.phase=e.phase,e.stale&&(n.dataset.stale=`true`),go.has(e.sessionId)&&n.classList.add(`is-flash`);let r=e.title||t(`dock.unknownSession`),i=e.primary||r,a=Bo(e),o=e.phase===`done`?`✓`:Array.from(r)[0]||`?`,s=document.createElement(`button`);if(s.type=`button`,s.className=`session-dock-chip`,s.setAttribute(`aria-label`,`${i} · ${a}`),s.title=``,s.textContent=o,s.addEventListener(`click`,()=>{Go(e)}),n.appendChild(s),e.queuedCount>0&&e.phase!==`done`){let t=document.createElement(`span`);t.className=`session-dock-badge`,t.textContent=String(e.queuedCount>99?`99+`:e.queuedCount),n.appendChild(t)}if(e.source===`scheduled`){let e=document.createElement(`span`);e.className=`session-dock-clock`,n.appendChild(e)}if(e.phase===`done`||e.stale){let r=document.createElement(`button`);r.type=`button`,r.className=`session-dock-dismiss`;let i=e.stale?t(`dock.dismissStale`):t(`dock.dismiss`);r.setAttribute(`aria-label`,i),r.title=i,r.textContent=`×`,r.addEventListener(`click`,t=>{t.stopPropagation(),as(e.sessionId)}),n.appendChild(r)}return n.addEventListener(`mouseenter`,()=>qo(n,e,a)),n.addEventListener(`mouseleave`,Jo),n.addEventListener(`focusin`,()=>qo(n,e,a)),n.addEventListener(`focusout`,Jo),n}function qo(e,n,r){if(!N)return;N.innerHTML=``;let i=document.createElement(`div`);i.className=`session-dock-tip-title`,i.textContent=n.primary||n.title||t(`dock.unknownSession`);let a=document.createElement(`div`);if(a.className=`session-dock-tip-status`,a.textContent=r,N.appendChild(i),n.sub){let e=document.createElement(`div`);e.className=`session-dock-tip-sub`,e.textContent=n.sub,N.appendChild(e)}N.appendChild(a);let o=e.getBoundingClientRect();N.style.top=`${Math.round(o.top)}px`,N.style.left=`${Math.round(o.right+8)}px`,N.classList.add(`show`)}function Jo(){N&&N.classList.remove(`show`)}function Yo(){return P||typeof document>`u`?P:(P=document.createElement(`div`),P.className=`session-dock-overflow`,P.setAttribute(`role`,`menu`),P.addEventListener(`mouseenter`,Xo),P.addEventListener(`mouseleave`,Zo),P.addEventListener(`focusin`,Xo),P.addEventListener(`focusout`,Zo),document.body.appendChild(P),P)}function Xo(){Co&&=(clearTimeout(Co),null)}function Zo(){vo||(Xo(),Co=setTimeout(()=>{Co=null,ns()},220))}function Qo(){let e=M?M.querySelector(`.session-dock-more`):null;e&&(e.setAttribute(`aria-expanded`,vo?`true`:`false`),e.classList.toggle(`is-open`,vo))}function $o(){let e=Yo();if(!e)return;e.innerHTML=``;let n=document.createElement(`div`);n.className=`session-dock-overflow-header`,n.textContent=t(`dock.overflowTitle`),e.appendChild(n);let r=document.createElement(`div`);r.className=`session-dock-overflow-list`;for(let e of _o){let n=e.primary||e.title||t(`dock.unknownSession`),i=Bo(e),a=document.createElement(`button`);a.type=`button`,a.className=`session-dock-overflow-row`,a.dataset.phase=e.phase,e.stale&&(a.dataset.stale=`true`),a.setAttribute(`aria-label`,`${n} · ${i}`);let o=document.createElement(`span`);o.className=`session-dock-overflow-title`,o.textContent=n;let s=document.createElement(`span`);s.className=`session-dock-overflow-status`,s.textContent=i,a.appendChild(o),a.appendChild(s),a.addEventListener(`click`,()=>{ns(),Go(e)}),r.appendChild(a)}e.appendChild(r)}function es(){if(!P||!M)return;let e=M.querySelector(`.session-dock-item--more`);if(!e)return;let t=e.getBoundingClientRect();P.style.left=`${Math.round(t.right+8)}px`;let n=P.offsetHeight||0,r=Math.max(8,window.innerHeight-n-8);P.style.top=`${Math.round(Math.min(Math.max(8,t.top),r))}px`}function ts(){_o.length!==0&&Yo()&&(Xo(),$o(),es(),P.classList.add(`show`),Qo())}function ns(){Xo(),vo=!1,P&&P.classList.remove(`show`),Qo()}function rs(){if(P&&P.classList.contains(`show`)&&vo){ns();return}ts(),vo=!0,Qo()}function is(e){let n=document.createElement(`div`);n.className=`session-dock-item session-dock-item--more`,n.dataset.count=String(e.length);let r=document.createElement(`button`);return r.type=`button`,r.className=`session-dock-chip session-dock-more`,r.setAttribute(`aria-label`,t(`dock.moreAria`,{count:e.length})),r.setAttribute(`aria-expanded`,vo?`true`:`false`),r.textContent=`+${e.length>99?`99`:e.length}`,r.addEventListener(`click`,()=>rs()),n.appendChild(r),n.addEventListener(`mouseenter`,()=>ts()),n.addEventListener(`mouseleave`,Zo),n.addEventListener(`focusin`,()=>ts()),n.addEventListener(`focusout`,Zo),n}function as(e){e&&(lo.add(e),os(),F())}function os(){try{chrome.storage.local.set({[Xa]:Array.from(lo)}).catch(()=>{})}catch{}}function ss(){try{chrome.storage.local.get([Xa],e=>{let t=e?.[Xa];if(Array.isArray(t)){for(let e of t)lo.add(e);F()}})}catch{}}function cs(){if(!Uo())return;let e=Vo();if(Ho(e),ho=e,ns(),_o=[],M.innerHTML=``,e.length===0){M.classList.remove(`show`),document.body.classList.remove(`has-session-dock`),Jo();return}let t=e.length>eo?to:eo;_o=e.slice(t);for(let n of e.slice(0,t))M.appendChild(Ko(n));_o.length>0&&M.appendChild(is(_o)),M.classList.add(`show`),document.body.classList.add(`has-session-dock`)}function F(){yo||=setTimeout(()=>{yo=null;try{cs()}catch(e){r.warn(`[SessionDock] render failed:`,e?.message||e)}},Qa)}function ls(){return new Promise(e=>{try{chrome.runtime.sendMessage({type:`QUERY_SESSION_RUNNING`},t=>{if(chrome.runtime.lastError||!t){e();return}Array.isArray(t.activeSessionIds)&&(mo=To(t.activeSessionIds)),e()})}catch{e()}})}function us(e){let t=e?.sessionId;if(!t)return;let n=io.get(t)||{};io.set(t,{nodeName:e.nodeName||n.nodeName||``,subtaskIndex:e.subtaskIndex||n.subtaskIndex||0,subtaskTotal:e.subtaskTotal||n.subtaskTotal||0}),so.set(t,Date.now()),F()}function ds(e){e&&(io.delete(e),ao.delete(e),oo.delete(e),so.delete(e),lo.delete(e),uo.delete(e),fo.delete(e),F())}function fs(){if(!(xo||typeof document>`u`||!Uo())){xo=!0,ss(),document.addEventListener(`generating-state-changed`,F),document.addEventListener(`session-switched`,F),document.addEventListener(`generation-ended`,e=>{let t=e?.detail?.sessionId;t&&!oo.has(t)&&oo.set(t,Date.now()),F()}),document.addEventListener(`session-archived`,e=>ds(e?.detail?.sessionId)),document.addEventListener(`session-deleted`,e=>ds(e?.detail?.sessionId));try{In(F)}catch(e){r.debug(`[SessionDock] subscribe queue failed:`,e?.message||e)}try{chrome.runtime.onMessage.addListener(e=>e?e.type===`EXECUTION_STATUS_UPDATE`?(us(e),!1):e.type===`SCHEDULED_TASK_RUN_STATE`&&e.sessionId?(e.running?co.add(e.sessionId):co.delete(e.sessionId),F(),!1):(e.type===`SCHEDULED_SESSION_UPDATED`&&F(),!1):!1)}catch(e){r.debug(`[SessionDock] register runtime listener failed:`,e?.message||e)}document.addEventListener(`visibilitychange`,()=>{if(document.hidden){ns();return}ls().then(F)}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&vo&&ns()}),bo||=setInterval(()=>{document.hidden||ls().then(F)},Za),ls().then(()=>{for(let e of mo)ao.has(e)||ao.set(e,Date.now());cs()})}}function ps(){let e=document.getElementById(`chatNavUp`),n=document.getElementById(`chatNavDown`),r=document.getElementById(`chatNavHotzone`),i=document.getElementById(`chatNavButtons`),a=document.getElementById(`chatNavQuestionPanel`),o=[],s=!1,c=null,l=``,u=!1,d=!1;function f(e){let t=document.getElementById(`chatContainer`);if(!t)return-1;let n=t.getBoundingClientRect();return et(e,n.top,n.bottom)}function p(e,t){let n=document.getElementById(`chatContainer`);if(!n)return`noop`;let r=Ye(n);if(r.length===0)return`noop`;let i=n.getBoundingClientRect().top;if(t){if(e===`prev`)r[0].start.scrollIntoView({behavior:`smooth`,block:`start`});else{let e=r[r.length-1].elements;e[e.length-1].scrollIntoView({behavior:`smooth`,block:`end`})}return`jumped`}let a=pt(r.length,$e(r,i),e);return a===null?(m(e),`blocked`):(r[a].start.scrollIntoView({behavior:`smooth`,block:`start`}),`jumped`)}function m(t){let r=t===`prev`?e:n;r&&(r.classList.remove(`blocked`),r.offsetWidth,r.classList.add(`blocked`),r.addEventListener(`animationend`,()=>r.classList.remove(`blocked`),{once:!0}))}function h(e,n){let r=a.querySelectorAll(`.chat-nav-question-item`);r.forEach(t=>{Number(t.dataset.groupIndex)===e?(t.classList.add(`current`),t.setAttribute(`aria-current`,`true`)):(t.classList.remove(`current`),t.setAttribute(`aria-current`,`false`))});let i=a.querySelector(`.chat-nav-question-header .count`);i&&(i.textContent=t(`chat.navPosition`,{current:e>=0?e+1:n,total:n}));let o=Array.from(r).find(t=>Number(t.dataset.groupIndex)===e);!d&&e>=0&&o&&o.scrollIntoView({block:`nearest`})}function g(){if(!a||!a.classList.contains(`expanded`))return;o=Ye(document.getElementById(`chatContainer`));let e=l?Ye(document.getElementById(`chatContainer`)).length:a.querySelectorAll(`.chat-nav-question-item`).length;if(o.length===0){a.innerHTML=``,a.classList.remove(`expanded`);return}if(!l&&e!==o.length){ee();return}h(f(o),o.length)}function ee(){if(!a)return!1;if(o=Ye(document.getElementById(`chatContainer`)),o.length===0)return a.innerHTML=``,!1;let e=f(o),t=document.activeElement===a.querySelector(`[data-role="nav-search"]`);a.innerHTML=Ze(o,e,s,l),a.querySelector(`.chat-nav-pin`).addEventListener(`click`,e=>{e.stopPropagation(),b()});let n=a.querySelector(`[data-role="nav-search"]`);if(n){let e=()=>{l!==n.value&&(l=n.value,ee())};n.addEventListener(`input`,t=>{t.isComposing||e()}),n.addEventListener(`compositionend`,e),t&&(n.focus(),n.setSelectionRange(n.value.length,n.value.length))}if(e>=0){let t=a.querySelector(`.chat-nav-question-item[data-group-index="${e}"]`);t&&t.scrollIntoView({block:`nearest`})}return!0}function te(){let e=document.activeElement;return e?[r,i,a].some(t=>t&&(t===e||t.contains(e))):!1}function ne(){i.classList.remove(`expanded`),a&&a.classList.remove(`expanded`)}function _(){let e=te();ne(),e&&r&&(u=!0,r.focus({preventScroll:!0}),u=!1)}function v(){if(clearTimeout(c),i.classList.add(`expanded`),a){if(a.classList.contains(`expanded`)){g();return}ee()?a.classList.add(`expanded`):a.classList.remove(`expanded`)}}function re(e){clearTimeout(c),!s&&(te()||(e?ne():c=setTimeout(ne,300)))}function y(e){if(s=e,r&&(r.classList.toggle(`pinned`,e),r.setAttribute(`aria-pressed`,String(e))),a){a.classList.toggle(`pinned`,e);let n=a.querySelector(`.chat-nav-pin`);if(n){let r=t(e?`chat.navUnpinLabel`:`chat.navPinLabel`);n.textContent=r,n.title=r,n.setAttribute(`aria-pressed`,String(e)),n.classList.toggle(`on`,e)}}}function b(){y(!s)}e&&e.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),p(`prev`,e.ctrlKey||e.metaKey),g()}),n&&n.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),p(`next`,e.ctrlKey||e.metaKey),g()}),r&&i&&(r.addEventListener(`mouseenter`,v),r.addEventListener(`mouseleave`,()=>re(!1)),r.addEventListener(`click`,()=>b()),r.addEventListener(`focus`,()=>{u||v()}),r.addEventListener(`blur`,()=>re(!1)),r.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),b())}),i.addEventListener(`mouseenter`,v),i.addEventListener(`mouseleave`,()=>re(!1)),i.addEventListener(`focusin`,v),a&&(a.addEventListener(`mouseenter`,()=>{d=!0,v()}),a.addEventListener(`mouseleave`,()=>{d=!1,re(!1)}),a.addEventListener(`focusin`,v),a.addEventListener(`keydown`,e=>{if(e.target.matches(`[data-role="nav-search"]`))return;let t=Array.from(a.querySelectorAll(`.chat-nav-question-item`));if(t.length===0)return;let n=t.indexOf(document.activeElement),r=null;e.key===`ArrowDown`?r=Math.min(n+1,t.length-1):e.key===`ArrowUp`?r=n<=0?0:n-1:e.key===`Home`?r=0:e.key===`End`&&(r=t.length-1),r!==null&&(e.preventDefault(),t[r].focus())}),a.addEventListener(`click`,e=>{let t=e.target.closest(`.chat-nav-question-item`);if(!t||!t.dataset.messageId)return;let n=o.find(e=>(e.userElement||e.start).dataset.messageId===t.dataset.messageId);if(!n)return;let r=n.userElement||n.start;r.scrollIntoView({behavior:`instant`,block:`start`}),r.classList.add(`bookmark-highlight`),setTimeout(()=>r.classList.remove(`bookmark-highlight`),2e3),s?g():_()})));{let e=document.getElementById(`chatContainer`);if(e){let t=!1;e.addEventListener(`scroll`,()=>{!a||!a.classList.contains(`expanded`)||t||(t=!0,requestAnimationFrame(()=>{t=!1,g()}))},{passive:!0})}}function x(){let e=a&&a.classList.contains(`expanded`);if(!s&&!e)return!1;if(a&&a.querySelector(`[data-role="nav-search"]`)&&l){l=``,ee();let e=a.querySelector(`[data-role="nav-search"]`);return e&&e.focus(),!0}return y(!1),_(),!0}return{jumpToMessage:p,updateActiveQuestion:g,handleEscape:x,isPinned:()=>s}}function ms(e){if(!e)return!1;let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;return!!(t&&t.closest&&t.closest(`#chatContainer, .message-fullscreen-body`))}e(`zh`,{searchPanel:{toggleTitle:`消息搜索`,title:`消息搜索`,closeTitle:`关闭`,inputPlaceholder:`搜索消息(支持 & | 组合搜索)...`,clearTitle:`清除`,globalSearchTitle:`在所有会话中搜索`,globalSearch:`全局搜索`,currentSessionTitle:`仅在当前会话中搜索`,currentSession:`当前会话`,startSearchHint:`输入关键词开始搜索`,searching:`搜索中...`,searchingWithCount:`搜索中... {count} 条`,searchError:`搜索出错`,noActiveSession:`没有活跃会话`,noSessionData:`没有会话数据`,noMatch:`未找到匹配消息`,unknownSession:`未知会话`,countResult:`{count} 条`,noResult:`无结果`,searchingSuffix:` (搜索中...)`,currentSessionResults:`当前会话{label} · {count} 条`,otherSessionsResults:`其他会话 · {count} 条`,roleUser:`你`,roleAssistant:`助手`,sessionNotExist:`会话已不存在`,messageDeleted:`消息已被删除`}}),e(`en`,{searchPanel:{toggleTitle:`Search messages`,title:`Message search`,closeTitle:`Close`,inputPlaceholder:`Search messages (supports & | combined search)...`,clearTitle:`Clear`,globalSearchTitle:`Search in all sessions`,globalSearch:`Global search`,currentSessionTitle:`Search in current session only`,currentSession:`Current session`,startSearchHint:`Enter keywords to start searching`,searching:`Searching...`,searchingWithCount:`Searching... {count} found`,searchError:`Search error`,noActiveSession:`No active session`,noSessionData:`No session data`,noMatch:`No matching messages found`,unknownSession:`Unknown session`,countResult:`{count} found`,noResult:`No results`,searchingSuffix:` (searching...)`,currentSessionResults:`Current session{label} · {count} found`,otherSessionsResults:`Other sessions · {count} found`,roleUser:`You`,roleAssistant:`Assistant`,sessionNotExist:`Session no longer exists`,messageDeleted:`Message has been deleted`}});var hs=!1,gs=!1,I=[],_s=``;function vs(){v.searchInputHistory=[],v.searchInputHistoryIndex=-1;try{chrome.storage.local.get([`searchInputHistory`],e=>{e.searchInputHistory&&(v.searchInputHistory=e.searchInputHistory)})}catch{}let e=document.createElement(`div`);e.className=`search-panel-container`,e.id=`searchPanelContainer`,e.innerHTML=`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/context-indicator-ZNMB0fDM.js","assets/chunk-CMxvf4Kt.js","assets/model-profiles-C7nNtymU.js","assets/i18n-XUUSwfZZ.js","assets/voice-shortcut-Dx863RGz.js","assets/session-store-BU0hS2_b.js","assets/version-DbUttEL9.js","assets/agent-store-_CfonCwg.js","assets/workspace-manager-DLH5XabD.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e,c as t,i as n,l as r,n as i,r as a,s as o}from"./i18n-XUUSwfZZ.js";import{A as s,At as c,Bt as l,Ht as u,J as d,Jt as f,L as p,Lt as m,M as h,Nt as g,Ot as ee,P as te,R as ne,U as _,b as v,c as re,ct as y,d as b,gt as x,ht as ie,i as S,it as C,jt as ae,k as oe,q as w,r as se,rt as ce,u as T,wt as le,x as E,y as ue,zt as de}from"./model-profiles-C7nNtymU.js";import{_ as fe,d as pe}from"./session-store-BU0hS2_b.js";import{A as me,C as he,D as ge,E as _e,M as ve,N as ye,O as be,S as xe,T as Se,_ as Ce,a as we,b as Te,c as Ee,d as De,f as Oe,g as ke,h as Ae,i as je,j as Me,k as Ne,l as Pe,m as Fe,n as D,o as Ie,p as Le,r as Re,s as ze,t as Be,u as Ve,v as He,w as Ue,x as We,y as Ge}from"./todo-model-BKnA8C59.js";import{$ as Ke,A as O,B as qe,D as Je,E as Ye,G as Xe,J as k,K as Ze,L as Qe,M as $e,N as et,O as tt,Q as nt,U as rt,V as it,W as at,X as ot,Z as st,_ as ct,et as lt,g as ut,j as A,k as dt,l as ft,q as pt,t as mt,v as ht,w as gt,y as _t}from"./version-DbUttEL9.js";import{$ as vt,$n as yt,$t as bt,A as xt,An as St,Ar as Ct,At as wt,B as Tt,Bn as Et,Br as Dt,Bt as Ot,C as kt,Cn as At,Cr as jt,Ct as Mt,D as j,Dn as Nt,Dr as Pt,Dt as Ft,E as It,En as Lt,Er as Rt,Et as zt,F as Bt,Fn as Vt,Fr as Ht,Ft as Ut,G as Wt,Gn as Gt,Gr as Kt,Gt as qt,H as Jt,Hn as Yt,Hr as Xt,Ht as Zt,I as Qt,In as $t,Ir as en,It as tn,J as nn,Jn as rn,Jr as an,Jt as on,K as sn,Kn as cn,Kr as ln,Kt as un,L as dn,Ln as fn,Lr as pn,Lt as mn,M as hn,Mn as gn,Mr as _n,Mt as vn,N as yn,Nn as bn,Nr as xn,Nt as Sn,O as Cn,On as wn,Or as Tn,Ot as En,P as Dn,Pn as On,Pr as kn,Pt as An,Q as jn,Qn as Mn,Qt as Nn,R as Pn,Rn as Fn,Rr as In,Rt as Ln,S as Rn,Sn as zn,St as Bn,T as Vn,Tn as Hn,Tr as Un,Tt as Wn,U as Gn,Un as Kn,Ur as qn,Ut as Jn,Vn as Yn,Vr as Xn,Vt as Zn,W as Qn,Wn as $n,Wr as er,Wt as tr,X as nr,Xn as rr,Xt as ir,Y as ar,Yn as or,Yt as sr,Z as cr,Zn as lr,Zt as ur,_ as dr,_r as fr,_t as pr,a as mr,an as hr,ar as gr,at as _r,b as vr,bn as yr,br,bt as xr,c as Sr,cn as Cr,cr as wr,ct as Tr,d as Er,dn as Dr,dr as Or,dt as kr,en as Ar,er as jr,et as Mr,f as Nr,fn as Pr,fr as Fr,ft as Ir,g as Lr,gn as Rr,gr as zr,gt as Br,h as Vr,hn as Hr,hr as Ur,ht as Wr,i as Gr,in as Kr,ir as qr,it as Jr,j as Yr,jn as Xr,jr as Zr,jt as Qr,k as $r,kn as ei,kr as ti,kt as ni,l as ri,lr as ii,lt as ai,m as oi,mn as si,mr as ci,mt as li,n as ui,nn as di,nr as fi,nt as pi,o as mi,on as hi,or as gi,ot as _i,p as vi,pn as yi,pr as bi,q as xi,qn as Si,qr as Ci,qt as wi,r as Ti,rn as Ei,rt as Di,s as Oi,sn as ki,sr as Ai,st as ji,t as Mi,tn as Ni,tr as Pi,tt as Fi,u as Ii,un as Li,ur as Ri,ut as zi,v as Bi,vn as Vi,vr as Hi,vt as Ui,w as Wi,wn as Gi,wr as Ki,wt as qi,x as Ji,xn as Yi,xr as Xi,xt as Zi,y as Qi,yn as $i,yr as ea,yt as ta,z as na,zn as ra,zr as ia,zt as aa}from"./context-indicator-ZNMB0fDM.js";import{o as oa}from"./agent-store-_CfonCwg.js";import{O as sa,b as ca,l as la,p as ua,v as da}from"./workspace-manager-DLH5XabD.js";var fa=`panel-observer-`,pa=new Map,ma=new Set;function ha(e){typeof e==`function`&&ma.add(e)}function ga(e){if(!e)return null;let t=pa.get(e);if(t)return t;let n;try{n=chrome.runtime.connect({name:`${fa}${e}`})}catch(e){return r.debug(`[PanelObserver] 建立观察端口失败(忽略):`,e?.message||e),null}pa.set(e,n);try{n.onMessage.addListener(e=>{for(let t of ma)try{t(e)}catch(e){r.debug(`[PanelObserver] 消息处理异常(忽略):`,e?.message||e)}})}catch(e){r.debug(`[PanelObserver] 观察端口消息监听挂不上(忽略):`,e?.message||e)}try{n.onDisconnect.addListener(()=>{pa.get(e)===n&&pa.delete(e)})}catch(e){r.debug(`[PanelObserver] 观察端口断开监听挂不上(忽略):`,e?.message||e)}return n}function _a(e){if(!e)return;let t=pa.get(e);if(t){pa.delete(e);try{t.disconnect()}catch(e){r.debug(`[PanelObserver] 关闭观察端口异常(忽略):`,e?.message||e)}}}function va({sessionId:e,callId:t,renderer:n,persist:i,onFinished:a=()=>{},emptyFallback:o=``,awaitSnapshot:s=!1}){let c=``,l=!1,u=s,d=[],f=n=>!!n&&n.sessionId===e&&n.callId===t,p=e=>{let t=[];for(let n of e){let e=t[t.length-1];n.type===`STREAM_CHUNK`&&e&&e.type===`STREAM_CHUNK`?t[t.length-1]={...n,delta:(e.delta||``)+(n.delta||``)}:t.push(n)}return t},m=()=>{u=!1;let e=p(d);d=[];for(let t of e)g(t)},h=e=>{l=!0,Promise.resolve().then(()=>i(e)).catch(e=>r.warn(`[ChatReattach] 终态落库失败(忽略):`,e?.message||e)).then(()=>{try{a()}catch{}})};return{sessionId:e,callId:t,get finished(){return l},dispose(){l=!0},restore(e){if(!u)return;u=!1;let r=!!e&&e.callId===t,i=r&&typeof e.accumulated==`string`?e.accumulated:``,a=r&&!!e.html;a&&n.restore?.({html:e.html}),c=i,i&&!a&&n.chunk?.(i);let o=p(d);d=[];for(let e of o)g(e)},handleMessage(e){return l||!f(e)?!1:u?e.type===`STREAM_CHUNK`?(d.push(e),!0):e.type===`API_COMPLETE`||e.type===`API_ERROR`?(m(),g(e)):(d.push(e),!0):g(e)}};function g(r){switch(r.type){case`STREAM_START`:return c=``,n.start?.(),!0;case`STREAM_CHUNK`:return c+=r.delta||``,n.chunk?.(c),!0;case`STREAM_TOOL_CALL`:return n.toolCalls?.(r.toolCalls||[],c),!0;case`STREAM_TOOL_RESULT`:return r.result&&n.toolResult?.(r.result),!0;case`AGENT_STREAM`:return r.execId&&n.agentStream?.(r),!0;case`AGENT_STREAM_DONE`:return r.execId&&n.agentStreamDone?.(r),!0;case`API_RETRYING`:return n.retrying?.(r.attempt,r.maxRetries),!0;case`STREAM_PRESELECT`:return n.preselect?.(r.preselectLog||[]),!0;case`EXECUTION_STATUS_UPDATE`:return!0;case`API_COMPLETE`:{let i=r.content&&String(r.content).trim()?r.content:o||c,a=r.executionLog||[],s={reflectionScore:r.reflectionScore,reasoningContent:r.reasoningContent||null,wasRevised:r.wasRevised||!1,budgetEnded:r.budgetEnded===!0};return n.final?.(i,a,s),h({sessionId:e,callId:t,content:i,executionLog:a,...s}),!0}case`API_ERROR`:return n.error?.(r.error||``,r.executionLog||[]),h({sessionId:e,callId:t,error:r.error||``,executionLog:r.executionLog||[]}),!0;default:return!1}}}function ya({queryRunning:e,hasLocalListener:t,isAttached:n,attach:i}){return{async syncFromBackground(){try{let r=await e(),a=r&&r.activeCallIds?r.activeCallIds:{};for(let[e,r]of Object.entries(a))!e||!r||t(e)||n(e,r)||i(e,r)}catch(e){r.debug(`[ChatReattach] 查询后台运行状态失败(忽略):`,e?.message||e)}}}}var ba=!1,xa=new Map,Sa=null,Ca=!1,wa=null,Ta=null,Ea=null,Da=250,Oa=new Set([`STREAM_START`,`STREAM_CHUNK`,`STREAM_TOOL_CALL`,`STREAM_TOOL_RESULT`,`AGENT_STREAM`,`AGENT_STREAM_DONE`,`API_RETRYING`,`STREAM_PRESELECT`,`EXECUTION_STATUS_UPDATE`,`API_COMPLETE`,`API_ERROR`]);function ka(e=0){return new Promise((t,n)=>{let r=!1,i=null,a=(e,t)=>{r||(r=!0,i&&clearTimeout(i),e(t))};e>0&&(i=setTimeout(()=>a(t,{}),e));try{chrome.runtime.sendMessage({type:`QUERY_SESSION_RUNNING`},e=>{if(chrome.runtime.lastError){a(n,Error(chrome.runtime.lastError.message));return}a(t,e||{})})}catch(e){a(n,e)}})}function Aa(e,t){let n=new Map;return{start(){zt(e,``),Wn(``),Ft(Date.now()),ji(t),Mt(t)},chunk(n){zt(e,n),En(t,n)},restore({html:e}){zi(t,e)},toolCalls(e,n){typeof n==`string`&&n&&Bn(t,n),Tr(t,e)},toolResult(e){ai(e,t)},agentStream(e){Zi(t,n),kr(n,t,e)},agentStreamDone(e){let t=n.get(e.execId);t&&t.element&&e.exitCode!==0&&t.element.classList.add(`agent-stream-error`)},retrying(e,n){Ui(t,e,n)},preselect(e){let n=t.querySelector(`.message-content`);!n||!e.length||e.forEach(e=>n.insertBefore(li(e),n.firstChild))},final(e,n,r={}){pr(t,e,n,r.reflectionScore,r.reasoningContent,r.wasRevised)},error(e,n){pr(t,e,n||[])}}}async function ja(e,t,n){let r=!!e.error,i={role:`assistant`,content:r?e.error:e.content||``,executionLog:e.executionLog||[],reflectionScore:e.reflectionScore,wasRevised:e.wasRevised||!1,callId:e.callId,resumed:!0,resumable:e.budgetEnded?`budget`:!1};if(!r&&n&&(i.messageId=n.dataset.messageId||void 0,i.htmlContent=n.dataset.htmlContent||n.outerHTML),v.activeSessionId===t){v.messageHistory.push(i);try{document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:t}}))}catch{}}let{appendMessageToSession:a}=await E(async()=>{let{appendMessageToSession:e}=await import(`./context-indicator-ZNMB0fDM.js`).then(e=>e.Sr);return{appendMessageToSession:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));await a(t,i)}function Ma(){E(()=>import(`./context-indicator-ZNMB0fDM.js`).then(e=>e.V).then(e=>e.syncPendingSessionsToStorage()),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).catch(e=>r.debug(`[ChatReattach] 同步生成态失败(忽略):`,e?.message||e))}var Na=1e3;function Pa(e){return Promise.race([ni(e),new Promise(e=>setTimeout(()=>e(null),Na))])}function Fa(e,n){let i=Wr(e);if(i())return!1;let a=_i(e);a.dataset.callId=n,i(a),zt(e,``),Ft(Date.now()),qi(Date.now()),v.pendingCallApiSessionIds.add(e),v.generatingSessionIds.add(e),Ma();try{document.dispatchEvent(new CustomEvent(`generating-state-changed`))}catch{}let o=va({sessionId:e,callId:n,awaitSnapshot:!0,renderer:Aa(e,a),persist:t=>ja(t,e,a),emptyFallback:t(`chatMsg.emptyModelReply`),onFinished:()=>{if(xa.get(e)===o){xa.delete(e),_a(e),v.pendingCallApiSessionIds.delete(e),Ma(),Br(e);try{document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:e}}))}catch{}Si(e)}}});return xa.set(e,o),ga(e),Pa(e).then(t=>{o.finished||xa.get(e)!==o||o.restore(t)}).catch(()=>o.restore(null)),v.activeSessionId===e&&ta(e),r.info(`[ChatReattach] 已接管运行中的任务: sessionId=${e}, callId=${n}`),!0}function Ia(e){let t=xa.get(e);if(!t)return;xa.delete(e),_a(e);try{t.dispose?.()}catch{}let n=Wr(e),r=n();try{r?.remove()}catch{}n(null),Br(e),v.pendingCallApiSessionIds.delete(e),Ma();try{document.dispatchEvent(new CustomEvent(`generating-state-changed`))}catch{}}function La(){let e=Sa;e&&Promise.resolve().then(()=>e.syncFromBackground()).catch(e=>r.debug(`[ChatReattach] 对齐后台状态失败(忽略):`,e?.message||e))}function Ra(){!ba||!Sa||Ea||(Ea=setTimeout(()=>{Ea=null,La()},Da))}var za=new Map,Ba=3e3,Va=100,Ha=new Set,Ua=new Set([`API_COMPLETE`,`API_ERROR`]);function Wa(e,t){let n=`${e}|${t.callId}`;Ha.has(n)||(Ha.add(n),Ha.size>Va&&Ha.delete(Ha.values().next().value),Ia(e),Fa(e,t.callId)&&xa.get(e)?.handleMessage(t))}function Ga(e,t,n){let r=za.get(e);if(r){r.messages.push(n);return}r={callId:t,messages:[n]},za.set(e,r),ka(Ba).then(t=>Ka(e,t&&t.activeCallIds&&t.activeCallIds[e]||null)).catch(()=>Ka(e,null)).finally(()=>{za.delete(e)})}function Ka(e,t){let n=za.get(e);if(!n)return;let{callId:r,messages:i}=n;if(t===r)Ia(e),Fa(e,r);else if(t===null){let t=i.find(e=>Ua.has(e.type));if(!t)return;Wa(e,t);return}else return;let a=xa.get(e);if(!(!a||a.callId!==r))for(let e of i){if(a.finished)break;a.handleMessage(e)}}function qa(){if(Ca)return;Ca=!0;let e=e=>{if(!e)return!1;let t=e.sessionId?xa.get(e.sessionId):null;return t?e.callId&&e.callId!==t.callId?(Ga(e.sessionId,e.callId,e),!1):(ga(e.sessionId),t.handleMessage(e),!1):(e.callId&&Oa.has(e.type)&&Ra(),!1)};chrome.runtime.onMessage.addListener(e),ha(e),wa=e=>{let t=e?.detail?.sessionId;t&&xa.has(t)&&ta(t),Ra()},document.addEventListener(`session-hydrated`,wa),Ta=e=>{let t=e?.detail?.sessionId;t&&xa.has(t)&&ta(t)},document.addEventListener(`chat-history-rendered`,Ta)}function Ja(){return ba?{syncFromBackground:()=>Sa.syncFromBackground()}:(ba=!0,qa(),Sa=ya({queryRunning:ka,hasLocalListener:e=>v.pendingCancelApiMap.has(e),isAttached:(e,t)=>xa.get(e)?.callId===t?(ga(e),!0):!1,attach:(e,t)=>{Fa(e,t)}}),Sa.syncFromBackground(),{syncFromBackground:()=>Sa.syncFromBackground()})}function Ya(e){!ba||!Sa||(e&&v.activeSessionId===e&&ta(e),Sa.syncFromBackground())}e(`zh`,{dock:{ariaLabel:`执行中会话`,running:`正在执行`,node:`正在执行:{node}`,subtask:`子任务 {index}/{total}`,queued:`排队 {count} 条`,done:`已完成,点击查看结果`,doneAt:`已完成 {time}`,scheduled:`定时任务`,dismiss:`从停靠条移除`,dismissStale:`移除失效条目`,stale:`状态可能已失效 · 未在限定时间内收到执行更新`,more:`还有 {count} 个`,moreAria:`还有 {count} 个未显示的执行条目`,overflowTitle:`其他执行中的会话`,openSession:`点击进入该会话`,unknownSession:`未知会话`}}),e(`en`,{dock:{ariaLabel:`Running sessions`,running:`Running`,node:`Running: {node}`,subtask:`Subtask {index}/{total}`,queued:`{count} queued`,done:`Finished — click to review`,doneAt:`Finished {time}`,scheduled:`Scheduled task`,dismiss:`Remove from dock`,dismissStale:`Remove stale entry`,stale:`Status may be stale · no execution update in time`,more:`+{count} more`,moreAria:`{count} more running entries not shown`,overflowTitle:`Other active sessions`,openSession:`Click to open this session`,unknownSession:`Unknown session`}});var Xa=`sessionDockDismissed`,Za=5e3,Qa=250,$a=1200,eo=8,to=eo-1,no=9e4,ro={running:0,queued:1,done:2},io=new Map,ao=new Map,oo=new Map,so=new Map,co=new Set,lo=new Set,uo=new Map,fo=new Map,po=new Set,mo=new Set,ho=[],go=new Set,M=null,N=null,P=null,_o=[],vo=!1,yo=null,bo=null,xo=!1,So=null,Co=null;function wo(e){return e?Array.isArray(e)?e:e instanceof Set?Array.from(e):[]:[]}function To(e){let t=new Set;for(let n of wo(e))n&&t.add(h(String(n))||String(n));return t}function Eo({phase:e=``,sessionId:t=null,backendRunningIds:n=[],startedAt:r=0,lastUpdateAt:i=0,now:a=Date.now(),staleMs:o=no}={}){if(e!==`running`||!t||wo(n).includes(t))return!1;let s=Math.max(Number(r)||0,Number(i)||0);return s?a-s>=o:!1}var Do=160;function Oo(e){let t=String(e??``).replace(/\s+/g,` `).trim();if(!t)return``;let n=Array.from(t);return n.length<=Do?t:`${n.slice(0,Do).join(``).trimEnd()}…`}function ko(e,t){let n=e=>String(e??``).trim().replace(/[…\s.]+$/,``).replace(/\s+/g,``),r=n(e),i=n(t);return!r||!i?!1:r===i||i.startsWith(r)||r.startsWith(i)}function Ao({phase:e=``,queuedText:t=``,questionText:n=``,title:r=``}={}){let i=e===`queued`?Oo(t):``,a=i||Oo(n),o=Oo(r),s=a||o,c=i?`queued`:a?`question`:s?`title`:``;return{primary:s,sub:a&&!ko(o,a)?o:``,isQuestion:!!a,from:c}}function jo(e){let t=Array.isArray(e?.messageHistory)?e.messageHistory:[];for(let e=t.length-1;e>=0;--e){let n=t[e];if(!n||n.role!==`user`)continue;let r=ae(n.content);if(r&&String(r).trim())return{text:String(r),messageId:n.messageId?String(n.messageId):``}}return{text:``,messageId:``}}function Mo({activeSessionId:e=null,titles:t={},questions:n={},anchors:r={},queuedTexts:i={},generatingIds:a=[],pendingIds:o=[],runningIds:s=[],completedIds:c=[],queuedCounts:l={},scheduledIds:u=[],dismissedIds:d=[],nodeInfo:f={},startedAt:p={},doneAt:m={},lastUpdateAt:h={},now:g=Date.now(),staleMs:ee=no}={}){let te=wo(s),ne=new Set([...wo(a),...wo(o),...te]),_=new Set(wo(c)),v=new Set(wo(d)),re=new Set(wo(u)),y=l||{},b=new Set([...ne,..._,...Object.keys(y)]),x=[];for(let a of b){if(!a||a===e)continue;let o=Number(y[a])||0,s;if(ne.has(a))s=`running`;else if(o>0)s=`queued`;else if(_.has(a))s=`done`;else continue;let c=Eo({phase:s,sessionId:a,backendRunningIds:te,startedAt:p?.[a],lastUpdateAt:h?.[a],now:g,staleMs:ee});if(v.has(a)&&(s===`done`||c))continue;let l=f?.[a]||{},u=Ao({phase:s,queuedText:i?.[a]||``,questionText:n?.[a]||``,title:t?.[a]||``});x.push({sessionId:a,title:t?.[a]||``,primary:u.primary,sub:u.sub,isQuestion:u.isQuestion,anchorMessageId:u.from===`question`?String(r?.[a]||``):``,phase:s,stale:c,source:re.has(a)?`scheduled`:`chat`,queuedCount:o,nodeName:l.nodeName||``,subtaskIndex:l.subtaskIndex||0,subtaskTotal:l.subtaskTotal||0,startedAt:p?.[a]||0,doneAt:m?.[a]||0,lastUpdateAt:h?.[a]||0})}return x.sort((e,t)=>{let n=ro[e.phase]-ro[t.phase];if(n!==0)return n;if(e.stale!==t.stale)return e.stale?1:-1;let r=e.phase===`done`?e.doneAt:e.startedAt,i=t.phase===`done`?t.doneAt:t.startedAt;return r===i?String(e.sessionId).localeCompare(String(t.sessionId)):i-r}),x}function No(e){return mo.has(e)||v.generatingSessionIds.has(e)||v.pendingCallApiSessionIds.has(e)}function Po(){let e={};try{let t=Zr();for(let n of t){let t=Tn(n);t>0&&(e[n]=t)}}catch(e){r.debug(`[SessionDock] read queue counts failed:`,e?.message||e)}return e}function Fo(){let e={};for(let t of v.sessions||[])e[t.id]=t.title||``;for(let[t,n]of uo)e[t]||(e[t]=n);return e}function Io(){let e={},t={},n=new Map;for(let e of v.sessions||[])n.set(e.id,e);for(let r of new Set([...mo,...v.generatingSessionIds,...v.pendingCallApiSessionIds,...v.completedSessionIds])){let i=ao.get(r)||oo.get(r)||0,a=fo.get(r);if(i&&a&&a.stamp===i){a.text&&(e[r]=a.text,t[r]=a.messageId||``);continue}let o=jo(n.get(r));o.text&&(e[r]=o.text,t[r]=o.messageId)}return{questions:e,anchors:t}}function Lo(){let e={};try{for(let t of Zr()){let n=_n(t);n?.text&&(e[t]=String(n.text))}}catch(e){r.debug(`[SessionDock] read queued texts failed:`,e?.message||e)}return e}function Ro(e){for(let t of e||[]){let e=t.sessionId;if(!e)continue;let n=t.startedAt||t.doneAt||0,i=fo.get(e),a=!i||i.stamp!==n,o=!t.title;!a&&!o||po.has(e)||(po.add(e),y(e).then(t=>{if(t&&((o||!uo.has(e))&&uo.set(e,t.title||``),a)){let r=jo(t);fo.set(e,{text:r.text,messageId:r.messageId,stamp:n})}}).catch(e=>{r.debug(`[SessionDock] hydrate label failed:`,e?.message||e)}).finally(()=>{po.delete(e),F()}))}}function zo(e){if(!e)return``;let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function Bo(e){if(e.phase===`running`){if(e.stale)return t(`dock.stale`);let n=e.nodeName?t(`dock.node`,{node:e.nodeName}):t(`dock.running`);return e.subtaskTotal>1?`${n} · ${t(`dock.subtask`,{index:e.subtaskIndex,total:e.subtaskTotal})}`:n}return e.phase===`queued`?t(`dock.queued`,{count:e.queuedCount}):e.doneAt?t(`dock.doneAt`,{time:zo(e.doneAt)}):t(`dock.done`)}function Vo(){let e=v.completedSessionIds;for(let e of new Set([...mo,...v.generatingSessionIds,...v.pendingCallApiSessionIds]))ao.has(e)||ao.set(e,Date.now()),oo.delete(e);for(let e of mo)lo.delete(e);for(let t of e)!oo.has(t)&&!No(t)&&oo.set(t,Date.now());let{questions:t,anchors:n}=Io(),r=Mo({activeSessionId:v.activeSessionId,titles:Fo(),questions:t,anchors:n,queuedTexts:Lo(),generatingIds:v.generatingSessionIds,pendingIds:v.pendingCallApiSessionIds,runningIds:mo,completedIds:e,queuedCounts:Po(),scheduledIds:co,dismissedIds:lo,nodeInfo:Object.fromEntries(io),startedAt:Object.fromEntries(ao),doneAt:Object.fromEntries(oo),lastUpdateAt:Object.fromEntries(so),now:Date.now()});return Ro(r),r}function Ho(e){let t=new Set(ho.filter(e=>e.phase===`done`).map(e=>e.sessionId)),n=e.filter(e=>e.phase===`done`&&!t.has(e.sessionId)).map(e=>e.sessionId);n.length!==0&&(go=new Set(n),So&&clearTimeout(So),So=setTimeout(()=>{So=null,go=new Set,F()},$a))}function Uo(){if(M||typeof document>`u`)return M;M=document.createElement(`div`),M.className=`session-dock`,M.id=`sessionDock`,M.setAttribute(`role`,`navigation`),document.body.appendChild(M),N=document.createElement(`div`),N.className=`session-dock-tip`,document.body.appendChild(N),Wo();let e=document.getElementById(`chatContainer`);return e&&typeof ResizeObserver<`u`&&new ResizeObserver(Wo).observe(e),window.addEventListener(`resize`,Wo),M}function Wo(){if(!M)return;let e=document.getElementById(`chatContainer`);if(!e)return;let t=e.getBoundingClientRect();M.style.top=`${Math.max(0,Math.round(t.top+8))}px`}function Go(e){Pi(e.sessionId,{focusMessageId:e.anchorMessageId||null})}function Ko(e){let n=document.createElement(`div`);n.className=`session-dock-item`,n.dataset.sessionId=e.sessionId,n.dataset.phase=e.phase,e.stale&&(n.dataset.stale=`true`),go.has(e.sessionId)&&n.classList.add(`is-flash`);let r=e.title||t(`dock.unknownSession`),i=e.primary||r,a=Bo(e),o=e.phase===`done`?`✓`:Array.from(r)[0]||`?`,s=document.createElement(`button`);if(s.type=`button`,s.className=`session-dock-chip`,s.setAttribute(`aria-label`,`${i} · ${a}`),s.title=``,s.textContent=o,s.addEventListener(`click`,()=>{Go(e)}),n.appendChild(s),e.queuedCount>0&&e.phase!==`done`){let t=document.createElement(`span`);t.className=`session-dock-badge`,t.textContent=String(e.queuedCount>99?`99+`:e.queuedCount),n.appendChild(t)}if(e.source===`scheduled`){let e=document.createElement(`span`);e.className=`session-dock-clock`,n.appendChild(e)}if(e.phase===`done`||e.stale){let r=document.createElement(`button`);r.type=`button`,r.className=`session-dock-dismiss`;let i=e.stale?t(`dock.dismissStale`):t(`dock.dismiss`);r.setAttribute(`aria-label`,i),r.title=i,r.textContent=`×`,r.addEventListener(`click`,t=>{t.stopPropagation(),as(e.sessionId)}),n.appendChild(r)}return n.addEventListener(`mouseenter`,()=>qo(n,e,a)),n.addEventListener(`mouseleave`,Jo),n.addEventListener(`focusin`,()=>qo(n,e,a)),n.addEventListener(`focusout`,Jo),n}function qo(e,n,r){if(!N)return;N.innerHTML=``;let i=document.createElement(`div`);i.className=`session-dock-tip-title`,i.textContent=n.primary||n.title||t(`dock.unknownSession`);let a=document.createElement(`div`);if(a.className=`session-dock-tip-status`,a.textContent=r,N.appendChild(i),n.sub){let e=document.createElement(`div`);e.className=`session-dock-tip-sub`,e.textContent=n.sub,N.appendChild(e)}N.appendChild(a);let o=e.getBoundingClientRect();N.style.top=`${Math.round(o.top)}px`,N.style.left=`${Math.round(o.right+8)}px`,N.classList.add(`show`)}function Jo(){N&&N.classList.remove(`show`)}function Yo(){return P||typeof document>`u`?P:(P=document.createElement(`div`),P.className=`session-dock-overflow`,P.setAttribute(`role`,`menu`),P.addEventListener(`mouseenter`,Xo),P.addEventListener(`mouseleave`,Zo),P.addEventListener(`focusin`,Xo),P.addEventListener(`focusout`,Zo),document.body.appendChild(P),P)}function Xo(){Co&&=(clearTimeout(Co),null)}function Zo(){vo||(Xo(),Co=setTimeout(()=>{Co=null,ns()},220))}function Qo(){let e=M?M.querySelector(`.session-dock-more`):null;e&&(e.setAttribute(`aria-expanded`,vo?`true`:`false`),e.classList.toggle(`is-open`,vo))}function $o(){let e=Yo();if(!e)return;e.innerHTML=``;let n=document.createElement(`div`);n.className=`session-dock-overflow-header`,n.textContent=t(`dock.overflowTitle`),e.appendChild(n);let r=document.createElement(`div`);r.className=`session-dock-overflow-list`;for(let e of _o){let n=e.primary||e.title||t(`dock.unknownSession`),i=Bo(e),a=document.createElement(`button`);a.type=`button`,a.className=`session-dock-overflow-row`,a.dataset.phase=e.phase,e.stale&&(a.dataset.stale=`true`),a.setAttribute(`aria-label`,`${n} · ${i}`);let o=document.createElement(`span`);o.className=`session-dock-overflow-title`,o.textContent=n;let s=document.createElement(`span`);s.className=`session-dock-overflow-status`,s.textContent=i,a.appendChild(o),a.appendChild(s),a.addEventListener(`click`,()=>{ns(),Go(e)}),r.appendChild(a)}e.appendChild(r)}function es(){if(!P||!M)return;let e=M.querySelector(`.session-dock-item--more`);if(!e)return;let t=e.getBoundingClientRect();P.style.left=`${Math.round(t.right+8)}px`;let n=P.offsetHeight||0,r=Math.max(8,window.innerHeight-n-8);P.style.top=`${Math.round(Math.min(Math.max(8,t.top),r))}px`}function ts(){_o.length!==0&&Yo()&&(Xo(),$o(),es(),P.classList.add(`show`),Qo())}function ns(){Xo(),vo=!1,P&&P.classList.remove(`show`),Qo()}function rs(){if(P&&P.classList.contains(`show`)&&vo){ns();return}ts(),vo=!0,Qo()}function is(e){let n=document.createElement(`div`);n.className=`session-dock-item session-dock-item--more`,n.dataset.count=String(e.length);let r=document.createElement(`button`);return r.type=`button`,r.className=`session-dock-chip session-dock-more`,r.setAttribute(`aria-label`,t(`dock.moreAria`,{count:e.length})),r.setAttribute(`aria-expanded`,vo?`true`:`false`),r.textContent=`+${e.length>99?`99`:e.length}`,r.addEventListener(`click`,()=>rs()),n.appendChild(r),n.addEventListener(`mouseenter`,()=>ts()),n.addEventListener(`mouseleave`,Zo),n.addEventListener(`focusin`,()=>ts()),n.addEventListener(`focusout`,Zo),n}function as(e){e&&(lo.add(e),os(),F())}function os(){try{chrome.storage.local.set({[Xa]:Array.from(lo)}).catch(()=>{})}catch{}}function ss(){try{chrome.storage.local.get([Xa],e=>{let t=e?.[Xa];if(Array.isArray(t)){for(let e of t)lo.add(e);F()}})}catch{}}function cs(){if(!Uo())return;let e=Vo();if(Ho(e),ho=e,ns(),_o=[],M.innerHTML=``,e.length===0){M.classList.remove(`show`),document.body.classList.remove(`has-session-dock`),Jo();return}let t=e.length>eo?to:eo;_o=e.slice(t);for(let n of e.slice(0,t))M.appendChild(Ko(n));_o.length>0&&M.appendChild(is(_o)),M.classList.add(`show`),document.body.classList.add(`has-session-dock`)}function F(){yo||=setTimeout(()=>{yo=null;try{cs()}catch(e){r.warn(`[SessionDock] render failed:`,e?.message||e)}},Qa)}function ls(){return new Promise(e=>{try{chrome.runtime.sendMessage({type:`QUERY_SESSION_RUNNING`},t=>{if(chrome.runtime.lastError||!t){e();return}Array.isArray(t.activeSessionIds)&&(mo=To(t.activeSessionIds)),e()})}catch{e()}})}function us(e){let t=e?.sessionId;if(!t)return;let n=io.get(t)||{};io.set(t,{nodeName:e.nodeName||n.nodeName||``,subtaskIndex:e.subtaskIndex||n.subtaskIndex||0,subtaskTotal:e.subtaskTotal||n.subtaskTotal||0}),so.set(t,Date.now()),F()}function ds(e){e&&(io.delete(e),ao.delete(e),oo.delete(e),so.delete(e),lo.delete(e),uo.delete(e),fo.delete(e),F())}function fs(){if(!(xo||typeof document>`u`||!Uo())){xo=!0,ss(),document.addEventListener(`generating-state-changed`,F),document.addEventListener(`session-switched`,F),document.addEventListener(`generation-ended`,e=>{let t=e?.detail?.sessionId;t&&!oo.has(t)&&oo.set(t,Date.now()),F()}),document.addEventListener(`session-archived`,e=>ds(e?.detail?.sessionId)),document.addEventListener(`session-deleted`,e=>ds(e?.detail?.sessionId));try{In(F)}catch(e){r.debug(`[SessionDock] subscribe queue failed:`,e?.message||e)}try{chrome.runtime.onMessage.addListener(e=>e?e.type===`EXECUTION_STATUS_UPDATE`?(us(e),!1):e.type===`SCHEDULED_TASK_RUN_STATE`&&e.sessionId?(e.running?co.add(e.sessionId):co.delete(e.sessionId),F(),!1):(e.type===`SCHEDULED_SESSION_UPDATED`&&F(),!1):!1)}catch(e){r.debug(`[SessionDock] register runtime listener failed:`,e?.message||e)}document.addEventListener(`visibilitychange`,()=>{if(document.hidden){ns();return}ls().then(F)}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&vo&&ns()}),bo||=setInterval(()=>{document.hidden||ls().then(F)},Za),ls().then(()=>{for(let e of mo)ao.has(e)||ao.set(e,Date.now());cs()})}}function ps(){let e=document.getElementById(`chatNavUp`),n=document.getElementById(`chatNavDown`),r=document.getElementById(`chatNavHotzone`),i=document.getElementById(`chatNavButtons`),a=document.getElementById(`chatNavQuestionPanel`),o=[],s=!1,c=null,l=``,u=!1,d=!1;function f(e){let t=document.getElementById(`chatContainer`);if(!t)return-1;let n=t.getBoundingClientRect();return et(e,n.top,n.bottom)}function p(e,t){let n=document.getElementById(`chatContainer`);if(!n)return`noop`;let r=Ye(n);if(r.length===0)return`noop`;let i=n.getBoundingClientRect().top;if(t){if(e===`prev`)r[0].start.scrollIntoView({behavior:`smooth`,block:`start`});else{let e=r[r.length-1].elements;e[e.length-1].scrollIntoView({behavior:`smooth`,block:`end`})}return`jumped`}let a=pt(r.length,$e(r,i),e);return a===null?(m(e),`blocked`):(r[a].start.scrollIntoView({behavior:`smooth`,block:`start`}),`jumped`)}function m(t){let r=t===`prev`?e:n;r&&(r.classList.remove(`blocked`),r.offsetWidth,r.classList.add(`blocked`),r.addEventListener(`animationend`,()=>r.classList.remove(`blocked`),{once:!0}))}function h(e,n){let r=a.querySelectorAll(`.chat-nav-question-item`);r.forEach(t=>{Number(t.dataset.groupIndex)===e?(t.classList.add(`current`),t.setAttribute(`aria-current`,`true`)):(t.classList.remove(`current`),t.setAttribute(`aria-current`,`false`))});let i=a.querySelector(`.chat-nav-question-header .count`);i&&(i.textContent=t(`chat.navPosition`,{current:e>=0?e+1:n,total:n}));let o=Array.from(r).find(t=>Number(t.dataset.groupIndex)===e);!d&&e>=0&&o&&o.scrollIntoView({block:`nearest`})}function g(){if(!a||!a.classList.contains(`expanded`))return;o=Ye(document.getElementById(`chatContainer`));let e=l?Ye(document.getElementById(`chatContainer`)).length:a.querySelectorAll(`.chat-nav-question-item`).length;if(o.length===0){a.innerHTML=``,a.classList.remove(`expanded`);return}if(!l&&e!==o.length){ee();return}h(f(o),o.length)}function ee(){if(!a)return!1;if(o=Ye(document.getElementById(`chatContainer`)),o.length===0)return a.innerHTML=``,!1;let e=f(o),t=document.activeElement===a.querySelector(`[data-role="nav-search"]`);a.innerHTML=Ze(o,e,s,l),a.querySelector(`.chat-nav-pin`).addEventListener(`click`,e=>{e.stopPropagation(),b()});let n=a.querySelector(`[data-role="nav-search"]`);if(n){let e=()=>{l!==n.value&&(l=n.value,ee())};n.addEventListener(`input`,t=>{t.isComposing||e()}),n.addEventListener(`compositionend`,e),t&&(n.focus(),n.setSelectionRange(n.value.length,n.value.length))}if(e>=0){let t=a.querySelector(`.chat-nav-question-item[data-group-index="${e}"]`);t&&t.scrollIntoView({block:`nearest`})}return!0}function te(){let e=document.activeElement;return e?[r,i,a].some(t=>t&&(t===e||t.contains(e))):!1}function ne(){i.classList.remove(`expanded`),a&&a.classList.remove(`expanded`)}function _(){let e=te();ne(),e&&r&&(u=!0,r.focus({preventScroll:!0}),u=!1)}function v(){if(clearTimeout(c),i.classList.add(`expanded`),a){if(a.classList.contains(`expanded`)){g();return}ee()?a.classList.add(`expanded`):a.classList.remove(`expanded`)}}function re(e){clearTimeout(c),!s&&(te()||(e?ne():c=setTimeout(ne,300)))}function y(e){if(s=e,r&&(r.classList.toggle(`pinned`,e),r.setAttribute(`aria-pressed`,String(e))),a){a.classList.toggle(`pinned`,e);let n=a.querySelector(`.chat-nav-pin`);if(n){let r=t(e?`chat.navUnpinLabel`:`chat.navPinLabel`);n.textContent=r,n.title=r,n.setAttribute(`aria-pressed`,String(e)),n.classList.toggle(`on`,e)}}}function b(){y(!s)}e&&e.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),p(`prev`,e.ctrlKey||e.metaKey),g()}),n&&n.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),p(`next`,e.ctrlKey||e.metaKey),g()}),r&&i&&(r.addEventListener(`mouseenter`,v),r.addEventListener(`mouseleave`,()=>re(!1)),r.addEventListener(`click`,()=>b()),r.addEventListener(`focus`,()=>{u||v()}),r.addEventListener(`blur`,()=>re(!1)),r.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),b())}),i.addEventListener(`mouseenter`,v),i.addEventListener(`mouseleave`,()=>re(!1)),i.addEventListener(`focusin`,v),a&&(a.addEventListener(`mouseenter`,()=>{d=!0,v()}),a.addEventListener(`mouseleave`,()=>{d=!1,re(!1)}),a.addEventListener(`focusin`,v),a.addEventListener(`keydown`,e=>{if(e.target.matches(`[data-role="nav-search"]`))return;let t=Array.from(a.querySelectorAll(`.chat-nav-question-item`));if(t.length===0)return;let n=t.indexOf(document.activeElement),r=null;e.key===`ArrowDown`?r=Math.min(n+1,t.length-1):e.key===`ArrowUp`?r=n<=0?0:n-1:e.key===`Home`?r=0:e.key===`End`&&(r=t.length-1),r!==null&&(e.preventDefault(),t[r].focus())}),a.addEventListener(`click`,e=>{let t=e.target.closest(`.chat-nav-question-item`);if(!t||!t.dataset.messageId)return;let n=o.find(e=>(e.userElement||e.start).dataset.messageId===t.dataset.messageId);if(!n)return;let r=n.userElement||n.start;r.scrollIntoView({behavior:`instant`,block:`start`}),r.classList.add(`bookmark-highlight`),setTimeout(()=>r.classList.remove(`bookmark-highlight`),2e3),s?g():_()})));{let e=document.getElementById(`chatContainer`);if(e){let t=!1;e.addEventListener(`scroll`,()=>{!a||!a.classList.contains(`expanded`)||t||(t=!0,requestAnimationFrame(()=>{t=!1,g()}))},{passive:!0})}}function x(){let e=a&&a.classList.contains(`expanded`);if(!s&&!e)return!1;if(a&&a.querySelector(`[data-role="nav-search"]`)&&l){l=``,ee();let e=a.querySelector(`[data-role="nav-search"]`);return e&&e.focus(),!0}return y(!1),_(),!0}return{jumpToMessage:p,updateActiveQuestion:g,handleEscape:x,isPinned:()=>s}}function ms(e){if(!e)return!1;let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;return!!(t&&t.closest&&t.closest(`#chatContainer, .message-fullscreen-body`))}e(`zh`,{searchPanel:{toggleTitle:`消息搜索`,title:`消息搜索`,closeTitle:`关闭`,inputPlaceholder:`搜索消息(支持 & | 组合搜索)...`,clearTitle:`清除`,globalSearchTitle:`在所有会话中搜索`,globalSearch:`全局搜索`,currentSessionTitle:`仅在当前会话中搜索`,currentSession:`当前会话`,startSearchHint:`输入关键词开始搜索`,searching:`搜索中...`,searchingWithCount:`搜索中... {count} 条`,searchError:`搜索出错`,noActiveSession:`没有活跃会话`,noSessionData:`没有会话数据`,noMatch:`未找到匹配消息`,unknownSession:`未知会话`,countResult:`{count} 条`,noResult:`无结果`,searchingSuffix:` (搜索中...)`,currentSessionResults:`当前会话{label} · {count} 条`,otherSessionsResults:`其他会话 · {count} 条`,roleUser:`你`,roleAssistant:`助手`,sessionNotExist:`会话已不存在`,messageDeleted:`消息已被删除`}}),e(`en`,{searchPanel:{toggleTitle:`Search messages`,title:`Message search`,closeTitle:`Close`,inputPlaceholder:`Search messages (supports & | combined search)...`,clearTitle:`Clear`,globalSearchTitle:`Search in all sessions`,globalSearch:`Global search`,currentSessionTitle:`Search in current session only`,currentSession:`Current session`,startSearchHint:`Enter keywords to start searching`,searching:`Searching...`,searchingWithCount:`Searching... {count} found`,searchError:`Search error`,noActiveSession:`No active session`,noSessionData:`No session data`,noMatch:`No matching messages found`,unknownSession:`Unknown session`,countResult:`{count} found`,noResult:`No results`,searchingSuffix:` (searching...)`,currentSessionResults:`Current session{label} · {count} found`,otherSessionsResults:`Other sessions · {count} found`,roleUser:`You`,roleAssistant:`Assistant`,sessionNotExist:`Session no longer exists`,messageDeleted:`Message has been deleted`}});var hs=!1,gs=!1,I=[],_s=``;function vs(){v.searchInputHistory=[],v.searchInputHistoryIndex=-1;try{chrome.storage.local.get([`searchInputHistory`],e=>{e.searchInputHistory&&(v.searchInputHistory=e.searchInputHistory)})}catch{}let e=document.createElement(`div`);e.className=`search-panel-container`,e.id=`searchPanelContainer`,e.innerHTML=`
|
|
3
3
|
<button class="search-panel-toggle" id="searchPanelToggle" title="${t(`searchPanel.toggleTitle`)}">
|
|
4
4
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
5
5
|
<circle cx="11" cy="11" r="8"/>
|
|
@@ -48,7 +48,7 @@ import{a as e,c as t,i as n,l as r,n as i,r as a,s as o}from"./i18n-XUUSwfZZ.js"
|
|
|
48
48
|
</div>
|
|
49
49
|
<div class="search-result-preview">${c}</div>
|
|
50
50
|
</div>
|
|
51
|
-
`}).join(``)}function As(e,t){if(!t)return e;let n=t.split(/[&|]/).map(e=>e.trim()).filter(Boolean);if(n.length===0)return e;let r=n.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)),i=RegExp(`(${r.join(`|`)})`,`gi`);return e.replace(i,`<mark class="search-highlight-match">$1</mark>`)}async function js(e,n){if(!(!e||!n)){if(v.activeSessionId!==e)try{let n=v.activeSessionId;if(await jt(e)===!1||v.activeSessionId!==e){k(t(`searchPanel.sessionNotExist`),`warning`);return}document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:e,previousSessionId:n,skipScrollRestore:!0}}));try{let{renderSessionTabs:e}=await E(async()=>{let{renderSessionTabs:e}=await import(`./context-indicator-
|
|
51
|
+
`}).join(``)}function As(e,t){if(!t)return e;let n=t.split(/[&|]/).map(e=>e.trim()).filter(Boolean);if(n.length===0)return e;let r=n.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)),i=RegExp(`(${r.join(`|`)})`,`gi`);return e.replace(i,`<mark class="search-highlight-match">$1</mark>`)}async function js(e,n){if(!(!e||!n)){if(v.activeSessionId!==e)try{let n=v.activeSessionId;if(await jt(e)===!1||v.activeSessionId!==e){k(t(`searchPanel.sessionNotExist`),`warning`);return}document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:e,previousSessionId:n,skipScrollRestore:!0}}));try{let{renderSessionTabs:e}=await E(async()=>{let{renderSessionTabs:e}=await import(`./context-indicator-ZNMB0fDM.js`).then(e=>e.rr);return{renderSessionTabs:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));e()}catch(e){r.warn(`[SearchPanel] refreshsessionTab failed:`,e)}}catch(e){r.error(`[SearchPanel] switchsession failed:`,e);return}setTimeout(async()=>{let i=document.getElementById(`chatContainer`);if(!i){r.warn(`[SearchPanel] chatContainer not found`);return}let a=i.querySelector(`.message[data-message-id="${n}"]`);if(a||=i.querySelector(`[data-message-id="${n}"]`),!a){let t=Array.from(i.querySelectorAll(`[data-message-id]`),e=>e.dataset.messageId);r.warn(`[SearchPanel] positionmessage failed`,{targetSessionId:e,activeSessionId:v.activeSessionId,targetMessageId:n,typeOfMessageId:typeof n,messageIdLength:n.length,domMessageIds:t,chatContainerHtmlLen:i.innerHTML.length})}if(a)a.scrollIntoView({behavior:`instant`,block:`nearest`}),a.classList.add(`bookmark-highlight`),setTimeout(()=>{a.classList.remove(`bookmark-highlight`)},2e3);else{k(t(`searchPanel.messageDeleted`),`warning`);try{if(await _(e,n)){I=I.filter(t=>!(t.sessionId===e&&t.messageId===n));let i=document.getElementById(`searchPanelContent`),a=document.getElementById(`searchPanelCount`);i&&I.length>0?(Os(I,_s,i),a.textContent=t(`searchPanel.countResult`,{count:I.length})):i&&I.length===0&&(i.innerHTML=`<div class="search-panel-empty">${t(`searchPanel.noMatch`)}</div>`,a&&(a.textContent=t(`searchPanel.noResult`))),r.debug(`[SearchPanel] cleaned IndexedDB dirtydata:`,e,n)}}catch(e){r.warn(`[SearchPanel] cleanupdirtydata failed:`,e)}}},500)}}e(`zh`,{schedPanel:{toggleTitle:`定时任务`,toggleRunning:`执行中`,title:`定时任务`,newTask:`新建任务`,close:`关闭`,empty:`暂无定时任务`,nameLabel:`任务名称`,descLabel:`任务描述(可选)`,promptLabel:`任务指令`,scheduleLabel:`定时规则`,scheduleTypeOnce:`一次性`,scheduleTypeInterval:`间隔`,scheduleTypeCron:`Cron 表达式`,intervalValuePlaceholder:`例如:30m / 2h / 1d`,cronValuePlaceholder:`例如:0 9 * * *`,relativeValuePlaceholder:`例如:30`,onceModeLabel:`执行方式`,onceModeRelative:`多少分钟后`,onceModeAbsolute:`指定时间点`,valueLabelInterval:`间隔时间`,valueLabelCron:`Cron 表达式`,minutesSuffix:` 分钟后`,contextUrlLabel:`上下文网页地址(可选)`,useCurrentPage:`使用当前页面`,sessionLabel:`宿主会话`,sessionAuto:`自动(会话被删时自动新建)`,save:`保存`,cancel:`取消`,edit:`编辑`,editTitle:`编辑任务`,delete:`删除`,runNow:`立即执行`,enable:`启用`,disable:`停用`,statusSuccess:`成功`,statusFailed:`失败`,statusRunning:`运行中`,statusDisabled:`已停用`,nextRun:`下次执行`,deleted:`任务已删除`,saved:`任务已保存`,runNowToast:`已触发执行`,deleteConfirmTitle:`删除定时任务`,deleteConfirmMsg:`确定删除任务「{name}」吗?`,createFailed:`创建任务失败`,nameRequired:`请填写任务名称`,promptRequired:`请填写任务指令`,scheduleRequired:`请填写定时规则`,loading:`加载中...`,contextModeLabel:`网页上下文方式`,contextModeFetch:`抓取网页正文`,contextModeUrlOnly:`仅使用 URL(不抓正文)`,maxRunsLabel:`最多执行次数(可选)`,endAtLabel:`截止时间(可选)`,runHistoryLabel:`运行历史`,runHistoryEmpty:`暂无运行记录`,runCountLabel:`运行历史 ({count})`,filterAll:`全部`,filterEnabled:`启用中`,filterDisabled:`已停用`,sortLabel:`排序`,sortCreated:`创建时间`,sortLastRun:`最近执行`,sortUpdated:`更新时间`,emptyFiltered:`没有符合筛选条件的任务`}}),e(`en`,{schedPanel:{toggleTitle:`Scheduled tasks`,toggleRunning:`Running`,title:`Scheduled tasks`,newTask:`New task`,close:`Close`,empty:`No scheduled tasks`,nameLabel:`Name`,descLabel:`Description (optional)`,promptLabel:`Prompt`,scheduleLabel:`Schedule`,scheduleTypeOnce:`Once`,scheduleTypeInterval:`Interval`,scheduleTypeCron:`Cron expression`,intervalValuePlaceholder:`e.g. 30m / 2h / 1d`,cronValuePlaceholder:`e.g. 0 9 * * *`,relativeValuePlaceholder:`e.g. 30`,onceModeLabel:`Run mode`,onceModeRelative:`After some minutes`,onceModeAbsolute:`At specific time`,valueLabelInterval:`Interval`,valueLabelCron:`Cron expression`,minutesSuffix:` minutes later`,contextUrlLabel:`Context page URL (optional)`,useCurrentPage:`Use current page`,sessionLabel:`Host session`,sessionAuto:`Auto (recreate if deleted)`,save:`Save`,cancel:`Cancel`,edit:`Edit`,editTitle:`Edit task`,delete:`Delete`,runNow:`Run now`,enable:`Enable`,disable:`Disable`,statusSuccess:`Success`,statusFailed:`Failed`,statusRunning:`Running`,statusDisabled:`Disabled`,nextRun:`Next run`,deleted:`Task deleted`,saved:`Task saved`,runNowToast:`Execution triggered`,deleteConfirmTitle:`Delete scheduled task`,deleteConfirmMsg:`Delete task "{name}"?`,createFailed:`Failed to create task`,nameRequired:`Name is required`,promptRequired:`Prompt is required`,scheduleRequired:`Schedule is required`,loading:`Loading...`,contextModeLabel:`Page context mode`,contextModeFetch:`Fetch page content`,contextModeUrlOnly:`URL only`,maxRunsLabel:`Max runs (optional)`,endAtLabel:`End time (optional)`,runHistoryLabel:`Run history`,runHistoryEmpty:`No runs yet`,runCountLabel:`Run history ({count})`,filterAll:`All`,filterEnabled:`Enabled`,filterDisabled:`Disabled`,sortLabel:`Sort`,sortCreated:`Created`,sortLastRun:`Last run`,sortUpdated:`Updated`,emptyFiltered:`No tasks match the filter`}});function Ms(e){return chrome.runtime.sendMessage(e)}function Ns(e){return e?new Date(e).toLocaleString(void 0,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`}):`—`}function Ps(e){return e==null?``:e<1e3?e+`ms`:e<6e4?(e/1e3).toFixed(1).replace(/\.0$/,``)+`s`:(e/6e4).toFixed(1).replace(/\.0$/,``)+`min`}function Fs(e){return e===`success`?t(`schedPanel.statusSuccess`):e===`failed`?t(`schedPanel.statusFailed`):e===`running`?t(`schedPanel.statusRunning`):``}function Is(e){if(!e)return``;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function Ls(e){let n=e.schedule||{};return n.type===`once`?n.onceMode===`relative`?t(`schedPanel.scheduleTypeOnce`)+` · `+(n.value||``)+t(`schedPanel.minutesSuffix`):t(`schedPanel.scheduleTypeOnce`)+` · `+Ns(new Date(n.value).getTime()):n.type===`interval`?t(`schedPanel.scheduleTypeInterval`)+` · `+(n.value||``):n.type===`cron`?t(`schedPanel.scheduleTypeCron`)+` · `+(n.value||``):``}function Rs(e){return e.enabled?e.lastStatus===`running`?`<span class="sched-badge running">${t(`schedPanel.statusRunning`)}</span>`:e.lastStatus===`failed`?`<span class="sched-badge failed">${t(`schedPanel.statusFailed`)}</span>`:e.lastStatus===`success`?`<span class="sched-badge success">${t(`schedPanel.statusSuccess`)}</span>`:``:`<span class="sched-badge muted">${t(`schedPanel.statusDisabled`)}</span>`}function zs(){let e=document.getElementById(`chatContainer`);e&&(e.scrollTop=e.scrollHeight)}async function Bs(e){if(e){if(v.activeSessionId!==e){let t=v.activeSessionId;try{if(await jt(e)===!1||v.activeSessionId!==e)return}catch{return}document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:e,previousSessionId:t,skipScrollRestore:!0}}));try{let{renderSessionTabs:e}=await E(async()=>{let{renderSessionTabs:e}=await import(`./context-indicator-ZNMB0fDM.js`).then(e=>e.rr);return{renderSessionTabs:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));e()}catch{}}setTimeout(zs,500)}}function Vs(){let e=document.createElement(`div`);e.className=`schedule-panel-container`,e.id=`schedulePanelContainer`,e.innerHTML=`
|
|
52
52
|
<style>
|
|
53
53
|
.schedule-panel-container { position: relative; display: flex; justify-content: flex-end; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; width: 100%; background: transparent; }
|
|
54
54
|
.schedule-panel-toggle { background: rgba(var(--success-rgb), 0.14); color: var(--success-strong); border: none; border-radius: 6px 0 0 6px; padding: 8px 4px; cursor: pointer; font-size: 14px; box-shadow: -1px 1px 4px rgba(var(--overlay-rgb), 0.12); transition: all 0.3s ease; display: flex; align-items: center; justify-content: center; }
|
|
@@ -472,7 +472,7 @@ import{a as e,c as t,i as n,l as r,n as i,r as a,s as o}from"./i18n-XUUSwfZZ.js"
|
|
|
472
472
|
<button class="sap-btn sap-transfer"></button>
|
|
473
473
|
<button class="sap-btn sap-regen"></button>
|
|
474
474
|
</div>
|
|
475
|
-
`,document.body.appendChild(Q),Q.querySelector(`.sap-close`).addEventListener(`click`,Sm),Q.querySelector(`.sap-lock`).addEventListener(`click`,gm),Q.querySelector(`.sap-copy`).addEventListener(`click`,Em),Q.querySelector(`.sap-transfer`).addEventListener(`click`,Dm),Q.querySelector(`.sap-regen`).addEventListener(`click`,()=>{im&&am&&km()}),Tm(Q.querySelector(`.sap-header`)),Q)}function mm(){if(!Q)return;Q.querySelector(`.sap-close`).title=t(`sidePanel.popupClose`);let e=Q.querySelector(`.sap-copy`);e.textContent=t(`sidePanel.popupCopy`),e.title=t(`sidePanel.popupCopy`);let n=Q.querySelector(`.sap-transfer`);n.textContent=t(`sidePanel.popupTransfer`),n.title=t(`sidePanel.popupTransfer`);let r=Q.querySelector(`.sap-regen`);r.textContent=t(`sidePanel.popupRegenerate`),r.title=t(`sidePanel.popupRegenerate`),hm()}function hm(){if(!Q)return;let e=Q.querySelector(`.sap-lock`);e&&(e.classList.toggle(`locked`,lm),e.title=t(lm?`sidePanel.popupUnlock`:`sidePanel.popupLock`),e.innerHTML=lm?`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>`:`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 9.9-1"/></svg>`)}function gm(){lm=!lm,hm()}function _m(e,t){let n=pm(),r=window.innerWidth,i=window.innerHeight,a=t+12,o=e-320/2;o<8&&(o=8),o+320>r-8&&(o=r-320-8),a+280>i-8&&(a=t-280-12),a<8&&(a=8),n.style.position=`fixed`,n.style.top=a+`px`,n.style.left=o+`px`}function vm(e){let n=pm();mm(),n.querySelector(`.sap-title`).textContent=e||t(`sidePanel.popupTitle`),n.querySelector(`.sap-body`).innerHTML=`<div class="sap-loading">${A(t(`sidePanel.popupLoading`))}</div>`,n.classList.add(`show`),Q.style.display=`block`}function ym(){return!!Q&&Q.classList.contains(`show`)}function bm(e,t=!0){let n=Q?.querySelector(`.sap-body`);n&&(n.innerHTML=`<div class="sap-content markdown-body">${e}</div>`,t&&(n.scrollTop=n.scrollHeight))}function xm(e){let t=Q?.querySelector(`.sap-body`);t&&(t.innerHTML=`<div class="sap-error">${A(e)}</div>`)}function Sm(){cm&&nm&&chrome.runtime.sendMessage({type:`CANCEL_REACT`,sessionId:nm}).catch(()=>{}),Q&&(Q.classList.remove(`show`),Q.style.display=`none`),nm=null,rm=``,cm=!1,lm=!1}function Cm(e){if(!ym()||lm||Q.contains(e.target))return;let t=document.getElementById(`selectionFloatingMenu`);t&&t.contains(e.target)||Sm()}function wm(e){e.key===`Escape`&&(!ym()||lm||Sm())}function Tm(e){let t=!1,n,r,i,a;e.addEventListener(`mousedown`,e=>{if(e.target.closest(`.sap-close, .sap-lock`))return;t=!0,n=e.clientX,r=e.clientY;let o=Q.getBoundingClientRect();i=o.top,a=o.left,e.preventDefault()}),document.addEventListener(`mousemove`,e=>{if(!t)return;let o=e.clientX-n,s=e.clientY-r;Q.style.position=`fixed`,Q.style.top=i+s+`px`,Q.style.left=a+o+`px`}),document.addEventListener(`mouseup`,()=>{t=!1})}function Em(){rm&&navigator.clipboard.writeText(rm).then(()=>{k(t(`sidePanel.popupCopied`))}).catch(()=>{let e=document.createElement(`textarea`);e.value=rm,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e),k(t(`sidePanel.popupCopied`))})}function Dm(){if(!rm||!im)return;An()&&Qr();let e=rm,n=im.content,r=`${om?`[${t(`sidePanel.popupContextLabel`)}]\n${om}\n\n`:``}[${t(`sidePanel.selectedContentLabel`)}]\n${am}\n\n[${t(`sidePanel.userQuestionLabel`)}]\n${im.content}`;E(async()=>{let{addMessage:e}=await import(`./context-indicator-O2JgFDbD.js`).then(e=>e.V);return{addMessage:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(({addMessage:i})=>{i(`user`,n,!0,[],null,!1,r),v.messageHistory.push({role:`user`,content:r,timestamp:new Date().toISOString()}),i(`assistant`,e,!0),v.messageHistory.push({role:`assistant`,content:e}),E(async()=>{let{saveCurrentSession:e}=await import(`./context-indicator-O2JgFDbD.js`).then(e=>e.Sr);return{saveCurrentSession:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(({saveCurrentSession:e})=>{e()}),Promise.all([E(()=>import(`./context-indicator-O2JgFDbD.js`).then(e=>e.pt),__vite__mapDeps([0,1,2,3,4,5,6,7,8])),new Promise(e=>requestAnimationFrame(e))]).then(([{autoScrollToBottom:e}])=>{e(document.getElementById(`chatContainer`),{force:!0,smooth:!0}),k(t(`sidePanel.popupTransferred`))})}),Sm()}function Om(e,t,n){let{context:r,truncated:i}=dm(n,t);im=e,am=t,om=r,sm=i,km()}function km(){rm=``,cm=!0,vm(im?.content);let e=fm(am,om,im.content,sm);nm=`popup_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,chrome.runtime.sendMessage({type:`SIDEPANEL_POPUP_ASK`,sessionId:nm,messages:e}).catch(e=>{r.error(`[SelectionPopup] sendMessage failed:`,e),xm(t(`sidePanel.popupRequestFailed`)),cm=!1})}var Am=!1;function jm(){Am||(Am=!0,chrome.runtime.onMessage.addListener(e=>{if(!(!e||!e.type)&&e.type.startsWith(`SIDEPANEL_POPUP_`)&&e.sessionId===nm){if(e.type===`SIDEPANEL_POPUP_STREAM_CHUNK`)e.delta&&(rm+=e.delta,bm(ut(rm)));else if(e.type===`SIDEPANEL_POPUP_STREAM_DONE`)cm=!1,e.finalContent&&(rm=e.finalContent),bm(ut(rm));else if(e.type===`SIDEPANEL_POPUP_STREAM_ERROR`){if(!cm)return;cm=!1,xm(e.error||t(`sidePanel.popupRequestFailed`))}}}))}function Mm(){jm(),document.addEventListener(`mousedown`,Cm),document.addEventListener(`keydown`,wm)}function Nm(e,t,n,r,i){!t||!e||(jm(),_m(n,r),lm=!1,Om(e,t,i||v.currentSelectionRange))}e(`zh`,{tokenStats:{clearConfirmMessage:`确定要清空所有 Token 使用统计吗?此操作不可撤销。`,loadFailed:`加载失败`,currentSessionNoData:`当前会话暂无数据`,totalTokenUsage:`总 Token 消耗`,apiCallCount:`API 调用次数`,contextUsageRate:`上下文使用率`,max:`最大`,avg:`平均`,min:`最小`,totalTokens:`总 Token`,totalSessions:`总会话数`,totalApiCalls:`总 API 调用`,callTypeNonStream:`普通`,callTypeStream:`流式`,callTypeReflection:`反思`,callTypeToolReflection:`工具反思`,callTypeSubtaskReflection:`子任务反思`,tabTrend:`趋势`,tabDistribution:`分布`,tabGlobal:`全局`,topCardSessionTokens:`本次 Token`,topCardSessionCalls:`本次调用`,topCardContextPeak:`上下文峰值`,sparklineTitle:`最近 20 次调用趋势`,distPromptVsCompletion:`Prompt / Completion 占比`,distPrompt:`Prompt`,distCompletion:`Completion`,distByModel:`按模型分布`,distByCallType:`按调用类型分布`,distNoData:`暂无分布数据`,globalSparklineTitle:`最近 30 天趋势`,globalNoDailyData:`所选范围内暂无数据`,globalTotalTokens:`总 Token`,globalTotalSessions:`总会话数`,globalTotalApiCalls:`总 API 调用`}}),e(`en`,{tokenStats:{clearConfirmMessage:`Are you sure you want to clear all Token usage statistics? This action cannot be undone.`,loadFailed:`Load failed`,currentSessionNoData:`No data for current session`,totalTokenUsage:`Total Token Usage`,apiCallCount:`API Call Count`,contextUsageRate:`Context Usage Rate`,max:`Max`,avg:`Avg`,min:`Min`,totalTokens:`Total Tokens`,totalSessions:`Total Sessions`,totalApiCalls:`Total API Calls`,callTypeNonStream:`Normal`,callTypeStream:`Stream`,callTypeReflection:`Reflection`,callTypeToolReflection:`Tool Reflection`,callTypeSubtaskReflection:`Subtask Reflection`,tabTrend:`Trend`,tabDistribution:`Distribution`,tabGlobal:`Global`,topCardSessionTokens:`Session Tokens`,topCardSessionCalls:`Session Calls`,topCardContextPeak:`Context Peak`,sparklineTitle:`Last 20 Calls Trend`,distPromptVsCompletion:`Prompt / Completion Ratio`,distPrompt:`Prompt`,distCompletion:`Completion`,distByModel:`By Model`,distByCallType:`By Call Type`,distNoData:`No distribution data`,globalSparklineTitle:`Last 30 Days Trend`,globalNoDailyData:`No data in selected range`,globalTotalTokens:`Total Tokens`,globalTotalSessions:`Total Sessions`,globalTotalApiCalls:`Total API Calls`}});function Pm(e,n){let i=document.getElementById(`tokenStatsOverlay`),a=document.getElementById(`tokenStatsClose`),o=document.getElementById(`tokenStatsRefreshBtn`),s=document.getElementById(`tokenStatsClearBtn`),c=document.getElementById(`tokenStatsTabNav`),l=document.getElementById(`tokenStatsTopCards`);if(!i)return;let u=`trend`,d=`month`;function f(){i.style.display=`flex`,h()}function p(){i.style.display=`none`}if(window.openTokenStats=f,a&&a.addEventListener(`click`,p),i&&i.addEventListener(`click`,e=>{e.target===i&&p()}),o&&o.addEventListener(`click`,h),s&&s.addEventListener(`click`,async()=>{await n(t(`tokenStats.clearConfirmMessage`),t(`toolStats.clearTitle`))&&(await ge(),h())}),c){c.addEventListener(`click`,e=>{let t=e.target.closest(`.token-tab-btn`);if(!t)return;let n=t.dataset.tab;if(n===u)return;c.querySelectorAll(`.token-tab-btn`).forEach(e=>{e.classList.remove(`active`),e.style.borderBottomColor=`transparent`,e.style.color=`var(--text-secondary)`}),t.classList.add(`active`),t.style.borderBottomColor=`var(--brand-500)`,t.style.color=`var(--brand-500)`,document.querySelectorAll(`.token-tab-content`).forEach(e=>{e.style.display=`none`});let r=document.getElementById(`tokenTab${n.charAt(0).toUpperCase()+n.slice(1)}`);r&&(r.style.display=n===`global`?`flex`:``),u=n});let e=c.querySelector(`.token-tab-btn.active`);e&&(e.style.borderBottomColor=`var(--brand-500)`,e.style.color=`var(--brand-500)`)}let m=document.querySelectorAll(`.token-time-range-btn`);m.forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.range;t!==d&&(d=t,m.forEach(e=>{e.classList.remove(`active`),e.style.border=`1px solid var(--border-default)`,e.style.background=`var(--bg-surface)`,e.style.color=`var(--text-secondary)`}),e.classList.add(`active`),e.style.border=`1px solid var(--brand-500)`,e.style.background=`var(--brand-500)`,e.style.color=`var(--text-on-brand)`,b())})});async function h(){let n=e(),i=document.getElementById(`tokenStatsLoading`),a=document.getElementById(`tokenStatsEmpty`),o=document.getElementById(`tokenStatsContent`);i&&(i.style.display=``),a&&(a.style.display=`none`),o&&(o.style.display=`none`),c&&(c.style.display=`none`),l&&(l.style.display=`none`);try{let[e,t]=await Promise.all([Me(n),Ne()]);if(i&&(i.style.display=`none`),!(t&&t.totalApiCalls>0)){a&&(a.style.display=``);return}o&&(o.style.display=``),c&&(c.style.display=`flex`),l&&(l.style.display=``),g(e),ee(e),ie(e.records||[]),v(t),b()}catch(e){r.error(`[TokenStats] load stats failed:`,e),i&&(i.style.display=`none`),a&&(a.textContent=t(`tokenStats.loadFailed`),a.style.display=``)}}function g(e){if(!l)return;if(!e||e.apiCallCount===0){l.innerHTML=``;return}let n=e.maxContextUsageRate||0,r=C(n);l.innerHTML=`
|
|
475
|
+
`,document.body.appendChild(Q),Q.querySelector(`.sap-close`).addEventListener(`click`,Sm),Q.querySelector(`.sap-lock`).addEventListener(`click`,gm),Q.querySelector(`.sap-copy`).addEventListener(`click`,Em),Q.querySelector(`.sap-transfer`).addEventListener(`click`,Dm),Q.querySelector(`.sap-regen`).addEventListener(`click`,()=>{im&&am&&km()}),Tm(Q.querySelector(`.sap-header`)),Q)}function mm(){if(!Q)return;Q.querySelector(`.sap-close`).title=t(`sidePanel.popupClose`);let e=Q.querySelector(`.sap-copy`);e.textContent=t(`sidePanel.popupCopy`),e.title=t(`sidePanel.popupCopy`);let n=Q.querySelector(`.sap-transfer`);n.textContent=t(`sidePanel.popupTransfer`),n.title=t(`sidePanel.popupTransfer`);let r=Q.querySelector(`.sap-regen`);r.textContent=t(`sidePanel.popupRegenerate`),r.title=t(`sidePanel.popupRegenerate`),hm()}function hm(){if(!Q)return;let e=Q.querySelector(`.sap-lock`);e&&(e.classList.toggle(`locked`,lm),e.title=t(lm?`sidePanel.popupUnlock`:`sidePanel.popupLock`),e.innerHTML=lm?`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>`:`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 9.9-1"/></svg>`)}function gm(){lm=!lm,hm()}function _m(e,t){let n=pm(),r=window.innerWidth,i=window.innerHeight,a=t+12,o=e-320/2;o<8&&(o=8),o+320>r-8&&(o=r-320-8),a+280>i-8&&(a=t-280-12),a<8&&(a=8),n.style.position=`fixed`,n.style.top=a+`px`,n.style.left=o+`px`}function vm(e){let n=pm();mm(),n.querySelector(`.sap-title`).textContent=e||t(`sidePanel.popupTitle`),n.querySelector(`.sap-body`).innerHTML=`<div class="sap-loading">${A(t(`sidePanel.popupLoading`))}</div>`,n.classList.add(`show`),Q.style.display=`block`}function ym(){return!!Q&&Q.classList.contains(`show`)}function bm(e,t=!0){let n=Q?.querySelector(`.sap-body`);n&&(n.innerHTML=`<div class="sap-content markdown-body">${e}</div>`,t&&(n.scrollTop=n.scrollHeight))}function xm(e){let t=Q?.querySelector(`.sap-body`);t&&(t.innerHTML=`<div class="sap-error">${A(e)}</div>`)}function Sm(){cm&&nm&&chrome.runtime.sendMessage({type:`CANCEL_REACT`,sessionId:nm}).catch(()=>{}),Q&&(Q.classList.remove(`show`),Q.style.display=`none`),nm=null,rm=``,cm=!1,lm=!1}function Cm(e){if(!ym()||lm||Q.contains(e.target))return;let t=document.getElementById(`selectionFloatingMenu`);t&&t.contains(e.target)||Sm()}function wm(e){e.key===`Escape`&&(!ym()||lm||Sm())}function Tm(e){let t=!1,n,r,i,a;e.addEventListener(`mousedown`,e=>{if(e.target.closest(`.sap-close, .sap-lock`))return;t=!0,n=e.clientX,r=e.clientY;let o=Q.getBoundingClientRect();i=o.top,a=o.left,e.preventDefault()}),document.addEventListener(`mousemove`,e=>{if(!t)return;let o=e.clientX-n,s=e.clientY-r;Q.style.position=`fixed`,Q.style.top=i+s+`px`,Q.style.left=a+o+`px`}),document.addEventListener(`mouseup`,()=>{t=!1})}function Em(){rm&&navigator.clipboard.writeText(rm).then(()=>{k(t(`sidePanel.popupCopied`))}).catch(()=>{let e=document.createElement(`textarea`);e.value=rm,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e),k(t(`sidePanel.popupCopied`))})}function Dm(){if(!rm||!im)return;An()&&Qr();let e=rm,n=im.content,r=`${om?`[${t(`sidePanel.popupContextLabel`)}]\n${om}\n\n`:``}[${t(`sidePanel.selectedContentLabel`)}]\n${am}\n\n[${t(`sidePanel.userQuestionLabel`)}]\n${im.content}`;E(async()=>{let{addMessage:e}=await import(`./context-indicator-ZNMB0fDM.js`).then(e=>e.V);return{addMessage:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(({addMessage:i})=>{i(`user`,n,!0,[],null,!1,r),v.messageHistory.push({role:`user`,content:r,timestamp:new Date().toISOString()}),i(`assistant`,e,!0),v.messageHistory.push({role:`assistant`,content:e}),E(async()=>{let{saveCurrentSession:e}=await import(`./context-indicator-ZNMB0fDM.js`).then(e=>e.Sr);return{saveCurrentSession:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(({saveCurrentSession:e})=>{e()}),Promise.all([E(()=>import(`./context-indicator-ZNMB0fDM.js`).then(e=>e.pt),__vite__mapDeps([0,1,2,3,4,5,6,7,8])),new Promise(e=>requestAnimationFrame(e))]).then(([{autoScrollToBottom:e}])=>{e(document.getElementById(`chatContainer`),{force:!0,smooth:!0}),k(t(`sidePanel.popupTransferred`))})}),Sm()}function Om(e,t,n){let{context:r,truncated:i}=dm(n,t);im=e,am=t,om=r,sm=i,km()}function km(){rm=``,cm=!0,vm(im?.content);let e=fm(am,om,im.content,sm);nm=`popup_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,chrome.runtime.sendMessage({type:`SIDEPANEL_POPUP_ASK`,sessionId:nm,messages:e}).catch(e=>{r.error(`[SelectionPopup] sendMessage failed:`,e),xm(t(`sidePanel.popupRequestFailed`)),cm=!1})}var Am=!1;function jm(){Am||(Am=!0,chrome.runtime.onMessage.addListener(e=>{if(!(!e||!e.type)&&e.type.startsWith(`SIDEPANEL_POPUP_`)&&e.sessionId===nm){if(e.type===`SIDEPANEL_POPUP_STREAM_CHUNK`)e.delta&&(rm+=e.delta,bm(ut(rm)));else if(e.type===`SIDEPANEL_POPUP_STREAM_DONE`)cm=!1,e.finalContent&&(rm=e.finalContent),bm(ut(rm));else if(e.type===`SIDEPANEL_POPUP_STREAM_ERROR`){if(!cm)return;cm=!1,xm(e.error||t(`sidePanel.popupRequestFailed`))}}}))}function Mm(){jm(),document.addEventListener(`mousedown`,Cm),document.addEventListener(`keydown`,wm)}function Nm(e,t,n,r,i){!t||!e||(jm(),_m(n,r),lm=!1,Om(e,t,i||v.currentSelectionRange))}e(`zh`,{tokenStats:{clearConfirmMessage:`确定要清空所有 Token 使用统计吗?此操作不可撤销。`,loadFailed:`加载失败`,currentSessionNoData:`当前会话暂无数据`,totalTokenUsage:`总 Token 消耗`,apiCallCount:`API 调用次数`,contextUsageRate:`上下文使用率`,max:`最大`,avg:`平均`,min:`最小`,totalTokens:`总 Token`,totalSessions:`总会话数`,totalApiCalls:`总 API 调用`,callTypeNonStream:`普通`,callTypeStream:`流式`,callTypeReflection:`反思`,callTypeToolReflection:`工具反思`,callTypeSubtaskReflection:`子任务反思`,tabTrend:`趋势`,tabDistribution:`分布`,tabGlobal:`全局`,topCardSessionTokens:`本次 Token`,topCardSessionCalls:`本次调用`,topCardContextPeak:`上下文峰值`,sparklineTitle:`最近 20 次调用趋势`,distPromptVsCompletion:`Prompt / Completion 占比`,distPrompt:`Prompt`,distCompletion:`Completion`,distByModel:`按模型分布`,distByCallType:`按调用类型分布`,distNoData:`暂无分布数据`,globalSparklineTitle:`最近 30 天趋势`,globalNoDailyData:`所选范围内暂无数据`,globalTotalTokens:`总 Token`,globalTotalSessions:`总会话数`,globalTotalApiCalls:`总 API 调用`}}),e(`en`,{tokenStats:{clearConfirmMessage:`Are you sure you want to clear all Token usage statistics? This action cannot be undone.`,loadFailed:`Load failed`,currentSessionNoData:`No data for current session`,totalTokenUsage:`Total Token Usage`,apiCallCount:`API Call Count`,contextUsageRate:`Context Usage Rate`,max:`Max`,avg:`Avg`,min:`Min`,totalTokens:`Total Tokens`,totalSessions:`Total Sessions`,totalApiCalls:`Total API Calls`,callTypeNonStream:`Normal`,callTypeStream:`Stream`,callTypeReflection:`Reflection`,callTypeToolReflection:`Tool Reflection`,callTypeSubtaskReflection:`Subtask Reflection`,tabTrend:`Trend`,tabDistribution:`Distribution`,tabGlobal:`Global`,topCardSessionTokens:`Session Tokens`,topCardSessionCalls:`Session Calls`,topCardContextPeak:`Context Peak`,sparklineTitle:`Last 20 Calls Trend`,distPromptVsCompletion:`Prompt / Completion Ratio`,distPrompt:`Prompt`,distCompletion:`Completion`,distByModel:`By Model`,distByCallType:`By Call Type`,distNoData:`No distribution data`,globalSparklineTitle:`Last 30 Days Trend`,globalNoDailyData:`No data in selected range`,globalTotalTokens:`Total Tokens`,globalTotalSessions:`Total Sessions`,globalTotalApiCalls:`Total API Calls`}});function Pm(e,n){let i=document.getElementById(`tokenStatsOverlay`),a=document.getElementById(`tokenStatsClose`),o=document.getElementById(`tokenStatsRefreshBtn`),s=document.getElementById(`tokenStatsClearBtn`),c=document.getElementById(`tokenStatsTabNav`),l=document.getElementById(`tokenStatsTopCards`);if(!i)return;let u=`trend`,d=`month`;function f(){i.style.display=`flex`,h()}function p(){i.style.display=`none`}if(window.openTokenStats=f,a&&a.addEventListener(`click`,p),i&&i.addEventListener(`click`,e=>{e.target===i&&p()}),o&&o.addEventListener(`click`,h),s&&s.addEventListener(`click`,async()=>{await n(t(`tokenStats.clearConfirmMessage`),t(`toolStats.clearTitle`))&&(await ge(),h())}),c){c.addEventListener(`click`,e=>{let t=e.target.closest(`.token-tab-btn`);if(!t)return;let n=t.dataset.tab;if(n===u)return;c.querySelectorAll(`.token-tab-btn`).forEach(e=>{e.classList.remove(`active`),e.style.borderBottomColor=`transparent`,e.style.color=`var(--text-secondary)`}),t.classList.add(`active`),t.style.borderBottomColor=`var(--brand-500)`,t.style.color=`var(--brand-500)`,document.querySelectorAll(`.token-tab-content`).forEach(e=>{e.style.display=`none`});let r=document.getElementById(`tokenTab${n.charAt(0).toUpperCase()+n.slice(1)}`);r&&(r.style.display=n===`global`?`flex`:``),u=n});let e=c.querySelector(`.token-tab-btn.active`);e&&(e.style.borderBottomColor=`var(--brand-500)`,e.style.color=`var(--brand-500)`)}let m=document.querySelectorAll(`.token-time-range-btn`);m.forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.range;t!==d&&(d=t,m.forEach(e=>{e.classList.remove(`active`),e.style.border=`1px solid var(--border-default)`,e.style.background=`var(--bg-surface)`,e.style.color=`var(--text-secondary)`}),e.classList.add(`active`),e.style.border=`1px solid var(--brand-500)`,e.style.background=`var(--brand-500)`,e.style.color=`var(--text-on-brand)`,b())})});async function h(){let n=e(),i=document.getElementById(`tokenStatsLoading`),a=document.getElementById(`tokenStatsEmpty`),o=document.getElementById(`tokenStatsContent`);i&&(i.style.display=``),a&&(a.style.display=`none`),o&&(o.style.display=`none`),c&&(c.style.display=`none`),l&&(l.style.display=`none`);try{let[e,t]=await Promise.all([Me(n),Ne()]);if(i&&(i.style.display=`none`),!(t&&t.totalApiCalls>0)){a&&(a.style.display=``);return}o&&(o.style.display=``),c&&(c.style.display=`flex`),l&&(l.style.display=``),g(e),ee(e),ie(e.records||[]),v(t),b()}catch(e){r.error(`[TokenStats] load stats failed:`,e),i&&(i.style.display=`none`),a&&(a.textContent=t(`tokenStats.loadFailed`),a.style.display=``)}}function g(e){if(!l)return;if(!e||e.apiCallCount===0){l.innerHTML=``;return}let n=e.maxContextUsageRate||0,r=C(n);l.innerHTML=`
|
|
476
476
|
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;">
|
|
477
477
|
<div style="background: var(--brand-soft-bg); border-radius: 8px; padding: 10px; text-align: center;">
|
|
478
478
|
<div style="font-size: 10px; color: var(--text-tertiary); margin-bottom: 4px;">${t(`tokenStats.topCardSessionTokens`)}</div>
|
|
@@ -601,7 +601,7 @@ Agent address: {url}
|
|
|
601
601
|
Are you sure you want to update the agent? It will install the latest patch version within the {version} minor range compatible with this extension, 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...`,agentVersionAhead:`Agent version is newer than this extension. Please update the extension from the store first`,agentAlreadyLatest:`Already at the latest compatible version`,agentUpdateAvailable:`Update available: v{current} → v{latest}`,updateFailed:`Update failed: {error}`,updateRequestFailed:`Update request failed: {error}`,stopAgentConfirm:`Agent name: {name}
|
|
602
602
|
Agent address: {url}
|
|
603
603
|
|
|
604
|
-
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`,defaultPromptImage:`Please look at the attached image and describe what you see`,defaultPromptFile:`Please read the attached file and summarize the key points`,defaultPromptAttachments:`Please review the attached image and file and summarize the key points`,defaultPromptKnowledge:`Please answer based on the knowledge base content I referenced`,defaultKnowledgeQuery:`key points summary`,defaultPromptPage:`Please summarize the main content of this page`,defaultPromptSelection:`Please continue based on the content I provided`,defaultPromptContext:`Please continue based on the context I provided`,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,n=t(`sidePanel.confirmAction`)){return new Promise(t=>{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){t(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(),t(!0)},u=()=>{c(),t(!1)},d=e=>{e.target===r&&(c(),t(!1))},f=e=>{e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),l()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),u())};i.textContent=n,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&&(v.chatConfig.autoCompaction=e.chatAutoCompaction.newValue===!0,Lm(),r.debug(`[SidePanel] auto-compaction config updated:`,v.chatConfig.autoCompaction)),t===`local`&&e.chatPersistSummaryToMemory&&(v.chatConfig.persistSummaryToMemory=e.chatPersistSummaryToMemory.newValue!==!1,Rm(),r.debug(`[SidePanel] persist-summary config updated:`,v.chatConfig.persistSummaryToMemory)),t===`local`&&e.chatMaxMemoryMessages&&(v.chatConfig.maxMemoryMessages=e.chatMaxMemoryMessages.newValue,Im(),r.debug(`[SidePanel] memory limitconfiguration updated:`,v.chatConfig.maxMemoryMessages)),t===`local`&&e.queueAutoCarry&&(v.chatConfig.queueAutoCarry=e.queueAutoCarry.newValue!==!1,r.debug(`[SidePanel] queue auto-carry updated:`,v.chatConfig.queueAutoCarry)),t===`local`&&e.queueAutoCarryEveryNIterations&&(v.chatConfig.queueAutoCarryEveryNIterations=e.queueAutoCarryEveryNIterations.newValue,r.debug(`[SidePanel] queue auto-carry interval updated:`,v.chatConfig.queueAutoCarryEveryNIterations))});function Im(){let e=document.getElementById(`memoryLimitLabel`);e&&(v.chatConfig.maxMemoryMessages!==null&&v.chatConfig.maxMemoryMessages!==void 0&&v.chatConfig.maxMemoryMessages>0?e.textContent=v.chatConfig.maxMemoryMessages:e.textContent=t(`sidePanel.memoryLimitAll`),e.title=t(`sidePanel.memoryLimitTitle`))}function Lm(){let e=document.getElementById(`autoCompactBtn`);e&&(e.checked=v.chatConfig.autoCompaction===!0)}function Rm(){let e=document.getElementById(`persistSummaryBtn`);e&&(e.checked=v.chatConfig.persistSummaryToMemory!==!1)}function zm(e){e.preventDefault(),e.stopPropagation();let t=document.getElementById(`memoryLimitDropdown`);if(t.classList.toggle(`show`),t.classList.contains(`show`)){let e=v.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 Bm(){let e=document.getElementById(`memoryLimitDropdown`),n=document.getElementById(`memoryLimitLabel`),r=e?.querySelector(`#memoryLimitInput`);if(!e||!n)return;Im(),n.addEventListener(`click`,zm);let i=document.getElementById(`autoCompactBtn`);i&&(i.checked=v.chatConfig.autoCompaction===!0,i.addEventListener(`change`,()=>{let e=i.checked;chrome.storage.local.set({chatAutoCompaction:e},()=>{v.chatConfig.autoCompaction=e,k(t(`sidePanel.configUpdated`),`success`)})}));let a=document.getElementById(`persistSummaryBtn`);a&&(a.checked=v.chatConfig.persistSummaryToMemory!==!1,a.addEventListener(`change`,()=>{let e=a.checked;chrome.storage.local.set({chatPersistSummaryToMemory:e},()=>{v.chatConfig.persistSummaryToMemory=e,k(t(`sidePanel.configUpdated`),`success`)})}));let o=e.querySelectorAll(`.memory-limit-option`);o.forEach(e=>{e.addEventListener(`click`,n=>{n.stopPropagation();let i=parseInt(e.dataset.value),a=i===0?null:i;o.forEach(e=>e.classList.remove(`selected`)),e.classList.add(`selected`),r&&(r.value=i===0?``:i),chrome.storage.local.set({chatMaxMemoryMessages:a},()=>{v.chatConfig.maxMemoryMessages=a,Im(),k(t(`sidePanel.configUpdated`),`success`)})})}),r&&(r.addEventListener(`click`,e=>e.stopPropagation()),r.addEventListener(`mousedown`,e=>e.stopPropagation()),r.addEventListener(`change`,e=>{e.stopPropagation();let n=e.target.value.trim(),r=n&&parseInt(n)>0?parseInt(n):null;o.forEach(e=>e.classList.remove(`selected`)),chrome.storage.local.set({chatMaxMemoryMessages:r},()=>{v.chatConfig.maxMemoryMessages=r,Im(),k(t(`sidePanel.configUpdated`),`success`)})})),document.getElementById(`memoryLimitConfigEntry`)?.addEventListener(`click`,()=>{chrome.runtime.sendMessage({type:`OPEN_OPTIONS_PAGE`,hash:`memory`})}),document.addEventListener(`click`,t=>{!e.contains(t.target)&&t.target!==n&&e.classList.remove(`show`)})}async function Vm(e){if(v.activeAgentId&&v.activeAgentId!=="default")try{let{updateAgent:t}=await E(async()=>{let{updateAgent:e}=await import(`./agent-store-_CfonCwg.js`).then(e=>e.t);return{updateAgent:e}},__vite__mapDeps([7,1,2,3]));await t(v.activeAgentId,{model:e})}catch{}else chrome.storage.local.set({modelName:e}),ue(e)}async function Hm(){try{let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),t=Fm(e.pairedAgents),n=e.activeAgentId,r=t.find(e=>e.id===n&&!e.disabled);if(!r){v.agentPlatform={connected:!1},$(v.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){v.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&&v.agentVersions.set(n,t.version),t.workdir&&v.agentWorkdirs.set(n,t.workdir),t.homeDir&&v.agentHomeDirs.set(n,t.homeDir);let e=vh(t.platformName||t.platform,t.arch);e&&v.agentSystemInfos.set(n,e)}else v.agentPlatform={connected:!1}}else v.agentPlatform={connected:!1}}catch{v.agentPlatform={connected:!1}}else v.agentPlatform={connected:!1};$(v.agentPlatform),si()}catch{}}async function Um(e,t,n){if(v.activeAgentId&&v.activeAgentId!=="default")try{let{updateAgent:n}=await E(async()=>{let{updateAgent:e}=await import(`./agent-store-_CfonCwg.js`).then(e=>e.t);return{updateAgent:e}},__vite__mapDeps([7,1,2,3]));await n(v.activeAgentId,{temperature:e,topP:t})}catch{}else chrome.storage.local.set({temperature:e,topP:t,selectedTempIndex:n})}function Wm(){let e=document.getElementById(`currentModelTag`);if(!e)return;let t=v.currentModel||``;e.textContent=t,e.title=t,e.style.display=t?``:`none`}var Gm=new Set,Km=0;function qm(){let e=document.getElementById(`workdirTag`);e&&(e.dataset.locked=Rr(v.activeSessionId)?`true`:`false`)}async function Jm(){let e=++Km,n=document.getElementById(`workdirTag`),i=document.getElementById(`workdirTagName`);if(!n||!i)return;let a=v.activeSessionId||null,o=Array.isArray(v.enabledTools)&&v.enabledTools.includes(`agent_exec`);if(v.agentPlatform?.connected!==!0||!o){n.style.display=`none`;return}let c=null;try{c=await p(a)}catch(e){r.debug(`[WorkdirTag] resolve failed:`,e&&e.message)}if(e!==Km)return;let l=c&&c.workdir||``;if(!l){n.style.display=`none`;return}n.style.display=``,i.textContent=s(l,{homeDir:v.agentPlatform?.homeDir||``}),qm();try{let{getWorkspaceRoot:e}=await E(async()=>{let{getWorkspaceRoot:e}=await import(`./workspace-manager-DLH5XabD.js`).then(e=>e.j);return{getWorkspaceRoot:e}},__vite__mapDeps([8,1,2,3])),t=await e(a),i=!!(t&&t!==l);i&&c.scope==="default"?(n.dataset.invalid=`false`,em(a).then(e=>{e&&Jm()}).catch(e=>r.debug(`[WorkdirTag] reconcile failed:`,e&&e.message))):n.dataset.invalid=i?`true`:`false`}catch{n.dataset.invalid=`false`}if(e===Km&&(n.title=`${l}${c.scope===`session`?t(`workdirTag.sessionScope`):t(`workdirTag.defaultScope`)}${n.dataset.invalid===`true`?t(`workdirTag.pathMissing`):``}`,c.boundWorkdir&&c.scope==="default")){let e=`${a||``}::${c.agentId||``}`;Gm.has(e)||(Gm.add(e),k(t(`workdirTag.agentSwitched`),`warning`))}}function Ym(){let e=document.getElementById(`workdirTag`);e&&(e.setAttribute(`aria-label`,t(`workdirTag.tagHint`)),e.addEventListener(`click`,async e=>{if(e.stopPropagation(),Rr(v.activeSessionId)){qm(),k(t(`workdirTag.lockedHint`),`warning`);return}qm();let{showSwitchWorkdirDialog:n}=await E(async()=>{let{showSwitchWorkdirDialog:e}=await import(`./context-indicator-O2JgFDbD.js`).then(e=>e.ln);return{showSwitchWorkdirDialog:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));await n({sessionId:v.activeSessionId||null})})),Jm(),document.addEventListener(`session-switched`,()=>{Jm()}),document.addEventListener(`session-workdir-changed`,()=>{Jm()}),document.addEventListener(`agent-model-changed`,()=>{Jm()}),document.addEventListener(`agent-tools-changed`,()=>{Jm()}),document.addEventListener(`generating-state-changed`,()=>{qm()}),document.addEventListener(`generation-ended`,()=>{qm()}),In(()=>{qm()})}function Xm(){let e=document.getElementById(`currentModelTag`);e&&e.addEventListener(`click`,e=>{e.stopPropagation(),document.getElementById(`tempDisplay`)?.click()}),Wm()}function Zm(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=g(t),r.style.display=``):r.style.display=`none`),Wm()}function Qm(e,n){let r=document.getElementById(`tempDropdown`);if(!r){typeof n==`function`&&n();return}let i=r.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=`
|
|
604
|
+
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`,defaultPromptImage:`Please look at the attached image and describe what you see`,defaultPromptFile:`Please read the attached file and summarize the key points`,defaultPromptAttachments:`Please review the attached image and file and summarize the key points`,defaultPromptKnowledge:`Please answer based on the knowledge base content I referenced`,defaultKnowledgeQuery:`key points summary`,defaultPromptPage:`Please summarize the main content of this page`,defaultPromptSelection:`Please continue based on the content I provided`,defaultPromptContext:`Please continue based on the context I provided`,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,n=t(`sidePanel.confirmAction`)){return new Promise(t=>{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){t(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(),t(!0)},u=()=>{c(),t(!1)},d=e=>{e.target===r&&(c(),t(!1))},f=e=>{e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),l()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),u())};i.textContent=n,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&&(v.chatConfig.autoCompaction=e.chatAutoCompaction.newValue===!0,Lm(),r.debug(`[SidePanel] auto-compaction config updated:`,v.chatConfig.autoCompaction)),t===`local`&&e.chatPersistSummaryToMemory&&(v.chatConfig.persistSummaryToMemory=e.chatPersistSummaryToMemory.newValue!==!1,Rm(),r.debug(`[SidePanel] persist-summary config updated:`,v.chatConfig.persistSummaryToMemory)),t===`local`&&e.chatMaxMemoryMessages&&(v.chatConfig.maxMemoryMessages=e.chatMaxMemoryMessages.newValue,Im(),r.debug(`[SidePanel] memory limitconfiguration updated:`,v.chatConfig.maxMemoryMessages)),t===`local`&&e.queueAutoCarry&&(v.chatConfig.queueAutoCarry=e.queueAutoCarry.newValue!==!1,r.debug(`[SidePanel] queue auto-carry updated:`,v.chatConfig.queueAutoCarry)),t===`local`&&e.queueAutoCarryEveryNIterations&&(v.chatConfig.queueAutoCarryEveryNIterations=e.queueAutoCarryEveryNIterations.newValue,r.debug(`[SidePanel] queue auto-carry interval updated:`,v.chatConfig.queueAutoCarryEveryNIterations))});function Im(){let e=document.getElementById(`memoryLimitLabel`);e&&(v.chatConfig.maxMemoryMessages!==null&&v.chatConfig.maxMemoryMessages!==void 0&&v.chatConfig.maxMemoryMessages>0?e.textContent=v.chatConfig.maxMemoryMessages:e.textContent=t(`sidePanel.memoryLimitAll`),e.title=t(`sidePanel.memoryLimitTitle`))}function Lm(){let e=document.getElementById(`autoCompactBtn`);e&&(e.checked=v.chatConfig.autoCompaction===!0)}function Rm(){let e=document.getElementById(`persistSummaryBtn`);e&&(e.checked=v.chatConfig.persistSummaryToMemory!==!1)}function zm(e){e.preventDefault(),e.stopPropagation();let t=document.getElementById(`memoryLimitDropdown`);if(t.classList.toggle(`show`),t.classList.contains(`show`)){let e=v.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 Bm(){let e=document.getElementById(`memoryLimitDropdown`),n=document.getElementById(`memoryLimitLabel`),r=e?.querySelector(`#memoryLimitInput`);if(!e||!n)return;Im(),n.addEventListener(`click`,zm);let i=document.getElementById(`autoCompactBtn`);i&&(i.checked=v.chatConfig.autoCompaction===!0,i.addEventListener(`change`,()=>{let e=i.checked;chrome.storage.local.set({chatAutoCompaction:e},()=>{v.chatConfig.autoCompaction=e,k(t(`sidePanel.configUpdated`),`success`)})}));let a=document.getElementById(`persistSummaryBtn`);a&&(a.checked=v.chatConfig.persistSummaryToMemory!==!1,a.addEventListener(`change`,()=>{let e=a.checked;chrome.storage.local.set({chatPersistSummaryToMemory:e},()=>{v.chatConfig.persistSummaryToMemory=e,k(t(`sidePanel.configUpdated`),`success`)})}));let o=e.querySelectorAll(`.memory-limit-option`);o.forEach(e=>{e.addEventListener(`click`,n=>{n.stopPropagation();let i=parseInt(e.dataset.value),a=i===0?null:i;o.forEach(e=>e.classList.remove(`selected`)),e.classList.add(`selected`),r&&(r.value=i===0?``:i),chrome.storage.local.set({chatMaxMemoryMessages:a},()=>{v.chatConfig.maxMemoryMessages=a,Im(),k(t(`sidePanel.configUpdated`),`success`)})})}),r&&(r.addEventListener(`click`,e=>e.stopPropagation()),r.addEventListener(`mousedown`,e=>e.stopPropagation()),r.addEventListener(`change`,e=>{e.stopPropagation();let n=e.target.value.trim(),r=n&&parseInt(n)>0?parseInt(n):null;o.forEach(e=>e.classList.remove(`selected`)),chrome.storage.local.set({chatMaxMemoryMessages:r},()=>{v.chatConfig.maxMemoryMessages=r,Im(),k(t(`sidePanel.configUpdated`),`success`)})})),document.getElementById(`memoryLimitConfigEntry`)?.addEventListener(`click`,()=>{chrome.runtime.sendMessage({type:`OPEN_OPTIONS_PAGE`,hash:`memory`})}),document.addEventListener(`click`,t=>{!e.contains(t.target)&&t.target!==n&&e.classList.remove(`show`)})}async function Vm(e){if(v.activeAgentId&&v.activeAgentId!=="default")try{let{updateAgent:t}=await E(async()=>{let{updateAgent:e}=await import(`./agent-store-_CfonCwg.js`).then(e=>e.t);return{updateAgent:e}},__vite__mapDeps([7,1,2,3]));await t(v.activeAgentId,{model:e})}catch{}else chrome.storage.local.set({modelName:e}),ue(e)}async function Hm(){try{let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),t=Fm(e.pairedAgents),n=e.activeAgentId,r=t.find(e=>e.id===n&&!e.disabled);if(!r){v.agentPlatform={connected:!1},$(v.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){v.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&&v.agentVersions.set(n,t.version),t.workdir&&v.agentWorkdirs.set(n,t.workdir),t.homeDir&&v.agentHomeDirs.set(n,t.homeDir);let e=vh(t.platformName||t.platform,t.arch);e&&v.agentSystemInfos.set(n,e)}else v.agentPlatform={connected:!1}}else v.agentPlatform={connected:!1}}catch{v.agentPlatform={connected:!1}}else v.agentPlatform={connected:!1};$(v.agentPlatform),si()}catch{}}async function Um(e,t,n){if(v.activeAgentId&&v.activeAgentId!=="default")try{let{updateAgent:n}=await E(async()=>{let{updateAgent:e}=await import(`./agent-store-_CfonCwg.js`).then(e=>e.t);return{updateAgent:e}},__vite__mapDeps([7,1,2,3]));await n(v.activeAgentId,{temperature:e,topP:t})}catch{}else chrome.storage.local.set({temperature:e,topP:t,selectedTempIndex:n})}function Wm(){let e=document.getElementById(`currentModelTag`);if(!e)return;let t=v.currentModel||``;e.textContent=t,e.title=t,e.style.display=t?``:`none`}var Gm=new Set,Km=0;function qm(){let e=document.getElementById(`workdirTag`);e&&(e.dataset.locked=Rr(v.activeSessionId)?`true`:`false`)}async function Jm(){let e=++Km,n=document.getElementById(`workdirTag`),i=document.getElementById(`workdirTagName`);if(!n||!i)return;let a=v.activeSessionId||null,o=Array.isArray(v.enabledTools)&&v.enabledTools.includes(`agent_exec`);if(v.agentPlatform?.connected!==!0||!o){n.style.display=`none`;return}let c=null;try{c=await p(a)}catch(e){r.debug(`[WorkdirTag] resolve failed:`,e&&e.message)}if(e!==Km)return;let l=c&&c.workdir||``;if(!l){n.style.display=`none`;return}n.style.display=``,i.textContent=s(l,{homeDir:v.agentPlatform?.homeDir||``}),qm();try{let{getWorkspaceRoot:e}=await E(async()=>{let{getWorkspaceRoot:e}=await import(`./workspace-manager-DLH5XabD.js`).then(e=>e.j);return{getWorkspaceRoot:e}},__vite__mapDeps([8,1,2,3])),t=await e(a),i=!!(t&&t!==l);i&&c.scope==="default"?(n.dataset.invalid=`false`,em(a).then(e=>{e&&Jm()}).catch(e=>r.debug(`[WorkdirTag] reconcile failed:`,e&&e.message))):n.dataset.invalid=i?`true`:`false`}catch{n.dataset.invalid=`false`}if(e===Km&&(n.title=`${l}${c.scope===`session`?t(`workdirTag.sessionScope`):t(`workdirTag.defaultScope`)}${n.dataset.invalid===`true`?t(`workdirTag.pathMissing`):``}`,c.boundWorkdir&&c.scope==="default")){let e=`${a||``}::${c.agentId||``}`;Gm.has(e)||(Gm.add(e),k(t(`workdirTag.agentSwitched`),`warning`))}}function Ym(){let e=document.getElementById(`workdirTag`);e&&(e.setAttribute(`aria-label`,t(`workdirTag.tagHint`)),e.addEventListener(`click`,async e=>{if(e.stopPropagation(),Rr(v.activeSessionId)){qm(),k(t(`workdirTag.lockedHint`),`warning`);return}qm();let{showSwitchWorkdirDialog:n}=await E(async()=>{let{showSwitchWorkdirDialog:e}=await import(`./context-indicator-ZNMB0fDM.js`).then(e=>e.ln);return{showSwitchWorkdirDialog:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));await n({sessionId:v.activeSessionId||null})})),Jm(),document.addEventListener(`session-switched`,()=>{Jm()}),document.addEventListener(`session-workdir-changed`,()=>{Jm()}),document.addEventListener(`agent-model-changed`,()=>{Jm()}),document.addEventListener(`agent-tools-changed`,()=>{Jm()}),document.addEventListener(`generating-state-changed`,()=>{qm()}),document.addEventListener(`generation-ended`,()=>{qm()}),In(()=>{qm()})}function Xm(){let e=document.getElementById(`currentModelTag`);e&&e.addEventListener(`click`,e=>{e.stopPropagation(),document.getElementById(`tempDisplay`)?.click()}),Wm()}function Zm(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=g(t),r.style.display=``):r.style.display=`none`),Wm()}function Qm(e,n){let r=document.getElementById(`tempDropdown`);if(!r){typeof n==`function`&&n();return}let i=r.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=`
|
|
605
605
|
<div class="model-section-title" data-i18n="model.selectModel">${t(`model.selectModel`)}</div>
|
|
606
606
|
<div class="section-select" id="modelSelect">
|
|
607
607
|
<div class="section-select-row" id="modelSelectRow">
|
|
@@ -666,7 +666,7 @@ Are you sure you want to stop the agent service? You will not be able to connect
|
|
|
666
666
|
</div>
|
|
667
667
|
<h2>${t(`sidePanel.welcomeTitle`)}</h2>
|
|
668
668
|
<p>${t(`sidePanel.welcomeSubtitle`)}</p>
|
|
669
|
-
`,a.appendChild(e)}if(r.debug(`[SidePanel] session-switched: pendingTask?`,l,`pendingSessionIds:`,[...v.pendingCallApiSessionIds],`activeSessionId:`,n,`hasCancelApi:`,!!v.pendingCancelApi),l&&(r.debug(`[SidePanel] switch back tobackground task session,rebuildstreamingoutput element`),xr(n)),Ya(n),!e.detail?.skipScrollRestore){let e=`scrollPosition_`+(n||`default`);chrome.storage.local.get([e],t=>{t[e]!==void 0&&setTimeout(async()=>{let n=document.getElementById(`chatContainer`);n&&(n.scrollTop=t[e]);let{updateScrollButtonState:r}=await E(async()=>{let{updateScrollButtonState:e}=await import(`./context-indicator-O2JgFDbD.js`).then(e=>e.pt);return{updateScrollButtonState:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));r()},150)})}}),document.addEventListener(`session-cache-invalidate`,e=>{let{sessionId:t}=e.detail||{};t&&jh(t)}),document.querySelectorAll(`.model-option`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let n=e.dataset.value;v.currentModel=n,Zm(n),Vm(n),Gr()})}),document.addEventListener(`agent-model-changed`,()=>{Zm(v.currentModel);let e=document.getElementById(`tempSlider`),t=document.getElementById(`tempNumberInput`),n=document.getElementById(`tempIconValue`);e&&(e.value=v.temperature),t&&(t.value=v.temperature.toFixed(2)),n&&(n.textContent=v.temperature.toFixed(2)),_()}),document.addEventListener(`click`,e=>{let t=document.getElementById(`promptDropdown`),n=document.getElementById(`promptSelector`),r=document.getElementById(`agentAtSelector`),i=document.getElementById(`selectionFloatingMenu`);n.contains(e.target)||(t.classList.remove(`show`),j()),r&&!r.contains(e.target)&&on();let a=document.getElementById(`fileAtSelector`);if(a&&!a.contains(e.target)&&cf(),i&&!i.contains(e.target)){let t=window.getSelection(),n=ms(e.target),r=t&&!t.isCollapsed&&ms(t.anchorNode);(!n||!r)&&window.hideFloatingMenu()}});let w=document.getElementById(`stopCompanionBtn`);function se(){let e=!!(a&&a.value&&a.value.trim())||Xr();return v.isGenerating&&e}function ce(){a&&a.value&&a.value.trim();let e=v.isGenerating,n=se();s.classList.toggle(`queue-mode`,n),s.classList.toggle(`stop-mode`,e&&!n),n?(s.innerHTML=`<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h11"/><path d="M3 12h11"/><path d="M3 18h7"/><path d="M17.5 10v8"/><path d="M14.5 15.5L17.5 18.5l3-3"/></svg>`,s.title=t(`queue.enqueueBtn`)):e?(s.innerHTML=`<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect></svg>`,s.title=t(`sidePanel.sendBtnStop`)):(s.innerHTML=`<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor"><path d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8-8-8z"/></svg>`,s.title=t(`sidePanel.sendBtnSend`)),s.disabled=!1,s.style.opacity=``,s.style.cursor=``,w&&(w.style.display=n?``:`none`,w.disabled=!1,w.style.opacity=``,w.style.cursor=``)}s.addEventListener(`click`,()=>{if(!v.isGenerating){Fi();return}se()?gn():Ir(s)}),w?.addEventListener(`click`,()=>Ir(w));function T(e){if(!v.isGenerating)return!1;let n=v.activeSessionId;return n?On(n)?(Fn(n),Ir(w&&w.style.display!==`none`?w:e||s)?(k(t(`queue.stopAndSendStarted`),`success`,2500),!0):(Yt(n),!0)):(k(t(`queue.stopAndSendEmpty`),`warning`,3e3),!1):!1}function ue(e,{isPrimarySend:t=!1}={}){if(!e)return;let n=()=>t&&se();e.addEventListener(`contextmenu`,t=>{n()||!v.isGenerating||!On(v.activeSessionId)||(t.preventDefault(),T(e))});let r=null,i=()=>{r&&=(clearTimeout(r),null)};e.addEventListener(`pointerdown`,t=>{t.pointerType===`mouse`&&t.button!==0||n()||!v.isGenerating||!On(v.activeSessionId)||(i(),r=setTimeout(()=>{r=null,T(e)},600))});for(let t of[`pointerup`,`pointerleave`,`pointercancel`])e.addEventListener(t,i)}ue(s,{isPrimarySend:!0}),ue(w),document.addEventListener(`queue-stop-and-send`,()=>{T(w&&w.style.display!==`none`?w:s)}),document.addEventListener(`generating-state-changed`,ce),a.addEventListener(`input`,ce),document.addEventListener(`input-attachments-changed`,ce),document.addEventListener(`voice-draft-written`,ce);let de=document.getElementById(`shortcutsBtn`),fe=document.getElementById(`shortcutsModal`),pe=document.getElementById(`shortcutsCloseBtn`);function me(){fe&&(fe.style.display=`flex`)}function he(){fe&&(fe.style.display=`none`)}de&&de.addEventListener(`click`,e=>{e.stopPropagation(),me();let t=document.getElementById(`headerMoreDropdown`);t&&t.classList.remove(`show`)}),pe&&pe.addEventListener(`click`,he),fe&&fe.addEventListener(`click`,e=>{e.target===fe&&he()});let ge=ps();Sn(),$n({adjustInputHeight:ee}).catch(e=>{r.warn(`[SidePanel] initVoiceInput failed:`,e?.message||e)}),document.addEventListener(`keydown`,e=>{if((e.ctrlKey||e.metaKey)&&e.key===`t`){e.preventDefault();let t=document.getElementById(`toolsPopup`);t&&t.style.display!==`none`?Ai():Ri()}if(e.key===`Escape`&&Kn()){e.preventDefault();return}if(!(e.key===`Escape`&&ge.handleEscape())){if(e.key===`Escape`&&fe&&fe.style.display!==`none`){he();return}if(e.altKey&&e.code===`Slash`){e.preventDefault(),me();return}if(e.altKey&&!e.shiftKey&&e.code===`KeyS`&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),Li();return}if(e.altKey&&e.shiftKey&&e.code===`KeyS`&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),Dr();return}if(Gt(e)){e.preventDefault(),cn();return}if(e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyN`){e.preventDefault(),fi();return}if(e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyW`){e.preventDefault(),jr();return}if(e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyE`){e.preventDefault();let t=document.querySelectorAll(`#chatContainer .message.user`),n=t[t.length-1];if(n){Wt(n);let e=document.getElementById(`userInput`);e&&e.focus()}return}if(e.altKey&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){e.preventDefault();let t=e.key===`ArrowUp`?`prev`:`next`;ge.jumpToMessage(t,e.ctrlKey||e.metaKey),ge.updateActiveQuestion();return}}}),a.addEventListener(`keydown`,e=>{let t=document.getElementById(`promptSelector`),n=document.getElementById(`promptDropdown`),r=document.getElementById(`agentAtSelector`),i=document.getElementById(`agentAtDropdown`);if(r.style.display!==`none`&&i.classList.contains(`show`)){let t=document.getElementById(`agentAtTabs`),n=t&&t.classList.contains(`merged-mode`);if(!n&&e.key===`Tab`){e.preventDefault();let t=Array.from(document.querySelectorAll(`#agentAtTabs .prompt-tab`)).map(e=>e.dataset.tab),n=e=>{let t=document.querySelector(`#agentAtTabs .prompt-tab[data-tab="${e}"]`);return!!t&&t.style.display!==`none`},r=t.indexOf(Ot);for(let e=0;e<t.length;e++)if(r=(r+1)%t.length,n(t[r])){di(t[r]);break}return}let r,i;n?(r=document.getElementById(`agentAtList`),i=v.selectedAgentAtIndex):Ot===`pages`?(r=document.getElementById(`agentPageList`),i=v.selectedPageIndex):Ot===`proxies`?(r=document.getElementById(`agentProxyList`),i=v.selectedProxyAtIndex):Ot===`knowledge`?(r=document.getElementById(`agentKnowledgeList`),i=v.selectedKnowledgeAtIndex):(r=document.getElementById(`agentAtList`),i=v.selectedAgentAtIndex);let a=r?r.querySelectorAll(`.prompt-item`):[],o=a.length;if(o!==0){if(e.key===`ArrowDown`){e.preventDefault();let t=i<0?0:(i+1)%o;n?(v.selectedAgentAtIndex=t,Ei(a)):Ot===`proxies`?(v.selectedProxyAtIndex=t,Ei(a)):Ot===`knowledge`?(v.selectedKnowledgeAtIndex=t,Ei(a)):Ot===`pages`?(v.selectedPageIndex=t,aa(a)):(v.selectedAgentAtIndex=t,Ei(a));return}else if(e.key===`ArrowUp`){e.preventDefault();let t=i<0||i===0?o-1:i-1;n?(v.selectedAgentAtIndex=t,Ei(a)):Ot===`proxies`?(v.selectedProxyAtIndex=t,Ei(a)):Ot===`knowledge`?(v.selectedKnowledgeAtIndex=t,Ei(a)):Ot===`pages`?(v.selectedPageIndex=t,aa(a)):(v.selectedAgentAtIndex=t,Ei(a));return}else if(e.key===`Enter`&&i>=0){e.preventDefault(),a[i].click(),(e.ctrlKey||e.metaKey)&&on();return}else if(e.key===`Escape`){on();return}}}let o=document.getElementById(`fileAtSelector`),s=document.getElementById(`fileAtDropdown`);if(o&&s&&o.style.display!==`none`&&s.classList.contains(`show`)){let t=document.getElementById(`fileAtList`),n=t?t.querySelectorAll(`.prompt-item`):[],r=n.length;if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),r>0&&(v.selectedFileAtIndex=e.key===`ArrowDown`?v.selectedFileAtIndex<0?0:(v.selectedFileAtIndex+1)%r:v.selectedFileAtIndex<0||v.selectedFileAtIndex===0?r-1:v.selectedFileAtIndex-1,pf(n));return}if(e.key===`Enter`&&r>0&&v.selectedFileAtIndex>=0){e.preventDefault(),n[v.selectedFileAtIndex].click();return}if(e.key===`Escape`){e.preventDefault(),cf();return}}if(t.style.display!==`none`&&n.classList.contains(`show`)){if(v.showMergedList){let t=n.querySelectorAll(`#promptList .prompt-item`),r=t.length;if(e.key===`ArrowDown`){e.preventDefault(),v.selectedPromptIndex<0?v.selectedPromptIndex=0:v.selectedPromptIndex=(v.selectedPromptIndex+1)%r,Dn(t);return}if(e.key===`ArrowUp`){e.preventDefault(),v.selectedPromptIndex<0||v.selectedPromptIndex===0?v.selectedPromptIndex=r-1:--v.selectedPromptIndex,Dn(t);return}if(e.key===`Enter`&&v.selectedPromptIndex>=0){e.preventDefault();let n=t[v.selectedPromptIndex];n.dataset.type===`skill`||n.dataset.type===`mcp`?(n.click(),(e.ctrlKey||e.metaKey)&&j()):e.ctrlKey||e.metaKey?$r(n.dataset.code):xt(n.dataset.code);return}if(e.key===`Escape`){j();return}return}if(v.activeDropdownTab===`skills`){let t=n.querySelectorAll(`#skillList .skill-list-item`),r=t.length;if(e.key===`ArrowDown`){e.preventDefault(),v.selectedSkillIndex<0?v.selectedSkillIndex=0:v.selectedSkillIndex=(v.selectedSkillIndex+1)%r,Wi(t);return}if(e.key===`ArrowUp`){e.preventDefault(),v.selectedSkillIndex<0||v.selectedSkillIndex===0?v.selectedSkillIndex=r-1:--v.selectedSkillIndex,Wi(t);return}if(e.key===`Enter`&&v.selectedSkillIndex>=0){e.preventDefault(),t[v.selectedSkillIndex].click(),(e.ctrlKey||e.metaKey)&&j();return}if(e.key===`Escape`){j();return}if(e.key===`Tab`){e.preventDefault();let t=document.getElementById(`mcpTab`);t&&t.style.display!==`none`?Rn(`mcp`):Rn(`prompts`);return}return}if(v.activeDropdownTab===`mcp`){let t=n.querySelectorAll(`#mcpList .mcp-list-item`),r=t.length;if(e.key===`ArrowDown`){e.preventDefault(),v.selectedMcpServiceIndex<0?v.selectedMcpServiceIndex=0:v.selectedMcpServiceIndex=(v.selectedMcpServiceIndex+1)%r,kt(t);return}if(e.key===`ArrowUp`){e.preventDefault(),v.selectedMcpServiceIndex<0||v.selectedMcpServiceIndex===0?v.selectedMcpServiceIndex=r-1:--v.selectedMcpServiceIndex,kt(t);return}if(e.key===`Enter`&&v.selectedMcpServiceIndex>=0){e.preventDefault(),t[v.selectedMcpServiceIndex].click(),(e.ctrlKey||e.metaKey)&&j();return}if(e.key===`Escape`){j();return}if(e.key===`Tab`){e.preventDefault(),Rn(`prompts`);return}return}let t=n.querySelectorAll(`#promptList .prompt-item`),r=t.length;if(e.key===`Tab`){let t=document.getElementById(`skillsTab`),n=document.getElementById(`mcpTab`);if(t&&t.style.display!==`none`){e.preventDefault(),Rn(`skills`);return}if(n&&n.style.display!==`none`){e.preventDefault(),Rn(`mcp`);return}}if(r!==0&&e.key===`ArrowDown`){e.preventDefault(),v.selectedPromptIndex<0?v.selectedPromptIndex=0:v.selectedPromptIndex=(v.selectedPromptIndex+1)%r,Dn(t);return}if(e.key===`ArrowUp`){e.preventDefault(),v.selectedPromptIndex<0||v.selectedPromptIndex===0?v.selectedPromptIndex=r-1:--v.selectedPromptIndex,Dn(t);return}if(e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&v.selectedPromptIndex>=0){e.preventDefault();let n=t[v.selectedPromptIndex].dataset.code;$r(n);return}if(e.key===`Enter`&&v.selectedPromptIndex>=0){e.preventDefault();let n=t[v.selectedPromptIndex].dataset.code;xt(n);return}if(e.key===`Escape`){j();return}}if(e.key===`Escape`){v.inputHistoryIndex>=0&&(v.inputHistoryIndex=-1),a.value&&(a.value=``,a.style.height=`auto`,a.dispatchEvent(new Event(`input`))),e.preventDefault();return}let c=t.style.display!==`none`&&n.classList.contains(`show`),l=r.style.display!==`none`&&i.classList.contains(`show`),u=o.style.display!==`none`&&s.classList.contains(`show`);if(e.key===`ArrowUp`&&v.inputHistoryIndex===-1&&!a.value.trim()&&!Xr()&&Vp()){e.preventDefault();return}if(!c&&!l&&!u){let t=vp({key:e.key,value:a.value,caret:a.selectionStart,history:v.inputHistory,index:v.inputHistoryIndex});if(t.handled){e.preventDefault(),v.inputHistoryIndex=t.index,a.value=t.value,a.dispatchEvent(new Event(`input`)),a.setSelectionRange(t.value.length,t.value.length);return}}if(e.key===`Enter`&&!e.shiftKey){if(v.isComposing)return;if(e.preventDefault(),cf(),v.isGenerating){if(e.altKey){$t(a.value);return}gn();return}Fi()}}),a.addEventListener(`compositionstart`,()=>{v.isComposing=!0}),a.addEventListener(`compositionend`,()=>{v.isComposing=!1}),a.addEventListener(`paste`,e=>{let t=e.clipboardData?.items;if(t)for(let n of t){if(n.type.startsWith(`image/`)&&v.enableImageInput){e.preventDefault();let t=n.getAsFile();t&&At(t);break}if(n.kind===`file`&&v.enableFileInput){e.preventDefault();let t=n.getAsFile();t&&yr([t]);break}}});let _e=document.getElementById(`fileAttachBtn`),ve=document.getElementById(`fileInput`);_e&&ve&&(_e.addEventListener(`click`,()=>{ve.click()}),ve.addEventListener(`change`,async()=>{if(ve.files.length>0){let e=Array.from(ve.files),n=e.filter(e=>e.type.startsWith(`image/`)),r=e.filter(e=>!e.type.startsWith(`image/`));if(n.length>0)if(v.enableImageInput)for(let e of n)await At(e);else k(t(`sidePanel.imageNotEnabled`)),yr(n);r.length>0&&yr(r),ve.value=``}}));let ye=document.querySelector(`.input-wrapper`),be=0;ye&&(ye.addEventListener(`dragenter`,e=>{e.preventDefault(),e.stopPropagation(),be++,ye.classList.add(`drag-over`)}),ye.addEventListener(`dragleave`,e=>{e.preventDefault(),e.stopPropagation(),be--,be<=0&&(be=0,ye.classList.remove(`drag-over`))}),ye.addEventListener(`dragover`,e=>{e.preventDefault(),e.stopPropagation()}),ye.addEventListener(`drop`,async e=>{e.preventDefault(),e.stopPropagation(),be=0,ye.classList.remove(`drag-over`);let n=e.dataTransfer.getData(`application/x-workspace-file`);if(n){e.preventDefault();try{let{path:e}=JSON.parse(n);if(e){Kr([e]);return}}catch(e){r.warn(`[SidePanel] parse workspace dragdata failed:`,e)}}let i=Array.from(e.dataTransfer.files);if(i.length>0){e.preventDefault();let n=i.filter(e=>e.type.startsWith(`image/`)),r=i.filter(e=>!e.type.startsWith(`image/`));if(n.length>0)if(v.enableImageInput)for(let e of n)await At(e);else k(t(`sidePanel.imageNotEnabled`)),yr(n);r.length>0&&yr(r);return}let o=e.dataTransfer.getData(`text/plain`);if(o&&(e.preventDefault(),a)){a.focus();let e=a.selectionStart??a.value.length,t=a.selectionEnd??a.value.length;a.value=a.value.slice(0,e)+o+a.value.slice(t),a.selectionStart=a.selectionEnd=e+o.length,a.dispatchEvent(new Event(`input`))}}));let xe=document.getElementById(`screenshotBtn`);xe&&xe.addEventListener(`click`,async()=>{if(v.enableImageInput)try{await Li()}catch(e){r.error(`[SidePanel] screenshot failed:`,e),k(t(`sidePanel.screenshotFailed`))}}),Gi(),a.addEventListener(`wheel`,e=>{v.isScrolling=!0;let t=a.style.height||a.offsetHeight+`px`;a.style.height=t,a.scrollHeight<=a.clientHeight+10&&(e.preventDefault(),e.stopPropagation()),setTimeout(()=>{v.isScrolling=!1},100)},{passive:!1}),a.addEventListener(`input`,e=>{let t=a.value,n=document.getElementById(`promptSelector`),r=document.getElementById(`promptDropdown`);document.getElementById(`agentAtSelector`),document.getElementById(`agentAtDropdown`);let i=t.lastIndexOf(`/`),o=t.lastIndexOf(`@`),s=t.lastIndexOf(`$`),c=e=>{if(e===-1||e!==0&&t[e-1]!==`
|
|
669
|
+
`,a.appendChild(e)}if(r.debug(`[SidePanel] session-switched: pendingTask?`,l,`pendingSessionIds:`,[...v.pendingCallApiSessionIds],`activeSessionId:`,n,`hasCancelApi:`,!!v.pendingCancelApi),l&&(r.debug(`[SidePanel] switch back tobackground task session,rebuildstreamingoutput element`),xr(n)),Ya(n),!e.detail?.skipScrollRestore){let e=`scrollPosition_`+(n||`default`);chrome.storage.local.get([e],t=>{t[e]!==void 0&&setTimeout(async()=>{let n=document.getElementById(`chatContainer`);n&&(n.scrollTop=t[e]);let{updateScrollButtonState:r}=await E(async()=>{let{updateScrollButtonState:e}=await import(`./context-indicator-ZNMB0fDM.js`).then(e=>e.pt);return{updateScrollButtonState:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));r()},150)})}}),document.addEventListener(`session-cache-invalidate`,e=>{let{sessionId:t}=e.detail||{};t&&jh(t)}),document.querySelectorAll(`.model-option`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let n=e.dataset.value;v.currentModel=n,Zm(n),Vm(n),Gr()})}),document.addEventListener(`agent-model-changed`,()=>{Zm(v.currentModel);let e=document.getElementById(`tempSlider`),t=document.getElementById(`tempNumberInput`),n=document.getElementById(`tempIconValue`);e&&(e.value=v.temperature),t&&(t.value=v.temperature.toFixed(2)),n&&(n.textContent=v.temperature.toFixed(2)),_()}),document.addEventListener(`click`,e=>{let t=document.getElementById(`promptDropdown`),n=document.getElementById(`promptSelector`),r=document.getElementById(`agentAtSelector`),i=document.getElementById(`selectionFloatingMenu`);n.contains(e.target)||(t.classList.remove(`show`),j()),r&&!r.contains(e.target)&&on();let a=document.getElementById(`fileAtSelector`);if(a&&!a.contains(e.target)&&cf(),i&&!i.contains(e.target)){let t=window.getSelection(),n=ms(e.target),r=t&&!t.isCollapsed&&ms(t.anchorNode);(!n||!r)&&window.hideFloatingMenu()}});let w=document.getElementById(`stopCompanionBtn`);function se(){let e=!!(a&&a.value&&a.value.trim())||Xr();return v.isGenerating&&e}function ce(){a&&a.value&&a.value.trim();let e=v.isGenerating,n=se();s.classList.toggle(`queue-mode`,n),s.classList.toggle(`stop-mode`,e&&!n),n?(s.innerHTML=`<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h11"/><path d="M3 12h11"/><path d="M3 18h7"/><path d="M17.5 10v8"/><path d="M14.5 15.5L17.5 18.5l3-3"/></svg>`,s.title=t(`queue.enqueueBtn`)):e?(s.innerHTML=`<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect></svg>`,s.title=t(`sidePanel.sendBtnStop`)):(s.innerHTML=`<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor"><path d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8-8-8z"/></svg>`,s.title=t(`sidePanel.sendBtnSend`)),s.disabled=!1,s.style.opacity=``,s.style.cursor=``,w&&(w.style.display=n?``:`none`,w.disabled=!1,w.style.opacity=``,w.style.cursor=``)}s.addEventListener(`click`,()=>{if(!v.isGenerating){Fi();return}se()?gn():Ir(s)}),w?.addEventListener(`click`,()=>Ir(w));function T(e){if(!v.isGenerating)return!1;let n=v.activeSessionId;return n?On(n)?(Fn(n),Ir(w&&w.style.display!==`none`?w:e||s)?(k(t(`queue.stopAndSendStarted`),`success`,2500),!0):(Yt(n),!0)):(k(t(`queue.stopAndSendEmpty`),`warning`,3e3),!1):!1}function ue(e,{isPrimarySend:t=!1}={}){if(!e)return;let n=()=>t&&se();e.addEventListener(`contextmenu`,t=>{n()||!v.isGenerating||!On(v.activeSessionId)||(t.preventDefault(),T(e))});let r=null,i=()=>{r&&=(clearTimeout(r),null)};e.addEventListener(`pointerdown`,t=>{t.pointerType===`mouse`&&t.button!==0||n()||!v.isGenerating||!On(v.activeSessionId)||(i(),r=setTimeout(()=>{r=null,T(e)},600))});for(let t of[`pointerup`,`pointerleave`,`pointercancel`])e.addEventListener(t,i)}ue(s,{isPrimarySend:!0}),ue(w),document.addEventListener(`queue-stop-and-send`,()=>{T(w&&w.style.display!==`none`?w:s)}),document.addEventListener(`generating-state-changed`,ce),a.addEventListener(`input`,ce),document.addEventListener(`input-attachments-changed`,ce),document.addEventListener(`voice-draft-written`,ce);let de=document.getElementById(`shortcutsBtn`),fe=document.getElementById(`shortcutsModal`),pe=document.getElementById(`shortcutsCloseBtn`);function me(){fe&&(fe.style.display=`flex`)}function he(){fe&&(fe.style.display=`none`)}de&&de.addEventListener(`click`,e=>{e.stopPropagation(),me();let t=document.getElementById(`headerMoreDropdown`);t&&t.classList.remove(`show`)}),pe&&pe.addEventListener(`click`,he),fe&&fe.addEventListener(`click`,e=>{e.target===fe&&he()});let ge=ps();Sn(),$n({adjustInputHeight:ee}).catch(e=>{r.warn(`[SidePanel] initVoiceInput failed:`,e?.message||e)}),document.addEventListener(`keydown`,e=>{if((e.ctrlKey||e.metaKey)&&e.key===`t`){e.preventDefault();let t=document.getElementById(`toolsPopup`);t&&t.style.display!==`none`?Ai():Ri()}if(e.key===`Escape`&&Kn()){e.preventDefault();return}if(!(e.key===`Escape`&&ge.handleEscape())){if(e.key===`Escape`&&fe&&fe.style.display!==`none`){he();return}if(e.altKey&&e.code===`Slash`){e.preventDefault(),me();return}if(e.altKey&&!e.shiftKey&&e.code===`KeyS`&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),Li();return}if(e.altKey&&e.shiftKey&&e.code===`KeyS`&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),Dr();return}if(Gt(e)){e.preventDefault(),cn();return}if(e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyN`){e.preventDefault(),fi();return}if(e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyW`){e.preventDefault(),jr();return}if(e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyE`){e.preventDefault();let t=document.querySelectorAll(`#chatContainer .message.user`),n=t[t.length-1];if(n){Wt(n);let e=document.getElementById(`userInput`);e&&e.focus()}return}if(e.altKey&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){e.preventDefault();let t=e.key===`ArrowUp`?`prev`:`next`;ge.jumpToMessage(t,e.ctrlKey||e.metaKey),ge.updateActiveQuestion();return}}}),a.addEventListener(`keydown`,e=>{let t=document.getElementById(`promptSelector`),n=document.getElementById(`promptDropdown`),r=document.getElementById(`agentAtSelector`),i=document.getElementById(`agentAtDropdown`);if(r.style.display!==`none`&&i.classList.contains(`show`)){let t=document.getElementById(`agentAtTabs`),n=t&&t.classList.contains(`merged-mode`);if(!n&&e.key===`Tab`){e.preventDefault();let t=Array.from(document.querySelectorAll(`#agentAtTabs .prompt-tab`)).map(e=>e.dataset.tab),n=e=>{let t=document.querySelector(`#agentAtTabs .prompt-tab[data-tab="${e}"]`);return!!t&&t.style.display!==`none`},r=t.indexOf(Ot);for(let e=0;e<t.length;e++)if(r=(r+1)%t.length,n(t[r])){di(t[r]);break}return}let r,i;n?(r=document.getElementById(`agentAtList`),i=v.selectedAgentAtIndex):Ot===`pages`?(r=document.getElementById(`agentPageList`),i=v.selectedPageIndex):Ot===`proxies`?(r=document.getElementById(`agentProxyList`),i=v.selectedProxyAtIndex):Ot===`knowledge`?(r=document.getElementById(`agentKnowledgeList`),i=v.selectedKnowledgeAtIndex):(r=document.getElementById(`agentAtList`),i=v.selectedAgentAtIndex);let a=r?r.querySelectorAll(`.prompt-item`):[],o=a.length;if(o!==0){if(e.key===`ArrowDown`){e.preventDefault();let t=i<0?0:(i+1)%o;n?(v.selectedAgentAtIndex=t,Ei(a)):Ot===`proxies`?(v.selectedProxyAtIndex=t,Ei(a)):Ot===`knowledge`?(v.selectedKnowledgeAtIndex=t,Ei(a)):Ot===`pages`?(v.selectedPageIndex=t,aa(a)):(v.selectedAgentAtIndex=t,Ei(a));return}else if(e.key===`ArrowUp`){e.preventDefault();let t=i<0||i===0?o-1:i-1;n?(v.selectedAgentAtIndex=t,Ei(a)):Ot===`proxies`?(v.selectedProxyAtIndex=t,Ei(a)):Ot===`knowledge`?(v.selectedKnowledgeAtIndex=t,Ei(a)):Ot===`pages`?(v.selectedPageIndex=t,aa(a)):(v.selectedAgentAtIndex=t,Ei(a));return}else if(e.key===`Enter`&&i>=0){e.preventDefault(),a[i].click(),(e.ctrlKey||e.metaKey)&&on();return}else if(e.key===`Escape`){on();return}}}let o=document.getElementById(`fileAtSelector`),s=document.getElementById(`fileAtDropdown`);if(o&&s&&o.style.display!==`none`&&s.classList.contains(`show`)){let t=document.getElementById(`fileAtList`),n=t?t.querySelectorAll(`.prompt-item`):[],r=n.length;if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),r>0&&(v.selectedFileAtIndex=e.key===`ArrowDown`?v.selectedFileAtIndex<0?0:(v.selectedFileAtIndex+1)%r:v.selectedFileAtIndex<0||v.selectedFileAtIndex===0?r-1:v.selectedFileAtIndex-1,pf(n));return}if(e.key===`Enter`&&r>0&&v.selectedFileAtIndex>=0){e.preventDefault(),n[v.selectedFileAtIndex].click();return}if(e.key===`Escape`){e.preventDefault(),cf();return}}if(t.style.display!==`none`&&n.classList.contains(`show`)){if(v.showMergedList){let t=n.querySelectorAll(`#promptList .prompt-item`),r=t.length;if(e.key===`ArrowDown`){e.preventDefault(),v.selectedPromptIndex<0?v.selectedPromptIndex=0:v.selectedPromptIndex=(v.selectedPromptIndex+1)%r,Dn(t);return}if(e.key===`ArrowUp`){e.preventDefault(),v.selectedPromptIndex<0||v.selectedPromptIndex===0?v.selectedPromptIndex=r-1:--v.selectedPromptIndex,Dn(t);return}if(e.key===`Enter`&&v.selectedPromptIndex>=0){e.preventDefault();let n=t[v.selectedPromptIndex];n.dataset.type===`skill`||n.dataset.type===`mcp`?(n.click(),(e.ctrlKey||e.metaKey)&&j()):e.ctrlKey||e.metaKey?$r(n.dataset.code):xt(n.dataset.code);return}if(e.key===`Escape`){j();return}return}if(v.activeDropdownTab===`skills`){let t=n.querySelectorAll(`#skillList .skill-list-item`),r=t.length;if(e.key===`ArrowDown`){e.preventDefault(),v.selectedSkillIndex<0?v.selectedSkillIndex=0:v.selectedSkillIndex=(v.selectedSkillIndex+1)%r,Wi(t);return}if(e.key===`ArrowUp`){e.preventDefault(),v.selectedSkillIndex<0||v.selectedSkillIndex===0?v.selectedSkillIndex=r-1:--v.selectedSkillIndex,Wi(t);return}if(e.key===`Enter`&&v.selectedSkillIndex>=0){e.preventDefault(),t[v.selectedSkillIndex].click(),(e.ctrlKey||e.metaKey)&&j();return}if(e.key===`Escape`){j();return}if(e.key===`Tab`){e.preventDefault();let t=document.getElementById(`mcpTab`);t&&t.style.display!==`none`?Rn(`mcp`):Rn(`prompts`);return}return}if(v.activeDropdownTab===`mcp`){let t=n.querySelectorAll(`#mcpList .mcp-list-item`),r=t.length;if(e.key===`ArrowDown`){e.preventDefault(),v.selectedMcpServiceIndex<0?v.selectedMcpServiceIndex=0:v.selectedMcpServiceIndex=(v.selectedMcpServiceIndex+1)%r,kt(t);return}if(e.key===`ArrowUp`){e.preventDefault(),v.selectedMcpServiceIndex<0||v.selectedMcpServiceIndex===0?v.selectedMcpServiceIndex=r-1:--v.selectedMcpServiceIndex,kt(t);return}if(e.key===`Enter`&&v.selectedMcpServiceIndex>=0){e.preventDefault(),t[v.selectedMcpServiceIndex].click(),(e.ctrlKey||e.metaKey)&&j();return}if(e.key===`Escape`){j();return}if(e.key===`Tab`){e.preventDefault(),Rn(`prompts`);return}return}let t=n.querySelectorAll(`#promptList .prompt-item`),r=t.length;if(e.key===`Tab`){let t=document.getElementById(`skillsTab`),n=document.getElementById(`mcpTab`);if(t&&t.style.display!==`none`){e.preventDefault(),Rn(`skills`);return}if(n&&n.style.display!==`none`){e.preventDefault(),Rn(`mcp`);return}}if(r!==0&&e.key===`ArrowDown`){e.preventDefault(),v.selectedPromptIndex<0?v.selectedPromptIndex=0:v.selectedPromptIndex=(v.selectedPromptIndex+1)%r,Dn(t);return}if(e.key===`ArrowUp`){e.preventDefault(),v.selectedPromptIndex<0||v.selectedPromptIndex===0?v.selectedPromptIndex=r-1:--v.selectedPromptIndex,Dn(t);return}if(e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&v.selectedPromptIndex>=0){e.preventDefault();let n=t[v.selectedPromptIndex].dataset.code;$r(n);return}if(e.key===`Enter`&&v.selectedPromptIndex>=0){e.preventDefault();let n=t[v.selectedPromptIndex].dataset.code;xt(n);return}if(e.key===`Escape`){j();return}}if(e.key===`Escape`){v.inputHistoryIndex>=0&&(v.inputHistoryIndex=-1),a.value&&(a.value=``,a.style.height=`auto`,a.dispatchEvent(new Event(`input`))),e.preventDefault();return}let c=t.style.display!==`none`&&n.classList.contains(`show`),l=r.style.display!==`none`&&i.classList.contains(`show`),u=o.style.display!==`none`&&s.classList.contains(`show`);if(e.key===`ArrowUp`&&v.inputHistoryIndex===-1&&!a.value.trim()&&!Xr()&&Vp()){e.preventDefault();return}if(!c&&!l&&!u){let t=vp({key:e.key,value:a.value,caret:a.selectionStart,history:v.inputHistory,index:v.inputHistoryIndex});if(t.handled){e.preventDefault(),v.inputHistoryIndex=t.index,a.value=t.value,a.dispatchEvent(new Event(`input`)),a.setSelectionRange(t.value.length,t.value.length);return}}if(e.key===`Enter`&&!e.shiftKey){if(v.isComposing)return;if(e.preventDefault(),cf(),v.isGenerating){if(e.altKey){$t(a.value);return}gn();return}Fi()}}),a.addEventListener(`compositionstart`,()=>{v.isComposing=!0}),a.addEventListener(`compositionend`,()=>{v.isComposing=!1}),a.addEventListener(`paste`,e=>{let t=e.clipboardData?.items;if(t)for(let n of t){if(n.type.startsWith(`image/`)&&v.enableImageInput){e.preventDefault();let t=n.getAsFile();t&&At(t);break}if(n.kind===`file`&&v.enableFileInput){e.preventDefault();let t=n.getAsFile();t&&yr([t]);break}}});let _e=document.getElementById(`fileAttachBtn`),ve=document.getElementById(`fileInput`);_e&&ve&&(_e.addEventListener(`click`,()=>{ve.click()}),ve.addEventListener(`change`,async()=>{if(ve.files.length>0){let e=Array.from(ve.files),n=e.filter(e=>e.type.startsWith(`image/`)),r=e.filter(e=>!e.type.startsWith(`image/`));if(n.length>0)if(v.enableImageInput)for(let e of n)await At(e);else k(t(`sidePanel.imageNotEnabled`)),yr(n);r.length>0&&yr(r),ve.value=``}}));let ye=document.querySelector(`.input-wrapper`),be=0;ye&&(ye.addEventListener(`dragenter`,e=>{e.preventDefault(),e.stopPropagation(),be++,ye.classList.add(`drag-over`)}),ye.addEventListener(`dragleave`,e=>{e.preventDefault(),e.stopPropagation(),be--,be<=0&&(be=0,ye.classList.remove(`drag-over`))}),ye.addEventListener(`dragover`,e=>{e.preventDefault(),e.stopPropagation()}),ye.addEventListener(`drop`,async e=>{e.preventDefault(),e.stopPropagation(),be=0,ye.classList.remove(`drag-over`);let n=e.dataTransfer.getData(`application/x-workspace-file`);if(n){e.preventDefault();try{let{path:e}=JSON.parse(n);if(e){Kr([e]);return}}catch(e){r.warn(`[SidePanel] parse workspace dragdata failed:`,e)}}let i=Array.from(e.dataTransfer.files);if(i.length>0){e.preventDefault();let n=i.filter(e=>e.type.startsWith(`image/`)),r=i.filter(e=>!e.type.startsWith(`image/`));if(n.length>0)if(v.enableImageInput)for(let e of n)await At(e);else k(t(`sidePanel.imageNotEnabled`)),yr(n);r.length>0&&yr(r);return}let o=e.dataTransfer.getData(`text/plain`);if(o&&(e.preventDefault(),a)){a.focus();let e=a.selectionStart??a.value.length,t=a.selectionEnd??a.value.length;a.value=a.value.slice(0,e)+o+a.value.slice(t),a.selectionStart=a.selectionEnd=e+o.length,a.dispatchEvent(new Event(`input`))}}));let xe=document.getElementById(`screenshotBtn`);xe&&xe.addEventListener(`click`,async()=>{if(v.enableImageInput)try{await Li()}catch(e){r.error(`[SidePanel] screenshot failed:`,e),k(t(`sidePanel.screenshotFailed`))}}),Gi(),a.addEventListener(`wheel`,e=>{v.isScrolling=!0;let t=a.style.height||a.offsetHeight+`px`;a.style.height=t,a.scrollHeight<=a.clientHeight+10&&(e.preventDefault(),e.stopPropagation()),setTimeout(()=>{v.isScrolling=!1},100)},{passive:!1}),a.addEventListener(`input`,e=>{let t=a.value,n=document.getElementById(`promptSelector`),r=document.getElementById(`promptDropdown`);document.getElementById(`agentAtSelector`),document.getElementById(`agentAtDropdown`);let i=t.lastIndexOf(`/`),o=t.lastIndexOf(`@`),s=t.lastIndexOf(`$`),c=e=>{if(e===-1||e!==0&&t[e-1]!==`
|
|
670
670
|
`&&t[e-1]!==` `)return!1;let n=t.substring(e+1);return!(n.includes(` `)||n.includes(`
|
|
671
671
|
`))},l=c(i),u=c(o),d=c(s),f=null;if(l&&(f={key:`slash`,index:i}),u&&(!f||o>f.index)&&(f={key:`at`,index:o}),d&&(!f||s>f.index)&&(f={key:`dollar`,index:s}),f&&f.key===`dollar`)j(),on(),sf(t.substring(s+1));else if(f&&f.key===`at`)j(),cf(),Ni(t.substring(o+1));else if(f&&f.key===`slash`){on(),cf();let e=t.substring(i+1);n.style.display!==`none`&&r.classList.contains(`show`)?yn(e):hn(e)}else j(),on(),cf();ee()});let Se=yp((e,t)=>{chrome.storage.local.set({[e]:t})},200);u.addEventListener(`scroll`,()=>{Se(`scrollPosition_`+(v.activeSessionId||`default`),u.scrollTop)}),window.addEventListener(`pagehide`,()=>{chrome.storage.local.set({[`scrollPosition_`+(v.activeSessionId||`default`)]:u.scrollTop})});let Ce=document.getElementById(`headerMoreBtn`),we=document.getElementById(`headerMoreDropdown`);Ce&&we&&(Ce.addEventListener(`click`,e=>{e.stopPropagation(),we.classList.toggle(`show`)}),document.addEventListener(`click`,e=>{!we.contains(e.target)&&e.target!==Ce&&Ae()}));let Te=document.getElementById(`themeToggleBtn`),Ee=document.getElementById(`themeToggleLabel`),De=document.getElementById(`themeSubmenu`),Oe=e=>t(e===`dark`?`settings.themeDark`:e===`system`?`settings.themeSystem`:`settings.themeLight`),ke=()=>{let e=st();Ee&&(Ee.textContent=t(`header.themeToggle`,{theme:Oe(e)})),De&&De.querySelectorAll(`.theme-submenu-item`).forEach(t=>{t.classList.toggle(`active`,t.dataset.themeValue===e)}),Te&&Te.setAttribute(`aria-expanded`,String(!!(De&&De.classList.contains(`show`))))};function Ae(){De&&De.classList.remove(`show`),we&&we.classList.remove(`show`),Te&&Te.setAttribute(`aria-expanded`,`false`)}Te&&De&&(Te.addEventListener(`click`,e=>{e.stopPropagation(),De.classList.toggle(`show`),ke()}),De.querySelectorAll(`.theme-submenu-item`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),Ke(e.dataset.themeValue),Ae()})})),ke(),lt(ke),o(ke),c.addEventListener(`click`,e=>{e.stopPropagation(),Ae(),Jr()}),l&&l.addEventListener(`click`,e=>{e.stopPropagation(),Ae(),Nt()});let je=document.getElementById(`importChatBtn`);je&&je.addEventListener(`click`,e=>{e.stopPropagation(),Ae(),wn()});let Me=document.getElementById(`importSessionsFile`);Me&&Me.addEventListener(`change`,e=>{let t=e.target.files[0];t&&Hn(t)});let Ne=document.getElementById(`settingsBtn`);Ne&&Ne.addEventListener(`click`,()=>{chrome.runtime.openOptionsPage()});let Pe=document.getElementById(`headerAgentIndicator`);Pe&&Pe.addEventListener(`click`,async()=>{let e=chrome.runtime.getURL(`options.html#agent`),t=await chrome.tabs.query({url:chrome.runtime.getURL(`options.html`)});t.length>0?await chrome.tabs.update(t[0].id,{active:!0,url:e}):await chrome.tabs.create({url:e})});let Fe=document.getElementById(`prototypeLibraryBtn`);Fe&&Fe.addEventListener(`click`,e=>{e.stopPropagation(),Ae(),yt()});let D=document.getElementById(`tokenStatsHeaderBtn`);D&&D.addEventListener(`click`,e=>{e.stopPropagation(),Ae(),window.openTokenStats&&window.openTokenStats()});let Ie=document.getElementById(`auditLogBtn`),Le=document.getElementById(`auditLogOverlay`),Re=document.getElementById(`auditLogClose`),ze=document.getElementById(`auditLogRefreshBtn`),Be=document.getElementById(`auditLogCategoryFilter`),Ve=document.getElementById(`auditLogLimit`),He=document.getElementById(`auditLogSearch`),Ue=document.getElementById(`auditLogSearchClear`),We=document.getElementById(`auditLogLoading`),Ge=document.getElementById(`auditLogEmpty`),O=document.getElementById(`auditLogList`),qe=[],Je={auth:t(`sidePanel.auditCategoryAuth`),fs:t(`sidePanel.auditCategoryFs`),exec:t(`sidePanel.auditCategoryExec`),security:t(`sidePanel.auditCategorySecurity`),system:t(`sidePanel.auditCategorySystem`)},Ye={info:`INFO`,warn:`WARN`,error:`ERROR`},Xe={info:`audit-level-info`,warn:`audit-level-warn`,error:`audit-level-error`};function Ze(e){if(!e)return`-`;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function $e(e){let n=new Set([`timestamp`,`level`,`category`,`action`]),r=[];for(let[t,i]of Object.entries(e)){if(n.has(t))continue;let e=typeof i==`string`?i:JSON.stringify(i),a=e.length>60?e.slice(0,60)+`...`:e;r.push(`${t}: ${a}`)}return r.join(t(`sidePanel.auditDetailSeparator`))}async function et(){if(!We||!Ge||!O)return;We.style.display=`block`,Ge.style.display=`none`,O.style.display=`none`;let e=Be?.value||null,n=parseInt(Ve?.value||`200`,10);try{let r=await new Promise((t,r)=>{chrome.runtime.sendMessage({type:`QUERY_AUDIT_LOGS`,category:e,limit:n},e=>{chrome.runtime.lastError?r(Error(chrome.runtime.lastError.message)):t(e)})});if(We.style.display=`none`,!r||!r.success){Ge.style.display=`block`,Ge.textContent=t(`sidePanel.auditQueryFailed`,{error:r?.error||t(`sidePanel.unknownError`)});return}qe=r.entries||[],tt()}catch(e){We.style.display=`none`,Ge.style.display=`block`,Ge.textContent=t(`sidePanel.auditLoadFailed`,{error:e.message})}}function tt(){if(!O)return;let e=(He?.value||``).trim().toLowerCase(),n=qe;if(e&&(n=n.filter(t=>[t.action||``,t.category||``,...Object.entries(t).filter(([e])=>![`timestamp`,`level`,`category`,`action`].includes(e)).map(([,e])=>typeof e==`string`?e:JSON.stringify(e))].join(` `).toLowerCase().includes(e))),Ue&&(Ue.style.display=e?`block`:`none`),We.style.display=`none`,n.length===0){Ge.style.display=`block`,Ge.textContent=t(e?`sidePanel.auditNoMatch`:`sidePanel.auditEmpty`),O.style.display=`none`;return}Ge.style.display=`none`,O.style.display=`block`,O.innerHTML=n.map(e=>{let t=A(Je[e.category]||e.category||`-`),n=A(Ye[e.level]||e.level?.toUpperCase()||`INFO`),r=Xe[e.level]||`audit-level-info`,i=Ze(e.timestamp),a=A($e(e));return`<div class="audit-entry">
|
|
672
672
|
<div class="audit-entry-header">
|
|
@@ -687,4 +687,4 @@ Are you sure you want to stop the agent service? You will not be able to connect
|
|
|
687
687
|
<span style="font-size: 12px; color: ${o}; font-weight: 500;">${r.toFixed(0)}%</span>
|
|
688
688
|
</td>
|
|
689
689
|
<td style="padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--border-subtle); color: var(--text-tertiary); font-size: 12px;">${s}</td>
|
|
690
|
-
</tr>`}).join(``),ln()}function ln(){let{column:e,asc:t}=en,n=[`name`,`callCount`,`successCount`,`successRate`,`duration`],r={name:`sortByName`,callCount:`sortByCallCount`,successCount:`sortBySuccessCount`,successRate:`sortBySuccessRate`,duration:`sortByDuration`};n.forEach(n=>{let i=document.getElementById(r[n]);if(!i)return;let a=i.querySelector(`.sort-indicator`);a&&(n===e?(a.textContent=t?`▲`:`▼`,a.style.color=`var(--brand-500)`):(a.textContent=``,a.style.color=``))})}document.querySelectorAll(`#toolStatsTable th[data-sort]`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.sort;en.column===t?en.asc=!en.asc:(en.column=t,en.asc=!1),tn()})}),Bt.addEventListener(`click`,()=>{xi()}),Vt.addEventListener(`click`,()=>{xi(),Jt()});let un=document.getElementById(`confirmModal`);un.addEventListener(`click`,e=>{e.target===un&&xi()});let fn=document.getElementById(`selectionClose`);fn&&fn.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),r.debug(`[SidePanel] user clickcloseselected content by button`),Gn(),window.hideFloatingMenu(),v.lastSelectedText=``,v.currentSelectionRange=null}),a.addEventListener(`input`,()=>{})}),at().then(()=>{Im(),pi(v.chatConfig.showMessageTimestamp!==!1),Lm(),Rm()}),document.addEventListener(`DOMContentLoaded`,()=>{Bm()}),document.addEventListener(`DOMContentLoaded`,ia),document.addEventListener(`DOMContentLoaded`,ui),document.addEventListener(`DOMContentLoaded`,Xm),document.addEventListener(`DOMContentLoaded`,Ym),document.addEventListener(`DOMContentLoaded`,Zd),document.addEventListener(`DOMContentLoaded`,Kf),document.addEventListener(`DOMContentLoaded`,_p),document.addEventListener(`DOMContentLoaded`,ei),document.addEventListener(`DOMContentLoaded`,async()=>{er(),Ja(),await $i(),Vi(),await oc(),Kl(),vs(),Mm(),Vs(),Eh(),hr(),Ad();let{updateBookmarkButtons:e,updateBookmarkBadge:t}=await E(async()=>{let{updateBookmarkButtons:e,updateBookmarkBadge:t}=await import(`./context-indicator-
|
|
690
|
+
</tr>`}).join(``),ln()}function ln(){let{column:e,asc:t}=en,n=[`name`,`callCount`,`successCount`,`successRate`,`duration`],r={name:`sortByName`,callCount:`sortByCallCount`,successCount:`sortBySuccessCount`,successRate:`sortBySuccessRate`,duration:`sortByDuration`};n.forEach(n=>{let i=document.getElementById(r[n]);if(!i)return;let a=i.querySelector(`.sort-indicator`);a&&(n===e?(a.textContent=t?`▲`:`▼`,a.style.color=`var(--brand-500)`):(a.textContent=``,a.style.color=``))})}document.querySelectorAll(`#toolStatsTable th[data-sort]`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.sort;en.column===t?en.asc=!en.asc:(en.column=t,en.asc=!1),tn()})}),Bt.addEventListener(`click`,()=>{xi()}),Vt.addEventListener(`click`,()=>{xi(),Jt()});let un=document.getElementById(`confirmModal`);un.addEventListener(`click`,e=>{e.target===un&&xi()});let fn=document.getElementById(`selectionClose`);fn&&fn.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),r.debug(`[SidePanel] user clickcloseselected content by button`),Gn(),window.hideFloatingMenu(),v.lastSelectedText=``,v.currentSelectionRange=null}),a.addEventListener(`input`,()=>{})}),at().then(()=>{Im(),pi(v.chatConfig.showMessageTimestamp!==!1),Lm(),Rm()}),document.addEventListener(`DOMContentLoaded`,()=>{Bm()}),document.addEventListener(`DOMContentLoaded`,ia),document.addEventListener(`DOMContentLoaded`,ui),document.addEventListener(`DOMContentLoaded`,Xm),document.addEventListener(`DOMContentLoaded`,Ym),document.addEventListener(`DOMContentLoaded`,Zd),document.addEventListener(`DOMContentLoaded`,Kf),document.addEventListener(`DOMContentLoaded`,_p),document.addEventListener(`DOMContentLoaded`,ei),document.addEventListener(`DOMContentLoaded`,async()=>{er(),Ja(),await $i(),Vi(),await oc(),Kl(),vs(),Mm(),Vs(),Eh(),hr(),Ad();let{updateBookmarkButtons:e,updateBookmarkBadge:t}=await E(async()=>{let{updateBookmarkButtons:e,updateBookmarkBadge:t}=await import(`./context-indicator-ZNMB0fDM.js`).then(e=>e._n);return{updateBookmarkButtons:e,updateBookmarkBadge:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));e(),t()}),document.addEventListener(`DOMContentLoaded`,()=>{fs()}),document.addEventListener(`DOMContentLoaded`,async()=>{St(e=>Fi(e)),await Vt(),await Jp()});function Mh(){Gn(),Sr(),Oi(),Zn(),Ut(),Yi();let e=document.getElementById(`imagePreviewBar`);e&&(e.innerHTML=``,e.style.display=`none`)}function Nh(e){let t=e||{};t.quotedContextText&&Di(t.quotedContextText),t.selectedPage&&Ln(t.selectedPage),!t.quotedContextText&&v.selectedContextText&&nr(),dr(),Lr(),ur(),yi(),zn()}document.addEventListener(`queue-context-cleared`,Mh),document.addEventListener(`queue-context-restored`,e=>{Nh(e&&e.detail?e.detail.snapshot:null)}),document.addEventListener(`DOMContentLoaded`,Cn),document.addEventListener(`DOMContentLoaded`,Nr),document.addEventListener(`DOMContentLoaded`,vi),document.addEventListener(`DOMContentLoaded`,Er),document.addEventListener(`DOMContentLoaded`,mn),document.addEventListener(`DOMContentLoaded`,gr),document.addEventListener(`DOMContentLoaded`,qr),document.addEventListener(`DOMContentLoaded`,Mn),document.addEventListener(`DOMContentLoaded`,Lt),document.addEventListener(`DOMContentLoaded`,()=>mr()),document.addEventListener(`DOMContentLoaded`,async()=>{let{refreshAgentNames:e,initScrollToBottomBtn:t}=await E(async()=>{let{refreshAgentNames:e,initScrollToBottomBtn:t}=await import(`./context-indicator-ZNMB0fDM.js`).then(e=>e.pt);return{refreshAgentNames:e,initScrollToBottomBtn:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]));e(),t()});async function Ph(){try{let e=(await chrome.storage.local.get(`_detachOriginTabId`))?._detachOriginTabId;if(typeof e==`number`)try{let t=await chrome.tabs.get(e);if(t?.id!=null)return t.id}catch{}}catch{}try{let e=(await chrome.windows.getAll({populate:!0})||[]).filter(e=>e.type===`normal`);return((e.find(e=>e.focused)||e[0])?.tabs||[]).find(e=>e.active)?.id??null}catch{return null}}document.addEventListener(`DOMContentLoaded`,()=>{let e=new URLSearchParams(window.location.search).has(`popup`),n=document.getElementById(`detachBtn`),i=document.getElementById(`attachBtn`),a=e?i:n;e?i&&(i.style.display=`flex`):n&&(n.style.display=`flex`);let o=()=>{if(!a)return;let n=v.pendingCallApiSessionIds&&v.pendingCallApiSessionIds.size>0;a.disabled=n,a.style.opacity=n?`0.35`:``,a.style.cursor=n?`not-allowed`:`pointer`,a.title=t(n?`detach.taskRunning`:e?`header.attachTitle`:`header.detachTitle`)};o(),document.addEventListener(`generating-state-changed`,o),n&&n.addEventListener(`click`,async()=>{if(v.pendingCallApiSessionIds&&v.pendingCallApiSessionIds.size>0){k(t(`detach.taskRunning`),`warning`);return}try{if((await chrome.runtime.sendMessage({type:`DETACH_SIDEPANEL`,width:window.innerWidth}))?.success)try{window.close()}catch{}}catch(e){r.warn(`[SidePanel] detach failed:`,e?.message)}}),i&&i.addEventListener(`click`,async()=>{if(v.pendingCallApiSessionIds&&v.pendingCallApiSessionIds.size>0){k(t(`detach.taskRunning`),`warning`);return}try{let e=(await chrome.windows.getCurrent()).id,n=await Ph();if(n==null){k(t(`detach.attachFailed`),`error`);return}let i=await chrome.runtime.sendMessage({type:`ATTACH_SIDEPANEL`,windowId:e,tabId:n});if(i?.success)try{window.close()}catch{}else r.warn(`[SidePanel] attach rejected:`,i?.error),k(t(`detach.attachFailed`),`error`)}catch(e){r.warn(`[SidePanel] attach failed:`,e?.message),k(t(`detach.attachFailed`),`error`)}})});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/workspace-manager-DLH5XabD.js","assets/chunk-CMxvf4Kt.js","assets/model-profiles-C7nNtymU.js","assets/i18n-XUUSwfZZ.js","assets/context-indicator-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/workspace-manager-DLH5XabD.js","assets/chunk-CMxvf4Kt.js","assets/model-profiles-C7nNtymU.js","assets/i18n-XUUSwfZZ.js","assets/context-indicator-ZNMB0fDM.js","assets/voice-shortcut-Dx863RGz.js","assets/session-store-BU0hS2_b.js","assets/agent-store-_CfonCwg.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{a as e,c as t,l as n,r}from"./i18n-XUUSwfZZ.js";import{N as i,b as a,rn as o,wt as s,x as c}from"./model-profiles-C7nNtymU.js";import{o as l}from"./voice-shortcut-Dx863RGz.js";import{o as u}from"./agent-store-_CfonCwg.js";var d=`appTheme`,f=[`light`,`dark`,`system`],p=`light`,m=`light`,h=null,g=null,_=[],v=!1;function y(e){let t=e!==m;m=e,typeof document<`u`&&document.documentElement.setAttribute(`data-theme`,e);try{localStorage.setItem(`appThemeResolved`,e)}catch{}t&&_.slice().forEach(t=>{try{t(e)}catch(e){console.warn(`[theme] subscriber error`,e)}})}function b(e){return e===`system`?typeof matchMedia<`u`&&matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:e===`dark`?`dark`:`light`}(function(){try{let e=typeof localStorage<`u`&&localStorage.getItem(`appThemeResolved`);(e===`dark`||e===`light`)&&(m=e,typeof document<`u`&&document.documentElement.setAttribute(`data-theme`,e))}catch{}})();function x(){return p}function S(){return m}function C(e){_.push(e)}async function w(){typeof matchMedia<`u`&&(h=matchMedia(`(prefers-color-scheme: dark)`),g&&h.removeEventListener(`change`,g),g=()=>{p===`system`&&y(b(`system`))},h.addEventListener(`change`,g)),!v&&typeof chrome<`u`&&chrome.storage&&chrome.storage.onChanged&&(chrome.storage.onChanged.addListener((e,t)=>{t===`local`&&e.appTheme&&f.includes(e.appTheme.newValue)&&(p=e.appTheme.newValue,y(b(p)))}),v=!0);let e=await new Promise(e=>{try{chrome.storage.local.get([d],t=>{if(chrome.runtime&&chrome.runtime.lastError){e(null);return}e(t||{})})}catch{e(null)}});e!==null&&(p=f.includes(e[d])?e[d]:`light`,y(b(p)))}async function T(e){f.includes(e)&&(p=e,y(b(e)),await new Promise(t=>chrome.storage.local.set({appTheme:e},t)))}e(`zh`,{util:{cmdHintPowerShell:"(请使用 PowerShell 语法,如 `Get-ChildItem`、`Set-Content`、`Remove-Item` 等)",cmdHintCmd:"(请使用 CMD 语法,如 `dir`、`echo`、`del` 等)",cmdHintGitBash:"(请使用 Unix 命令,如 `ls`、`cat`、`rm` 等,路径使用正斜杠 `/`)",cmdHintPowerShellShort:`(请使用 PowerShell 语法)`,cmdHintUnix:"(请使用 Unix 命令,如 `ls`、`cat`、`rm` 等)",cmdExecEnvTitle:`## 命令执行环境`,cmdExecOsShell:`**操作系统/Shell**`,cmdExecWorkdir:`工作目录`,cmdExecWorkdirUnset:`未设置`,assistantTerm:`- **助手**:用户创建的 AI 智能体,每个助手有独立的系统提示词和工具权限,可独立工作或被其他助手调度执行子任务`,noDesc:`无描述`,subDispatchTitle:`## 子助手调度`,subDispatchDesc:`使用 dispatch_task(subAgentId, task) 分派子任务给其他助手执行,支持并行调用。`,subDispatchAvailable:`可用子助手:`,agentTerm:`- **代理**:远端执行服务,提供文件操作、命令执行等能力。可通过 manage_agent 工具查询或切换代理`,agentHostLabel:`- 代理主机地址:`,agentHostHint:`(访问代理端服务时请优先使用此地址)`,terminologyTitle:`## 术语定义`,taskPlanningTitle:`## 任务拆解`,taskPlanningDesc:`复杂任务(多步骤、有依赖)拆解为子任务,通常 2-6 个、最多不超过 8 个;简单任务(1-2 步即可完成)直接执行,不要为凑数而拆分。使用 plan_task(taskDescription, subtasks) 提交方案。重要:调用 plan_task 时必须单独调用,同一轮响应中不要同时返回其他工具调用;其他想执行的动作请编入子任务描述,由子任务执行。`,artifactDeclTitle:`## 文件产物声明`,artifactDeclDesc:`当本次任务通过脚本或命令在工作目录内创建/修改了文件(尤其是运行时才确定路径的文件,如带日期的报表),请在最终回答末尾各用一行声明每个产物,格式严格为:[[artifact:相对工作目录或绝对路径|可选中文说明]]。示例:[[artifact:报表_2026-10-20.xlsx|书签统计报表]]。只列本次真实产生的文件,不要虚构、不要列未生成的文件;说明可省略。这些标记不会展示给用户。`,memoryTitle:`## 记忆`,memoryRules:`- 统一工具 agent_memory,通过 action 区分:store(增删改)/recall(检索)/manage(审查清理)
|
|
3
3
|
- store: subAction=add需type+content,update需memoryId+type,**delete仅需memoryId无需type**。**删除前先recall查id**
|
|
4
4
|
- recall: query用关键词(如"考试"),不用完整句子。可选memoryType和limit
|
|
@@ -169,4 +169,4 @@ Ctrl/Cmd+click to copy rich-text table`,downloadExcel:`Download Excel`,exportTab
|
|
|
169
169
|
`);return{full:a+`
|
|
170
170
|
`+o+`
|
|
171
171
|
`+s,header:a+`
|
|
172
|
-
`+o,body:s}}function ot(e){let t=e.closest(`.code-block-container`);if(t){let n=t.querySelector(`pre code`);n&&P(n.textContent,e)}}function st(e,n){if(n.ctrlKey||n.metaKey){let n=e.closest(`.table-container-wrapper`)?.querySelector(`table`);if(n)try{let r=Y(n).outerHTML;e.focus();let i=new Blob([r],{type:`text/html`}),a=new ClipboardItem({"text/html":i});navigator.clipboard.write([a]).then(()=>{E(t(`markdown.copiedRichTable`))}).catch(()=>{let n=document.createElement(`div`);n.style.cssText=`position:fixed;left:-999999px;top:-999999px;`,n.innerHTML=r,document.body.appendChild(n);let i=document.createRange();i.selectNodeContents(n);let a=window.getSelection();a.removeAllRanges(),a.addRange(i);try{e.focus(),document.execCommand(`copy`),E(t(`markdown.copiedRichTable`))}catch{E(t(`markdown.copyRichTableFailed`),`error`)}finally{a.removeAllRanges(),document.body.removeChild(n)}})}catch{E(t(`markdown.copyFailedShort`),`error`)}return}let r=e.dataset.tableFull?decodeURIComponent(e.dataset.tableFull):null;if(r){P(r,e),E(t(`markdown.copiedMdTable`));return}let i=e.dataset.tableIndex,a=window.__tableBlocks?.[parseInt(i)];if(a){P(a.full,e),E(t(`markdown.copiedMdTable`));return}let o=at(e);o&&(P(o.full,e),E(t(`markdown.copiedMdTable`)))}function ct(e){let t=e.dataset.tableHeader?decodeURIComponent(e.dataset.tableHeader):null,n=e.dataset.tableBody?decodeURIComponent(e.dataset.tableBody):null;if(t&&n){W({header:t,body:n});return}let r=e.dataset.tableIndex,i=window.__tableBlocks?.[parseInt(r)];if(i){W(i);return}let a=at(e);a&&W(a)}async function lt(e){let r=e.closest(`.table-container-wrapper`);if(r)try{let e=await B();if(!e){E(t(`markdown.imageExportLibMissing`),`error`);return}let n=await e(r,{scale:2,useCORS:!0,logging:!1,backgroundColor:`#ffffff`}),i=document.createElement(`a`);i.download=`table-${Date.now()}.jpg`,i.href=n.toDataURL(`image/jpeg`,.95),document.body.appendChild(i),i.click(),document.body.removeChild(i),E(t(`markdown.tableImageExported`))}catch(e){n.error(`[SidePanel] export tableimage failed:`,e),E(t(`markdown.exportImageFailed`),`error`)}}var ut=!1;function dt(){ut||typeof document>`u`||!document.addEventListener||(ut=!0,document.addEventListener(`click`,e=>{let t=e.target;if(!t||typeof t.closest!=`function`)return;let n=t.closest(`.code-copy-btn`);if(n){e.stopPropagation(),ot(n);return}let r=t.closest(`.copy-md-btn`);if(r){e.stopPropagation(),st(r,e);return}let i=t.closest(`.download-excel-btn`);if(i){e.stopPropagation(),ct(i);return}let a=t.closest(`.export-table-img-btn`);if(a){e.stopPropagation(),lt(a);return}},!0))}function ft(){dt()}function Y(e){let t=e.cloneNode(!0);return t.querySelectorAll(`.table-header-cell-wrapper`).forEach(e=>{let t=e.textContent.trim();e.innerHTML=``,e.textContent=t,e.classList.remove(`table-header-cell-wrapper`)}),t.querySelectorAll(`.table-toolbar`).forEach(e=>e.remove()),t}var pt=RegExp(`(?:~?/[\\w\\-.\\u4e00-\\u9fa5/]+|\\b[A-Za-z]:\\\\[\\w\\-.\\\\\\u4e00-\\u9fa5]+|\\b[\\w\\-.\\u4e00-\\u9fa5]+/[\\w\\-./\\u4e00-\\u9fa5]*\\.[A-Za-z0-9]{1,6}|\\b[\\w\\-.\\u4e00-\\u9fa5]+\\.[A-Za-z0-9]{1,6})`,`g`);function mt(e){if(!e)return[];let t=e.replace(/\bhttps?:\/\/\S+/gi,` `),n=[],r;for(pt.lastIndex=0;(r=pt.exec(t))!==null;){let e=r[0].replace(/[,。、)()\s]+$/,``);e&&(/\/$/.test(e)&&!RegExp(`\\.[A-Za-z0-9]{1,6}$`).test(e)||/[.\\/~]/.test(e)&&(n.includes(e)||n.push(e)))}return n}function X(e){return(e||``).replace(/\\/g,`/`).replace(/\/+/g,`/`)}async function ht(e,n=[]){if(!e)return;let r=e.querySelector(`.markdown-body`)||e,i=new Set((n||[]).map(X)),a=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,{acceptNode(e){if(!e.nodeValue||!e.nodeValue.trim())return NodeFilter.FILTER_REJECT;let t=e.parentNode;return!t||!t.closest||t.closest(`a, pre, code, script, style, .chat-file-link`)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),o=[];for(;a.nextNode();)o.push(a.currentNode);let s=new Set;for(let e of o)for(let t of mt(e.nodeValue))s.add(t);if(s.size===0)return;let l=[...s].filter(e=>!i.has(X(e))),u=new Set;if(l.length>0)try{let e=null;try{let t=await(await c(()=>import(`./workspace-manager-DLH5XabD.js`).then(e=>e.j),__vite__mapDeps([0,1,2,3]))).getAgentStatusDetail();t&&t.workdir&&(e=t.workdir)}catch{}let t=await c(()=>import(`./context-indicator-
|
|
172
|
+
`+o,body:s}}function ot(e){let t=e.closest(`.code-block-container`);if(t){let n=t.querySelector(`pre code`);n&&P(n.textContent,e)}}function st(e,n){if(n.ctrlKey||n.metaKey){let n=e.closest(`.table-container-wrapper`)?.querySelector(`table`);if(n)try{let r=Y(n).outerHTML;e.focus();let i=new Blob([r],{type:`text/html`}),a=new ClipboardItem({"text/html":i});navigator.clipboard.write([a]).then(()=>{E(t(`markdown.copiedRichTable`))}).catch(()=>{let n=document.createElement(`div`);n.style.cssText=`position:fixed;left:-999999px;top:-999999px;`,n.innerHTML=r,document.body.appendChild(n);let i=document.createRange();i.selectNodeContents(n);let a=window.getSelection();a.removeAllRanges(),a.addRange(i);try{e.focus(),document.execCommand(`copy`),E(t(`markdown.copiedRichTable`))}catch{E(t(`markdown.copyRichTableFailed`),`error`)}finally{a.removeAllRanges(),document.body.removeChild(n)}})}catch{E(t(`markdown.copyFailedShort`),`error`)}return}let r=e.dataset.tableFull?decodeURIComponent(e.dataset.tableFull):null;if(r){P(r,e),E(t(`markdown.copiedMdTable`));return}let i=e.dataset.tableIndex,a=window.__tableBlocks?.[parseInt(i)];if(a){P(a.full,e),E(t(`markdown.copiedMdTable`));return}let o=at(e);o&&(P(o.full,e),E(t(`markdown.copiedMdTable`)))}function ct(e){let t=e.dataset.tableHeader?decodeURIComponent(e.dataset.tableHeader):null,n=e.dataset.tableBody?decodeURIComponent(e.dataset.tableBody):null;if(t&&n){W({header:t,body:n});return}let r=e.dataset.tableIndex,i=window.__tableBlocks?.[parseInt(r)];if(i){W(i);return}let a=at(e);a&&W(a)}async function lt(e){let r=e.closest(`.table-container-wrapper`);if(r)try{let e=await B();if(!e){E(t(`markdown.imageExportLibMissing`),`error`);return}let n=await e(r,{scale:2,useCORS:!0,logging:!1,backgroundColor:`#ffffff`}),i=document.createElement(`a`);i.download=`table-${Date.now()}.jpg`,i.href=n.toDataURL(`image/jpeg`,.95),document.body.appendChild(i),i.click(),document.body.removeChild(i),E(t(`markdown.tableImageExported`))}catch(e){n.error(`[SidePanel] export tableimage failed:`,e),E(t(`markdown.exportImageFailed`),`error`)}}var ut=!1;function dt(){ut||typeof document>`u`||!document.addEventListener||(ut=!0,document.addEventListener(`click`,e=>{let t=e.target;if(!t||typeof t.closest!=`function`)return;let n=t.closest(`.code-copy-btn`);if(n){e.stopPropagation(),ot(n);return}let r=t.closest(`.copy-md-btn`);if(r){e.stopPropagation(),st(r,e);return}let i=t.closest(`.download-excel-btn`);if(i){e.stopPropagation(),ct(i);return}let a=t.closest(`.export-table-img-btn`);if(a){e.stopPropagation(),lt(a);return}},!0))}function ft(){dt()}function Y(e){let t=e.cloneNode(!0);return t.querySelectorAll(`.table-header-cell-wrapper`).forEach(e=>{let t=e.textContent.trim();e.innerHTML=``,e.textContent=t,e.classList.remove(`table-header-cell-wrapper`)}),t.querySelectorAll(`.table-toolbar`).forEach(e=>e.remove()),t}var pt=RegExp(`(?:~?/[\\w\\-.\\u4e00-\\u9fa5/]+|\\b[A-Za-z]:\\\\[\\w\\-.\\\\\\u4e00-\\u9fa5]+|\\b[\\w\\-.\\u4e00-\\u9fa5]+/[\\w\\-./\\u4e00-\\u9fa5]*\\.[A-Za-z0-9]{1,6}|\\b[\\w\\-.\\u4e00-\\u9fa5]+\\.[A-Za-z0-9]{1,6})`,`g`);function mt(e){if(!e)return[];let t=e.replace(/\bhttps?:\/\/\S+/gi,` `),n=[],r;for(pt.lastIndex=0;(r=pt.exec(t))!==null;){let e=r[0].replace(/[,。、)()\s]+$/,``);e&&(/\/$/.test(e)&&!RegExp(`\\.[A-Za-z0-9]{1,6}$`).test(e)||/[.\\/~]/.test(e)&&(n.includes(e)||n.push(e)))}return n}function X(e){return(e||``).replace(/\\/g,`/`).replace(/\/+/g,`/`)}async function ht(e,n=[]){if(!e)return;let r=e.querySelector(`.markdown-body`)||e,i=new Set((n||[]).map(X)),a=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,{acceptNode(e){if(!e.nodeValue||!e.nodeValue.trim())return NodeFilter.FILTER_REJECT;let t=e.parentNode;return!t||!t.closest||t.closest(`a, pre, code, script, style, .chat-file-link`)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),o=[];for(;a.nextNode();)o.push(a.currentNode);let s=new Set;for(let e of o)for(let t of mt(e.nodeValue))s.add(t);if(s.size===0)return;let l=[...s].filter(e=>!i.has(X(e))),u=new Set;if(l.length>0)try{let e=null;try{let t=await(await c(()=>import(`./workspace-manager-DLH5XabD.js`).then(e=>e.j),__vite__mapDeps([0,1,2,3]))).getAgentStatusDetail();t&&t.workdir&&(e=t.workdir)}catch{}let t=await c(()=>import(`./context-indicator-ZNMB0fDM.js`).then(e=>e.ln),__vite__mapDeps([4,1,2,3,5,6,7,0])),n=e?X(e):null,r=await Promise.all(l.map(e=>t.resolveWorkspaceAbsolutePath(e).catch(()=>null))),i=[];for(let e=0;e<l.length;e++){let t=r[e];if(!n||!t)continue;let a=X(t);a!==n&&!a.startsWith(n.endsWith(`/`)?n:n+`/`)||i.push({token:l[e],path:t})}if(i.length){let e=await chrome.runtime.sendMessage({type:`CHECK_FILES_EXIST`,paths:i.map(e=>e.path)});if(e&&e.success&&e.results)for(let t of i)e.results[t.path]===!0&&u.add(X(t.token))}}catch{}let d=e=>i.has(X(e))||u.has(X(e)),f=t(`chat.fileLinkTitle`);for(let e of o){let t=e.nodeValue,n=mt(t).filter(d);if(n.length===0)continue;let r=n.slice().sort((e,t)=>t.length-e.length),i=document.createDocumentFragment(),a=t;for(;a.length;){let e=-1,t=null;for(let n of r){let r=a.indexOf(n);r!==-1&&(e===-1||r<e)&&(e=r,t=n)}if(e===-1){i.appendChild(document.createTextNode(a));break}e>0&&i.appendChild(document.createTextNode(a.slice(0,e)));let n=document.createElement(`span`);n.className=`chat-file-link`,n.setAttribute(`data-path`,t),n.setAttribute(`title`,f),n.textContent=t,i.appendChild(n),a=a.slice(e+t.length)}e.parentNode&&e.parentNode.replaceChild(i,e)}}var gt=!1;function _t(){gt||(gt=!0,document.addEventListener(`click`,async e=>{let n=e.target.closest&&e.target.closest(`.chat-file-link`);if(!n)return;let r=n.getAttribute(`data-path`);if(r)try{await(await c(()=>import(`./context-indicator-ZNMB0fDM.js`).then(e=>e.ln),__vite__mapDeps([4,1,2,3,5,6,7,0]))).locateFileInWorkspace(r)}catch{E(t(`chat.fileLinkFailed`),`error`)}},!0))}var Z=`voiceInputDevice`,vt=new Set([`default`,`communications`]);function Q(e){return typeof e==`string`?e.trim():``}function yt(e){let t=Q(e),n={channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0};return t?{...n,deviceId:{exact:t}}:n}function $(e){try{return(e.navigator??globalThis.navigator)?.mediaDevices||null}catch{return null}}async function bt(e={}){let t=$(e);if(!t||typeof t.enumerateDevices!=`function`)return[];let n;try{n=await t.enumerateDevices()}catch{return[]}let r=new Set,i=[];for(let e of Array.isArray(n)?n:[]){if(e?.kind!==`audioinput`)continue;let t=Q(e.deviceId);!t||vt.has(t)||r.has(t)||(r.add(t),i.push({deviceId:t,label:typeof e.label==`string`?e.label.trim():``}))}return i}function xt(e,t){let n=Q(t);return n?(Array.isArray(e)?e:[]).some(e=>e?.deviceId===n):!0}var St=2500,Ct=Symbol(`device-enum-timeout`);async function wt(e={},t=St){let n=$(e);if(!n||typeof n.enumerateDevices!=`function`)return{devices:[],timedOut:!1,unsupported:!0};let r=Math.max(0,Number(t)||2500),i=null,a=new Promise(e=>{i=setTimeout(()=>e(Ct),r)});try{let t=await Promise.race([bt(e),a]);return t===Ct?{devices:[],timedOut:!0,unsupported:!1}:{devices:t,timedOut:!1,unsupported:!1}}finally{i!==null&&clearTimeout(i)}}var Tt=1500;async function Et(e={},t=Tt){let n=$(e);if(!n||typeof n.getUserMedia!=`function`)return!1;let r=Math.max(0,Number(t)||1500),i=e=>{try{e?.getTracks?.().forEach(e=>e.stop())}catch{}},a=!1,o=null,s=null,c=Promise.resolve().then(()=>n.getUserMedia({audio:!0})).then(e=>(a?i(e):o=e,!!e)).catch(()=>!1),l=new Promise(e=>{s=setTimeout(()=>e(!1),r)}),u;try{u=await Promise.race([c,l])}finally{s!==null&&clearTimeout(s),a=!0,i(o),o=null}return u===!0}function Dt(){try{return globalThis.chrome?.storage?.local||null}catch{return null}}async function Ot(){let e=Dt();if(!e?.get)return``;try{return Q((await e.get(Z))?.[Z])}catch{return``}}async function kt(e){let t=Q(e),n=Dt();if(!n?.set)return t;try{await n.set({[Z]:t})}catch{}return t}function At(e,t={}){let n=$(t);if(!n||typeof n.addEventListener!=`function`)return()=>{};let r=()=>{try{e()}catch{}};try{n.addEventListener(`devicechange`,r)}catch{return()=>{}}return()=>{try{n.removeEventListener(`devicechange`,r)}catch{}}}async function jt(e,t={}){let n=$(t);if(!n||typeof n.getUserMedia!=`function`){let e=Error(`unsupported`);throw e.name=`NotSupportedError`,e}let r=Q(e);try{return{stream:await n.getUserMedia({audio:yt(r)}),fellBack:!1,deviceId:r}}catch(e){let t=e?.name||``;if(!r||!(t===`OverconstrainedError`||t===`NotFoundError`||t===`NotReadableError`))throw e;return{stream:await n.getUserMedia({audio:yt(``)}),fellBack:!0,deviceId:``,error:t}}}var Mt={version:`2.8.19`,tag:`v2.8.19`,commitId:`5debba2becd2250a732ae814f203ca2eb208e7ba`,publishedAt:`2026-11-23T23:12:52.326Z`};export{T as $,A,fe as B,Fe as C,_e as D,be as E,te as F,ve as G,ge as H,ne as I,E as J,je as K,ee as L,Ce as M,we as N,P as O,Se as P,w as Q,re as R,B as S,ie as T,le as U,he as V,pe as W,O as X,ae as Y,x as Z,qe as _,wt as a,U as b,At as c,ft as d,C as et,ht as f,Ye as g,He as h,Ot as i,k as j,me as k,it as l,Y as m,jt as n,kt as o,_t as p,Te as q,xt as r,Et as s,Mt as t,K as u,tt as v,D as w,Ve as x,Je as y,N as z};
|
package/dist/manifest.json
CHANGED
package/dist/options.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<script type="module" crossorigin src="/assets/model-profiles-C7nNtymU.js"></script>
|
|
11
11
|
<script type="module" crossorigin src="/assets/voice-shortcut-Dx863RGz.js"></script>
|
|
12
12
|
<script type="module" crossorigin src="/assets/agent-store-_CfonCwg.js"></script>
|
|
13
|
-
<script type="module" crossorigin src="/assets/version-
|
|
13
|
+
<script type="module" crossorigin src="/assets/version-DbUttEL9.js"></script>
|
|
14
14
|
<script type="module" crossorigin src="/assets/network-scope-0d6MoKgI.js"></script>
|
|
15
15
|
<script type="module" crossorigin src="/assets/options.js"></script>
|
|
16
16
|
<link rel="stylesheet" crossorigin href="/assets/theme-ChzggwXz.css">
|
package/dist/side_panel.html
CHANGED
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
<script type="module" crossorigin src="/assets/session-store-BU0hS2_b.js"></script>
|
|
12
12
|
<script type="module" crossorigin src="/assets/voice-shortcut-Dx863RGz.js"></script>
|
|
13
13
|
<script type="module" crossorigin src="/assets/agent-store-_CfonCwg.js"></script>
|
|
14
|
-
<script type="module" crossorigin src="/assets/version-
|
|
14
|
+
<script type="module" crossorigin src="/assets/version-DbUttEL9.js"></script>
|
|
15
15
|
<script type="module" crossorigin src="/assets/workspace-manager-DLH5XabD.js"></script>
|
|
16
|
-
<script type="module" crossorigin src="/assets/context-indicator-
|
|
16
|
+
<script type="module" crossorigin src="/assets/context-indicator-ZNMB0fDM.js"></script>
|
|
17
17
|
<script type="module" crossorigin src="/assets/todo-model-BKnA8C59.js"></script>
|
|
18
18
|
<script type="module" crossorigin src="/assets/side_panel.js"></script>
|
|
19
19
|
<link rel="stylesheet" crossorigin href="/assets/theme-ChzggwXz.css">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-helper-agent",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.19",
|
|
4
4
|
"description": "AI Helper Agent - Local file access and system command execution proxy for Chrome extension / AI Helper 代理服务,为 Chrome 扩展提供本地文件读写和系统命令执行",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/server.js",
|