ai-helper-agent 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -1
- package/README.zh-CN.md +20 -1
- package/bin/agent.js +150 -0
- package/dist/assets/{agent-store-C4hZkQT5.js → agent-store-DOyMdB_7.js} +2 -2
- package/dist/assets/{agent-store-C4hZkQT5.js.map → agent-store-DOyMdB_7.js.map} +1 -1
- package/dist/assets/background.js +84 -85
- package/dist/assets/background.js.map +1 -1
- package/dist/assets/content.js +80 -78
- package/dist/assets/{i18n-CAh-vB_T.js → i18n-MmYITlVj.js} +5 -5
- package/dist/assets/i18n-MmYITlVj.js.map +1 -0
- package/dist/assets/model-profiles-CV_sUuPf.js +25 -0
- package/dist/assets/model-profiles-CV_sUuPf.js.map +1 -0
- package/dist/assets/options.js +56 -56
- package/dist/assets/options.js.map +1 -1
- package/dist/assets/page-snapshot-renderer-CE53ibi-.js +4 -0
- package/dist/assets/page-snapshot-renderer-CE53ibi-.js.map +1 -0
- package/dist/assets/{session-store-uZ_LNasH.js → session-store-B0ZPGm7d.js} +4 -4
- package/dist/assets/{session-store-uZ_LNasH.js.map → session-store-B0ZPGm7d.js.map} +1 -1
- package/dist/assets/side_panel.css +1 -1
- package/dist/assets/side_panel.js +177 -171
- package/dist/assets/side_panel.js.map +1 -1
- package/dist/manifest.json +6 -3
- package/dist/offscreen/offscreen.js +6 -6
- package/dist/options.html +2 -11
- package/dist/side_panel.html +6 -6
- package/package.json +1 -1
- package/src/install-mode.js +128 -0
- package/src/locales/cli.json +24 -0
- package/src/rag/install.js +4 -0
- package/src/server.js +3 -1
- package/dist/assets/i18n-CAh-vB_T.js.map +0 -1
- package/dist/assets/model-profiles-CGxULM3O.js +0 -25
- package/dist/assets/model-profiles-CGxULM3O.js.map +0 -1
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/agent-store-
|
|
2
|
-
import{i as e,o as t,r as n}from"./rolldown-runtime-C0FnF6B9.js";import{a as r,c as i,i as a,l as o,n as s,r as c,s as l}from"./i18n-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/agent-store-DOyMdB_7.js","assets/rolldown-runtime-C0FnF6B9.js","assets/i18n-MmYITlVj.js","assets/session-store-B0ZPGm7d.js","assets/pdf-HiJ0icvU.js","assets/lib-Bi7BFuND.js","assets/jszip.min-BXqW2-9v.js","assets/dist-BQOFgIxk.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e,o as t,r as n}from"./rolldown-runtime-C0FnF6B9.js";import{a as r,c as i,i as a,l as o,n as s,r as c,s as l}from"./i18n-MmYITlVj.js";import{C as u,D as d,H as f,I as p,L as m,M as h,N as g,O as _,P as v,S as y,U as b,Y as x,b as S,c as C,d as w,i as T,j as E,r as D,u as O,w as k,x as A,y as j}from"./model-profiles-CV_sUuPf.js";import{C as M,D as ee,H as N,L as P,O as F,P as I,S as L,U as R,V as z,W as te,Y as ne,a as re,b as ie,c as ae,d as oe,f as B,h as se,i as V,j as ce,l as le,m as H,n as ue,o as de,p as fe,s as pe,t as me,u as he,v as ge,w as _e,x as ve,y as ye}from"./session-store-B0ZPGm7d.js";import{a as be,c as xe,i as Se,n as Ce,o as we,r as Te,s as Ee}from"./agent-store-DOyMdB_7.js";var De=[...new Set([...b,`mcp`,`knowledge`])],Oe=[{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}];r(`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 时必须单独调用,同一轮响应中不要同时返回其他工具调用;其他想执行的动作请编入子任务描述,由子任务执行。`,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
|
|
5
5
|
- manage: subAction=review审查价值,compact清理低价值
|
|
6
|
-
- 存长期价值信息,加tags和importance(1-10)
|
|
6
|
+
- 存长期价值信息,加tags和importance(1-10)便于检索
|
|
7
|
+
- importance语义:8-10=跨对话高频相关(环境约束/技术偏好/工作习惯),会常驻系统提示词;5-7=窄场景重要信息(项目详情/配置记录),按需召回;1-4=低价值
|
|
8
|
+
- 不存凭据原文(密码/授权码/密钥),只存位置指针(如"授权码存于 xxx/.env")`,importanceLabel:`重要性`,tagsLabel:`标签`,permanentNotesTitle:`## 永久注意事项`,permanentNotesMore:`> 另有 {count} 条历史记忆(涵盖:{topics} 等主题)。回答涉及本机环境、已装工具/技能、历史项目、个人偏好或过往记录的问题前,先调用 agent_memory 检索(action=recall)再作答;不确定时宁可多召回一次。`,permanentNotesMoreNoTopics:`> 另有 {count} 条历史记忆。回答涉及本机环境、已装工具/技能、历史项目、个人偏好或过往记录的问题前,先调用 agent_memory 检索(action=recall)再作答;不确定时宁可多召回一次。`,currentEnvTitle:`## 当前环境`,currentTimeLabel:`当前时间:`,browserLabel:`浏览器:Chrome 扩展 (Side Panel)`,defaultPromptIntro:`AI Helper:IT技术助手。`,capabilityTitle:`## 能力`,capabilityDesc:`编程开发与调试(Java/Python/JavaScript/Go/C++)、架构优化、性能调优、代码审查、文档编写、浏览器工具调用`,taskPlanningJoin:`、任务规划`,requirementTitle:`## 要求`,requirementDesc:`精准技术术语,代码示例可运行,Markdown格式,方案可落地,不生成安全违规代码`,envTitle:`## 环境`}}),r(`en`,{util:{cmdHintPowerShell:"(Use PowerShell syntax, e.g. `Get-ChildItem`, `Set-Content`, `Remove-Item`, etc.)",cmdHintCmd:"(Use CMD syntax, e.g. `dir`, `echo`, `del`, etc.)",cmdHintGitBash:"(Use Unix commands, e.g. `ls`, `cat`, `rm`, etc. Use forward slashes `/` for paths)",cmdHintPowerShellShort:`(Use PowerShell syntax)`,cmdHintUnix:"(Use Unix commands, e.g. `ls`, `cat`, `rm`, etc.)",cmdExecEnvTitle:`## Command Execution Environment`,cmdExecOsShell:`**OS/Shell**`,cmdExecWorkdir:`Working directory`,cmdExecWorkdirUnset:`not set`,assistantTerm:`- **Assistant**: An AI agent created by the user. Each assistant has its own system prompt and tool permissions, and can work independently or be dispatched by other assistants to perform subtasks`,noDesc:`No description`,subDispatchTitle:`## Sub-assistant Dispatch`,subDispatchDesc:`Use dispatch_task(subAgentId, task) to dispatch subtasks to other assistants. Parallel calls are supported.`,subDispatchAvailable:`Available sub-assistants:`,agentTerm:`- **Agent**: A remote execution service that provides file operations, command execution, and other capabilities. Use the manage_agent tool to query or switch agents`,agentHostLabel:`- Agent host: `,agentHostHint:`(Please use this address first when accessing agent services)`,terminologyTitle:`## Terminology`,taskPlanningTitle:`## Task Decomposition`,taskPlanningDesc:`Break down complex tasks (multi-step, with dependencies) into subtasks — typically 2-6, at most 8; execute simple tasks (doable in 1-2 steps) directly and never split just to hit a count. Use plan_task(taskDescription, subtasks) to submit the plan. Important: when calling plan_task, call it alone — do not return other tool calls in the same turn; put any other intended actions into the subtask descriptions for the subtasks to execute.`,memoryTitle:`## Memory`,memoryRules:`- Unified tool agent_memory, distinguished by action: store (add/update/delete) / recall (retrieve) / manage (review/cleanup)
|
|
7
9
|
- store: subAction=add requires type+content, update requires memoryId+type, **delete only requires memoryId (no type)**. **Always recall first to find the id before deleting**
|
|
8
10
|
- recall: use keywords for query (e.g. "exam"), not full sentences. Optional memoryType and limit
|
|
9
11
|
- manage: subAction=review to assess value, compact to clean up low-value entries
|
|
10
|
-
- Store long-term valuable information; add tags and importance (1-10) for easier retrieval
|
|
12
|
+
- Store long-term valuable information; add tags and importance (1-10) for easier retrieval
|
|
13
|
+
- importance semantics: 8-10 = relevant across most conversations (environment constraints / tech preferences / work habits), always injected into the system prompt; 5-7 = important but narrow-scope info (project details / config records), retrieved on demand; 1-4 = low value
|
|
14
|
+
- Never store raw credentials (passwords / auth codes / keys); store only a location pointer (e.g. "auth code lives in xxx/.env")`,importanceLabel:`Importance`,tagsLabel:`Tags`,permanentNotesTitle:`## Permanent Notes`,permanentNotesMore:`> There are {count} more historical memories (covering: {topics}, etc.). Before answering questions about the local environment, installed tools/skills, past projects, personal preferences, or prior records, retrieve them first via agent_memory (action=recall); when unsure, recall once more rather than skip.`,permanentNotesMoreNoTopics:`> There are {count} more historical memories. Before answering questions about the local environment, installed tools/skills, past projects, personal preferences, or prior records, retrieve them first via agent_memory (action=recall); when unsure, recall once more rather than skip.`,currentEnvTitle:`## Current Environment`,currentTimeLabel:`Current time: `,browserLabel:`Browser: Chrome Extension (Side Panel)`,defaultPromptIntro:`AI Helper: IT Technical Assistant.`,capabilityTitle:`## Capabilities`,capabilityDesc:`Programming & debugging (Java/Python/JavaScript/Go/C++), architecture optimization, performance tuning, code review, documentation, browser tool calls`,taskPlanningJoin:`, task planning`,requirementTitle:`## Requirements`,requirementDesc:`Precise technical terminology, runnable code examples, Markdown format, actionable solutions, no security-violating code`,envTitle:`## Environment`}});function U(e,t=`info`,n=3e3){let r=document.getElementById(`toastContainer`);if(!r)return;let i=document.createElement(`div`);i.className=`toast ${t}`,i.textContent=e,r.appendChild(i),requestAnimationFrame(()=>{i.classList.add(`toast-show`)}),setTimeout(()=>{i.classList.remove(`toast-show`),setTimeout(()=>{i.parentNode&&i.parentNode.removeChild(i)},300)},n)}function ke(){let e=document.getElementById(`userInput`);if(!e||H.isScrolling)return;e.style.height=`auto`;let t=e.scrollHeight;t<=50?e.style.height=``:e.style.height=Math.min(t,100)+`px`,Ae()}function Ae(){let e=document.querySelector(`.input-wrapper`),t=document.querySelector(`.input-container`);if(!e||!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect().bottom-n.top+8;t.style.setProperty(`--dropdown-bottom`,r+`px`)}function W(e){if(!e)return``;let t=document.createElement(`div`);return t.textContent=e,t.innerHTML}function je(e){return e?String(e).replace(/&/g,`&`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/</g,`<`).replace(/>/g,`>`):``}function Me(e){return!e||e<0?`0ms`:e<1e3?`${Math.round(e)}ms`:e<6e4?`${Ne(e/1e3)}s`:e<36e5?`${Ne(e/6e4)}min`:`${Ne(e/36e5)}h`}function Ne(e){let t=Math.round(e*10)/10;return Number.isInteger(t)?String(t):t.toFixed(1)}function Pe(e){return String(e).padStart(2,`0`)}function Fe(e){if(!e)return``;let t=new Date(e);if(isNaN(t.getTime()))return``;let n=`${Pe(t.getHours())}:${Pe(t.getMinutes())}`,r=new Date,i=c()!==`en`;return t.getFullYear()===r.getFullYear()&&t.getMonth()===r.getMonth()&&t.getDate()===r.getDate()?n:i?t.getFullYear()===r.getFullYear()?`${t.getMonth()+1}月${t.getDate()}日 ${n}`:`${t.getFullYear()}/${t.getMonth()+1}/${t.getDate()} ${n}`:t.getFullYear()===r.getFullYear()?`${t.toLocaleString(`en-US`,{month:`short`})} ${t.getDate()}, ${n}`:`${t.getFullYear()}/${Pe(t.getMonth()+1)}/${Pe(t.getDate())}, ${n}`}function Ie(e){if(!e)return``;let t=new Date(e);if(isNaN(t.getTime()))return``;let n=`${Pe(t.getHours())}:${Pe(t.getMinutes())}:${Pe(t.getSeconds())}`;return c()===`en`?`${t.getFullYear()}-${Pe(t.getMonth()+1)}-${Pe(t.getDate())} ${n}`:`${t.getFullYear()}年${t.getMonth()+1}月${t.getDate()}日 ${n}`}function Le(e){return!e||e<=0?`0`:e<1e3?String(e):e<1e4?Math.round(e/100)/10+`K`:e<1e6?Math.round(e/1e3)+`K`:Math.round(e/1e5)/10+`M`}function Re(e){return!e&&e!==0?`0`:Number(e).toLocaleString(`en-US`)}function ze(e){if(!e||!Array.isArray(e))return null;let t=0,n=0,r=0,i=!1;for(let a of e){let e=a.apiResponse?.tokenUsage;e&&(t+=e.prompt_tokens||0,n+=e.completion_tokens||0,r+=e.total_tokens||(e.prompt_tokens||0)+(e.completion_tokens||0),i=!0)}return i?{promptTokens:t,completionTokens:n,totalTokens:r}:null}r(`zh`,{tokenPopup:{title:`Token 消耗明细`,total:`总计`,input:`输入`,output:`输出`,inputUnit:`tokens`,outputUnit:`tokens`,percent:`{p}%`,balanceTitle:`账户余额`,balanceTotal:`总余额`,balanceGranted:`赠送余额`,balanceToppedUp:`充值余额`,balanceLoading:`查询中...`}}),r(`en`,{tokenPopup:{title:`Token Usage Details`,total:`Total`,input:`Input`,output:`Output`,inputUnit:`tokens`,outputUnit:`tokens`,percent:`{p}%`,balanceTitle:`Account Balance`,balanceTotal:`Total Balance`,balanceGranted:`Granted`,balanceToppedUp:`Topped Up`,balanceLoading:`Loading...`}});function Be(e,t){if(!e)return;let n=document.querySelector(`.token-detail-popup`);if(n&&(n.remove(),t._tokenPopupOpen)){t._tokenPopupOpen=!1;return}document.querySelectorAll(`[data-token-popup-open]`).forEach(e=>{e._tokenPopupOpen=!1,e.removeAttribute(`data-token-popup-open`)});let{promptTokens:r,completionTokens:a,totalTokens:o}=e,s=o>0?Math.round(r/o*100):0,c=o>0?Math.round(a/o*100):0,l=document.createElement(`div`);l.className=`token-detail-popup`,l.innerHTML=`
|
|
11
15
|
<div class="token-popup-header">
|
|
12
16
|
<span class="token-popup-title">${i(`tokenPopup.title`)}</span>
|
|
13
17
|
<button class="token-popup-close" aria-label="${i(`common.close`)}">×</button>
|
|
@@ -64,44 +68,46 @@ import{i as e,o as t,r as n}from"./rolldown-runtime-C0FnF6B9.js";import{a as r,c
|
|
|
64
68
|
${i(`util.cmdExecEnvTitle`)}
|
|
65
69
|
- ${i(`util.cmdExecOsShell`)}: ${r.osType} (${r.arch}) / ${r.shellType}
|
|
66
70
|
- ${i(`util.cmdExecWorkdir`)}: ${r.workdir||i(`util.cmdExecWorkdirUnset`)}
|
|
67
|
-
- ${r.commandHint}`);let o=(await we()).filter(t=>t.allowSubDispatch&&t.id!==(e?.id||``)),s=o.length>0&&Ge(`dispatch_task`,e?.toolIds),
|
|
68
|
-
`);
|
|
71
|
+
- ${r.commandHint}`);let o=(await we()).filter(t=>t.allowSubDispatch&&t.id!==(e?.id||``)),s=o.length>0&&Ge(`dispatch_task`,e?.toolIds),l=!1,u=null;try{let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),t=e.pairedAgents||[];if(l=t.length>0,l&&e.activeAgentId){let n=t.find(t=>t.id===e.activeAgentId);if(n?.url)try{u=new URL(n.url).hostname}catch{let e=n.url.replace(/^https?:\/\//,``).replace(/\/.*$/,``).split(`:`)[0];e&&(u=e)}}}catch{}let d=``;u&&(d=`\n${i(`util.agentHostLabel`)}${u}${i(`util.agentHostHint`)}`);let f=``,p=``,m=``;if(s){f=i(`util.assistantTerm`);let e=o.map(e=>`- **${e.id}** (${e.icon} ${e.name}): ${e.description||i(`util.noDesc`)}`).join(`
|
|
72
|
+
`);m=`
|
|
69
73
|
|
|
70
74
|
${i(`util.subDispatchTitle`)}
|
|
71
75
|
${i(`util.subDispatchDesc`)}
|
|
72
76
|
|
|
73
77
|
${i(`util.subDispatchAvailable`)}
|
|
74
|
-
${e}`}
|
|
75
|
-
`);
|
|
78
|
+
${e}`}l&&(p=i(`util.agentTerm`));let h=``;if(f||p){let e=[f,p].filter(Boolean).join(`
|
|
79
|
+
`);h=`
|
|
76
80
|
|
|
77
81
|
${i(`util.terminologyTitle`)}
|
|
78
|
-
${e}`}let
|
|
82
|
+
${e}`}let g=H.useTools&&Ge(`plan_task`,e?.toolIds)?`
|
|
79
83
|
|
|
80
84
|
${i(`util.taskPlanningTitle`)}
|
|
81
|
-
${i(`util.taskPlanningDesc`)}`:``,
|
|
85
|
+
${i(`util.taskPlanningDesc`)}`:``,_=[`agent_memory`].some(t=>Ge(t,e?.toolIds)),v=H.useTools&&_,y=H.useTools&&H.agentPlatform?.connected&&_?`
|
|
82
86
|
|
|
83
87
|
${i(`util.memoryTitle`)}
|
|
84
|
-
${i(`util.memoryRules`)}`:``,
|
|
85
|
-
`);v=`
|
|
88
|
+
${i(`util.memoryRules`)}`:``,b=``;if(H.agentPlatform?.connected)try{let e=await Je(),t=e.facts||[],n=e.remainingCount||0,r=t.length>0,a=n>0&&v;if(r||a){let o=`
|
|
86
89
|
|
|
87
90
|
${i(`util.permanentNotesTitle`)}
|
|
88
|
-
|
|
89
|
-
`
|
|
91
|
+
`;if(r&&(o+=t.map((e,t)=>`${t+1}. [${i(`util.importanceLabel`)}: ${e.importance||5}] ${e.content}${e.tags&&e.tags.length?` (${i(`util.tagsLabel`)}: ${e.tags.join(`, `)})`:``}`).join(`
|
|
92
|
+
`)+`
|
|
93
|
+
`),a){let t=e.remainingTags||[],r=t.join(c()===`zh`?`、`:`, `);o+=`
|
|
94
|
+
`+(t.length>0?i(`util.permanentNotesMore`,{count:n,topics:r}):i(`util.permanentNotesMoreNoTopics`,{count:n}))+`
|
|
95
|
+
`}b=o}}catch{}let x;if(x=e&&e.systemPrompt&&e.systemPrompt.trim()?e.systemPrompt:H.systemPrompt&&H.systemPrompt.trim()?H.systemPrompt:null,x){let r=`${x}${h}${b}
|
|
90
96
|
|
|
91
97
|
${i(`util.currentEnvTitle`)}
|
|
92
98
|
- ${i(`util.currentTimeLabel`)}${t}
|
|
93
|
-
- ${i(`util.browserLabel`)} / ${n}${
|
|
94
|
-
`;try{let t=await qe(e?.toolIds,e?.skillIds);t&&(r+=`\n${t}\n`)}catch{}return r}let
|
|
99
|
+
- ${i(`util.browserLabel`)} / ${n}${d}${a}${g}${m}${y}
|
|
100
|
+
`;try{let t=await qe(e?.toolIds,e?.skillIds);t&&(r+=`\n${t}\n`)}catch{}return r}let S=`${i(`util.defaultPromptIntro`)}${h}${b}
|
|
95
101
|
|
|
96
102
|
${i(`util.capabilityTitle`)}
|
|
97
103
|
${i(`util.capabilityDesc`)}${H.useTools&&Ge(`plan_task`,e?.toolIds)?i(`util.taskPlanningJoin`):``}
|
|
98
104
|
|
|
99
105
|
${i(`util.requirementTitle`)}
|
|
100
|
-
${i(`util.requirementDesc`)}${
|
|
106
|
+
${i(`util.requirementDesc`)}${g}${m}${y}
|
|
101
107
|
|
|
102
108
|
${i(`util.envTitle`)}
|
|
103
|
-
${t} | Chrome Side Panel / ${n}${
|
|
104
|
-
`;try{let t=await qe(e?.toolIds,e?.skillIds);t&&(
|
|
109
|
+
${t} | Chrome Side Panel / ${n}${d}${a}
|
|
110
|
+
`;try{let t=await qe(e?.toolIds,e?.skillIds);t&&(S+=`\n${t}\n`)}catch{}return S}async function qe(e,t){return Array.isArray(t)&&t.length===0||!(t!=null&&Array.isArray(t)&&t.length>0)&&e!=null&&Array.isArray(e)&&!e.includes(`agent_skill`)?``:new Promise(e=>{try{chrome.storage.local.get([`skillsEnabled`],n=>{if(n.skillsEnabled===!1){e(``);return}let r={type:`GET_AGENT_SKILL_PROMPTS`};t!=null&&Array.isArray(t)&&t.length>0&&(r.skillNames=t),chrome.runtime.sendMessage(r,t=>{if(chrome.runtime.lastError){e(``);return}e(t?.prompts||``)})})}catch{e(``)}})}async function Je(){return new Promise(e=>{let t={facts:[],remainingCount:0,remainingTags:[]};try{chrome.runtime.sendMessage({type:`GET_PERMANENT_NOTES`},n=>{if(chrome.runtime.lastError||!n?.success){e(t);return}e({facts:n.facts||[],remainingCount:n.remainingCount||0,remainingTags:n.remainingTags||[]})})}catch{e(t)}})}function Ye(){return Promise.resolve({temperature:parseFloat(H.temperature.toFixed(2)),top_p:parseFloat(H.topP.toFixed(2))})}function Xe(){return new Promise(e=>{chrome.runtime.sendMessage({type:`GET_CHAT_CONFIG`},t=>{t&&(H.chatConfig=t,o.debug(`[SidePanel] conversationconfiguration loaded:`,H.chatConfig)),e(t)})})}async function Ze(){return new Promise(e=>{chrome.runtime.sendMessage({type:`GET_CHAT_CONFIG`},t=>{t&&(H.chatConfig=t,o.debug(`[SidePanel] sync loadconversationconfiguration:`,H.chatConfig)),e()})})}async function Qe(){return new Promise(e=>{chrome.tabs.query({active:!0,currentWindow:!0},t=>{t&&t.length>0&&t[0].id?(H.currentTabId=t[0].id,o.debug(`[SidePanel] get current Tab ID:`,H.currentTabId,`URL:`,t[0].url),e(H.currentTabId)):(o.warn(`[SidePanel] did not getvalid Tab ID`),e(null))})})}function $e(){return new Promise(e=>{chrome.storage.local.get([`reactMaxIterations`,`reactApiTimeout`,`reactLoopTimeout`,`reactToolTimeout`,`reactClarifyTimeout`],t=>{e({maxIterations:t.reactMaxIterations||30,apiTimeout:t.reactApiTimeout||6e4,loopTimeout:t.reactLoopTimeout||72e5,toolTimeout:t.reactToolTimeout||3e4,clarifyTimeout:x.clarifyTimeout})})})}function et(e){e&&(e.style.removeProperty(`--clamp-y`),requestAnimationFrame(()=>{let t=e.getBoundingClientRect();if(!t.height)return;let n=0;t.bottom>window.innerHeight-8&&(n=window.innerHeight-8-t.bottom),t.top+n<8&&(n=8-t.top),n&&e.style.setProperty(`--clamp-y`,`${Math.round(n)}px`)}))}function tt(e){e&&e.style.removeProperty(`--clamp-y`)}r(`zh`,{contextUsage:{compactionInjection:`[上下文摘要|压缩了{count}条历史]`}}),r(`en`,{contextUsage:{compactionInjection:`[Context Summary | {count} messages compacted]`}});var nt=2e3,rt=.7,it=1e3;function at(e,{isolateChat:t=!0,maxMemoryMessages:n=null,compaction:r=null,historyBudget:i=1/0,currentMessage:a=null}={}){let o=a||{role:`user`,content:``};if(!t)return{messages:[o],keptHistory:[],compactionApplied:!1,trimmedCount:0,historySummaryText:null};let s=Array.isArray(e)?e:[],c=!1,l=-1;r&&r.summary&&r.upToMessageId&&(l=s.findIndex(e=>e.messageId===r.upToMessageId),c=l>=0);let d=s,f=s.map((e,t)=>t);n&&n>0&&s.length>n&&(d=s.slice(s.length-n),f=f.slice(s.length-n));let m=[];for(let e=0;e<d.length;e++)c&&f[e]<=l||m.push(d[e]);let h=[],g=u([o]);for(let e=m.length-1;e>=0;e--){let t=m[e],n={...t,content:p(t.content)},r=u([n]);if(g+r<=i)h.unshift(t),g+=r;else break}let v=null,y=m.length-h.length;if(y>0){let e=_(m.slice(0,y));e&&(v=k(e)>it?e.substring(0,it*4)+`
|
|
105
111
|
...[历史摘要已截断]`:e)}return{messages:[...h,o],keptHistory:h,compactionApplied:c,trimmedCount:y,historySummaryText:v}}function ot(e,t){return!t||!t.summary?e:`${e}\n\n${i(`contextUsage.compactionInjection`,{count:t.compressedCount||0})}\n${t.summary}`}function st({model:e,customModelMap:t=null,systemPromptText:n=``,toolCount:r=0,history:i=[],inputText:a=``,maxMemoryMessages:o=null,compaction:s=null,isolateChat:c=!0,userConfiguredWindow:l=0}={}){let d=E(e,l,t),f=d-k(n)-S-nt,p=Math.floor(Math.max(f,0)*rt),m={role:`user`,content:a},h=c?s:null,g=at(i,{isolateChat:c,maxMemoryMessages:o,compaction:h,historyBudget:p,currentMessage:m}),_=g.compactionApplied?ot(n,h):n,v=k(_),y=r*200,b=u(g.keptHistory),x=a&&a.trim()?u([m]):0,C=v+y+b+x,w=A(C,d);return{usedTokens:C,contextWindow:d,ratio:d>0?C/d:0,level:w.level,breakdown:{system:v,tools:y,history:b,input:x,outputReserve:S,safetyMargin:nt,selectedCount:g.keptHistory.length,totalCount:i.length,trimmedCount:g.trimmedCount,compactionApplied:g.compactionApplied,compactionInvalid:!!(h&&h.summary&&!g.compactionApplied),historyBudget:p}}}function ct(e,{maxMemoryMessages:t=null,compaction:n=null}={}){let r=at(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=p(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 lt(e){if(!e||!e.trim()||e.trim()==`/`)return;let t=e.trim(),n=H.inputHistory.indexOf(t);n!==-1&&H.inputHistory.splice(n,1),H.inputHistory.push(t),H.inputHistory.length>20&&H.inputHistory.shift(),ut()}function ut(){try{chrome.storage.local.set({inputHistory:H.inputHistory}),o.debug(`[SidePanel] input history saved,count:`,H.inputHistory.length)}catch(e){o.error(`[SidePanel] saveinput history failed:`,e)}}var dt=[`workspace`,`bookmark`,`toc`,`search`,`schedule`],ft=`.workspace-panel.expanded, .bookmark-panel.expanded, .message-toc-panel.expanded, .search-panel.expanded, .schedule-panel.open`,pt=null,mt=null;function ht(){if(pt)return pt;pt=document.createElement(`div`),pt.className=`side-rail`,pt.id=`sideRail`,pt.innerHTML=dt.map(e=>`<div class="side-rail-slot" data-slot="${e}"></div>`).join(``),document.body.appendChild(pt),_t();let e=document.getElementById(`chatContainer`);return e&&typeof ResizeObserver<`u`&&new ResizeObserver(_t).observe(e),window.addEventListener(`resize`,_t),pt}function gt(e){return(pt||ht()).querySelector(`.side-rail-slot[data-slot="${e}"]`)}function _t(){if(!pt)return;let e=document.getElementById(`chatContainer`);if(!e)return;let t=e.getBoundingClientRect(),n=window.innerHeight;pt.style.top=`${Math.max(0,Math.round(t.top))}px`,pt.style.bottom=`${Math.max(0,Math.round(n-t.bottom))}px`,vt()}function vt(){mt&&clearTimeout(mt),mt=setTimeout(()=>{mt=null,document.querySelectorAll(ft).forEach(et)},120)}r(`zh`,{messageToc:{toggleTitle:`显示目录(H{count}个标题)`,title:`目录`,headingCount:`{count} 个`}}),r(`en`,{messageToc:{toggleTitle:`Show table of contents (H{count} headings)`,title:`Contents`,headingCount:`{count}`}});function yt(){document.addEventListener(`mouseover`,bt,!0),document.addEventListener(`mouseout`,xt,!0),o.debug(`[SidePanel] messagedirectory featureinitializing`)}function bt(e){if(!(e.target instanceof Element))return;if(e.target.closest(`.message-toc-container`)){H.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){Ct();return}St(r,i)}function xt(e){if(!(e.target instanceof Element))return;if(e.target.closest(`.message-toc-container`)){H.isMouseOverToc=!1,H.tocHideTimer&&(clearTimeout(H.tocHideTimer),H.tocHideTimer=null);return}let t=e.target.closest(`.message.assistant`),n=e.target.closest(`.workspace-preview-markdown`);if(!t&&!n)return;let r=e.relatedTarget;r&&(r.closest(`.message-toc-container`)||r.closest(`.message.assistant`)||r.closest(`.workspace-preview-markdown`))||H.isMouseOverToc||(H.tocHideTimer&&clearTimeout(H.tocHideTimer),H.tocHideTimer=setTimeout(()=>{H.isMouseOverToc||Ct(),H.tocHideTimer=null},800))}function St(e,t){let n=Array.from(t);H.messageTocContainer&&Ct(),n.forEach((e,t)=>{e.id||=`toc-heading-${Date.now()}-${t}`});let r=document.createElement(`div`);r.className=`message-toc-container`,r.dataset.headingsCount=n.length;let a=0,o=n.map(e=>{let t=parseInt(e.tagName.charAt(1)),n=e.textContent.trim(),r=n.length>30?n.substring(0,30)+`...`:n,i=`H${t}`;return a++,`
|
|
106
112
|
<li class="message-toc-item level-${t}"
|
|
107
113
|
data-target="${e.id}"
|
|
@@ -126,7 +132,7 @@ ${t} | Chrome Side Panel / ${n}${u}${a}
|
|
|
126
132
|
</ul>
|
|
127
133
|
</div>
|
|
128
134
|
</div>
|
|
129
|
-
`,gt(`toc`).appendChild(r),H.messageTocContainer=r;let s=r.querySelector(`.message-toc-toggle`),c=r.querySelector(`.message-toc-panel`);s.addEventListener(`mouseenter`,()=>{c.classList.add(`expanded`),et(c)}),s.addEventListener(`click`,()=>{c.classList.toggle(`expanded`)?et(c):tt(c)}),c.addEventListener(`mouseenter`,()=>{c.classList.add(`expanded`)}),r.querySelectorAll(`.message-toc-item`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.target,n=document.getElementById(t);n&&(n.scrollIntoView({behavior:`smooth`,block:`start`}),n.classList.add(`toc-highlight`),setTimeout(()=>{n.classList.remove(`toc-highlight`)},1500))})})}function Ct(){H.tocHideTimer&&(clearTimeout(H.tocHideTimer),H.tocHideTimer=null),H.messageTocContainer&&(H.messageTocContainer.remove(),H.messageTocContainer=null)}var wt=`completedSessionIds`;async function Tt(){try{let e=(await chrome.storage.local.get([wt]))[wt]||[];H.completedSessionIds=new Set(e)}catch(e){o.warn(`[SessionManager] restore completedSessionIds failed:`,e)}}async function Et(){try{await chrome.storage.local.set({[wt]:Array.from(H.completedSessionIds)})}catch(e){o.warn(`[SessionManager] persist completedSessionIds failed:`,e)}}async function Dt(e){e&&e!==H.activeSessionId&&(H.completedSessionIds.has(e)||(H.completedSessionIds.add(e),await Et(),document.dispatchEvent(new CustomEvent(`generating-state-changed`))))}async function Ot(e){e&&H.completedSessionIds.has(e)&&(H.completedSessionIds.delete(e),await Et(),document.dispatchEvent(new CustomEvent(`generating-state-changed`)))}async function kt(){return ae()}async function At(){return oe()}async function jt(){return V()}async function Mt(e){return B(e)}async function Nt(e){let t=await re(e);return H.completedSessionIds.has(e)&&(H.completedSessionIds.delete(e),await Et()),t}async function Pt(e,t){return le(e,t)}async function Ft(e){return he(e)}async function It(){return ue()}async function Lt(e){return pe(e)}async function Rt(e,t){return me(e,t)}async function zt(e,t=null){return de(e,t)}r(`zh`,{toolPanel:{agentRestrictedBanner:`当前 Agent 限制了可用工具,部分工具已禁用`,noMatch:`没有匹配的工具`,enabledCount:`已启用 {enabled}/{total} 个工具`,toolsEnabled:`工具已启用`,allToolsDisabled:`所有工具已禁用`,toggleBtnEnabled:`禁用所有工具`,toggleBtnDisabled:`启用所有工具`,mcpServiceToolCount:`{count} 个工具`,mcpServiceExpand:`展开/收起工具列表`,mcpExcludedByAgent:`已被当前助手排除,可在助手编辑中调整`,categorySelectAllHint:`对该分类下可见项全选/取消全选`,stateOn:`已开启`,stateOff:`已关闭`,stateLine:`{name}:{state}`}}),r(`en`,{toolPanel:{agentRestrictedBanner:`Current agent has restricted available tools, some tools are disabled`,noMatch:`No matching tools`,enabledCount:`{enabled}/{total} tools enabled`,toolsEnabled:`Tools enabled`,allToolsDisabled:`All tools disabled`,toggleBtnEnabled:`Disable all tools`,toggleBtnDisabled:`Enable all tools`,mcpServiceToolCount:`{count} tools`,mcpServiceExpand:`Show/hide tool list`,mcpExcludedByAgent:`Excluded by current assistant; adjust in assistant editor`,categorySelectAllHint:`Select/deselect all visible items in this category`,stateOn:`On`,stateOff:`Off`,stateLine:`{name}: {state}`}});var Bt=[],Vt=[];function Ht(e){if(!e)return``;let t=`tool.${e.id}`,n=i(t);return n===t?e.description||``:n}function Ut(e){if(!e)return``;let t=e.description||``;if(t.startsWith(`[MCP:`)){let e=t.indexOf(`]`);e!==-1&&(t=t.slice(e+1).trim())}return t===(e.name||``)?``:t}async function Wt(){try{let e=await chrome.runtime.sendMessage({type:`GET_MCP_TOOLS`});if(e?.success&&e.tools)return Bt=e.tools,Bt}catch{}try{return Bt=(await chrome.storage.local.get([`mcpTools`])).mcpTools||[],Bt}catch{return Bt=[],[]}}async function Gt(){try{Vt=(await chrome.storage.local.get([`ragTools`])).ragTools||[]}catch{Vt=[]}return Vt}async function Kt(){let e=`agentMcpClosedServers_${H.activeAgentId||`default`}`;try{let t=await chrome.storage.local.get([e]);H.mcpClosedServers=t[e]||[]}catch{H.mcpClosedServers=[]}try{let{getAgent:e}=await fe(async()=>{let{getAgent:e}=await import(`./agent-store-
|
|
135
|
+
`,gt(`toc`).appendChild(r),H.messageTocContainer=r;let s=r.querySelector(`.message-toc-toggle`),c=r.querySelector(`.message-toc-panel`);s.addEventListener(`mouseenter`,()=>{c.classList.add(`expanded`),et(c)}),s.addEventListener(`click`,()=>{c.classList.toggle(`expanded`)?et(c):tt(c)}),c.addEventListener(`mouseenter`,()=>{c.classList.add(`expanded`)}),r.querySelectorAll(`.message-toc-item`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.target,n=document.getElementById(t);n&&(n.scrollIntoView({behavior:`smooth`,block:`start`}),n.classList.add(`toc-highlight`),setTimeout(()=>{n.classList.remove(`toc-highlight`)},1500))})})}function Ct(){H.tocHideTimer&&(clearTimeout(H.tocHideTimer),H.tocHideTimer=null),H.messageTocContainer&&(H.messageTocContainer.remove(),H.messageTocContainer=null)}var wt=`completedSessionIds`;async function Tt(){try{let e=(await chrome.storage.local.get([wt]))[wt]||[];H.completedSessionIds=new Set(e)}catch(e){o.warn(`[SessionManager] restore completedSessionIds failed:`,e)}}async function Et(){try{await chrome.storage.local.set({[wt]:Array.from(H.completedSessionIds)})}catch(e){o.warn(`[SessionManager] persist completedSessionIds failed:`,e)}}async function Dt(e){e&&e!==H.activeSessionId&&(H.completedSessionIds.has(e)||(H.completedSessionIds.add(e),await Et(),document.dispatchEvent(new CustomEvent(`generating-state-changed`))))}async function Ot(e){e&&H.completedSessionIds.has(e)&&(H.completedSessionIds.delete(e),await Et(),document.dispatchEvent(new CustomEvent(`generating-state-changed`)))}async function kt(){return ae()}async function At(){return oe()}async function jt(){return V()}async function Mt(e){return B(e)}async function Nt(e){let t=await re(e);return H.completedSessionIds.has(e)&&(H.completedSessionIds.delete(e),await Et()),t}async function Pt(e,t){return le(e,t)}async function Ft(e){return he(e)}async function It(){return ue()}async function Lt(e){return pe(e)}async function Rt(e,t){return me(e,t)}async function zt(e,t=null){return de(e,t)}r(`zh`,{toolPanel:{agentRestrictedBanner:`当前 Agent 限制了可用工具,部分工具已禁用`,noMatch:`没有匹配的工具`,enabledCount:`已启用 {enabled}/{total} 个工具`,toolsEnabled:`工具已启用`,allToolsDisabled:`所有工具已禁用`,toggleBtnEnabled:`禁用所有工具`,toggleBtnDisabled:`启用所有工具`,mcpServiceToolCount:`{count} 个工具`,mcpServiceExpand:`展开/收起工具列表`,mcpExcludedByAgent:`已被当前助手排除,可在助手编辑中调整`,categorySelectAllHint:`对该分类下可见项全选/取消全选`,stateOn:`已开启`,stateOff:`已关闭`,stateLine:`{name}:{state}`}}),r(`en`,{toolPanel:{agentRestrictedBanner:`Current agent has restricted available tools, some tools are disabled`,noMatch:`No matching tools`,enabledCount:`{enabled}/{total} tools enabled`,toolsEnabled:`Tools enabled`,allToolsDisabled:`All tools disabled`,toggleBtnEnabled:`Disable all tools`,toggleBtnDisabled:`Enable all tools`,mcpServiceToolCount:`{count} tools`,mcpServiceExpand:`Show/hide tool list`,mcpExcludedByAgent:`Excluded by current assistant; adjust in assistant editor`,categorySelectAllHint:`Select/deselect all visible items in this category`,stateOn:`On`,stateOff:`Off`,stateLine:`{name}: {state}`}});var Bt=[],Vt=[];function Ht(e){if(!e)return``;let t=`tool.${e.id}`,n=i(t);return n===t?e.description||``:n}function Ut(e){if(!e)return``;let t=e.description||``;if(t.startsWith(`[MCP:`)){let e=t.indexOf(`]`);e!==-1&&(t=t.slice(e+1).trim())}return t===(e.name||``)?``:t}async function Wt(){try{let e=await chrome.runtime.sendMessage({type:`GET_MCP_TOOLS`});if(e?.success&&e.tools)return Bt=e.tools,Bt}catch{}try{return Bt=(await chrome.storage.local.get([`mcpTools`])).mcpTools||[],Bt}catch{return Bt=[],[]}}async function Gt(){try{Vt=(await chrome.storage.local.get([`ragTools`])).ragTools||[]}catch{Vt=[]}return Vt}async function Kt(){let e=`agentMcpClosedServers_${H.activeAgentId||`default`}`;try{let t=await chrome.storage.local.get([e]);H.mcpClosedServers=t[e]||[]}catch{H.mcpClosedServers=[]}try{let{getAgent:e}=await fe(async()=>{let{getAgent:e}=await import(`./agent-store-DOyMdB_7.js`).then(e=>e.t);return{getAgent:e}},__vite__mapDeps([0,1,2,3])),t=H.activeAgentId?await e(H.activeAgentId):null;H.activeAgentMcpExcludedServerIds=t?t.mcpExcludedServerIds??null:null}catch{}}var qt=!1,Jt=!0;chrome.storage.local.get([`enableToolPreselect`,`toolConfirmationEnabled`],e=>{qt=e.enableToolPreselect===!0,Jt=e.toolConfirmationEnabled!==!1,bn()}),chrome.storage.onChanged.addListener((e,t)=>{if(t!==`local`)return;let n=!1;e.mcpTools&&(Bt=e.mcpTools.newValue||[],o.debug(`[SidePanel] MCP toolcache updated:`,Bt.length,``),n=!0),e.ragTools&&(Vt=e.ragTools.newValue||[],o.debug(`[SidePanel] RAG toolcache updated:`,Vt.length),n=!0),e.mcpEnabled&&(Yt=e.mcpEnabled.newValue===!0,o.debug(`[SidePanel] MCP globaltoggle changed:`,Yt),n=!0),e.skillsEnabled&&(Xt=e.skillsEnabled.newValue!==!1,o.debug(`[SidePanel] Skill global toggle changed:`,Xt),n=!0);let r=!1;e.enableToolPreselect&&(qt=e.enableToolPreselect.newValue===!0,r=!0),e.toolConfirmationEnabled&&(Jt=e.toolConfirmationEnabled.newValue!==!1,r=!0),r&&bn(),n&&(document.getElementById(`toolsPopupOverlay`)?.classList.contains(`show`)&&(hn(),gn(),sn()),yn())}),Wt().then(()=>yn()),Gt().then(()=>yn());var Yt=!1,Xt=!0;chrome.storage.local.get([`mcpEnabled`,`skillsEnabled`],e=>{Yt=e.mcpEnabled===!0,Xt=e.skillsEnabled!==!1,yn()});function Zt(){let e=[...f,...Vt],t=H.activeAgentToolIds,n=e;if(t!=null){let r=new Set(t);n=e.filter(e=>r.has(e.id))}return Xt||(n=n.filter(e=>e.id!==`agent_skill`)),H.agentPlatform?.connected!==!0&&(n=n.filter(e=>!e.id.startsWith(`agent_`)&&!e.id.startsWith(`knowledge_`))),n}function Qt(){if(!Yt||H.agentPlatform?.connected!==!0)return[];let e=new Map;return Bt.forEach(t=>{let n=t.serverId||`unknown`;e.has(n)||e.set(n,{serverId:n,serverName:t.serverName||n,tools:[],toolCount:0});let r=e.get(n);r.tools.push(t),r.toolCount++}),Array.from(e.values())}function $t(e){return Array.isArray(H.mcpClosedServers)&&H.mcpClosedServers.includes(e)}function en(e){return Array.isArray(H.activeAgentMcpExcludedServerIds)&&H.activeAgentMcpExcludedServerIds.includes(e)}function tn(e){return!$t(e)&&!en(e)}function nn(){if(H.currentCategory!==`all`&&H.currentCategory!==`mcp`)return[];let e=Qt();if(H.currentSearch){let t=H.currentSearch;e=e.filter(e=>(e.serverName||``).toLowerCase().includes(t)||(e.serverId||``).toLowerCase().includes(t)||e.tools.some(e=>(e.name||``).toLowerCase().includes(t)||Ht(e).toLowerCase().includes(t)))}return e}function rn(e,t){Array.isArray(H.mcpClosedServers)||(H.mcpClosedServers=[]);let n=H.mcpClosedServers.indexOf(e);t?n>-1&&H.mcpClosedServers.splice(n,1):n===-1&&H.mcpClosedServers.push(e)}async function an(){let e=document.getElementById(`toolsPopupOverlay`);if(!e)return;H.currentCategory=`all`,H.currentSearch=``;let t=document.getElementById(`toolsSearchInput`);t&&(t.value=``),await Wt(),await Gt(),await Kt(),hn(),gn(),chrome.storage.local.get([`enableToolPreselect`,`toolConfirmationEnabled`],e=>{let t=document.getElementById(`toolsPreselectToggle`);t&&(t.checked=e.enableToolPreselect!==void 0&&e.enableToolPreselect);let n=document.getElementById(`toolConfirmToggle`);n&&(n.checked=e.toolConfirmationEnabled===void 0||e.toolConfirmationEnabled)}),document.querySelectorAll(`.category-btn`).forEach(e=>{e.classList.remove(`active`),e.classList.contains(`category-all`)?(e.classList.add(`active`),e.style.background=`linear-gradient(135deg, #667eea 0%, #764ba2 100%)`,e.style.color=`white`,e.style.borderColor=`transparent`):(e.style.background=`white`,e.style.color=`#555`,e.style.borderColor=`#ececec`)}),sn(),e.classList.add(`show`),o.debug(`[SidePanel] opentool popup`)}function on(){let e=document.getElementById(`toolsPopupOverlay`);e&&(document.querySelectorAll(`.category-btn`).forEach(e=>{e.classList.remove(`active`),e.style.background=``,e.style.color=``,e.style.borderColor=``}),e.classList.remove(`show`),o.debug(`[SidePanel] closetool popup`))}function sn(){let e=document.getElementById(`toolsPopupList`);if(!e)return;e.innerHTML=``;let t=Zt();if(H.activeAgentToolIds!==null&&H.activeAgentToolIds!==void 0){let t=document.createElement(`div`);t.className=`popup-tool-agent-banner`,t.innerHTML=`<span>${i(`toolPanel.agentRestrictedBanner`)}</span>`,e.appendChild(t)}let n={};t.forEach(e=>{if(H.currentCategory!==`all`&&e.category!==H.currentCategory)return;if(H.currentSearch){let t=e.name.toLowerCase().includes(H.currentSearch),n=Ht(e).toLowerCase().includes(H.currentSearch);if(!t&&!n)return}let t=e.category||`other`;n[t]||(n[t]=[]),n[t].push(e)});let r=nn();if(De.forEach(a=>{let o=a===`mcp`,s=n[a]||[],c=o?r:[];if(o?c.length===0:s.length===0)return;let l;if(o)l=`${c.filter(e=>tn(e.serverId)).length}/${c.length}`;else{let e=t.filter(e=>e.category===a);l=`${e.filter(e=>H.enabledTools.includes(e.id)).length}/${e.length}`}let u=document.createElement(`div`);u.className=`popup-tool-category-group`,u.dataset.category=a;let d=document.createElement(`div`);d.className=`popup-tool-category`,d.dataset.category=a;let f=H.collapsedCategories[a]||!1;d.innerHTML=`
|
|
130
136
|
<span class="category-expand-icon">${f?`▶`:`▼`}</span>
|
|
131
137
|
<span class="category-name">${i(`toolCategory.`+a)}</span>
|
|
132
138
|
<span class="category-count">${l}</span>
|
|
@@ -216,7 +222,7 @@ Ctrl/Cmd+click to copy rich-text table`,downloadExcel:`Download Excel`,exportTab
|
|
|
216
222
|
`);return{full:i+`
|
|
217
223
|
`+a+`
|
|
218
224
|
`+o,header:i+`
|
|
219
|
-
`+a,body:o}}function Ji(){document.querySelectorAll(`.copy-md-btn`).forEach((e,t)=>{e.dataset.boundMd||(e.dataset.boundMd=`true`,e.addEventListener(`click`,t=>{if(t.stopPropagation(),t.ctrlKey||t.metaKey){let t=e.closest(`.table-container-wrapper`)?.querySelector(`table`);if(t)try{let n=Yi(t).outerHTML;e.focus();let r=new Blob([n],{type:`text/html`}),a=new ClipboardItem({"text/html":r});navigator.clipboard.write([a]).then(()=>{U(i(`markdown.copiedRichTable`))}).catch(()=>{let t=document.createElement(`div`);t.style.cssText=`position:fixed;left:-999999px;top:-999999px;`,t.innerHTML=n,document.body.appendChild(t);let r=document.createRange();r.selectNodeContents(t);let a=window.getSelection();a.removeAllRanges(),a.addRange(r);try{e.focus(),document.execCommand(`copy`),U(i(`markdown.copiedRichTable`))}catch{U(i(`markdown.copyRichTableFailed`),`error`)}finally{a.removeAllRanges(),document.body.removeChild(t)}})}catch{U(i(`markdown.copyFailedShort`),`error`)}return}let n=e.dataset.tableFull?decodeURIComponent(e.dataset.tableFull):null;if(n){He(n,e),U(i(`markdown.copiedMdTable`));return}let r=e.dataset.tableIndex,a=window.__tableBlocks?.[parseInt(r)];if(a){He(a.full,e),U(i(`markdown.copiedMdTable`));return}let o=qi(e);o&&(He(o.full,e),U(i(`markdown.copiedMdTable`)))}))}),document.querySelectorAll(`.download-excel-btn`).forEach((e,t)=>{e.dataset.boundExcel||(e.dataset.boundExcel=`true`,e.addEventListener(`click`,t=>{t.stopPropagation();let n=e.dataset.tableHeader?decodeURIComponent(e.dataset.tableHeader):null,r=e.dataset.tableBody?decodeURIComponent(e.dataset.tableBody):null;if(n&&r){ki({header:n,body:r});return}let i=e.dataset.tableIndex,a=window.__tableBlocks?.[parseInt(i)];if(a){ki(a);return}let o=qi(e);o&&ki(o)}))}),document.querySelectorAll(`.export-table-img-btn`).forEach(e=>{e.dataset.boundImg||(e.dataset.boundImg=`true`,e.addEventListener(`click`,async t=>{t.stopPropagation();let n=e.closest(`.table-container-wrapper`);if(n)try{let e=await _i();if(!e){U(i(`markdown.imageExportLibMissing`),`error`);return}let t=await e(n,{scale:2,useCORS:!0,logging:!1,backgroundColor:`#ffffff`}),r=document.createElement(`a`);r.download=`table-${Date.now()}.jpg`,r.href=t.toDataURL(`image/jpeg`,.95),document.body.appendChild(r),r.click(),document.body.removeChild(r),U(i(`markdown.tableImageExported`))}catch(e){o.error(`[SidePanel] export tableimage failed:`,e),U(i(`markdown.exportImageFailed`),`error`)}}))})}function Yi(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 Xi=n({closeCurrentSession:()=>Ba,handleDuplicateSession:()=>ja,newSession:()=>ia,renderSessionTabs:()=>na});r(`zh`,{session:{newSession:`新会话`,closeSession:`关闭会话`,taskCompleted:`任务已完成`,closeAllCount:`关闭全部({count})`,noMatch:`未找到匹配的会话`,rename:`重命名`,duplicate:`复制会话`,confirmCloseMessageWithTitle:`确定要关闭会话 "{title}" 吗?`,confirmCloseAllMessage:`确定要关闭所有 {count} 个会话吗?`,confirmCloseAllTitle:`关闭全部会话`,forkedFrom:`已从 "{title}" 分叉`,forkedSession:`已复制会话 "{title}"`,operationFailed:`操作失败:{message}`,sessionListTitle:`会话列表`,closeGroupAll:`全部关闭`,confirmCloseGroupMessage:`确定要关闭“{group}”下的 {count} 个会话吗?`,today:`今天`,yesterday:`昨天`,last7Days:`近 7 天`,earlier:`更早`,todayFormat:`今天 {hour}:{minute}`,yesterdayFormat:`昨天 {hour}:{minute}`,daysAgo:`{count} 天前`}}),r(`en`,{session:{newSession:`New Session`,closeSession:`Close Session`,taskCompleted:`Task completed`,closeAllCount:`Close All ({count})`,noMatch:`No matching sessions found`,rename:`Rename`,duplicate:`Duplicate`,confirmCloseMessageWithTitle:`Are you sure you want to close session "{title}"?`,confirmCloseAllMessage:`Are you sure you want to close all {count} sessions?`,confirmCloseAllTitle:`Close All Sessions`,forkedFrom:`Forked from "{title}"`,forkedSession:`Duplicated session "{title}"`,operationFailed:`Operation failed: {message}`,sessionListTitle:`Sessions`,closeGroupAll:`Close all`,confirmCloseGroupMessage:`Are you sure you want to close {count} sessions in "{group}"?`,today:`Today`,yesterday:`Yesterday`,last7Days:`Last 7 days`,earlier:`Earlier`,todayFormat:`Today {hour}:{minute}`,yesterdayFormat:`Yesterday {hour}:{minute}`,daysAgo:`{count}d ago`}});var Zi={visible:!1,highlightIndex:-1,filteredSessions:[]},Qi={draggedId:null,sourceType:null};function $i(e){if(!e)return``;let t=new Date(e),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),a=t.getTime();if(a>=r)return i(`session.todayFormat`,{hour:String(t.getHours()).padStart(2,`0`),minute:String(t.getMinutes()).padStart(2,`0`)});if(a>=r-864e5)return i(`session.yesterdayFormat`,{hour:String(t.getHours()).padStart(2,`0`),minute:String(t.getMinutes()).padStart(2,`0`)});let o=Math.floor((r-a)/864e5);return o<=7?i(`session.daysAgo`,{count:o}):t.getFullYear()===n.getFullYear()?`${t.getMonth()+1}/${t.getDate()}`:`${t.getFullYear()}/${t.getMonth()+1}/${t.getDate()}`}function ea(e){return e.sort((e,t)=>{let n=e.updatedAt?new Date(e.updatedAt).getTime():0;return(t.updatedAt?new Date(t.updatedAt).getTime():0)-n})}function ta(e){if(!e)return`earlier`;let t=new Date(e),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),i=t.getTime();return i>=r?`today`:i>=r-864e5?`yesterday`:Math.floor((r-i)/864e5)<=7?`last7Days`:`earlier`}async function na(e=null){let t=e||await kt();H.sessions=t.list,H.activeSessionId=t.activeSessionId;let n=document.getElementById(`sessionTabs`),r=document.getElementById(`sessionTabsScroll`),a=document.getElementById(`sessionTabsActions`);!n||!r||!a||(r.style.opacity=``,r.innerHTML=``,t.list.forEach(e=>{let t=document.createElement(`div`);t.className=`session-tab`,t.dataset.sessionId=e.id,e.id===H.activeSessionId&&t.classList.add(`active`),t.title=e.title;let n=document.createElement(`span`);n.className=`session-tab-title`,n.textContent=e.title||i(`session.newSession`),t.appendChild(n);let a=document.createElement(`span`);if(a.className=`session-tab-close`,a.innerHTML=`✕`,a.title=i(`session.closeSession`),a.addEventListener(`click`,async t=>{if(t.stopPropagation(),(e.id===H.activeSessionId?H.messageHistory?.length||0:e.messageHistory?.length||0)===0){await Nt(e.id),await za();return}Ia(e,async()=>{await za()})}),t.appendChild(a),e.isGenerating||H.generatingSessionIds.has(e.id)){let e=document.createElement(`span`);e.className=`session-tab-indicator`,t.appendChild(e)}else if(H.completedSessionIds.has(e.id)&&e.id!==H.activeSessionId){let e=document.createElement(`span`);e.className=`session-tab-completed-indicator`,e.title=i(`session.taskCompleted`),t.appendChild(e)}t.addEventListener(`click`,async n=>{if(n.preventDefault(),e.id!==H.activeSessionId&&!ka){ka=!0,r.querySelectorAll(`.session-tab.active`).forEach(e=>e.classList.remove(`active`)),t.classList.add(`active`);try{await Aa(e.id)}finally{ka=!1,H.activeSessionId!==e.id&&na({list:H.sessions,activeSessionId:H.activeSessionId})}}}),t.addEventListener(`contextmenu`,t=>{t.preventDefault(),La(t,e)}),t.addEventListener(`mousedown`,async t=>{t.button===1&&(t.preventDefault(),t.stopPropagation(),await Nt(e.id),await za())}),t.draggable=!0,t.addEventListener(`dragstart`,t=>ua(t,e.id)),t.addEventListener(`dragover`,e=>da(e)),t.addEventListener(`dragleave`,e=>fa(e)),t.addEventListener(`drop`,t=>pa(t,e.id)),t.addEventListener(`dragend`,e=>ma(e)),r.appendChild(t)}),ra(),aa(),Ta(),Pa(r),oa(r),la(r))}function ra(){let e=document.getElementById(`sessionTabsMore`);if(!e)return;let t=e.cloneNode(!0);e.parentNode.replaceChild(t,e),t.addEventListener(`click`,e=>{e.stopPropagation(),ha()})}async function ia(){let e=H.activeSessionId;await At();let t=await jt();H.activeSessionId=t.id,H.messageHistory=[],H.activeCompaction=null,document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:t.id,previousSessionId:e}})),na()}function aa(){let e=document.getElementById(`sessionTabsAdd`);if(!e)return;let t=e.cloneNode(!0);e.parentNode.replaceChild(t,e),t.addEventListener(`click`,()=>ia())}function oa(e){let t=document.getElementById(`sessionTabsMore`);t&&(e.scrollWidth>e.clientWidth?t.style.display=`flex`:t.style.display=`none`)}var sa=null;function ca(){if(sa)return;let e=document.getElementById(`sessionTabsScroll`);e&&(sa=new ResizeObserver(()=>{requestAnimationFrame(()=>{oa(e)})}),sa.observe(e))}function la(e){let t=e.querySelector(`.session-tab.active`);if(t){let n=t.offsetLeft,r=t.offsetWidth;e.scrollLeft=n-(e.clientWidth-r)/2}e.style.opacity=`1`}function ua(e,t){Qi.draggedId=t,Qi.sourceType=`tab`,e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t),e.currentTarget.classList.add(`dragging`)}function da(e){e.preventDefault(),e.dataTransfer.dropEffect=`move`,e.currentTarget.classList.add(`drag-over`)}function fa(e){e.currentTarget.classList.remove(`drag-over`)}async function pa(e,t){e.preventDefault(),e.currentTarget.classList.remove(`drag-over`);let n=Qi.draggedId;if(!n||n===t)return;let r=H.sessions||[],i=r.findIndex(e=>e.id===n),a=r.findIndex(e=>e.id===t);if(i===-1||a===-1)return;let o=[...r],[s]=o.splice(i,1);o.splice(a,0,s),H.sessions=o,await Ft(o.map(e=>e.id)),na()}function ma(e){e.currentTarget.classList.remove(`dragging`),document.querySelectorAll(`.session-tab.drag-over`).forEach(e=>e.classList.remove(`drag-over`)),Qi.draggedId=null,Qi.sourceType=null}function ha(){Zi.visible?_a():ga()}async function ga(){let e=document.getElementById(`sessionTabsMore`),t=document.getElementById(`sessionDropdown`);if(!e||!t)return;let n=await kt();H.sessions=n.list,H.activeSessionId=n.activeSessionId,Zi.filteredSessions=ea([...n.list]),Zi.highlightIndex=-1,Zi.visible=!0,ya(),t.classList.add(`show`);let r=document.getElementById(`sessionDropdownCloseBtn`);r&&(r.onclick=()=>_a());let i=document.getElementById(`sessionDropdownSearch`),a=document.getElementById(`sessionDropdownSearchClear`);i&&(i.value=Zi.lastSearchText||``,va(),Zi.lastSearchText&&ba(Zi.lastSearchText),setTimeout(()=>i.focus(),50),i.oninput=()=>{Zi.lastSearchText=i.value,va(),ba(i.value)},i.onkeydown=e=>{Ea(e)}),a&&(a.onclick=()=>{i&&(i.value=``,Zi.lastSearchText=``,va(),ba(``),i.focus())}),e.classList.add(`active`)}function _a(){let e=document.getElementById(`sessionTabsMore`),t=document.getElementById(`sessionDropdown`);t&&t.classList.remove(`show`),e&&e.classList.remove(`active`);let n=document.getElementById(`sessionDropdownSearch`);n&&(Zi.lastSearchText=n.value,n.oninput=null,n.onkeydown=null);let r=document.getElementById(`sessionDropdownSearchClear`);r&&(r.onclick=null),Zi.visible=!1,Zi.highlightIndex=-1,Zi.filteredSessions=[]}function va(){let e=document.getElementById(`sessionDropdownSearch`),t=document.getElementById(`sessionDropdownSearchClear`);t&&e&&(t.style.display=e.value?`flex`:`none`)}function ya(){let e=document.getElementById(`sessionDropdownList`);if(!e)return;e.innerHTML=``;let t=document.getElementById(`sessionDropdownCloseAll`);if(t){let e=(H.sessions||[]).length;t.textContent=i(`session.closeAllCount`,{count:e})}if(Zi.filteredSessions.length===0){let t=document.createElement(`div`);t.className=`session-dropdown-empty`,t.textContent=i(`session.noMatch`),e.appendChild(t);return}let n={today:i(`session.today`),yesterday:i(`session.yesterday`),last7Days:i(`session.last7Days`),earlier:i(`session.earlier`)},r={};Zi.filteredSessions.forEach(e=>{let t=ta(e.updatedAt);r[t]=(r[t]||0)+1});let a=null;Zi.filteredSessions.forEach((t,o)=>{let s=ta(t.updatedAt);if(s!==a){a=s;let t=document.createElement(`div`);t.className=`session-dropdown-group-header`;let o=document.createElement(`span`);if(o.textContent=n[s]||s,t.appendChild(o),(r[s]||0)>0){let e=document.createElement(`button`);e.className=`session-dropdown-group-close`,e.textContent=i(`session.closeGroupAll`),e.onclick=e=>{e.stopPropagation(),wa(s,n[s]||s)},t.appendChild(e)}e.appendChild(t)}let c=document.createElement(`div`);if(c.className=`session-dropdown-item`,c.dataset.sessionId=t.id,c.dataset.index=o,t.id===H.activeSessionId&&c.classList.add(`active`),o===Zi.highlightIndex&&c.classList.add(`highlighted`),H.completedSessionIds.has(t.id)&&t.id!==H.activeSessionId&&!t.isGenerating&&!H.generatingSessionIds.has(t.id)){let e=document.createElement(`span`);e.className=`session-dropdown-item-completed`,e.title=i(`session.taskCompleted`),c.appendChild(e)}let l=document.createElement(`span`);l.className=`session-dropdown-item-icon`,l.innerHTML=`<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>`,c.appendChild(l);let u=document.createElement(`span`);if(u.className=`session-dropdown-item-title`,u.textContent=t.title||i(`session.newSession`),u.title=t.title||i(`session.newSession`),c.appendChild(u),t.id===H.activeSessionId){let e=document.createElement(`span`);e.className=`session-dropdown-item-check`,e.innerHTML=`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>`,c.appendChild(e)}let d=document.createElement(`span`);d.className=`session-dropdown-item-time`,d.textContent=$i(t.updatedAt),c.appendChild(d);let f=document.createElement(`span`);f.className=`session-dropdown-item-actions`;let p=document.createElement(`span`);p.className=`session-dropdown-item-rename`,p.title=i(`session.rename`),p.innerHTML=`<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,p.addEventListener(`click`,e=>{e.stopPropagation(),e.preventDefault(),Fa(t)}),f.appendChild(p);let m=document.createElement(`span`);m.className=`session-dropdown-item-duplicate`,m.title=i(`session.duplicate`),m.innerHTML=`<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="6" r="2.5"/><circle cx="6" cy="18" r="2.5"/><circle cx="18" cy="6" r="2.5"/><path d="M6 8.5v7"/><path d="M18 8.5c0 4-6 3.5-6 3.5"/></svg>`,m.addEventListener(`click`,async e=>{e.stopPropagation(),e.preventDefault(),await ja(t.id);let n=await kt();H.sessions=n.list,H.activeSessionId=n.activeSessionId,ba(document.getElementById(`sessionDropdownSearch`)?.value||``)}),f.appendChild(m);let h=document.createElement(`span`);h.className=`session-dropdown-item-close`,h.innerHTML=`✕`,h.title=i(`session.closeSession`),h.addEventListener(`click`,async e=>{e.stopPropagation(),e.preventDefault(),await Sa(t.id)}),f.appendChild(h),c.appendChild(f),c.addEventListener(`click`,async e=>{e.preventDefault(),await xa(t.id)}),e.appendChild(c)})}function ba(e){let t=H.sessions||[],n;if(!e.trim())n=[...t];else{let r=e.trim().toLowerCase();n=t.filter(e=>(e.title||i(`session.newSession`)).toLowerCase().includes(r))}Zi.filteredSessions=ea(n),Zi.highlightIndex=-1,ya()}async function xa(e){_a(),e!==H.activeSessionId&&await Aa(e)}async function Sa(e){let t=(H.sessions||[]).find(t=>t.id===e);t&&((e===H.activeSessionId?H.messageHistory?.length||0:t.messageHistory?.length||0)>0&&!await Oa(i(`session.confirmCloseMessageWithTitle`,{title:t.title}),i(`session.closeSession`))||(await Nt(e),await za(),ba(document.getElementById(`sessionDropdownSearch`)?.value||``)))}async function Ca(){let e=H.sessions||[];if(e.length!==0&&await Oa(i(`session.confirmCloseAllMessage`,{count:e.length}),i(`session.confirmCloseAllTitle`))){for(let t of e)await Nt(t.id);await za(),ba(document.getElementById(`sessionDropdownSearch`)?.value||``)}}async function wa(e,t){let n=(H.sessions||[]).filter(t=>ta(t.updatedAt)===e);if(n.length!==0&&await Oa(i(`session.confirmCloseGroupMessage`,{group:t,count:n.length}),i(`session.closeSession`))){for(let e of n)await Nt(e.id);await za(),ba(document.getElementById(`sessionDropdownSearch`)?.value||``)}}function Ta(){let e=document.getElementById(`sessionDropdownCloseAll`),t=document.getElementById(`sessionDropdown`);if(t){if(e){let t=e.cloneNode(!0);e.parentNode.replaceChild(t,e),t.addEventListener(`click`,async e=>{e.stopPropagation(),await Ca()})}t.addEventListener(`click`,e=>{e.stopPropagation()})}}function Ea(e){if(!Zi.visible)return;let t=Zi.filteredSessions.length;if(t===0){e.key===`Escape`&&_a();return}switch(e.key){case`ArrowDown`:e.preventDefault(),Zi.highlightIndex=Math.min(Zi.highlightIndex+1,t-1),ya(),Da();break;case`ArrowUp`:e.preventDefault(),Zi.highlightIndex=Math.max(Zi.highlightIndex-1,0),ya(),Da();break;case`Enter`:if(e.preventDefault(),Zi.highlightIndex>=0&&Zi.highlightIndex<t){let e=Zi.filteredSessions[Zi.highlightIndex];xa(e.id)}break;case`Escape`:e.preventDefault(),_a()}}function Da(){let e=document.querySelector(`.session-dropdown-item.highlighted`);e&&e.scrollIntoView({block:`nearest`})}function Oa(e,t){return new Promise(t=>{let n=document.getElementById(`sessionDeleteModal`),r=document.getElementById(`sessionDeleteMessage`),i=document.getElementById(`sessionDeleteConfirmBtn`),a=document.getElementById(`sessionDeleteCancelBtn`),o=document.getElementById(`sessionDeleteCloseBtn`);if(!n||!r){t(!1);return}r.textContent=e;let s=()=>{n.classList.remove(`show`),i.removeEventListener(`click`,c),a.removeEventListener(`click`,l),o.removeEventListener(`click`,l)},c=()=>{s(),t(!0)},l=()=>{s(),t(!1)};i.addEventListener(`click`,c),a.addEventListener(`click`,l),o.addEventListener(`click`,l),n.classList.add(`show`)})}var ka=!1;async function Aa(e){let t=H.activeSessionId;if(!await Mt(e))return;let n=`agentEnabledTools_${H.activeAgentId||`default`}`,r=`agentMcpClosedServers_${H.activeAgentId||`default`}`,[i,a,o,s]=await Promise.all([kt(),chrome.storage.local.get([r,`ragTools`,`ragToolsIntroduced`]),chrome.storage.local.get([n,`enabledTools`]),H.activeAgentId?be(H.activeAgentId):Promise.resolve(null)]);H.sessions=i.list,H.activeSessionId=e;let c=a.ragTools||[];H.mcpClosedServers=a[r]||[];let l=!!o[n],u=o[n]||o.enabledTools;if(l||u&&u.length>0){let e=new Set([...f.map(e=>e.id),...c.map(e=>e.id)]),t=u.filter(t=>e.has(t));if(l)H.enabledTools=t;else{let e=f.filter(e=>e.enabled&&!t.includes(e.id)).map(e=>e.id);H.enabledTools=[...t,...e]}let r=xn(H.enabledTools,c,a.ragToolsIntroduced);H.enabledTools=r.tools,H.enabledTools.length!==u.length&&chrome.storage.local.set({[n]:H.enabledTools,...r.migrated?{ragToolsIntroduced:!0}:{}})}else{H.enabledTools=f.filter(e=>e.enabled).map(e=>e.id);let e=xn(H.enabledTools,c,a.ragToolsIntroduced);H.enabledTools=e.tools,e.migrated&&chrome.storage.local.set({ragToolsIntroduced:!0,[n]:H.enabledTools})}H.activeAgentToolIds=s?s.toolIds:null,H.activeAgentMcpExcludedServerIds=s?s.mcpExcludedServerIds??null:null,document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:e,previousSessionId:t}})),Ot(e),na(i),Ma(),Ek();try{let{refreshBookmarkPanel:e,updateBookmarkButtons:t}=await fe(async()=>{let{refreshBookmarkPanel:e,updateBookmarkButtons:t}=await Promise.resolve().then(()=>ll);return{refreshBookmarkPanel:e,updateBookmarkButtons:t}},void 0);e(),setTimeout(()=>t(),100)}catch{}let d=document.getElementById(`toolsPopupOverlay`);d&&d.classList.contains(`show`)&&(sn(),hn(),gn()),yn()}async function ja(e,t=null){if(e)try{let n=await zt(e,t);await Aa(n.id),U(i(t?`session.forkedFrom`:`session.forkedSession`,{title:n.title}),`success`)}catch(e){o.error(`[SessionUI] copy/forksession failed:`,e),U(i(`session.operationFailed`,{message:e.message}),`error`)}}function Ma(){let e=document.querySelector(`.model-display`);e&&H.currentModel&&(e.textContent=H.currentModel);let t=document.getElementById(`enableToolsBtn`);t&&(t.checked=H.useTools);let n=document.getElementById(`tempIconValue`);n&&H.temperature!==void 0&&(n.textContent=H.temperature.toFixed(2))}var Na=new WeakSet;function Pa(e){Na.has(e)||(Na.add(e),e.addEventListener(`wheel`,t=>{e.scrollWidth<=e.clientWidth||(t.preventDefault(),e.scrollLeft+=t.deltaY)},{passive:!1}))}function Fa(e){let t=document.getElementById(`sessionRenameModal`),n=document.getElementById(`sessionRenameInput`),r=document.getElementById(`sessionRenameConfirmBtn`),i=document.getElementById(`sessionRenameCancelBtn`),a=document.getElementById(`sessionRenameCloseBtn`);if(!t||!n)return;n.value=e.title;let o=()=>{t.classList.remove(`show`),r.removeEventListener(`click`,s),i.removeEventListener(`click`,c),a.removeEventListener(`click`,c)},s=async()=>{let t=n.value.trim();if(t&&t!==e.title){await Pt(e.id,t),na();let n=await kt();H.sessions=n.list,H.activeSessionId=n.activeSessionId,ba(document.getElementById(`sessionDropdownSearch`)?.value||``)}o()},c=()=>{o()};r.addEventListener(`click`,s),i.addEventListener(`click`,c),a.addEventListener(`click`,c),n.onkeydown=e=>{e.key===`Enter`?s():e.key===`Escape`&&c()},t.classList.add(`show`),setTimeout(()=>{n.focus(),n.select()},50)}function Ia(e,t){let n=document.getElementById(`sessionDeleteModal`),r=document.getElementById(`sessionDeleteMessage`),a=document.getElementById(`sessionDeleteConfirmBtn`),o=document.getElementById(`sessionDeleteCancelBtn`),s=document.getElementById(`sessionDeleteCloseBtn`);if(!n||!r)return;r.textContent=i(`session.confirmCloseMessageWithTitle`,{title:e.title});let c=()=>{n.classList.remove(`show`),a.removeEventListener(`click`,l),o.removeEventListener(`click`,u),s.removeEventListener(`click`,u)},l=async()=>{await Nt(e.id),t&&await t(),c()},u=()=>{c()};a.addEventListener(`click`,l),o.addEventListener(`click`,u),s.addEventListener(`click`,u),n.classList.add(`show`),requestAnimationFrame(()=>a.focus())}function La(e,t){let n=document.querySelector(`.session-context-menu`);n&&n.remove();let r=document.createElement(`div`);r.className=`session-context-menu`,r.style.left=e.clientX+`px`,r.style.top=e.clientY+`px`;let a=Ra(i(`session.rename`),`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,()=>{r.remove(),Fa(t)});r.appendChild(a);let o=Ra(i(`session.duplicate`),`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="6" r="2.5"/><circle cx="6" cy="18" r="2.5"/><circle cx="18" cy="6" r="2.5"/><path d="M6 8.5v7"/><path d="M18 8.5c0 4-6 3.5-6 3.5"/></svg>`,()=>{r.remove(),ja(t.id)});r.appendChild(o);let s=Ra(i(`session.closeSession`),`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>`,async()=>{if(r.remove(),(t.id===H.activeSessionId?H.messageHistory?.length||0:t.messageHistory?.length||0)===0){await Nt(t.id),await za();return}Ia(t,async()=>{await za()})},`danger`);r.appendChild(s),document.body.appendChild(r);let c=e=>{r.contains(e.target)||(r.remove(),document.removeEventListener(`click`,c))};setTimeout(()=>document.addEventListener(`click`,c),0)}function Ra(e,t=``,n,r=``){let i=document.createElement(`div`);return i.className=`session-context-menu-item `+r,t?i.innerHTML=`${t}<span>${e}</span>`:i.textContent=e,i.addEventListener(`click`,n),i}async function za(){let e=H.activeSessionId,t=await kt();t.activeSessionId||(await jt(),t=await kt()),H.activeSessionId=t.activeSessionId,H.sessions=t.list;let n=t.list.find(e=>e.id===t.activeSessionId);if(H.messageHistory=n&&n.messageHistory||[],H.activeCompaction=n?.contextCompaction||null,H.activeAgentId=n&&n.agentId||null,H.activeAgentId){let e=await be(H.activeAgentId);H.activeAgentToolIds=e?e.toolIds:null,H.activeAgentMcpExcludedServerIds=e?e.mcpExcludedServerIds??null:null}else H.activeAgentToolIds=null,H.activeAgentMcpExcludedServerIds=null;document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:H.activeSessionId,previousSessionId:e}})),na(),await Ek()}async function Ba(){let e=H.activeSessionId;if(!e)return;let t=H.sessions?.find(t=>t.id===e);if(t){if((H.messageHistory?.length||0)===0){await Nt(e),await za();return}Ia(t,async()=>{await za()})}}document.addEventListener(`generating-state-changed`,()=>{na()}),document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,ca):ca(),[`<svg viewBox="0 0 16 16" fill="currentColor">`,`<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25zM5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25z"/>`,`</svg>`].join(``),[`<svg viewBox="0 0 16 16" fill="currentColor">`,`<path d="M12.146.146a.5.5 0 0 1 .708 0l2.5 2.5a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168l10-10zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207 11.207 2.5zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293l6.5-6.5zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12h.5a.5.5 0 0 1 .5.5v.5a.5.5 0 0 1-.5.5h-.5a.5.5 0 0 1-.468-.325z"/>`,`</svg>`].join(``),[`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<circle cx="12" cy="12" r="10"></circle>`,`<polyline points="12 6 12 12 16 14"></polyline>`,`</svg>`].join(``),[`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<line x1="18" y1="6" x2="6" y2="18"></line>`,`<line x1="6" y1="6" x2="18" y2="18"></line>`,`</svg>`].join(``),[`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<polyline points="7 13 12 18 17 13"></polyline>`,`<polyline points="7 6 12 11 17 6"></polyline>`,`</svg>`].join(``);var Va=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>`,Ha=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>`,Ua=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>`,Wa=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,Ga=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>`,Ka=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>`;[`<svg class="tool-call-icon exec" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<polyline points="4 17 10 11 4 5"/><line x1="12" y1="19" x2="20" y2="19"/>`,`</svg>`].join(``),[`<svg class="tool-call-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>`,`<polyline points="14 2 14 8 20 8"/>`,`</svg>`].join(``),[`<svg class="tool-call-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>`,`</svg>`].join(``),[`<svg class="tool-call-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/>`,`</svg>`].join(``),r(`zh`,{uiProto:{defaultTitle:`原型`,optimizePrompt:`请帮我优化这个UI原型界面 {id}({title}),`,loadFailed:`加载失败`,noDescription:`暂无描述`,previewInPanel:`面板内预览`,continueOptimizeTitle:`继续优化`,downloadPrototype:`下载原型`,confirmDeleteTitle:`确认删除`,confirmDeleteMessage:`确定删除原型 "{title}" 吗?此操作不可撤销。`,deleteFailed:`删除失败: {message}`,justNow:`刚刚`,minutesAgo:`{count} 分钟前`,hoursAgo:`{count} 小时前`}}),r(`en`,{uiProto:{defaultTitle:`Prototype`,optimizePrompt:`Please help me optimize this UI prototype {id} ({title}), `,loadFailed:`Load failed`,noDescription:`No description`,previewInPanel:`Preview in panel`,continueOptimizeTitle:`Continue optimizing`,downloadPrototype:`Download prototype`,confirmDeleteTitle:`Confirm delete`,confirmDeleteMessage:`Are you sure you want to delete prototype "{title}"? This action cannot be undone.`,deleteFailed:`Delete failed: {message}`,justNow:`Just now`,minutesAgo:`{count} minutes ago`,hoursAgo:`{count} hours ago`}});var qa=null,Ja=1,Ya=.25,Xa=2,Za=.1;function Qa(e){let t=e.trim();return/^\s*<!DOCTYPE\s/i.test(t)||/^\s*<html[\s>]/i.test(t)?/<\/head>/i.test(t)?t.replace(/<\/head>/i,`<style>html,body{overflow:auto!important;height:auto!important;}</style></head>`):/<body[\s>]/i.test(t)?t.replace(/<body([\s>])/i,`<body$1<style>html,body{overflow:auto!important;height:auto!important;}</style>`):t:`<!DOCTYPE html>
|
|
225
|
+
`+a,body:o}}function Ji(){document.querySelectorAll(`.copy-md-btn`).forEach((e,t)=>{e.dataset.boundMd||(e.dataset.boundMd=`true`,e.addEventListener(`click`,t=>{if(t.stopPropagation(),t.ctrlKey||t.metaKey){let t=e.closest(`.table-container-wrapper`)?.querySelector(`table`);if(t)try{let n=Yi(t).outerHTML;e.focus();let r=new Blob([n],{type:`text/html`}),a=new ClipboardItem({"text/html":r});navigator.clipboard.write([a]).then(()=>{U(i(`markdown.copiedRichTable`))}).catch(()=>{let t=document.createElement(`div`);t.style.cssText=`position:fixed;left:-999999px;top:-999999px;`,t.innerHTML=n,document.body.appendChild(t);let r=document.createRange();r.selectNodeContents(t);let a=window.getSelection();a.removeAllRanges(),a.addRange(r);try{e.focus(),document.execCommand(`copy`),U(i(`markdown.copiedRichTable`))}catch{U(i(`markdown.copyRichTableFailed`),`error`)}finally{a.removeAllRanges(),document.body.removeChild(t)}})}catch{U(i(`markdown.copyFailedShort`),`error`)}return}let n=e.dataset.tableFull?decodeURIComponent(e.dataset.tableFull):null;if(n){He(n,e),U(i(`markdown.copiedMdTable`));return}let r=e.dataset.tableIndex,a=window.__tableBlocks?.[parseInt(r)];if(a){He(a.full,e),U(i(`markdown.copiedMdTable`));return}let o=qi(e);o&&(He(o.full,e),U(i(`markdown.copiedMdTable`)))}))}),document.querySelectorAll(`.download-excel-btn`).forEach((e,t)=>{e.dataset.boundExcel||(e.dataset.boundExcel=`true`,e.addEventListener(`click`,t=>{t.stopPropagation();let n=e.dataset.tableHeader?decodeURIComponent(e.dataset.tableHeader):null,r=e.dataset.tableBody?decodeURIComponent(e.dataset.tableBody):null;if(n&&r){ki({header:n,body:r});return}let i=e.dataset.tableIndex,a=window.__tableBlocks?.[parseInt(i)];if(a){ki(a);return}let o=qi(e);o&&ki(o)}))}),document.querySelectorAll(`.export-table-img-btn`).forEach(e=>{e.dataset.boundImg||(e.dataset.boundImg=`true`,e.addEventListener(`click`,async t=>{t.stopPropagation();let n=e.closest(`.table-container-wrapper`);if(n)try{let e=await _i();if(!e){U(i(`markdown.imageExportLibMissing`),`error`);return}let t=await e(n,{scale:2,useCORS:!0,logging:!1,backgroundColor:`#ffffff`}),r=document.createElement(`a`);r.download=`table-${Date.now()}.jpg`,r.href=t.toDataURL(`image/jpeg`,.95),document.body.appendChild(r),r.click(),document.body.removeChild(r),U(i(`markdown.tableImageExported`))}catch(e){o.error(`[SidePanel] export tableimage failed:`,e),U(i(`markdown.exportImageFailed`),`error`)}}))})}function Yi(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 Xi=n({closeCurrentSession:()=>Ba,handleDuplicateSession:()=>ja,newSession:()=>ia,renderSessionTabs:()=>na});r(`zh`,{session:{newSession:`新会话`,closeSession:`关闭会话`,taskCompleted:`任务已完成`,closeAllCount:`关闭全部({count})`,noMatch:`未找到匹配的会话`,rename:`重命名`,duplicate:`复制会话`,confirmCloseMessageWithTitle:`确定要关闭会话 "{title}" 吗?`,confirmCloseAllMessage:`确定要关闭所有 {count} 个会话吗?`,confirmCloseAllTitle:`关闭全部会话`,forkedFrom:`已从 "{title}" 分叉`,forkedSession:`已复制会话 "{title}"`,operationFailed:`操作失败:{message}`,sessionListTitle:`会话列表`,closeGroupAll:`全部关闭`,confirmCloseGroupMessage:`确定要关闭“{group}”下的 {count} 个会话吗?`,today:`今天`,yesterday:`昨天`,last7Days:`近 7 天`,earlier:`更早`,todayFormat:`今天 {hour}:{minute}`,yesterdayFormat:`昨天 {hour}:{minute}`,daysAgo:`{count} 天前`}}),r(`en`,{session:{newSession:`New Session`,closeSession:`Close Session`,taskCompleted:`Task completed`,closeAllCount:`Close All ({count})`,noMatch:`No matching sessions found`,rename:`Rename`,duplicate:`Duplicate`,confirmCloseMessageWithTitle:`Are you sure you want to close session "{title}"?`,confirmCloseAllMessage:`Are you sure you want to close all {count} sessions?`,confirmCloseAllTitle:`Close All Sessions`,forkedFrom:`Forked from "{title}"`,forkedSession:`Duplicated session "{title}"`,operationFailed:`Operation failed: {message}`,sessionListTitle:`Sessions`,closeGroupAll:`Close all`,confirmCloseGroupMessage:`Are you sure you want to close {count} sessions in "{group}"?`,today:`Today`,yesterday:`Yesterday`,last7Days:`Last 7 days`,earlier:`Earlier`,todayFormat:`Today {hour}:{minute}`,yesterdayFormat:`Yesterday {hour}:{minute}`,daysAgo:`{count}d ago`}});var Zi={visible:!1,highlightIndex:-1,filteredSessions:[]},Qi={draggedId:null,sourceType:null};function $i(e){if(!e)return``;let t=new Date(e),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),a=t.getTime();if(a>=r)return i(`session.todayFormat`,{hour:String(t.getHours()).padStart(2,`0`),minute:String(t.getMinutes()).padStart(2,`0`)});if(a>=r-864e5)return i(`session.yesterdayFormat`,{hour:String(t.getHours()).padStart(2,`0`),minute:String(t.getMinutes()).padStart(2,`0`)});let o=Math.floor((r-a)/864e5);return o<=7?i(`session.daysAgo`,{count:o}):t.getFullYear()===n.getFullYear()?`${t.getMonth()+1}/${t.getDate()}`:`${t.getFullYear()}/${t.getMonth()+1}/${t.getDate()}`}function ea(e){return e.sort((e,t)=>{let n=e.updatedAt?new Date(e.updatedAt).getTime():0;return(t.updatedAt?new Date(t.updatedAt).getTime():0)-n})}function ta(e){if(!e)return`earlier`;let t=new Date(e),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),i=t.getTime();return i>=r?`today`:i>=r-864e5?`yesterday`:Math.floor((r-i)/864e5)<=7?`last7Days`:`earlier`}async function na(e=null){let t=e||await kt();H.sessions=t.list,H.activeSessionId=t.activeSessionId;let n=document.getElementById(`sessionTabs`),r=document.getElementById(`sessionTabsScroll`),a=document.getElementById(`sessionTabsActions`);!n||!r||!a||(r.style.opacity=``,r.innerHTML=``,t.list.forEach(e=>{let t=document.createElement(`div`);t.className=`session-tab`,t.dataset.sessionId=e.id,e.id===H.activeSessionId&&t.classList.add(`active`),t.title=e.title;let n=document.createElement(`span`);n.className=`session-tab-title`,n.textContent=e.title||i(`session.newSession`),t.appendChild(n);let a=document.createElement(`span`);if(a.className=`session-tab-close`,a.innerHTML=`✕`,a.title=i(`session.closeSession`),a.addEventListener(`click`,async t=>{if(t.stopPropagation(),(e.id===H.activeSessionId?H.messageHistory?.length||0:e.messageHistory?.length||0)===0){await Nt(e.id),await za();return}Ia(e,async()=>{await za()})}),t.appendChild(a),e.isGenerating||H.generatingSessionIds.has(e.id)){let e=document.createElement(`span`);e.className=`session-tab-indicator`,t.appendChild(e)}else if(H.completedSessionIds.has(e.id)&&e.id!==H.activeSessionId){let e=document.createElement(`span`);e.className=`session-tab-completed-indicator`,e.title=i(`session.taskCompleted`),t.appendChild(e)}t.addEventListener(`click`,async n=>{if(n.preventDefault(),e.id!==H.activeSessionId&&!ka){ka=!0,r.querySelectorAll(`.session-tab.active`).forEach(e=>e.classList.remove(`active`)),t.classList.add(`active`);try{await Aa(e.id)}finally{ka=!1,H.activeSessionId!==e.id&&na({list:H.sessions,activeSessionId:H.activeSessionId})}}}),t.addEventListener(`contextmenu`,t=>{t.preventDefault(),La(t,e)}),t.addEventListener(`mousedown`,async t=>{t.button===1&&(t.preventDefault(),t.stopPropagation(),await Nt(e.id),await za())}),t.draggable=!0,t.addEventListener(`dragstart`,t=>ua(t,e.id)),t.addEventListener(`dragover`,e=>da(e)),t.addEventListener(`dragleave`,e=>fa(e)),t.addEventListener(`drop`,t=>pa(t,e.id)),t.addEventListener(`dragend`,e=>ma(e)),r.appendChild(t)}),ra(),aa(),Ta(),Pa(r),oa(r),la(r))}function ra(){let e=document.getElementById(`sessionTabsMore`);if(!e)return;let t=e.cloneNode(!0);e.parentNode.replaceChild(t,e),t.addEventListener(`click`,e=>{e.stopPropagation(),ha()})}async function ia(){let e=H.activeSessionId;await At();let t=await jt();H.activeSessionId=t.id,H.messageHistory=[],H.activeCompaction=null,document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:t.id,previousSessionId:e}})),na()}function aa(){let e=document.getElementById(`sessionTabsAdd`);if(!e)return;let t=e.cloneNode(!0);e.parentNode.replaceChild(t,e),t.addEventListener(`click`,()=>ia())}function oa(e){let t=document.getElementById(`sessionTabsMore`);t&&(e.scrollWidth>e.clientWidth?t.style.display=`flex`:t.style.display=`none`)}var sa=null;function ca(){if(sa)return;let e=document.getElementById(`sessionTabsScroll`);e&&(sa=new ResizeObserver(()=>{requestAnimationFrame(()=>{oa(e)})}),sa.observe(e))}function la(e){let t=e.querySelector(`.session-tab.active`);if(t){let n=t.offsetLeft,r=t.offsetWidth;e.scrollLeft=n-(e.clientWidth-r)/2}e.style.opacity=`1`}function ua(e,t){Qi.draggedId=t,Qi.sourceType=`tab`,e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t),e.currentTarget.classList.add(`dragging`)}function da(e){e.preventDefault(),e.dataTransfer.dropEffect=`move`,e.currentTarget.classList.add(`drag-over`)}function fa(e){e.currentTarget.classList.remove(`drag-over`)}async function pa(e,t){e.preventDefault(),e.currentTarget.classList.remove(`drag-over`);let n=Qi.draggedId;if(!n||n===t)return;let r=H.sessions||[],i=r.findIndex(e=>e.id===n),a=r.findIndex(e=>e.id===t);if(i===-1||a===-1)return;let o=[...r],[s]=o.splice(i,1);o.splice(a,0,s),H.sessions=o,await Ft(o.map(e=>e.id)),na()}function ma(e){e.currentTarget.classList.remove(`dragging`),document.querySelectorAll(`.session-tab.drag-over`).forEach(e=>e.classList.remove(`drag-over`)),Qi.draggedId=null,Qi.sourceType=null}function ha(){Zi.visible?_a():ga()}async function ga(){let e=document.getElementById(`sessionTabsMore`),t=document.getElementById(`sessionDropdown`);if(!e||!t)return;let n=await kt();H.sessions=n.list,H.activeSessionId=n.activeSessionId,Zi.filteredSessions=ea([...n.list]),Zi.highlightIndex=-1,Zi.visible=!0,ya(),t.classList.add(`show`);let r=document.getElementById(`sessionDropdownCloseBtn`);r&&(r.onclick=()=>_a());let i=document.getElementById(`sessionDropdownSearch`),a=document.getElementById(`sessionDropdownSearchClear`);i&&(i.value=Zi.lastSearchText||``,va(),Zi.lastSearchText&&ba(Zi.lastSearchText),setTimeout(()=>i.focus(),50),i.oninput=()=>{Zi.lastSearchText=i.value,va(),ba(i.value)},i.onkeydown=e=>{Ea(e)}),a&&(a.onclick=()=>{i&&(i.value=``,Zi.lastSearchText=``,va(),ba(``),i.focus())}),e.classList.add(`active`)}function _a(){let e=document.getElementById(`sessionTabsMore`),t=document.getElementById(`sessionDropdown`);t&&t.classList.remove(`show`),e&&e.classList.remove(`active`);let n=document.getElementById(`sessionDropdownSearch`);n&&(Zi.lastSearchText=n.value,n.oninput=null,n.onkeydown=null);let r=document.getElementById(`sessionDropdownSearchClear`);r&&(r.onclick=null),Zi.visible=!1,Zi.highlightIndex=-1,Zi.filteredSessions=[]}function va(){let e=document.getElementById(`sessionDropdownSearch`),t=document.getElementById(`sessionDropdownSearchClear`);t&&e&&(t.style.display=e.value?`flex`:`none`)}function ya(){let e=document.getElementById(`sessionDropdownList`);if(!e)return;e.innerHTML=``;let t=document.getElementById(`sessionDropdownCloseAll`);if(t){let e=(H.sessions||[]).length;t.textContent=i(`session.closeAllCount`,{count:e})}if(Zi.filteredSessions.length===0){let t=document.createElement(`div`);t.className=`session-dropdown-empty`,t.textContent=i(`session.noMatch`),e.appendChild(t);return}let n={today:i(`session.today`),yesterday:i(`session.yesterday`),last7Days:i(`session.last7Days`),earlier:i(`session.earlier`)},r={};Zi.filteredSessions.forEach(e=>{let t=ta(e.updatedAt);r[t]=(r[t]||0)+1});let a=null;Zi.filteredSessions.forEach((t,o)=>{let s=ta(t.updatedAt);if(s!==a){a=s;let t=document.createElement(`div`);t.className=`session-dropdown-group-header`;let o=document.createElement(`span`);if(o.textContent=n[s]||s,t.appendChild(o),(r[s]||0)>0){let e=document.createElement(`button`);e.className=`session-dropdown-group-close`,e.textContent=i(`session.closeGroupAll`),e.onclick=e=>{e.stopPropagation(),wa(s,n[s]||s)},t.appendChild(e)}e.appendChild(t)}let c=document.createElement(`div`);if(c.className=`session-dropdown-item`,c.dataset.sessionId=t.id,c.dataset.index=o,t.id===H.activeSessionId&&c.classList.add(`active`),o===Zi.highlightIndex&&c.classList.add(`highlighted`),H.completedSessionIds.has(t.id)&&t.id!==H.activeSessionId&&!t.isGenerating&&!H.generatingSessionIds.has(t.id)){let e=document.createElement(`span`);e.className=`session-dropdown-item-completed`,e.title=i(`session.taskCompleted`),c.appendChild(e)}let l=document.createElement(`span`);l.className=`session-dropdown-item-icon`,l.innerHTML=`<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>`,c.appendChild(l);let u=document.createElement(`span`);if(u.className=`session-dropdown-item-title`,u.textContent=t.title||i(`session.newSession`),u.title=t.title||i(`session.newSession`),c.appendChild(u),t.id===H.activeSessionId){let e=document.createElement(`span`);e.className=`session-dropdown-item-check`,e.innerHTML=`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>`,c.appendChild(e)}let d=document.createElement(`span`);d.className=`session-dropdown-item-time`,d.textContent=$i(t.updatedAt),c.appendChild(d);let f=document.createElement(`span`);f.className=`session-dropdown-item-actions`;let p=document.createElement(`span`);p.className=`session-dropdown-item-rename`,p.title=i(`session.rename`),p.innerHTML=`<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,p.addEventListener(`click`,e=>{e.stopPropagation(),e.preventDefault(),Fa(t)}),f.appendChild(p);let m=document.createElement(`span`);m.className=`session-dropdown-item-duplicate`,m.title=i(`session.duplicate`),m.innerHTML=`<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="6" r="2.5"/><circle cx="6" cy="18" r="2.5"/><circle cx="18" cy="6" r="2.5"/><path d="M6 8.5v7"/><path d="M18 8.5c0 4-6 3.5-6 3.5"/></svg>`,m.addEventListener(`click`,async e=>{e.stopPropagation(),e.preventDefault(),await ja(t.id);let n=await kt();H.sessions=n.list,H.activeSessionId=n.activeSessionId,ba(document.getElementById(`sessionDropdownSearch`)?.value||``)}),f.appendChild(m);let h=document.createElement(`span`);h.className=`session-dropdown-item-close`,h.innerHTML=`✕`,h.title=i(`session.closeSession`),h.addEventListener(`click`,async e=>{e.stopPropagation(),e.preventDefault(),await Sa(t.id)}),f.appendChild(h),c.appendChild(f),c.addEventListener(`click`,async e=>{e.preventDefault(),await xa(t.id)}),e.appendChild(c)})}function ba(e){let t=H.sessions||[],n;if(!e.trim())n=[...t];else{let r=e.trim().toLowerCase();n=t.filter(e=>(e.title||i(`session.newSession`)).toLowerCase().includes(r))}Zi.filteredSessions=ea(n),Zi.highlightIndex=-1,ya()}async function xa(e){_a(),e!==H.activeSessionId&&await Aa(e)}async function Sa(e){let t=(H.sessions||[]).find(t=>t.id===e);t&&((e===H.activeSessionId?H.messageHistory?.length||0:t.messageHistory?.length||0)>0&&!await Oa(i(`session.confirmCloseMessageWithTitle`,{title:t.title}),i(`session.closeSession`))||(await Nt(e),await za(),ba(document.getElementById(`sessionDropdownSearch`)?.value||``)))}async function Ca(){let e=H.sessions||[];if(e.length!==0&&await Oa(i(`session.confirmCloseAllMessage`,{count:e.length}),i(`session.confirmCloseAllTitle`))){for(let t of e)await Nt(t.id);await za(),ba(document.getElementById(`sessionDropdownSearch`)?.value||``)}}async function wa(e,t){let n=(H.sessions||[]).filter(t=>ta(t.updatedAt)===e);if(n.length!==0&&await Oa(i(`session.confirmCloseGroupMessage`,{group:t,count:n.length}),i(`session.closeSession`))){for(let e of n)await Nt(e.id);await za(),ba(document.getElementById(`sessionDropdownSearch`)?.value||``)}}function Ta(){let e=document.getElementById(`sessionDropdownCloseAll`),t=document.getElementById(`sessionDropdown`);if(t){if(e){let t=e.cloneNode(!0);e.parentNode.replaceChild(t,e),t.addEventListener(`click`,async e=>{e.stopPropagation(),await Ca()})}t.addEventListener(`click`,e=>{e.stopPropagation()})}}function Ea(e){if(!Zi.visible)return;let t=Zi.filteredSessions.length;if(t===0){e.key===`Escape`&&_a();return}switch(e.key){case`ArrowDown`:e.preventDefault(),Zi.highlightIndex=Math.min(Zi.highlightIndex+1,t-1),ya(),Da();break;case`ArrowUp`:e.preventDefault(),Zi.highlightIndex=Math.max(Zi.highlightIndex-1,0),ya(),Da();break;case`Enter`:if(e.preventDefault(),Zi.highlightIndex>=0&&Zi.highlightIndex<t){let e=Zi.filteredSessions[Zi.highlightIndex];xa(e.id)}break;case`Escape`:e.preventDefault(),_a()}}function Da(){let e=document.querySelector(`.session-dropdown-item.highlighted`);e&&e.scrollIntoView({block:`nearest`})}function Oa(e,t){return new Promise(t=>{let n=document.getElementById(`sessionDeleteModal`),r=document.getElementById(`sessionDeleteMessage`),i=document.getElementById(`sessionDeleteConfirmBtn`),a=document.getElementById(`sessionDeleteCancelBtn`),o=document.getElementById(`sessionDeleteCloseBtn`);if(!n||!r){t(!1);return}r.textContent=e;let s=()=>{n.classList.remove(`show`),i.removeEventListener(`click`,c),a.removeEventListener(`click`,l),o.removeEventListener(`click`,l)},c=()=>{s(),t(!0)},l=()=>{s(),t(!1)};i.addEventListener(`click`,c),a.addEventListener(`click`,l),o.addEventListener(`click`,l),n.classList.add(`show`)})}var ka=!1;async function Aa(e){let t=H.activeSessionId;if(!await Mt(e))return;let n=`agentEnabledTools_${H.activeAgentId||`default`}`,r=`agentMcpClosedServers_${H.activeAgentId||`default`}`,[i,a,o,s]=await Promise.all([kt(),chrome.storage.local.get([r,`ragTools`,`ragToolsIntroduced`]),chrome.storage.local.get([n,`enabledTools`]),H.activeAgentId?be(H.activeAgentId):Promise.resolve(null)]);H.sessions=i.list,H.activeSessionId=e;let c=a.ragTools||[];H.mcpClosedServers=a[r]||[];let l=!!o[n],u=o[n]||o.enabledTools;if(l||u&&u.length>0){let e=new Set([...f.map(e=>e.id),...c.map(e=>e.id)]),t=u.filter(t=>e.has(t));if(l)H.enabledTools=t;else{let e=f.filter(e=>e.enabled&&!t.includes(e.id)).map(e=>e.id);H.enabledTools=[...t,...e]}let r=xn(H.enabledTools,c,a.ragToolsIntroduced);H.enabledTools=r.tools,H.enabledTools.length!==u.length&&chrome.storage.local.set({[n]:H.enabledTools,...r.migrated?{ragToolsIntroduced:!0}:{}})}else{H.enabledTools=f.filter(e=>e.enabled).map(e=>e.id);let e=xn(H.enabledTools,c,a.ragToolsIntroduced);H.enabledTools=e.tools,e.migrated&&chrome.storage.local.set({ragToolsIntroduced:!0,[n]:H.enabledTools})}H.activeAgentToolIds=s?s.toolIds:null,H.activeAgentMcpExcludedServerIds=s?s.mcpExcludedServerIds??null:null,document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:e,previousSessionId:t}})),Ot(e),na(i),Ma(),Dk();try{let{refreshBookmarkPanel:e,updateBookmarkButtons:t}=await fe(async()=>{let{refreshBookmarkPanel:e,updateBookmarkButtons:t}=await Promise.resolve().then(()=>ll);return{refreshBookmarkPanel:e,updateBookmarkButtons:t}},void 0);e(),setTimeout(()=>t(),100)}catch{}let d=document.getElementById(`toolsPopupOverlay`);d&&d.classList.contains(`show`)&&(sn(),hn(),gn()),yn()}async function ja(e,t=null){if(e)try{let n=await zt(e,t);await Aa(n.id),U(i(t?`session.forkedFrom`:`session.forkedSession`,{title:n.title}),`success`)}catch(e){o.error(`[SessionUI] copy/forksession failed:`,e),U(i(`session.operationFailed`,{message:e.message}),`error`)}}function Ma(){let e=document.querySelector(`.model-display`);e&&H.currentModel&&(e.textContent=H.currentModel);let t=document.getElementById(`enableToolsBtn`);t&&(t.checked=H.useTools);let n=document.getElementById(`tempIconValue`);n&&H.temperature!==void 0&&(n.textContent=H.temperature.toFixed(2))}var Na=new WeakSet;function Pa(e){Na.has(e)||(Na.add(e),e.addEventListener(`wheel`,t=>{e.scrollWidth<=e.clientWidth||(t.preventDefault(),e.scrollLeft+=t.deltaY)},{passive:!1}))}function Fa(e){let t=document.getElementById(`sessionRenameModal`),n=document.getElementById(`sessionRenameInput`),r=document.getElementById(`sessionRenameConfirmBtn`),i=document.getElementById(`sessionRenameCancelBtn`),a=document.getElementById(`sessionRenameCloseBtn`);if(!t||!n)return;n.value=e.title;let o=()=>{t.classList.remove(`show`),r.removeEventListener(`click`,s),i.removeEventListener(`click`,c),a.removeEventListener(`click`,c)},s=async()=>{let t=n.value.trim();if(t&&t!==e.title){await Pt(e.id,t),na();let n=await kt();H.sessions=n.list,H.activeSessionId=n.activeSessionId,ba(document.getElementById(`sessionDropdownSearch`)?.value||``)}o()},c=()=>{o()};r.addEventListener(`click`,s),i.addEventListener(`click`,c),a.addEventListener(`click`,c),n.onkeydown=e=>{e.key===`Enter`?s():e.key===`Escape`&&c()},t.classList.add(`show`),setTimeout(()=>{n.focus(),n.select()},50)}function Ia(e,t){let n=document.getElementById(`sessionDeleteModal`),r=document.getElementById(`sessionDeleteMessage`),a=document.getElementById(`sessionDeleteConfirmBtn`),o=document.getElementById(`sessionDeleteCancelBtn`),s=document.getElementById(`sessionDeleteCloseBtn`);if(!n||!r)return;r.textContent=i(`session.confirmCloseMessageWithTitle`,{title:e.title});let c=()=>{n.classList.remove(`show`),a.removeEventListener(`click`,l),o.removeEventListener(`click`,u),s.removeEventListener(`click`,u)},l=async()=>{await Nt(e.id),t&&await t(),c()},u=()=>{c()};a.addEventListener(`click`,l),o.addEventListener(`click`,u),s.addEventListener(`click`,u),n.classList.add(`show`),requestAnimationFrame(()=>a.focus())}function La(e,t){let n=document.querySelector(`.session-context-menu`);n&&n.remove();let r=document.createElement(`div`);r.className=`session-context-menu`,r.style.left=e.clientX+`px`,r.style.top=e.clientY+`px`;let a=Ra(i(`session.rename`),`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,()=>{r.remove(),Fa(t)});r.appendChild(a);let o=Ra(i(`session.duplicate`),`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="6" r="2.5"/><circle cx="6" cy="18" r="2.5"/><circle cx="18" cy="6" r="2.5"/><path d="M6 8.5v7"/><path d="M18 8.5c0 4-6 3.5-6 3.5"/></svg>`,()=>{r.remove(),ja(t.id)});r.appendChild(o);let s=Ra(i(`session.closeSession`),`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>`,async()=>{if(r.remove(),(t.id===H.activeSessionId?H.messageHistory?.length||0:t.messageHistory?.length||0)===0){await Nt(t.id),await za();return}Ia(t,async()=>{await za()})},`danger`);r.appendChild(s),document.body.appendChild(r);let c=e=>{r.contains(e.target)||(r.remove(),document.removeEventListener(`click`,c))};setTimeout(()=>document.addEventListener(`click`,c),0)}function Ra(e,t=``,n,r=``){let i=document.createElement(`div`);return i.className=`session-context-menu-item `+r,t?i.innerHTML=`${t}<span>${e}</span>`:i.textContent=e,i.addEventListener(`click`,n),i}async function za(){let e=H.activeSessionId,t=await kt();t.activeSessionId||(await jt(),t=await kt()),H.activeSessionId=t.activeSessionId,H.sessions=t.list;let n=t.list.find(e=>e.id===t.activeSessionId);if(H.messageHistory=n&&n.messageHistory||[],H.activeCompaction=n?.contextCompaction||null,H.activeAgentId=n&&n.agentId||null,H.activeAgentId){let e=await be(H.activeAgentId);H.activeAgentToolIds=e?e.toolIds:null,H.activeAgentMcpExcludedServerIds=e?e.mcpExcludedServerIds??null:null}else H.activeAgentToolIds=null,H.activeAgentMcpExcludedServerIds=null;document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:H.activeSessionId,previousSessionId:e}})),na(),await Dk()}async function Ba(){let e=H.activeSessionId;if(!e)return;let t=H.sessions?.find(t=>t.id===e);if(t){if((H.messageHistory?.length||0)===0){await Nt(e),await za();return}Ia(t,async()=>{await za()})}}document.addEventListener(`generating-state-changed`,()=>{na()}),document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,ca):ca(),[`<svg viewBox="0 0 16 16" fill="currentColor">`,`<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25zM5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25z"/>`,`</svg>`].join(``),[`<svg viewBox="0 0 16 16" fill="currentColor">`,`<path d="M12.146.146a.5.5 0 0 1 .708 0l2.5 2.5a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168l10-10zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207 11.207 2.5zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293l6.5-6.5zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12h.5a.5.5 0 0 1 .5.5v.5a.5.5 0 0 1-.5.5h-.5a.5.5 0 0 1-.468-.325z"/>`,`</svg>`].join(``),[`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<circle cx="12" cy="12" r="10"></circle>`,`<polyline points="12 6 12 12 16 14"></polyline>`,`</svg>`].join(``),[`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<line x1="18" y1="6" x2="6" y2="18"></line>`,`<line x1="6" y1="6" x2="18" y2="18"></line>`,`</svg>`].join(``),[`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<polyline points="7 13 12 18 17 13"></polyline>`,`<polyline points="7 6 12 11 17 6"></polyline>`,`</svg>`].join(``);var Va=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>`,Ha=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>`,Ua=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>`,Wa=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,Ga=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>`,Ka=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>`;[`<svg class="tool-call-icon exec" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<polyline points="4 17 10 11 4 5"/><line x1="12" y1="19" x2="20" y2="19"/>`,`</svg>`].join(``),[`<svg class="tool-call-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>`,`<polyline points="14 2 14 8 20 8"/>`,`</svg>`].join(``),[`<svg class="tool-call-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>`,`</svg>`].join(``),[`<svg class="tool-call-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/>`,`</svg>`].join(``),r(`zh`,{uiProto:{defaultTitle:`原型`,optimizePrompt:`请帮我优化这个UI原型界面 {id}({title}),`,loadFailed:`加载失败`,noDescription:`暂无描述`,previewInPanel:`面板内预览`,continueOptimizeTitle:`继续优化`,downloadPrototype:`下载原型`,confirmDeleteTitle:`确认删除`,confirmDeleteMessage:`确定删除原型 "{title}" 吗?此操作不可撤销。`,deleteFailed:`删除失败: {message}`,justNow:`刚刚`,minutesAgo:`{count} 分钟前`,hoursAgo:`{count} 小时前`}}),r(`en`,{uiProto:{defaultTitle:`Prototype`,optimizePrompt:`Please help me optimize this UI prototype {id} ({title}), `,loadFailed:`Load failed`,noDescription:`No description`,previewInPanel:`Preview in panel`,continueOptimizeTitle:`Continue optimizing`,downloadPrototype:`Download prototype`,confirmDeleteTitle:`Confirm delete`,confirmDeleteMessage:`Are you sure you want to delete prototype "{title}"? This action cannot be undone.`,deleteFailed:`Delete failed: {message}`,justNow:`Just now`,minutesAgo:`{count} minutes ago`,hoursAgo:`{count} hours ago`}});var qa=null,Ja=1,Ya=.25,Xa=2,Za=.1;function Qa(e){let t=e.trim();return/^\s*<!DOCTYPE\s/i.test(t)||/^\s*<html[\s>]/i.test(t)?/<\/head>/i.test(t)?t.replace(/<\/head>/i,`<style>html,body{overflow:auto!important;height:auto!important;}</style></head>`):/<body[\s>]/i.test(t)?t.replace(/<body([\s>])/i,`<body$1<style>html,body{overflow:auto!important;height:auto!important;}</style>`):t:`<!DOCTYPE html>
|
|
220
226
|
<html>
|
|
221
227
|
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"></head>
|
|
222
228
|
<body style="margin:0;padding:0;overflow:auto;">${t}</body>
|
|
@@ -921,7 +927,7 @@ Actual: `+e.attribValue);else{var i=e.tag,a=e.tags[e.tags.length-1]||e;i.ns===a.
|
|
|
921
927
|
line-height: 1.6;
|
|
922
928
|
color: #333;
|
|
923
929
|
box-sizing: border-box;
|
|
924
|
-
`;let u=document.createElement(`div`);u.className=`markdown-body`,u.innerHTML=Ei(a),n.appendChild(u),document.body.appendChild(n),await Fb(n),await Rb(n),await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e)));let d=(await r(n,{scale:2,useCORS:!0,logging:!1,backgroundColor:`#ffffff`,willReadFrequently:!0})).toDataURL(`image/jpeg`,.92),f=document.createElement(`a`);f.href=d,f.download=s,document.body.appendChild(f),f.click(),document.body.removeChild(f),Bb(t,`image`),document.body.removeChild(n),n=null,o.debug(`[SidePanel] image export successful:`,s)}catch(e){o.error(`[SidePanel] export image failed:`,e),U(i(`chatExport.exportFailed`,{message:e.message}),`error`),n&&n.parentNode&&document.body.removeChild(n),Vb(t)}})}))}r(`zh`,{workspace:{workDir:`工作目录`,closePanel:`关闭面板`,embedMode:`嵌入模式`,floatMode:`浮窗模式`,narrowViewportHint:`视口过窄,已切回浮窗模式`,switchWorkdir:`切换工作目录`,backToParent:`返回上级目录`,uploadToCurrent:`上传文件到当前目录`,newFolder:`新建文件夹`,askSelectedFiles:`基于选中的文件进行问答`,downloadSelected:`下载选中的文件/目录(多选打包为ZIP)`,deleteSelected:`删除选中的文件`,clearSearch:`清除`,search:`搜索`,searchPlaceholder:`搜索...`,selectAllToggle:`全选/取消全选`,colName:`文件名`,colSize:`大小`,colTime:`修改时间`,noMatch:`未找到匹配的文件`,dirEmpty:`此目录为空`,noWorkspace:`无法获取工作目录,请确认 Agent 已连接`,loadDirFailed:`加载目录失败`,refreshFailed:`无法刷新,请确认 Agent 已连接`,agentNotConnected:`Agent 未连接`,agentNotConnectedUpload:`Agent 未连接,无法上传`,unsupportedFileType:`不支持的文件类型`,unknownError:`未知错误`,copiedFileName:`已复制文件名: {name}`,copiedPath:`已复制路径: {path}`,copyFailed:`复制失败`,copiedToClipboard:`已复制到剪贴板`,copyFailedManual:`复制失败,请手动选择复制`,getContentFailed:`获取内容失败`,codeCopiedToClipboard:`代码已复制到剪贴板`,copyUnsupportedType:`此文件类型不支持复制文本内容`,copiedToClipboardShort:`已复制到剪贴板`,clickToCopy:`点击复制`,preview:`预览`,previewBtn:`预览`,details:`详情`,download:`下载`,downloadFile:`下载文件`,rename:`重命名`,askFile:`基于文件问答`,delete:`删除`,copyAll:`复制`,copyAllTitle:`复制全部内容`,toggleRenderPreview:`切换渲染预览`,openInBrowser:`在浏览器中打开`,openInBrowserBtn:`在浏览器中打开`,fullscreenPreview:`全屏预览`,exitFullscreen:`退出全屏`,enterEditMode:`进入编辑模式`,edit:`编辑`,save:`保存`,saveChanges:`保存修改 (Ctrl+S)`,cancelChanges:`取消修改 (Esc)`,closePreview:`关闭预览`,close:`关闭`,confirm:`确定`,cancel:`取消`,switchToSourcePreview:`切换为源码预览`,switchToRenderPreview:`切换为渲染预览`,markdownRendered:`Markdown 渲染`,lineCount:`{count} 行`,linesModified:`{count} 行 · 已修改`,truncatedHint:`(仅显示前 {shown} 行,共 {total} 行,请下载查看完整内容)`,fileTooLargeNoPreview:`文件过大 ({size}),不支持预览,请直接下载`,fileTooLargeOpenInBrowser:`文件过大 ({size}),无法内置预览,请点击上方「在浏览器中打开」按钮查看`,previewFailed:`预览失败: {error}`,openFailed:`打开失败: {error}`,documentEmpty:`(文档为空)`,pptxEmptyOrFailed:`PPTX 文件为空或解析失败`,pageCount:`{count} 页`,prevPage:`上一页`,nextPage:`下一页`,zoomOut:`缩小`,zoomIn:`放大`,fitPage:`适应页面`,originalSize:`原始大小`,imageLoadFailed:`图片加载失败`,parsingExcel:`正在解析 Excel 文件...`,loadingData:`正在加载数据...`,requestFailed:`请求失败: {error}`,parseFailed:`解析失败: {error}`,noSheetsInWorkbook:`工作簿中没有工作表`,sheetNotFound:`未找到工作表数据`,emptySheet:`(空工作表)`,xlsxTruncatedHint:`仅显示前 {shown} 行,共 {total} 行,请下载查看完整内容`,unsupportedMediaHint:`⚠ 浏览器不支持播放此格式({ext}),请下载后使用本地播放器查看。`,uploading:`上传中...`,downloadInProgress:`下载中`,uploadInProgress:`上传中`,cancelUpload:`取消上传`,downloadCanceled:`下载已取消`,downloadFailed:`下载失败`,downloadFailedWithError:`下载失败: {error}`,savingToLocal:`正在由浏览器保存至本地...`,savedToLocal:`已保存至本地`,downloaded:`已下载: {name}`,downloadedCount:`已下载 {count} 个文件`,downloadedZip:`已下载 {count} 个文件(ZIP 压缩包)`,fileCount:`{count} 个文件`,uploadCanceled:`已取消上传`,uploadSuccessCount:`成功 {count}`,uploadSkippedCount:`跳过 {count}`,uploadFailedCount:`失败 {count}`,uploadComplete:`上传完成`,uploadCompleteWithStats:`上传完成 · {stats}`,uploadedFiles:`成功上传 {count} 个文件`,filesSkipped:`{count} 个文件已存在,跳过上传`,filesUploadFailed:`{count} 个文件上传失败`,uploadFailed:`上传失败`,uploadFailedWithStatus:`上传失败 ({status})`,parseResponseFailed:`解析响应失败`,networkError:`网络错误`,cannotMoveToSubdir:`不能将目录移动到其子目录中`,moving:`移动中...`,movedToDir:`"{name}" 已移动到目标目录`,movedToTarget:`"{name}" 已移动到 "{target}"`,moveFailed:`移动失败: {error}`,searching:`搜索中...`,confirmDeleteDir:`确定要删除目录 "{name}" 及其所有内容吗?
|
|
930
|
+
`;let u=document.createElement(`div`);u.className=`markdown-body`,u.innerHTML=Ei(a),n.appendChild(u),document.body.appendChild(n),await Fb(n),await Rb(n),await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e)));let d=(await r(n,{scale:2,useCORS:!0,logging:!1,backgroundColor:`#ffffff`,willReadFrequently:!0})).toDataURL(`image/jpeg`,.92),f=document.createElement(`a`);f.href=d,f.download=s,document.body.appendChild(f),f.click(),document.body.removeChild(f),Bb(t,`image`),document.body.removeChild(n),n=null,o.debug(`[SidePanel] image export successful:`,s)}catch(e){o.error(`[SidePanel] export image failed:`,e),U(i(`chatExport.exportFailed`,{message:e.message}),`error`),n&&n.parentNode&&document.body.removeChild(n),Vb(t)}})}))}r(`zh`,{workspace:{workDir:`工作目录`,closePanel:`关闭面板`,embedMode:`嵌入模式`,floatMode:`浮窗模式`,openPanel:`打开工作目录面板`,narrowViewportHint:`视口过窄,已切回浮窗模式`,switchWorkdir:`切换工作目录`,backToParent:`返回上级目录`,uploadToCurrent:`上传文件到当前目录`,newFolder:`新建文件夹`,askSelectedFiles:`基于选中的文件进行问答`,downloadSelected:`下载选中的文件/目录(多选打包为ZIP)`,deleteSelected:`删除选中的文件`,clearSearch:`清除`,search:`搜索`,searchPlaceholder:`搜索...`,selectAllToggle:`全选/取消全选`,colName:`文件名`,colSize:`大小`,colTime:`修改时间`,noMatch:`未找到匹配的文件`,dirEmpty:`此目录为空`,noWorkspace:`无法获取工作目录,请确认 Agent 已连接`,loadDirFailed:`加载目录失败`,refreshFailed:`无法刷新,请确认 Agent 已连接`,agentNotConnected:`Agent 未连接`,agentNotConnectedUpload:`Agent 未连接,无法上传`,unsupportedFileType:`不支持的文件类型`,unknownError:`未知错误`,copiedFileName:`已复制文件名: {name}`,copiedPath:`已复制路径: {path}`,copyFailed:`复制失败`,copiedToClipboard:`已复制到剪贴板`,copyFailedManual:`复制失败,请手动选择复制`,getContentFailed:`获取内容失败`,codeCopiedToClipboard:`代码已复制到剪贴板`,copyUnsupportedType:`此文件类型不支持复制文本内容`,copiedToClipboardShort:`已复制到剪贴板`,clickToCopy:`点击复制`,preview:`预览`,previewBtn:`预览`,details:`详情`,download:`下载`,downloadFile:`下载文件`,rename:`重命名`,askFile:`基于文件问答`,delete:`删除`,copyAll:`复制`,copyAllTitle:`复制全部内容`,toggleRenderPreview:`切换渲染预览`,openInBrowser:`在浏览器中打开`,openInBrowserBtn:`在浏览器中打开`,fullscreenPreview:`全屏预览`,exitFullscreen:`退出全屏`,enterEditMode:`进入编辑模式`,edit:`编辑`,save:`保存`,saveChanges:`保存修改 (Ctrl+S)`,cancelChanges:`取消修改 (Esc)`,closePreview:`关闭预览`,close:`关闭`,confirm:`确定`,cancel:`取消`,switchToSourcePreview:`切换为源码预览`,switchToRenderPreview:`切换为渲染预览`,markdownRendered:`Markdown 渲染`,lineCount:`{count} 行`,linesModified:`{count} 行 · 已修改`,truncatedHint:`(仅显示前 {shown} 行,共 {total} 行,请下载查看完整内容)`,fileTooLargeNoPreview:`文件过大 ({size}),不支持预览,请直接下载`,fileTooLargeOpenInBrowser:`文件过大 ({size}),无法内置预览,请点击上方「在浏览器中打开」按钮查看`,previewFailed:`预览失败: {error}`,openFailed:`打开失败: {error}`,documentEmpty:`(文档为空)`,pptxEmptyOrFailed:`PPTX 文件为空或解析失败`,pageCount:`{count} 页`,prevPage:`上一页`,nextPage:`下一页`,zoomOut:`缩小`,zoomIn:`放大`,fitPage:`适应页面`,originalSize:`原始大小`,imageLoadFailed:`图片加载失败`,parsingExcel:`正在解析 Excel 文件...`,loadingData:`正在加载数据...`,requestFailed:`请求失败: {error}`,parseFailed:`解析失败: {error}`,noSheetsInWorkbook:`工作簿中没有工作表`,sheetNotFound:`未找到工作表数据`,emptySheet:`(空工作表)`,xlsxTruncatedHint:`仅显示前 {shown} 行,共 {total} 行,请下载查看完整内容`,unsupportedMediaHint:`⚠ 浏览器不支持播放此格式({ext}),请下载后使用本地播放器查看。`,uploading:`上传中...`,downloadInProgress:`下载中`,uploadInProgress:`上传中`,cancelUpload:`取消上传`,downloadCanceled:`下载已取消`,downloadFailed:`下载失败`,downloadFailedWithError:`下载失败: {error}`,savingToLocal:`正在由浏览器保存至本地...`,savedToLocal:`已保存至本地`,downloaded:`已下载: {name}`,downloadedCount:`已下载 {count} 个文件`,downloadedZip:`已下载 {count} 个文件(ZIP 压缩包)`,fileCount:`{count} 个文件`,uploadCanceled:`已取消上传`,uploadSuccessCount:`成功 {count}`,uploadSkippedCount:`跳过 {count}`,uploadFailedCount:`失败 {count}`,uploadComplete:`上传完成`,uploadCompleteWithStats:`上传完成 · {stats}`,uploadedFiles:`成功上传 {count} 个文件`,filesSkipped:`{count} 个文件已存在,跳过上传`,filesUploadFailed:`{count} 个文件上传失败`,uploadFailed:`上传失败`,uploadFailedWithStatus:`上传失败 ({status})`,parseResponseFailed:`解析响应失败`,networkError:`网络错误`,cannotMoveToSubdir:`不能将目录移动到其子目录中`,moving:`移动中...`,movedToDir:`"{name}" 已移动到目标目录`,movedToTarget:`"{name}" 已移动到 "{target}"`,moveFailed:`移动失败: {error}`,searching:`搜索中...`,confirmDeleteDir:`确定要删除目录 "{name}" 及其所有内容吗?
|
|
925
931
|
|
|
926
932
|
路径: {path}
|
|
927
933
|
类型: 目录
|
|
@@ -940,7 +946,7 @@ Actual: `+e.attribValue);else{var i=e.tag,a=e.tags[e.tags.length-1]||e;i.ns===a.
|
|
|
940
946
|
{path}
|
|
941
947
|
|
|
942
948
|
移除后 AI 将无法访问该目录,可重新切换工作目录再加回。`,confirmRemovePathTitle:`确认移除允许目录`,removedFromAllowed:`已从允许列表移除`,removeFailedWithError:`移除失败: {error}`,selectOrInputPath:`请选择或输入目标路径`,alreadyCurrentWorkdir:`该目录已是当前工作目录`,confirmSwitchToNew:`该路径不在允许列表内,切换后将自动创建目录并加入允许列表:
|
|
943
|
-
{path}`,confirmSwitchToNewTitle:`确认切换到新目录`,switchFailedWithError:`切换失败: {error}`,switchedTo:`已切换到: {path}`,renameDir:`重命名目录`,renameFile:`重命名文件`,inputNewName:`输入新名称`,renamedTo:`已重命名为 "{name}"`,renameFailedWithError:`重命名失败: {error}`,newFolderTitle:`新建文件夹`,inputFolderName:`输入文件夹名称`,folderCreated:`已创建文件夹 "{name}"`,createFailedWithError:`创建失败: {error}`,addedFilesToQuestion:`已添加 {count} 个文件到问答`,addedFilesToQuestionNoImage:`已添加 {count} 个文件到问答(图片识别未启用,图片作为文件附件)`,selectedCount:`已选 {count}`,unsavedChanges:`未保存的修改`,discardChangesPrompt:`有未保存的修改,确定要{action}吗?`,actionClosePreview:`关闭预览`,actionCancelEdit:`取消编辑`,saving:`保存中...`,saveSuccess:`保存成功`,saveFailedWithError:`保存失败: {error}`,agentNamePrefix:` · {name}`,agentNotPaired:`Agent 未配对`,fileDetailsLabel:`文件详情`,loadingLabel:`加载中...`,export:`导出`,exportDocx:`Word`,exportPdf:`PDF`,exportImage:`图片`,exportMd:`Markdown`,copyMarkdownHint:`按住 Ctrl/Cmd 点击复制富文本`}}),r(`en`,{workspace:{workDir:`Working Directory`,closePanel:`Close Panel`,embedMode:`Embed mode`,floatMode:`Floating mode`,narrowViewportHint:`Viewport too narrow, switched back to floating mode`,switchWorkdir:`Switch Working Directory`,backToParent:`Back to Parent Directory`,uploadToCurrent:`Upload files to current directory`,newFolder:`New Folder`,askSelectedFiles:`Ask based on selected files`,downloadSelected:`Download selected files/directories (multi-select as ZIP)`,deleteSelected:`Delete selected files`,clearSearch:`Clear`,search:`Search`,searchPlaceholder:`Search...`,selectAllToggle:`Select All / Deselect All`,colName:`Name`,colSize:`Size`,colTime:`Modified`,noMatch:`No matching files found`,dirEmpty:`This directory is empty`,noWorkspace:`Unable to access working directory. Please confirm the Agent is connected.`,loadDirFailed:`Failed to load directory`,refreshFailed:`Unable to refresh. Please confirm the Agent is connected.`,agentNotConnected:`Agent not connected`,agentNotConnectedUpload:`Agent not connected, unable to upload`,unsupportedFileType:`Unsupported file type`,unknownError:`Unknown error`,copiedFileName:`Copied file name: {name}`,copiedPath:`Copied path: {path}`,copyFailed:`Copy failed`,copiedToClipboard:`Copied to clipboard`,copyFailedManual:`Copy failed, please select and copy manually`,getContentFailed:`Failed to get content`,codeCopiedToClipboard:`Code copied to clipboard`,copyUnsupportedType:`Copying text content is not supported for this file type`,copiedToClipboardShort:`Copied to clipboard`,clickToCopy:`Click to copy`,preview:`Preview`,previewBtn:`Preview`,details:`Details`,download:`Download`,downloadFile:`Download file`,rename:`Rename`,askFile:`Ask about file`,delete:`Delete`,copyAll:`Copy`,copyAllTitle:`Copy all content`,toggleRenderPreview:`Toggle rendered preview`,openInBrowser:`Open in browser`,openInBrowserBtn:`Open in browser`,fullscreenPreview:`Fullscreen preview`,exitFullscreen:`Exit fullscreen`,enterEditMode:`Enter edit mode`,edit:`Edit`,save:`Save`,saveChanges:`Save changes (Ctrl+S)`,cancelChanges:`Cancel changes (Esc)`,closePreview:`Close preview`,close:`Close`,confirm:`OK`,cancel:`Cancel`,switchToSourcePreview:`Switch to source preview`,switchToRenderPreview:`Switch to rendered preview`,markdownRendered:`Markdown rendered`,lineCount:`{count} lines`,linesModified:`{count} lines · Modified`,truncatedHint:`(Showing first {shown} of {total} lines. Download to view full content.)`,fileTooLargeNoPreview:`File too large ({size}). Preview not supported. Please download directly.`,fileTooLargeOpenInBrowser:`File too large ({size}) for built-in preview. Please click "Open in browser" above to view.`,previewFailed:`Preview failed: {error}`,openFailed:`Open failed: {error}`,documentEmpty:`(Empty document)`,pptxEmptyOrFailed:`PPTX file is empty or failed to parse`,pageCount:`{count} pages`,prevPage:`Previous page`,nextPage:`Next page`,zoomOut:`Zoom out`,zoomIn:`Zoom in`,fitPage:`Fit page`,originalSize:`Original size`,imageLoadFailed:`Image load failed`,parsingExcel:`Parsing Excel file...`,loadingData:`Loading data...`,requestFailed:`Request failed: {error}`,parseFailed:`Parse failed: {error}`,noSheetsInWorkbook:`No worksheets in the workbook`,sheetNotFound:`Worksheet data not found`,emptySheet:`(Empty sheet)`,xlsxTruncatedHint:`Showing first {shown} of {total} rows. Download to view full content.`,unsupportedMediaHint:`⚠ The browser cannot play this format ({ext}). Please download and use a local player.`,uploading:`Uploading...`,downloadInProgress:`Downloading`,uploadInProgress:`Uploading`,cancelUpload:`Cancel upload`,downloadCanceled:`Download canceled`,downloadFailed:`Download failed`,downloadFailedWithError:`Download failed: {error}`,savingToLocal:`Saving to local via browser...`,savedToLocal:`Saved to local`,downloaded:`Downloaded: {name}`,downloadedCount:`Downloaded {count} files`,downloadedZip:`Downloaded {count} files (ZIP archive)`,fileCount:`{count} files`,uploadCanceled:`Upload canceled`,uploadSuccessCount:`Success {count}`,uploadSkippedCount:`Skipped {count}`,uploadFailedCount:`Failed {count}`,uploadComplete:`Upload complete`,uploadCompleteWithStats:`Upload complete · {stats}`,uploadedFiles:`Successfully uploaded {count} files`,filesSkipped:`{count} file(s) already exist, skipped`,filesUploadFailed:`{count} file(s) failed to upload`,uploadFailed:`Upload failed`,uploadFailedWithStatus:`Upload failed ({status})`,parseResponseFailed:`Failed to parse response`,networkError:`Network error`,cannotMoveToSubdir:`Cannot move a directory into its own subdirectory`,moving:`Moving...`,movedToDir:`"{name}" moved to target directory`,movedToTarget:`"{name}" moved to "{target}"`,moveFailed:`Move failed: {error}`,searching:`Searching...`,confirmDeleteDir:`Are you sure you want to delete directory "{name}" and all its contents?
|
|
949
|
+
{path}`,confirmSwitchToNewTitle:`确认切换到新目录`,switchFailedWithError:`切换失败: {error}`,switchedTo:`已切换到: {path}`,renameDir:`重命名目录`,renameFile:`重命名文件`,inputNewName:`输入新名称`,renamedTo:`已重命名为 "{name}"`,renameFailedWithError:`重命名失败: {error}`,newFolderTitle:`新建文件夹`,inputFolderName:`输入文件夹名称`,folderCreated:`已创建文件夹 "{name}"`,createFailedWithError:`创建失败: {error}`,addedFilesToQuestion:`已添加 {count} 个文件到问答`,addedFilesToQuestionNoImage:`已添加 {count} 个文件到问答(图片识别未启用,图片作为文件附件)`,selectedCount:`已选 {count}`,unsavedChanges:`未保存的修改`,discardChangesPrompt:`有未保存的修改,确定要{action}吗?`,actionClosePreview:`关闭预览`,actionCancelEdit:`取消编辑`,saving:`保存中...`,saveSuccess:`保存成功`,saveFailedWithError:`保存失败: {error}`,agentNamePrefix:` · {name}`,agentNotPaired:`Agent 未配对`,fileDetailsLabel:`文件详情`,loadingLabel:`加载中...`,export:`导出`,exportDocx:`Word`,exportPdf:`PDF`,exportImage:`图片`,exportMd:`Markdown`,copyMarkdownHint:`按住 Ctrl/Cmd 点击复制富文本`}}),r(`en`,{workspace:{workDir:`Working Directory`,closePanel:`Close Panel`,embedMode:`Embed mode`,floatMode:`Floating mode`,openPanel:`Open workspace panel`,narrowViewportHint:`Viewport too narrow, switched back to floating mode`,switchWorkdir:`Switch Working Directory`,backToParent:`Back to Parent Directory`,uploadToCurrent:`Upload files to current directory`,newFolder:`New Folder`,askSelectedFiles:`Ask based on selected files`,downloadSelected:`Download selected files/directories (multi-select as ZIP)`,deleteSelected:`Delete selected files`,clearSearch:`Clear`,search:`Search`,searchPlaceholder:`Search...`,selectAllToggle:`Select All / Deselect All`,colName:`Name`,colSize:`Size`,colTime:`Modified`,noMatch:`No matching files found`,dirEmpty:`This directory is empty`,noWorkspace:`Unable to access working directory. Please confirm the Agent is connected.`,loadDirFailed:`Failed to load directory`,refreshFailed:`Unable to refresh. Please confirm the Agent is connected.`,agentNotConnected:`Agent not connected`,agentNotConnectedUpload:`Agent not connected, unable to upload`,unsupportedFileType:`Unsupported file type`,unknownError:`Unknown error`,copiedFileName:`Copied file name: {name}`,copiedPath:`Copied path: {path}`,copyFailed:`Copy failed`,copiedToClipboard:`Copied to clipboard`,copyFailedManual:`Copy failed, please select and copy manually`,getContentFailed:`Failed to get content`,codeCopiedToClipboard:`Code copied to clipboard`,copyUnsupportedType:`Copying text content is not supported for this file type`,copiedToClipboardShort:`Copied to clipboard`,clickToCopy:`Click to copy`,preview:`Preview`,previewBtn:`Preview`,details:`Details`,download:`Download`,downloadFile:`Download file`,rename:`Rename`,askFile:`Ask about file`,delete:`Delete`,copyAll:`Copy`,copyAllTitle:`Copy all content`,toggleRenderPreview:`Toggle rendered preview`,openInBrowser:`Open in browser`,openInBrowserBtn:`Open in browser`,fullscreenPreview:`Fullscreen preview`,exitFullscreen:`Exit fullscreen`,enterEditMode:`Enter edit mode`,edit:`Edit`,save:`Save`,saveChanges:`Save changes (Ctrl+S)`,cancelChanges:`Cancel changes (Esc)`,closePreview:`Close preview`,close:`Close`,confirm:`OK`,cancel:`Cancel`,switchToSourcePreview:`Switch to source preview`,switchToRenderPreview:`Switch to rendered preview`,markdownRendered:`Markdown rendered`,lineCount:`{count} lines`,linesModified:`{count} lines · Modified`,truncatedHint:`(Showing first {shown} of {total} lines. Download to view full content.)`,fileTooLargeNoPreview:`File too large ({size}). Preview not supported. Please download directly.`,fileTooLargeOpenInBrowser:`File too large ({size}) for built-in preview. Please click "Open in browser" above to view.`,previewFailed:`Preview failed: {error}`,openFailed:`Open failed: {error}`,documentEmpty:`(Empty document)`,pptxEmptyOrFailed:`PPTX file is empty or failed to parse`,pageCount:`{count} pages`,prevPage:`Previous page`,nextPage:`Next page`,zoomOut:`Zoom out`,zoomIn:`Zoom in`,fitPage:`Fit page`,originalSize:`Original size`,imageLoadFailed:`Image load failed`,parsingExcel:`Parsing Excel file...`,loadingData:`Loading data...`,requestFailed:`Request failed: {error}`,parseFailed:`Parse failed: {error}`,noSheetsInWorkbook:`No worksheets in the workbook`,sheetNotFound:`Worksheet data not found`,emptySheet:`(Empty sheet)`,xlsxTruncatedHint:`Showing first {shown} of {total} rows. Download to view full content.`,unsupportedMediaHint:`⚠ The browser cannot play this format ({ext}). Please download and use a local player.`,uploading:`Uploading...`,downloadInProgress:`Downloading`,uploadInProgress:`Uploading`,cancelUpload:`Cancel upload`,downloadCanceled:`Download canceled`,downloadFailed:`Download failed`,downloadFailedWithError:`Download failed: {error}`,savingToLocal:`Saving to local via browser...`,savedToLocal:`Saved to local`,downloaded:`Downloaded: {name}`,downloadedCount:`Downloaded {count} files`,downloadedZip:`Downloaded {count} files (ZIP archive)`,fileCount:`{count} files`,uploadCanceled:`Upload canceled`,uploadSuccessCount:`Success {count}`,uploadSkippedCount:`Skipped {count}`,uploadFailedCount:`Failed {count}`,uploadComplete:`Upload complete`,uploadCompleteWithStats:`Upload complete · {stats}`,uploadedFiles:`Successfully uploaded {count} files`,filesSkipped:`{count} file(s) already exist, skipped`,filesUploadFailed:`{count} file(s) failed to upload`,uploadFailed:`Upload failed`,uploadFailedWithStatus:`Upload failed ({status})`,parseResponseFailed:`Failed to parse response`,networkError:`Network error`,cannotMoveToSubdir:`Cannot move a directory into its own subdirectory`,moving:`Moving...`,movedToDir:`"{name}" moved to target directory`,movedToTarget:`"{name}" moved to "{target}"`,moveFailed:`Move failed: {error}`,searching:`Searching...`,confirmDeleteDir:`Are you sure you want to delete directory "{name}" and all its contents?
|
|
944
950
|
|
|
945
951
|
Path: {path}
|
|
946
952
|
Type: Directory
|
|
@@ -1157,7 +1163,7 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1157
1163
|
<div class="workspace-preview-content" id="workspacePreviewContent"></div>
|
|
1158
1164
|
</div>
|
|
1159
1165
|
</div>
|
|
1160
|
-
`,gt(`workspace`).appendChild(e),gx(),kw(),aw(),Ax(),jx(),Px(),o.debug(`[WorkspacePanel] workspace panelinitializing`)}function gx(){document.getElementById(`workspacePanelContainer`);let e=document.getElementById(`workspacePanel`);document.getElementById(`workspacePanelToggle`).addEventListener(`click`,async t=>{t.stopPropagation();let n=e.classList.contains(`expanded`);if(n||(mx=!1),n)Ix();else if(sx){let e=document.getElementById(`mainRow`);if((e?e.clientWidth:window.innerWidth)<$b){await Fx(),U(i(`workspace.narrowViewportHint`),`error`);return}await Fx(),ax=wx(ax),Ex(),ix=!0,ox=!1,await Ox()}else await Fx()}),document.getElementById(`workspacePanelClose`).addEventListener(`click`,e=>{e.stopPropagation(),Ix()}),document.getElementById(`workspacePanelModeBtn`).addEventListener(`click`,async e=>{e.stopPropagation(),await kx()});let t=document.getElementById(`workspaceSwitchBtn`);t&&t.addEventListener(`click`,async e=>{e.stopPropagation(),await zw()}),document.getElementById(`workspaceBackBtn`).addEventListener(`click`,e=>{e.stopPropagation(),sw()}),document.getElementById(`workspaceRefreshBtn`).addEventListener(`click`,e=>{e.stopPropagation(),cw()}),document.getElementById(`workspaceUploadBtn`).addEventListener(`click`,e=>{e.stopPropagation(),GC()}),document.getElementById(`workspaceNewFolderBtn`).addEventListener(`click`,e=>{e.stopPropagation(),Hw()}),document.getElementById(`workspaceAskBtn`).addEventListener(`click`,e=>{e.stopPropagation(),Gw()}),document.getElementById(`workspaceDownloadDirBtn`).addEventListener(`click`,e=>{e.stopPropagation(),UC()}),document.getElementById(`workspaceBatchDeleteBtn`).addEventListener(`click`,e=>{e.stopPropagation(),Fw()});let n=document.getElementById(`workspaceSearchInput`),r=document.getElementById(`workspaceToolbar`),a=r.querySelector(`.workspace-search-box`);function o(){return r.clientWidth<188}function s(){n.value.trim()?(a.classList.add(`search-box-expanded`),o()&&r.classList.add(`search-focused`)):(a.classList.remove(`search-box-expanded`),r.classList.remove(`search-focused`))}n.addEventListener(`input`,e=>{jw(e),s()}),n.addEventListener(`focus`,()=>{o()&&r.classList.add(`search-focused`)}),n.addEventListener(`blur`,()=>{n.value.trim()||r.classList.remove(`search-focused`)}),n.addEventListener(`keydown`,e=>{if(e.key===`Enter`)e.stopPropagation(),Mw();else if(e.key===`Escape`)e.stopPropagation(),Nw();else if(e.key===`ArrowUp`){if(e.preventDefault(),Dw.length===0)return;Ow===-1?Ow=Dw.length-1:Ow>0&&Ow--,n.value=Dw[Ow],ww=n.value.trim(),document.getElementById(`workspaceSearchClear`).style.display=ww?``:`none`}else e.key===`ArrowDown`&&(e.preventDefault(),Ow===-1||Ow>=Dw.length-1?(Ow=-1,n.value=``,ww=``,document.getElementById(`workspaceSearchClear`).style.display=`none`):(Ow++,n.value=Dw[Ow],ww=n.value.trim(),document.getElementById(`workspaceSearchClear`).style.display=ww?``:`none`))}),document.getElementById(`workspaceSearchBtn`).addEventListener(`click`,()=>{n.focus(),Mw()}),document.getElementById(`workspaceSearchClear`).addEventListener(`click`,Nw),document.getElementById(`workspacePanel`).querySelectorAll(`.workspace-file-header .sortable`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.sort;lx.field===t?lx.asc=!lx.asc:(lx.field=t,lx.asc=!0),fS(),eS()})}),document.getElementById(`workspaceSelectAll`).addEventListener(`click`,uS),document.getElementById(`workspacePanelContent`).addEventListener(`click`,sS),document.getElementById(`workspacePanelContent`).addEventListener(`dblclick`,cS),document.getElementById(`workspacePanelContent`).addEventListener(`keydown`,oS),document.getElementById(`workspacePanelContent`).tabIndex=0,document.getElementById(`workspacePanelContent`).addEventListener(`dragstart`,aS);let c=null;document.getElementById(`workspacePanelContent`).addEventListener(`scroll`,()=>{Xx&&(c&&cancelAnimationFrame(c),c=requestAnimationFrame(()=>{c=null,document.getElementById(`workspacePanelContent`).scrollTop!==Zx&&$x()}))}),document.getElementById(`workspacePreviewClose`).addEventListener(`click`,()=>FC()),document.getElementById(`workspacePreviewCopyBtn`).addEventListener(`click`,e=>wC(e)),document.getElementById(`workspacePreviewDownloadBtn`).addEventListener(`click`,DC),document.getElementById(`workspacePreviewOpenBrowserBtn`).addEventListener(`click`,OC),document.getElementById(`workspacePreviewFullscreenBtn`).addEventListener(`click`,AC),document.getElementById(`workspacePreviewMdToggleBtn`).addEventListener(`click`,jC),document.getElementById(`workspacePreviewEditBtn`).addEventListener(`click`,IC),document.getElementById(`workspacePreviewSaveBtn`).addEventListener(`click`,LC),document.getElementById(`workspacePreviewCancelBtn`).addEventListener(`click`,RC),pC(),document.addEventListener(`keydown`,VC),document.getElementById(`workspacePreviewFilename`).addEventListener(`click`,async e=>{let t=document.getElementById(`workspacePreviewArea`),n=t.dataset.previewName,r=t.dataset.previewPath;if(n){if((e.ctrlKey||e.metaKey)&&!e.shiftKey){e.preventDefault();try{await navigator.clipboard.writeText(n),U(i(`workspace.copiedFileName`,{name:n}))}catch{U(i(`workspace.copyFailed`),`error`)}}else if((e.ctrlKey||e.metaKey)&&e.shiftKey){if(e.preventDefault(),!r)return;try{await navigator.clipboard.writeText(r),U(i(`workspace.copiedPath`,{path:r}))}catch{U(i(`workspace.copyFailed`),`error`)}}}}),iw(),chrome.storage.local.onChanged.addListener(ow);let l=document.createElement(`input`);l.type=`file`,l.multiple=!0,l.id=`workspaceFileInput`,l.style.display=`none`,l.addEventListener(`change`,KC),document.body.appendChild(l)}var _x=[];function vx(e){Yb.push(e),Yb.length>Xb&&Yb.shift()}function yx(e){if(!e||typeof e!=`string`)return`unnamed`;let t=e.replace(/[<>:"|?*\\/\x00-\x1f]/g,`_`);return t=t.replace(/\.+$/,``),t=t.trim(),t||=`unnamed`,t}function bx(e,t){let n=$(e);if(!t)return n;let r=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return n.replace(RegExp(`(${r})`,`gi`),`<mark class="search-highlight">$1</mark>`)}var xx=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M15 3v18"/></svg>`,Sx=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M15 3v18"/><path d="m8 9-3 3 3 3"/></svg>`;function Cx(){let e=document.getElementById(`mainRow`),t=e?e.clientWidth:window.innerWidth;return Math.max(Zb,t-Qb)}function wx(e){return Math.max(Zb,Math.min(e,Cx()))}function Tx(e){let t=document.getElementById(`workspacePanelModeBtn`);t&&(t.title=i(e?`workspace.floatMode`:`workspace.embedMode`),t.innerHTML=e?Sx:xx)}function Ex(){let e=document.getElementById(`workspacePanelContainer`);if(!e)return;let t=document.getElementById(`mainRow`);t&&e.parentElement!==t&&t.appendChild(e),e.classList.add(`embedded`),e.style.setProperty(`--ws-embed-width`,`${ax}px`),Tx(!0)}function Dx(){let e=document.getElementById(`workspacePanelContainer`);if(!e)return;e.classList.remove(`embedded`);let t=gt(`workspace`);t&&e.parentElement!==t&&t.appendChild(e),Tx(!1)}async function Ox(){try{await chrome.storage.local.set({[tx]:ix,[nx]:ax})}catch(e){o.warn(`[WorkspacePanel] persist embed state failed`,e)}}async function kx(){if(ix){ix=!1,sx=!1,ox=!1,Dx(),await Ox();return}let e=document.getElementById(`mainRow`);if((e?e.clientWidth:window.innerWidth)<$b){U(i(`workspace.narrowViewportHint`),`error`);return}document.getElementById(`workspacePanel`).classList.contains(`expanded`)||await Fx(),ax=wx(ax),Ex(),ix=!0,sx=!0,ox=!1,await Ox()}function Ax(){let e=document.getElementById(`workspacePanelContainer`),t=document.createElement(`div`);t.className=`workspace-embed-divider`,t.id=`workspaceEmbedDivider`,e.appendChild(t),t.addEventListener(`mousedown`,t=>{t.preventDefault();let n=t.clientX,r=ax;e.classList.add(`resizing`);function i(t){let i=wx(r+(n-t.clientX));ax=i,e.style.setProperty(`--ws-embed-width`,`${i}px`)}function a(){document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,a),e.classList.remove(`resizing`),Ox()}document.addEventListener(`mousemove`,i),document.addEventListener(`mouseup`,a)})}function jx(){let e=document.getElementById(`mainRow`);!e||typeof ResizeObserver>`u`||new ResizeObserver(()=>{if(ix){e.clientWidth<$b&&(ox=!1,ix=!1,sx=!1,Dx(),Ox(),U(i(`workspace.narrowViewportHint`),`error`));return}ox&&e.clientWidth>=$b&&Nx()}).observe(e)}async function Mx(){if(ix)return!0;let e=document.getElementById(`workspacePanelContainer`);if(e&&e.style.display===`none`)return!1;let t=document.getElementById(`mainRow`);return(t?t.clientWidth:window.innerWidth)<$b?!1:(ax=wx(ax),document.getElementById(`workspacePanel`).classList.contains(`expanded`)||await Fx(),Ex(),ix=!0,!0)}function Nx(){ox=!1,Mx().then(e=>{e||(ox=!0)}).catch(e=>{o.warn(`[WorkspacePanel] deferred embed restore failed`,e),ox=!0})}async function Px(){try{let e=await chrome.storage.local.get([tx,nx,rx]);if(typeof e[nx]==`number`&&e[nx]>=Zb&&(ax=Math.round(e[nx])),!e[tx]||(sx=!0,e[rx]===!1)||(await new Promise(e=>{let t=!1,n=()=>{t||(t=!0,e())};requestAnimationFrame(()=>requestAnimationFrame(n)),setTimeout(n,500)}),await Mx()))return;ox=!0}catch(e){o.warn(`[WorkspacePanel] restore embed state failed`,e)}}async function Fx(){let e=document.getElementById(`workspacePanel`);e.classList.contains(`expanded`)||(e.classList.add(`expanded`),et(e),chrome.storage.local.set({[rx]:!0}).catch(()=>{}),await aw(),qb||await Lx())}function Ix(){Cw()}async function Lx(){let e=await jl();if(!e){dw(i(`workspace.noWorkspace`));return}Jb=e,Yb=[],Rx(e)}async function Rx(e){qb=e,ux.clear(),lw(),uw(),Jw(),fS(),Ew&&ww?(Tw=await Ul(e,ww),eS()):await Wx(e),dS()}var zx=new Map,Bx=3e4,Vx=20;function Hx(e){let t=zx.get(e);return t?Date.now()-t.timestamp>=Bx?(zx.delete(e),null):(zx.delete(e),zx.set(e,t),t):null}function Ux(e,t){zx.has(e)&&zx.delete(e),zx.set(e,t),zx.size>Vx&&zx.delete(zx.keys().next().value)}async function Wx(e){let t=document.getElementById(`workspacePanelContent`);t.innerHTML=`<div class="workspace-panel-loading">${i(`common.loading`)}</div>`;let n=Hx(e);if(n){_x=n.entries,eS();return}let r=await Rl(e);if(!r.success){dw(r.error||i(`workspace.loadDirFailed`));return}_x=(r.entries||[]).map(t=>({...t,path:Gx(`${e}/${t.name}`)})),Ux(e,{entries:_x,timestamp:Date.now()}),eS()}function Gx(e){return(e||``).replace(/\\/g,`/`).replace(/\/+/g,`/`)}function Kx(e){zx.delete(e)}var qx=200,Jx=32,Yx=5,Xx=null,Zx=0;function Qx(e){let t=yl(e.name,e.type),n=e.type===`directory`?`—`:bl(e.size),r=xl(e.mtime),a=e.type===`file`&&Sl(e.name),o=Ew?e.fullPath:Gx(`${qb}/${e.name}`),s=ux.has(o),c=Ew&&e.matchPath!==qb?Gx(e.matchPath).replace(Gx(Jb),``).replace(/^\//,``)+`/`+e.name:``,l=Ew?bx(e.name,ww):$(e.name);return`
|
|
1166
|
+
`,gt(`workspace`).appendChild(e),gx(),Aw(),ow(),Ax(),jx(),Px(),o.debug(`[WorkspacePanel] workspace panelinitializing`)}function gx(){document.getElementById(`workspacePanelContainer`);let e=document.getElementById(`workspacePanel`);document.getElementById(`workspacePanelToggle`).addEventListener(`click`,async t=>{t.stopPropagation(),e.classList.contains(`expanded`)?Lx():await Ix()}),document.getElementById(`workspacePanelClose`).addEventListener(`click`,e=>{e.stopPropagation(),Lx()}),document.getElementById(`workspacePanelModeBtn`).addEventListener(`click`,async e=>{e.stopPropagation(),await kx()});let t=document.getElementById(`workspaceSwitchBtn`);t&&t.addEventListener(`click`,async e=>{e.stopPropagation(),await Bw()}),document.getElementById(`workspaceBackBtn`).addEventListener(`click`,e=>{e.stopPropagation(),cw()}),document.getElementById(`workspaceRefreshBtn`).addEventListener(`click`,e=>{e.stopPropagation(),lw()}),document.getElementById(`workspaceUploadBtn`).addEventListener(`click`,e=>{e.stopPropagation(),KC()}),document.getElementById(`workspaceNewFolderBtn`).addEventListener(`click`,e=>{e.stopPropagation(),Uw()}),document.getElementById(`workspaceAskBtn`).addEventListener(`click`,e=>{e.stopPropagation(),Kw()}),document.getElementById(`workspaceDownloadDirBtn`).addEventListener(`click`,e=>{e.stopPropagation(),WC()}),document.getElementById(`workspaceBatchDeleteBtn`).addEventListener(`click`,e=>{e.stopPropagation(),Iw()});let n=document.getElementById(`workspaceSearchInput`),r=document.getElementById(`workspaceToolbar`),a=r.querySelector(`.workspace-search-box`);function o(){return r.clientWidth<188}function s(){n.value.trim()?(a.classList.add(`search-box-expanded`),o()&&r.classList.add(`search-focused`)):(a.classList.remove(`search-box-expanded`),r.classList.remove(`search-focused`))}n.addEventListener(`input`,e=>{Mw(e),s()}),n.addEventListener(`focus`,()=>{o()&&r.classList.add(`search-focused`)}),n.addEventListener(`blur`,()=>{n.value.trim()||r.classList.remove(`search-focused`)}),n.addEventListener(`keydown`,e=>{if(e.key===`Enter`)e.stopPropagation(),Nw();else if(e.key===`Escape`)e.stopPropagation(),Pw();else if(e.key===`ArrowUp`){if(e.preventDefault(),Ow.length===0)return;kw===-1?kw=Ow.length-1:kw>0&&kw--,n.value=Ow[kw],Tw=n.value.trim(),document.getElementById(`workspaceSearchClear`).style.display=Tw?``:`none`}else e.key===`ArrowDown`&&(e.preventDefault(),kw===-1||kw>=Ow.length-1?(kw=-1,n.value=``,Tw=``,document.getElementById(`workspaceSearchClear`).style.display=`none`):(kw++,n.value=Ow[kw],Tw=n.value.trim(),document.getElementById(`workspaceSearchClear`).style.display=Tw?``:`none`))}),document.getElementById(`workspaceSearchBtn`).addEventListener(`click`,()=>{n.focus(),Nw()}),document.getElementById(`workspaceSearchClear`).addEventListener(`click`,Pw),document.getElementById(`workspacePanel`).querySelectorAll(`.workspace-file-header .sortable`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.sort;lx.field===t?lx.asc=!lx.asc:(lx.field=t,lx.asc=!0),pS(),tS()})}),document.getElementById(`workspaceSelectAll`).addEventListener(`click`,dS),document.getElementById(`workspacePanelContent`).addEventListener(`click`,cS),document.getElementById(`workspacePanelContent`).addEventListener(`dblclick`,lS),document.getElementById(`workspacePanelContent`).addEventListener(`keydown`,sS),document.getElementById(`workspacePanelContent`).tabIndex=0,document.getElementById(`workspacePanelContent`).addEventListener(`dragstart`,oS);let c=null;document.getElementById(`workspacePanelContent`).addEventListener(`scroll`,()=>{Zx&&(c&&cancelAnimationFrame(c),c=requestAnimationFrame(()=>{c=null,document.getElementById(`workspacePanelContent`).scrollTop!==Qx&&eS()}))}),document.getElementById(`workspacePreviewClose`).addEventListener(`click`,()=>IC()),document.getElementById(`workspacePreviewCopyBtn`).addEventListener(`click`,e=>TC(e)),document.getElementById(`workspacePreviewDownloadBtn`).addEventListener(`click`,OC),document.getElementById(`workspacePreviewOpenBrowserBtn`).addEventListener(`click`,kC),document.getElementById(`workspacePreviewFullscreenBtn`).addEventListener(`click`,jC),document.getElementById(`workspacePreviewMdToggleBtn`).addEventListener(`click`,MC),document.getElementById(`workspacePreviewEditBtn`).addEventListener(`click`,LC),document.getElementById(`workspacePreviewSaveBtn`).addEventListener(`click`,RC),document.getElementById(`workspacePreviewCancelBtn`).addEventListener(`click`,zC),mC(),document.addEventListener(`keydown`,HC),document.getElementById(`workspacePreviewFilename`).addEventListener(`click`,async e=>{let t=document.getElementById(`workspacePreviewArea`),n=t.dataset.previewName,r=t.dataset.previewPath;if(n){if((e.ctrlKey||e.metaKey)&&!e.shiftKey){e.preventDefault();try{await navigator.clipboard.writeText(n),U(i(`workspace.copiedFileName`,{name:n}))}catch{U(i(`workspace.copyFailed`),`error`)}}else if((e.ctrlKey||e.metaKey)&&e.shiftKey){if(e.preventDefault(),!r)return;try{await navigator.clipboard.writeText(r),U(i(`workspace.copiedPath`,{path:r}))}catch{U(i(`workspace.copyFailed`),`error`)}}}}),aw(),chrome.storage.local.onChanged.addListener(sw);let l=document.createElement(`input`);l.type=`file`,l.multiple=!0,l.id=`workspaceFileInput`,l.style.display=`none`,l.addEventListener(`change`,qC),document.body.appendChild(l)}var _x=[];function vx(e){Yb.push(e),Yb.length>Xb&&Yb.shift()}function yx(e){if(!e||typeof e!=`string`)return`unnamed`;let t=e.replace(/[<>:"|?*\\/\x00-\x1f]/g,`_`);return t=t.replace(/\.+$/,``),t=t.trim(),t||=`unnamed`,t}function bx(e,t){let n=$(e);if(!t)return n;let r=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return n.replace(RegExp(`(${r})`,`gi`),`<mark class="search-highlight">$1</mark>`)}var xx=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M15 3v18"/></svg>`,Sx=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M15 3v18"/><path d="m8 9-3 3 3 3"/></svg>`;function Cx(){let e=document.getElementById(`mainRow`),t=e?e.clientWidth:window.innerWidth;return Math.max(Zb,t-Qb)}function wx(e){return Math.max(Zb,Math.min(e,Cx()))}function Tx(e){let t=document.getElementById(`workspacePanelModeBtn`);t&&(t.title=i(e?`workspace.floatMode`:`workspace.embedMode`),t.innerHTML=e?Sx:xx)}function Ex(){let e=document.getElementById(`workspacePanelContainer`);if(!e)return;let t=document.getElementById(`mainRow`);t&&e.parentElement!==t&&t.appendChild(e),e.classList.add(`embedded`),e.style.setProperty(`--ws-embed-width`,`${ax}px`),Tx(!0)}function Dx(){let e=document.getElementById(`workspacePanelContainer`);if(!e)return;e.classList.remove(`embedded`);let t=gt(`workspace`);t&&e.parentElement!==t&&t.appendChild(e),Tx(!1)}async function Ox(){try{await chrome.storage.local.set({[tx]:ix,[nx]:ax})}catch(e){o.warn(`[WorkspacePanel] persist embed state failed`,e)}}async function kx(){if(ix){ix=!1,sx=!1,ox=!1,Dx(),await Ox();return}let e=document.getElementById(`mainRow`);if((e?e.clientWidth:window.innerWidth)<$b){U(i(`workspace.narrowViewportHint`),`error`);return}document.getElementById(`workspacePanel`).classList.contains(`expanded`)||await Fx(),ax=wx(ax),Ex(),ix=!0,sx=!0,ox=!1,await Ox()}function Ax(){let e=document.getElementById(`workspacePanelContainer`),t=document.createElement(`div`);t.className=`workspace-embed-divider`,t.id=`workspaceEmbedDivider`,e.appendChild(t),t.addEventListener(`mousedown`,t=>{t.preventDefault();let n=t.clientX,r=ax;e.classList.add(`resizing`);function i(t){let i=wx(r+(n-t.clientX));ax=i,e.style.setProperty(`--ws-embed-width`,`${i}px`)}function a(){document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,a),e.classList.remove(`resizing`),Ox()}document.addEventListener(`mousemove`,i),document.addEventListener(`mouseup`,a)})}function jx(){let e=document.getElementById(`mainRow`);!e||typeof ResizeObserver>`u`||new ResizeObserver(()=>{if(ix){e.clientWidth<$b&&(ox=!1,ix=!1,sx=!1,Dx(),Ox(),U(i(`workspace.narrowViewportHint`),`error`));return}ox&&e.clientWidth>=$b&&Nx()}).observe(e)}async function Mx(){if(ix)return!0;let e=document.getElementById(`workspacePanelContainer`);if(e&&e.style.display===`none`)return!1;let t=document.getElementById(`mainRow`);return(t?t.clientWidth:window.innerWidth)<$b?!1:(ax=wx(ax),document.getElementById(`workspacePanel`).classList.contains(`expanded`)||await Fx(),Ex(),ix=!0,!0)}function Nx(){ox=!1,Mx().then(e=>{e||(ox=!0)}).catch(e=>{o.warn(`[WorkspacePanel] deferred embed restore failed`,e),ox=!0})}async function Px(){try{let e=await chrome.storage.local.get([tx,nx,rx]);if(typeof e[nx]==`number`&&e[nx]>=Zb&&(ax=Math.round(e[nx])),!e[tx]||(sx=!0,e[rx]===!1)||(await new Promise(e=>{let t=!1,n=()=>{t||(t=!0,e())};requestAnimationFrame(()=>requestAnimationFrame(n)),setTimeout(n,500)}),await Mx()))return;ox=!0}catch(e){o.warn(`[WorkspacePanel] restore embed state failed`,e)}}async function Fx(){let e=document.getElementById(`workspacePanel`);e.classList.contains(`expanded`)||(e.classList.add(`expanded`),et(e),chrome.storage.local.set({[rx]:!0}).catch(()=>{}),await ow(),qb||await Rx())}async function Ix(){let e=document.getElementById(`workspacePanel`);if(!(!e||e.classList.contains(`expanded`))){if(mx=!1,sx){let e=document.getElementById(`mainRow`);if((e?e.clientWidth:window.innerWidth)<$b){await Fx(),U(i(`workspace.narrowViewportHint`),`error`);return}await Fx(),ax=wx(ax),Ex(),ix=!0,ox=!1,await Ox()}else await Fx()}}function Lx(){ww()}async function Rx(){let e=await jl();if(!e){fw(i(`workspace.noWorkspace`));return}Jb=e,Yb=[],zx(e)}async function zx(e){qb=e,ux.clear(),uw(),dw(),Yw(),pS(),Dw&&Tw?(Ew=await Ul(e,Tw),tS()):await Gx(e),fS()}var Bx=new Map,Vx=3e4,Hx=20;function Ux(e){let t=Bx.get(e);return t?Date.now()-t.timestamp>=Vx?(Bx.delete(e),null):(Bx.delete(e),Bx.set(e,t),t):null}function Wx(e,t){Bx.has(e)&&Bx.delete(e),Bx.set(e,t),Bx.size>Hx&&Bx.delete(Bx.keys().next().value)}async function Gx(e){let t=document.getElementById(`workspacePanelContent`);t.innerHTML=`<div class="workspace-panel-loading">${i(`common.loading`)}</div>`;let n=Ux(e);if(n){_x=n.entries,tS();return}let r=await Rl(e);if(!r.success){fw(r.error||i(`workspace.loadDirFailed`));return}_x=(r.entries||[]).map(t=>({...t,path:Kx(`${e}/${t.name}`)})),Wx(e,{entries:_x,timestamp:Date.now()}),tS()}function Kx(e){return(e||``).replace(/\\/g,`/`).replace(/\/+/g,`/`)}function qx(e){Bx.delete(e)}var Jx=200,Yx=32,Xx=5,Zx=null,Qx=0;function $x(e){let t=yl(e.name,e.type),n=e.type===`directory`?`—`:bl(e.size),r=xl(e.mtime),a=e.type===`file`&&Sl(e.name),o=Dw?e.fullPath:Kx(`${qb}/${e.name}`),s=ux.has(o),c=Dw&&e.matchPath!==qb?Kx(e.matchPath).replace(Kx(Jb),``).replace(/^\//,``)+`/`+e.name:``,l=Dw?bx(e.name,Tw):$(e.name);return`
|
|
1161
1167
|
<div class="workspace-file-item ${e.type} ${s?`selected`:``}" data-path="${$(o)}" data-type="${e.type}" data-name="${$(e.name)}" draggable="true">
|
|
1162
1168
|
<span class="workspace-file-select" data-action="select">
|
|
1163
1169
|
<span class="workspace-checkbox ${s?`checked`:``}"></span>
|
|
@@ -1174,8 +1180,8 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1174
1180
|
<button class="workspace-file-btn ask" title="${i(`workspace.askFile`)}" data-action="ask"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="13" height="13"><circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg></button>
|
|
1175
1181
|
<button class="workspace-file-btn delete" title="${i(`workspace.delete`)}" data-action="delete"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="13" height="13"><path d="M3 6h18M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg></button>
|
|
1176
1182
|
</span>
|
|
1177
|
-
</div>`}function
|
|
1178
|
-
`);s.textContent=i(`workspace.lineCount`,{count:m.length});let h=m.length>
|
|
1183
|
+
</div>`}function eS(){if(!Zx)return;let{sorted:e}=Zx,t=document.getElementById(`workspacePanelContent`),n=t.clientHeight,r=t.scrollTop,i=Zx.itemHeight,a=Math.max(0,Math.floor(r/i)-Xx),o=Math.min(e.length,Math.ceil((r+n)/i)+Xx),s=`<div class="workspace-file-list" style="padding-top:${a*i}px;padding-bottom:${(e.length-o)*i}px;">`;for(let t=a;t<o;t++)s+=$x(e[t]);s+=`</div>`,t.innerHTML=s;let c=t.querySelector(`.workspace-file-item`);if(c){let a=c.offsetHeight;if(a&&Math.abs(a-i)>2){Zx.itemHeight=a;let i=Math.max(0,Math.floor(r/a)-Xx),o=Math.min(e.length,Math.ceil((r+n)/a)+Xx),s=`<div class="workspace-file-list" style="padding-top:${i*a}px;padding-bottom:${(e.length-o)*a}px;">`;for(let t=i;t<o;t++)s+=$x(e[t]);s+=`</div>`,t.innerHTML=s}}rS(),$C(),Qx=t.scrollTop}function tS(){let e=document.getElementById(`workspacePanelContent`),t=[];if(t=Dw?Ew:[..._x],t.length===0){Zx=null,e.innerHTML=Dw?`<div class="workspace-panel-empty">${i(`workspace.noMatch`)}</div>`:`<div class="workspace-panel-empty">${i(`workspace.dirEmpty`)}</div>`;return}let n=t.filter(e=>e.type===`directory`),r=t.filter(e=>e.type!==`directory`),a=(e,t)=>{let n;if(lx.field===`name`)n=e.name.localeCompare(t.name);else if(lx.field===`size`){if(e.type===`directory`&&t.type!==`directory`)return lx.asc?-1:1;if(e.type!==`directory`&&t.type===`directory`)return lx.asc?1:-1;n=(e.size||0)-(t.size||0)}else n=(e.mtime||0)-(t.mtime||0);return lx.asc?n:-n},o=n.sort(a),s=r.sort(a),c;if(c=lx.field===`name`?lx.asc?[...o,...s]:[...s.reverse(),...o.reverse()]:[...o,...s],px=-1,c.length>Jx){Zx={sorted:c,itemHeight:Yx},e.scrollTop=0,eS();return}Zx=null;let l=`<div class="workspace-file-list">`;for(let e of c)l+=$x(e);l+=`</div>`,e.innerHTML=l}function nS(){let e=document.getElementById(`workspacePanelContent`);return e?Array.from(e.querySelectorAll(`.workspace-file-item`)):[]}function rS(){let e=document.getElementById(`workspacePanelContent`);if(Zx&&px>=0){let{sorted:t,itemHeight:n}=Zx;if(px>=t.length)return;let r=e.scrollTop,i=e.clientHeight,a=px*n,o=a+n;if(a<r||o>r+i){e.scrollTop=Math.max(0,a-(i-n)/2),eS();return}}let t=nS();if(t.forEach(e=>e.classList.remove(`keyboard-focused`)),!(px<0)){if(Zx){let e=Zx.sorted[px];if(!e)return;let n=Dw?e.fullPath:Kx(`${qb}/${e.name}`),r=t.find(e=>e.dataset.path===n);r&&r.classList.add(`keyboard-focused`)}else px<t.length&&(t[px].classList.add(`keyboard-focused`),t[px].scrollIntoView({block:`nearest`,behavior:`smooth`}))}}function iS(e){let t=nS();t.length!==0&&(px=px===-1?e>0?0:t.length-1:Math.max(0,Math.min(t.length-1,px+e)),rS())}function aS(){let e=nS();if(px<0||px>=e.length)return null;let t=e[px];return{el:t,path:t.dataset.path,name:t.dataset.name,type:t.dataset.type}}function oS(e){let t=e.target.closest(`.workspace-file-item`);if(!t)return;let n=t.dataset.path,r=t.dataset.type;n&&(e.dataTransfer.effectAllowed=`copy`,e.dataTransfer.setData(`application/x-workspace-file`,JSON.stringify({path:n,name:t.dataset.name,type:r})))}async function sS(e){let t=e.target.tagName;if(t!==`INPUT`&&t!==`TEXTAREA`)switch(e.key){case`ArrowDown`:e.preventDefault(),iS(1);break;case`ArrowUp`:e.preventDefault(),iS(-1);break;case`Enter`:{e.preventDefault();let t=aS();if(!t)return;t.type===`directory`?(vx(qb),await zx(t.path)):await TS(t.path,t.name);break}case`Delete`:{e.preventDefault();let t=aS();if(!t)return;await Fw(t.path,t.name,t.type);break}case`F2`:{e.preventDefault();let t=aS();if(!t)return;await Hw(t.path,t.name,t.type);break}case` `:{e.preventDefault();let t=aS();if(!t)return;uS(t.path),iS(1);break}case`Escape`:px=-1,rS()}}async function cS(e){let t=e.target.closest(`.workspace-file-item`);if(!t)return;mx=!1;let n=t.dataset.path,r=t.dataset.type,a=e.target.closest(`[data-action]`),o=nS().indexOf(t);if(o>=0&&(px=o,rS()),e.target.closest(`.workspace-file-select`)){e.stopPropagation(),uS(n);return}if(a){let i=a.dataset.action;e.stopPropagation(),i===`preview`?await TS(n,t.dataset.name):i===`info`?await Rw(n,t.dataset.name,r):i===`download`?await UC(n,t.dataset.name):i===`ask`?await Gw([n]):i===`delete`?await Fw(n,t.dataset.name,r):i===`rename`&&await Hw(n,t.dataset.name,r);return}if((e.ctrlKey||e.metaKey)&&!e.shiftKey){e.stopPropagation(),navigator.clipboard.writeText(t.dataset.name).then(()=>{U(i(`workspace.copiedFileName`,{name:t.dataset.name}))}).catch(()=>{U(i(`workspace.copyFailed`),`error`)});return}if((e.ctrlKey||e.metaKey)&&e.shiftKey){e.stopPropagation(),navigator.clipboard.writeText(n).then(()=>{U(i(`workspace.copiedPath`,{path:n}))}).catch(()=>{U(i(`workspace.copyFailed`),`error`)});return}if(r===`directory`){e.stopPropagation(),vx(qb),await zx(n);return}}async function lS(e){let t=e.target.closest(`.workspace-file-item`);if(!t)return;mx=!1;let n=t.dataset.path,r=t.dataset.type,i=t.dataset.name;if(!e.target.closest(`[data-action]`)&&!e.target.closest(`.workspace-file-select`)){if(r===`directory`){e.stopPropagation(),vx(qb),await zx(n);return}r===`file`&&Sl(i)&&(e.stopPropagation(),await TS(n,i))}}function uS(e){ux.has(e)?ux.delete(e):ux.add(e),Yw(),fS();let t=Array.from(document.querySelectorAll(`.workspace-file-item`)).find(t=>t.dataset.path===e);if(t){let n=ux.has(e);t.classList.toggle(`selected`,n);let r=t.querySelector(`.workspace-checkbox`);r&&r.classList.toggle(`checked`,n)}}function dS(){let e=(Dw?Ew:_x).map(e=>Dw?e.fullPath:Kx(`${qb}/${e.name}`));if(e.length>0&&e.every(e=>ux.has(e)))for(let t of e)ux.delete(t);else for(let t of e)ux.add(t);Yw(),fS();for(let e of document.querySelectorAll(`.workspace-file-item`)){let t=ux.has(e.dataset.path);e.classList.toggle(`selected`,t);let n=e.querySelector(`.workspace-checkbox`);n&&n.classList.toggle(`checked`,t)}}function fS(){let e=(Dw?Ew:_x).map(e=>Dw?e.fullPath:Kx(`${qb}/${e.name}`)),t=document.getElementById(`workspaceSelectAll`);if(!t)return;let n=t.querySelector(`.workspace-checkbox`);e.length===0?(n.classList.remove(`checked`),n.classList.remove(`indeterminate`)):e.every(e=>ux.has(e))?(n.classList.add(`checked`),n.classList.remove(`indeterminate`)):e.some(e=>ux.has(e))?(n.classList.remove(`checked`),n.classList.add(`indeterminate`)):(n.classList.remove(`checked`),n.classList.remove(`indeterminate`))}function pS(){[`name`,`size`,`time`].forEach(e=>{let t=document.getElementById(`sort${e.charAt(0).toUpperCase()+e.slice(1)}Indicator`);t&&(t.textContent=lx.field===e?lx.asc?`▲`:`▼`:``)})}var mS=1048576,hS=52428800,gS=20971520,_S=52428800,vS=52428800,yS=52428800,bS=209715200,xS=104857600,SS=1e4,CS=2e3;async function wS(e){let t=await Al();if(!t)throw Error(i(`workspace.agentNotPaired`));let n=await fetch(`${t.url}/api/fs/download-stream`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${t.token}`},body:JSON.stringify({path:e})});if(!n.ok){let e=await n.text().catch(()=>n.statusText);throw Error(typeof e==`string`?e:`HTTP ${n.status}`)}let r=n.body.getReader(),a=[];for(;;){let{done:e,value:t}=await r.read();if(e)break;a.push(t)}let o=a.reduce((e,t)=>e+t.length,0),s=new Uint8Array(o),c=0;for(let e of a)s.set(e,c),c+=e.length;return s.buffer}async function TS(e,t){let n=document.getElementById(`workspacePreviewArea`),r=document.getElementById(`workspacePreviewContent`),a=document.getElementById(`workspacePreviewFilename`),s=document.getElementById(`workspacePreviewLineCount`),c=document.getElementById(`workspacePreviewCopyBtn`),l=document.getElementById(`workspacePreviewDownloadBtn`),u=document.getElementById(`workspacePreviewOpenBrowserBtn`),d=document.getElementById(`workspacePreviewFullscreenBtn`),f=document.getElementById(`workspacePreviewMdToggleBtn`);a.textContent=t,s.textContent=``,r.classList.remove(`xlsx-mode`),r.classList.remove(`markdown-rendered`),r.innerHTML=`<div class="workspace-panel-loading">${i(`common.loading`)}</div>`,n.style.display=`flex`,c.style.display=``,l.style.display=``,u.style.display=`none`,d.style.display=`none`,f.style.display=`none`,f.classList.remove(`active`),AC(f,!1);let p=document.getElementById(`workspacePreviewEditBtn`),m=document.getElementById(`workspacePreviewSaveBtn`),h=document.getElementById(`workspacePreviewCancelBtn`);p.style.display=`none`,m.style.display=`none`,h.style.display=`none`,delete n.dataset.editMode,delete n.dataset.origContent,n.classList.remove(`has-unsaved`),a.classList.remove(`modified`),n.classList.remove(`fullscreen`),document.getElementById(`workspacePanel`).classList.remove(`preview-fullscreen`),n.dataset.previewPath=e,n.dataset.previewName=t,delete n.dataset.previewType,delete n.dataset.previewSheets;let g=Cl(t),_=_x.find(t=>t.path===e)||Ew.find(t=>t.fullPath===e),v=_?_.size:0;if(g===`text`){if(c.style.display=``,v>mS){r.innerHTML=`<div class="workspace-panel-error">${i(`workspace.fileTooLargeNoPreview`,{size:bl(v)})}</div>`;return}p.style.display=``,d.style.display=``;let a=(t.split(`.`).pop()||``).toLowerCase(),o=await zl(e);if(!o.success){r.innerHTML=`<div class="workspace-panel-error">${i(`workspace.previewFailed`,{error:$(o.error||i(`workspace.unknownError`))})}</div>`;return}let l=o.content||``;if(n.dataset.origContent=l,a===`md`||a===`markdown`){f.style.display=``,n.dataset.markdownText=l,r.classList.add(`markdown-rendered`),f.classList.add(`active`),f.title=i(`workspace.switchToSourcePreview`),AC(f,!0),c.style.display=``;let e=document.getElementById(`workspacePreviewDownloadBtn`);e&&(e.style.display=`none`);let t=document.getElementById(`workspacePreviewExportMenu`);t&&(t.style.display=``),r.innerHTML=`<div class="markdown-body workspace-preview-markdown">${Ei(l)}</div>`,PC(r),FC(r),Ji(),s.textContent=``,NC(!0);return}let u=pw(t),m=l.split(`
|
|
1184
|
+
`);s.textContent=i(`workspace.lineCount`,{count:m.length});let h=m.length>SS,g=h?m.slice(0,SS):m,_=`<table class="workspace-preview-code-table"><tbody>`;for(let e=0;e<g.length;e++)_+=`<tr><td class="line-num">${e+1}</td><td class="line-content"><code class="${u}">${$(g[e])}</code></td></tr>`;h&&(_+=`<tr><td class="line-num">…</td><td class="line-content"><code>${i(`workspace.truncatedHint`,{shown:SS,total:m.length})}</code></td></tr>`),_+=`</tbody></table>`,r.innerHTML=_;return}c.style.display=`none`,u.style.display=g===`pdf`||g===`image`?``:`none`;try{if(v>({pdf:hS,docx:gS,pptx:_S,xlsx:vS,image:yS,video:bS,audio:xS}[g]||mS)){r.innerHTML=`<div class="workspace-panel-error">${i(g===`pdf`||g===`image`?`workspace.fileTooLargeOpenInBrowser`:`workspace.fileTooLargeNoPreview`,{size:bl(v)})}</div>`;return}if(g===`xlsx`){d.style.display=``,await aC(t,r,n);return}let a=await wS(e);switch(g){case`pdf`:d.style.display=``,await BS(a,t,r,n);break;case`docx`:d.style.display=``,await VS(a,r);break;case`pptx`:d.style.display=``,await $S(a,t,r,n);break;case`image`:d.style.display=``,await cC(a,t,r);break;case`video`:case`audio`:d.style.display=``,await uC(a,t,g,r,n);break;default:r.innerHTML=`<div class="workspace-panel-error">${i(`workspace.unsupportedFileType`)}</div>`}}catch(t){o.error(`[WorkspacePanel] preview failed:`,e,t);let n=t instanceof Error?t.message:typeof t==`string`?t:String(t);r.innerHTML=`<div class="workspace-panel-error">${i(`workspace.previewFailed`,{error:$(n||i(`workspace.unknownError`))})}</div>`}}var ES=null,DS=1,OS=1,kS=1,AS=1,jS=0,MS=0,NS=!1,PS=0,FS=0,IS=0,LS=0,RS=null,zS=1;async function BS(e,n,r,a){let o=await fe(()=>import(`./pdf-HiJ0icvU.js`).then(e=>t(e.default,1)),__vite__mapDeps([4,1]));o.GlobalWorkerOptions.workerSrc=`libs/pdf.worker.min.js`;let s=await o.getDocument({data:e}).promise;ES=s,DS=1,OS=1,kS=1,AS=1,zS=1,jS=0,MS=0,a.dataset.previewType=`pdf`;let c=s.numPages;document.getElementById(`workspacePreviewLineCount`).textContent=i(`workspace.pageCount`,{count:c}),r.innerHTML=`
|
|
1179
1185
|
<div class="pdf-wrap">
|
|
1180
1186
|
<div class="pdf-toolbar">
|
|
1181
1187
|
<button class="pdf-toolbar-btn" id="pdfPrevPage" title="${i(`workspace.prevPage`)}" disabled>
|
|
@@ -1204,7 +1210,7 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1204
1210
|
</div>
|
|
1205
1211
|
</div>
|
|
1206
1212
|
</div>
|
|
1207
|
-
`;let l=document.getElementById(`pdfViewport`),u=document.getElementById(`pdfPan`),d=document.getElementById(`pdfCanvas`),f=document.getElementById(`pdfZoomInfo`);function p(){u.style.transform=`translate(${
|
|
1213
|
+
`;let l=document.getElementById(`pdfViewport`),u=document.getElementById(`pdfPan`),d=document.getElementById(`pdfCanvas`),f=document.getElementById(`pdfZoomInfo`);function p(){u.style.transform=`translate(${jS}px, ${MS}px) scale(${kS})`,f.textContent=Math.round(OS*100)+`%`,NS||(l.style.cursor=OS>AS?`grab`:`default`)}function m(){OS<=AS&&(jS=0,MS=0)}function h(e,t,n){let r=OS;if(OS=Math.max(.05,Math.min(5,e)),kS=OS/zS,t!==void 0&&n!==void 0){let e=l.getBoundingClientRect(),i=t-e.left-e.width/2,a=n-e.top-e.height/2,o=OS/r;jS=i-o*(i-jS),MS=a-o*(a-MS)}m(),p(),g()}function g(){RS&&clearTimeout(RS),RS=setTimeout(()=>{_()},180)}async function _(){if(!ES)return;let e=await ES.getPage(DS),t=window.devicePixelRatio||1,n=Math.max(OS,1);zS=n;let r=e.getViewport({scale:n});d.width=Math.floor(r.width*t),d.height=Math.floor(r.height*t),d.style.width=r.width+`px`,d.style.height=r.height+`px`;let i=d.getContext(`2d`);i.setTransform(t,0,0,t,0,0),await e.render({canvasContext:i,viewport:r}).promise;let a=e.getViewport({scale:1}),o=l.clientWidth,s=l.clientHeight;AS=o>0&&s>0&&a.width>0&&a.height>0?Math.min((o-24)/a.width,(s-24)/a.height):1,kS=OS/n,OS<AS*1.05&&OS>AS*.95&&(OS=AS,kS=AS/n,jS=0,MS=0),m(),p();let c=document.getElementById(`pdfPrevPage`),u=document.getElementById(`pdfNextPage`),f=document.getElementById(`pdfPageInput`);c&&(c.disabled=DS<=1),u&&(u.disabled=DS>=ES.numPages),f&&(f.value=DS)}await _(),l.addEventListener(`wheel`,e=>{e.preventDefault();let t=-e.deltaY*.005;h(OS+t*OS,e.clientX,e.clientY)},{passive:!1}),l.addEventListener(`mousedown`,e=>{e.button===0&&(NS=!0,PS=e.clientX,FS=e.clientY,IS=jS,LS=MS,l.style.cursor=`grabbing`,e.preventDefault())}),window.addEventListener(`mousemove`,e=>{NS&&(jS=IS+(e.clientX-PS),MS=LS+(e.clientY-FS),m(),p())}),window.addEventListener(`mouseup`,()=>{NS&&(NS=!1,l.style.cursor=OS>AS?`grab`:`default`)}),document.getElementById(`pdfPrevPage`).addEventListener(`click`,()=>{DS>1&&(DS--,_())}),document.getElementById(`pdfNextPage`).addEventListener(`click`,()=>{DS<c&&(DS++,_())}),document.getElementById(`pdfPageInput`).addEventListener(`change`,e=>{let t=parseInt(e.target.value,10);t>=1&&t<=c&&(DS=t,_())}),document.getElementById(`pdfZoomIn`).addEventListener(`click`,()=>{let e=l.getBoundingClientRect();h(OS*1.25,e.left+e.width/2,e.top+e.height/2)}),document.getElementById(`pdfZoomOut`).addEventListener(`click`,()=>{let e=l.getBoundingClientRect();h(OS/1.25,e.left+e.width/2,e.top+e.height/2)}),document.getElementById(`pdfZoomFit`).addEventListener(`click`,()=>{OS=AS,jS=0,MS=0,_()}),l.addEventListener(`dblclick`,()=>{OS=AS,jS=0,MS=0,_()}),window.addEventListener(`resize`,()=>{ES&&_()})}async function VS(e,n){let r=await(await fe(async()=>{let{default:e}=await import(`./lib-Bi7BFuND.js`).then(e=>t(e.default,1));return{default:e}},__vite__mapDeps([5,1,6]))).default.convertToHtml({arrayBuffer:e},{styleMap:[`p[style-name='Heading 1'] => h1:fresh`,`p[style-name='Heading 2'] => h2:fresh`,`p[style-name='Heading 3'] => h3:fresh`,`r[style-name='Strong'] => strong`,`r[style-name='Emphasis'] => em`]}),a=r.value||`<p>${i(`workspace.documentEmpty`)}</p>`,o=ui.sanitize(a,{ALLOWED_TAGS:`h1.h2.h3.h4.h5.h6.p.br.strong.em.u.s.a.img.table.thead.tbody.tr.td.th.ul.ol.li.blockquote.pre.code.hr.sup.sub`.split(`.`),ALLOWED_ATTR:[`href`,`src`,`alt`,`title`,`style`]}),s=r.messages?r.messages.filter(e=>e.type===`error`):[];n.innerHTML=s.length>0?`<div class="workspace-preview-docx">${o}<div class="docx-warnings">${s.map(e=>`<div class="docx-warning">⚠ ${$(e.message)}</div>`).join(``)}</div></div>`:`<div class="workspace-preview-docx">${o}</div>`}var HS=[],US=0,WS=1,GS=1,KS=0,qS=0,JS=!1,YS=0,XS=0,ZS=0,QS=0;async function $S(e,t,n,r){r.dataset.previewType=`pptx`;let{pptxToHtml:a}=await fe(async()=>{let{pptxToHtml:e}=await import(`./dist-BQOFgIxk.js`);return{pptxToHtml:e}},__vite__mapDeps([7,1,6]));if(HS=await a(e,{width:960,height:540,scaleToFit:!0,letterbox:!0}),US=0,WS=1,GS=1,KS=0,qS=0,!HS||HS.length===0){n.innerHTML=`<div class="workspace-panel-error">${i(`workspace.pptxEmptyOrFailed`)}</div>`;return}let o=HS.length;document.getElementById(`workspacePreviewLineCount`).textContent=i(`workspace.pageCount`,{count:o}),n.innerHTML=`
|
|
1208
1214
|
<div class="pptx-wrap">
|
|
1209
1215
|
<div class="pptx-toolbar">
|
|
1210
1216
|
<button class="pptx-toolbar-btn" id="pptxPrevSlide" title="${i(`workspace.prevPage`)}" disabled>
|
|
@@ -1233,7 +1239,7 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1233
1239
|
</div>
|
|
1234
1240
|
</div>
|
|
1235
1241
|
</div>
|
|
1236
|
-
`,
|
|
1242
|
+
`,nC();let s=document.getElementById(`pptxViewport`),c=document.getElementById(`pptxPan`),l=document.getElementById(`pptxZoomInfo`);function u(){c.style.transform=`translate(${KS}px, ${qS}px) scale(${WS})`,l.textContent=Math.round(WS*100)+`%`,JS||(s.style.cursor=WS>GS?`grab`:`default`)}function d(){WS<=GS&&(KS=0,qS=0)}function f(e,t,n){let r=WS;if(WS=Math.max(.05,Math.min(5,e)),t!==void 0&&n!==void 0){let e=s.getBoundingClientRect(),i=t-e.left-e.width/2,a=n-e.top-e.height/2,o=WS/r;KS=i-o*(i-KS),qS=a-o*(a-qS)}WS<GS*1.05&&WS>GS*.95&&(WS=GS,KS=0,qS=0),d(),u()}s.addEventListener(`wheel`,e=>{e.preventDefault();let t=-e.deltaY*.005;f(WS+t*WS,e.clientX,e.clientY)},{passive:!1}),s.addEventListener(`mousedown`,e=>{e.button===0&&(JS=!0,YS=e.clientX,XS=e.clientY,ZS=KS,QS=qS,s.style.cursor=`grabbing`,e.preventDefault())}),window.addEventListener(`mousemove`,e=>{JS&&(KS=ZS+(e.clientX-YS),qS=QS+(e.clientY-XS),d(),u())}),window.addEventListener(`mouseup`,()=>{JS&&(JS=!1,s.style.cursor=WS>GS?`grab`:`default`)}),document.getElementById(`pptxPrevSlide`).addEventListener(`click`,()=>{US>0&&(US--,nC())}),document.getElementById(`pptxNextSlide`).addEventListener(`click`,()=>{US<o-1&&(US++,nC())}),document.getElementById(`pptxZoomIn`).addEventListener(`click`,()=>{let e=s.getBoundingClientRect();f(WS*1.25,e.left+e.width/2,e.top+e.height/2)}),document.getElementById(`pptxZoomOut`).addEventListener(`click`,()=>{let e=s.getBoundingClientRect();f(WS/1.25,e.left+e.width/2,e.top+e.height/2)}),document.getElementById(`pptxZoomFit`).addEventListener(`click`,()=>{requestAnimationFrame(()=>{eC(),WS=GS,KS=0,qS=0,c.style.transform=`translate(0px, 0px) scale(${GS})`,l.textContent=Math.round(GS*100)+`%`,s.style.cursor=`default`})}),s.addEventListener(`dblclick`,()=>{requestAnimationFrame(()=>{eC(),WS=GS,KS=0,qS=0,c.style.transform=`translate(0px, 0px) scale(${GS})`,l.textContent=Math.round(GS*100)+`%`,s.style.cursor=`default`})}),window.addEventListener(`resize`,()=>{!HS||HS.length===0||requestAnimationFrame(()=>{tC()})})}function eC(){let e=document.getElementById(`pptxViewport`),t=document.getElementById(`pptxSlideContainer`);if(!e||!t)return;let n=parseFloat(t.style.width)||960,r=parseFloat(t.style.height)||540,i=e.clientWidth,a=e.clientHeight;GS=i>0&&a>0&&n>0&&r>0?Math.min((i-8)/n,(a-8)/r):1}function tC(){let e=document.getElementById(`pptxViewport`),t=document.getElementById(`pptxPan`),n=document.getElementById(`pptxZoomInfo`);if(!e||!t)return;let r=GS;eC(),WS<=r*1.05&&(WS=GS,KS=0,qS=0),t.style.transform=`translate(${KS}px, ${qS}px) scale(${WS})`,n&&(n.textContent=Math.round(WS*100)+`%`),JS||(e.style.cursor=WS>GS?`grab`:`default`)}function nC(){let e=document.getElementById(`pptxSlideContainer`),t=document.getElementById(`pptxPan`);if(!e||!t||US<0||US>=HS.length)return;t.style.transform=`scale(1)`;let n=HS[US],r=ui.sanitize(n,{ALLOWED_TAGS:`div.span.p.a.img.svg.path.circle.rect.line.polyline.polygon.ellipse.g.defs.linearGradient.radialGradient.stop.text.tspan.table.thead.tbody.tr.td.th.br.h1.h2.h3.h4.h5.h6.ul.ol.li.strong.em.b.i.u`.split(`.`),ALLOWED_ATTR:`class.style.id.src.alt.width.height.href.target.d.fill.stroke.stroke-width.transform.viewBox.x.y.cx.cy.r.rx.ry.x1.y1.x2.y2.points.opacity.font-size.font-family.text-anchor.dominant-baseline.clip-path.preserveAspectRatio.xmlns`.split(`.`)});e.style.width=``,e.style.height=``,e.innerHTML=r;let i=e.firstElementChild;i?(e.style.width=(i.offsetWidth||960)+`px`,e.style.height=(i.offsetHeight||540)+`px`):(e.style.width=`960px`,e.style.height=`540px`),eC(),WS=GS,KS=0,qS=0,t.style.transform=`translate(0px, 0px) scale(${GS})`;let a=document.getElementById(`pptxZoomInfo`);a&&(a.textContent=Math.round(WS*100)+`%`);let o=document.getElementById(`pptxViewport`);o&&!JS&&(o.style.cursor=`default`);let s=document.getElementById(`pptxPrevSlide`),c=document.getElementById(`pptxNextSlide`),l=document.getElementById(`pptxSlideNum`);s&&(s.disabled=US<=0),c&&(c.disabled=US>=HS.length-1),l&&(l.textContent=US+1)}var rC=[],iC=0;async function aC(e,t,n){t.innerHTML=`<div class="workspace-panel-empty">${i(`workspace.parsingExcel`)}</div>`;let r=n.dataset.previewPath,a;try{let e=await Al();if(!e)throw Error(i(`workspace.agentNotPaired`));a=await(await fetch(`${e.url}/api/fs/preview-xlsx`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${e.token}`},body:JSON.stringify({path:r,maxRows:500})})).json()}catch(e){t.innerHTML=`<div class="workspace-panel-error">${i(`workspace.requestFailed`,{error:$(e.message)})}</div>`;return}if(!a.success){t.innerHTML=`<div class="workspace-panel-error">${i(`workspace.parseFailed`,{error:$(a.error||i(`workspace.unknownError`))})}</div>`;return}let{sheets:o}=a.data;if(!o||o.length===0){t.innerHTML=`<div class="workspace-panel-error">${i(`workspace.noSheetsInWorkbook`)}</div>`;return}rC=o,iC=0,n.dataset.previewType=`xlsx`,n.dataset.previewSheets=JSON.stringify(o.map(e=>e.name)),t.classList.add(`xlsx-mode`);let s=`<div class="xlsx-sheet-tabs" id="xlsxSheetTabs">`;o.forEach((e,t)=>{s+=`<button class="xlsx-sheet-tab${t===0?` active`:``}" data-sheet="${t}">${$(e.name)}</button>`}),s+=`</div>`,t.innerHTML=s+`<div class="xlsx-sheet-content" id="xlsxSheetContent"><div class="workspace-panel-empty">${i(`workspace.loadingData`)}</div></div>`,document.getElementById(`xlsxSheetTabs`).addEventListener(`click`,e=>{let t=e.target.closest(`.xlsx-sheet-tab`);if(!t)return;let n=parseInt(t.dataset.sheet,10);n!==iC&&(document.querySelectorAll(`.xlsx-sheet-tab`).forEach(e=>e.classList.remove(`active`)),t.classList.add(`active`),oC(n))}),await oC(0)}async function oC(e){let t=document.getElementById(`xlsxSheetContent`);if(!t)return;iC=e;let n=rC[e];if(!n){t.innerHTML=`<div class="workspace-panel-error">${i(`workspace.sheetNotFound`)}</div>`;return}sC(n.rows,n.colCount,n.totalRows,t)}function sC(e,t,n,r){let a=r.querySelector(`.xlsx-table-scrollbar-mirror`);if(a&&a.remove(),!e||e.length===0){r.innerHTML=`<div class="workspace-panel-empty">${i(`workspace.emptySheet`)}</div>`;return}let o=e[0],s=`<div class="xlsx-table-scroll" id="xlsxTableScroll"><table class="xlsx-preview-table"><thead><tr>`;for(let e of o)s+=`<th>${$(String(e??``))}</th>`;s+=`</tr></thead><tbody>`;for(let n=1;n<e.length;n++){s+=`<tr>`;for(let r=0;r<t;r++)s+=`<td>${$(String(e[n][r]??``))}</td>`;s+=`</tr>`}s+=`</tbody></table></div>`,n>CS&&(s+=`<div class="xlsx-truncated-msg">${i(`workspace.xlsxTruncatedHint`,{shown:CS,total:n})}</div>`),r.innerHTML=s;let c=r.querySelector(`#xlsxTableScroll`);if(c){let e=document.createElement(`div`);e.className=`xlsx-table-scrollbar-mirror`,e.innerHTML=`<div class="xlsx-table-scrollbar-mirror-inner" style="width:${c.scrollWidth}px;"></div>`;let t=!1;c.addEventListener(`scroll`,()=>{if(t){t=!1;return}t=!0,e.scrollLeft=c.scrollLeft}),e.addEventListener(`scroll`,()=>{if(t){t=!1;return}t=!0,c.scrollLeft=e.scrollLeft}),r.appendChild(e)}}async function cC(e,t,n){let r={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,bmp:`image/bmp`,ico:`image/x-icon`}[(t.split(`.`).pop()||``).toLowerCase()]||`image/png`,a=new Blob([e],{type:r}),o=URL.createObjectURL(a);n.innerHTML=`
|
|
1237
1243
|
<div class="image-preview-wrap">
|
|
1238
1244
|
<div class="image-preview-toolbar">
|
|
1239
1245
|
<button class="image-preview-btn" id="imgZoomOut" title="${i(`workspace.zoomOut`)}">
|
|
@@ -1254,27 +1260,27 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1254
1260
|
</div>
|
|
1255
1261
|
</div>
|
|
1256
1262
|
</div>
|
|
1257
|
-
`;let s=document.getElementById(`imgPreviewImage`),c=document.getElementById(`imgViewport`),l=document.getElementById(`imgPan`),u=document.getElementById(`imgZoomLevel`),d=1,f=1,p=0,m=0,h=!1,g=0,_=0,v=0,y=0;function b(){if(!s.naturalWidth||!s.naturalHeight)return 1;let e=c.clientWidth,t=c.clientHeight;return e<=0||t<=0?1:Math.min((e-20)/s.naturalWidth,(t-20)/s.naturalHeight)}function x(){l.style.transform=`translate(${p}px, ${m}px) scale(${f})`,u.textContent=Math.round(f*100)+`%`,h||(c.style.cursor=f>d?`grab`:`default`)}function S(){f<=d&&(p=0,m=0)}function C(e,t,n){let r=f;if(f=Math.max(.01,Math.min(20,e)),t!==void 0&&n!==void 0){let e=c.getBoundingClientRect(),i=t-e.left-e.width/2,a=n-e.top-e.height/2,o=f/r;p=i-o*(i-p),m=a-o*(a-m)}S(),x()}function w(){f=d,p=0,m=0,x()}c.addEventListener(`wheel`,e=>{e.preventDefault();let t=-e.deltaY*.005;C(f+t*f,e.clientX,e.clientY)},{passive:!1}),c.addEventListener(`mousedown`,e=>{e.button===0&&(h=!0,g=e.clientX,_=e.clientY,v=p,y=m,c.style.cursor=`grabbing`,e.preventDefault())}),window.addEventListener(`mousemove`,e=>{h&&(p=v+(e.clientX-g),m=y+(e.clientY-_),S(),x())}),window.addEventListener(`mouseup`,()=>{h&&(h=!1,c.style.cursor=f>d?`grab`:`default`)}),document.getElementById(`imgZoomIn`).addEventListener(`click`,()=>{let e=c.getBoundingClientRect();C(f*1.25,e.left+e.width/2,e.top+e.height/2)}),document.getElementById(`imgZoomOut`).addEventListener(`click`,()=>{let e=c.getBoundingClientRect();C(f/1.25,e.left+e.width/2,e.top+e.height/2)}),document.getElementById(`imgZoomReset`).addEventListener(`click`,w),c.addEventListener(`dblclick`,w),s.addEventListener(`load`,()=>{d=b(),f=d,p=0,m=0,x(),setTimeout(()=>URL.revokeObjectURL(o),1e3)}),s.addEventListener(`error`,()=>{URL.revokeObjectURL(o),n.innerHTML=`<div class="workspace-panel-error">${i(`workspace.imageLoadFailed`)}</div>`}),window.addEventListener(`resize`,()=>{d=b(),S(),x()})}var
|
|
1263
|
+
`;let s=document.getElementById(`imgPreviewImage`),c=document.getElementById(`imgViewport`),l=document.getElementById(`imgPan`),u=document.getElementById(`imgZoomLevel`),d=1,f=1,p=0,m=0,h=!1,g=0,_=0,v=0,y=0;function b(){if(!s.naturalWidth||!s.naturalHeight)return 1;let e=c.clientWidth,t=c.clientHeight;return e<=0||t<=0?1:Math.min((e-20)/s.naturalWidth,(t-20)/s.naturalHeight)}function x(){l.style.transform=`translate(${p}px, ${m}px) scale(${f})`,u.textContent=Math.round(f*100)+`%`,h||(c.style.cursor=f>d?`grab`:`default`)}function S(){f<=d&&(p=0,m=0)}function C(e,t,n){let r=f;if(f=Math.max(.01,Math.min(20,e)),t!==void 0&&n!==void 0){let e=c.getBoundingClientRect(),i=t-e.left-e.width/2,a=n-e.top-e.height/2,o=f/r;p=i-o*(i-p),m=a-o*(a-m)}S(),x()}function w(){f=d,p=0,m=0,x()}c.addEventListener(`wheel`,e=>{e.preventDefault();let t=-e.deltaY*.005;C(f+t*f,e.clientX,e.clientY)},{passive:!1}),c.addEventListener(`mousedown`,e=>{e.button===0&&(h=!0,g=e.clientX,_=e.clientY,v=p,y=m,c.style.cursor=`grabbing`,e.preventDefault())}),window.addEventListener(`mousemove`,e=>{h&&(p=v+(e.clientX-g),m=y+(e.clientY-_),S(),x())}),window.addEventListener(`mouseup`,()=>{h&&(h=!1,c.style.cursor=f>d?`grab`:`default`)}),document.getElementById(`imgZoomIn`).addEventListener(`click`,()=>{let e=c.getBoundingClientRect();C(f*1.25,e.left+e.width/2,e.top+e.height/2)}),document.getElementById(`imgZoomOut`).addEventListener(`click`,()=>{let e=c.getBoundingClientRect();C(f/1.25,e.left+e.width/2,e.top+e.height/2)}),document.getElementById(`imgZoomReset`).addEventListener(`click`,w),c.addEventListener(`dblclick`,w),s.addEventListener(`load`,()=>{d=b(),f=d,p=0,m=0,x(),setTimeout(()=>URL.revokeObjectURL(o),1e3)}),s.addEventListener(`error`,()=>{URL.revokeObjectURL(o),n.innerHTML=`<div class="workspace-panel-error">${i(`workspace.imageLoadFailed`)}</div>`}),window.addEventListener(`resize`,()=>{d=b(),S(),x()})}var lC=null;async function uC(e,t,n,r,a){lC&&=(URL.revokeObjectURL(lC),null);let o=wl(t),s=new Blob([e],{type:o}),c=URL.createObjectURL(s);lC=c,a.dataset.previewType=n;let l=n===`video`,u=`<div class="workspace-panel-error" style="margin-top:10px;">${i(`workspace.unsupportedMediaHint`,{ext:$((t.split(`.`).pop()||``).toUpperCase())})}</div>`;if(l){r.innerHTML=`
|
|
1258
1264
|
<div class="media-preview-wrap" style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:12px;">
|
|
1259
1265
|
<video controls autoplay style="max-width:100%;max-height:calc(100% - 24px);border-radius:8px;background:#000;">
|
|
1260
1266
|
<source src="${c}" type="${$(o)}">
|
|
1261
1267
|
</video>
|
|
1262
1268
|
<div id="mediaUnsupportedHint" style="display:none;">${u}</div>
|
|
1263
|
-
</div>`;let e=r.querySelector(`video`);e&&e.addEventListener(`dblclick`,()=>
|
|
1269
|
+
</div>`;let e=r.querySelector(`video`);e&&e.addEventListener(`dblclick`,()=>jC())}else r.innerHTML=`
|
|
1264
1270
|
<div class="media-preview-wrap" style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:12px;gap:16px;">
|
|
1265
1271
|
<div style="font-size:14px;color:#555;">🎵 ${$(t)}</div>
|
|
1266
1272
|
<audio controls autoplay style="width:100%;max-width:560px;">
|
|
1267
1273
|
<source src="${c}" type="${$(o)}">
|
|
1268
1274
|
</audio>
|
|
1269
1275
|
<div id="mediaUnsupportedHint" style="display:none;">${u}</div>
|
|
1270
|
-
</div>`;let d=r.querySelector(`video, audio`),f=r.querySelector(`#mediaUnsupportedHint`);if(d){let e=()=>{d.style.display=`none`,f&&(f.style.display=`block`)};d.addEventListener(`error`,e),r.querySelectorAll(`source`).forEach(t=>t.addEventListener(`error`,e))}}var
|
|
1276
|
+
</div>`;let d=r.querySelector(`video, audio`),f=r.querySelector(`#mediaUnsupportedHint`);if(d){let e=()=>{d.style.display=`none`,f&&(f.style.display=`block`)};d.addEventListener(`error`,e),r.querySelectorAll(`source`).forEach(t=>t.addEventListener(`error`,e))}}var dC=!1;function fC(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 pC(e,t){fC(e,t),t.classList.add(`show`)}function mC(){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`):pC(t,n)});let r=null,i=null;e.addEventListener(`mouseenter`,()=>{i&&=(clearTimeout(i),null),r=setTimeout(()=>{pC(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`),gC(r)})}),document.addEventListener(`click`,t=>{!e.contains(t.target)&&!n.contains(t.target)&&n.classList.remove(`show`)});let a=()=>{n.classList.contains(`show`)&&fC(t,n)};document.getElementById(`workspacePreviewContent`)?.addEventListener(`scroll`,a),window.addEventListener(`resize`,a)}function hC(){return document.getElementById(`workspacePreviewArea`).dataset.markdownText||``}async function gC(e){if(dC)return;dC=!0;let t=document.getElementById(`workspacePreviewExportBtn`);document.getElementById(`workspacePreviewExportMenu`);let n=document.getElementById(`workspacePreviewExportDropdown`),r=document.getElementById(`workspacePreviewArea`).dataset.previewName||`export`,a=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 yC(r);break;case`pdf`:await xC(r);break;case`image`:await SC(r);break;case`md`:CC(r)}}catch(e){o.error(`[WorkspacePanel] export failed:`,e),U(i(`chatExport.exportFailed`,{message:e.message}),`error`)}finally{dC=!1,t.innerHTML=a,t.disabled=!1,t.style.opacity=`1`,n.classList.remove(`show`)}}async function _C(e){typeof mermaid>`u`||(await Fb(e),await Rb(e))}async function vC(e){if(typeof mermaid>`u`||!/```mermaid/i.test(e))return e;try{let t=Ei(e),n=document.createElement(`div`);n.style.cssText=`position:fixed;left:-9999px;top:-9999px;`,n.innerHTML=t,document.body.appendChild(n),await Fb(n),await Rb(n);let r=n.querySelectorAll(`.mermaid`),i=[];for(let e of r){let t=e.querySelector(`img`);t&&t.src&&t.src.startsWith(`data:`)?i.push(t.src):i.push(null)}if(document.body.removeChild(n),i.length===0)return e;let a=0;return e.replace(/```\s*mermaid\s*[\r\n]+([\s\S]*?)```/gi,e=>{let t=i[a];return a++,t?``:e})}catch(t){return o.warn(`[WorkspacePanel] Mermaid pre-render failed:`,t.message),e}}async function yC(e){let{Document:t,Packer:n,Paragraph:r,TextRun:a,HeadingLevel:o,Table:s,TableRow:c,TableCell:l,AlignmentType:u,WidthType:d,BorderStyle:f,ImageRun:p,ExternalHyperlink:m,convertInchesToTwip:h}=await fe(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 Promise.resolve().then(()=>su);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}},void 0),g=hC();if(!g){U(i(`chatExport.noContent`),`error`);return}g=await vC(g);let _=await bC(g),v=new t({styles:{default:{document:{run:{font:`Calibri`,size:22}},heading1:{run:{size:40,bold:!0,color:`333333`},paragraph:{spacing:{before:320,after:160}}},heading2:{run:{size:30,bold:!0,color:`333333`},paragraph:{spacing:{before:280,after:120}}},heading3:{run:{size:26,bold:!0,color:`333333`},paragraph:{spacing:{before:240,after:100}}}}},sections:[{properties:{page:{margin:{top:h(1),right:h(1),bottom:h(1),left:h(1)}}},children:_}]}),y=await n.toBlob(v),b=`word-${new Date().getTime()}.docx`;wC(y,b),U(i(`workspace.downloaded`,{name:b}),`success`)}async function bC(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 fe(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 Promise.resolve().then(()=>su);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}},void 0);if(!e||!e.trim())return[new r({children:[new i({text:``})]})];let h=[],g=e,_=[];g=g.replace(/```(\w*)\n([\s\S]*?)```/g,(e,t,n)=>{let r=_.length;return _.push({lang:t||``,code:n.trimEnd()}),`\n\n%%CODEBLOCK_${r}%%\n\n`});let v=[];g=g.replace(/<table[\s\S]*?<\/table>/gi,e=>{let t=v.length;return v.push(e),`\n\n%%HTMLTABLE_${t}%%\n\n`});let y=[];g=g.replace(/(?:^\|.+\|\s*$\n)+^\|[\s\-:|]+\|\s*$\n(?:^\|.+\|\s*$\n?)+/gm,e=>{let t=y.length;return y.push(e),`\n\n%%MDTABLE_${t}%%\n\n`});let b=g.split(/\n{2,}/).filter(e=>e.trim());function x(e){if(!e)return[];let t=/(\*\*(.+?)\*\*|(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)|__(.+?)__|(?<!_)_(?!_)(.+?)(?<!_)_(?!_)|`([^`]+)`|\[([^\]]+)\]\(([^)]+)\)|!\[([^\]]*)\]\(([^)]+)\))/,n=[],r=e;for(;r.length>0;){let e=r.match(t);if(!e){n.push(...Db(r));break}let a=e.index;a>0&&n.push(...Db(r.slice(0,a)));let o=e[1];if(e[2]!==void 0)n.push(...Db(e[2],{bold:!0}));else if(e[3]!==void 0)n.push(...Db(e[3],{italics:!0}));else if(e[4]!==void 0)n.push(...Db(e[4],{bold:!0}));else if(e[5]!==void 0)n.push(...Db(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[e,r]=t.split(`,`),i=e.match(/data:(image\/(\w+))/);if(i&&r){let e=atob(r),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);n.push(new f({data:t,transformation:{width:400,height:300},type:i[2]}))}}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 S(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 C(e){let t=e.trim().split(`
|
|
1271
1277
|
`),n=[];for(let e of t){if(/^[\s\|:\-]+$/.test(e.replace(/\|/g,``)))continue;let t=e.split(`|`).map(e=>e.trim()).filter(e=>e!==``);t.length>0&&n.push(t)}return n}function w(e){if(e.length===0)return new r({children:[]});let t=Math.max(...e.map(e=>e.length)),n=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:x(o),spacing:{before:40,after:40}})],shading:n===0?{fill:`F2F2F2`}:void 0,width:{size:100/t,type:u.PERCENTAGE}}))}return new s({children:i})});return new o({rows:n,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 b){let t=e.trim(),n=t.match(/^%%CODEBLOCK_(\d+)%%$/);if(n){let{lang:e,code:t}=_[parseInt(n[1])],a=e?`${e} code`:`code`;h.push(new r({children:[new i({text:a,bold:!0,font:`Consolas`,size:18})]}));let o=t.split(`
|
|
1272
1278
|
`);for(let e of o)h.push(new r({children:[new i({text:e||` `,font:`Consolas`,size:18})],spacing:{before:0,after:0,line:240},shading:{fill:`F5F5F5`}}));h.push(new r({children:[new i({text:``})]}));continue}let o=t.match(/^%%HTMLTABLE_(\d+)%%$/);if(o){let e=S(v[parseInt(o[1])]);e.length>0&&(h.push(w(e)),h.push(new r({children:[new i({text:``})]})));continue}let s=t.match(/^%%MDTABLE_(\d+)%%$/);if(s){let e=C(y[parseInt(s[1])]);h.push(w(e)),h.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};h.push(new r({children:x(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&&h.push(new r({children:x(n),spacing:{before:60,after:60}}));continue}if(/^(---|\*\*\*|___)\s*$/.test(t)){h.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)h.push(new r({children:x(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)h.push(new r({children:x(e.replace(/^\d+\.\s+/,``)),numbering:{reference:`default`,level:0},spacing:{before:40,after:40}}));continue}if(t.startsWith(`>`)){let t=e.split(`
|
|
1273
1279
|
`).map(e=>e.replace(/^>\s?/,``)).join(`
|
|
1274
|
-
`);h.push(new r({children:x(t),indent:{left:m(.5)},border:{left:{style:d.SINGLE,size:12,color:`CCCCCC`}},spacing:{before:60,after:60}}));continue}let l=x(t);h.push(new r({children:l.length>0?l:Db(t),spacing:{before:60,after:60}}))}return h}async function
|
|
1280
|
+
`);h.push(new r({children:x(t),indent:{left:m(.5)},border:{left:{style:d.SINGLE,size:12,color:`CCCCCC`}},spacing:{before:60,after:60}}));continue}let l=x(t);h.push(new r({children:l.length>0?l:Db(t),spacing:{before:60,after:60}}))}return h}async function xC(e){let{jsPDF:t,html2canvas:n}=await vi();if(!t||!n){U(i(`chatExport.pdfLibNotLoaded`),`error`);return}let r=hC();if(!r){U(i(`chatExport.noContent`),`error`);return}let a=document.createElement(`div`);a.style.cssText=`position:fixed;left:-9999px;top:-9999px;width:515px;padding:40px;background:white;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Hiragino Sans GB','Microsoft YaHei',sans-serif;font-size:12px;line-height:1.6;color:#333;box-sizing:border-box;`,a.innerHTML=`<div class="markdown-body">${Ei(r)}</div>`,document.body.appendChild(a),await _C(a);let s=a.scrollHeight,c=Math.ceil(s/762);n(a,{scale:2,useCORS:!0,logging:!1,backgroundColor:`#ffffff`,willReadFrequently:!0}).then(e=>{let n=new t({orientation:`portrait`,unit:`px`,format:[595,842],compress:!0}),r=e.width,o=e.height,l=o/s,u=762*l;for(let t=0;t<c;t++){t>0&&n.addPage();let i=t*u,a=Math.min(i+u,o)-i,s=document.createElement(`canvas`);s.width=r,s.height=a;let c=s.getContext(`2d`,{willReadFrequently:!0});c.fillStyle=`#ffffff`,c.fillRect(0,0,s.width,s.height),c.drawImage(e,0,i,r,a,0,0,r,a);let d,f;try{d=s.toDataURL(`image/jpeg`,.85),f=`JPEG`}catch{d=s.toDataURL(`image/png`),f=`PNG`}let p=a/l;n.addImage(d,f,0,0,595,p,void 0,`FAST`)}let d=`pdf-${new Date().getTime()}.pdf`;n.save(d),document.body.removeChild(a),U(i(`workspace.downloaded`,{name:d}),`success`)}).catch(e=>{o.error(`[WorkspacePanel] PDF export failed:`,e),U(i(`chatExport.exportFailed`,{message:e.message}),`error`),document.body.removeChild(a)})}async function SC(e){let t=await _i();if(!t){U(i(`chatExport.imageLibNotLoaded`),`error`);return}let n=document.getElementById(`workspacePreviewContent`).querySelector(`.workspace-preview-markdown`);if(!n){U(i(`chatExport.noContent`),`error`);return}let r=n.cloneNode(!0),a=document.createElement(`div`);a.style.cssText=`position:fixed;left:-9999px;top:-9999px;width:800px;padding:40px;background:white;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;font-size:14px;line-height:1.6;color:#333;box-sizing:border-box;`,a.appendChild(r),document.body.appendChild(a),await _C(a),await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e)));try{let e=(await t(a,{scale:2,useCORS:!0,logging:!1,backgroundColor:`#ffffff`,willReadFrequently:!0})).toDataURL(`image/jpeg`,.92),n=document.createElement(`a`);n.href=e;let r=`image-${new Date().getTime()}.jpg`;n.download=r,document.body.appendChild(n),n.click(),document.body.removeChild(n),U(i(`workspace.downloaded`,{name:r}),`success`)}catch(e){o.error(`[WorkspacePanel] image export failed:`,e),U(i(`chatExport.exportFailed`,{message:e.message}),`error`)}finally{document.body.removeChild(a)}}function CC(e){let t=hC();if(!t){U(i(`chatExport.noContent`),`error`);return}let n=t.replace(/\r\n/g,`
|
|
1275
1281
|
`).replace(/\n{3,}/g,`
|
|
1276
1282
|
|
|
1277
|
-
`),r=new Blob([n],{type:`text/markdown;charset=utf-8`}),a=`md-${new Date().getTime()}.md`;
|
|
1283
|
+
`),r=new Blob([n],{type:`text/markdown;charset=utf-8`}),a=`md-${new Date().getTime()}.md`;wC(r,a),U(i(`workspace.downloaded`,{name:a}),`success`)}function wC(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}async function TC(e){let t=document.getElementById(`workspacePreviewArea`),n=t.dataset.previewPath;if(!n)return;if((t.dataset.previewType||Cl(t.dataset.previewName||``))!==`text`){U(i(`workspace.copyUnsupportedType`),`info`);return}let r=e&&(e.ctrlKey||e.metaKey),a=document.getElementById(`workspacePreviewContent`).classList.contains(`markdown-rendered`);if(r&&a)await EC();else{let e=t.dataset.markdownText||``;if(e)try{await navigator.clipboard.writeText(e),U(i(`workspace.copiedToClipboard`),`success`)}catch{U(i(`workspace.copyFailedManual`),`error`)}else{let e=await zl(n);if(e.success)try{await navigator.clipboard.writeText(e.content||``),U(i(`workspace.copiedToClipboard`),`success`)}catch{U(i(`workspace.copyFailedManual`),`error`)}else U(i(`workspace.getContentFailed`),`error`)}}}async function EC(){let e=document.getElementById(`workspacePreviewContent`).querySelector(`.workspace-preview-markdown`);if(!e){U(i(`chatCopy.copyFailedManual`),`error`);return}let t=e.cloneNode(!0);t.querySelectorAll(`table`).forEach(e=>{let t=Yi(e);e.parentNode.replaceChild(t,e)});let n=t.innerHTML,r=t.textContent||``,a=DC(n);try{if(typeof ClipboardItem<`u`){let e=new ClipboardItem({"text/plain":new Blob([r],{type:`text/plain`}),"text/html":new Blob([a],{type:`text/html`})});await navigator.clipboard.write([e])}else{let e=document.createElement(`div`);e.style.position=`fixed`,e.style.left=`-999999px`,e.style.top=`-999999px`,e.innerHTML=a,document.body.appendChild(e);let t=document.createRange();t.selectNodeContents(e);let n=window.getSelection();n.removeAllRanges(),n.addRange(t);try{document.execCommand(`copy`)}catch{await navigator.clipboard.writeText(r)}finally{n.removeAllRanges(),document.body.removeChild(e)}}U(i(`chatCopy.copiedRich`),`success`)}catch(e){o.warn(`[WorkspacePanel] rich textcopy failed:`,e.message);try{await navigator.clipboard.writeText(r),U(i(`workspace.copiedToClipboard`),`success`)}catch{U(i(`workspace.copyFailedManual`),`error`)}}}function DC(e){return`<!DOCTYPE html><html><head>
|
|
1278
1284
|
<style>
|
|
1279
1285
|
h1 { font-size: 24px; font-weight: bold; margin: 16px 0 8px; }
|
|
1280
1286
|
h2 { font-size: 20px; font-weight: bold; margin: 14px 0 6px; }
|
|
@@ -1295,12 +1301,12 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1295
1301
|
a { color: #007bff; text-decoration: underline; }
|
|
1296
1302
|
img { max-width: 100%; }
|
|
1297
1303
|
</style>
|
|
1298
|
-
</head><body>${e}</body></html>`}async function
|
|
1299
|
-
`);r.textContent=i(`workspace.lineCount`,{count:u.length});let d=`<table class="workspace-preview-code-table"><tbody>`;for(let e=0;e<u.length;e++)d+=`<tr><td class="line-num">${e+1}</td><td class="line-content"><code class="${c}">${$(u[e])}</code></td></tr>`;d+=`</tbody></table>`,t.innerHTML=d}
|
|
1300
|
-
`+i(`workspace.copyMarkdownHint`):i(`workspace.copyAllTitle`))}async function
|
|
1304
|
+
</head><body>${e}</body></html>`}async function OC(){let e=document.getElementById(`workspacePreviewArea`),t=e.dataset.previewPath,n=e.dataset.previewName;t&&await UC(t,n)}async function kC(){let e=document.getElementById(`workspacePreviewArea`).dataset.previewPath;if(e)try{let t=await Gl(e);if(!t.success){U(i(`workspace.requestFailed`,{error:t.error}),`error`);return}let n=URL.createObjectURL(t.blob);window.open(n,`_blank`),setTimeout(()=>URL.revokeObjectURL(n),6e4),U(i(`workspace.openInBrowser`),`success`)}catch(e){U(i(`workspace.openFailed`,{error:e.message}),`error`)}}function AC(e,t){let n=e.querySelector(`.workspace-preview-md-icon-preview`),r=e.querySelector(`.workspace-preview-md-icon-source`);n&&(n.style.display=t?`none`:``),r&&(r.style.display=t?``:`none`)}function jC(){let e=document.getElementById(`workspacePreviewArea`),t=document.getElementById(`workspacePanel`),n=document.getElementById(`workspacePreviewFullscreenBtn`);e.classList.toggle(`fullscreen`)?(t.classList.add(`preview-fullscreen`),n.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="14" height="14"><path d="M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"/></svg>`,n.title=i(`workspace.exitFullscreen`)):(t.classList.remove(`preview-fullscreen`),n.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="14" height="14"><path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"/></svg>`,n.title=i(`workspace.fullscreenPreview`))}function MC(){let e=document.getElementById(`workspacePreviewArea`),t=document.getElementById(`workspacePreviewContent`),n=document.getElementById(`workspacePreviewMdToggleBtn`),r=document.getElementById(`workspacePreviewLineCount`),a=document.getElementById(`workspacePreviewCopyBtn`),o=document.getElementById(`workspacePreviewDownloadBtn`),s=document.getElementById(`workspacePreviewExportMenu`),c=t.classList.toggle(`markdown-rendered`),l=e.dataset.markdownText||``;if(c)n.classList.add(`active`),n.title=i(`workspace.switchToSourcePreview`),AC(n,!0),a.style.display=``,o&&(o.style.display=`none`),s&&(s.style.display=``),t.innerHTML=`<div class="markdown-body workspace-preview-markdown">${Ei(l)}</div>`,PC(t),FC(t),Ji(),r.textContent=``;else{n.classList.remove(`active`),n.title=i(`workspace.switchToRenderPreview`),AC(n,!1),a.style.display=``,o&&(o.style.display=``),s&&(s.style.display=`none`);let c=pw(e.dataset.previewName||``),u=(l||``).split(`
|
|
1305
|
+
`);r.textContent=i(`workspace.lineCount`,{count:u.length});let d=`<table class="workspace-preview-code-table"><tbody>`;for(let e=0;e<u.length;e++)d+=`<tr><td class="line-num">${e+1}</td><td class="line-content"><code class="${c}">${$(u[e])}</code></td></tr>`;d+=`</tbody></table>`,t.innerHTML=d}NC(c)}function NC(e){let t=document.getElementById(`workspacePreviewCopyBtn`);t&&(t.title=e?i(`workspace.copyAllTitle`)+`
|
|
1306
|
+
`+i(`workspace.copyMarkdownHint`):i(`workspace.copyAllTitle`))}async function PC(e){if(typeof mermaid>`u`)return;let t=e.querySelectorAll(`.mermaid`);for(let e of t){if(e.querySelector(`svg`))continue;let t=e.getAttribute(`data-raw-code`),n=t?decodeURIComponent(t):e.textContent||``;try{await mermaid.run({nodes:[e]}),typeof Fi==`function`&&Fi(e)}catch{e.textContent=n}}}function FC(e){e.querySelectorAll(`.code-copy-btn`).forEach(e=>{e.dataset.bound||(e.dataset.bound=`true`,e.addEventListener(`click`,t=>{t.stopPropagation();let n=e.closest(`.code-block-container`);if(n){let t=n.querySelector(`pre code`);t&&He(t.textContent||``,e)}}))}),e.dataset.ctrlClickBound||(e.dataset.ctrlClickBound=`true`,e.addEventListener(`click`,e=>{if(!e.ctrlKey&&!e.metaKey||e.button!==0)return;let t=e.target.closest(`code`);if(!t){let n=e.target.closest(`pre`);if(n&&(t=n.querySelector(`code`)),!t){let n=e.target.closest(`.code-block-container`);n&&(t=n.querySelector(`code`))}}if(!t||e.target.closest(`.code-copy-btn`))return;e.preventDefault();let n=t.textContent;n&&navigator.clipboard.writeText(n).then(()=>{U(i(`workspace.codeCopiedToClipboard`),`success`)}).catch(()=>{let e=document.createElement(`textarea`);e.value=n,e.style.position=`fixed`,e.style.left=`-999999px`,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e),U(i(`workspace.codeCopiedToClipboard`),`success`)})}))}async function IC(e=!1){let t=document.getElementById(`workspacePreviewArea`);if(!e&&t.dataset.editMode===`true`&&t.classList.contains(`has-unsaved`)&&!await VC(i(`workspace.actionClosePreview`)))return!1;BC(!1);let n=document.getElementById(`workspacePanel`),r=document.getElementById(`workspacePreviewContent`);r.classList.remove(`xlsx-mode`),r.classList.remove(`markdown-rendered`),delete t.dataset.markdownText;let a=document.getElementById(`workspacePreviewMdToggleBtn`);if(a&&(a.classList.remove(`active`),a.style.display=`none`,AC(a,!1)),t.classList.contains(`fullscreen`)){t.classList.remove(`fullscreen`),n.classList.remove(`preview-fullscreen`);let e=document.getElementById(`workspacePreviewFullscreenBtn`);e&&(e.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="14" height="14"><path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"/></svg>`,e.title=i(`workspace.fullscreenPreview`))}ES&&=(ES.destroy(),null),DS=1,kS=1,lC&&=(URL.revokeObjectURL(lC),null);let o=document.getElementById(`workspacePreviewExportMenu`);o&&(o.style.display=`none`);let s=document.getElementById(`workspacePreviewCopyBtn`);return s&&(s.title=i(`workspace.copyAllTitle`)),t.style.display=`none`,document.getElementById(`workspacePreviewContent`).innerHTML=``,mx&&(mx=!1,ww(!1)),!0}function LC(){let e=document.getElementById(`workspacePreviewArea`),t=document.getElementById(`workspacePreviewContent`),n=document.getElementById(`workspacePreviewEditBtn`),r=document.getElementById(`workspacePreviewSaveBtn`),a=document.getElementById(`workspacePreviewCancelBtn`),o=document.getElementById(`workspacePreviewCopyBtn`),s=document.getElementById(`workspacePreviewDownloadBtn`),c=document.getElementById(`workspacePreviewMdToggleBtn`);document.getElementById(`workspacePreviewFullscreenBtn`);let l=document.getElementById(`workspacePreviewLineCount`),u=document.getElementById(`workspacePreviewFilename`),d=e.dataset.origContent||``;e.dataset.editMode=`true`,r.title=i(`workspace.saveChanges`),r.disabled=!1,o.style.display=`none`,s.style.display=`none`,c.style.display=`none`,n.style.display=`none`;let f=document.getElementById(`workspacePreviewExportMenu`);f&&(f.style.display=`none`),r.style.display=``,a.style.display=``,t.innerHTML=`<textarea class="workspace-preview-editor" id="workspacePreviewEditor" spellcheck="false"></textarea>`;let p=t.querySelector(`#workspacePreviewEditor`);p.value=d,p.focus(),p.setSelectionRange(p.value.length,p.value.length),l.textContent=i(`workspace.lineCount`,{count:d.split(`
|
|
1301
1307
|
`).length}),u.classList.add(`modified`),u.textContent=(e.dataset.previewName||``)+` *`,p.addEventListener(`input`,()=>{p.value===d?(e.classList.remove(`has-unsaved`),l.textContent=i(`workspace.lineCount`,{count:p.value.split(`
|
|
1302
1308
|
`).length})):(e.classList.add(`has-unsaved`),l.textContent=i(`workspace.linesModified`,{count:p.value.split(`
|
|
1303
|
-
`).length}))})}async function
|
|
1309
|
+
`).length}))})}async function RC(){let e=document.getElementById(`workspacePreviewArea`),t=document.getElementById(`workspacePreviewEditor`);if(!t)return;let n=e.dataset.previewPath,r=t.value;if(r===(e.dataset.origContent||``)){zC();return}let a=document.getElementById(`workspacePreviewSaveBtn`),s=a.title;a.title=i(`workspace.saving`),a.disabled=!0;try{let t=await Bl(n,r);if(t.success){o.info(`[WorkspacePanel] file save successful:`,n),U(i(`workspace.saveSuccess`)),e.dataset.origContent=r,BC(!1);let t=e.dataset.previewName;await TS(n,t)}else o.error(`[WorkspacePanel] filesave failed:`,n,t.error),U(i(`workspace.saveFailedWithError`,{error:t.error||i(`workspace.unknownError`)})),a.title=s,a.disabled=!1}catch(e){o.error(`[WorkspacePanel] file saveexception:`,n,e),U(i(`workspace.saveFailedWithError`,{error:e.message||e})),a.title=s,a.disabled=!1}}async function zC(){let e=document.getElementById(`workspacePreviewArea`);if(e.classList.contains(`has-unsaved`)&&!await VC(i(`workspace.actionCancelEdit`)))return;BC(!0);let t=e.dataset.previewPath,n=e.dataset.previewName;t&&n&&await TS(t,n)}function BC(e){let t=document.getElementById(`workspacePreviewArea`),n=document.getElementById(`workspacePreviewFilename`),r=document.getElementById(`workspacePreviewSaveBtn`),i=document.getElementById(`workspacePreviewCancelBtn`);delete t.dataset.editMode,t.classList.remove(`has-unsaved`),n.classList.remove(`modified`),r.style.display=`none`,i.style.display=`none`}async function VC(e){return typeof window.showCustomConfirm==`function`?await window.showCustomConfirm(i(`workspace.discardChangesPrompt`,{action:e}),i(`workspace.unsavedChanges`)):window.confirm(i(`workspace.discardChangesPrompt`,{action:e}))}function HC(e){let t=document.getElementById(`workspacePreviewArea`);if(t.style.display===`none`)return;if(t.dataset.editMode===`true`){(e.ctrlKey||e.metaKey)&&e.key===`s`&&(e.preventDefault(),RC()),e.key===`Escape`&&(e.preventDefault(),zC());return}let n=(e.target?.tagName||``).toLowerCase();if(n===`input`||n===`textarea`||e.target?.isContentEditable)return;let r=t.dataset.previewType;if(r===`pdf`||r===`pptx`){if(e.key===`ArrowLeft`){e.preventDefault();let t=document.getElementById(r===`pdf`?`pdfPrevPage`:`pptxPrevSlide`);t&&!t.disabled&&t.click()}else if(e.key===`ArrowRight`){e.preventDefault();let t=document.getElementById(r===`pdf`?`pdfNextPage`:`pptxNextSlide`);t&&!t.disabled&&t.click()}}}async function UC(e,t){if(dx)return;dx=!0,JC(!0);let n=XC(e),r=new AbortController,a=[],o=()=>{if(a.length<2)return 0;let e=a[0],t=a[a.length-1],n=(t.time-e.time)/1e3;return n<=0?0:(t.loaded-e.loaded)/n},s=ew(()=>r.abort());s.classList.add(`download-mode`),tw(s,{percent:0,fileName:t,loaded:0,totalBytes:0,speed:0});try{let c=await Kl(e,({loaded:e,total:r,percent:i})=>{ZC(n,i);let c=Date.now();a.push({time:c,loaded:e}),a.length>8&&a.shift(),tw(s,{percent:i,fileName:t,loaded:e,totalBytes:r,speed:o()})},r.signal);if(c.aborted){nw(s,i(`workspace.downloadCanceled`),!0),U(i(`workspace.downloadCanceled`),`info`);return}if(!c.success){nw(s,i(`workspace.downloadFailed`),!0),U(i(`workspace.downloadFailedWithError`,{error:c.error}),`error`);return}GC(c.blob,c.name||t),tw(s,{percent:100,fileName:t,loaded:c.blob.size,totalBytes:c.blob.size,speed:0,statusText:i(`workspace.savingToLocal`)}),setTimeout(()=>{nw(s,i(`workspace.savedToLocal`),!1)},1500),U(i(`workspace.downloaded`,{name:c.name||t}),`success`)}catch(e){e.name===`AbortError`?(nw(s,i(`workspace.downloadCanceled`),!0),U(i(`workspace.downloadCanceled`),`info`)):(nw(s,i(`workspace.downloadFailed`),!0),U(i(`workspace.downloadFailedWithError`,{error:e.message}),`error`))}finally{setTimeout(()=>QC(n),600),dx=!1,JC(!1)}}async function WC(){if(ux.size===0||dx)return;let e=Array.from(ux);if(e.length===1){let t=e[0].split(/[\\/]/).pop();await UC(e[0],t);return}dx=!0,JC(!0);let t=new AbortController,n=[],r=()=>{if(n.length<2)return 0;let e=n[0],t=n[n.length-1],r=(t.time-e.time)/1e3;return r<=0?0:(t.loaded-e.loaded)/r},a=i(`workspace.fileCount`,{count:e.length}),o=ew(()=>t.abort());o.classList.add(`download-mode`),tw(o,{percent:0,fileName:a,loaded:0,totalBytes:0,speed:0});try{let s=await Jl(e,({loaded:e,total:t,percent:i})=>{let s=Date.now();n.push({time:s,loaded:e}),n.length>8&&n.shift(),tw(o,{percent:i,fileName:a,loaded:e,totalBytes:t,speed:r()})},t.signal);if(s.aborted){nw(o,i(`workspace.downloadCanceled`),!0),U(i(`workspace.downloadCanceled`),`info`);return}s.success&&s.blob?(GC(s.blob,s.name||`workspace.zip`),nw(o,i(`workspace.downloadedCount`,{count:e.length}),!1),U(i(`workspace.downloadedZip`,{count:e.length}),`success`)):(nw(o,i(`workspace.downloadFailed`),!0),U(i(`workspace.downloadFailedWithError`,{error:s.error||i(`workspace.unknownError`)}),`error`))}catch(e){e.name===`AbortError`?(nw(o,i(`workspace.downloadCanceled`),!0),U(i(`workspace.downloadCanceled`),`info`)):(nw(o,i(`workspace.downloadFailed`),!0),U(i(`workspace.downloadFailedWithError`,{error:e.message}),`error`))}finally{dx=!1,JC(!1)}}function GC(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),setTimeout(()=>URL.revokeObjectURL(n),6e4)}function KC(){let e=document.getElementById(`workspaceFileInput`);e&&e.click()}async function qC(e){let t=e.target.files;if(!t||t.length===0)return;let n=Array.from(t);e.target.value=``,await iw(n)}function JC(e){document.querySelectorAll(`.workspace-file-btn.download`).forEach(t=>{t.disabled=e});let t=document.getElementById(`workspaceDownloadDirBtn`);t&&(t.disabled=e||ux.size===0);let n=document.getElementById(`workspacePreviewDownloadBtn`);n&&(n.disabled=e)}var YC=new Map;function XC(e){return YC.set(e,0),$C(),e}function ZC(e,t){if(!e)return;let n=e;YC.set(n,t);let r=Array.from(document.querySelectorAll(`.workspace-file-item`)).find(e=>e.dataset.path===n);if(r){let e=r.querySelector(`.workspace-file-progress`);e||(e=document.createElement(`div`),e.className=`workspace-file-progress`,e.innerHTML=`<div class="workspace-file-progress-bar"></div>`,r.appendChild(e));let n=e.querySelector(`.workspace-file-progress-bar`);n&&(n.style.width=t+`%`)}}function QC(e){if(!e)return;let t=e;YC.delete(t);let n=Array.from(document.querySelectorAll(`.workspace-file-item`)).find(e=>e.dataset.path===t);if(n){let e=n.querySelector(`.workspace-file-progress`);e&&e.remove()}}function $C(){for(let[e,t]of YC){let n=Array.from(document.querySelectorAll(`.workspace-file-item`)).find(t=>t.dataset.path===e);if(n&&!n.querySelector(`.workspace-file-progress`)){let e=document.createElement(`div`);e.className=`workspace-file-progress`,e.innerHTML=`<div class="workspace-file-progress-bar" style="width:${t}%"></div>`,n.appendChild(e)}}}function ew(e){let t=document.createElement(`div`);t.className=`workspace-upload-progress`,t.innerHTML=`
|
|
1304
1310
|
<div class="workspace-upload-progress-header">
|
|
1305
1311
|
<span class="workspace-upload-progress-title">${i(`workspace.uploading`)}</span>
|
|
1306
1312
|
<button class="workspace-upload-progress-cancel" title="${i(`workspace.cancelUpload`)}">
|
|
@@ -1317,8 +1323,8 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1317
1323
|
<span class="workspace-upload-progress-bytes"></span>
|
|
1318
1324
|
<span class="workspace-upload-progress-speed"></span>
|
|
1319
1325
|
</div>
|
|
1320
|
-
`,document.body.appendChild(t);let n=t.querySelector(`.workspace-upload-progress-cancel`);return n&&n.addEventListener(`click`,()=>{n.style.display=`none`,typeof e==`function`&&e()}),t}function ew(e,t){if(!e)return;let{percent:n,completed:r,total:a,fileName:o,loaded:s,totalBytes:c,speed:l,statusText:u}=t,d=e.querySelector(`.workspace-upload-progress-title`),f=e.querySelector(`.workspace-upload-progress-file`),p=e.querySelector(`.workspace-upload-progress-bar`),m=e.querySelector(`.workspace-upload-progress-bytes`),h=e.querySelector(`.workspace-upload-progress-speed`),g=e.classList.contains(`download-mode`)?i(`workspace.downloadInProgress`):i(`workspace.uploadInProgress`);d&&(d.textContent=u||(r!=null&&a!=null?`${g} ${r}/${a} · ${n}%`:`${g} ${n}%`)),f&&o&&(f.textContent=o,f.title=o),p&&(p.style.width=n+`%`),m&&(s!=null&&c!=null&&c>0?m.textContent=`${bl(s)} / ${bl(c)}`:s!=null&&(m.textContent=bl(s))),h&&(h.textContent=l>0?`${bl(l)}/s`:``)}function tw(e,t,n){if(!e)return;let r=e.querySelector(`.workspace-upload-progress-title`),i=e.querySelector(`.workspace-upload-progress-cancel`),a=e.querySelector(`.workspace-upload-progress-bar`);i&&(i.style.display=`none`),r&&(r.textContent=t),a&&!n&&(a.style.width=`100%`),e.classList.add(`workspace-upload-progress-done`),n&&e.classList.add(`workspace-upload-progress-error`),setTimeout(()=>{try{e.remove()}catch{}},1500)}function nw(e){let t=document.getElementById(`workspaceUploadBtn`);t&&(t.disabled=e,e?(t.dataset.originalHtml=t.innerHTML,t.innerHTML=`<span class="workspace-upload-spinner"></span>`):t.dataset.originalHtml&&(t.innerHTML=t.dataset.originalHtml,delete t.dataset.originalHtml));let n=document.getElementById(`workspacePanel`);n&&n.classList.toggle(`upload-in-progress`,e)}async function rw(e){let t=Array.from(e);if(t.length===0||fx)return;fx=!0,nw(!0);let n=await Al();if(!n){U(i(`workspace.agentNotConnectedUpload`),`error`),fx=!1,nw(!1);return}let r=new Set;try{let e=await Rl(qb);e.success&&Array.isArray(e.entries)&&(r=new Set(e.entries.map(e=>e.name)))}catch{}let a=0,o=0,s=0,c=t.reduce((e,t)=>e+t.size,0),l=Array(t.length).fill(0),u=new Set,d=!1,f=``,p=[],m=()=>{if(p.length<2)return 0;let e=p[0],t=p[p.length-1],n=(t.time-e.time)/1e3;return n<=0?0:(t.loaded-e.loaded)/n},h=$C(()=>{d=!0;for(let e of u)try{e.abort()}catch{}u.clear()}),g=e=>{e&&(f=e);let n=l.reduce((e,t)=>e+t,0),r=c>0?Math.round(n/c*100):0,i=Date.now();p.push({time:i,loaded:n}),p.length>8&&p.shift(),ew(h,{percent:r,completed:a+o+s,total:t.length,fileName:f,loaded:n,totalBytes:c,speed:m()})};g();for(let e=0;e<t.length&&!d;e+=3){let c=t.slice(e,e+3),f=await Promise.allSettled(c.map(async(t,a)=>{let o=e+a,s=yx(t.name),c=Gx(`${qb}/${s}`);if(r.has(s))throw l[o]=t.size,g(s),Error(`__SKIPPED__`);if(d)throw Error(`__CANCELLED__`);await new Promise((e,r)=>{let a=new XMLHttpRequest;u.add(a);let s=`${n.url}/api/fs/upload-stream?path=${encodeURIComponent(c)}`;a.open(`POST`,s),a.setRequestHeader(`Authorization`,`Bearer ${n.token}`),a.upload.onprogress=e=>{e.lengthComputable&&(l[o]=e.loaded,g(t.name))},a.onload=()=>{if(u.delete(a),d){r(Error(`__CANCELLED__`));return}if(a.status>=200&&a.status<300)try{let n=JSON.parse(a.responseText);n.success?(l[o]=t.size,g(t.name),e()):r(Error(n.error||i(`workspace.uploadFailed`)))}catch{r(Error(i(`workspace.parseResponseFailed`)))}else try{let e=JSON.parse(a.responseText);r(Error(e.error||i(`workspace.uploadFailedWithStatus`,{status:a.status})))}catch{r(Error(i(`workspace.uploadFailedWithStatus`,{status:a.status})))}},a.onerror=()=>{u.delete(a),r(Error(d?`__CANCELLED__`:i(`workspace.networkError`)))},a.onabort=()=>{u.delete(a),r(Error(`__CANCELLED__`))},a.send(t)})}));for(let e of f)if(e.status===`fulfilled`)a++;else{let t=e.reason&&e.reason.message?e.reason.message:``;t.includes(`__SKIPPED__`)||t.includes(`已存在`)?o++:t.includes(`__CANCELLED__`)||s++}}let _,v=!1;if(d)_=i(`workspace.uploadCanceled`),v=!0;else{let e=[];a>0&&e.push(i(`workspace.uploadSuccessCount`,{count:a})),o>0&&e.push(i(`workspace.uploadSkippedCount`,{count:o})),s>0&&e.push(i(`workspace.uploadFailedCount`,{count:s})),_=e.length>0?i(`workspace.uploadCompleteWithStats`,{stats:e.join(` / `)}):i(`workspace.uploadComplete`),v=s>0}tw(h,_,v),a>0&&U(i(`workspace.uploadedFiles`,{count:a}),`success`),o>0&&U(i(`workspace.filesSkipped`,{count:o}),`info`),s>0&&U(i(`workspace.filesUploadFailed`,{count:s}),`error`),d&&U(i(`workspace.uploadCanceled`),`info`),fx=!1,nw(!1),a>0&&(await cw(),Kw(t[t.length-1].name))}function iw(){let e=document.getElementById(`workspacePanel`);if(!e)return;let t=document.getElementById(`workspacePanelContent`);t.addEventListener(`dragstart`,e=>{let t=e.target.closest(`.workspace-file-item`);if(!t)return;let n=t.dataset.path,r=t.dataset.name;e.dataTransfer.setData(`application/x-workspace-move`,JSON.stringify({path:n,name:r})),e.dataTransfer.effectAllowed=`move`,t.classList.add(`dragging`);let i=()=>{t.classList.remove(`dragging`),t.removeEventListener(`dragend`,i)};t.addEventListener(`dragend`,i)}),t.addEventListener(`dragover`,n=>{n.preventDefault(),n.stopPropagation();let r=n.target.closest(`.workspace-file-item.directory`);t.querySelectorAll(`.workspace-file-item.directory.drop-target`).forEach(e=>e.classList.remove(`drop-target`)),r?(n.dataTransfer.dropEffect=n.dataTransfer.types.includes(`application/x-workspace-move`)?`move`:`copy`,r.classList.add(`drop-target`),e.classList.remove(`drag-over`)):n.dataTransfer.types.includes(`application/x-workspace-move`)||e.classList.add(`drag-over`)}),t.addEventListener(`dragleave`,n=>{n.preventDefault(),n.stopPropagation(),t.querySelectorAll(`.workspace-file-item.directory.drop-target`).forEach(e=>e.classList.remove(`drop-target`)),e.classList.remove(`drag-over`)}),t.addEventListener(`drop`,async n=>{n.preventDefault(),n.stopPropagation();let r=n.target.closest(`.workspace-file-item.directory`);if(t.querySelectorAll(`.workspace-file-item.directory.drop-target`).forEach(e=>e.classList.remove(`drop-target`)),e.classList.remove(`drag-over`),r&&n.dataTransfer.types.includes(`application/x-workspace-move`)){try{let e=JSON.parse(n.dataTransfer.getData(`application/x-workspace-move`)),t=e.path,a=r.dataset.path,o=e.name,s=Gx(t),c=Gx(a);if(s===c)return;if(s.startsWith(c+`/`)){U(i(`workspace.cannotMoveToSubdir`),`error`);return}U(i(`workspace.moving`),`info`);let l=await Zl(t,a);if(l.success){U(i(`workspace.movedToDir`,{name:o}),`success`),Kx(qb),Kx(a);let e=a.split(/[\\/]/).pop();await cw(),Kw(e)}else U(i(`workspace.moveFailed`,{error:l.error}),`error`)}catch(e){U(i(`workspace.moveFailed`,{error:e.message}),`error`)}return}if(r&&n.dataTransfer.files&&n.dataTransfer.files.length>0){let e=r.dataset.path;e.split(/[\\/]/).pop(),vx(qb),qb=e,await rw(n.dataTransfer.files),lw(),uw();return}if(n.dataTransfer.files&&n.dataTransfer.files.length>0){await rw(n.dataTransfer.files);return}}),e.addEventListener(`dragover`,t=>{t.preventDefault(),t.stopPropagation(),!t.dataTransfer.types.includes(`application/x-workspace-move`)&&e.classList.add(`drag-over`)}),e.addEventListener(`dragleave`,t=>{t.preventDefault(),t.stopPropagation(),!t.dataTransfer.types.includes(`application/x-workspace-move`)&&e.classList.remove(`drag-over`)}),e.addEventListener(`drop`,async t=>{if(t.preventDefault(),t.stopPropagation(),t.dataTransfer.types.includes(`application/x-workspace-move`))return;e.classList.remove(`drag-over`);let n=t.dataTransfer.files;!n||n.length===0||await rw(n)})}async function aw(){try{let e=document.getElementById(`workspaceAgentName`);if(!e)return;let t=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=t.pairedAgents||[],r=t.activeAgentId;if(r){let t=n.find(e=>e.id===r);if(t&&t.name){e.textContent=` · ${t.name}`,e.style.display=``;return}}e.textContent=``,e.style.display=`none`}catch(e){o.debug(`[WorkspacePanel] update agentname failed:`,e)}}async function ow(e,t){if(t===`local`&&!(!e.pairedAgents&&!e.activeAgentId)&&(await aw(),e.activeAgentId?.newValue!==e.activeAgentId?.oldValue)){o.debug(`[WorkspacePanel] Agent changed,refreshworking directory`),Nl(),Jb=null,qb=null,Yb=[],ux.clear(),ww=``,Tw=[],Ew=!1,zx.clear();let e=document.getElementById(`workspacePanel`);e&&e.classList.contains(`expanded`)&&await Lx()}}async function sw(){if(Yb.length===0)return;let e=Yb.pop();ux.clear(),await Rx(e)}async function cw(e){if(!qb){let e=Jb||await jl();if(!e){U(i(`workspace.refreshFailed`),`error`);return}Jb=e,qb=e}if(Kx(qb),ux.clear(),Jw(),Ew&&ww?(Tw=await Ul(qb,ww),eS()):await Wx(qb),FC(),dS(),e!==void 0){let t=document.getElementById(`workspacePanelContent`);t&&requestAnimationFrame(()=>{t.scrollTop=e})}}function lw(){let e=document.getElementById(`workspaceBreadcrumb`);if(!qb){e.innerHTML=``;return}let t=Gx(qb).split(`/`).filter(Boolean),n=Jb?Gx(Jb).replace(/\/$/,``):null,r=``,a=``;for(let e=0;e<t.length;e++){a=e===0?/^[a-zA-Z]:$/.test(t[e])?t[e]+`/`:`/`+t[e]:(a.endsWith(`/`)?a:a+`/`)+t[e];let i=e===t.length-1,o=!n||a===n||a.startsWith(n+`/`);e>0&&(r+=`<span class="workspace-breadcrumb-sep">/</span>`),r+=i?`<span class="workspace-breadcrumb-current">${$(t[e])}</span>`:o?`<span class="workspace-breadcrumb-link" data-path="${$(a)}">${$(t[e])}</span>`:`<span class="workspace-breadcrumb-disabled">${$(t[e])}</span>`}e.innerHTML=r||`<span class="workspace-breadcrumb-current">/</span>`,e.querySelectorAll(`.workspace-breadcrumb-link`).forEach(e=>{e.addEventListener(`click`,async t=>{t.stopPropagation();let n=e.dataset.path,r=Yb.findIndex(e=>e===n);Yb=r>=0?Yb.slice(0,r):[],ux.clear(),await Rx(n)}),e.addEventListener(`dragover`,t=>{t.dataTransfer.types.includes(`application/x-workspace-move`)&&(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=`move`,e.classList.add(`drop-target`))}),e.addEventListener(`dragleave`,t=>{t.preventDefault(),t.stopPropagation(),e.classList.remove(`drop-target`)}),e.addEventListener(`drop`,async t=>{if(t.preventDefault(),t.stopPropagation(),e.classList.remove(`drop-target`),t.dataTransfer.types.includes(`application/x-workspace-move`))try{let n=JSON.parse(t.dataTransfer.getData(`application/x-workspace-move`)),r=n.path,a=e.dataset.path,o=n.name,s=Gx(r),c=Gx(a);if(s===c)return;if(c.startsWith(s+`/`)){U(i(`workspace.cannotMoveToSubdir`),`error`);return}U(i(`workspace.moving`),`info`);let l=await Zl(r,a);l.success?(U(i(`workspace.movedToTarget`,{name:o,target:a.split(/[\\/]/).pop()}),`success`),Kx(qb),Kx(a),await cw()):U(i(`workspace.moveFailed`,{error:l.error}),`error`)}catch(e){U(i(`workspace.moveFailed`,{error:e.message}),`error`)}})})}function uw(){let e=document.getElementById(`workspaceBackBtn`);e.disabled=!(Jb&&qb&&qb!==Jb)}function dw(e){let t=document.getElementById(`workspacePanelContent`);t.innerHTML=`<div class="workspace-panel-error">${$(e)}</div>`}function $(e){return e?String(e).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`):``}function fw(e){let t=(e.split(`.`).pop()||``).toLowerCase(),n={js:`javascript`,mjs:`javascript`,ts:`typescript`,jsx:`jsx`,tsx:`tsx`,html:`html`,htm:`html`,css:`css`,scss:`scss`,less:`less`,json:`json`,xml:`xml`,yaml:`yaml`,yml:`yaml`,py:`python`,java:`java`,c:`c`,cpp:`cpp`,h:`c`,go:`go`,rs:`rust`,rb:`ruby`,php:`php`,sql:`sql`,sh:`bash`,bash:`bash`,zsh:`bash`,md:`markdown`,vue:`html`,svelte:`html`};return n[t]?`language-${n[t]}`:``}async function pw(){Nl(),Jb=null,qb=null,Yb=[],ux.clear(),ww=``,Tw=[],Ew=!1,zx.clear();let e=document.getElementById(`workspacePanel`);e&&e.classList.contains(`expanded`)&&await Lx()}function mw(e){let t=document.getElementById(`workspacePanelContainer`);if(t){if(e){if(t.style.display=``,ix){let e=document.getElementById(`workspacePanel`);e&&!e.classList.contains(`expanded`)&&Fx().catch(e=>o.warn(`[WorkspacePanel] reopen panel after reconnect failed`,e))}ox&&Nx()}else t.style.display=`none`,Cw(!0)}}function hw(e,t){let n=t.toLowerCase(),r=e.toLowerCase();return r===n?``:r.startsWith(n+`/`)?e.substring(t.length+1):null}function gw(e,t){let n=t.split(`/`).filter(Boolean).pop();if(!n)return null;let r=e.lastIndexOf(`/`+n);if(r===-1)return null;let i=e.substring(r+n.length+1);return i===``?``:i}function _w(e,t){if(!e)return null;let n=Gx(t);if(!n)return null;let r=Gx(e).trim();if(!r||r===`.`||r===`~`||r.startsWith(`~/`))return null;if(!(r.startsWith(`/`)||/^[a-zA-Z]:\//.test(r)))return n+`/`+r;let i=hw(r,n);return i===null&&(i=gw(r,n)),i===null?null:i===``?n:n+`/`+i}async function vw(e){if(!(e===`~`||e&&e.startsWith(`~/`)))return e;try{let t=await Ml();if(t)return Gx(e===`~`?t:t+`/`+e.slice(2))}catch{}return e}async function yw(e){if(!e)return;let t=document.getElementById(`workspacePanel`),n=document.getElementById(`workspacePanelContainer`);if(!t||!n)return;if(t.classList.add(`expanded`),et(t),n.classList.add(`click-opened`),Jb||=await jl(),!Jb){dw(i(`workspace.noWorkspace`));return}let r=_w(await vw(e),Jb);if(!r){dw(i(`artifacts.locateFailed`));return}let a=r.lastIndexOf(`/`),o=a>0?r.substring(0,a):Jb,s=a>0?r.substring(a+1):r;Kx(o),await Rx(o);let c=e=>{let t=()=>{let t=null;return document.querySelectorAll(`.workspace-file-item`).forEach(n=>{n.dataset.name===e&&(t=n)}),t},n=t();if(n||!Xx)return n;let r=Xx.sorted.findIndex(t=>t.name===e);if(r<0)return null;let i=document.getElementById(`workspacePanelContent`);if(!i)return null;let{itemHeight:a}=Xx;return i.scrollTop=Math.max(0,r*a-i.clientHeight/2+a/2),$x(),t()};setTimeout(async()=>{let e=c(s);e||=(Kx(o),await Rx(o),await new Promise(e=>setTimeout(e,300)),c(s)),e?(e.classList.add(`highlighted`),e.scrollIntoView({behavior:`smooth`,block:`center`}),setTimeout(()=>e.classList.remove(`highlighted`),3e3)):U(i(`artifacts.fileNotFound`))},300)}async function bw(e,t){if(!e)return;let n=document.getElementById(`workspacePanel`),r=document.getElementById(`workspacePanelContainer`);if(!n||!r)return;let a=n.classList.contains(`expanded`);if(n.classList.add(`expanded`),et(n),r.classList.add(`click-opened`),Jb||=await jl(),!Jb){dw(i(`workspace.noWorkspace`));return}let o=_w(await vw(e),Jb);if(!o){dw(i(`artifacts.locateFailed`));return}await FC(!0),await wS(o,t),mx=!a}async function xw(){await FC(!0)}async function Sw(e){return!e||(Jb||=await jl(),!Jb)?null:_w(await vw(e),Jb)}async function Cw(e=!1){if(e&&await FC(!0)===!1)return;let t=document.getElementById(`workspacePanel`),n=document.getElementById(`workspacePanelContainer`);t&&(t.classList.remove(`expanded`),tt(t),e||chrome.storage.local.set({[rx]:!1}).catch(()=>{})),n&&(n.classList.remove(`hover-expanded`),n.classList.remove(`click-opened`),ix&&!e&&(ix=!1,ox=!1,n.classList.add(`closing-no-anim`),Dx(),requestAnimationFrame(()=>n.classList.remove(`closing-no-anim`))))}var ww=``,Tw=[],Ew=!1,Dw=[],Ow=-1;function kw(){try{chrome.storage.local.get([`workspaceSearchHistory`],e=>{Dw=e.workspaceSearchHistory||[]})}catch{}}function Aw(e){if(!e.trim())return;let t=Dw.indexOf(e);t!==-1&&Dw.splice(t,1),Dw.push(e),Dw.length>20&&Dw.shift();try{chrome.storage.local.set({workspaceSearchHistory:Dw})}catch{}}function jw(e){ww=e.target.value.trim();let t=document.getElementById(`workspaceSearchClear`);t.style.display=ww?``:`none`}async function Mw(){if(!ww){Ew=!1,Tw=[],eS(),dS();return}Aw(ww),Ow=-1,U(i(`workspace.searching`),`info`),Tw=await Ul(qb,ww),Ew=!0,eS(),dS()}async function Nw(){let e=document.getElementById(`workspaceSearchInput`),t=document.getElementById(`workspaceToolbar`),n=t.querySelector(`.workspace-search-box`);e.value=``,ww=``,Ew=!1,Tw=[],ux.clear(),document.getElementById(`workspaceSearchClear`).style.display=`none`,t.classList.remove(`search-focused`),n.classList.remove(`search-box-expanded`),e.blur(),await Wx(qb),dS(),Jw()}async function Pw(e,t,n){let r=n===`directory`,a=i(r?`workspace.confirmDeleteDir`:`workspace.confirmDeleteFile`,{name:t,path:e});if(typeof window.showCustomConfirm!=`function`){if(!confirm(a))return}else if(!await window.showCustomConfirm(a,i(`workspace.confirmDeleteTitle`)))return;let o=document.getElementById(`workspacePanelContent`),s=o?o.scrollTop:0;try{let t=await Al();if(!t){U(i(`workspace.agentNotConnected`),`error`);return}let n=await(await fetch(`${t.url}/api/fs/delete`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${t.token}`},body:JSON.stringify({path:e})})).json();n.success?(U(i(r?`workspace.dirDeleted`:`workspace.fileDeleted`),`success`),ux.delete(e),Jw(),await cw(s)):U(i(`workspace.deleteFailedWithError`,{error:n.error||i(`workspace.unknownError`)}),`error`)}catch(e){U(i(`workspace.deleteFailedWithError`,{error:e.message}),`error`)}}async function Fw(){if(ux.size===0)return;let e=Array.from(ux),t=e.map(e=>{let t=_x.find(t=>t.path===e)||Tw.find(t=>t.fullPath===e);return t?t.name:e.split(/[\\/]/).pop()}),n=t.slice(0,5).map(e=>`• ${e}`).join(`
|
|
1321
|
-
`)+(t.length>5?i(`workspace.batchNamesMore`,{count:t.length}):``),r=i(`workspace.confirmBatchDelete`,{count:e.length,names:n});if(typeof window.showCustomConfirm!=`function`){if(!confirm(r))return}else if(!await window.showCustomConfirm(r,i(`workspace.confirmBatchDeleteTitle`)))return;let a=document.getElementById(`workspacePanelContent`),o=a?a.scrollTop:0;try{let t=await Al();if(!t){U(i(`workspace.agentNotConnected`),`error`);return}let n=0,r=0;for(let i of e)try{(await(await fetch(`${t.url}/api/fs/delete`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${t.token}`},body:JSON.stringify({path:i})})).json()).success?(ux.delete(i),n++):r++}catch{r++}n>0?(U(i(`workspace.deletedCount`,{success:n,failed:r>0?i(`workspace.deletedCountFailed`,{count:r}):``}),r>0?`warning`:`success`),
|
|
1326
|
+
`,document.body.appendChild(t);let n=t.querySelector(`.workspace-upload-progress-cancel`);return n&&n.addEventListener(`click`,()=>{n.style.display=`none`,typeof e==`function`&&e()}),t}function tw(e,t){if(!e)return;let{percent:n,completed:r,total:a,fileName:o,loaded:s,totalBytes:c,speed:l,statusText:u}=t,d=e.querySelector(`.workspace-upload-progress-title`),f=e.querySelector(`.workspace-upload-progress-file`),p=e.querySelector(`.workspace-upload-progress-bar`),m=e.querySelector(`.workspace-upload-progress-bytes`),h=e.querySelector(`.workspace-upload-progress-speed`),g=e.classList.contains(`download-mode`)?i(`workspace.downloadInProgress`):i(`workspace.uploadInProgress`);d&&(d.textContent=u||(r!=null&&a!=null?`${g} ${r}/${a} · ${n}%`:`${g} ${n}%`)),f&&o&&(f.textContent=o,f.title=o),p&&(p.style.width=n+`%`),m&&(s!=null&&c!=null&&c>0?m.textContent=`${bl(s)} / ${bl(c)}`:s!=null&&(m.textContent=bl(s))),h&&(h.textContent=l>0?`${bl(l)}/s`:``)}function nw(e,t,n){if(!e)return;let r=e.querySelector(`.workspace-upload-progress-title`),i=e.querySelector(`.workspace-upload-progress-cancel`),a=e.querySelector(`.workspace-upload-progress-bar`);i&&(i.style.display=`none`),r&&(r.textContent=t),a&&!n&&(a.style.width=`100%`),e.classList.add(`workspace-upload-progress-done`),n&&e.classList.add(`workspace-upload-progress-error`),setTimeout(()=>{try{e.remove()}catch{}},1500)}function rw(e){let t=document.getElementById(`workspaceUploadBtn`);t&&(t.disabled=e,e?(t.dataset.originalHtml=t.innerHTML,t.innerHTML=`<span class="workspace-upload-spinner"></span>`):t.dataset.originalHtml&&(t.innerHTML=t.dataset.originalHtml,delete t.dataset.originalHtml));let n=document.getElementById(`workspacePanel`);n&&n.classList.toggle(`upload-in-progress`,e)}async function iw(e){let t=Array.from(e);if(t.length===0||fx)return;fx=!0,rw(!0);let n=await Al();if(!n){U(i(`workspace.agentNotConnectedUpload`),`error`),fx=!1,rw(!1);return}let r=new Set;try{let e=await Rl(qb);e.success&&Array.isArray(e.entries)&&(r=new Set(e.entries.map(e=>e.name)))}catch{}let a=0,o=0,s=0,c=t.reduce((e,t)=>e+t.size,0),l=Array(t.length).fill(0),u=new Set,d=!1,f=``,p=[],m=()=>{if(p.length<2)return 0;let e=p[0],t=p[p.length-1],n=(t.time-e.time)/1e3;return n<=0?0:(t.loaded-e.loaded)/n},h=ew(()=>{d=!0;for(let e of u)try{e.abort()}catch{}u.clear()}),g=e=>{e&&(f=e);let n=l.reduce((e,t)=>e+t,0),r=c>0?Math.round(n/c*100):0,i=Date.now();p.push({time:i,loaded:n}),p.length>8&&p.shift(),tw(h,{percent:r,completed:a+o+s,total:t.length,fileName:f,loaded:n,totalBytes:c,speed:m()})};g();for(let e=0;e<t.length&&!d;e+=3){let c=t.slice(e,e+3),f=await Promise.allSettled(c.map(async(t,a)=>{let o=e+a,s=yx(t.name),c=Kx(`${qb}/${s}`);if(r.has(s))throw l[o]=t.size,g(s),Error(`__SKIPPED__`);if(d)throw Error(`__CANCELLED__`);await new Promise((e,r)=>{let a=new XMLHttpRequest;u.add(a);let s=`${n.url}/api/fs/upload-stream?path=${encodeURIComponent(c)}`;a.open(`POST`,s),a.setRequestHeader(`Authorization`,`Bearer ${n.token}`),a.upload.onprogress=e=>{e.lengthComputable&&(l[o]=e.loaded,g(t.name))},a.onload=()=>{if(u.delete(a),d){r(Error(`__CANCELLED__`));return}if(a.status>=200&&a.status<300)try{let n=JSON.parse(a.responseText);n.success?(l[o]=t.size,g(t.name),e()):r(Error(n.error||i(`workspace.uploadFailed`)))}catch{r(Error(i(`workspace.parseResponseFailed`)))}else try{let e=JSON.parse(a.responseText);r(Error(e.error||i(`workspace.uploadFailedWithStatus`,{status:a.status})))}catch{r(Error(i(`workspace.uploadFailedWithStatus`,{status:a.status})))}},a.onerror=()=>{u.delete(a),r(Error(d?`__CANCELLED__`:i(`workspace.networkError`)))},a.onabort=()=>{u.delete(a),r(Error(`__CANCELLED__`))},a.send(t)})}));for(let e of f)if(e.status===`fulfilled`)a++;else{let t=e.reason&&e.reason.message?e.reason.message:``;t.includes(`__SKIPPED__`)||t.includes(`已存在`)?o++:t.includes(`__CANCELLED__`)||s++}}let _,v=!1;if(d)_=i(`workspace.uploadCanceled`),v=!0;else{let e=[];a>0&&e.push(i(`workspace.uploadSuccessCount`,{count:a})),o>0&&e.push(i(`workspace.uploadSkippedCount`,{count:o})),s>0&&e.push(i(`workspace.uploadFailedCount`,{count:s})),_=e.length>0?i(`workspace.uploadCompleteWithStats`,{stats:e.join(` / `)}):i(`workspace.uploadComplete`),v=s>0}nw(h,_,v),a>0&&U(i(`workspace.uploadedFiles`,{count:a}),`success`),o>0&&U(i(`workspace.filesSkipped`,{count:o}),`info`),s>0&&U(i(`workspace.filesUploadFailed`,{count:s}),`error`),d&&U(i(`workspace.uploadCanceled`),`info`),fx=!1,rw(!1),a>0&&(await lw(),qw(t[t.length-1].name))}function aw(){let e=document.getElementById(`workspacePanel`);if(!e)return;let t=document.getElementById(`workspacePanelContent`);t.addEventListener(`dragstart`,e=>{let t=e.target.closest(`.workspace-file-item`);if(!t)return;let n=t.dataset.path,r=t.dataset.name;e.dataTransfer.setData(`application/x-workspace-move`,JSON.stringify({path:n,name:r})),e.dataTransfer.effectAllowed=`move`,t.classList.add(`dragging`);let i=()=>{t.classList.remove(`dragging`),t.removeEventListener(`dragend`,i)};t.addEventListener(`dragend`,i)}),t.addEventListener(`dragover`,n=>{n.preventDefault(),n.stopPropagation();let r=n.target.closest(`.workspace-file-item.directory`);t.querySelectorAll(`.workspace-file-item.directory.drop-target`).forEach(e=>e.classList.remove(`drop-target`)),r?(n.dataTransfer.dropEffect=n.dataTransfer.types.includes(`application/x-workspace-move`)?`move`:`copy`,r.classList.add(`drop-target`),e.classList.remove(`drag-over`)):n.dataTransfer.types.includes(`application/x-workspace-move`)||e.classList.add(`drag-over`)}),t.addEventListener(`dragleave`,n=>{n.preventDefault(),n.stopPropagation(),t.querySelectorAll(`.workspace-file-item.directory.drop-target`).forEach(e=>e.classList.remove(`drop-target`)),e.classList.remove(`drag-over`)}),t.addEventListener(`drop`,async n=>{n.preventDefault(),n.stopPropagation();let r=n.target.closest(`.workspace-file-item.directory`);if(t.querySelectorAll(`.workspace-file-item.directory.drop-target`).forEach(e=>e.classList.remove(`drop-target`)),e.classList.remove(`drag-over`),r&&n.dataTransfer.types.includes(`application/x-workspace-move`)){try{let e=JSON.parse(n.dataTransfer.getData(`application/x-workspace-move`)),t=e.path,a=r.dataset.path,o=e.name,s=Kx(t),c=Kx(a);if(s===c)return;if(s.startsWith(c+`/`)){U(i(`workspace.cannotMoveToSubdir`),`error`);return}U(i(`workspace.moving`),`info`);let l=await Zl(t,a);if(l.success){U(i(`workspace.movedToDir`,{name:o}),`success`),qx(qb),qx(a);let e=a.split(/[\\/]/).pop();await lw(),qw(e)}else U(i(`workspace.moveFailed`,{error:l.error}),`error`)}catch(e){U(i(`workspace.moveFailed`,{error:e.message}),`error`)}return}if(r&&n.dataTransfer.files&&n.dataTransfer.files.length>0){let e=r.dataset.path;e.split(/[\\/]/).pop(),vx(qb),qb=e,await iw(n.dataTransfer.files),uw(),dw();return}if(n.dataTransfer.files&&n.dataTransfer.files.length>0){await iw(n.dataTransfer.files);return}}),e.addEventListener(`dragover`,t=>{t.preventDefault(),t.stopPropagation(),!t.dataTransfer.types.includes(`application/x-workspace-move`)&&e.classList.add(`drag-over`)}),e.addEventListener(`dragleave`,t=>{t.preventDefault(),t.stopPropagation(),!t.dataTransfer.types.includes(`application/x-workspace-move`)&&e.classList.remove(`drag-over`)}),e.addEventListener(`drop`,async t=>{if(t.preventDefault(),t.stopPropagation(),t.dataTransfer.types.includes(`application/x-workspace-move`))return;e.classList.remove(`drag-over`);let n=t.dataTransfer.files;!n||n.length===0||await iw(n)})}async function ow(){try{let e=document.getElementById(`workspaceAgentName`);if(!e)return;let t=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=t.pairedAgents||[],r=t.activeAgentId;if(r){let t=n.find(e=>e.id===r);if(t&&t.name){e.textContent=` · ${t.name}`,e.style.display=``;return}}e.textContent=``,e.style.display=`none`}catch(e){o.debug(`[WorkspacePanel] update agentname failed:`,e)}}async function sw(e,t){if(t===`local`&&!(!e.pairedAgents&&!e.activeAgentId)&&(await ow(),e.activeAgentId?.newValue!==e.activeAgentId?.oldValue)){o.debug(`[WorkspacePanel] Agent changed,refreshworking directory`),Nl(),Jb=null,qb=null,Yb=[],ux.clear(),Tw=``,Ew=[],Dw=!1,Bx.clear();let e=document.getElementById(`workspacePanel`);e&&e.classList.contains(`expanded`)&&await Rx()}}async function cw(){if(Yb.length===0)return;let e=Yb.pop();ux.clear(),await zx(e)}async function lw(e){if(!qb){let e=Jb||await jl();if(!e){U(i(`workspace.refreshFailed`),`error`);return}Jb=e,qb=e}if(qx(qb),ux.clear(),Yw(),Dw&&Tw?(Ew=await Ul(qb,Tw),tS()):await Gx(qb),IC(),fS(),e!==void 0){let t=document.getElementById(`workspacePanelContent`);t&&requestAnimationFrame(()=>{t.scrollTop=e})}}function uw(){let e=document.getElementById(`workspaceBreadcrumb`);if(!qb){e.innerHTML=``;return}let t=Kx(qb).split(`/`).filter(Boolean),n=Jb?Kx(Jb).replace(/\/$/,``):null,r=``,a=``;for(let e=0;e<t.length;e++){a=e===0?/^[a-zA-Z]:$/.test(t[e])?t[e]+`/`:`/`+t[e]:(a.endsWith(`/`)?a:a+`/`)+t[e];let i=e===t.length-1,o=!n||a===n||a.startsWith(n+`/`);e>0&&(r+=`<span class="workspace-breadcrumb-sep">/</span>`),r+=i?`<span class="workspace-breadcrumb-current">${$(t[e])}</span>`:o?`<span class="workspace-breadcrumb-link" data-path="${$(a)}">${$(t[e])}</span>`:`<span class="workspace-breadcrumb-disabled">${$(t[e])}</span>`}e.innerHTML=r||`<span class="workspace-breadcrumb-current">/</span>`,e.querySelectorAll(`.workspace-breadcrumb-link`).forEach(e=>{e.addEventListener(`click`,async t=>{t.stopPropagation();let n=e.dataset.path,r=Yb.findIndex(e=>e===n);Yb=r>=0?Yb.slice(0,r):[],ux.clear(),await zx(n)}),e.addEventListener(`dragover`,t=>{t.dataTransfer.types.includes(`application/x-workspace-move`)&&(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=`move`,e.classList.add(`drop-target`))}),e.addEventListener(`dragleave`,t=>{t.preventDefault(),t.stopPropagation(),e.classList.remove(`drop-target`)}),e.addEventListener(`drop`,async t=>{if(t.preventDefault(),t.stopPropagation(),e.classList.remove(`drop-target`),t.dataTransfer.types.includes(`application/x-workspace-move`))try{let n=JSON.parse(t.dataTransfer.getData(`application/x-workspace-move`)),r=n.path,a=e.dataset.path,o=n.name,s=Kx(r),c=Kx(a);if(s===c)return;if(c.startsWith(s+`/`)){U(i(`workspace.cannotMoveToSubdir`),`error`);return}U(i(`workspace.moving`),`info`);let l=await Zl(r,a);l.success?(U(i(`workspace.movedToTarget`,{name:o,target:a.split(/[\\/]/).pop()}),`success`),qx(qb),qx(a),await lw()):U(i(`workspace.moveFailed`,{error:l.error}),`error`)}catch(e){U(i(`workspace.moveFailed`,{error:e.message}),`error`)}})})}function dw(){let e=document.getElementById(`workspaceBackBtn`);e.disabled=!(Jb&&qb&&qb!==Jb)}function fw(e){let t=document.getElementById(`workspacePanelContent`);t.innerHTML=`<div class="workspace-panel-error">${$(e)}</div>`}function $(e){return e?String(e).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`):``}function pw(e){let t=(e.split(`.`).pop()||``).toLowerCase(),n={js:`javascript`,mjs:`javascript`,ts:`typescript`,jsx:`jsx`,tsx:`tsx`,html:`html`,htm:`html`,css:`css`,scss:`scss`,less:`less`,json:`json`,xml:`xml`,yaml:`yaml`,yml:`yaml`,py:`python`,java:`java`,c:`c`,cpp:`cpp`,h:`c`,go:`go`,rs:`rust`,rb:`ruby`,php:`php`,sql:`sql`,sh:`bash`,bash:`bash`,zsh:`bash`,md:`markdown`,vue:`html`,svelte:`html`};return n[t]?`language-${n[t]}`:``}async function mw(){Nl(),Jb=null,qb=null,Yb=[],ux.clear(),Tw=``,Ew=[],Dw=!1,Bx.clear();let e=document.getElementById(`workspacePanel`);e&&e.classList.contains(`expanded`)&&await Rx()}function hw(e){let t=document.getElementById(`workspacePanelContainer`);if(t){if(e){if(t.style.display=``,ix){let e=document.getElementById(`workspacePanel`);e&&!e.classList.contains(`expanded`)&&Fx().catch(e=>o.warn(`[WorkspacePanel] reopen panel after reconnect failed`,e))}ox&&Nx()}else t.style.display=`none`,ww(!0)}}function gw(e,t){let n=t.toLowerCase(),r=e.toLowerCase();return r===n?``:r.startsWith(n+`/`)?e.substring(t.length+1):null}function _w(e,t){let n=t.split(`/`).filter(Boolean).pop();if(!n)return null;let r=e.lastIndexOf(`/`+n);if(r===-1)return null;let i=e.substring(r+n.length+1);return i===``?``:i}function vw(e,t){if(!e)return null;let n=Kx(t);if(!n)return null;let r=Kx(e).trim();if(!r||r===`.`||r===`~`||r.startsWith(`~/`))return null;if(!(r.startsWith(`/`)||/^[a-zA-Z]:\//.test(r)))return n+`/`+r;let i=gw(r,n);return i===null&&(i=_w(r,n)),i===null?null:i===``?n:n+`/`+i}async function yw(e){if(!(e===`~`||e&&e.startsWith(`~/`)))return e;try{let t=await Ml();if(t)return Kx(e===`~`?t:t+`/`+e.slice(2))}catch{}return e}async function bw(e){if(!e)return;let t=document.getElementById(`workspacePanel`),n=document.getElementById(`workspacePanelContainer`);if(!t||!n)return;if(t.classList.add(`expanded`),et(t),n.classList.add(`click-opened`),Jb||=await jl(),!Jb){fw(i(`workspace.noWorkspace`));return}let r=vw(await yw(e),Jb);if(!r){fw(i(`artifacts.locateFailed`));return}let a=r.lastIndexOf(`/`),o=a>0?r.substring(0,a):Jb,s=a>0?r.substring(a+1):r;qx(o),await zx(o);let c=e=>{let t=()=>{let t=null;return document.querySelectorAll(`.workspace-file-item`).forEach(n=>{n.dataset.name===e&&(t=n)}),t},n=t();if(n||!Zx)return n;let r=Zx.sorted.findIndex(t=>t.name===e);if(r<0)return null;let i=document.getElementById(`workspacePanelContent`);if(!i)return null;let{itemHeight:a}=Zx;return i.scrollTop=Math.max(0,r*a-i.clientHeight/2+a/2),eS(),t()};setTimeout(async()=>{let e=c(s);e||=(qx(o),await zx(o),await new Promise(e=>setTimeout(e,300)),c(s)),e?(e.classList.add(`highlighted`),e.scrollIntoView({behavior:`smooth`,block:`center`}),setTimeout(()=>e.classList.remove(`highlighted`),3e3)):U(i(`artifacts.fileNotFound`))},300)}async function xw(e,t){if(!e)return;let n=document.getElementById(`workspacePanel`),r=document.getElementById(`workspacePanelContainer`);if(!n||!r)return;let a=n.classList.contains(`expanded`);if(n.classList.add(`expanded`),et(n),r.classList.add(`click-opened`),Jb||=await jl(),!Jb){fw(i(`workspace.noWorkspace`));return}let o=vw(await yw(e),Jb);if(!o){fw(i(`artifacts.locateFailed`));return}await IC(!0),await TS(o,t),mx=!a}async function Sw(){await IC(!0)}async function Cw(e){return!e||(Jb||=await jl(),!Jb)?null:vw(await yw(e),Jb)}async function ww(e=!1){if(e&&await IC(!0)===!1)return;let t=document.getElementById(`workspacePanel`),n=document.getElementById(`workspacePanelContainer`);t&&(t.classList.remove(`expanded`),tt(t),e||chrome.storage.local.set({[rx]:!1}).catch(()=>{})),n&&(n.classList.remove(`hover-expanded`),n.classList.remove(`click-opened`),ix&&!e&&(ix=!1,ox=!1,n.classList.add(`closing-no-anim`),Dx(),requestAnimationFrame(()=>n.classList.remove(`closing-no-anim`))))}var Tw=``,Ew=[],Dw=!1,Ow=[],kw=-1;function Aw(){try{chrome.storage.local.get([`workspaceSearchHistory`],e=>{Ow=e.workspaceSearchHistory||[]})}catch{}}function jw(e){if(!e.trim())return;let t=Ow.indexOf(e);t!==-1&&Ow.splice(t,1),Ow.push(e),Ow.length>20&&Ow.shift();try{chrome.storage.local.set({workspaceSearchHistory:Ow})}catch{}}function Mw(e){Tw=e.target.value.trim();let t=document.getElementById(`workspaceSearchClear`);t.style.display=Tw?``:`none`}async function Nw(){if(!Tw){Dw=!1,Ew=[],tS(),fS();return}jw(Tw),kw=-1,U(i(`workspace.searching`),`info`),Ew=await Ul(qb,Tw),Dw=!0,tS(),fS()}async function Pw(){let e=document.getElementById(`workspaceSearchInput`),t=document.getElementById(`workspaceToolbar`),n=t.querySelector(`.workspace-search-box`);e.value=``,Tw=``,Dw=!1,Ew=[],ux.clear(),document.getElementById(`workspaceSearchClear`).style.display=`none`,t.classList.remove(`search-focused`),n.classList.remove(`search-box-expanded`),e.blur(),await Gx(qb),fS(),Yw()}async function Fw(e,t,n){let r=n===`directory`,a=i(r?`workspace.confirmDeleteDir`:`workspace.confirmDeleteFile`,{name:t,path:e});if(typeof window.showCustomConfirm!=`function`){if(!confirm(a))return}else if(!await window.showCustomConfirm(a,i(`workspace.confirmDeleteTitle`)))return;let o=document.getElementById(`workspacePanelContent`),s=o?o.scrollTop:0;try{let t=await Al();if(!t){U(i(`workspace.agentNotConnected`),`error`);return}let n=await(await fetch(`${t.url}/api/fs/delete`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${t.token}`},body:JSON.stringify({path:e})})).json();n.success?(U(i(r?`workspace.dirDeleted`:`workspace.fileDeleted`),`success`),ux.delete(e),Yw(),await lw(s)):U(i(`workspace.deleteFailedWithError`,{error:n.error||i(`workspace.unknownError`)}),`error`)}catch(e){U(i(`workspace.deleteFailedWithError`,{error:e.message}),`error`)}}async function Iw(){if(ux.size===0)return;let e=Array.from(ux),t=e.map(e=>{let t=_x.find(t=>t.path===e)||Ew.find(t=>t.fullPath===e);return t?t.name:e.split(/[\\/]/).pop()}),n=t.slice(0,5).map(e=>`• ${e}`).join(`
|
|
1327
|
+
`)+(t.length>5?i(`workspace.batchNamesMore`,{count:t.length}):``),r=i(`workspace.confirmBatchDelete`,{count:e.length,names:n});if(typeof window.showCustomConfirm!=`function`){if(!confirm(r))return}else if(!await window.showCustomConfirm(r,i(`workspace.confirmBatchDeleteTitle`)))return;let a=document.getElementById(`workspacePanelContent`),o=a?a.scrollTop:0;try{let t=await Al();if(!t){U(i(`workspace.agentNotConnected`),`error`);return}let n=0,r=0;for(let i of e)try{(await(await fetch(`${t.url}/api/fs/delete`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${t.token}`},body:JSON.stringify({path:i})})).json()).success?(ux.delete(i),n++):r++}catch{r++}n>0?(U(i(`workspace.deletedCount`,{success:n,failed:r>0?i(`workspace.deletedCountFailed`,{count:r}):``}),r>0?`warning`:`success`),Yw(),await lw(o)):U(i(`workspace.deleteFailed`),`error`)}catch(e){U(i(`workspace.deleteFailedWithError`,{error:e.message}),`error`)}}function Lw(e,t){let n=[{bit:256,ch:`r`},{bit:128,ch:`w`},{bit:64,ch:`x`},{bit:32,ch:`r`},{bit:16,ch:`w`},{bit:8,ch:`x`},{bit:4,ch:`r`},{bit:2,ch:`w`},{bit:1,ch:`x`}],r=t?`d`:`-`;for(let t of n)r+=e&t.bit?t.ch:`-`,t.ch===`x`&&e&t.bit<<9&&(r=r.slice(0,-1)+(t.ch===`x`?`s`:`S`));let i=(e&511).toString(8).padStart(3,`0`);return`${r} (${i})`}async function Rw(e,t,n){let r=document.createElement(`div`);r.className=`modal-overlay show`,r.innerHTML=`
|
|
1322
1328
|
<div class="modal-container file-info-modal">
|
|
1323
1329
|
<button class="file-info-close" title="${i(`workspace.close`)}" style="position:absolute;top:10px;right:12px;background:none;border:none;font-size:20px;color:#999;cursor:pointer;padding:4px 8px;line-height:1;transition:color 0.15s ease;">×</button>
|
|
1324
1330
|
<div class="modal-title">${$(t)} - ${i(`workspace.fileDetailsLabel`)}</div>
|
|
@@ -1326,7 +1332,7 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1326
1332
|
<div class="modal-actions" style="display:flex;justify-content:flex-end;gap:8px;margin-top:12px;">
|
|
1327
1333
|
<button class="modal-btn-cancel" style="padding:6px 16px;border:1px solid #ddd;border-radius:6px;background:#fff;cursor:pointer;">${i(`workspace.close`)}</button>
|
|
1328
1334
|
</div>
|
|
1329
|
-
</div>`,document.body.appendChild(r);let a=()=>r.remove();r.querySelector(`.modal-btn-cancel`).addEventListener(`click`,a),r.querySelector(`.file-info-close`).addEventListener(`click`,a);try{let t=await Ql(e),n=r.querySelector(`.file-info-loading`);if(!t.success||!t.info){n.className=``,n.innerHTML=`<div class="workspace-panel-error">${i(`workspace.getDetailsFailed`,{error:t.error||i(`workspace.unknownError`)})}</div>`;return}let a=t.info,o=e=>e?new Date(e).toLocaleString(c()===`en`?`en-US`:`zh-CN`):`—`,s=a.isDirectory?i(`workspace.getTypeDir`):a.isSymbolicLink?i(`workspace.getTypeSymlink`):i(`workspace.getTypeFile`),l=a.isDirectory?null:bl(a.size)+` (${a.size.toLocaleString()} ${i(`workspace.bytes`)})`,u=a.mimeType||null,d=
|
|
1335
|
+
</div>`,document.body.appendChild(r);let a=()=>r.remove();r.querySelector(`.modal-btn-cancel`).addEventListener(`click`,a),r.querySelector(`.file-info-close`).addEventListener(`click`,a);try{let t=await Ql(e),n=r.querySelector(`.file-info-loading`);if(!t.success||!t.info){n.className=``,n.innerHTML=`<div class="workspace-panel-error">${i(`workspace.getDetailsFailed`,{error:t.error||i(`workspace.unknownError`)})}</div>`;return}let a=t.info,o=e=>e?new Date(e).toLocaleString(c()===`en`?`en-US`:`zh-CN`):`—`,s=a.isDirectory?i(`workspace.getTypeDir`):a.isSymbolicLink?i(`workspace.getTypeSymlink`):i(`workspace.getTypeFile`),l=a.isDirectory?null:bl(a.size)+` (${a.size.toLocaleString()} ${i(`workspace.bytes`)})`,u=a.mimeType||null,d=Lw(a.mode,a.isDirectory),f=[[i(`workspace.infoName`),$(a.name),a.name],[i(`workspace.infoType`),s,s],[i(`workspace.infoPath`),`<span style="word-break:break-all;">${$(a.path)}</span>`,a.path],[i(`workspace.infoSize`),l||`—`,l],[i(`workspace.infoMime`),u?$(u):`—`,u],[i(`workspace.infoMtime`),o(a.mtime),o(a.mtime)],[i(`workspace.infoCtime`),o(a.ctime),o(a.ctime)],[i(`workspace.infoAtime`),o(a.atime),o(a.atime)],[i(`workspace.infoPermission`),$(d),d]];a.uid!==void 0&&f.push([`UID`,String(a.uid),String(a.uid)]),a.gid!==void 0&&f.push([`GID`,String(a.gid),String(a.gid)]),n.className=`file-info-body`,n.innerHTML=`<table class="file-info-table">${f.map(([e,t,n])=>n==null?`<tr><td class="file-info-key">${e}</td><td class="file-info-val">${t}</td></tr>`:`<tr><td class="file-info-key">${e}</td><td class="file-info-val file-info-copyable" data-copy="${$(n)}" title="${i(`workspace.clickToCopy`)}">${t}<svg class="file-info-copy-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="12" height="12"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg></td></tr>`).join(``)}</table>`,n.querySelectorAll(`.file-info-copyable`).forEach(e=>{e.addEventListener(`click`,async()=>{let t=e.dataset.copy;if(t)try{await navigator.clipboard.writeText(t),U(i(`workspace.copiedToClipboard`),`success`)}catch{U(i(`workspace.copyFailed`),`error`)}})})}catch(e){let t=r.querySelector(`.file-info-loading`);t.className=``,t.innerHTML=`<div class="workspace-panel-error">${i(`workspace.getDetailsFailed`,{error:e.message})}</div>`}}function zw(e,t=``,n=``){return new Promise(r=>{let a=document.createElement(`div`);a.className=`modal-overlay show`,a.innerHTML=`
|
|
1330
1336
|
<div class="modal-container input-dialog" style="min-width:320px;">
|
|
1331
1337
|
<div class="modal-title">${$(e)}</div>
|
|
1332
1338
|
<input type="text" class="modal-input" value="${$(t)}" placeholder="${$(n)}" autofocus style="width:100%;padding:8px 12px;border:1px solid #ddd;border-radius:6px;font-size:14px;margin:8px 0;box-sizing:border-box;">
|
|
@@ -1334,7 +1340,7 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1334
1340
|
<button class="modal-btn-cancel" style="padding:6px 16px;border:1px solid #ddd;border-radius:6px;background:#fff;cursor:pointer;">${i(`workspace.cancel`)}</button>
|
|
1335
1341
|
<button class="modal-btn-confirm" style="padding:6px 16px;border:none;border-radius:6px;background:#4a90d9;color:#fff;cursor:pointer;">${i(`workspace.confirm`)}</button>
|
|
1336
1342
|
</div>
|
|
1337
|
-
</div>`,document.body.appendChild(a);let o=a.querySelector(`.modal-input`),s=a.querySelector(`.modal-btn-confirm`),c=a.querySelector(`.modal-btn-cancel`),l=()=>{a.remove()},u=()=>{let e=o.value.trim();l(),r(e||null)};s.addEventListener(`click`,u),c.addEventListener(`click`,()=>{l(),r(null)}),o.addEventListener(`keydown`,e=>{e.key===`Enter`&&u(),e.key===`Escape`&&(l(),r(null))}),setTimeout(()=>o.select(),50)})}async function
|
|
1343
|
+
</div>`,document.body.appendChild(a);let o=a.querySelector(`.modal-input`),s=a.querySelector(`.modal-btn-confirm`),c=a.querySelector(`.modal-btn-cancel`),l=()=>{a.remove()},u=()=>{let e=o.value.trim();l(),r(e||null)};s.addEventListener(`click`,u),c.addEventListener(`click`,()=>{l(),r(null)}),o.addEventListener(`keydown`,e=>{e.key===`Enter`&&u(),e.key===`Escape`&&(l(),r(null))}),setTimeout(()=>o.select(),50)})}async function Bw(){let e=null;try{e=await Pl()}catch{U(i(`workspace.getWorkdirInfoFailed`),`error`);return}if(!e){U(i(`workspace.cannotConnectAgent`),`error`);return}let t=e.workdir||``,n=Array.isArray(e.allowedPaths)?[...e.allowedPaths]:[];return new Promise(e=>{let r=document.createElement(`div`);r.className=`modal-overlay show`,r.innerHTML=`
|
|
1338
1344
|
<div class="modal-container switch-workdir-dialog" style="max-width:480px;width:90%;box-sizing:border-box;position:relative;">
|
|
1339
1345
|
<button class="switch-workdir-close" title="${i(`workspace.close`)}" style="position:absolute;top:10px;right:12px;width:28px;height:28px;border:none;background:transparent;color:#999;border-radius:6px;font-size:18px;cursor:pointer;display:flex;align-items:center;justify-content:center;line-height:1;padding:0;transition:all 0.2s;">✕</button>
|
|
1340
1346
|
<div class="modal-title">${i(`workspace.switchWorkdirTitle`)}</div>
|
|
@@ -1352,13 +1358,13 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1352
1358
|
<span style="flex-shrink:0;">📁</span>
|
|
1353
1359
|
<span style="flex:1;">${$(e)}</span>
|
|
1354
1360
|
${n?`<span style="flex-shrink:0;font-size:11px;color:#4a90d9;border:1px solid #4a90d9;border-radius:4px;padding:0 6px;">`+i(`workspace.currentTag`)+`</span>`:`<button class="switch-workdir-remove" data-remove-path="`+$(e)+`" title="`+i(`workspace.removeFromAllowed`)+`" style="flex-shrink:0;background:none;border:none;color:#e53e3e;cursor:pointer;font-size:16px;line-height:1;padding:2px 6px;border-radius:4px;">×</button>`}
|
|
1355
|
-
</div>`}).join(``)}f();async function p(e){if(!await window.showCustomConfirm(i(`workspace.confirmRemovePath`,{path:e}),i(`workspace.confirmRemovePathTitle`)))return;let t=await Il(e);t.success?(n=Array.isArray(t.allowedPaths)?t.allowedPaths:n.filter(t=>t!==e),f(),U(i(`workspace.removedFromAllowed`),`success`)):U(i(`workspace.removeFailedWithError`,{error:t.error||i(`workspace.unknownError`)}),`error`)}a.addEventListener(`click`,e=>{let t=e.target.closest(`.switch-workdir-remove`);if(t){e.stopPropagation(),p(t.dataset.removePath);return}let n=e.target.closest(`.switch-workdir-item:not(.current)`);n&&m(n.dataset.path)});async function m(r){if(!r){U(i(`workspace.selectOrInputPath`),`error`);return}if(r=r.trim(),r===t){U(i(`workspace.alreadyCurrentWorkdir`),`info`),d(),e(!1);return}let a=e=>e.replace(/\\/g,`/`).toLowerCase();!n.some(e=>{let t=a(r),n=a(e);return t===n||t.startsWith(n+`/`)})&&!await window.showCustomConfirm(i(`workspace.confirmSwitchToNew`,{path:r}),i(`workspace.confirmSwitchToNewTitle`))||(d(),e(await Bw(r)))}c.addEventListener(`click`,()=>m(o.value)),s.addEventListener(`click`,()=>{d(),e(!1)}),l.addEventListener(`click`,()=>{d(),e(!1)}),l.addEventListener(`mouseenter`,()=>{l.style.color=`#333`,l.style.background=`#e8e8e8`}),l.addEventListener(`mouseleave`,()=>{l.style.color=`#999`,l.style.background=`transparent`}),o.addEventListener(`keydown`,t=>{t.key===`Enter`&&(t.preventDefault(),m(o.value)),t.key===`Escape`&&(d(),e(!1))}),r.addEventListener(`click`,e=>{e.target===r&&e.stopPropagation()}),setTimeout(()=>o.focus(),50)})}async function Bw(e){let t=await Fl(e);if(!t.success)return U(i(`workspace.switchFailedWithError`,{error:t.error||i(`workspace.unknownError`)}),`error`),!1;Jb=null,qb=null,Yb=[],ux.clear(),ww=``,Tw=[],Ew=!1,zx.clear();let n=document.getElementById(`workspaceSearchInput`);n&&(n.value=``);let r=document.getElementById(`workspaceSearchClear`);r&&(r.style.display=`none`);let a=document.getElementById(`workspaceToolbar`);if(a){a.classList.remove(`search-focused`);let e=a.querySelector(`.workspace-search-box`);e&&e.classList.remove(`search-box-expanded`)}H.agentPlatform&&(H.agentPlatform={...H.agentPlatform,workdir:t.workdir});try{let{activeAgentId:e}=await chrome.storage.local.get([`activeAgentId`]);e&&(H.agentWorkdirs.set(e,t.workdir),typeof window.updateAgentItemWorkdir==`function`&&window.updateAgentItemWorkdir(e,t.workdir))}catch(e){o.debug(`[WorkspacePanel] sync dropdown column table workdir failed:`,e)}let s=document.getElementById(`workspacePanel`);return s&&s.classList.contains(`expanded`)&&await Lx(),U(i(`workspace.switchedTo`,{path:t.workdir}),`success`),!0}async function Vw(e,t,n){let r=t,a=``,o=t.lastIndexOf(`.`);n!==`directory`&&o>0&&(r=t.substring(0,o),a=t.substring(o));let s=await Rw(i(n===`directory`?`workspace.renameDir`:`workspace.renameFile`),r,i(`workspace.inputNewName`));if(!s||s===r)return;let c=s+a;try{let t=await Yl(e,c);t.success?(U(i(`workspace.renamedTo`,{name:c}),`success`),Kx(qb),await cw(),Kw(c)):U(i(`workspace.renameFailedWithError`,{error:t.error}),`error`)}catch(e){U(i(`workspace.renameFailedWithError`,{error:e.message}),`error`)}}async function Hw(){if(!qb)return;let e=await Rw(i(`workspace.newFolderTitle`),``,i(`workspace.inputFolderName`));if(!e)return;let t=Gx(`${qb}/${e}`);try{let n=await Xl(t);n.success?(U(i(`workspace.folderCreated`,{name:e}),`success`),Kx(qb),await cw(),Kw(e)):U(i(`workspace.createFailedWithError`,{error:n.error}),`error`)}catch(e){U(i(`workspace.createFailedWithError`,{error:e.message}),`error`)}}async function Uw(e){return new Promise((t,n)=>{let r=new Image,a=URL.createObjectURL(e);r.onload=()=>{URL.revokeObjectURL(a);let n=new FileReader;n.onloadend=()=>{let e=n.result,i=r.width,a=r.height,o=Math.max(i,a),s,c;o<=768?(s=o,c=.75):o<=1280?(s=768,c=.7):o<=2560?(s=1024,c=.65):o<=3840?(s=1280,c=.6):(s=1280,c=.55);let l=i,u=a;o>s&&(i>a?(u=Math.round(s/i*a),l=s):(l=Math.round(s/a*i),u=s));let d=document.createElement(`canvas`);d.width=l,d.height=u;let f=d.getContext(`2d`);f.imageSmoothingEnabled=!0,f.imageSmoothingQuality=`high`,f.drawImage(r,0,0,l,u),t({originalUrl:e,compressedUrl:d.toDataURL(`image/jpeg`,c)})},n.readAsDataURL(e)},r.onerror=()=>{URL.revokeObjectURL(a),n(Error(i(`workspace.imageLoadFailed`)))},r.src=a})}async function Ww(e){let t=[],n=[];for(let r of e){let e=r&&typeof r==`object`,i=e?r.fullPath||r.path:r,a=i.split(/[\\/]/).pop(),o;e?o=r:(o=_x.find(e=>e.path===i),o||=Tw.find(e=>e.fullPath===i));let s=o?o.size:0,c=wl(a);if(c.startsWith(`image/`)&&H.enableImageInput)n.push({name:a,size:s,type:c,path:i});else{let e={name:a,size:s,type:c,text:``,status:`done`,agentPath:i};t.push(e)}}for(let e of n)try{let t=await Al();if(t){let n=await fetch(`${t.url}/api/fs/download-stream`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${t.token}`},body:JSON.stringify({path:e.path})});if(n.ok){let{originalUrl:e,compressedUrl:t}=await Uw(await n.blob());H.attachedImages.some(e=>e.compressedUrl===t)||H.attachedImages.push({originalUrl:e,compressedUrl:t})}}}catch{}for(let e of t)H.attachedFiles.some(t=>t.name===e.name&&t.agentPath===e.agentPath)||H.attachedFiles.push(e);el(),nu();let r=t.length+n.length;r>0&&(!H.enableImageInput&&t.some(e=>e.type?.startsWith(`image/`))?U(i(`workspace.addedFilesToQuestionNoImage`,{count:r}),`success`):U(i(`workspace.addedFilesToQuestion`,{count:r}),`success`))}async function Gw(){ux.size!==0&&await Ww(Array.from(ux))}function Kw(e,t=0){let n=document.getElementById(`workspacePanelContent`);if(!n)return;if(Xx){let t=Xx.sorted.findIndex(t=>t.name===e);if(t>=0){let r=Xx.itemHeight;n.scrollTop=Math.max(0,t*r-n.clientHeight/2+r/2),$x();let i=Array.from(n.querySelectorAll(`.workspace-file-item`)).find(t=>t.dataset.name===e);i&&(i.classList.add(`highlight-new`),setTimeout(()=>i.classList.remove(`highlight-new`),2e3));return}}let r=Array.from(n.querySelectorAll(`.workspace-file-item`)).find(t=>t.dataset.name===e);r?(r.scrollIntoView({behavior:`smooth`,block:`center`}),r.classList.add(`highlight-new`),setTimeout(()=>r.classList.remove(`highlight-new`),2e3)):t<5&&setTimeout(()=>Kw(e,t+1),150)}function qw(){let e=document.getElementById(`workspaceAskBtn`);ux.size===0?e.style.display=`none`:e.style.display=``}function Jw(){let e=document.getElementById(`workspaceDownloadDirBtn`),t=document.getElementById(`workspaceBatchDeleteBtn`),n=document.getElementById(`workspaceSelectedCount`);ux.size===0?(e.style.display=`none`,t.style.display=`none`,n.style.display=`none`):(e.style.display=``,t.style.display=``,n.style.display=``,n.textContent=i(`workspace.selectedCount`,{count:ux.size}),e.disabled=dx),qw()}r(`zh`,{artifacts:{btnTitle:`文件产物({count})`,modalTitle:`本次任务的文件产物`,emptyHint:`本次任务没有产生文件产物`,fileCol:`文件`,sizeCol:`大小`,typeCol:`类型`,timeCol:`时间`,actionCol:`操作`,locate:`定位到文件`,preview:`预览`,closeBtn:`关闭`,typeWrite:`写入`,typeDelete:`删除`,typeCreate:`创建`,typeEdit:`编辑`,typeOther:`操作`,noWorkspace:`无法获取工作目录,请确认 Agent 已连接`,locateFailed:`定位文件失败`,fileNotFound:`目录已定位,但未找到该文件(可能已被删除)`,previewFailed:`预览文件失败`,previewNotSupported:`此文件类型不支持预览`,totalCount:`共 {count} 个文件`,badgeLabel:`产物`,download:`下载`,downloadFailed:`下载失败`,copyFileName:`复制文件名`,copyFilePath:`复制文件路径`,copiedName:`已复制文件名:{name}`,copiedPath:`已复制文件路径`,dblClickHint:`双击文件名可预览`,sortHint:`点击排序`,serialCol:`序号`}}),r(`en`,{artifacts:{btnTitle:`Artifacts ({count})`,modalTitle:`File Artifacts of This Task`,emptyHint:`No file artifacts produced in this task`,fileCol:`File`,sizeCol:`Size`,typeCol:`Type`,timeCol:`Time`,actionCol:`Actions`,locate:`Locate File`,preview:`Preview`,closeBtn:`Close`,typeWrite:`Write`,typeDelete:`Delete`,typeCreate:`Create`,typeEdit:`Edit`,typeOther:`Op`,noWorkspace:`Unable to access working directory. Please confirm the Agent is connected.`,locateFailed:`Failed to locate file`,fileNotFound:`Directory located, but file not found (may have been deleted)`,previewFailed:`Failed to preview file`,previewNotSupported:`Preview not supported for this file type`,totalCount:`{count} files in total`,badgeLabel:`Artifacts`,download:`Download`,downloadFailed:`Download failed`,copyFileName:`Copy File Name`,copyFilePath:`Copy File Path`,copiedName:`Copied file name: {name}`,copiedPath:`File path copied`,dblClickHint:`Double-click to preview`,sortHint:`Click to sort`,serialCol:`#`}});function Yw(e){return(e||``).replace(/\\/g,`/`).replace(/\/+/g,`/`)}function Xw(e){if(!e)return``;let t=Yw(e).split(`/`);return t[t.length-1]||``}function Zw(e){if(!e)return``;let t=Xw(e),n=t.lastIndexOf(`.`);return n>0?t.substring(n+1).toLowerCase():``}function Qw(e){return String(e??``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function $w(e,t){let n=new Set(t),r=[],i=0,a=``;for(let t of e)t===`{`?i++:t===`}`&&(i=Math.max(0,i-1)),i===0&&n.has(t)?(r.push(a),a=``):a+=t;return r.push(a),r}function eT(e){let t=e.indexOf(`{`);if(t===-1)return[e];let n=0,r=-1;for(let i=t;i<e.length;i++)if(e[i]===`{`)n++;else if(e[i]===`}`&&(n--,n===0)){r=i;break}if(r===-1)return[e];let i=e.substring(0,t),a=e.substring(t+1,r),o=e.substring(r+1),s=$w(a,`,`).map(e=>e.trim());if(s.length<=1)return[e];let c=[];for(let e of s)for(let t of eT(e))for(let e of eT(o))c.push(i+t+e);return c}function tT(e,t){let n=[],r=new Set;for(let i of e)if(i)for(let e of eT(i)){if(!e)continue;let i=t(e);!i||r.has(i)||(r.add(i),n.push(i))}return n}function nT(e){if(!e)return null;let t=e;if(typeof t==`string`)try{t=JSON.parse(t)}catch{let e=t.match(/["']?path["']?\s*[:=]\s*["']([^"']+)["']/i);return e?e[1]:null}return t&&typeof t==`object`&&(t.path||t.filePath||t.file_path||t.result?.path)||null}function rT(e){let t=[],n=0,r=``;for(let i=0;i<e.length;i++){let a=e[i];if(a===`{`?n++:a===`}`&&(n=Math.max(0,n-1)),n===0&&a===`<`&&e[i+1]===`<`){let t=iT(e,i);if(t>i){r+=e.substring(i,t),i=t-1;continue}}n===0&&a===`;`?(t.push(r),r=``):n===0&&a===`&`&&e[i+1]===`&`?(t.push(r),r=``,i++):r+=a}return t.push(r),t}function iT(e,t){let n=e.substring(t).match(/^<<-?\s*['"]?([A-Za-z_][A-Za-z0-9_]*)['"]?/);if(!n)return-1;let r=n[1],i=t+n[0].length,a=e.substring(i),o=RegExp(`\\n\\s*`+r.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)+`\\s*(?=\\n|$)`),s=a.match(o);return s?i+s.index+s[0].length:-1}function aT(e){let t=Yw(e||``).replace(/\/$/,``);if(!t)return``;let n=t.lastIndexOf(`/`);return n>0?t.substring(0,n):``}var oT=new Set([`du`,`df`,`stat`,`wc`,`file`,`cat`,`head`,`tail`,`grep`,`rg`]);function sT(e){if(!e||typeof e!=`string`)return!1;let t=rT(e);if(t.length===0)return!1;for(let e of t){let t=e.trim().split(/\s+/).filter(Boolean);for(;t.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(t[0]);)t.shift();if(!t.length)continue;let n=t[0].split(`/`).pop().toLowerCase();if(n===`sudo`&&t.length>1&&(n=t[1].split(`/`).pop().toLowerCase()),!oT.has(n))return!1}return!0}function cT(e,t){let n=t=>e===t||e.startsWith(t.endsWith(`/`)?t:t+`/`);return[...t].some(n)}function lT(e,t){if(!e||typeof e!=`string`)return t||``;let n=t||``;for(let t of rT(e)){let e=t.trim().match(/^cd\s+(.+?)\s*$/);if(!e)continue;let r=e[1].trim().replace(/^['"]|['"]$/g,``);n=r.startsWith(`/`)||r.startsWith(`~/`)?r:r===`..`?n?Yw(n).replace(/\/[^/]+$/,``)||`/`:`..`:Yw(n?n.replace(/\/$/,``)+`/`+r:r)}return n}function uT(e,t){if(!e||typeof e!=`string`)return[];let n=[],r=t||``,i=rT(e);for(let e of i){let t=e.trim();if(!t)continue;let i=t.replace(/"[^"]*"/g,`""`).replace(/'[^']*'/g,`''`),a=t.match(/^cd\s+(.+?)\s*$/);if(a){let e=a[1].trim().replace(/^['"]|['"]$/g,``);r=e.startsWith(`/`)||e.startsWith(`~/`)?e:e===`..`?r?Yw(r).replace(/\/[^/]+$/,``)||`/`:`..`:Yw(r?r.replace(/\/$/,``)+`/`+e:e);continue}let o=e=>(e=e.replace(/^['"]|['"]$/g,``),!e.startsWith(`/`)&&!e.startsWith(`~/`)&&r&&(e=Yw(r.replace(/\/$/,``)+`/`+e)),Yw(e)),s=t.match(/^(\S+)\s+.*<<-?\s*['"]?([A-Za-z_][A-Za-z0-9_]*)['"]?\s*\n([\s\S]*?)\n\s*\2\s*$/);if(s){let e=s[1].split(`/`).pop().toLowerCase(),t=s[3],r=null;if(/^python[\d.]*$/.test(e)?r=`py`:/^(ba)?sh$/.test(e)&&(r=`sh`),r){for(let e of dT(t,r))e&&n.push({path:o(e),isDir:!1});continue}}let c=i.match(/^mkdir\s+(?:-[a-z]+\s+)*(.+?)$/);if(c){let e=tT($w(c[1],` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`-`)&&e!==`""`&&e!==`''`),o);for(let t of e)n.push({path:t,isDir:!0});continue}let l=i.match(/^touch\s+(.+)$/);if(l){let e=tT($w(l[1],` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`-`)&&e!==`""`&&e!==`''`),o);for(let t of e)n.push({path:t,isDir:!1});continue}let u=null,d=i.match(/\s[>]{1,2}\s*['"]?([^\s|&;'"]+)['"]?\s*$/);if(d&&(u=d[1]),!u){let e=i.match(/^cat\s+>\s*['"]?([^\s|&;'"]+)['"]?/);e&&(u=e[1])}if(!u){let e=t.match(/^cp\s+(?:-[a-zA-Z]+\s+)*(?:.+?\s+)+?['"]?([^\s|&;'"]+)['"]?\s*$/);e&&(u=e[1])}if(!u){let e=i.match(/tee\s+(?:-[a-zA-Z]+\s+)*['"]?([^\s|&;'"]+)['"]?/);e&&(u=e[1])}if(u){let e=tT([u],o);for(let t of e)n.push({path:t,isDir:!1})}}return n}function dT(e,t){if(!e||typeof e!=`string`)return[];let n=[],r=e.split(`
|
|
1356
|
-
`);if([`sh`,`bash`,`zsh`].includes(t))for(let e of r){let t=e.trim();if(!t||t.startsWith(`#`))continue;let r=[...t.matchAll(/[>]{1,2}\s*['"]?([^\s|&;>'"]+)['"]?/g)];for(let e of r)e[1]&&!e[1].startsWith(`/dev/`)&&n.push(e[1]);let i=t.match(/^mkdir\s+(?:-[a-z]+\s+)*(.+?)$/);if(i){let e=$w(i[1],` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`-`));n.push(...e)}let a=t.match(/^touch\s+(.+)$/);if(a){let e=$w(a[1],` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`-`));n.push(...e)}let o=t.match(/^cp\s+(?:-[a-zA-Z]+\s+)*(?:.+?\s+)+?['"]?([^\s|&;'"]+)['"]?\s*$/);o&&n.push(o[1]);let s=t.match(/tee\s+(?:-[a-zA-Z]+\s+)*['"]?([^\s|&;'"]+)['"]?/);s&&n.push(s[1])}else if(t===`bat`||t===`cmd`)for(let e of r){let t=e.trim().replace(/^@/,``);if(!t||(t.toUpperCase(),/^REM\b/i.test(t)||t.startsWith(`::`))||/^ECHO\b/i.test(t)&&!/[>]{1,2}/.test(t))continue;let r=[...t.matchAll(/[>]{1,2}\s*"?([^\s|&;>"]+)"?/g)];for(let e of r)e[1]&&e[1].toUpperCase()!==`NUL`&&n.push(e[1]);let i=t.match(/^(?:mkdir|md)\s+(?:"([^"]+)"|(\S+))/i);i&&n.push(i[1]||i[2]);let a=t.match(/^copy\s+(?:\/\S+\s+)*(?:.+?\s+)+?"?([^\s|&;"]+)"?\s*$/i);a&&n.push(a[1]);let o=t.match(/^xcopy\s+(?:\/\S+\s+)*(?:"[^"]+"|\S+)\s+(?:"([^"]+)"|(\S+))/i);o&&n.push(o[1]||o[2])}else if(t===`ps1`)for(let e of r){let t=e.trim();if(!t||t.startsWith(`#`))continue;let r=[...t.matchAll(/[>]{1,2}\s*"?([^\s|;>'"]+)"?/g)];for(let e of r)e[1]&&e[1].toUpperCase()!==`NUL`&&n.push(e[1]);let i=t.match(/(?:Set-Content|Out-File|Add-Content)\s+(?:-[\w]+\s+)*"?([^";\s|]+)"?/i);i&&n.push(i[1]);let a=t.match(/New-Item\s+(?:-[\w]+\s+)*-Path\s+"?([^";\s|]+)"?/i);a&&n.push(a[1]);let o=t.match(/New-Item\s+"?([^";\s|]+)"?\s+(?:-[\w]+\s+)*-ItemType/i);o&&n.push(o[1]);let s=t.match(/Copy-Item\s+(?:-[\w]+\s+)*"?([^";\s|]+)"?\s+(?:-[\w]+\s+)*-Destination\s+"?([^";\s|]+)"?/i);s&&n.push(s[2]);let c=t.match(/Move-Item\s+(?:-[\w]+\s+)*"?([^";\s|]+)"?\s+(?:-[\w]+\s+)*-Destination\s+"?([^";\s|]+)"?/i);c&&n.push(c[2])}else if(t===`py`)for(let e of r){let t=e.trim();if(!t||t.startsWith(`#`))continue;let r=t.match(/open\s*\(\s*['"]([^'"]+)['"]\s*,\s*['"][wax][+]?['"]/);r&&n.push(r[1]);let i=t.match(/os\.(?:makedirs|mkdir)\s*\(\s*['"]([^'"]+)['"]/);i&&n.push(i[1]);let a=t.match(/shutil\.(?:copy2?|move)\s*\([^,]+,\s*['"]([^'"]+)['"]/);a&&n.push(a[1]);let o=t.match(/Path\s*\(\s*['"]([^'"]+)['"]\s*\)\s*\.\s*(?:write_text|write_bytes|touch|mkdir)/);o&&n.push(o[1])}let i=new Set;return n.filter(e=>!e||i.has(e)||(i.add(e),/\$[\w({]|%[\w]+%/.test(e))?!1:e.includes(`/`)||e.includes(`\\`)||e.includes(`.`))}function fT(e,t,n){if(!e||typeof e!=`string`||e.startsWith(`{`)||e.startsWith(`[`))return[];let r=e.split(/\s+/).filter(Boolean);if(r.length===0)return[];let i=new Set([`total`,`.`,`..`,`...`,`.git`,`.DS_Store`,`node_modules`,`__pycache__`,`.learnings`,`dist`,`.trae`]),a=r.some(e=>/^[d-][rwx-]{9}[@+*]?$/.test(e)),o=n?[...n.matchAll(/find\b[\s\S]*?-type\s+([df])/g)].map(e=>e[1]):[],s=o.length===1?o[0]:null,c=/[<>"'`|&;()[\]*?#!]/,l=new Map,u=(e,t)=>{!e||i.has(e)||/^\d+$/.test(e)||c.test(e)||(!l.has(e)||t)&&l.set(e,t)},d=e=>e.startsWith(`/`)?Yw(e):Yw((t?t.replace(/\/$/,``)+`/`:``)+e),f=e=>!(e.split(`/`).pop()||``).includes(`.`);if(r.some(e=>/^\.\/([^:]+):$/.test(e)&&e.length>3)){let e=new Set;for(let t of r){let n=t.match(/^\.\/([^:]+):$/);n&&n[1]&&e.add(n[1])}let t=null;for(let n of r){let r=n.match(/^\.\/([^:]+):$/);if(r&&r[1]){t=r[1],u(t,!0);continue}if(n.startsWith(`./`)){let t=n.slice(2);t&&!i.has(t)&&u(t,e.has(t)||f(t)&&s!==`f`);continue}if(!(i.has(n)||n.startsWith(`-`)||a||n.endsWith(`...`))){if(t===null)(n.includes(`.`)||e.has(n))&&u(n,e.has(n));else{if(n.includes(`/`)){u(n,e.has(n)||f(n));continue}let r=t+`/`+n;u(r,e.has(r)||f(r))}}}}else for(let e of r){if(i.has(e)||e.startsWith(`-`)||e.startsWith(`=`)||e.endsWith(`...`)||e.includes(`:`)||e.includes(`=`)||/^\d+$/.test(e)||/^[\d.]+[KMGTPE]?B?$/i.test(e))continue;let t=null;if(e.startsWith(`./`)){if(e.length<=2)continue;t=e.slice(2)}else if(a)continue;else{if(!e.includes(`/`)&&!/^.+\.[a-zA-Z0-9]+$/.test(e))continue;t=e}!t||i.has(t)||u(t,f(t)&&s!==`f`)}let p=[];for(let[e,t]of l)p.push({path:d(e),isDir:t});return p}function pT(e){if(!e||typeof e!=`string`)return[];let t=[],n=/cat\s+>\s*['"]?(\S+)['"]?\s*<<-?\s*['"]?([A-Za-z_][A-Za-z0-9_]*)['"]?\s*\n([\s\S]*?)\n\s*\2\s*(?=\n|$)/g,r;for(;(r=n.exec(e))!==null;){let e=r[1],n=Zw(e);[`sh`,`bash`,`zsh`,`bat`,`cmd`,`ps1`,`py`].includes(n)&&t.push({path:Yw(e),content:r[3],ext:n})}return t}function mT(e,t){if(!e||typeof e!=`string`)return null;let n=e.trim();for(let e of t){let t=Xw(e).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),r=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),i=e.replace(/\//g,`\\`).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);if(RegExp(`(?:^|[;\\s&|])(?:ba)?sh\\s+.*${t}|(?:^|[;\\s&|])python[23]?\\s+.*${t}|(?:^|[;\\s&|])node\\s+.*${t}|(?:^|[;\\s&|])\\.?/${t}|(?:^|[;\\s&|])cmd(?:\\.exe)?\\s+(?:/c|/k)\\s+.*${t}|(?:^|[;\\s&|])(?:powershell|pwsh)(?:\\.exe)?\\s+(?:-[\w-]+\\s+)*-File\\s+.*${t}|(?:^|[;\\s&|])${r}|(?:^|[;\\s&|])${i}`).test(n))return e}return null}function hT(e,t){if(!e||typeof e!=`string`)return[];let n=[],r=t||``,i=e=>(e=e.replace(/^['"]|['"]$/g,``),!e.startsWith(`/`)&&!e.startsWith(`~/`)&&!/^[A-Za-z]:[\\/]/.test(e)&&r&&(e=Yw(r.replace(/\/$/,``)+`/`+e)),Yw(e)),a=rT(e);for(let e of a){let t=e.trim();if(!t)continue;let a=t.match(/^cd\s+(?:\/[dD]\s+)?(.+?)\s*$/);if(a){let e=a[1].trim().replace(/^['"]|['"]$/g,``);r=e.startsWith(`/`)||/^[A-Za-z]:/.test(e)?Yw(e):e.startsWith(`~/`)?e:e===`..`?r?Yw(r).replace(/\/[^/]+$/,``)||`/`:`..`:Yw(r?r.replace(/\/$/,``)+`/`+e:e);continue}let o=t.match(/^rm\s+((?:-[a-zA-Z]+\s+)*)(.+)$/);if(o){let e=o[1],t=o[2],r=/r|R/i.test(e),a=tT($w(t,` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`-`)),i);for(let e of a)n.push({path:e,isDir:r});continue}let s=t.match(/^(?:del|erase)\s+((?:\/[a-zA-Z]+\s+)*)(.+)$/i);if(s){s[1];let e=s[2],t=tT($w(e,` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`/`)),i);for(let e of t)n.push({path:e,isDir:!1});continue}let c=t.match(/^(?:rmdir|rd)\s+((?:\/[a-zA-Z]+\s+)*)(.+)$/i);if(c){let e=c[1],t=c[2],r=/s|S/i.test(e),a=tT($w(t,` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`/`)),i);for(let e of a)n.push({path:e,isDir:r});continue}let l=t.match(/^Remove-Item\s+((?:-[\w-]+\s+)*(?:"[^"]+"|\S+)?(?:\s+(?:-[\w-]+\s+)*(?:"[^"]+"|\S+))*)/i);if(l){let e=l[1],t=/-Recurse/i.test(e),r=tT([...e.matchAll(/(?:"([^"]+)"|(?<![-\/])(\S+))/g)].map(e=>e[1]||e[2]).filter(e=>e&&!e.startsWith(`-`)),i);for(let e of r)n.push({path:e,isDir:t});continue}}return n}function gT(e){if(!Array.isArray(e)||e.length===0)return[];let t=[],n=new Set,r=[...e].sort((e,t)=>new Date(e.timestamp||0)-new Date(t.timestamp||0)),i=new Map;for(let e of r)if(e.nodeType===`tool_exec`&&e.status!==`failed`){if(e.action?.name===`agent_file`){let t=e.action.params;if(typeof t==`string`)try{t=JSON.parse(t)}catch{continue}if(!t||t.action!==`write`||typeof t.content!=`string`)continue;let n=Yw(t.path||t.filePath||``),r=Zw(n);[`sh`,`bash`,`zsh`,`bat`,`cmd`,`ps1`,`py`].includes(r)&&i.set(n,{content:t.content,ext:r})}else if(e.action?.name===`agent_exec`){let t=e.action.params,n=typeof t==`string`?t:t&&typeof t==`object`?t.command:null;if(typeof n==`string`)for(let e of pT(n))i.has(e.path)||i.set(e.path,{content:e.content,ext:e.ext})}}let a=[...i.keys()],o=new Map,s=(e,t)=>!t||e==null||t.timestamp==null||new Date(t.timestamp||0).getTime()>=new Date(e||0).getTime(),c=new Set,l=!1;for(let e of r){if(e.nodeType!==`tool_exec`||!e.action)continue;let r=e.action.name||``,s=e.action.params;if(s==null)continue;if(typeof s==`string`)try{s=JSON.parse(s)}catch{continue}if(typeof s!=`object`)continue;if(r===`agent_exec`){let u=s.command||``;if(!u)continue;let d=mT(u,a);if(d&&e.status!==`failed`){let a=i.get(d);if(a){let i=dT(a.content,a.ext);for(let a of i){if(!a)continue;let i=(a.startsWith(`/`),Yw(a));if(n.has(i)){let e=t.findIndex(e=>e.path===i);e>=0&&t.splice(e,1)}n.add(i),t.push({path:i,fileName:Xw(i),toolName:r,action:`typeCreate`,size:0,timestamp:e.timestamp||null,status:e.status||`unknown`,type:`file`})}}}if(e.status!==`failed`){let t=hT(u,s.cwd);for(let n of t)o.set(n.path,{isDir:n.isDir,timestamp:e.timestamp})}let f=uT(u,s.cwd);for(let e of f)if(e&&e.path){let t=e.isDir?e.path:aT(e.path);t&&c.add(t)}for(let i of f){let a=i&&i.path;if(a){if(n.has(a)){let e=t.findIndex(e=>e.path===a);e>=0&&t.splice(e,1)}n.add(a),e.status!==`failed`&&t.push({path:a,fileName:Xw(a),toolName:r,action:`typeCreate`,size:0,timestamp:e.timestamp||null,status:e.status||`unknown`,type:i.isDir?`directory`:`file`})}}let p=f.length>0||!!d||/<<-?/.test(u);if(e.status!==`failed`&&typeof e.observation==`string`){let i=lT(u,s.cwd);/\bcd\s/.test(u)&&i&&(p||l)&&c.add(Yw(i));let a=fT(e.observation,i,u);a.length>0&&!p&&(a=sT(u)?[]:a.filter(e=>cT(e.path,c)));for(let i of a){if(n.has(i.path)){let e=t.findIndex(e=>e.path===i.path);e>=0&&t.splice(e,1)}n.add(i.path),t.push({path:i.path,fileName:Xw(i.path),toolName:r,action:`typeCreate`,size:0,timestamp:e.timestamp||null,status:e.status||`unknown`,type:i.isDir?`directory`:`file`})}}e.status!==`failed`&&p&&(l=!0);continue}let u=null,d=`typeOther`;if(r===`agent_file`){let t=s.action;if(t===`write`)u=s.path||s.filePath,d=`typeWrite`;else if(t===`delete`){let t=Yw(s.path||s.filePath||``);t&&e.status!==`failed`&&o.set(t,{isDir:!1,timestamp:e.timestamp});continue}else continue}else if(r===`file_upload`)u=s.path||s.filePath||s.filename,d=`typeCreate`;else if(r===`download_file`)continue;else s.file_path&&(s.content!==void 0||s.action===`write`||s.action===`create`)&&(u=s.file_path,d=s.action===`create`?`typeCreate`:`typeWrite`);if(!u)continue;let f=Yw(nT(e.observation)||u);if(!f)continue;if(n.has(f)){let e=t.findIndex(e=>e.path===f);e>=0&&t.splice(e,1)}if(n.add(f),e.status===`failed`)continue;let p=aT(f);p&&c.add(p),l=!0;let m=0;if(e.observation){let t=e.observation;if(typeof t==`string`)try{t=JSON.parse(t)}catch{}t&&typeof t==`object`&&(m=t.size||t.fileSize||t.file_size||0)}t.push({path:f,fileName:Xw(f),toolName:r,action:d,size:m,timestamp:e.timestamp||null,status:e.status||`unknown`,type:`file`})}if(o.size>0){let e=[...o.keys()],n=(e,t)=>{if(e===t)return!0;let n=e.startsWith(`/`),r=t.startsWith(`/`);return n&&!r?e.endsWith(`/`+t)||e.endsWith(t):r&&!n?t.endsWith(`/`+e)||t.endsWith(e):!1};for(let r of t)r.deleted||(o.has(r.path)&&s(r.timestamp,o.get(r.path))||e.some(e=>{let t=o.get(e);return s(r.timestamp,t)?n(r.path,e)?!0:t&&t.isDir&&(r.path.startsWith(e+`/`)||r.path.startsWith(e+`\\`)):!1}))&&(r.deleted=!0)}return t}function _T(e){try{return Sl(e)}catch{return!1}}var vT=null,yT=null,bT=null,xT=1;function ST(e){if(!e)return`—`;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function CT(e){if(!bT)return e;let t=xT;return[...e].sort((e,n)=>{let r,i;return bT===`name`?(r=(e.fileName||e.path||``).toLowerCase(),i=(n.fileName||n.path||``).toLowerCase()):bT===`type`?(r=e.type||`file`,i=n.type||`file`):(r=new Date(e.timestamp||0).getTime(),i=new Date(n.timestamp||0).getTime()),r<i?-t:r>i?t:0})}function wT(e,t){let n=yl(e.fileName,e.type),r=i(`artifacts.${e.action}`),a=ST(e.timestamp),o=_T(e.fileName),s=`${Qw(e.path)} · ${i(`artifacts.dblClickHint`)}`;return`
|
|
1357
|
-
<tr class="artifacts-row" data-idx="${t}" data-path="${
|
|
1361
|
+
</div>`}).join(``)}f();async function p(e){if(!await window.showCustomConfirm(i(`workspace.confirmRemovePath`,{path:e}),i(`workspace.confirmRemovePathTitle`)))return;let t=await Il(e);t.success?(n=Array.isArray(t.allowedPaths)?t.allowedPaths:n.filter(t=>t!==e),f(),U(i(`workspace.removedFromAllowed`),`success`)):U(i(`workspace.removeFailedWithError`,{error:t.error||i(`workspace.unknownError`)}),`error`)}a.addEventListener(`click`,e=>{let t=e.target.closest(`.switch-workdir-remove`);if(t){e.stopPropagation(),p(t.dataset.removePath);return}let n=e.target.closest(`.switch-workdir-item:not(.current)`);n&&m(n.dataset.path)});async function m(r){if(!r){U(i(`workspace.selectOrInputPath`),`error`);return}if(r=r.trim(),r===t){U(i(`workspace.alreadyCurrentWorkdir`),`info`),d(),e(!1);return}let a=e=>e.replace(/\\/g,`/`).toLowerCase();!n.some(e=>{let t=a(r),n=a(e);return t===n||t.startsWith(n+`/`)})&&!await window.showCustomConfirm(i(`workspace.confirmSwitchToNew`,{path:r}),i(`workspace.confirmSwitchToNewTitle`))||(d(),e(await Vw(r)))}c.addEventListener(`click`,()=>m(o.value)),s.addEventListener(`click`,()=>{d(),e(!1)}),l.addEventListener(`click`,()=>{d(),e(!1)}),l.addEventListener(`mouseenter`,()=>{l.style.color=`#333`,l.style.background=`#e8e8e8`}),l.addEventListener(`mouseleave`,()=>{l.style.color=`#999`,l.style.background=`transparent`}),o.addEventListener(`keydown`,t=>{t.key===`Enter`&&(t.preventDefault(),m(o.value)),t.key===`Escape`&&(d(),e(!1))}),r.addEventListener(`click`,e=>{e.target===r&&e.stopPropagation()}),setTimeout(()=>o.focus(),50)})}async function Vw(e){let t=await Fl(e);if(!t.success)return U(i(`workspace.switchFailedWithError`,{error:t.error||i(`workspace.unknownError`)}),`error`),!1;Jb=null,qb=null,Yb=[],ux.clear(),Tw=``,Ew=[],Dw=!1,Bx.clear();let n=document.getElementById(`workspaceSearchInput`);n&&(n.value=``);let r=document.getElementById(`workspaceSearchClear`);r&&(r.style.display=`none`);let a=document.getElementById(`workspaceToolbar`);if(a){a.classList.remove(`search-focused`);let e=a.querySelector(`.workspace-search-box`);e&&e.classList.remove(`search-box-expanded`)}H.agentPlatform&&(H.agentPlatform={...H.agentPlatform,workdir:t.workdir});try{let{activeAgentId:e}=await chrome.storage.local.get([`activeAgentId`]);e&&(H.agentWorkdirs.set(e,t.workdir),typeof window.updateAgentItemWorkdir==`function`&&window.updateAgentItemWorkdir(e,t.workdir))}catch(e){o.debug(`[WorkspacePanel] sync dropdown column table workdir failed:`,e)}let s=document.getElementById(`workspacePanel`);return s&&s.classList.contains(`expanded`)&&await Rx(),U(i(`workspace.switchedTo`,{path:t.workdir}),`success`),!0}async function Hw(e,t,n){let r=t,a=``,o=t.lastIndexOf(`.`);n!==`directory`&&o>0&&(r=t.substring(0,o),a=t.substring(o));let s=await zw(i(n===`directory`?`workspace.renameDir`:`workspace.renameFile`),r,i(`workspace.inputNewName`));if(!s||s===r)return;let c=s+a;try{let t=await Yl(e,c);t.success?(U(i(`workspace.renamedTo`,{name:c}),`success`),qx(qb),await lw(),qw(c)):U(i(`workspace.renameFailedWithError`,{error:t.error}),`error`)}catch(e){U(i(`workspace.renameFailedWithError`,{error:e.message}),`error`)}}async function Uw(){if(!qb)return;let e=await zw(i(`workspace.newFolderTitle`),``,i(`workspace.inputFolderName`));if(!e)return;let t=Kx(`${qb}/${e}`);try{let n=await Xl(t);n.success?(U(i(`workspace.folderCreated`,{name:e}),`success`),qx(qb),await lw(),qw(e)):U(i(`workspace.createFailedWithError`,{error:n.error}),`error`)}catch(e){U(i(`workspace.createFailedWithError`,{error:e.message}),`error`)}}async function Ww(e){return new Promise((t,n)=>{let r=new Image,a=URL.createObjectURL(e);r.onload=()=>{URL.revokeObjectURL(a);let n=new FileReader;n.onloadend=()=>{let e=n.result,i=r.width,a=r.height,o=Math.max(i,a),s,c;o<=768?(s=o,c=.75):o<=1280?(s=768,c=.7):o<=2560?(s=1024,c=.65):o<=3840?(s=1280,c=.6):(s=1280,c=.55);let l=i,u=a;o>s&&(i>a?(u=Math.round(s/i*a),l=s):(l=Math.round(s/a*i),u=s));let d=document.createElement(`canvas`);d.width=l,d.height=u;let f=d.getContext(`2d`);f.imageSmoothingEnabled=!0,f.imageSmoothingQuality=`high`,f.drawImage(r,0,0,l,u),t({originalUrl:e,compressedUrl:d.toDataURL(`image/jpeg`,c)})},n.readAsDataURL(e)},r.onerror=()=>{URL.revokeObjectURL(a),n(Error(i(`workspace.imageLoadFailed`)))},r.src=a})}async function Gw(e){let t=[],n=[];for(let r of e){let e=r&&typeof r==`object`,i=e?r.fullPath||r.path:r,a=i.split(/[\\/]/).pop(),o;e?o=r:(o=_x.find(e=>e.path===i),o||=Ew.find(e=>e.fullPath===i));let s=o?o.size:0,c=wl(a);if(c.startsWith(`image/`)&&H.enableImageInput)n.push({name:a,size:s,type:c,path:i});else{let e={name:a,size:s,type:c,text:``,status:`done`,agentPath:i};t.push(e)}}for(let e of n)try{let t=await Al();if(t){let n=await fetch(`${t.url}/api/fs/download-stream`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${t.token}`},body:JSON.stringify({path:e.path})});if(n.ok){let{originalUrl:e,compressedUrl:t}=await Ww(await n.blob());H.attachedImages.some(e=>e.compressedUrl===t)||H.attachedImages.push({originalUrl:e,compressedUrl:t})}}}catch{}for(let e of t)H.attachedFiles.some(t=>t.name===e.name&&t.agentPath===e.agentPath)||H.attachedFiles.push(e);el(),nu();let r=t.length+n.length;r>0&&(!H.enableImageInput&&t.some(e=>e.type?.startsWith(`image/`))?U(i(`workspace.addedFilesToQuestionNoImage`,{count:r}),`success`):U(i(`workspace.addedFilesToQuestion`,{count:r}),`success`))}async function Kw(){ux.size!==0&&await Gw(Array.from(ux))}function qw(e,t=0){let n=document.getElementById(`workspacePanelContent`);if(!n)return;if(Zx){let t=Zx.sorted.findIndex(t=>t.name===e);if(t>=0){let r=Zx.itemHeight;n.scrollTop=Math.max(0,t*r-n.clientHeight/2+r/2),eS();let i=Array.from(n.querySelectorAll(`.workspace-file-item`)).find(t=>t.dataset.name===e);i&&(i.classList.add(`highlight-new`),setTimeout(()=>i.classList.remove(`highlight-new`),2e3));return}}let r=Array.from(n.querySelectorAll(`.workspace-file-item`)).find(t=>t.dataset.name===e);r?(r.scrollIntoView({behavior:`smooth`,block:`center`}),r.classList.add(`highlight-new`),setTimeout(()=>r.classList.remove(`highlight-new`),2e3)):t<5&&setTimeout(()=>qw(e,t+1),150)}function Jw(){let e=document.getElementById(`workspaceAskBtn`);ux.size===0?e.style.display=`none`:e.style.display=``}function Yw(){let e=document.getElementById(`workspaceDownloadDirBtn`),t=document.getElementById(`workspaceBatchDeleteBtn`),n=document.getElementById(`workspaceSelectedCount`);ux.size===0?(e.style.display=`none`,t.style.display=`none`,n.style.display=`none`):(e.style.display=``,t.style.display=``,n.style.display=``,n.textContent=i(`workspace.selectedCount`,{count:ux.size}),e.disabled=dx),Jw()}r(`zh`,{artifacts:{btnTitle:`文件产物({count})`,modalTitle:`本次任务的文件产物`,emptyHint:`本次任务没有产生文件产物`,fileCol:`文件`,sizeCol:`大小`,typeCol:`类型`,timeCol:`时间`,actionCol:`操作`,locate:`定位到文件`,preview:`预览`,closeBtn:`关闭`,typeWrite:`写入`,typeDelete:`删除`,typeCreate:`创建`,typeEdit:`编辑`,typeOther:`操作`,noWorkspace:`无法获取工作目录,请确认 Agent 已连接`,locateFailed:`定位文件失败`,fileNotFound:`目录已定位,但未找到该文件(可能已被删除)`,previewFailed:`预览文件失败`,previewNotSupported:`此文件类型不支持预览`,totalCount:`共 {count} 个文件`,badgeLabel:`产物`,download:`下载`,downloadFailed:`下载失败`,copyFileName:`复制文件名`,copyFilePath:`复制文件路径`,copiedName:`已复制文件名:{name}`,copiedPath:`已复制文件路径`,dblClickHint:`双击文件名可预览`,sortHint:`点击排序`,serialCol:`序号`}}),r(`en`,{artifacts:{btnTitle:`Artifacts ({count})`,modalTitle:`File Artifacts of This Task`,emptyHint:`No file artifacts produced in this task`,fileCol:`File`,sizeCol:`Size`,typeCol:`Type`,timeCol:`Time`,actionCol:`Actions`,locate:`Locate File`,preview:`Preview`,closeBtn:`Close`,typeWrite:`Write`,typeDelete:`Delete`,typeCreate:`Create`,typeEdit:`Edit`,typeOther:`Op`,noWorkspace:`Unable to access working directory. Please confirm the Agent is connected.`,locateFailed:`Failed to locate file`,fileNotFound:`Directory located, but file not found (may have been deleted)`,previewFailed:`Failed to preview file`,previewNotSupported:`Preview not supported for this file type`,totalCount:`{count} files in total`,badgeLabel:`Artifacts`,download:`Download`,downloadFailed:`Download failed`,copyFileName:`Copy File Name`,copyFilePath:`Copy File Path`,copiedName:`Copied file name: {name}`,copiedPath:`File path copied`,dblClickHint:`Double-click to preview`,sortHint:`Click to sort`,serialCol:`#`}});function Xw(e){return(e||``).replace(/\\/g,`/`).replace(/\/+/g,`/`)}function Zw(e){if(!e)return``;let t=Xw(e).split(`/`);return t[t.length-1]||``}function Qw(e){if(!e)return``;let t=Zw(e),n=t.lastIndexOf(`.`);return n>0?t.substring(n+1).toLowerCase():``}function $w(e){return String(e??``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function eT(e,t){let n=new Set(t),r=[],i=0,a=``;for(let t of e)t===`{`?i++:t===`}`&&(i=Math.max(0,i-1)),i===0&&n.has(t)?(r.push(a),a=``):a+=t;return r.push(a),r}function tT(e){let t=e.indexOf(`{`);if(t===-1)return[e];let n=0,r=-1;for(let i=t;i<e.length;i++)if(e[i]===`{`)n++;else if(e[i]===`}`&&(n--,n===0)){r=i;break}if(r===-1)return[e];let i=e.substring(0,t),a=e.substring(t+1,r),o=e.substring(r+1),s=eT(a,`,`).map(e=>e.trim());if(s.length<=1)return[e];let c=[];for(let e of s)for(let t of tT(e))for(let e of tT(o))c.push(i+t+e);return c}function nT(e,t){let n=[],r=new Set;for(let i of e)if(i)for(let e of tT(i)){if(!e)continue;let i=t(e);!i||r.has(i)||(r.add(i),n.push(i))}return n}function rT(e){if(!e)return null;let t=e;if(typeof t==`string`)try{t=JSON.parse(t)}catch{let e=t.match(/["']?path["']?\s*[:=]\s*["']([^"']+)["']/i);return e?e[1]:null}return t&&typeof t==`object`&&(t.path||t.filePath||t.file_path||t.result?.path)||null}function iT(e){let t=[],n=0,r=``;for(let i=0;i<e.length;i++){let a=e[i];if(a===`{`?n++:a===`}`&&(n=Math.max(0,n-1)),n===0&&a===`<`&&e[i+1]===`<`){let t=aT(e,i);if(t>i){r+=e.substring(i,t),i=t-1;continue}}n===0&&a===`;`?(t.push(r),r=``):n===0&&a===`&`&&e[i+1]===`&`?(t.push(r),r=``,i++):r+=a}return t.push(r),t}function aT(e,t){let n=e.substring(t).match(/^<<-?\s*['"]?([A-Za-z_][A-Za-z0-9_]*)['"]?/);if(!n)return-1;let r=n[1],i=t+n[0].length,a=e.substring(i),o=RegExp(`\\n\\s*`+r.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)+`\\s*(?=\\n|$)`),s=a.match(o);return s?i+s.index+s[0].length:-1}function oT(e){let t=Xw(e||``).replace(/\/$/,``);if(!t)return``;let n=t.lastIndexOf(`/`);return n>0?t.substring(0,n):``}var sT=new Set([`du`,`df`,`stat`,`wc`,`file`,`cat`,`head`,`tail`,`grep`,`rg`]);function cT(e){if(!e||typeof e!=`string`)return!1;let t=iT(e);if(t.length===0)return!1;for(let e of t){let t=e.trim().split(/\s+/).filter(Boolean);for(;t.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(t[0]);)t.shift();if(!t.length)continue;let n=t[0].split(`/`).pop().toLowerCase();if(n===`sudo`&&t.length>1&&(n=t[1].split(`/`).pop().toLowerCase()),!sT.has(n))return!1}return!0}function lT(e,t){let n=t=>e===t||e.startsWith(t.endsWith(`/`)?t:t+`/`);return[...t].some(n)}function uT(e,t){if(!e||typeof e!=`string`)return t||``;let n=t||``;for(let t of iT(e)){let e=t.trim().match(/^cd\s+(.+?)\s*$/);if(!e)continue;let r=e[1].trim().replace(/^['"]|['"]$/g,``);n=r.startsWith(`/`)||r.startsWith(`~/`)?r:r===`..`?n?Xw(n).replace(/\/[^/]+$/,``)||`/`:`..`:Xw(n?n.replace(/\/$/,``)+`/`+r:r)}return n}function dT(e,t){if(!e||typeof e!=`string`)return[];let n=[],r=t||``,i=iT(e);for(let e of i){let t=e.trim();if(!t)continue;let i=t.replace(/"[^"]*"/g,`""`).replace(/'[^']*'/g,`''`),a=t.match(/^cd\s+(.+?)\s*$/);if(a){let e=a[1].trim().replace(/^['"]|['"]$/g,``);r=e.startsWith(`/`)||e.startsWith(`~/`)?e:e===`..`?r?Xw(r).replace(/\/[^/]+$/,``)||`/`:`..`:Xw(r?r.replace(/\/$/,``)+`/`+e:e);continue}let o=e=>(e=e.replace(/^['"]|['"]$/g,``),!e.startsWith(`/`)&&!e.startsWith(`~/`)&&r&&(e=Xw(r.replace(/\/$/,``)+`/`+e)),Xw(e)),s=t.match(/^(\S+)\s+.*<<-?\s*['"]?([A-Za-z_][A-Za-z0-9_]*)['"]?\s*\n([\s\S]*?)\n\s*\2\s*$/);if(s){let e=s[1].split(`/`).pop().toLowerCase(),t=s[3],r=null;if(/^python[\d.]*$/.test(e)?r=`py`:/^(ba)?sh$/.test(e)&&(r=`sh`),r){for(let e of fT(t,r))e&&n.push({path:o(e),isDir:!1});continue}}let c=i.match(/^mkdir\s+(?:-[a-z]+\s+)*(.+?)$/);if(c){let e=nT(eT(c[1],` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`-`)&&e!==`""`&&e!==`''`),o);for(let t of e)n.push({path:t,isDir:!0});continue}let l=i.match(/^touch\s+(.+)$/);if(l){let e=nT(eT(l[1],` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`-`)&&e!==`""`&&e!==`''`),o);for(let t of e)n.push({path:t,isDir:!1});continue}let u=null,d=i.match(/\s[>]{1,2}\s*['"]?([^\s|&;'"]+)['"]?\s*$/);if(d&&(u=d[1]),!u){let e=i.match(/^cat\s+>\s*['"]?([^\s|&;'"]+)['"]?/);e&&(u=e[1])}if(!u){let e=t.match(/^cp\s+(?:-[a-zA-Z]+\s+)*(?:.+?\s+)+?['"]?([^\s|&;'"]+)['"]?\s*$/);e&&(u=e[1])}if(!u){let e=i.match(/tee\s+(?:-[a-zA-Z]+\s+)*['"]?([^\s|&;'"]+)['"]?/);e&&(u=e[1])}if(u){let e=nT([u],o);for(let t of e)n.push({path:t,isDir:!1})}}return n}function fT(e,t){if(!e||typeof e!=`string`)return[];let n=[],r=e.split(`
|
|
1362
|
+
`);if([`sh`,`bash`,`zsh`].includes(t))for(let e of r){let t=e.trim();if(!t||t.startsWith(`#`))continue;let r=[...t.matchAll(/[>]{1,2}\s*['"]?([^\s|&;>'"]+)['"]?/g)];for(let e of r)e[1]&&!e[1].startsWith(`/dev/`)&&n.push(e[1]);let i=t.match(/^mkdir\s+(?:-[a-z]+\s+)*(.+?)$/);if(i){let e=eT(i[1],` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`-`));n.push(...e)}let a=t.match(/^touch\s+(.+)$/);if(a){let e=eT(a[1],` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`-`));n.push(...e)}let o=t.match(/^cp\s+(?:-[a-zA-Z]+\s+)*(?:.+?\s+)+?['"]?([^\s|&;'"]+)['"]?\s*$/);o&&n.push(o[1]);let s=t.match(/tee\s+(?:-[a-zA-Z]+\s+)*['"]?([^\s|&;'"]+)['"]?/);s&&n.push(s[1])}else if(t===`bat`||t===`cmd`)for(let e of r){let t=e.trim().replace(/^@/,``);if(!t||(t.toUpperCase(),/^REM\b/i.test(t)||t.startsWith(`::`))||/^ECHO\b/i.test(t)&&!/[>]{1,2}/.test(t))continue;let r=[...t.matchAll(/[>]{1,2}\s*"?([^\s|&;>"]+)"?/g)];for(let e of r)e[1]&&e[1].toUpperCase()!==`NUL`&&n.push(e[1]);let i=t.match(/^(?:mkdir|md)\s+(?:"([^"]+)"|(\S+))/i);i&&n.push(i[1]||i[2]);let a=t.match(/^copy\s+(?:\/\S+\s+)*(?:.+?\s+)+?"?([^\s|&;"]+)"?\s*$/i);a&&n.push(a[1]);let o=t.match(/^xcopy\s+(?:\/\S+\s+)*(?:"[^"]+"|\S+)\s+(?:"([^"]+)"|(\S+))/i);o&&n.push(o[1]||o[2])}else if(t===`ps1`)for(let e of r){let t=e.trim();if(!t||t.startsWith(`#`))continue;let r=[...t.matchAll(/[>]{1,2}\s*"?([^\s|;>'"]+)"?/g)];for(let e of r)e[1]&&e[1].toUpperCase()!==`NUL`&&n.push(e[1]);let i=t.match(/(?:Set-Content|Out-File|Add-Content)\s+(?:-[\w]+\s+)*"?([^";\s|]+)"?/i);i&&n.push(i[1]);let a=t.match(/New-Item\s+(?:-[\w]+\s+)*-Path\s+"?([^";\s|]+)"?/i);a&&n.push(a[1]);let o=t.match(/New-Item\s+"?([^";\s|]+)"?\s+(?:-[\w]+\s+)*-ItemType/i);o&&n.push(o[1]);let s=t.match(/Copy-Item\s+(?:-[\w]+\s+)*"?([^";\s|]+)"?\s+(?:-[\w]+\s+)*-Destination\s+"?([^";\s|]+)"?/i);s&&n.push(s[2]);let c=t.match(/Move-Item\s+(?:-[\w]+\s+)*"?([^";\s|]+)"?\s+(?:-[\w]+\s+)*-Destination\s+"?([^";\s|]+)"?/i);c&&n.push(c[2])}else if(t===`py`)for(let e of r){let t=e.trim();if(!t||t.startsWith(`#`))continue;let r=t.match(/open\s*\(\s*['"]([^'"]+)['"]\s*,\s*['"][wax][+]?['"]/);r&&n.push(r[1]);let i=t.match(/os\.(?:makedirs|mkdir)\s*\(\s*['"]([^'"]+)['"]/);i&&n.push(i[1]);let a=t.match(/shutil\.(?:copy2?|move)\s*\([^,]+,\s*['"]([^'"]+)['"]/);a&&n.push(a[1]);let o=t.match(/Path\s*\(\s*['"]([^'"]+)['"]\s*\)\s*\.\s*(?:write_text|write_bytes|touch|mkdir)/);o&&n.push(o[1])}let i=new Set;return n.filter(e=>!e||i.has(e)||(i.add(e),/\$[\w({]|%[\w]+%/.test(e))?!1:e.includes(`/`)||e.includes(`\\`)||e.includes(`.`))}function pT(e,t,n){if(!e||typeof e!=`string`||e.startsWith(`{`)||e.startsWith(`[`))return[];let r=e.split(/\s+/).filter(Boolean);if(r.length===0)return[];let i=new Set([`total`,`.`,`..`,`...`,`.git`,`.DS_Store`,`node_modules`,`__pycache__`,`.learnings`,`dist`,`.trae`]),a=r.some(e=>/^[d-][rwx-]{9}[@+*]?$/.test(e)),o=n?[...n.matchAll(/find\b[\s\S]*?-type\s+([df])/g)].map(e=>e[1]):[],s=o.length===1?o[0]:null,c=/[<>"'`|&;()[\]*?#!]/,l=new Map,u=(e,t)=>{!e||i.has(e)||/^\d+$/.test(e)||c.test(e)||(!l.has(e)||t)&&l.set(e,t)},d=e=>e.startsWith(`/`)?Xw(e):Xw((t?t.replace(/\/$/,``)+`/`:``)+e),f=e=>!(e.split(`/`).pop()||``).includes(`.`);if(r.some(e=>/^\.\/([^:]+):$/.test(e)&&e.length>3)){let e=new Set;for(let t of r){let n=t.match(/^\.\/([^:]+):$/);n&&n[1]&&e.add(n[1])}let t=null;for(let n of r){let r=n.match(/^\.\/([^:]+):$/);if(r&&r[1]){t=r[1],u(t,!0);continue}if(n.startsWith(`./`)){let t=n.slice(2);t&&!i.has(t)&&u(t,e.has(t)||f(t)&&s!==`f`);continue}if(!(i.has(n)||n.startsWith(`-`)||a||n.endsWith(`...`))){if(t===null)(n.includes(`.`)||e.has(n))&&u(n,e.has(n));else{if(n.includes(`/`)){u(n,e.has(n)||f(n));continue}let r=t+`/`+n;u(r,e.has(r)||f(r))}}}}else for(let e of r){if(i.has(e)||e.startsWith(`-`)||e.startsWith(`=`)||e.endsWith(`...`)||e.includes(`:`)||e.includes(`=`)||/^\d+$/.test(e)||/^[\d.]+[KMGTPE]?B?$/i.test(e))continue;let t=null;if(e.startsWith(`./`)){if(e.length<=2)continue;t=e.slice(2)}else if(a)continue;else{if(!e.includes(`/`)&&!/^.+\.[a-zA-Z0-9]+$/.test(e))continue;t=e}!t||i.has(t)||u(t,f(t)&&s!==`f`)}let p=[];for(let[e,t]of l)p.push({path:d(e),isDir:t});return p}function mT(e){if(!e||typeof e!=`string`)return[];let t=[],n=/cat\s+>\s*['"]?(\S+)['"]?\s*<<-?\s*['"]?([A-Za-z_][A-Za-z0-9_]*)['"]?\s*\n([\s\S]*?)\n\s*\2\s*(?=\n|$)/g,r;for(;(r=n.exec(e))!==null;){let e=r[1],n=Qw(e);[`sh`,`bash`,`zsh`,`bat`,`cmd`,`ps1`,`py`].includes(n)&&t.push({path:Xw(e),content:r[3],ext:n})}return t}function hT(e,t){if(!e||typeof e!=`string`)return null;let n=e.trim();for(let e of t){let t=Zw(e).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),r=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),i=e.replace(/\//g,`\\`).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);if(RegExp(`(?:^|[;\\s&|])(?:ba)?sh\\s+.*${t}|(?:^|[;\\s&|])python[23]?\\s+.*${t}|(?:^|[;\\s&|])node\\s+.*${t}|(?:^|[;\\s&|])\\.?/${t}|(?:^|[;\\s&|])cmd(?:\\.exe)?\\s+(?:/c|/k)\\s+.*${t}|(?:^|[;\\s&|])(?:powershell|pwsh)(?:\\.exe)?\\s+(?:-[\w-]+\\s+)*-File\\s+.*${t}|(?:^|[;\\s&|])${r}|(?:^|[;\\s&|])${i}`).test(n))return e}return null}function gT(e,t){if(!e||typeof e!=`string`)return[];let n=[],r=t||``,i=e=>(e=e.replace(/^['"]|['"]$/g,``),!e.startsWith(`/`)&&!e.startsWith(`~/`)&&!/^[A-Za-z]:[\\/]/.test(e)&&r&&(e=Xw(r.replace(/\/$/,``)+`/`+e)),Xw(e)),a=iT(e);for(let e of a){let t=e.trim();if(!t)continue;let a=t.match(/^cd\s+(?:\/[dD]\s+)?(.+?)\s*$/);if(a){let e=a[1].trim().replace(/^['"]|['"]$/g,``);r=e.startsWith(`/`)||/^[A-Za-z]:/.test(e)?Xw(e):e.startsWith(`~/`)?e:e===`..`?r?Xw(r).replace(/\/[^/]+$/,``)||`/`:`..`:Xw(r?r.replace(/\/$/,``)+`/`+e:e);continue}let o=t.match(/^rm\s+((?:-[a-zA-Z]+\s+)*)(.+)$/);if(o){let e=o[1],t=o[2],r=/r|R/i.test(e),a=nT(eT(t,` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`-`)),i);for(let e of a)n.push({path:e,isDir:r});continue}let s=t.match(/^(?:del|erase)\s+((?:\/[a-zA-Z]+\s+)*)(.+)$/i);if(s){s[1];let e=s[2],t=nT(eT(e,` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`/`)),i);for(let e of t)n.push({path:e,isDir:!1});continue}let c=t.match(/^(?:rmdir|rd)\s+((?:\/[a-zA-Z]+\s+)*)(.+)$/i);if(c){let e=c[1],t=c[2],r=/s|S/i.test(e),a=nT(eT(t,` `).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`/`)),i);for(let e of a)n.push({path:e,isDir:r});continue}let l=t.match(/^Remove-Item\s+((?:-[\w-]+\s+)*(?:"[^"]+"|\S+)?(?:\s+(?:-[\w-]+\s+)*(?:"[^"]+"|\S+))*)/i);if(l){let e=l[1],t=/-Recurse/i.test(e),r=nT([...e.matchAll(/(?:"([^"]+)"|(?<![-\/])(\S+))/g)].map(e=>e[1]||e[2]).filter(e=>e&&!e.startsWith(`-`)),i);for(let e of r)n.push({path:e,isDir:t});continue}}return n}function _T(e){if(!Array.isArray(e)||e.length===0)return[];let t=[],n=new Set,r=[...e].sort((e,t)=>new Date(e.timestamp||0)-new Date(t.timestamp||0)),i=new Map;for(let e of r)if(e.nodeType===`tool_exec`&&e.status!==`failed`){if(e.action?.name===`agent_file`){let t=e.action.params;if(typeof t==`string`)try{t=JSON.parse(t)}catch{continue}if(!t||t.action!==`write`||typeof t.content!=`string`)continue;let n=Xw(t.path||t.filePath||``),r=Qw(n);[`sh`,`bash`,`zsh`,`bat`,`cmd`,`ps1`,`py`].includes(r)&&i.set(n,{content:t.content,ext:r})}else if(e.action?.name===`agent_exec`){let t=e.action.params,n=typeof t==`string`?t:t&&typeof t==`object`?t.command:null;if(typeof n==`string`)for(let e of mT(n))i.has(e.path)||i.set(e.path,{content:e.content,ext:e.ext})}}let a=[...i.keys()],o=new Map,s=(e,t)=>!t||e==null||t.timestamp==null||new Date(t.timestamp||0).getTime()>=new Date(e||0).getTime(),c=new Set,l=!1;for(let e of r){if(e.nodeType!==`tool_exec`||!e.action)continue;let r=e.action.name||``,s=e.action.params;if(s==null)continue;if(typeof s==`string`)try{s=JSON.parse(s)}catch{continue}if(typeof s!=`object`)continue;if(r===`agent_exec`){let u=s.command||``;if(!u)continue;let d=hT(u,a);if(d&&e.status!==`failed`){let a=i.get(d);if(a){let i=fT(a.content,a.ext);for(let a of i){if(!a)continue;let i=(a.startsWith(`/`),Xw(a));if(n.has(i)){let e=t.findIndex(e=>e.path===i);e>=0&&t.splice(e,1)}n.add(i),t.push({path:i,fileName:Zw(i),toolName:r,action:`typeCreate`,size:0,timestamp:e.timestamp||null,status:e.status||`unknown`,type:`file`})}}}if(e.status!==`failed`){let t=gT(u,s.cwd);for(let n of t)o.set(n.path,{isDir:n.isDir,timestamp:e.timestamp})}let f=dT(u,s.cwd);for(let e of f)if(e&&e.path){let t=e.isDir?e.path:oT(e.path);t&&c.add(t)}for(let i of f){let a=i&&i.path;if(a){if(n.has(a)){let e=t.findIndex(e=>e.path===a);e>=0&&t.splice(e,1)}n.add(a),e.status!==`failed`&&t.push({path:a,fileName:Zw(a),toolName:r,action:`typeCreate`,size:0,timestamp:e.timestamp||null,status:e.status||`unknown`,type:i.isDir?`directory`:`file`})}}let p=f.length>0||!!d||/<<-?/.test(u);if(e.status!==`failed`&&typeof e.observation==`string`){let i=uT(u,s.cwd);/\bcd\s/.test(u)&&i&&(p||l)&&c.add(Xw(i));let a=pT(e.observation,i,u);a.length>0&&!p&&(a=cT(u)?[]:a.filter(e=>lT(e.path,c)));for(let i of a){if(n.has(i.path)){let e=t.findIndex(e=>e.path===i.path);e>=0&&t.splice(e,1)}n.add(i.path),t.push({path:i.path,fileName:Zw(i.path),toolName:r,action:`typeCreate`,size:0,timestamp:e.timestamp||null,status:e.status||`unknown`,type:i.isDir?`directory`:`file`})}}e.status!==`failed`&&p&&(l=!0);continue}let u=null,d=`typeOther`;if(r===`agent_file`){let t=s.action;if(t===`write`)u=s.path||s.filePath,d=`typeWrite`;else if(t===`delete`){let t=Xw(s.path||s.filePath||``);t&&e.status!==`failed`&&o.set(t,{isDir:!1,timestamp:e.timestamp});continue}else continue}else if(r===`file_upload`)u=s.path||s.filePath||s.filename,d=`typeCreate`;else if(r===`download_file`)continue;else s.file_path&&(s.content!==void 0||s.action===`write`||s.action===`create`)&&(u=s.file_path,d=s.action===`create`?`typeCreate`:`typeWrite`);if(!u)continue;let f=Xw(rT(e.observation)||u);if(!f)continue;if(n.has(f)){let e=t.findIndex(e=>e.path===f);e>=0&&t.splice(e,1)}if(n.add(f),e.status===`failed`)continue;let p=oT(f);p&&c.add(p),l=!0;let m=0;if(e.observation){let t=e.observation;if(typeof t==`string`)try{t=JSON.parse(t)}catch{}t&&typeof t==`object`&&(m=t.size||t.fileSize||t.file_size||0)}t.push({path:f,fileName:Zw(f),toolName:r,action:d,size:m,timestamp:e.timestamp||null,status:e.status||`unknown`,type:`file`})}if(o.size>0){let e=[...o.keys()],n=(e,t)=>{if(e===t)return!0;let n=e.startsWith(`/`),r=t.startsWith(`/`);return n&&!r?e.endsWith(`/`+t)||e.endsWith(t):r&&!n?t.endsWith(`/`+e)||t.endsWith(e):!1};for(let r of t)r.deleted||(o.has(r.path)&&s(r.timestamp,o.get(r.path))||e.some(e=>{let t=o.get(e);return s(r.timestamp,t)?n(r.path,e)?!0:t&&t.isDir&&(r.path.startsWith(e+`/`)||r.path.startsWith(e+`\\`)):!1}))&&(r.deleted=!0)}return t}function vT(e){try{return Sl(e)}catch{return!1}}var yT=null,bT=null,xT=null,ST=1;function CT(e){if(!e)return`—`;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function wT(e){if(!xT)return e;let t=ST;return[...e].sort((e,n)=>{let r,i;return xT===`name`?(r=(e.fileName||e.path||``).toLowerCase(),i=(n.fileName||n.path||``).toLowerCase()):xT===`type`?(r=e.type||`file`,i=n.type||`file`):(r=new Date(e.timestamp||0).getTime(),i=new Date(n.timestamp||0).getTime()),r<i?-t:r>i?t:0})}function TT(e,t){let n=yl(e.fileName,e.type),r=i(`artifacts.${e.action}`),a=CT(e.timestamp),o=vT(e.fileName),s=`${$w(e.path)} · ${i(`artifacts.dblClickHint`)}`;return`
|
|
1363
|
+
<tr class="artifacts-row" data-idx="${t}" data-path="${$w(e.path)}" data-name="${$w(e.fileName)}">
|
|
1358
1364
|
<td class="col-index">${t+1}</td>
|
|
1359
1365
|
<td class="col-file">
|
|
1360
1366
|
<span class="artifact-icon">${n}</span>
|
|
1361
|
-
<span class="artifact-name" title="${s}">${
|
|
1367
|
+
<span class="artifact-name" title="${s}">${$w(e.fileName)}</span>
|
|
1362
1368
|
<button class="artifact-copy-btn" title="${i(`artifacts.copyFileName`)}">
|
|
1363
1369
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="13" height="13">
|
|
1364
1370
|
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"/>
|
|
@@ -1391,7 +1397,7 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1391
1397
|
</button>`:``}
|
|
1392
1398
|
</td>
|
|
1393
1399
|
</tr>
|
|
1394
|
-
`}function
|
|
1400
|
+
`}function ET(e,t){e.querySelectorAll(`.artifacts-row`).forEach(e=>{let n=t[parseInt(e.dataset.idx,10)];if(!n)return;e.addEventListener(`click`,e=>{e.target.closest(`.artifact-action-btn`)||e.target.closest(`.artifact-copy-btn`)||(clearTimeout(bT),bT=setTimeout(()=>{bT=null,Sw().catch(()=>{}),bw(n.path).catch(e=>{o.error(`[Artifacts] locate failed:`,e)})},250))});let r=e.querySelector(`.artifact-name`);r&&r.addEventListener(`dblclick`,e=>{e.stopPropagation(),e.preventDefault(),clearTimeout(bT),bT=null,vT(n.fileName)&&xw(n.path,n.fileName).catch(e=>{o.error(`[Artifacts] preview failed:`,e)})});let a=e.querySelector(`.artifact-copy-btn`);a&&a.addEventListener(`click`,async e=>{e.stopPropagation();let t=e.ctrlKey||e.metaKey,r=n.fileName;t&&(r=await Cw(n.path)||n.path),He(r,a),U(t?i(`artifacts.copiedPath`):i(`artifacts.copiedName`,{name:n.fileName}),`success`)});let s=e.querySelector(`.download-btn`);s&&s.addEventListener(`click`,e=>{e.stopPropagation(),OT(n)}),e.querySelectorAll(`.locate-btn, .preview-btn`).forEach(e=>{e.addEventListener(`click`,async t=>{if(t.stopPropagation(),e.classList.contains(`locate-btn`)){Sw().catch(()=>{});try{await bw(n.path)}catch(e){o.error(`[Artifacts] locate failed:`,e)}}else if(e.classList.contains(`preview-btn`))try{await xw(n.path,n.fileName)}catch(e){o.error(`[Artifacts] preview failed:`,e)}})})})}function DT(e,t){let n=wT(t),r=e.querySelector(`.artifacts-table tbody`);r.innerHTML=n.map((e,t)=>TT(e,t)).join(``),e.querySelectorAll(`.artifacts-table th.sortable`).forEach(e=>{let t=e.dataset.sort;e.classList.toggle(`sorted-asc`,t===xT&&ST===1),e.classList.toggle(`sorted-desc`,t===xT&&ST===-1)}),ET(e,n)}async function OT(e){let t=null;try{t=e.type===`directory`?await ql([e.path]):await Gl(e.path)}catch(e){t={success:!1,error:e.message}}if(!t||!t.success){let e=t&&t.error?`: ${t.error}`:``;U(i(`artifacts.downloadFailed`)+e,`error`);return}let n=URL.createObjectURL(t.blob),r=document.createElement(`a`),a=t.name||Zw(e.path)||`workspace.zip`;if(e.type===`directory`){let t=Zw(e.path);t&&(a=t.replace(/\.zip$/i,``)+`.zip`)}r.href=n,r.download=a,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),5e3)}function kT(e,t){if(!t)return!0;let n=Xw(e||``);if(!n||n.startsWith(`~/`)||n===`~`)return!1;if(!(n.startsWith(`/`)||/^[a-zA-Z]:\//.test(n)))return!0;let r=n.toLowerCase(),i=t.toLowerCase();return r===i||r.startsWith(i+`/`)}function AT(e,t){return!t||!(e===`~`||e&&e.startsWith(`~/`))?e:Xw(e===`~`?t:t+`/`+e.slice(2))}function jT(e,t){let n=e.querySelector(`.artifacts-modal-count`);n&&(n.textContent=i(`artifacts.totalCount`,{count:t.length}))}async function MT(e){if(!e||e.length===0)return!1;let t=null;try{let e=await jl();e&&(t=Xw(e))}catch{}let n=null;try{n=await Ml()}catch{}let r=!1;if(t)for(let i=e.length-1;i>=0;i--){let a=e[i];kT(AT(a.path,n),t)||(e.splice(i,1),r=!0)}if(e.length===0)return r;try{let t=new Map;await Promise.all(e.map(async e=>{let n=e.path;try{let t=await Cw(e.path);t&&(n=t)}catch{}t.has(n)||t.set(n,[]),t.get(n).push(e.path)}));let n=[...t.keys()];if(n.length===0)return r;let i=await chrome.runtime.sendMessage({type:`CHECK_FILES_EXIST`,paths:n});if(!i||!i.success||!i.results)return r;let a=new Set;for(let[e,n]of t)if(i.results[e]===!1)for(let e of n)a.add(e);if(a.size>0)for(let t=e.length-1;t>=0;t--)a.has(e[t].path)&&(e.splice(t,1),r=!0)}catch{}return r}function NT(e,t){if(!e)return;let n=e.querySelector(`.artifacts-btn-count`);t>0?(n&&(n.textContent=t),e.title=i(`artifacts.btnTitle`,{count:t}),e.style.display=``):e.style.display=`none`}function PT(e,t){!e||e.length===0||!t||MT(e).then(n=>{n&&NT(t,e.length)}).catch(()=>{})}function FT(e){if(!e)return 0;for(let t=e.length-1;t>=0;t--)e[t].deleted&&e.splice(t,1);return e.length}function IT(e,t){if(LT(),!e)return;for(let t=e.length-1;t>=0;t--)e[t].deleted&&e.splice(t,1);if(e.length===0){NT(t,0);return}xT=null,ST=1,yT=document.createElement(`div`),yT.className=`artifacts-modal-overlay`,yT.id=`artifactsModalOverlay`;let n=document.createElement(`div`);n.className=`artifacts-modal`;let r=document.createElement(`div`);r.className=`artifacts-modal-header`,r.innerHTML=`
|
|
1395
1401
|
<div class="artifacts-modal-title">
|
|
1396
1402
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:18px;height:18px;color:#4a90d9;">
|
|
1397
1403
|
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
|
|
@@ -1414,7 +1420,7 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1414
1420
|
</tr>
|
|
1415
1421
|
</thead>
|
|
1416
1422
|
<tbody></tbody>
|
|
1417
|
-
`,a.appendChild(o);let s=document.createElement(`div`);s.className=`artifacts-modal-footer`;let c=document.createElement(`button`);c.className=`artifacts-modal-close-btn`,c.textContent=i(`artifacts.closeBtn`),c.addEventListener(`click`,
|
|
1423
|
+
`,a.appendChild(o);let s=document.createElement(`div`);s.className=`artifacts-modal-footer`;let c=document.createElement(`button`);c.className=`artifacts-modal-close-btn`,c.textContent=i(`artifacts.closeBtn`),c.addEventListener(`click`,LT),s.appendChild(c),n.appendChild(r),n.appendChild(a),n.appendChild(s),yT.appendChild(n);let l=document.body,u=document.getElementById(`workspacePanelContainer`);if(u&&u.classList.contains(`embedded`)){let e=document.getElementById(`mainLeft`);e&&(yT.classList.add(`embedded-mode`),e.style.position=`relative`,l=e)}l.appendChild(yT),document.getElementById(`artifactsModalClose`).addEventListener(`click`,LT);let d=e=>{e.key===`Escape`&&(LT(),document.removeEventListener(`keydown`,d))};document.addEventListener(`keydown`,d),o.querySelectorAll(`th.sortable`).forEach(t=>{t.addEventListener(`click`,()=>{let r=t.dataset.sort;xT===r?ST=-ST:(xT=r,ST=1),DT(n,e)})}),DT(n,e),MT(e).then(r=>{if(!(!r||!yT)){if(e.length===0){let t=n.querySelector(`.artifacts-table tbody`);t&&(t.innerHTML=`<tr><td colspan="5" class="artifacts-empty">${i(`artifacts.emptyHint`)}</td></tr>`),jT(n,e)}else jT(n,e),DT(n,e);NT(t,e.length)}}).catch(()=>{})}function LT(){bT&&=(clearTimeout(bT),null),yT&&=(yT.remove(),null)}r(`zh`,{promptSelector:{noMatchAgent:`没有匹配的 Agent`,inheritGlobal:`继承全局设置`,editAgentTitle:`编辑此 Agent`,deleteAgentTitle:`删除此 Agent`,noMatchProxy:`没有匹配的代理`,unnamedProxy:`未命名代理`,enableTitle:`启用此代理`,disableTitle:`禁用此代理`,noMatchAll:`没有匹配的 Agent、网页或代理`,noTitle:`无标题`,proxyAddress:`代理地址`,deleteProxyTitle:`删除此代理`,confirmDeleteProxy:`确定要删除此代理吗?`},knowledgeSelector:{disabled:`知识库检索已关闭(可在设置页「知识库」中开启)`,notAvailable:`知识库不可用(请确认代理已连接、检索依赖已安装)`,noCollections:`暂无知识库(可在设置页「知识库」中创建)`,docChunk:`{docs} 文档 · {chunks} 分块`,disabledBadge:`已停用`,disabledTooltip:`已停用(大模型不会自主检索该库),仍可手动 @ 引用`,manualSuffix:`手动引用`}}),r(`en`,{promptSelector:{noMatchAgent:`No matching agent`,inheritGlobal:`Inherit global settings`,editAgentTitle:`Edit this agent`,deleteAgentTitle:`Delete this agent`,noMatchProxy:`No matching proxy`,unnamedProxy:`Unnamed proxy`,enableTitle:`Enable this proxy`,disableTitle:`Disable this proxy`,noMatchAll:`No matching agent, page or proxy`,noTitle:`Untitled`,proxyAddress:`Proxy address`,deleteProxyTitle:`Delete this proxy`,confirmDeleteProxy:`Are you sure you want to delete this proxy?`},knowledgeSelector:{disabled:`Knowledge retrieval is turned off (you can enable it in Settings - Knowledge)`,notAvailable:`Knowledge base unavailable (check the agent connection and installed retrieval dependencies)`,noCollections:`No knowledge base yet (create one in Settings - Knowledge)`,docChunk:`{docs} docs · {chunks} chunks`,disabledBadge:`Disabled`,disabledTooltip:`Disabled (the model won't search this knowledge base autonomously); you can still reference it manually via @`,manualSuffix:`manual`}});var RT=`pages`;async function zT(){try{let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]);return(e.pairedAgents||[]).map(t=>({...t,isActive:t.id===e.activeAgentId,isDisabled:!!t.disabled}))}catch{return[]}}var BT=!1;async function VT(e=``,t=null){let n=document.getElementById(`agentAtSelector`),r=document.getElementById(`agentAtDropdown`);Ae(),n.style.display=`block`,r.classList.add(`show`),WT(),t?await GT(t):await KT(e),HT()}async function HT(){try{let[e,t,n,r]=await Promise.all([we(),wE(),zT(),vE()]),a=document.querySelector(`#agentAtTabs .prompt-tab[data-tab="agents"]`),o=document.querySelector(`#agentAtTabs .prompt-tab[data-tab="pages"]`),s=document.querySelector(`#agentAtTabs .prompt-tab[data-tab="proxies"]`),c=document.querySelector(`#agentAtTabs .prompt-tab[data-tab="knowledge"]`);a&&(a.textContent=i(`promptSelector.agentsCount`,{count:e.length})),o&&(o.textContent=i(`promptSelector.pagesCount`,{count:t.length})),s&&(s.textContent=i(`promptSelector.proxiesCount`,{count:n.length}),s.style.display=n.length>0?``:`none`),c&&(c.textContent=i(`promptSelector.knowledgeCount`,{count:r.collections.length}),c.style.display=r.ok?``:`none`,!r.ok&&RT===`knowledge`&>(`pages`))}catch{}}function UT(){let e=document.getElementById(`agentAtSelector`),t=document.getElementById(`agentAtDropdown`);e.style.display=`none`,t.classList.remove(`show`),H.selectedAgentAtIndex=-1,H.selectedPageIndex=-1,H.selectedProxyAtIndex=-1,H.selectedKnowledgeAtIndex=-1}function WT(){let e=document.getElementById(`agentAtDropdown`);if(!e||e.dataset.initialized)return;e.dataset.initialized=`1`,e.addEventListener(`mousedown`,e=>{e.target.closest(`.prompt-item, .prompt-tab, .skill-list-item, .mcp-list-item`)&&e.preventDefault()});let t=document.getElementById(`agentAtTabs`);t&&t.querySelectorAll(`.prompt-tab`).forEach(e=>{e.addEventListener(`click`,()=>{GT(e.dataset.tab)})}),e.addEventListener(`click`,async e=>{if(e.target.closest(`#agentAddBtn`)){e.stopPropagation(),UT(),Gk(null);return}if(e.target.closest(`#proxyAddBtn`)){e.stopPropagation(),UT(),chrome.runtime.sendMessage({type:`OPEN_OPTIONS_PAGE`,hash:`agent`});return}if(e.target.closest(`#knowledgeAddBtn`)){e.stopPropagation(),UT(),chrome.runtime.sendMessage({type:`OPEN_OPTIONS_PAGE`,hash:`knowledge`});return}if(e.target.closest(`#pageAddBtn`)){e.stopPropagation(),UT(),chrome.tabs.create({});return}let t=e.target.closest(`.agent-edit-btn`);if(t){e.stopPropagation();let n=t.dataset.agentId;UT(),Gk(n);return}let n=e.target.closest(`.agent-delete-btn`);if(n){e.stopPropagation();let t=n.dataset.agentId;if(await sA(t)){let e=document.getElementById(`userInput`);await KT(e?qT(e.value):``)}}})}async function GT(e){RT=e;let t=document.getElementById(`agentAtTabs`);t&&t.querySelectorAll(`.prompt-tab`).forEach(t=>{t.classList.toggle(`active`,t.dataset.tab===e)});let n=document.getElementById(`agentAtList`),r=document.getElementById(`agentPageList`),i=document.getElementById(`agentProxyList`),a=document.getElementById(`agentKnowledgeList`);n&&(n.style.display=e===`agents`?``:`none`),r&&(r.style.display=e===`pages`?``:`none`),i&&(i.style.display=e===`proxies`?``:`none`),a&&(a.style.display=e===`knowledge`?``:`none`);let o=document.getElementById(`agentAtDropdown`);o&&o.setAttribute(`data-active-tab`,e);let s=document.getElementById(`userInput`);s&&s.focus(),await KT(s?qT(s.value):``)}async function KT(e=``){let t=document.getElementById(`agentAtTabs`),n=document.getElementById(`agentPageList`),r=document.getElementById(`agentAtList`),i=document.getElementById(`agentProxyList`),a=document.getElementById(`agentKnowledgeList`);if(e){BT=!0,t&&t.classList.add(`merged-mode`),n&&(n.style.display=`none`),i&&(i.style.display=`none`),a&&(a.style.display=`none`),r&&(r.style.display=``),await iE(e);let o=document.getElementById(`agentAtDropdown`);o&&o.setAttribute(`data-active-tab`,`merged`)}else{BT=!1,t&&t.classList.remove(`merged-mode`),t&&t.querySelectorAll(`.prompt-tab`).forEach(e=>{e.classList.toggle(`active`,e.dataset.tab===RT)}),n&&(n.style.display=RT===`pages`?``:`none`),r&&(r.style.display=RT===`agents`?``:`none`),i&&(i.style.display=RT===`proxies`?``:`none`),a&&(a.style.display=RT===`knowledge`?``:`none`);let e=document.getElementById(`agentAtDropdown`);e&&e.setAttribute(`data-active-tab`,RT),RT===`pages`?await TE(``):RT===`proxies`?await rE(``):RT===`knowledge`?await yE(``):await XT(``)}}function qT(e){let t=e.lastIndexOf(`@`);return t===-1?``:e.substring(t+1)}function JT(e){return e.id==="default"?i(`agentMgr.defaultAgentName`):e.name}function YT(e){return e.id==="default"?i(`agentMgr.defaultAgentDesc`):e.description}async function XT(e=``){let t=document.getElementById(`agentAtList`);if(!t)return;let n=await we(),r=(e||``).toLowerCase(),a=n.filter(t=>{if(!e)return!0;let n=JT(t),i=YT(t);return n&&n.toLowerCase().includes(r)||i&&i.toLowerCase().includes(r)});if(a.length===0){t.innerHTML=`<div class="prompt-empty">${i(`promptSelector.noMatchAgent`)}</div>`,H.selectedAgentAtIndex=-1;return}H.selectedAgentAtIndex=0,t.innerHTML=a.map((e,t)=>{let n=e.id===H.activeAgentId||!H.activeAgentId&&e.id==="default",r=e.toolIds?e.toolIds.length:e.toolIds===null?null:0,a=r===null?i(`promptSelector.inheritGlobal`):i(`promptSelector.toolCount`,{count:r}),o=JT(e),s=YT(e);return`
|
|
1418
1424
|
<div class="prompt-item ${t===0?`selected`:``} ${n?`agent-at-active`:``}"
|
|
1419
1425
|
data-index="${t}" data-agent-id="${W(e.id)}">
|
|
1420
1426
|
<span class="prompt-item-index">${t+1}</span>
|
|
@@ -1427,7 +1433,7 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1427
1433
|
${e.isBuiltin?``:`<span class="agent-delete-btn" data-agent-id="${W(e.id)}" title="${i(`promptSelector.deleteAgentTitle`)}">✕</span>`}
|
|
1428
1434
|
</span>
|
|
1429
1435
|
</div>
|
|
1430
|
-
`}).join(``),t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,async t=>{t.target.closest(`.agent-edit-btn`)||t.target.closest(`.agent-delete-btn`)||await
|
|
1436
|
+
`}).join(``),t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,async t=>{t.target.closest(`.agent-edit-btn`)||t.target.closest(`.agent-delete-btn`)||await cE(e.dataset.agentId)})})}async function ZT(e){if(!e?.url)return{online:!1};try{let t=new AbortController;setTimeout(()=>t.abort(),2e3);let n=await fetch(`${e.url}/api/status`,{signal:t.signal});if(!n.ok)return{online:!1};let r=await n.json();return{online:!0,version:r.version||null,platformName:r.platformName||r.platform||null,arch:r.arch||null}}catch{return{online:!1}}}var QT=new Map,$T=1e4;function eE(e){let t=QT.get(e.id);return t&&Date.now()-t.ts<$T?t:null}function tE(e,t){return e.isDisabled?`disabled`:e.isActive?t?`connected`:`disconnected`:t?`online`:`offline`}async function nE(e){if(eE(e))return;let t=await ZT(e);QT.set(e.id,{online:t.online,version:t.version||null,platformName:t.platformName||null,ts:Date.now()}),document.querySelectorAll(`.prompt-item-proxy`).forEach(n=>{if(n.dataset.proxyId===e.id){let r=n.querySelector(`.agent-at-dot`);r&&(r.className=`agent-at-dot agent-at-dot-${tE(e,t.online)}`)}})}async function rE(e=``){let t=document.getElementById(`agentProxyList`);if(!t)return;let n=await zT(),r=(e||``).toLowerCase(),a=n.filter(t=>!e||t.name.toLowerCase().includes(r)||t.url&&t.url.toLowerCase().includes(r));if(a.length===0){t.innerHTML=`<div class="prompt-empty">${i(`promptSelector.noMatchProxy`)}</div>`,H.selectedProxyAtIndex=-1;return}H.selectedProxyAtIndex=0,t.innerHTML=a.map((e,t)=>{let n=eE(e),r=e.isActive,a=e.isDisabled,o=tE(e,n?n.online:!1),s=e.name||i(`promptSelector.unnamedProxy`);return`
|
|
1431
1437
|
<div class="prompt-item ${t===0?`selected`:``} ${r?`agent-at-active`:``} ${a?`agent-disabled`:``} prompt-item-proxy"
|
|
1432
1438
|
data-index="${t}" data-proxy-id="${W(e.id)}">
|
|
1433
1439
|
<span class="prompt-item-index">${t+1}</span>
|
|
@@ -1440,7 +1446,7 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1440
1446
|
${a?`<span class="proxy-enable-btn" data-action="enable" data-id="${W(e.id)}" title="${i(`promptSelector.enableTitle`)}">▶</span>`:`<span class="proxy-disable-btn" data-action="disable" data-id="${W(e.id)}" title="${i(`promptSelector.disableTitle`)}">⏸</span>`}
|
|
1441
1447
|
<span class="proxy-delete-btn" data-action="delete" data-id="${W(e.id)}" title="${i(`common.delete`)}">✕</span>
|
|
1442
1448
|
</div>
|
|
1443
|
-
`}).join(``),t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,async t=>{let n=t.target.closest(`.proxy-disable-btn, .proxy-delete-btn, .proxy-enable-btn`);if(n){t.stopPropagation(),await
|
|
1449
|
+
`}).join(``),t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,async t=>{let n=t.target.closest(`.proxy-disable-btn, .proxy-delete-btn, .proxy-enable-btn`);if(n){t.stopPropagation(),await CE(n.dataset.action,n.dataset.id);return}await bE(e.dataset.proxyId)})}),a.forEach(e=>nE(e))}async function iE(e=``){let t=document.getElementById(`agentAtList`);if(!t)return;let n=e.toLowerCase(),[r,a,o,s]=await Promise.all([we(),wE(),zT(),vE()]),c=r.filter(e=>{let t=JT(e),r=YT(e);return t&&t.toLowerCase().includes(n)||r&&r.toLowerCase().includes(n)}),l=a.filter(e=>{if(!e.url)return!1;let t=(e.title||``).toLowerCase().includes(n),r=e.url.toLowerCase().includes(n);return t||r}),u=o.filter(e=>e.name.toLowerCase().includes(n)||e.url&&e.url.toLowerCase().includes(n)),d=s.ok?s.collections.filter(e=>e.name&&e.name.toLowerCase().includes(n)||e.description&&e.description.toLowerCase().includes(n)):[],f=c.length+l.length+u.length+d.length,p=document.getElementById(`agentAtMergedTitle`);if(p&&(p.textContent=i(`promptSelector.mergedTitleCount`,{count:f})),f===0){t.innerHTML=`<div class="prompt-empty">${i(`promptSelector.noMatchAll`)}</div>`,H.selectedAgentAtIndex=-1;return}H.selectedAgentAtIndex=0;let m=``,h=0;c.forEach(e=>{let t=e.id===H.activeAgentId||!H.activeAgentId&&e.id==="default",n=e.toolIds?e.toolIds.length:e.toolIds===null?null:0,r=n===null?i(`promptSelector.inheritGlobal`):i(`promptSelector.toolCount`,{count:n}),a=JT(e),o=YT(e);m+=`
|
|
1444
1450
|
<div class="prompt-item${h===0?` selected`:``}${t?` agent-at-active`:``}"
|
|
1445
1451
|
data-index="${h}" data-type="agent" data-agent-id="${W(e.id)}">
|
|
1446
1452
|
<span class="prompt-item-index">${h+1}</span>
|
|
@@ -1474,7 +1480,7 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1474
1480
|
<span class="prompt-item-content">${W(e.name||``)}</span>
|
|
1475
1481
|
${r?`<span class="knowledge-item-badge badge-disabled">${i(`knowledgeSelector.disabledBadge`)}</span>`:``}
|
|
1476
1482
|
<span class="prompt-item-code">${W(n)}</span>
|
|
1477
|
-
</div>`,h++}),u.forEach(e=>{let t=e.isActive,n=e.isDisabled,r
|
|
1483
|
+
</div>`,h++}),u.forEach(e=>{let t=e.isActive,n=e.isDisabled,r=eE(e),a=tE(e,r?r.online:!1),o=e.name||i(`promptSelector.unnamedProxy`);m+=`
|
|
1478
1484
|
<div class="prompt-item${h===0?` selected`:``}${t?` agent-at-active`:``}${n?` agent-disabled`:``} prompt-item-proxy"
|
|
1479
1485
|
data-index="${h}" data-type="proxy" data-proxy-id="${W(e.id)}">
|
|
1480
1486
|
<span class="prompt-item-index">${h+1}</span>
|
|
@@ -1484,12 +1490,12 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1484
1490
|
${t?`<span class="agent-item-actions"><span class="agent-active-mark">✓</span></span>`:``}
|
|
1485
1491
|
${n?`<span class="proxy-enable-btn" data-action="enable" data-id="${W(e.id)}" title="${i(`promptSelector.enableTitle`)}">▶</span>`:`<span class="proxy-disable-btn" data-action="disable" data-id="${W(e.id)}" title="${i(`promptSelector.disableTitle`)}">⏸</span>`}
|
|
1486
1492
|
<span class="proxy-delete-btn" data-action="delete" data-id="${W(e.id)}" title="${i(`common.delete`)}">✕</span>
|
|
1487
|
-
</div>`,h++}),t.innerHTML=m,t.querySelectorAll(`img.favicon-img`).forEach(e=>{e.addEventListener(`error`,()=>{e.style.display=`none`})}),u.forEach(e=>
|
|
1493
|
+
</div>`,h++}),t.innerHTML=m,t.querySelectorAll(`img.favicon-img`).forEach(e=>{e.addEventListener(`error`,()=>{e.style.display=`none`})}),u.forEach(e=>nE(e)),t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,async t=>{let n=t.target.closest(`.page-action-btn`);if(n){t.stopPropagation(),AE(parseInt(n.dataset.tabId),n.dataset.action);return}let r=t.target.closest(`.proxy-disable-btn, .proxy-delete-btn, .proxy-enable-btn`);if(r){t.stopPropagation(),await CE(r.dataset.action,r.dataset.id);return}if(t.target.closest(`.agent-edit-btn`)||t.target.closest(`.agent-delete-btn`))return;let i=e.dataset.type;i===`agent`?await cE(e.dataset.agentId):i===`page`?lE(parseInt(e.dataset.tabId)):i===`knowledge`?(dE({id:e.dataset.kbId,name:e.dataset.kbName,enabled:e.dataset.kbDisabled!==`1`}),(t.ctrlKey||t.metaKey)&&UT()):i===`proxy`&&await bE(e.dataset.proxyId)})})}function aE(e){let t;t=BT?H.selectedAgentAtIndex:RT===`proxies`?H.selectedProxyAtIndex:RT===`knowledge`?H.selectedKnowledgeAtIndex:H.selectedAgentAtIndex,e.forEach((e,n)=>{n===t?(e.classList.add(`selected`),e.scrollIntoView({block:`nearest`})):e.classList.remove(`selected`)})}function oE(){let e=document.getElementById(`userInput`);if(!e)return;let t=e.value,n=t.lastIndexOf(`@`);n!==-1&&(e.value=t.substring(0,n)),e.focus(),e.selectionStart=e.selectionEnd=e.value.length}function sE(){let e=document.getElementById(`userInput`);e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length)}async function cE(e,{clearTrigger:t=!0}={}){t?oE():sE(),UT(),await jk(e),ke()}function lE(e){oE(),chrome.tabs.get(e,e=>{if(chrome.runtime.lastError||!e){o.error(`[AgentAtSelector] getlabelpageinfo failed:`,chrome.runtime.lastError);return}DE(e),UT();let t=document.getElementById(`userInput`);t&&(t.focus(),ke())})}function uE(){let e=new Set(H.knowledgeRefs.map(e=>e.id));document.querySelectorAll(`.prompt-item-knowledge`).forEach(t=>{let n=e.has(t.dataset.kbId);t.classList.toggle(`agent-at-active`,n),t.classList.toggle(`picked`,n)})}function dE(e,{clearTrigger:t=!0}={}){t?oE():sE();let n=H.knowledgeRefs.findIndex(t=>t.id===e.id);n>=0?H.knowledgeRefs.splice(n,1):H.knowledgeRefs.push({id:e.id,name:e.name||e.id,enabled:e.enabled!==!1}),uE(),mE(),ke()}function fE(e){H.knowledgeRefs=H.knowledgeRefs.filter(t=>t.id!==e),uE(),mE()}function pE(){H.knowledgeRefs=[],uE(),mE()}function mE(){let e=document.getElementById(`knowledgeIndicator`);if(e){if(H.knowledgeRefs.length===0){e.style.display=`none`,e.innerHTML=``;return}e.innerHTML=H.knowledgeRefs.map(e=>{let t=e.enabled===!1,n=t?`${e.name} (${i(`knowledgeSelector.manualSuffix`)})`:e.name;return`
|
|
1488
1494
|
<span class="knowledge-chip${t?` knowledge-chip-manual`:``}">
|
|
1489
1495
|
<span class="knowledge-chip-name" title="${W(t?i(`knowledgeSelector.disabledTooltip`):e.name)}">📚 ${W(n)}</span>
|
|
1490
1496
|
<button class="knowledge-chip-close" data-kb-id="${W(e.id)}" title="${i(`common.delete`)}">✕</button>
|
|
1491
1497
|
</span>
|
|
1492
|
-
`}).join(``),e.querySelectorAll(`.knowledge-chip-close`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),
|
|
1498
|
+
`}).join(``),e.querySelectorAll(`.knowledge-chip-close`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),fE(e.dataset.kbId)})}),e.style.display=`flex`}}var hE={ok:!1,collections:[],ts:0},gE=null,_E=15e3;async function vE(e=!1){let t=Date.now(),{ragEnabled:n}=await chrome.storage.local.get(`ragEnabled`);return n===!0?!e&&hE.ts&&t-hE.ts<_E?hE:gE||(gE=new Promise(e=>{try{chrome.runtime.sendMessage({type:`RAG_LIST_COLLECTIONS`},t=>{hE=chrome.runtime.lastError||!t||!t.success?{ok:!1,collections:[],ts:Date.now()}:{ok:!0,collections:[...t.collections||[]].sort((e,t)=>(e.enabled===!1)-+(t.enabled===!1)),ts:Date.now()},e(hE)})}catch{hE={ok:!1,collections:[],ts:Date.now()},e(hE)}}).finally(()=>{gE=null}),gE):{ok:!1,disabled:!0,collections:[],ts:Date.now()}}async function yE(e=``){let t=document.getElementById(`agentKnowledgeList`);if(!t)return;let n=await vE();if(!n.ok){let e=n.disabled?`knowledgeSelector.disabled`:`knowledgeSelector.notAvailable`;t.innerHTML=`<div class="prompt-empty">${i(e)}</div>`,H.selectedKnowledgeAtIndex=-1;return}let r=(e||``).toLowerCase(),a=n.collections.filter(t=>!e||t.name&&t.name.toLowerCase().includes(r)||t.description&&t.description.toLowerCase().includes(r));if(a.length===0){t.innerHTML=`<div class="prompt-empty">${i(`knowledgeSelector.noCollections`)}</div>`,H.selectedKnowledgeAtIndex=-1;return}H.selectedKnowledgeAtIndex=0,t.innerHTML=a.map((e,t)=>{let n=H.knowledgeRefs.some(t=>t.id===e.id),r=i(`knowledgeSelector.docChunk`,{docs:e.documentCount||0,chunks:e.chunkCount||0}),a=e.enabled===!1;return`
|
|
1493
1499
|
<div class="prompt-item ${t===0?`selected`:``} ${n?`agent-at-active picked`:``} ${a?`knowledge-item-disabled`:``} prompt-item-knowledge"
|
|
1494
1500
|
data-index="${t}" data-kb-id="${W(e.id)}" data-kb-name="${W(e.name||``)}"
|
|
1495
1501
|
data-kb-disabled="${a?`1`:`0`}"${a?` title="${W(i(`knowledgeSelector.disabledTooltip`))}"`:``}>
|
|
@@ -1499,7 +1505,7 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1499
1505
|
${a?`<span class="knowledge-item-badge badge-disabled">${i(`knowledgeSelector.disabledBadge`)}</span>`:``}
|
|
1500
1506
|
<span class="prompt-item-code">${W(r)}</span>
|
|
1501
1507
|
</div>
|
|
1502
|
-
`}).join(``),t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,t=>{
|
|
1508
|
+
`}).join(``),t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,t=>{dE({id:e.dataset.kbId,name:e.dataset.kbName,enabled:e.dataset.kbDisabled!==`1`}),(t.ctrlKey||t.metaKey)&&UT()})})}async function bE(e,{clearTrigger:t=!0}={}){t?oE():sE(),UT();try{await chrome.storage.local.set({activeAgentId:e}),chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!0,agentId:e}),o.debug(`[AgentAtSelector] switched to agent:`,e)}catch(e){o.error(`[AgentAtSelector] switchagent failed:`,e)}ke()}var xE=!1;function SE(){xE||(xE=!0,chrome.tabs.onActivated.addListener(()=>{let e=document.getElementById(`agentAtSelector`);if(!e||e.style.display!==`block`||RT!==`pages`&&!BT)return;let t=document.getElementById(`userInput`);KT(t?qT(t.value):``)}))}SE();async function CE(e,t){let n=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),r=n.pairedAgents||[];switch(e){case`enable`:r=r.map(e=>e.id===t?{...e,disabled:!1}:e),await chrome.storage.local.set({pairedAgents:r});break;case`disable`:{r=r.map(e=>e.id===t?{...e,disabled:!0}:e);let e=n.activeAgentId;n.activeAgentId===t&&(e=r.find(e=>e.id!==t&&!e.disabled)?.id||null),await chrome.storage.local.set({pairedAgents:r,activeAgentId:e||``}),e?chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!0,agentId:e}):chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!1});break}case`delete`:{let e=r.find(e=>e.id===t),a=e?.url?`\n${i(`promptSelector.proxyAddress`)}: ${e.url}`:``;if(!await window.showCustomConfirm(i(`promptSelector.deleteProxyTitle`),i(`promptSelector.confirmDeleteProxy`,{name:e?.name||t,urlInfo:a})))return;r=r.filter(e=>e.id!==t);let o=n.activeAgentId===t?r.find(e=>!e.disabled)?.id||null:n.activeAgentId;await chrome.storage.local.set({pairedAgents:r,activeAgentId:o||``}),o?chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!0,agentId:o}):chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!1});break}}let a=document.getElementById(`userInput`);await KT(a?qT(a.value):``)}r(`zh`,{pageSelector:{noOpenPages:`暂无打开的网页`,noTitle:`无标题`,currentTab:`当前`,openNewTab:`新建标签页`,interpretPage:`解读`,summarizePage:`总结`,translatePage:`翻译`,interpretMsg:`解读一下当前网页`,summarizeMsg:`总结一下当前网页`,translateMsg:`翻译一下当前网页`}}),r(`en`,{pageSelector:{noOpenPages:`No open pages`,noTitle:`Untitled`,currentTab:`Current`,openNewTab:`Open new tab`,interpretPage:`Interpret`,summarizePage:`Summarize`,translatePage:`Translate`,interpretMsg:`Interpret the current webpage`,summarizeMsg:`Summarize the current webpage`,translateMsg:`Translate the current webpage`}});async function wE(){try{return[...await chrome.tabs.query({currentWindow:!0})].sort((e,t)=>e.active===t.active?0:e.active?-1:1)}catch(e){return o.error(`[PageSelector] getlabelpage failed:`,e),[]}}async function TE(e=``){let t=document.getElementById(`agentPageList`);if(!t)return;let n=await wE(),r=e.toLowerCase(),a=n.filter(t=>{if(!t.url)return!1;if(!e)return!0;let n=(t.title||``).toLowerCase().includes(r),i=t.url.toLowerCase().includes(r);return n||i});if(a.length===0){t.innerHTML=`<div class="prompt-empty">${i(`pageSelector.noOpenPages`)}</div>`,H.selectedPageIndex=-1;return}H.selectedPageIndex=0;let o=H.selectedPage?H.selectedPage.id:null;t.innerHTML=a.map((e,t)=>{let n=e.title||i(`pageSelector.noTitle`),r=e.url||``,a=e.favIconUrl?`<img src="${W(e.favIconUrl)}" width="16" height="16" style="flex-shrink:0;" class="favicon-img">`:`<span style="font-size:14px;flex-shrink:0;">🌐</span>`,s=e.active?`<span class="current-tab-badge">${i(`pageSelector.currentTab`)}</span>`:``,c=e.id===o;return`
|
|
1503
1509
|
<div class="prompt-item prompt-item-page ${t===0?`selected`:``}"
|
|
1504
1510
|
data-index="${t}" data-tab-id="${e.id}">
|
|
1505
1511
|
<span class="prompt-item-index">${t+1}</span>
|
|
@@ -1514,8 +1520,8 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1514
1520
|
<span class="page-action-btn" data-action="translate" data-tab-id="${e.id}" title="${i(`pageSelector.translatePage`)}">${i(`pageSelector.translatePage`)}</span>
|
|
1515
1521
|
</span>
|
|
1516
1522
|
</div>
|
|
1517
|
-
`}).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(),
|
|
1518
|
-
`),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){o.warn(`[SidePanel] Mermaid chartprocessing failed,remove:`,t.message),e.remove()}return{html:e.innerHTML,firstPngBlob:n}}function
|
|
1523
|
+
`}).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(),AE(parseInt(n.dataset.tabId),n.dataset.action);return}kE(parseInt(e.dataset.tabId))})})}function EE(e){e.forEach((e,t)=>{t===H.selectedPageIndex?(e.classList.add(`selected`),e.scrollIntoView({block:`nearest`})):e.classList.remove(`selected`)})}function DE(e){H.selectedPage={id:e.id,title:e.title||i(`pageSelector.noTitle`),url:e.url||``,favIconUrl:e.favIconUrl||``};let t=document.getElementById(`pageIndicator`),n=document.getElementById(`pageIndicatorName`);if(t&&n){let e=H.selectedPage.title&&H.selectedPage.title!==i(`pageSelector.noTitle`)?H.selectedPage.title:``,r=H.selectedPage.url||``;n.textContent=e&&r?`${e} · ${r}`:e||r,t.style.display=`flex`}}function OE(){H.selectedPage=null,H.selectedPageIndex=-1;let e=document.getElementById(`pageIndicator`);e&&(e.style.display=`none`)}function kE(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){o.error(`[PageSelector] getlabelpageinfo failed:`,chrome.runtime.lastError);return}DE(e),UT(),t&&(t.focus(),ke())})}function AE(e,t){let n={interpret:i(`pageSelector.interpretMsg`),summarize:i(`pageSelector.summarizeMsg`),translate:i(`pageSelector.translateMsg`)}[t];n&&chrome.tabs.get(e,e=>{if(chrome.runtime.lastError||!e){o.error(`[PageSelector] get tab info failed:`,chrome.runtime.lastError);return}DE(e),UT();let t=document.getElementById(`userInput`);t&&(t.value=n,ke()),eO()})}function jE(){let e=document.getElementById(`pageIndicatorClose`);e&&e.addEventListener(`click`,()=>{OE()})}r(`zh`,{chatCopy:{copiedMarkdown:`已复制 Markdown`,copiedRich:`已复制富文本`,copyFailedManual:`复制失败,请手动复制`}}),r(`en`,{chatCopy:{copiedMarkdown:`Markdown copied`,copiedRich:`Rich text copied`,copyFailedManual:`Copy failed, please copy manually`}});function ME(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(`
|
|
1524
|
+
`),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){o.warn(`[SidePanel] Mermaid chartprocessing failed,remove:`,t.message),e.remove()}return{html:e.innerHTML,firstPngBlob:n}}function NE(e,t){try{let n=e.dataset.textContent_||e.dataset.rawContent||``;navigator.clipboard.writeText(n).then(()=>{let e=t.innerHTML;t.innerHTML=`
|
|
1519
1525
|
<svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor">
|
|
1520
1526
|
<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"/>
|
|
1521
1527
|
</svg>
|
|
@@ -1523,12 +1529,12 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1523
1529
|
<svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor">
|
|
1524
1530
|
<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"/>
|
|
1525
1531
|
</svg>
|
|
1526
|
-
`,t.classList.add(`copied`),setTimeout(()=>{t.innerHTML=e,t.classList.remove(`copied`)},2e3)}catch{U(i(`chatCopy.copyFailed`),`error`)}document.body.removeChild(r)})}catch(e){o.error(`[SidePanel] copy failed:`,e),U(i(`chatCopy.copyFailed`),`error`)}}function
|
|
1532
|
+
`,t.classList.add(`copied`),setTimeout(()=>{t.innerHTML=e,t.classList.remove(`copied`)},2e3)}catch{U(i(`chatCopy.copyFailed`),`error`)}document.body.removeChild(r)})}catch(e){o.error(`[SidePanel] copy failed:`,e),U(i(`chatCopy.copyFailed`),`error`)}}function PE(e,t,n){try{let r=e.dataset.rawMarkdown||e.dataset.rawContent||``,i=``;if(!r){let t=H.messageHistory.find(e=>e.role===`assistant`);if(t)r=t.content;else{let t=e.querySelector(`.final-answer .markdown-body`)||e.querySelector(`.markdown-body`);t?(r=t.innerText,i=t.innerHTML):(r=e.innerText,i=e.innerHTML)}}if(!i){let t=e.querySelector(`.final-answer .markdown-body`)||e.querySelector(`.markdown-body`);t?i=t.innerHTML:r&&(i=Ei(r))}if(n&&(n.ctrlKey||n.metaKey)&&i){let e=document.createElement(`div`);e.innerHTML=i,e.querySelectorAll(`table`).forEach(e=>{let t=Yi(e);e.parentNode.replaceChild(t,e)});let{html:n,firstPngBlob:a}=ME(e);LE(r,n,t,a)}else navigator.clipboard.writeText(r).then(()=>{t&&FE(t)}).catch(()=>{IE(r,t)})}catch(e){o.error(`[SidePanel] copy failed:`,e),U(i(`chatCopy.copyFailed`),`error`)}}function FE(e,t=!1){let n=e.innerHTML;e.innerHTML=`
|
|
1527
1533
|
<svg viewBox="0 0 16 16" fill="currentColor">
|
|
1528
1534
|
<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"/>
|
|
1529
1535
|
</svg>
|
|
1530
1536
|
<span>${i(t?`chatCopy.copiedRich`:`chatCopy.copiedMarkdown`)}</span>
|
|
1531
|
-
`,e.classList.add(`copied`),setTimeout(()=>{e.innerHTML=n,e.classList.remove(`copied`)},2e3)}function
|
|
1537
|
+
`,e.classList.add(`copied`),setTimeout(()=>{e.innerHTML=n,e.classList.remove(`copied`)},2e3)}function IE(e,t){let n=document.createElement(`textarea`);n.value=e,n.style.position=`fixed`,n.style.left=`-999999px`,document.body.appendChild(n),n.select();try{document.execCommand(`copy`),FE(t)}catch{U(i(`chatCopy.copyFailedManual`),`error`)}document.body.removeChild(n)}function LE(e,t,n,r=null){let i=RE(t);if(n&&!document.hasFocus()&&n.focus(),typeof ClipboardItem<`u`){let t={"text/plain":new Blob([e],{type:`text/plain`}),"text/html":new Blob([i],{type:`text/html`})};r&&(t[`image/png`]=r);let a=new ClipboardItem(t);navigator.clipboard.write([a]).then(()=>{FE(n,!0)}).catch(t=>{o.warn(`[SidePanel] Clipboard API write failed,using fallback plan:`,t.message),zE(e,i,n)})}else zE(e,i,n)}function RE(e){return`<!DOCTYPE html><html><head>
|
|
1532
1538
|
<style>
|
|
1533
1539
|
h1 { font-size: 24px; font-weight: bold; margin: 16px 0 8px; }
|
|
1534
1540
|
h2 { font-size: 20px; font-weight: bold; margin: 14px 0 6px; }
|
|
@@ -1567,12 +1573,12 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1567
1573
|
a { color: #007bff; text-decoration: underline; }
|
|
1568
1574
|
img { max-width: 100%; }
|
|
1569
1575
|
</style>
|
|
1570
|
-
</head><body>${e}</body></html>`}function
|
|
1576
|
+
</head><body>${e}</body></html>`}function zE(e,t,n){n&&!document.hasFocus()&&n.focus();let r=document.createElement(`div`);r.style.position=`fixed`,r.style.left=`-999999px`,r.style.top=`-999999px`,r.innerHTML=t,document.body.appendChild(r);let i=document.createRange();i.selectNodeContents(r);let a=window.getSelection();a.removeAllRanges(),a.addRange(i);try{document.execCommand(`copy`),FE(n,!0)}catch{IE(e,n)}finally{a.removeAllRanges(),document.body.removeChild(r)}}var BE=null;function VE(e){BE=e}function HE(e){try{let t=e.dataset.rawMarkdown||e.dataset.rawContent||``;if(!t){o.warn(`[SidePanel] unable to getmessagecontent`);return}let n=document.getElementById(`userInput`);if(!n){o.warn(`[SidePanel] cannot find input box`);return}let r=e.querySelector(`.quote-btn`),a=r?r.innerHTML:``;BE&&BE(t),r&&(r.innerHTML=`
|
|
1571
1577
|
<svg viewBox="0 0 16 16" fill="currentColor">
|
|
1572
1578
|
<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"/>
|
|
1573
1579
|
</svg>
|
|
1574
1580
|
<span>${i(`chatCopy.quoted`)}</span>
|
|
1575
|
-
`,r.classList.add(`quoted`),setTimeout(()=>{r.innerHTML=a,r.classList.remove(`quoted`)},2e3)),n.focus(),o.debug(`[SidePanel] quote with messagecontent to prompt,input boxfocused`)}catch(e){o.error(`[SidePanel] quoted question failed:`,e),U(i(`chatCopy.quoteFailed`,{message:e.message}),`error`)}}r(`zh`,{chatPanels:{decisionPassed:`通过`,decisionRevised:`已修订`,decisionNeedsImprovement:`需改进`,dimAccuracy:`准确性`,dimCompleteness:`完整性`,dimRelevance:`相关性`,dimClarity:`清晰度`,dimUsefulness:`实用性`,dimSafety:`安全性`,dimEfficiency:`效率`,dimensionsTitle:`📊 评分维度`,issuesTitle:`❗ 发现的问题`,suggestionsTitle:`💡 改进建议`,roundsEvaluated:`评估 {rounds} 轮{revised}`,revisedTag:`(已修订)`,finalDecision:`最终决策:{label}`,resultUseful:`结果可用`,resultNeedsImprovement:`结果需改进`,processTitle:`🔄 评估过程`,scoreHighExplanation:`回答质量较高,内容准确、完整且清晰。`,scoreMidExplanation:`回答基本可用,但存在一些可以改进的地方。`,scoreLowExplanation:`回答质量较低,存在明显问题需要改进。`,reflectionTitle:`💡 质量评估详情`,overallScore:`综合评分`,scoreExplanationTitle:`📝 评分说明`,aboutTitle:`ℹ️ 关于质量评估`,aboutDesc:`质量评估由 AI 自动完成,从多个维度对回答进行打分,帮助判断回答的可靠程度。`,scoreStandard:`评分标准:8-10 分优秀,5-7 分良好,1-4 分需改进。`,executionLogTitle:`执行日志`,taskBreakdown:`任务拆解`,totalDurationTitle:`总耗时:{duration}`,totalDuration:`总耗时`,totalNodesTitle:`共 {count} 个执行节点`,totalNodes:`执行节点`,successCountTitle:`成功 {count} 个`,successLabel:`成功`,failedCountTitle:`失败 {count} 个`,failedLabel:`失败`,subtaskCountTitle:`子任务 {completed}/{total} 完成`,subtaskLabel:`子任务`,scoreTitle:`评分 {score}/10`,scoreLabel:`评分`,tokenUsage:`Token 消耗`,tokenUsageTitle:`Token 消耗: {total} (Prompt: {prompt}, Completion: {completion})`,expandAll:`展开全部`,collapseAll:`收起全部`}}),r(`en`,{chatPanels:{decisionPassed:`Passed`,decisionRevised:`Revised`,decisionNeedsImprovement:`Needs Improvement`,dimAccuracy:`Accuracy`,dimCompleteness:`Completeness`,dimRelevance:`Relevance`,dimClarity:`Clarity`,dimUsefulness:`Usefulness`,dimSafety:`Safety`,dimEfficiency:`Efficiency`,dimensionsTitle:`📊 Scoring Dimensions`,issuesTitle:`❗ Issues Found`,suggestionsTitle:`💡 Suggestions`,roundsEvaluated:`Evaluated {rounds} rounds{revised}`,revisedTag:` (revised)`,finalDecision:`Final Decision: {label}`,resultUseful:`Result is useful`,resultNeedsImprovement:`Result needs improvement`,processTitle:`🔄 Evaluation Process`,scoreHighExplanation:`The answer is high quality, accurate, complete, and clear.`,scoreMidExplanation:`The answer is generally usable but has room for improvement.`,scoreLowExplanation:`The answer is low quality with obvious issues that need improvement.`,reflectionTitle:`💡 Quality Assessment Details`,overallScore:`Overall Score`,scoreExplanationTitle:`📝 Score Explanation`,aboutTitle:`ℹ️ About Quality Assessment`,aboutDesc:`Quality assessment is performed automatically by AI, scoring answers across multiple dimensions to help judge reliability.`,scoreStandard:`Scoring: 8-10 excellent, 5-7 good, 1-4 needs improvement.`,executionLogTitle:`Execution Log`,taskBreakdown:`Task Breakdown`,totalDurationTitle:`Total duration: {duration}`,totalDuration:`Duration`,totalNodesTitle:`{count} execution nodes`,totalNodes:`Nodes`,successCountTitle:`{count} succeeded`,successLabel:`Success`,failedCountTitle:`{count} failed`,failedLabel:`Failed`,subtaskCountTitle:`Subtasks {completed}/{total} done`,subtaskLabel:`Subtasks`,scoreTitle:`Score {score}/10`,scoreLabel:`Score`,tokenUsage:`Token Usage`,tokenUsageTitle:`Token usage: {total} (Prompt: {prompt}, Completion: {completion})`,expandAll:`Expand All`,collapseAll:`Collapse All`}});function
|
|
1581
|
+
`,r.classList.add(`quoted`),setTimeout(()=>{r.innerHTML=a,r.classList.remove(`quoted`)},2e3)),n.focus(),o.debug(`[SidePanel] quote with messagecontent to prompt,input boxfocused`)}catch(e){o.error(`[SidePanel] quoted question failed:`,e),U(i(`chatCopy.quoteFailed`,{message:e.message}),`error`)}}r(`zh`,{chatPanels:{decisionPassed:`通过`,decisionRevised:`已修订`,decisionNeedsImprovement:`需改进`,dimAccuracy:`准确性`,dimCompleteness:`完整性`,dimRelevance:`相关性`,dimClarity:`清晰度`,dimUsefulness:`实用性`,dimSafety:`安全性`,dimEfficiency:`效率`,dimensionsTitle:`📊 评分维度`,issuesTitle:`❗ 发现的问题`,suggestionsTitle:`💡 改进建议`,roundsEvaluated:`评估 {rounds} 轮{revised}`,revisedTag:`(已修订)`,finalDecision:`最终决策:{label}`,resultUseful:`结果可用`,resultNeedsImprovement:`结果需改进`,processTitle:`🔄 评估过程`,scoreHighExplanation:`回答质量较高,内容准确、完整且清晰。`,scoreMidExplanation:`回答基本可用,但存在一些可以改进的地方。`,scoreLowExplanation:`回答质量较低,存在明显问题需要改进。`,reflectionTitle:`💡 质量评估详情`,overallScore:`综合评分`,scoreExplanationTitle:`📝 评分说明`,aboutTitle:`ℹ️ 关于质量评估`,aboutDesc:`质量评估由 AI 自动完成,从多个维度对回答进行打分,帮助判断回答的可靠程度。`,scoreStandard:`评分标准:8-10 分优秀,5-7 分良好,1-4 分需改进。`,executionLogTitle:`执行日志`,taskBreakdown:`任务拆解`,totalDurationTitle:`总耗时:{duration}`,totalDuration:`总耗时`,totalNodesTitle:`共 {count} 个执行节点`,totalNodes:`执行节点`,successCountTitle:`成功 {count} 个`,successLabel:`成功`,failedCountTitle:`失败 {count} 个`,failedLabel:`失败`,subtaskCountTitle:`子任务 {completed}/{total} 完成`,subtaskLabel:`子任务`,scoreTitle:`评分 {score}/10`,scoreLabel:`评分`,tokenUsage:`Token 消耗`,tokenUsageTitle:`Token 消耗: {total} (Prompt: {prompt}, Completion: {completion})`,expandAll:`展开全部`,collapseAll:`收起全部`}}),r(`en`,{chatPanels:{decisionPassed:`Passed`,decisionRevised:`Revised`,decisionNeedsImprovement:`Needs Improvement`,dimAccuracy:`Accuracy`,dimCompleteness:`Completeness`,dimRelevance:`Relevance`,dimClarity:`Clarity`,dimUsefulness:`Usefulness`,dimSafety:`Safety`,dimEfficiency:`Efficiency`,dimensionsTitle:`📊 Scoring Dimensions`,issuesTitle:`❗ Issues Found`,suggestionsTitle:`💡 Suggestions`,roundsEvaluated:`Evaluated {rounds} rounds{revised}`,revisedTag:` (revised)`,finalDecision:`Final Decision: {label}`,resultUseful:`Result is useful`,resultNeedsImprovement:`Result needs improvement`,processTitle:`🔄 Evaluation Process`,scoreHighExplanation:`The answer is high quality, accurate, complete, and clear.`,scoreMidExplanation:`The answer is generally usable but has room for improvement.`,scoreLowExplanation:`The answer is low quality with obvious issues that need improvement.`,reflectionTitle:`💡 Quality Assessment Details`,overallScore:`Overall Score`,scoreExplanationTitle:`📝 Score Explanation`,aboutTitle:`ℹ️ About Quality Assessment`,aboutDesc:`Quality assessment is performed automatically by AI, scoring answers across multiple dimensions to help judge reliability.`,scoreStandard:`Scoring: 8-10 excellent, 5-7 good, 1-4 needs improvement.`,executionLogTitle:`Execution Log`,taskBreakdown:`Task Breakdown`,totalDurationTitle:`Total duration: {duration}`,totalDuration:`Duration`,totalNodesTitle:`{count} execution nodes`,totalNodes:`Nodes`,successCountTitle:`{count} succeeded`,successLabel:`Success`,failedCountTitle:`{count} failed`,failedLabel:`Failed`,subtaskCountTitle:`Subtasks {completed}/{total} done`,subtaskLabel:`Subtasks`,scoreTitle:`Score {score}/10`,scoreLabel:`Score`,tokenUsage:`Token Usage`,tokenUsageTitle:`Token usage: {total} (Prompt: {prompt}, Completion: {completion})`,expandAll:`Expand All`,collapseAll:`Collapse All`}});function UE(e,t){let n=document.querySelector(`.reflection-info-overlay`);n&&n.remove();let r=document.createElement(`div`);r.className=`reflection-info-overlay`;let{overallScore:a,dimensions:o,issues:s,suggestions:c,decision:l,useful:u,reasoning:d,suggestion:f,rounds:p,wasRevised:m}=e,h=a>=8?`score-high`:a>=5?`score-mid`:`score-low`,g=a>=8?`✅`:a>=5?`🔍`:`⚠️`,_=l===`passed`?i(`chatPanels.decisionPassed`):l===`revised`?i(`chatPanels.decisionRevised`):l===`needs_improvement`?i(`chatPanels.decisionNeedsImprovement`):``,v={accuracy:i(`chatPanels.dimAccuracy`),completeness:i(`chatPanels.dimCompleteness`),relevance:i(`chatPanels.dimRelevance`),clarity:i(`chatPanels.dimClarity`),usefulness:i(`chatPanels.dimUsefulness`),safety:i(`chatPanels.dimSafety`),efficiency:i(`chatPanels.dimEfficiency`)},y=``;o&&Object.keys(o).length>0&&(y=`
|
|
1576
1582
|
<div class="ri-section">
|
|
1577
1583
|
<div class="ri-section-title">${i(`chatPanels.dimensionsTitle`)}</div>
|
|
1578
1584
|
<div class="ri-dimensions">
|
|
@@ -1627,7 +1633,7 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1627
1633
|
</div>
|
|
1628
1634
|
</div>
|
|
1629
1635
|
</div>
|
|
1630
|
-
`,document.body.appendChild(r),r.querySelector(`.ri-close`).addEventListener(`click`,()=>r.remove()),r.addEventListener(`click`,e=>{e.target===r&&r.remove()});let w=t.getBoundingClientRect(),T=r.querySelector(`.reflection-info-panel`),E=Math.min(window.innerHeight-40,560),D=w.right-380;D<10&&(D=10),D+380>window.innerWidth-10&&(D=window.innerWidth-380-10);let O=w.bottom+6;O+E>window.innerHeight-10&&(O=w.top-E-6),O<10&&(O=10),T.style.left=D+`px`,T.style.top=O+`px`,T.style.maxHeight=E+`px`}function
|
|
1636
|
+
`,document.body.appendChild(r),r.querySelector(`.ri-close`).addEventListener(`click`,()=>r.remove()),r.addEventListener(`click`,e=>{e.target===r&&r.remove()});let w=t.getBoundingClientRect(),T=r.querySelector(`.reflection-info-panel`),E=Math.min(window.innerHeight-40,560),D=w.right-380;D<10&&(D=10),D+380>window.innerWidth-10&&(D=window.innerWidth-380-10);let O=w.bottom+6;O+E>window.innerHeight-10&&(O=w.top-E-6),O<10&&(O=10),T.style.left=D+`px`,T.style.top=O+`px`,T.style.maxHeight=E+`px`}function WE(e){let t=document.querySelector(`.execution-log-panel`);t&&t.remove();let n=document.createElement(`div`);n.className=`execution-log-panel`;let r=e.reduce((e,t)=>e+(t.duration||0),0),a=e.filter(e=>e.status===`success`).length,o=e.filter(e=>e.status===`failed`).length,s=e.filter(e=>e.nodeType===`subtask`).length,c=e.filter(e=>e.nodeType===`subtask`&&e.status===`success`).length,l=e.filter(e=>e.nodeType===`tool_exec`&&e.action?.name===`plan_task`&&e.status===`success`).length,u=e.filter(e=>e.nodeType===`reflection`).find(e=>e.reflectionType===`post`),d=ze(e);n.innerHTML=`
|
|
1631
1637
|
<div class="log-container">
|
|
1632
1638
|
<div class="log-header">
|
|
1633
1639
|
<div class="log-title">
|
|
@@ -1709,11 +1715,11 @@ After removal, the AI will no longer be able to access this directory. You can s
|
|
|
1709
1715
|
${gs(e)}
|
|
1710
1716
|
</div>
|
|
1711
1717
|
</div>
|
|
1712
|
-
`,document.body.appendChild(n),ds(n),n.addEventListener(`click`,e=>{e.target===n&&n.remove()}),n.querySelector(`.log-close`).addEventListener(`click`,()=>{n.remove()});let f=n.querySelector(`.toggle-expand-btn`),p=n.querySelectorAll(`.timeline-content`),m=!1;f.addEventListener(`click`,()=>{m=!m,p.forEach(e=>{m?e.classList.add(`expanded`):e.classList.remove(`expanded`)});let e=f.querySelector(`svg`);m?(e.innerHTML=`<polyline points="17 11 12 6 7 11"></polyline><polyline points="17 18 12 13 7 18"></polyline>`,f.setAttribute(`title`,i(`chatPanels.collapseAll`))):(e.innerHTML=`<polyline points="7 13 12 18 17 13"></polyline><polyline points="7 6 12 11 17 6"></polyline>`,f.setAttribute(`title`,i(`chatPanels.expandAll`)))}),n.querySelectorAll(`.timeline-header`).forEach(e=>{e.addEventListener(`click`,()=>{e.parentElement.classList.toggle(`expanded`)})}),n.querySelectorAll(`.task-group-header`).forEach(e=>{e.addEventListener(`click`,()=>{e.parentElement.classList.toggle(`collapsed`)})});let h=n.querySelectorAll(`.combo-stat`),g=n.querySelectorAll(`.timeline-item`);h.forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.status,n=e.classList.contains(`active`);h.forEach(e=>e.classList.remove(`active`)),n?g.forEach(e=>{e.style.display=``}):(e.classList.add(`active`),g.forEach(e=>{if(t===`subtask`)e.classList.contains(`subtask-level`)?e.style.display=``:e.style.display=`none`;else{let n=e.querySelector(`.timeline-dot`);n&&n.classList.contains(t)?e.style.display=``:e.style.display=`none`}}))})})}r(`zh`,{chatResume:{title:`继续执行任务`,desc:`任务执行被中断,你可以提供补充说明帮助模型继续。`,placeholder:`输入补充说明(可选)…`,continueBtn:`继续`,interruptedAgo:`({duration}前)`,taskInterrupted:`任务执行被中断{elapsed}`,checkpointNotFound:`检查点已失效,无法继续执行。请重新发送任务。`,taskCancelled:`任务已被用户停止`,swRestarted:`Service Worker 已重启,请重新发送任务`,resumeFailed:`恢复失败:{message}`,unknownError:`未知错误`}}),r(`en`,{chatResume:{title:`Continue Task`,desc:`The task was interrupted. You can provide additional guidance to help the model continue.`,placeholder:`Enter additional guidance (optional)…`,continueBtn:`Continue`,interruptedAgo:` ({duration} ago)`,taskInterrupted:`Task execution was interrupted{elapsed}`,checkpointNotFound:`The checkpoint has expired and the task cannot be resumed. Please resend the task.`,taskCancelled:`Task was stopped by user`,swRestarted:`Service Worker restarted. Please resend the task.`,resumeFailed:`Resume failed: {message}`,unknownError:`Unknown error`}});function WE(){return new Promise(e=>{let t=document.createElement(`div`);t.className=`modal-overlay resume-dialog-overlay`,t.style.cssText=`display:flex;position:fixed;inset:0;background:rgba(0,0,0,0.45);z-index:10000;align-items:center;justify-content:center;`;let n=document.createElement(`div`);n.className=`modal-container resume-dialog-container`,n.style.cssText=`background:#fff;border-radius:8px;padding:24px;width:90%;max-width:480px;box-shadow:0 8px 32px rgba(0,0,0,0.2);`;let r=document.createElement(`h3`);r.textContent=i(`chatResume.title`),r.style.cssText=`margin:0 0 8px 0;font-size:16px;color:#1a202c;`;let a=document.createElement(`p`);a.textContent=i(`chatResume.desc`),a.style.cssText=`margin:0 0 16px 0;font-size:13px;color:#718096;line-height:1.5;`;let o=document.createElement(`textarea`);o.className=`resume-dialog-textarea`,o.placeholder=i(`chatResume.placeholder`),o.style.cssText=`width:100%;min-height:80px;padding:8px 12px;border:1px solid #cbd5e0;border-radius:4px;font-size:13px;resize:vertical;box-sizing:border-box;font-family:inherit;line-height:1.5;`,o.rows=3;let s=document.createElement(`div`);s.style.cssText=`display:flex;justify-content:flex-end;gap:8px;margin-top:16px;`;let c=document.createElement(`button`);c.textContent=i(`common.cancel`),c.style.cssText=`padding:6px 16px;border:1px solid #cbd5e0;background:#fff;color:#4a5568;border-radius:4px;cursor:pointer;font-size:13px;`;let l=document.createElement(`button`);l.textContent=i(`chatResume.continueBtn`),l.style.cssText=`padding:6px 16px;border:none;background:#3182ce;color:#fff;border-radius:4px;cursor:pointer;font-size:13px;font-weight:500;`,s.appendChild(c),s.appendChild(l),n.appendChild(r),n.appendChild(a),n.appendChild(o),n.appendChild(s),t.appendChild(n),document.body.appendChild(t),requestAnimationFrame(()=>o.focus());let u=()=>{t.remove(),document.removeEventListener(`keydown`,d)},d=t=>{t.key===`Escape`?(u(),e(null)):t.key===`Enter`&&(t.ctrlKey||t.metaKey)&&(u(),e(o.value.trim()))};c.addEventListener(`click`,()=>{u(),e(null)}),l.addEventListener(`click`,()=>{u(),e(o.value.trim())}),document.addEventListener(`keydown`,d)})}function GE(e){if(!e)return;let t=!1;for(let e of H.messageHistory)e.resumable&&(e.resumable=!1,t=!0);let n=document.getElementById(`chatContainer`);n&&n.querySelectorAll(`.message[data-resumable="true"]`).forEach(e=>{e.removeAttribute(`data-resumable`);let t=e.querySelector(`.resume-task-btn`);t&&t.remove()}),t&&WD()}async function KE(e,t){if(!(!e||!t))try{if(!(await chrome.runtime.sendMessage({type:`GET_CHECKPOINT`,sessionId:t}))?.exists){e.removeAttribute(`data-resumable`);let t=e.querySelector(`.resume-task-btn`);t&&t.remove();let n=e.dataset.messageId,r=H.messageHistory.find(e=>e.messageId===n);r&&r.resumable&&(r.resumable=!1,WD())}}catch{}}async function qE(){let e=H.activeSessionId;if(!e||H.pendingCallApiSessionIds&&H.pendingCallApiSessionIds.has(e))return;let t=H.messageHistory.some(e=>e.resumable),n=document.getElementById(`chatContainer`),r=n&&n.querySelector(`.resume-task-btn`);if(!(t&&r))try{let r=await chrome.runtime.sendMessage({type:`GET_CHECKPOINT`,sessionId:e});if(r?.exists){o.debug(`[SidePanel] found abandoned checkpoint,auto addrestorehint card`),document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:e}}));let a=r.checkpoint,s=a.updatedAt?Me(Date.now()-a.updatedAt):``,c=s?i(`chatResume.interruptedAgo`,{duration:s}):``,l=i(`chatResume.taskInterrupted`,{elapsed:c});if(t){let e=H.messageHistory.find(e=>e.resumable);if(e&&(e.content=l,WD()),n){let e=n.querySelector(`.message[data-resumable="true"]`);if(!e){let t=n.querySelectorAll(`.message.assistant`);for(let n of t)if((n.textContent||``).includes(`任务执行被中断`)){e=n;break}}e&&e.remove()}}let{element:u,messageId:d}=oO(`assistant`,l,!0,[],null,!1,null,null,[],!0);t||(H.messageHistory.push({role:`assistant`,content:l,executionLog:[],messageId:d,resumable:!0,interrupted:!0}),WD()),KE(u,e)}}catch(e){o.warn(`[SidePanel] check abandoned checkpoint failed:`,e.message)}}async function JE(e,t=``){if(!e)return o.warn(`[SidePanel] resumeTask: missing sessionId`),!1;if(H.activeSessionId!==e)return o.warn(`[SidePanel] resumeTask: currently activesessionwith targetsession not consistent,please switch firstto targetsession`),!1;if(H.pendingCallApiSessionIds&&H.pendingCallApiSessionIds.has(e))return o.warn(`[SidePanel] resumeTask: currentsession has ongoingtask`),!1;o.debug(`[SidePanel] resumeTask: startrestoretask, sessionId:`,e,`userGuidance:`,t?`"${t.substring(0,50)}..."`:`( no )`);try{let t=await chrome.runtime.sendMessage({type:`GET_CHECKPOINT`,sessionId:e});if(!t?.exists){o.warn(`[SidePanel] resumeTask: checkpoint not found, no way to restore, sessionId:`,e);let t=i(`chatResume.checkpointNotFound`),{messageId:n}=oO(`assistant`,t,!0,[]);return H.messageHistory.push({role:`assistant`,content:t,executionLog:[],messageId:n,resumable:!1,resumed:!0}),WD(),GE(e),!1}o.debug(`[SidePanel] resumeTask: checkpoint verified, iteration:`,t.checkpoint?.iteration)}catch(e){o.warn(`[SidePanel] resumeTask: verify checkpoint hourcommunication failed,continue tryrestore:`,e.message)}let n=e,r=fO();H.isGenerating=!0;let a=``,s=[],c=null,l=!1,u=!1,d=null,f=null;try{let e=await xO(null,null,!1,{},{resumeFromCheckpoint:!0,userGuidance:t,loadingId:r});a=e.content,s=e.executionLog||[],c=e.reflectionScore,l=e.wasRevised||!1,u=e.wasStreamed||!1,d=e.streamingHtml||null,e.streamingConnected!==void 0&&e.streamingConnected,f=e.streamingMsgId||null}catch(e){if(H.activeSessionId!==n){let t=!!e.checkpoint||e.swRestarted||e.message===`任务已被用户停止`;return e.message===`任务已被用户停止`?Rt(n,{role:`assistant`,content:i(`chatResume.taskCancelled`),executionLog:e.executionLog||[],resumable:t,resumed:!0}):e.swRestarted?Rt(n,{role:`assistant`,content:i(`chatResume.swRestarted`),executionLog:e.executionLog||[],resumable:t,resumed:!0}):Rt(n,{role:`assistant`,content:i(`chatResume.resumeFailed`,{message:e.message||i(`chatResume.unknownError`)}),executionLog:e.executionLog||[],resumable:!1,resumed:!0}),document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:n}})),pO(r),!1}if(e.message===`任务已被用户停止`){pO(r);let{messageId:t}=oO(`assistant`,i(`chatResume.taskCancelled`),!1,e.executionLog||[]);return H.messageHistory.push({role:`assistant`,content:i(`chatResume.taskCancelled`),executionLog:e.executionLog||[],messageId:t,resumable:!0,resumed:!0}),WD(),!1}if(e.swRestarted){pO(r);let t=!!e.checkpoint,{messageId:n}=oO(`assistant`,i(`chatResume.swRestarted`),!1,e.executionLog||[]);return H.messageHistory.push({role:`assistant`,content:i(`chatResume.swRestarted`),executionLog:e.executionLog||[],messageId:n,resumable:t,resumed:!0}),WD(),!1}pO(r);let t=i(`chatResume.resumeFailed`,{message:e.message||i(`chatResume.unknownError`)}),{element:a,messageId:o}=oO(`assistant`,t,!0,e.executionLog||[]);return H.messageHistory.push({role:`assistant`,content:t,executionLog:e.executionLog||[],messageId:o,resumable:!1,resumed:!0}),WD(),!1}finally{H.generatingSessionIds.delete(n),Dt(n),document.dispatchEvent(new CustomEvent(`generating-state-changed`))}if(GE(n),H.activeSessionId!==n){let e={role:`assistant`,content:a,executionLog:s,reflectionScore:c,wasRevised:l,resumed:!0};return u&&d&&(e.htmlContent=d),Rt(n,e),document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:n}})),pO(r),!0}if(u&&d){let e=f;return H.messageHistory.push({role:`assistant`,content:a,executionLog:s,reflectionScore:c,wasRevised:l,messageId:e,resumed:!0,htmlContent:d}),WD(),!0}pO(r);let{element:p,messageId:m}=oO(`assistant`,a,!0,s,c,l);return H.messageHistory.push({role:`assistant`,content:a,executionLog:s,reflectionScore:c,wasRevised:l,messageId:m,resumed:!0}),WD(),p&&Ui(p),!0}var YE=n({addStreamingMessage:()=>wD,appendToolCallItems:()=>DD,appendToolResult:()=>kD,autoScrollToBottom:()=>rD,bindProcessHeaderClick:()=>cD,cancelStreamingTask:()=>MD,createCodeBlockHtml:()=>OD,createPreSelectCard:()=>AD,createStreamingElementAccessor:()=>gD,deleteStreamingState:()=>_D,finalizeCancelledStream:()=>ND,finalizeStreamingMessage:()=>jD,getPendingPreselectLog:()=>yD,initScrollToBottomBtn:()=>aD,notifyNonStreamContentArrived:()=>oD,reconnectStreamingElement:()=>TD,refreshAgentNames:()=>lD,resetScrollState:()=>iD,setPendingPreselectLog:()=>bD,setProcessStartTime:()=>SD,setReasoningContent:()=>CD,setStreamedContent:()=>vD,setThinkingStartTime:()=>xD,updateScrollButtonState:()=>tD,updateStreamingMessage:()=>ED});r(`zh`,{chatStream:{thinking:`思考中...`,outputting:`输出中...`,stopGenerating:`停止生成`,thinkingResult:`思考结果`,toolActionOperate:`操作`,toolActionUpload:`上传`,toolActionDownload:`下载`,toolActionRequest:`请求`,toolActionInteract:`交互`,toolActionFill:`填写`,toolActionDispatch:`分派`,toolActionPreview:`预览`,toolActionRead:`读取`,toolActionWrite:`写入`,terminateCommand:`终止命令`,abortWaiting:`终止等待(跳过当前工具执行等待,不终止实际进程)`,executing:`执行中...`,terminating:`正在终止...`,copyCode:`复制代码`,truncatedTitle:`原始结果过大,已截断显示`,truncatedNote:`(输出过长已截断)`,noOutput:`(无输出)`,execFailed:`执行失败`,clickToExpand:`
|
|
1718
|
+
`,document.body.appendChild(n),ds(n),n.addEventListener(`click`,e=>{e.target===n&&n.remove()}),n.querySelector(`.log-close`).addEventListener(`click`,()=>{n.remove()});let f=n.querySelector(`.toggle-expand-btn`),p=n.querySelectorAll(`.timeline-content`),m=!1;f.addEventListener(`click`,()=>{m=!m,p.forEach(e=>{m?e.classList.add(`expanded`):e.classList.remove(`expanded`)});let e=f.querySelector(`svg`);m?(e.innerHTML=`<polyline points="17 11 12 6 7 11"></polyline><polyline points="17 18 12 13 7 18"></polyline>`,f.setAttribute(`title`,i(`chatPanels.collapseAll`))):(e.innerHTML=`<polyline points="7 13 12 18 17 13"></polyline><polyline points="7 6 12 11 17 6"></polyline>`,f.setAttribute(`title`,i(`chatPanels.expandAll`)))}),n.querySelectorAll(`.timeline-header`).forEach(e=>{e.addEventListener(`click`,()=>{e.parentElement.classList.toggle(`expanded`)})}),n.querySelectorAll(`.task-group-header`).forEach(e=>{e.addEventListener(`click`,()=>{e.parentElement.classList.toggle(`collapsed`)})});let h=n.querySelectorAll(`.combo-stat`),g=n.querySelectorAll(`.timeline-item`);h.forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.status,n=e.classList.contains(`active`);h.forEach(e=>e.classList.remove(`active`)),n?g.forEach(e=>{e.style.display=``}):(e.classList.add(`active`),g.forEach(e=>{if(t===`subtask`)e.classList.contains(`subtask-level`)?e.style.display=``:e.style.display=`none`;else{let n=e.querySelector(`.timeline-dot`);n&&n.classList.contains(t)?e.style.display=``:e.style.display=`none`}}))})})}r(`zh`,{chatResume:{title:`继续执行任务`,desc:`任务执行被中断,你可以提供补充说明帮助模型继续。`,placeholder:`输入补充说明(可选)…`,continueBtn:`继续`,interruptedAgo:`({duration}前)`,taskInterrupted:`任务执行被中断{elapsed}`,checkpointNotFound:`检查点已失效,无法继续执行。请重新发送任务。`,taskCancelled:`任务已被用户停止`,swRestarted:`Service Worker 已重启,请重新发送任务`,resumeFailed:`恢复失败:{message}`,unknownError:`未知错误`}}),r(`en`,{chatResume:{title:`Continue Task`,desc:`The task was interrupted. You can provide additional guidance to help the model continue.`,placeholder:`Enter additional guidance (optional)…`,continueBtn:`Continue`,interruptedAgo:` ({duration} ago)`,taskInterrupted:`Task execution was interrupted{elapsed}`,checkpointNotFound:`The checkpoint has expired and the task cannot be resumed. Please resend the task.`,taskCancelled:`Task was stopped by user`,swRestarted:`Service Worker restarted. Please resend the task.`,resumeFailed:`Resume failed: {message}`,unknownError:`Unknown error`}});function GE(){return new Promise(e=>{let t=document.createElement(`div`);t.className=`modal-overlay resume-dialog-overlay`,t.style.cssText=`display:flex;position:fixed;inset:0;background:rgba(0,0,0,0.45);z-index:10000;align-items:center;justify-content:center;`;let n=document.createElement(`div`);n.className=`modal-container resume-dialog-container`,n.style.cssText=`background:#fff;border-radius:8px;padding:24px;width:90%;max-width:480px;box-shadow:0 8px 32px rgba(0,0,0,0.2);`;let r=document.createElement(`h3`);r.textContent=i(`chatResume.title`),r.style.cssText=`margin:0 0 8px 0;font-size:16px;color:#1a202c;`;let a=document.createElement(`p`);a.textContent=i(`chatResume.desc`),a.style.cssText=`margin:0 0 16px 0;font-size:13px;color:#718096;line-height:1.5;`;let o=document.createElement(`textarea`);o.className=`resume-dialog-textarea`,o.placeholder=i(`chatResume.placeholder`),o.style.cssText=`width:100%;min-height:80px;padding:8px 12px;border:1px solid #cbd5e0;border-radius:4px;font-size:13px;resize:vertical;box-sizing:border-box;font-family:inherit;line-height:1.5;`,o.rows=3;let s=document.createElement(`div`);s.style.cssText=`display:flex;justify-content:flex-end;gap:8px;margin-top:16px;`;let c=document.createElement(`button`);c.textContent=i(`common.cancel`),c.style.cssText=`padding:6px 16px;border:1px solid #cbd5e0;background:#fff;color:#4a5568;border-radius:4px;cursor:pointer;font-size:13px;`;let l=document.createElement(`button`);l.textContent=i(`chatResume.continueBtn`),l.style.cssText=`padding:6px 16px;border:none;background:#3182ce;color:#fff;border-radius:4px;cursor:pointer;font-size:13px;font-weight:500;`,s.appendChild(c),s.appendChild(l),n.appendChild(r),n.appendChild(a),n.appendChild(o),n.appendChild(s),t.appendChild(n),document.body.appendChild(t),requestAnimationFrame(()=>o.focus());let u=()=>{t.remove(),document.removeEventListener(`keydown`,d)},d=t=>{t.key===`Escape`?(u(),e(null)):t.key===`Enter`&&(t.ctrlKey||t.metaKey)&&(u(),e(o.value.trim()))};c.addEventListener(`click`,()=>{u(),e(null)}),l.addEventListener(`click`,()=>{u(),e(o.value.trim())}),document.addEventListener(`keydown`,d)})}function KE(e){if(!e)return;let t=!1;for(let e of H.messageHistory)e.resumable&&(e.resumable=!1,t=!0);let n=document.getElementById(`chatContainer`);n&&n.querySelectorAll(`.message[data-resumable="true"]`).forEach(e=>{e.removeAttribute(`data-resumable`);let t=e.querySelector(`.resume-task-btn`);t&&t.remove()}),t&&GD()}async function qE(e,t){if(!(!e||!t))try{if(!(await chrome.runtime.sendMessage({type:`GET_CHECKPOINT`,sessionId:t}))?.exists){e.removeAttribute(`data-resumable`);let t=e.querySelector(`.resume-task-btn`);t&&t.remove();let n=e.dataset.messageId,r=H.messageHistory.find(e=>e.messageId===n);r&&r.resumable&&(r.resumable=!1,GD())}}catch{}}async function JE(){let e=H.activeSessionId;if(!e||H.pendingCallApiSessionIds&&H.pendingCallApiSessionIds.has(e))return;let t=H.messageHistory.some(e=>e.resumable),n=document.getElementById(`chatContainer`),r=n&&n.querySelector(`.resume-task-btn`);if(!(t&&r))try{let r=await chrome.runtime.sendMessage({type:`GET_CHECKPOINT`,sessionId:e});if(r?.exists){o.debug(`[SidePanel] found abandoned checkpoint,auto addrestorehint card`),document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:e}}));let a=r.checkpoint,s=a.updatedAt?Me(Date.now()-a.updatedAt):``,c=s?i(`chatResume.interruptedAgo`,{duration:s}):``,l=i(`chatResume.taskInterrupted`,{elapsed:c});if(t){let e=H.messageHistory.find(e=>e.resumable);if(e&&(e.content=l,GD()),n){let e=n.querySelector(`.message[data-resumable="true"]`);if(!e){let t=n.querySelectorAll(`.message.assistant`);for(let n of t)if((n.textContent||``).includes(`任务执行被中断`)){e=n;break}}e&&e.remove()}}let{element:u,messageId:d}=sO(`assistant`,l,!0,[],null,!1,null,null,[],!0);t||(H.messageHistory.push({role:`assistant`,content:l,executionLog:[],messageId:d,resumable:!0,interrupted:!0}),GD()),qE(u,e)}}catch(e){o.warn(`[SidePanel] check abandoned checkpoint failed:`,e.message)}}async function YE(e,t=``){if(!e)return o.warn(`[SidePanel] resumeTask: missing sessionId`),!1;if(H.activeSessionId!==e)return o.warn(`[SidePanel] resumeTask: currently activesessionwith targetsession not consistent,please switch firstto targetsession`),!1;if(H.pendingCallApiSessionIds&&H.pendingCallApiSessionIds.has(e))return o.warn(`[SidePanel] resumeTask: currentsession has ongoingtask`),!1;o.debug(`[SidePanel] resumeTask: startrestoretask, sessionId:`,e,`userGuidance:`,t?`"${t.substring(0,50)}..."`:`( no )`);try{let t=await chrome.runtime.sendMessage({type:`GET_CHECKPOINT`,sessionId:e});if(!t?.exists){o.warn(`[SidePanel] resumeTask: checkpoint not found, no way to restore, sessionId:`,e);let t=i(`chatResume.checkpointNotFound`),{messageId:n}=sO(`assistant`,t,!0,[]);return H.messageHistory.push({role:`assistant`,content:t,executionLog:[],messageId:n,resumable:!1,resumed:!0}),GD(),KE(e),!1}o.debug(`[SidePanel] resumeTask: checkpoint verified, iteration:`,t.checkpoint?.iteration)}catch(e){o.warn(`[SidePanel] resumeTask: verify checkpoint hourcommunication failed,continue tryrestore:`,e.message)}let n=e,r=pO();H.isGenerating=!0;let a=``,s=[],c=null,l=!1,u=!1,d=null,f=null;try{let e=await SO(null,null,!1,{},{resumeFromCheckpoint:!0,userGuidance:t,loadingId:r});a=e.content,s=e.executionLog||[],c=e.reflectionScore,l=e.wasRevised||!1,u=e.wasStreamed||!1,d=e.streamingHtml||null,e.streamingConnected!==void 0&&e.streamingConnected,f=e.streamingMsgId||null}catch(e){if(H.activeSessionId!==n){let t=!!e.checkpoint||e.swRestarted||e.message===`任务已被用户停止`;return e.message===`任务已被用户停止`?Rt(n,{role:`assistant`,content:i(`chatResume.taskCancelled`),executionLog:e.executionLog||[],resumable:t,resumed:!0}):e.swRestarted?Rt(n,{role:`assistant`,content:i(`chatResume.swRestarted`),executionLog:e.executionLog||[],resumable:t,resumed:!0}):Rt(n,{role:`assistant`,content:i(`chatResume.resumeFailed`,{message:e.message||i(`chatResume.unknownError`)}),executionLog:e.executionLog||[],resumable:!1,resumed:!0}),document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:n}})),mO(r),!1}if(e.message===`任务已被用户停止`){mO(r);let{messageId:t}=sO(`assistant`,i(`chatResume.taskCancelled`),!1,e.executionLog||[]);return H.messageHistory.push({role:`assistant`,content:i(`chatResume.taskCancelled`),executionLog:e.executionLog||[],messageId:t,resumable:!0,resumed:!0}),GD(),!1}if(e.swRestarted){mO(r);let t=!!e.checkpoint,{messageId:n}=sO(`assistant`,i(`chatResume.swRestarted`),!1,e.executionLog||[]);return H.messageHistory.push({role:`assistant`,content:i(`chatResume.swRestarted`),executionLog:e.executionLog||[],messageId:n,resumable:t,resumed:!0}),GD(),!1}mO(r);let t=i(`chatResume.resumeFailed`,{message:e.message||i(`chatResume.unknownError`)}),{element:a,messageId:o}=sO(`assistant`,t,!0,e.executionLog||[]);return H.messageHistory.push({role:`assistant`,content:t,executionLog:e.executionLog||[],messageId:o,resumable:!1,resumed:!0}),GD(),!1}finally{H.generatingSessionIds.delete(n),Dt(n),document.dispatchEvent(new CustomEvent(`generating-state-changed`))}if(KE(n),H.activeSessionId!==n){let e={role:`assistant`,content:a,executionLog:s,reflectionScore:c,wasRevised:l,resumed:!0};return u&&d&&(e.htmlContent=d),Rt(n,e),document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:n}})),mO(r),!0}if(u&&d){let e=f;return H.messageHistory.push({role:`assistant`,content:a,executionLog:s,reflectionScore:c,wasRevised:l,messageId:e,resumed:!0,htmlContent:d}),GD(),!0}mO(r);let{element:p,messageId:m}=sO(`assistant`,a,!0,s,c,l);return H.messageHistory.push({role:`assistant`,content:a,executionLog:s,reflectionScore:c,wasRevised:l,messageId:m,resumed:!0}),GD(),p&&Ui(p),!0}var XE=n({addStreamingMessage:()=>TD,appendToolCallItems:()=>OD,appendToolResult:()=>AD,autoScrollToBottom:()=>iD,bindProcessHeaderClick:()=>lD,cancelStreamingTask:()=>ND,createCodeBlockHtml:()=>kD,createPreSelectCard:()=>jD,createStreamingElementAccessor:()=>_D,deleteStreamingState:()=>vD,finalizeCancelledStream:()=>PD,finalizeStreamingMessage:()=>MD,getPendingPreselectLog:()=>bD,initScrollToBottomBtn:()=>oD,notifyNonStreamContentArrived:()=>sD,reconnectStreamingElement:()=>ED,refreshAgentNames:()=>uD,resetScrollState:()=>aD,setPendingPreselectLog:()=>xD,setProcessStartTime:()=>CD,setReasoningContent:()=>wD,setStreamedContent:()=>yD,setThinkingStartTime:()=>SD,updateScrollButtonState:()=>nD,updateStreamingMessage:()=>DD});r(`zh`,{chatStream:{thinking:`思考中...`,outputting:`输出中...`,stopGenerating:`停止生成`,thinkingResult:`思考结果`,toolActionOperate:`操作`,toolActionUpload:`上传`,toolActionDownload:`下载`,toolActionRequest:`请求`,toolActionInteract:`交互`,toolActionFill:`填写`,toolActionDispatch:`分派`,toolActionPreview:`预览`,toolActionRead:`读取`,toolActionWrite:`写入`,terminateCommand:`终止命令`,abortWaiting:`终止等待(跳过当前工具执行等待,不终止实际进程)`,executing:`执行中...`,terminating:`正在终止...`,copyCode:`复制代码`,truncatedTitle:`原始结果过大,已截断显示`,truncatedNote:`(输出过长已截断)`,noOutput:`(无输出)`,execFailed:`执行失败`,clickToExpand:`
|
|
1713
1719
|
... (点击展开查看完整输出)`,execResult:`执行结果`,statusFailed:`失败`,statusCompleted:`完成`,preselectFiltered:`从 {total} 个工具中筛选出 <strong>{count}</strong> 个:`,preselectSkippedAll:`跳过筛选({reason}),使用全部工具`,preselectSkippedCount:`跳过筛选({reason}),工具总数 {count}`,preselectDirectAnswer:`模型直接回答:`,toolPreselect:`工具预筛选`,toolsAfterFilter:`筛选后工具数:<strong>{count}</strong>`,listSeparator:`、`,totalNodes:`总节点`,successLabel:`成功`,failedLabel:`失败`,tokenLabel:`Token`,tokenUsageTitle:`Token 消耗: {total} (Prompt: {prompt}, Completion: {completion})`,thinkingProcess:`思考过程`,copyMarkdown:`复制 Markdown 内容 (Ctrl/Cmd + 点击复制富文本)`,copy:`复制`,quoteTitle:`引用该内容问答`,quote:`引用`,export:`导出`,exportWord:`导出 Word`,exportPdf:`导出 PDF`,exportImage:`导出图片`,exportMarkdown:`导出 Markdown`,executionLog:`执行日志`,reflectionRoundsTag:` ({count}轮)`,qualityAssessmentTitle:`AI 质量评估: {score}/10{rounds}
|
|
1714
1720
|
点击查看评估详情`,reflectionFailedTitle:`反思评估失败(点击查看执行日志)`,reflectionFailedBadge:`⚠️ 反思失败`,prototypeOpenedLocal:`已在本地浏览器打开,点击可在面板内查看`,viewUiPrototype:`查看 UI 原型`,bookmarkMessage:`收藏消息`,removeBookmark:`取消收藏`,forkSession:`从此处分叉会话(仅复制到此条消息)`,deleteMessage:`删除消息`,stopping:`停止中...`,taskStopped:`任务已被用户停止`,cancelled:`已取消`}}),r(`en`,{chatStream:{thinking:`Thinking...`,outputting:`Outputting...`,stopGenerating:`Stop generating`,thinkingResult:`Thinking result`,toolActionOperate:`Operate`,toolActionUpload:`Upload`,toolActionDownload:`Download`,toolActionRequest:`Request`,toolActionInteract:`Interact`,toolActionFill:`Fill`,toolActionDispatch:`Dispatch`,toolActionPreview:`Preview`,toolActionRead:`Read`,toolActionWrite:`Write`,terminateCommand:`Terminate command`,abortWaiting:`Abort waiting (skip current tool wait, does not terminate the actual process)`,executing:`Executing...`,terminating:`Terminating...`,copyCode:`Copy code`,truncatedTitle:`Original result too large, truncated for display`,truncatedNote:`(output too long, truncated)`,noOutput:`(no output)`,execFailed:`Execution failed`,clickToExpand:`
|
|
1715
1721
|
... (click to expand and view full output)`,execResult:`Execution result`,statusFailed:`Failed`,statusCompleted:`Completed`,preselectFiltered:`Filtered <strong>{count}</strong> of {total} tools: `,preselectSkippedAll:`Skipped filtering ({reason}), using all tools`,preselectSkippedCount:`Skipped filtering ({reason}), total tools: {count}`,preselectDirectAnswer:`Model direct answer: `,toolPreselect:`Tool Pre-filter`,toolsAfterFilter:`Tools after filtering: <strong>{count}</strong>`,listSeparator:`, `,totalNodes:`Total nodes`,successLabel:`Success`,failedLabel:`Failed`,tokenLabel:`Token`,tokenUsageTitle:`Token usage: {total} (Prompt: {prompt}, Completion: {completion})`,thinkingProcess:`Thinking process`,copyMarkdown:`Copy Markdown content (Ctrl/Cmd + click to copy rich text)`,copy:`Copy`,quoteTitle:`Quote this content for Q&A`,quote:`Quote`,export:`Export`,exportWord:`Export Word`,exportPdf:`Export PDF`,exportImage:`Export Image`,exportMarkdown:`Export Markdown`,executionLog:`Execution log`,reflectionRoundsTag:` ({count} rounds)`,qualityAssessmentTitle:`AI quality assessment: {score}/10{rounds}
|
|
1716
|
-
Click to view assessment details`,reflectionFailedTitle:`Reflection assessment failed (click to view execution log)`,reflectionFailedBadge:`⚠️ Reflection failed`,prototypeOpenedLocal:`Already opened in local browser, click to view in panel`,viewUiPrototype:`View UI prototype`,bookmarkMessage:`Bookmark message`,removeBookmark:`Remove bookmark`,forkSession:`Fork session from here (copy up to this message only)`,deleteMessage:`Delete message`,stopping:`Stopping...`,taskStopped:`Task stopped by user`,cancelled:`Cancelled`}});var
|
|
1722
|
+
Click to view assessment details`,reflectionFailedTitle:`Reflection assessment failed (click to view execution log)`,reflectionFailedBadge:`⚠️ Reflection failed`,prototypeOpenedLocal:`Already opened in local browser, click to view in panel`,viewUiPrototype:`View UI prototype`,bookmarkMessage:`Bookmark message`,removeBookmark:`Remove bookmark`,forkSession:`Fork session from here (copy up to this message only)`,deleteMessage:`Delete message`,stopping:`Stopping...`,taskStopped:`Task stopped by user`,cancelled:`Cancelled`}});var ZE=new Map,QE=!1,$E=!1,eD=!1,tD=!1;function nD(){let e=document.getElementById(`scrollToBottomBtn`),t=document.getElementById(`scrollToBottomBadge`);if(!e)return;let n=document.getElementById(`chatContainer`);if(!n)return;let r=n.scrollHeight-n.scrollTop-n.clientHeight<80;r?(e.classList.remove(`visible`),tD=!1):e.classList.add(`visible`),t&&(tD&&!r?(t.classList.add(`active`),H.isGenerating?t.classList.add(`pulsing`):t.classList.remove(`pulsing`)):t.classList.remove(`active`,`pulsing`))}function rD(){if(eD)return;let e=document.getElementById(`chatContainer`);e&&(eD=!0,e.addEventListener(`scroll`,()=>{if(QE)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<80;$E=!t,t?tD=!1:H.isGenerating&&(tD=!0),nD()},{passive:!0}),document.addEventListener(`generating-state-changed`,()=>{H.isGenerating&&(tD=!0),requestAnimationFrame(()=>nD())}))}function iD(e,t={}){if(!e)return;rD();let{force:n=!1,smooth:r=!1}=t;if(!n&&$E){tD=!0,nD();return}QE=!0,r?e.scrollTo({top:e.scrollHeight,behavior:`smooth`}):e.scrollTop=e.scrollHeight,requestAnimationFrame(()=>{QE=!1})}function aD(){$E=!1,tD=!1,H.isGenerating&&(tD=!0),nD()}function oD(){rD();let e=document.getElementById(`scrollToBottomBtn`);if(!e||e.dataset.bound)return;e.dataset.bound=`1`;let t=localStorage.getItem(`scrollBtnPosition`)||`center`;e.classList.add(`pos-${t}`);let n=!1,r=0,i=0,a=!1,o=0,s=!1;function c(){let t=document.getElementById(`chatContainer`);if(!t)return;let n=t.clientWidth,r={left:n/6,center:n/2,right:n*5/6},i=`center`,a=1/0;for(let[e,t]of Object.entries(r)){let n=Math.abs(o-t);n<a&&(a=n,i=e)}e.classList.remove(`pos-left`,`pos-center`,`pos-right`),e.classList.add(`pos-${i}`),e.style.left=``,e.style.marginLeft=``,e.style.right=``,localStorage.setItem(`scrollBtnPosition`,i)}function l(){let t=document.getElementById(`chatContainer`),n=e.getBoundingClientRect(),a=t?t.getBoundingClientRect():null,o=a?n.left-a.left+n.width/2:r;e.classList.remove(`pos-left`,`pos-center`,`pos-right`),e.style.left=`${o}px`,e.style.marginLeft=`0`,e.style.right=`auto`,e.classList.add(`dragging`),i=o,s=!0}function u(e){(e.type!==`mousedown`||e.button===0)&&(e.preventDefault(),n=!0,a=!1,s=!1,r=e.touches?e.touches[0].clientX:e.clientX)}function d(t){if(!n)return;let c=t.touches?t.touches[0].clientX:t.clientX;if(!s){if(Math.abs(c-r)<=3)return;a=!0,l()}let u=document.getElementById(`chatContainer`);if(!u)return;let d=u.getBoundingClientRect(),f=i+(c-r),p=e.offsetWidth/2;f=Math.max(p,Math.min(d.width-p,f)),o=f,e.style.left=`${f}px`}function f(){if(n){if(n=!1,a)e.classList.remove(`dragging`),c();else{s&&(e.classList.remove(`dragging`),e.style.left=``,e.style.marginLeft=``,e.style.right=``);let t=document.getElementById(`chatContainer`);t&&($E=!1,tD=!1,nD(),iD(t,{force:!0,smooth:!0}))}a=!1,s=!1}}e.addEventListener(`mousedown`,u),e.addEventListener(`touchstart`,u,{passive:!1}),document.addEventListener(`mousemove`,d),document.addEventListener(`touchmove`,d,{passive:!1}),document.addEventListener(`mouseup`,f),document.addEventListener(`touchend`,f),nD()}function sD(){rD();let e=document.getElementById(`chatContainer`);e&&(e.scrollHeight-e.scrollTop-e.clientHeight<80||(tD=!0),nD())}function cD(e,t){let n=e.querySelector(`.thinking-process-content`);if(!n)return;e.dataset.activeFilter=t,e.querySelectorAll(`.thinking-process-stat[data-filter]`).forEach(e=>{e.classList.toggle(`active`,e.dataset.filter===t)});let r=e=>t===`all`||e===t;n.querySelectorAll(`.tool-call-item`).forEach(e=>{e.classList.contains(`preselect-card`)||(e.style.display=r(e.dataset.status)?``:`none`)}),n.querySelectorAll(`.thinking-badge`).forEach(e=>{let t=r(e.dataset.status||`success`);e.style.display=t?``:`none`;let n=e.nextElementSibling;n&&n.classList.contains(`thinking-content`)&&(n.style.display=t?``:`none`)}),n.querySelectorAll(`.thinking-content`).forEach(e=>{let t=e.previousElementSibling;t&&t.classList.contains(`thinking-badge`)||(e.style.display=r(`success`)?``:`none`)})}function lD(e){if(!e||e._filterBound)return;e._filterBound=!0;let t=[``,`success`,`failed`];e.querySelectorAll(`.thinking-process-stat`).forEach((e,n)=>{t[n]&&(e.dataset.filter=t[n],e.classList.add(`filterable`))}),e.querySelectorAll(`.token-stat`).forEach(e=>{e.style.cursor=`pointer`}),e.addEventListener(`click`,t=>{if(t.ctrlKey||t.metaKey)return;let n=t.target.closest(`.thinking-process-stat`),r=e.closest(`.thinking-process`);if(r){if(n&&n.classList.contains(`token-stat`)){let e=r.closest(`.message`);if(e)try{let t=e.dataset.executionLog,r=ze(t?JSON.parse(t):[]);r&&Be(r,n)}catch{}return}n&&n.dataset.filter?cD(r,r.dataset.activeFilter===n.dataset.filter?`all`:n.dataset.filter):r.classList.toggle(`collapsed`)}});let n=e.closest(`.thinking-process`);n&&cD(n,n.dataset.activeFilter||`all`)}async function uD(){try{let{getAllAgents:e}=await fe(async()=>{let{getAllAgents:e}=await import(`./agent-store-DOyMdB_7.js`).then(e=>e.t);return{getAllAgents:e}},__vite__mapDeps([0,1,2,3])),t=await e();ZE.clear();for(let e of t)ZE.set(e.id,e.name||e.id)}catch{}}function dD(e){return ZE.get(e)||e}var fD=new Map,pD=new Map,mD=null,hD=0,gD=0;function _D(e){return t=>t===void 0?fD.get(e)||null:(fD.set(e,t),t)}function vD(e){fD.delete(e),pD.delete(e)}function yD(e,t){pD.set(e,t)}function bD(){return mD}function xD(e){mD=e}function SD(e){hD=e}function CD(e){gD=e}function wD(e){}function TD(e){let t=document.getElementById(`chatContainer`),n=document.createElement(`div`);n.className=`message-wrapper assistant streaming`;let r=`msg_`+Date.now().toString(36)+`_`+Math.random().toString(36).substring(2,8);n.dataset.messageId=r,n.dataset.sessionId=e||``,n.innerHTML=`
|
|
1717
1723
|
<div class="message-content">
|
|
1718
1724
|
<div class="stream-content"></div>
|
|
1719
1725
|
<div class="thinking-indicator">
|
|
@@ -1734,7 +1740,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1734
1740
|
</div>
|
|
1735
1741
|
<div class="stream-status hidden"></div>
|
|
1736
1742
|
</div>
|
|
1737
|
-
`,(!e||e===H.activeSessionId)&&t&&(t.appendChild(n),
|
|
1743
|
+
`,(!e||e===H.activeSessionId)&&t&&(t.appendChild(n),aD(),nD(),requestAnimationFrame(()=>{iD(t,{force:!0})}));let a=n.querySelector(`.streaming-stop-btn`);return a&&a.addEventListener(`click`,e=>{e.stopPropagation(),ND(a)}),n}function ED(e){let t=fD.get(e);if(!t||t.dataset.sessionId&&t.dataset.sessionId!==e)return;let n=document.getElementById(`chatContainer`);if(!n)return;n.appendChild(t);let r=pD.get(e)||``;r&&(DD(t,r),t.querySelectorAll(`.thinking-indicator:not(.hidden)`).forEach(e=>{let t=e.parentElement,n=e.previousElementSibling,r=document.createElement(`span`);r.className=`thinking-badge`,r.dataset.status=`success`,r.innerHTML=`<svg class="thinking-icon-static" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2a3 3 0 0 0-3 3v1a3 3 0 0 0 3 3 3 3 0 0 1 3 3v1a3 3 0 0 1-3 3 3 3 0 0 0-3 3v1a3 3 0 0 0 3 3"/><circle cx="8" cy="12" r="1.5"/><circle cx="16" cy="12" r="1.5"/></svg>`+i(`chatStream.thinkingResult`),n&&n.classList.contains(`thinking-content`)?t.insertBefore(r,n):t.insertBefore(r,e),e.classList.add(`hidden`)})),requestAnimationFrame(()=>{n.scrollTop=n.scrollHeight})}function DD(e,t){let n=e.querySelector(`.stream-content`);if(!n)return;let r=n.querySelector(`.thinking-indicator:not(.hidden)`)||e.querySelector(`.thinking-indicator:not(.hidden)`);if(r){let e=r.querySelector(`.thinking-label`);if(e&&(e.textContent===i(`chatStream.thinking`)||e.dataset.retrying===`1`)&&(e.textContent=i(`chatStream.outputting`),delete e.dataset.retrying),n.contains(r)){let e=r.previousElementSibling;if(e&&e.classList.contains(`thinking-content`))e.innerHTML=Pi(t);else{let e=document.createElement(`div`);e.className=`thinking-content`,e.innerHTML=Pi(t),n.insertBefore(e,r)}}else{let e=n.querySelectorAll(`.thinking-content`);if(e.length===0){let e=document.createElement(`div`);e.className=`thinking-content`,e.innerHTML=Pi(t),n.appendChild(e)}else{let r=e[e.length-1],i=r.nextElementSibling;if(!i||!i.classList.contains(`thinking-badge`))r.innerHTML=Pi(t);else{let e=document.createElement(`div`);e.className=`thinking-content`,e.innerHTML=Pi(t),n.appendChild(e)}}}}else{let e=n.querySelectorAll(`.thinking-badge`);if(e.length>0){let n=e[e.length-1],r=n.nextElementSibling;if(r&&r.classList.contains(`thinking-content`))r.innerHTML=Pi(t);else{let e=document.createElement(`div`);e.className=`thinking-content`,e.innerHTML=Pi(t),n.after(e)}}else{let e=document.createElement(`div`);e.className=`thinking-content`,e.innerHTML=Pi(t),n.appendChild(e)}}e.isConnected&&requestAnimationFrame(()=>{let e=document.getElementById(`chatContainer`);e&&iD(e)})}function OD(e,t){if(!e||!t?.length)return;let n=e.querySelector(`.stream-content`);if(!n)return;let r=e.querySelector(`.thinking-indicator:not(.hidden)`);if(r){let e=hD>0?Me(Date.now()-hD):``,t=document.createElement(`span`);if(t.className=`thinking-badge`,t.innerHTML=`<svg class="thinking-icon-static" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2a3 3 0 0 0-3 3v1a3 3 0 0 0 3 3 3 3 0 0 1 3 3v1a3 3 0 0 1-3 3 3 3 0 0 0-3 3v1a3 3 0 0 0 3 3"/><circle cx="8" cy="12" r="1.5"/><circle cx="16" cy="12" r="1.5"/></svg>${i(`chatStream.thinkingResult`)}${e?` <span class="thinking-duration">`+e+`</span>`:``}`,t.dataset.status=`success`,n.contains(r)){let e=r.previousElementSibling;e&&e.classList.contains(`thinking-content`)?n.insertBefore(t,e):n.insertBefore(t,r),r.classList.add(`hidden`)}else{let e=n.querySelectorAll(`.thinking-content`);if(e.length>0){let r=e[e.length-1],i=r.nextElementSibling;!i||!i.classList.contains(`thinking-badge`)?n.insertBefore(t,r):n.appendChild(t)}else n.appendChild(t);r.classList.add(`hidden`),r.remove()}}let a={execute_command:{metaType:`exec`},agent_exec:{metaType:`exec`},agent_file:{metaType:`file`,action:i(`chatStream.toolActionOperate`)},file_upload:{metaType:`file`,action:i(`chatStream.toolActionUpload`)},download_file:{metaType:`file`,action:i(`chatStream.toolActionDownload`)},fetch_url:{metaType:`web`,action:i(`chatStream.toolActionRequest`)},interact_element:{metaType:`web`,action:i(`chatStream.toolActionInteract`)},fill_form:{metaType:`web`,action:i(`chatStream.toolActionFill`)},manage_tab:{metaType:`web`,action:i(`chatStream.toolActionOperate`)},search_browser_data:{metaType:`search`},search_in_page:{metaType:`search`},dispatch_task:{metaType:`subagent`,action:i(`chatStream.toolActionDispatch`)},exec_log:{metaType:`search`},preview_ui:{metaType:`web`,action:i(`chatStream.toolActionPreview`)}};t.filter(e=>e&&typeof e==`object`).forEach(e=>{let t=e.function?.name||`unknown`,r=a[t]||{metaType:`other`},o;try{o=JSON.parse(e.function?.arguments||`{}`)}catch{o={raw:e.function?.arguments||``}}let s=JSON.stringify(o,null,2),c=``,l=``;if(r.metaType===`exec`){let e=o.command||o.cmd||JSON.stringify(o);l=e,c=`<code class="tool-call-cmd">$ ${W(e)}</code>`}else if(r.metaType===`file`){let e=o.file_path||o.filePath||o.path||o.filename||o.fileName||o.url||``,n=r.action===i(`chatStream.toolActionRead`)?`📖`:r.action===i(`chatStream.toolActionWrite`)?`📝`:r.action===i(`chatStream.toolActionUpload`)?`📤`:`📥`;l=e||t,c=`<span class="tool-call-file">${n} ${W(e)||W(t)}</span>`}else if(r.metaType===`web`){let e=o.url||o.href||o.selector||``;l=e||JSON.stringify(o),c=`<span class="tool-call-web">${W(r.action)}: ${W(e)||W(JSON.stringify(o).substring(0,80))}</span>`}else if(r.metaType===`search`){let e=o.query||o.keyword||o.text||``;l=e||t,c=`<span class="tool-call-search">🔍 ${W(e)||W(t)}</span>`}else if(r.metaType===`subagent`){let e=o.subAgentId||o.agent_id||``,t=e?dD(e):``,n=(o.task||``).substring(0,80);t&&t!==e?(l=`${t} (${e}): ${n}`,c=`<span class="tool-call-subagent">🤖 <strong>${W(t)}</strong> <span class="tool-call-subagent-id">(${W(e)})</span>: ${W(n)}</span>`):(l=`${e}: ${n}`,c=`<span class="tool-call-subagent">🤖 <strong>${W(e)}</strong>: ${W(n)}</span>`)}else{let e=Object.keys(o);if(e.length===0)l=t,c=`<span>${W(t)}</span>`;else if(e.length===1){let t=JSON.stringify(o[e[0]]);l=`${e[0]}: ${t}`,c=`<span>${W(e[0])}: ${W(t.substring(0,80))}</span>`}else l=e.map(e=>`${e}=${JSON.stringify(o[e])}`).join(`, `),c=`<span>${e.slice(0,2).map(e=>`${W(e)}=${W(JSON.stringify(o[e]).substring(0,30))}`).join(`, `)}${e.length>2?` ...`:``}</span>`}let u=r.metaType===`exec`?`<svg class="tool-call-icon exec" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1738
1744
|
<polyline points="4 17 10 11 4 5"/><line x1="12" y1="19" x2="20" y2="19"/>
|
|
1739
1745
|
</svg>`:r.metaType===`file`?`<svg class="tool-call-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1740
1746
|
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
|
|
@@ -1762,16 +1768,16 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1762
1768
|
<svg class="tool-call-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>
|
|
1763
1769
|
</div>
|
|
1764
1770
|
<div class="tool-call-body">
|
|
1765
|
-
${
|
|
1771
|
+
${kD(W(s))}
|
|
1766
1772
|
</div>
|
|
1767
|
-
`,l){let e=d.querySelector(`.tool-call-summary`);e&&(e.title=l)}if(Ki(),f){let e=d.querySelector(`.tool-call-terminate-btn`);e&&e.addEventListener(`click`,e=>{e.stopPropagation(),
|
|
1773
|
+
`,l){let e=d.querySelector(`.tool-call-summary`);e&&(e.title=l)}if(Ki(),f){let e=d.querySelector(`.tool-call-terminate-btn`);e&&e.addEventListener(`click`,e=>{e.stopPropagation(),vO(H.activeSessionId)})}let h=d.querySelector(`.tool-call-abort-btn`);h&&h.addEventListener(`click`,e=>{e.stopPropagation(),chrome.runtime.sendMessage({type:`ABORT_CURRENT_TOOL`,sessionId:H.activeSessionId}),h.disabled=!0,h.title=i(`chatStream.terminating`)}),d.querySelector(`.tool-call-header`).addEventListener(`click`,e=>{e.ctrlKey||e.metaKey||d.classList.toggle(`expanded`)}),n.appendChild(d)}),e.isConnected&&requestAnimationFrame(()=>{let e=document.getElementById(`chatContainer`);e&&iD(e)})}function kD(e,t=``){let n=t?` class="${t}"`:``;return`<div class="code-block-container" style="position: relative;">
|
|
1768
1774
|
<button class="code-copy-btn" title="${i(`chatStream.copyCode`)}">
|
|
1769
1775
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
1770
1776
|
<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"/>
|
|
1771
1777
|
</svg>
|
|
1772
1778
|
</button>
|
|
1773
1779
|
<pre${n}><code>${e}</code></pre>
|
|
1774
|
-
</div>`}function
|
|
1780
|
+
</div>`}function AD(e,t){if(!e?.toolCallId)return;let n=t;if(!n)return;let r=n.querySelector(`.tool-call-item[data-tool-call-id="${e.toolCallId}"]`);if(!r)return;r.classList.add(`has-result`),r.dataset.status=e.success?`success`:`failed`;let a=parseInt(r.getAttribute(`data-created-at`),10),o=Date.now()-a,s=o<400&&o>=0?400-o:0,c=()=>{let n=r.querySelector(`.tool-call-executing`);n&&n.remove();let a=r.querySelector(`.tool-call-terminate-btn`);a&&(a.style.display=`none`);let o=r.querySelector(`.tool-call-abort-btn`);o&&(o.style.display=`none`);let s=r.querySelector(`.tool-call-result`);s&&s.remove();let c=e.truncated?`<span class="tool-result-truncated" title="${i(`chatStream.truncatedTitle`)}">${i(`chatStream.truncatedNote`)}</span>`:``,l=r.getAttribute(`data-meta-type`)===`exec`,u=r.querySelector(`.tool-call-header`),d=`
|
|
1775
1781
|
<span class="tool-result-status ${e.success?`success`:`fail`}">
|
|
1776
1782
|
${e.success?`<svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>`:`<svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16"><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z"/></svg>`}
|
|
1777
1783
|
</span>
|
|
@@ -1780,9 +1786,9 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1780
1786
|
`,f=u.querySelector(`.tool-call-chevron`);if(f?f.insertAdjacentHTML(`beforebegin`,d):u.insertAdjacentHTML(`beforeend`,d),!l||!e.success){let t=e.content||(e.success?i(`chatStream.noOutput`):i(`chatStream.execFailed`)),n=t.length>500?t.substring(0,500)+i(`chatStream.clickToExpand`):t,a=t,o=document.createElement(`div`);if(o.className=`tool-call-result`,o.innerHTML=`
|
|
1781
1787
|
<div class="tool-result-title">${i(`chatStream.execResult`)}</div>
|
|
1782
1788
|
<div class="tool-result-content">
|
|
1783
|
-
${
|
|
1789
|
+
${kD(W(n))}
|
|
1784
1790
|
</div>
|
|
1785
|
-
`,a.length>500){let e=o.querySelector(`code`);e.dataset.fullContent=a;let t=!1;o.style.cursor=`pointer`,o.addEventListener(`click`,r=>{r.ctrlKey||r.metaKey||(t=!t,e.textContent=t?a:n)})}let s=r.querySelector(`.tool-call-body`);s?s.appendChild(o):r.appendChild(o)}Ki(),t.isConnected&&requestAnimationFrame(()=>{let e=document.getElementById(`chatContainer`);e&&
|
|
1791
|
+
`,a.length>500){let e=o.querySelector(`code`);e.dataset.fullContent=a;let t=!1;o.style.cursor=`pointer`,o.addEventListener(`click`,r=>{r.ctrlKey||r.metaKey||(t=!t,e.textContent=t?a:n)})}let s=r.querySelector(`.tool-call-body`);s?s.appendChild(o):r.appendChild(o)}Ki(),t.isConnected&&requestAnimationFrame(()=>{let e=document.getElementById(`chatContainer`);e&&iD(e)})};s>0?setTimeout(c,s):c()}function jD(e){let t=document.createElement(`div`);t.className=`tool-call-item preselect-card`+(H.chatConfig?.streamExpandTools?` expanded`:``);let n=e.status===`failed`,r=``,a=``;if(e.action?.params?.selected){let t=e.action.params.selected,n=e.apiRequest?.toolCount||`?`;r=`<div class="tool-call-summary"><span>${i(`chatStream.preselectFiltered`,{total:n,count:t.length})}</span></div>`,a=`<span class="preselect-summary">${t.map(e=>`<code>${W(e)}</code>`).join(i(`chatStream.listSeparator`))}</span>`}else e.action?.name===`all_tools`?(r=`<div class="tool-call-summary"><span>${W(e.action.params.reason||``)}</span></div>`,a=`<span class="preselect-summary">${i(`chatStream.preselectSkippedAll`,{reason:W(e.action.params.reason||``)})}</span>`):e.action?.name===`skip`?(r=`<div class="tool-call-summary"><span>${W(e.action.params.reason||``)}</span></div>`,a=`<span class="preselect-summary">${i(`chatStream.preselectSkippedCount`,{reason:W(e.action.params.reason||``),count:e.action.params.toolCount||`?`})}</span>`):e.error?(r=`<div class="tool-call-summary"><span style="color:#dc2626;">${W(e.error)}</span></div>`,a=`<span class="preselect-summary" style="color:#dc2626;">${W(e.error)}</span>`):e.thought&&(r=`<div class="tool-call-summary"><span>${i(`chatStream.preselectDirectAnswer`)}</span></div>`,a=`<span class="preselect-summary">${i(`chatStream.preselectDirectAnswer`)}${W(e.thought).substring(0,200)}</span>`);let o=e.duration?Me(e.duration):``,s=n?`<svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16"><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z"/></svg>`:`<svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>`;return t.innerHTML=`
|
|
1786
1792
|
<div class="tool-call-header">
|
|
1787
1793
|
<svg class="tool-call-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1788
1794
|
<circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>
|
|
@@ -1797,7 +1803,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1797
1803
|
${a}
|
|
1798
1804
|
${e.apiResponse?.toolCountAfter===void 0?``:`<div class="preselect-meta">${i(`chatStream.toolsAfterFilter`,{count:e.apiResponse.toolCountAfter})}</div>`}
|
|
1799
1805
|
</div>
|
|
1800
|
-
`,t.querySelector(`.tool-call-header`).addEventListener(`click`,e=>{e.ctrlKey||e.metaKey||t.classList.toggle(`expanded`)}),t}function
|
|
1806
|
+
`,t.querySelector(`.tool-call-header`).addEventListener(`click`,e=>{e.ctrlKey||e.metaKey||t.classList.toggle(`expanded`)}),t}function MD(e,t,n=[],r=null,a=null,s=!1){if(!e)return;let c=e.querySelector(`.message-content`),l=e.querySelector(`.stream-content`),u=e.querySelector(`.thinking-indicator:not(.hidden)`);if(u&&l){let e=hD>0?Me(Date.now()-hD):``,t=document.createElement(`span`);if(t.className=`thinking-badge`,t.innerHTML=`<svg class="thinking-icon-static" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2a3 3 0 0 0-3 3v1a3 3 0 0 0 3 3 3 3 0 0 1 3 3v1a3 3 0 0 1-3 3 3 3 0 0 0-3 3v1a3 3 0 0 0 3 3"/><circle cx="8" cy="12" r="1.5"/><circle cx="16" cy="12" r="1.5"/></svg>${i(`chatStream.thinkingResult`)}${e?` <span class="thinking-duration">`+e+`</span>`:``}`,t.dataset.status=`success`,l.contains(u)){let e=u.previousElementSibling;e&&e.classList.contains(`thinking-content`)?l.insertBefore(t,e):l.insertBefore(t,u),u.classList.add(`hidden`)}else{let e=l.querySelectorAll(`.thinking-content`);if(e.length>0){let n=e[e.length-1],r=n.nextElementSibling;!r||!r.classList.contains(`thinking-badge`)?l.insertBefore(t,n):l.appendChild(t)}else l.appendChild(t);u.classList.add(`hidden`),u.remove()}}e.querySelectorAll(`.thinking-indicator`).forEach(e=>e.classList.add(`hidden`));let d=e.querySelector(`.stream-status`);if(d&&d.remove(),e.classList.remove(`streaming`),c&&c.querySelector(`.tool-call-item`)||l&&l.querySelector(`.tool-call-item`)){let e=gD>0?Me(Date.now()-gD):``,r=(n||[]).filter(e=>e.nodeType===`api_call`||e.nodeType===`tool_exec`),a=r.filter(e=>e.status===`success`).length,u=r.filter(e=>e.status===`failed`).length,d=r.length,f=ze(n),p=document.createElement(`div`);p.className=`thinking-process collapsed`;let m=document.createElement(`div`);m.className=`thinking-process-header`;let h=d>0?`
|
|
1801
1807
|
<span class="thinking-process-stat">
|
|
1802
1808
|
<span class="stat-icon node-icon">◉</span>
|
|
1803
1809
|
<span class="stat-label">${i(`chatStream.totalNodes`)}</span>
|
|
@@ -1832,7 +1838,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1832
1838
|
<svg class="thinking-process-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
1833
1839
|
<polyline points="6 9 12 15 18 9"/>
|
|
1834
1840
|
</svg>
|
|
1835
|
-
`,f){let e=m.querySelector(`.token-stat`);e&&(e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Be(f,e)}))}let _=document.createElement(`div`);_.className=`thinking-process-body`;let v=document.createElement(`div`);if(v.className=`thinking-process-content`,_.appendChild(v),l)for(;l.firstChild;)v.appendChild(l.firstChild);c.querySelectorAll(`.tool-call-item`).forEach(e=>v.appendChild(e)),v.querySelectorAll(`.preselect-card`).forEach(e=>e.remove());let y=(n||[]).filter(e=>e.nodeType===`preselect`);o.debug(`[finalizeStreamingMessage] executionLog length:`,(n||[]).length,`preselectEntries:`,y.length),y.forEach(e=>{o.debug(`[finalizeStreamingMessage] creating preselect card for entry:`,e);let t=
|
|
1841
|
+
`,f){let e=m.querySelector(`.token-stat`);e&&(e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Be(f,e)}))}let _=document.createElement(`div`);_.className=`thinking-process-body`;let v=document.createElement(`div`);if(v.className=`thinking-process-content`,_.appendChild(v),l)for(;l.firstChild;)v.appendChild(l.firstChild);c.querySelectorAll(`.tool-call-item`).forEach(e=>v.appendChild(e)),v.querySelectorAll(`.preselect-card`).forEach(e=>e.remove());let y=(n||[]).filter(e=>e.nodeType===`preselect`);o.debug(`[finalizeStreamingMessage] executionLog length:`,(n||[]).length,`preselectEntries:`,y.length),y.forEach(e=>{o.debug(`[finalizeStreamingMessage] creating preselect card for entry:`,e);let t=jD(e);v.insertBefore(t,v.firstChild)});let b=v.querySelectorAll(`.thinking-content`),x=RD(t).trim();if(b.length>0){let e=b[b.length-1],t=e.textContent.trim();if(!s||s&&t===x){let t=e.previousElementSibling;for(;t;){if(t.classList.contains(`thinking-badge`)){t.remove();break}t=t.previousElementSibling}e.remove()}}if(v.children.length>0&&v.textContent.trim()){p.appendChild(m),p.appendChild(_);let e=document.createElement(`div`);e.className=`final-answer`;let n=RD(t);n&&n.trim()&&(e.innerHTML=Pi(n));let r=c.querySelector(`.thinking-indicator`);r&&r.remove(),l&&(l.innerHTML=``),c.appendChild(p),c.appendChild(e),lD(m)}else{let e=c.querySelector(`.thinking-indicator`);if(e&&e.remove(),l){let e=RD(t);e&&e.trim()&&(l.innerHTML=Pi(e))}}}else if(l){let e=RD(t);if(l.querySelector(`.thinking-content`)){let t=gD>0?Me(Date.now()-gD):``,r=(n||[]).filter(e=>e.nodeType===`api_call`||e.nodeType===`tool_exec`),a=r.filter(e=>e.status===`success`).length,o=r.filter(e=>e.status===`failed`).length,u=r.length,d=ze(n),f=document.createElement(`div`);f.className=`thinking-process collapsed`;let p=document.createElement(`div`);p.className=`thinking-process-header`;let m=u>0?`
|
|
1836
1842
|
<span class="thinking-process-stat">
|
|
1837
1843
|
<span class="stat-icon node-icon">◉</span>
|
|
1838
1844
|
<span class="stat-label">${i(`chatStream.totalNodes`)}</span>
|
|
@@ -1867,7 +1873,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1867
1873
|
<svg class="thinking-process-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
1868
1874
|
<polyline points="6 9 12 15 18 9"/>
|
|
1869
1875
|
</svg>
|
|
1870
|
-
`,d){let e=p.querySelector(`.token-stat`);e&&(e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Be(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=Pi(e));let n=c.querySelector(`.thinking-indicator`);n&&n.remove(),c.appendChild(f),c.appendChild(t),cD(p)}else{let t=c.querySelector(`.thinking-indicator`);t&&t.remove(),e&&e.trim()&&(l.innerHTML=Pi(e))}}else e&&e.trim()&&(l.innerHTML=Pi(e))}e.classList.add(`assistant`,`message`),e.dataset.rawContent=typeof t==`string`?t:JSON.stringify(t),e.dataset.textContent_=LD(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=i(`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>`+i(`chatStream.copy`)+`</span>`].join(``),p.addEventListener(`click`,t=>{t.stopPropagation(),NE(e,p,t)}),f.appendChild(p);let m=document.createElement(`button`);m.className=`quote-btn`,m.title=i(`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>`+i(`chatStream.quote`)+`</span>`].join(``),m.addEventListener(`click`,t=>{t.stopPropagation(),VE(e)}),f.appendChild(m);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>`+i(`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>`+i(`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>`+i(`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>`+i(`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>`+i(`chatStream.exportMarkdown`)+`</span>`,`</button>`].join(``);let v=_.querySelector(`.export-docx-item`);v.addEventListener(`click`,t=>{t.stopPropagation(),Ub(e,v,_)});let y=_.querySelector(`.export-md-item`);y.addEventListener(`click`,t=>{t.stopPropagation(),Gb(e,y,_)});let b=_.querySelector(`.export-pdf-item`);b.addEventListener(`click`,t=>{t.stopPropagation(),Wb(e,b,_)});let x=_.querySelector(`.export-image-item`);x.addEventListener(`click`,t=>{t.stopPropagation(),Kb(e,x,_)}),g.addEventListener(`click`,e=>{e.stopPropagation(),document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==_&&e.classList.remove(`show`)}),_.classList.toggle(`show`)});let S=null;h.addEventListener(`mouseenter`,()=>{S=setTimeout(()=>{document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==_&&e.classList.remove(`show`)}),_.classList.add(`show`)},300)}),h.addEventListener(`mouseleave`,()=>{S&&=(clearTimeout(S),null),setTimeout(()=>{!h.matches(`:hover`)&&!_.matches(`:hover`)&&_.classList.remove(`show`)},100)}),h.appendChild(g),h.appendChild(_),f.appendChild(h);let C=document.createElement(`div`);C.className=`footer-right-actions`,C.style.marginLeft=`auto`,C.style.display=`flex`,C.style.alignItems=`center`,C.style.gap=`8px`;let w=ze(n);if(w){let e=document.createElement(`span`);e.className=`token-usage-tag`,e.title=i(`chatStream.tokenUsageTitle`,{total:Le(w.totalTokens),prompt:Le(w.promptTokens),completion:Le(w.completionTokens)}),e.innerHTML=`<span class="token-tag-icon">⬤</span><span class="token-tag-value">${Le(w.totalTokens)}</span>`,e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Be(w,e)}),C.appendChild(e)}let T=gT(n);if(PT(T),T.length>0){let e=document.createElement(`button`);e.className=`artifacts-btn`,e.type=`button`,e.title=i(`artifacts.btnTitle`,{count:T.length}),e.innerHTML=`
|
|
1876
|
+
`,d){let e=p.querySelector(`.token-stat`);e&&(e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Be(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=Pi(e));let n=c.querySelector(`.thinking-indicator`);n&&n.remove(),c.appendChild(f),c.appendChild(t),lD(p)}else{let t=c.querySelector(`.thinking-indicator`);t&&t.remove(),e&&e.trim()&&(l.innerHTML=Pi(e))}}else e&&e.trim()&&(l.innerHTML=Pi(e))}e.classList.add(`assistant`,`message`),e.dataset.rawContent=typeof t==`string`?t:JSON.stringify(t),e.dataset.textContent_=RD(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=i(`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>`+i(`chatStream.copy`)+`</span>`].join(``),p.addEventListener(`click`,t=>{t.stopPropagation(),PE(e,p,t)}),f.appendChild(p);let m=document.createElement(`button`);m.className=`quote-btn`,m.title=i(`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>`+i(`chatStream.quote`)+`</span>`].join(``),m.addEventListener(`click`,t=>{t.stopPropagation(),HE(e)}),f.appendChild(m);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>`+i(`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>`+i(`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>`+i(`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>`+i(`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>`+i(`chatStream.exportMarkdown`)+`</span>`,`</button>`].join(``);let v=_.querySelector(`.export-docx-item`);v.addEventListener(`click`,t=>{t.stopPropagation(),Ub(e,v,_)});let y=_.querySelector(`.export-md-item`);y.addEventListener(`click`,t=>{t.stopPropagation(),Gb(e,y,_)});let b=_.querySelector(`.export-pdf-item`);b.addEventListener(`click`,t=>{t.stopPropagation(),Wb(e,b,_)});let x=_.querySelector(`.export-image-item`);x.addEventListener(`click`,t=>{t.stopPropagation(),Kb(e,x,_)}),g.addEventListener(`click`,e=>{e.stopPropagation(),document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==_&&e.classList.remove(`show`)}),_.classList.toggle(`show`)});let S=null;h.addEventListener(`mouseenter`,()=>{S=setTimeout(()=>{document.querySelectorAll(`.export-dropdown.show`).forEach(e=>{e!==_&&e.classList.remove(`show`)}),_.classList.add(`show`)},300)}),h.addEventListener(`mouseleave`,()=>{S&&=(clearTimeout(S),null),setTimeout(()=>{!h.matches(`:hover`)&&!_.matches(`:hover`)&&_.classList.remove(`show`)},100)}),h.appendChild(g),h.appendChild(_),f.appendChild(h);let C=document.createElement(`div`);C.className=`footer-right-actions`,C.style.marginLeft=`auto`,C.style.display=`flex`,C.style.alignItems=`center`,C.style.gap=`8px`;let w=ze(n);if(w){let e=document.createElement(`span`);e.className=`token-usage-tag`,e.title=i(`chatStream.tokenUsageTitle`,{total:Le(w.totalTokens),prompt:Le(w.promptTokens),completion:Le(w.completionTokens)}),e.innerHTML=`<span class="token-tag-icon">⬤</span><span class="token-tag-value">${Le(w.totalTokens)}</span>`,e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Be(w,e)}),C.appendChild(e)}let T=_T(n);if(FT(T),T.length>0){let e=document.createElement(`button`);e.className=`artifacts-btn`,e.type=`button`,e.title=i(`artifacts.btnTitle`,{count:T.length}),e.innerHTML=`
|
|
1871
1877
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="14" height="14">
|
|
1872
1878
|
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
|
|
1873
1879
|
<polyline points="14 2 14 8 20 8"/>
|
|
@@ -1875,7 +1881,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1875
1881
|
<line x1="9" y1="15" x2="15" y2="15"/>
|
|
1876
1882
|
</svg>
|
|
1877
1883
|
<span class="artifacts-btn-count">${T.length}</span>
|
|
1878
|
-
`,e.addEventListener(`click`,t=>{t.stopPropagation(),
|
|
1884
|
+
`,e.addEventListener(`click`,t=>{t.stopPropagation(),IT(T,e)}),C.appendChild(e),PT(T,e)}if(n&&n.length>0&&H.chatConfig?.enableExecutionLog){let e=document.createElement(`button`);e.className=`execution-log-btn`,e.type=`button`,e.title=i(`chatStream.executionLog`),e.innerHTML=[`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<circle cx="12" cy="12" r="10"></circle>`,`<polyline points="12 6 12 12 16 14"></polyline>`,`</svg>`].join(``),C.appendChild(e)}let E=r!=null,D=n?n.filter(e=>e.nodeType===`reflection`&&e.reflectionType===`post`&&e.status===`success`).length:0,O=n?.find(e=>e.nodeType===`reflection`&&e.reflectionType===`post`);if(E&&H.chatConfig?.enableExecutionLog){let e=r>=8?`score-high`:r>=5?`score-mid`:`score-low`,t=r>=8?`✅`:r>=5?`🔍`:`⚠️`,n=D>1?i(`chatStream.reflectionRoundsTag`,{count:D}):``,a=document.createElement(`button`);a.className=`reflection-score-btn`,a.type=`button`,a.title=i(`chatStream.qualityAssessmentTitle`,{score:r,rounds:n}),a.innerHTML=`<span class="reflection-badge ${e}">${t} ${r}/10</span>`,a.dataset.reflectionData=JSON.stringify({overallScore:O?.overallScore??r,dimensions:O?.dimensions||null,issues:O?.issues||null,suggestions:O?.suggestions||null,decision:O?.action?.decision||null,useful:O?.useful??null,reasoning:O?.reasoning||null,suggestion:O?.suggestion||null,rounds:D,wasRevised:!1}),C.appendChild(a)}else if(!E&&O&&O.status===`failed`&&H.chatConfig?.enableExecutionLog){let e=document.createElement(`button`);e.className=`reflection-score-btn`,e.type=`button`,e.title=i(`chatStream.reflectionFailedTitle`),e.innerHTML=`<span class="reflection-badge score-low">${i(`chatStream.reflectionFailedBadge`)}</span>`,C.appendChild(e)}let k=n?.slice().reverse().find(e=>e.nodeType===`tool_exec`&&(e.action?.name===`preview_ui`||e.action?.name===`preview_ui_prototype`)&&e.status===`success`);if(k){let e=!1;if(k.observation)try{e=(typeof k.observation==`string`?JSON.parse(k.observation):k.observation)?.localOpened===!0}catch{}let t=document.createElement(`button`);t.className=`prototype-btn-small`,t.type=`button`,t.title=i(e?`chatStream.prototypeOpenedLocal`:`chatStream.viewUiPrototype`),t.innerHTML=Va,t.addEventListener(`click`,()=>{let e=k.prototypeId;if(!e&&k.observation)try{e=(typeof k.observation==`string`?JSON.parse(k.observation):k.observation)?.prototypeId}catch{}e?io(e):o.error(`[SidePanel] not found prototypeId,entry keys:`,Object.keys(k),`observation:`,k.observation)}),C.appendChild(t)}let A=document.createElement(`button`);A.className=`bookmark-btn`,A.title=i(`chatStream.bookmarkMessage`),A.innerHTML=`
|
|
1879
1885
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1880
1886
|
<path d="M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"/>
|
|
1881
1887
|
</svg>
|
|
@@ -1889,22 +1895,22 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1889
1895
|
<polyline points="3 6 5 6 21 6"></polyline>
|
|
1890
1896
|
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
|
|
1891
1897
|
</svg>
|
|
1892
|
-
`,M.addEventListener(`click`,t=>{t.stopPropagation(),
|
|
1893
|
-
点击查看评估详情`,reflectionFailedTitle:`反思评估失败(点击查看执行日志)`,reflectionFailedBadge:`⚠️ 反思失败`,prototypeLocalOpened:`已在本地浏览器打开,点击可在面板内查看`,prototypeView:`查看 UI 原型`,bookmarkMessage:`收藏消息`,unbookmarkMessage:`取消收藏`,forkSession:`从此处分叉会话(仅复制到此条消息)`,deleteMessageTitle:`删除消息`,resumeTaskTitle:`从上次中断处继续执行任务`,resumeTaskBtn:`继续执行`,clickToEnlarge:`点击查看大图`,fileExtracting:` 提取中...`,fileFailed:` 失败`,fileExtractFailed:`提取失败`,copyMessageTitle:`复制消息内容`,editAndResend:`编辑后重新发送`,thinking:`思考中...`,stopTask:`停止任务`,viewExecutionLog:`查看执行日志`,preparing:`准备中...`,stopping:`停止中...`,retrying:`连接异常,正在重试 ({attempt}/{max})...`,copyCode:`复制代码`,aborting:`正在终止...`,terminateCommandTitle:`终止命令执行`,terminateCommandPrompt:`请选择终止方式:`,terminateWaitTitle:`终止等待`,terminateWaitDesc:`仅停止等待命令输出,后台进程继续运行。<br/>适用于挂起型服务(如 npm run dev)。`,terminateCommandBtnTitle:`终止命令`,terminateCommandBtnDesc:`直接终止后台命令进程,释放资源。`,confirmDeleteMessage:`确认删除消息`,deleteMessageWarning:`删除后消息将从对话历史中移除,且无法恢复。`,confirmDelete:`确认删除`,quotedContextLabel:`💬 已引用: {text}`,selectedContextLabel:`📌 已选中: {text}`,subtaskDone:`完成`,subtaskFailed:`失败`,subtaskExecuting:`执行中...`,subtaskAllDone:`✓ 全部完成 · ✓{success} 成功 ✗{fail} 失败`,subtaskPartialFail:`✗ {success}/{total} 完成,{fail} 个节点失败`,unknownNode:`未知`,stopGeneration:`停止生成`,toolResultTitle:`执行结果`,reflectionInProgress:`质量评估中...`,cannotGetMessageContent:`无法获取消息内容`,editFailed:`编辑失败: {message}`,errTaskStopped:`任务已被用户停止`,errTaskReplaced:`任务已被新请求替代`,errSwRestarted:`后台服务异常重启,API 调用已中断`,errTimeout:`请求超时({seconds}秒)`,cancelBtn:`取消`}}),r(`en`,{chatMsg:{searchPrompt:`Search`,exportWord:`Export Word`,exportPdf:`Export PDF`,exportImage:`Export Image`,exportMarkdown:`Export Markdown`,executionLogTitle:`Execution Log`,revisedTag:`Revised`,roundsTag:` ({count} rounds)`,revisedSuffix:` (Revised)`,scoreBadgeTitle:`AI Quality Assessment: {score}/10{rounds}{revised}
|
|
1894
|
-
Click to view assessment details`,reflectionFailedTitle:`Reflection assessment failed (click to view execution log)`,reflectionFailedBadge:`⚠️ Reflection Failed`,prototypeLocalOpened:`Opened in local browser, click to view in panel`,prototypeView:`View UI Prototype`,bookmarkMessage:`Bookmark message`,unbookmarkMessage:`Remove bookmark`,forkSession:`Fork session from here (copy up to this message only)`,deleteMessageTitle:`Delete message`,resumeTaskTitle:`Resume task from last interruption`,resumeTaskBtn:`Resume`,clickToEnlarge:`Click to view full size`,fileExtracting:` extracting...`,fileFailed:` failed`,fileExtractFailed:`Extraction failed`,copyMessageTitle:`Copy message content`,editAndResend:`Edit and resend`,thinking:`Thinking...`,stopTask:`Stop task`,viewExecutionLog:`View execution log`,preparing:`Preparing...`,stopping:`Stopping...`,retrying:`Connection unstable, retrying ({attempt}/{max})...`,copyCode:`Copy code`,aborting:`Aborting...`,terminateCommandTitle:`Terminate Command Execution`,terminateCommandPrompt:`Please select a termination method:`,terminateWaitTitle:`Stop Waiting`,terminateWaitDesc:`Only stop waiting for command output; the background process continues running.<br/>Suitable for hanging services (e.g. npm run dev).`,terminateCommandBtnTitle:`Terminate Command`,terminateCommandBtnDesc:`Directly terminate the background command process and release resources.`,confirmDeleteMessage:`Confirm Delete Message`,deleteMessageWarning:`After deletion, the message will be removed from the conversation history and cannot be recovered.`,confirmDelete:`Confirm Delete`,quotedContextLabel:`💬 Quoted: {text}`,selectedContextLabel:`📌 Selected: {text}`,subtaskDone:`Done`,subtaskFailed:`Failed`,subtaskExecuting:`Executing...`,subtaskAllDone:`✓ All done · ✓{success} succeeded ✗{fail} failed`,subtaskPartialFail:`✗ {success}/{total} done, {fail} nodes failed`,unknownNode:`Unknown`,stopGeneration:`Stop generation`,toolResultTitle:`Execution Result`,reflectionInProgress:`Assessing quality...`,cannotGetMessageContent:`Cannot get message content`,editFailed:`Edit failed: {message}`,errTaskStopped:`Task stopped by user`,errTaskReplaced:`Task replaced by new request`,errSwRestarted:`Background service restarted unexpectedly, API call interrupted`,errTimeout:`Request timeout ({seconds}s)`,cancelBtn:`Cancel`}});var
|
|
1898
|
+
`,M.addEventListener(`click`,t=>{t.stopPropagation(),bO(e)}),C.appendChild(M),f.appendChild(C),e.querySelector(`.message-content`).appendChild(f),uO(),fO(),Ki(),Ui(e).then(()=>{e.dataset.htmlContent=e.outerHTML}),e.dataset.htmlContent=e.outerHTML,requestAnimationFrame(()=>{if(rD(),!$E){let t=document.getElementById(`chatContainer`);t&&e.offsetHeight>t.clientHeight*.6&&e.scrollIntoView({behavior:`smooth`,block:`start`})}nD()})}function ND(e){if(!e||e.disabled)return;e.disabled=!0,e.style.opacity=`0.4`,e.style.cursor=`not-allowed`;let t=document.querySelector(`.loading-message .stop-task-btn`);if(t){t.disabled=!0,t.style.opacity=`0.6`,t.style.cursor=`not-allowed`;let e=document.querySelector(`.loading-message .loading-text`);e&&(e.textContent=i(`chatStream.stopping`))}chrome.runtime.sendMessage({type:`CANCEL_REACT`,tabId:null,sessionId:H.activeSessionId}),H.pendingCancelApi&&H.pendingCancelApi({message:i(`chatStream.taskStopped`),executionLog:H.currentExecutionStatus?.executionLog||[]})}function PD(e){if(!e)return;e.querySelectorAll(`.thinking-indicator`).forEach(e=>e.classList.add(`hidden`));let t=e.querySelector(`.stream-status`);t&&(t.textContent=``),e.querySelectorAll(`.tool-call-executing`).forEach(e=>{e.textContent=i(`chatStream.cancelled`),e.classList.add(`tool-call-cancelled`)}),e.querySelectorAll(`.subtask-status-label`).forEach(e=>{let t=e.querySelector(`.subtask-spinner`);t&&t.remove(),e.textContent.includes(i(`chatStream.executing`))&&(e.textContent=i(`chatStream.cancelled`))}),e.querySelectorAll(`.subtask-spinner, .thinking-spinner, .loading-dots`).forEach(e=>e.remove()),e.classList.remove(`streaming`),e.classList.add(`stream-cancelled`),e.querySelectorAll(`.tool-call-abort-btn`).forEach(e=>e.style.display=`none`),e.querySelectorAll(`.tool-call-terminate-btn`).forEach(e=>e.style.display=`none`)}VE(zD),r(`zh`,{chatMsg:{searchPrompt:`搜索一下`,exportWord:`导出 Word`,exportPdf:`导出 PDF`,exportImage:`导出图片`,exportMarkdown:`导出 Markdown`,executionLogTitle:`执行日志`,revisedTag:`已修订`,roundsTag:` ({count}轮)`,revisedSuffix:`(已修订)`,scoreBadgeTitle:`AI 质量评估: {score}/10{rounds}{revised}
|
|
1899
|
+
点击查看评估详情`,reflectionFailedTitle:`反思评估失败(点击查看执行日志)`,reflectionFailedBadge:`⚠️ 反思失败`,prototypeLocalOpened:`已在本地浏览器打开,点击可在面板内查看`,prototypeView:`查看 UI 原型`,bookmarkMessage:`收藏消息`,unbookmarkMessage:`取消收藏`,forkSession:`从此处分叉会话(仅复制到此条消息)`,deleteMessageTitle:`删除消息`,resumeTaskTitle:`从上次中断处继续执行任务`,resumeTaskBtn:`继续执行`,clickToEnlarge:`点击查看大图`,fileExtracting:` 提取中...`,fileFailed:` 失败`,fileExtractFailed:`提取失败`,copyMessageTitle:`复制消息内容`,editAndResend:`编辑后重新发送`,thinking:`思考中...`,stopTask:`停止任务`,viewExecutionLog:`查看执行日志`,preparing:`准备中...`,emptyModelReply:`模型未返回任何内容。若你发送了图片,请确认所选模型支持视觉识别(图片识别需选择支持多模态视觉的模型),或更换模型后重试。`,stopping:`停止中...`,retrying:`连接异常,正在重试 ({attempt}/{max})...`,copyCode:`复制代码`,aborting:`正在终止...`,terminateCommandTitle:`终止命令执行`,terminateCommandPrompt:`请选择终止方式:`,terminateWaitTitle:`终止等待`,terminateWaitDesc:`仅停止等待命令输出,后台进程继续运行。<br/>适用于挂起型服务(如 npm run dev)。`,terminateCommandBtnTitle:`终止命令`,terminateCommandBtnDesc:`直接终止后台命令进程,释放资源。`,confirmDeleteMessage:`确认删除消息`,deleteMessageWarning:`删除后消息将从对话历史中移除,且无法恢复。`,confirmDelete:`确认删除`,quotedContextLabel:`💬 已引用: {text}`,selectedContextLabel:`📌 已选中: {text}`,subtaskDone:`完成`,subtaskFailed:`失败`,subtaskExecuting:`执行中...`,subtaskAllDone:`✓ 全部完成 · ✓{success} 成功 ✗{fail} 失败`,subtaskPartialFail:`✗ {success}/{total} 完成,{fail} 个节点失败`,unknownNode:`未知`,stopGeneration:`停止生成`,toolResultTitle:`执行结果`,reflectionInProgress:`质量评估中...`,cannotGetMessageContent:`无法获取消息内容`,editFailed:`编辑失败: {message}`,errTaskStopped:`任务已被用户停止`,errTaskReplaced:`任务已被新请求替代`,errSwRestarted:`后台服务异常重启,API 调用已中断`,errTimeout:`请求超时({seconds}秒)`,cancelBtn:`取消`}}),r(`en`,{chatMsg:{searchPrompt:`Search`,exportWord:`Export Word`,exportPdf:`Export PDF`,exportImage:`Export Image`,exportMarkdown:`Export Markdown`,executionLogTitle:`Execution Log`,revisedTag:`Revised`,roundsTag:` ({count} rounds)`,revisedSuffix:` (Revised)`,scoreBadgeTitle:`AI Quality Assessment: {score}/10{rounds}{revised}
|
|
1900
|
+
Click to view assessment details`,reflectionFailedTitle:`Reflection assessment failed (click to view execution log)`,reflectionFailedBadge:`⚠️ Reflection Failed`,prototypeLocalOpened:`Opened in local browser, click to view in panel`,prototypeView:`View UI Prototype`,bookmarkMessage:`Bookmark message`,unbookmarkMessage:`Remove bookmark`,forkSession:`Fork session from here (copy up to this message only)`,deleteMessageTitle:`Delete message`,resumeTaskTitle:`Resume task from last interruption`,resumeTaskBtn:`Resume`,clickToEnlarge:`Click to view full size`,fileExtracting:` extracting...`,fileFailed:` failed`,fileExtractFailed:`Extraction failed`,copyMessageTitle:`Copy message content`,editAndResend:`Edit and resend`,thinking:`Thinking...`,stopTask:`Stop task`,viewExecutionLog:`View execution log`,preparing:`Preparing...`,emptyModelReply:`The model returned no content. If you sent an image, make sure the selected model supports vision (image recognition requires a multimodal vision model), or switch model and retry.`,stopping:`Stopping...`,retrying:`Connection unstable, retrying ({attempt}/{max})...`,copyCode:`Copy code`,aborting:`Aborting...`,terminateCommandTitle:`Terminate Command Execution`,terminateCommandPrompt:`Please select a termination method:`,terminateWaitTitle:`Stop Waiting`,terminateWaitDesc:`Only stop waiting for command output; the background process continues running.<br/>Suitable for hanging services (e.g. npm run dev).`,terminateCommandBtnTitle:`Terminate Command`,terminateCommandBtnDesc:`Directly terminate the background command process and release resources.`,confirmDeleteMessage:`Confirm Delete Message`,deleteMessageWarning:`After deletion, the message will be removed from the conversation history and cannot be recovered.`,confirmDelete:`Confirm Delete`,quotedContextLabel:`💬 Quoted: {text}`,selectedContextLabel:`📌 Selected: {text}`,subtaskDone:`Done`,subtaskFailed:`Failed`,subtaskExecuting:`Executing...`,subtaskAllDone:`✓ All done · ✓{success} succeeded ✗{fail} failed`,subtaskPartialFail:`✗ {success}/{total} done, {fail} nodes failed`,unknownNode:`Unknown`,stopGeneration:`Stop generation`,toolResultTitle:`Execution Result`,reflectionInProgress:`Assessing quality...`,cannotGetMessageContent:`Cannot get message content`,editFailed:`Edit failed: {message}`,errTaskStopped:`Task stopped by user`,errTaskReplaced:`Task replaced by new request`,errSwRestarted:`Background service restarted unexpectedly, API call interrupted`,errTimeout:`Request timeout ({seconds}s)`,cancelBtn:`Cancel`}});var FD=`pendingCallApiSessions`;function ID(){chrome.storage.session.set({[FD]:[...H.pendingCallApiSessionIds]}).catch(()=>{})}async function LD(){try{let e=await chrome.storage.session.get([FD]);e[FD]&&Array.isArray(e[FD])&&(H.pendingCallApiSessionIds=new Set(e[FD]))}catch{}}function RD(e){if(Array.isArray(e))return e.filter(e=>e.type===`text`).map(e=>e.text).join(``);if(typeof e==`string`&&e.startsWith(`[`))try{let t=JSON.parse(e);if(Array.isArray(t))return t.filter(e=>e.type===`text`).map(e=>e.text).join(``)}catch{}return e}function zD(e){let t=RD(e);H.quotedContextText=t;let n=document.getElementById(`selectionIndicator`),r=document.getElementById(`selectionText`),a=document.getElementById(`userInput`);if(n&&r&&a){let e;e=t.length>100?t.substring(0,100)+`...`:t.length>50?t.substring(0,50)+`...`:t,r.textContent=i(`chat.quotedPrefix`,{text:e}),n.classList.add(`show`)}}function BD(){o.debug(`[SidePanel] clear selectedcontenttext `),H.selectedContextText=``,H.quotedContextText=``;let e=document.getElementById(`selectionIndicator`),t=document.getElementById(`userInput`);if(e&&(e.classList.remove(`show`),o.debug(`[SidePanel] hiddenselected contentprompt`)),typeof window.hideFloatingMenu==`function`&&window.hideFloatingMenu(),t&&t.value.startsWith(`[选中内容]`)){let e=t.value.split(`
|
|
1895
1901
|
`),n=e.findIndex(e=>e.startsWith(`[用户问题]`));t.value=n===-1?``:e.slice(n+1).join(`
|
|
1896
|
-
`).trim()}}var
|
|
1902
|
+
`).trim()}}var VD,HD=new Promise(e=>{VD=e});async function UD(){try{await WD()}finally{VD()}}async function WD(){let e=await kt();if(e.activeSessionId&&e.list.length>0){H.activeSessionId=e.activeSessionId,H.sessions=e.list;let t=e.list.find(t=>t.id===e.activeSessionId);if(t){if(H.messageHistory=t.messageHistory||[],H.activeCompaction=t.contextCompaction||null,H.currentModel=t.model||H.currentModel,H.useTools=t.useTools===void 0?H.useTools:t.useTools,H.temperature=t.temperature===void 0?H.temperature:t.temperature,H.topP=t.topP===void 0?H.topP:t.topP,H.activeAgentId=t.agentId||null,H.activeAgentId&&H.activeAgentId!=="default"){try{let{getAgent:e}=await fe(async()=>{let{getAgent:e}=await import(`./agent-store-DOyMdB_7.js`).then(e=>e.t);return{getAgent:e}},__vite__mapDeps([0,1,2,3])),t=await e(H.activeAgentId);t&&(H.activeAgentMcpExcludedServerIds=t.mcpExcludedServerIds??null,t.model&&(H.currentModel=t.model),t.temperature!==null&&t.temperature!==void 0&&(H.temperature=t.temperature,H.topP=t.topP!==null&&t.topP!==void 0?t.topP:1),document.dispatchEvent(new CustomEvent(`agent-model-changed`)))}catch{}H.activeAgentMcpExcludedServerIds=null}else{H.activeAgentMcpExcludedServerIds=null;try{let e=await chrome.storage.local.get([`modelName`,`temperature`,`topP`]);e.modelName&&(H.currentModel=e.modelName),e.temperature!==void 0&&(H.temperature=e.temperature),e.topP!==void 0&&(H.topP=e.topP)}catch{}document.dispatchEvent(new CustomEvent(`agent-model-changed`))}let e=`agentMcpClosedServers_${H.activeAgentId||`default`}`,n=await chrome.storage.local.get([e]);H.mcpClosedServers=n[e]||[]}let n=document.getElementById(`chatContainer`);n&&n.querySelectorAll(`.message, .user-context-bubble`).forEach(e=>e.remove()),H.messageHistory.forEach(e=>{let t=e.wasRevised;if(!t&&e.executionLog)try{t=(typeof e.executionLog==`string`?JSON.parse(e.executionLog):e.executionLog).some(e=>e.nodeType===`reflection`&&e.reflectionType===`post`&&e.action?.decision===`revised`)}catch{}if(e.role===`user`&&e.contextBubbles&&Array.isArray(e.contextBubbles)&&e.contextBubbles.forEach(e=>{let t=``;switch(e.type){case`skill`:t=i(`contextBubble.bubbleSkill`,{name:e.name,desc:e.description?`:`+e.description:``});break;case`mcp`:t=i(`contextBubble.bubbleMcp`,{name:e.serverName});break;case`page`:t=i(`contextBubble.bubblePage`,{title:e.title,url:e.url});break;case`file`:t=`${e.name} (${Uc(e.size||0)})`;break;case`knowledge`:{let t=Array.isArray(e.refs)?e.refs:[];t.length>0&&QD(t,e.failed===!0);break}}t&&e.type!==`file`&&iO(e.type,t,!1)}),e.htmlContent)gO(e.htmlContent,e.messageId,e.resumable);else{let n=(e.contextBubbles||[]).filter(e=>e.type===`file`).map(e=>({name:e.name,size:e.size||0,type:e.fileType||``}));sO(e.role,e.content,!1,e.executionLog||[],e.reflectionScore,t,null,e.messageId,n,e.resumable,e.timestamp??null)}}),uO(),fO();let r=document.querySelector(`.welcome-message`);r&&H.messageHistory.length>0&&r.remove(),Ni(),Ki(),jA(),e.activeSessionId===H.activeSessionId?na(e):na(),await JE();let a=`scrollPosition_`+(H.activeSessionId||`default`);chrome.storage.local.get([a],e=>{e[a]!==void 0&&setTimeout(()=>{let t=document.getElementById(`chatContainer`);t.scrollTop=e[a]},100)})}else{await jt();let e=await kt();e.activeSessionId&&(H.activeSessionId=e.activeSessionId,H.sessions=e.list),na(e)}}function GD(){try{At().catch(e=>{o.error(`[SidePanel] save currentsession failed:`,e)})}catch(e){o.error(`[SidePanel] save conversationhistory exception:`,e)}}async function KD(){try{await At()}catch(e){o.error(`[SidePanel] save conversationhistory exception:`,e)}}function qD(){H.messageHistory&&H.messageHistory.length>0&&It().then(()=>{H.messageHistory=[],H.activeCompaction=null;let e=document.getElementById(`chatContainer`);if(e){e.innerHTML=``;let t=document.createElement(`div`);t.className=`welcome-message`,t.innerHTML=`
|
|
1897
1903
|
<div class="icon-wrapper">
|
|
1898
1904
|
<div class="icon">💬</div>
|
|
1899
1905
|
</div>
|
|
1900
1906
|
<h2>${i(`chat.welcomeTitle`)}</h2>
|
|
1901
1907
|
<p>${i(`chat.welcomeSubtitle`)}</p>
|
|
1902
|
-
`,e.appendChild(t)}chrome.storage.local.remove(`scrollPosition_`+(H.activeSessionId||`default`)),na()})}function
|
|
1908
|
+
`,e.appendChild(t)}chrome.storage.local.remove(`scrollPosition_`+(H.activeSessionId||`default`)),na()})}function JD(){document.getElementById(`confirmModal`).classList.add(`show`)}function YD(){document.getElementById(`confirmModal`).classList.remove(`show`)}var XD=1500;async function ZD(e,t){if(!t||t.length===0)return null;let{ragEnabled:n}=await chrome.storage.local.get(`ragEnabled`);if(n!==!0)return o.debug(`[SidePanel] RAG global switch off, skip knowledge context`),null;let r=await new Promise(n=>{try{chrome.runtime.sendMessage({type:`RAG_SEARCH`,params:{query:e,collectionIds:t.map(e=>e.id).filter(Boolean),topK:5}},e=>{if(chrome.runtime.lastError){n(null);return}n(e&&e.success?e:null)})}catch{n(null)}}),a=!r,s=r&&r.results||[],c=new Map(t.filter(e=>e.id).map(e=>[e.id,e.name])),l=new Map;s.forEach(e=>{let t=e.collectionId||``,n=l.get(t);n||(n={id:t,name:c.get(t)||t||i(`contextBubble.labelKnowledge`),hitCount:0,items:[]},l.set(t,n)),n.items.push(e),n.hitCount++});let u=Array.from(l.values()),d=s.length,f=e=>e.map(e=>{let t=String(e.content||``).trim();return{score:typeof e.score==`number`?e.score:Number(e.score)||0,content:t.slice(0,XD),truncated:t.length>XD,fullLength:t.length}}),p=t.map(e=>({id:e.id,name:e.name,hitCount:e.id&&l.get(e.id)?.hitCount||0,hits:e.id?f(l.get(e.id)?.items||[]):[]}));u.forEach(e=>{p.some(t=>t.id&&t.id===e.id)||p.push({id:e.id,name:e.name,hitCount:e.hitCount,hits:f(e.items)})});let m=[`[知识库检索结果](引用: ${t.map(e=>e.name).join(`、`)})`];return a?m.push(`知识库检索失败:检索服务暂时不可用(这不代表知识库中没有相关内容)。`):d===0?m.push(`未找到与问题相关的内容。`):u.forEach(e=>{m.push(``),m.push(`【${e.name}】`),e.items.forEach(e=>{let t=typeof e.score==`number`?e.score.toFixed(3):String(e.score??``);m.push(`· 相关度 ${t}`),m.push(String(e.content||``).trim().slice(0,XD)),m.push(``)})}),m.push(`[/知识库检索结果]`),{text:m.join(`
|
|
1903
1909
|
`)+`
|
|
1904
1910
|
|
|
1905
|
-
`,refs:p,failed:a}}function
|
|
1911
|
+
`,refs:p,failed:a}}function QD(e,t=!1){if(!Array.isArray(e)||e.length===0)return;let n=e.reduce((e,t)=>e+(t.hitCount||0),0);if(t){iO(`knowledge`,i(`contextBubble.bubbleKnowledgeFailed`,{name:e.map(e=>e.name).join(`、`)}),!1);return}if(n===0){iO(`knowledge`,i(`contextBubble.bubbleKnowledgeMiss`,{name:e.map(e=>e.name).join(`、`)}),!1);return}e.forEach(e=>{(e.hitCount||0)>0?iO(`knowledge`,i(`contextBubble.bubbleKnowledge`,{name:e.name,count:e.hitCount}),!1,Array.isArray(e.hits)?e.hits:null):iO(`knowledge`,i(`contextBubble.bubbleKnowledgeMiss`,{name:e.name}),!1)})}function $D(e){let t=e||i(`chatResume.unknownError`),n=t.toLowerCase();return n.includes(`network`)||n.includes(`failed to fetch`)||n.includes(`load failed`)?i(`chat.networkError`):n.includes(`timeout`)||t.includes(`超时`)?i(`chat.timeoutError`,{message:t}):i(`chat.requestFailed`,{message:t})}async function eO(){await HD;let e=document.getElementById(`userInput`),t=document.getElementById(`chatContainer`),n=e.value.trim();if(!n||H.isGenerating)return;KE(H.activeSessionId),chrome.runtime.sendMessage({type:`DELETE_CHECKPOINT`,sessionId:H.activeSessionId});let r=t.querySelector(`.welcome-message`);r&&r.remove();let a=n,s=H.selectedContextText&&H.selectedContextText.trim(),c=H.quotedContextText&&H.quotedContextText.trim(),l=[];if(c){let e=H.quotedContextText.trim(),{compressed:t,wasCompressed:r}=y(e);a=`[引用内容${r?`摘要`:``}]\n${t}\n\n[用户问题]\n${n}`,iO(`quoted`,e,!1),l.push({type:`quoted`,text:e}),H.quotedContextText=``}else if(s){let e=H.selectedContextText.trim(),{compressed:t,wasCompressed:r}=y(e);a=`[选中内容${r?`摘要`:``}]\n${t}\n\n[用户问题]\n${n}`,iO(`selected`,e,!1),l.push({type:`selected`,text:e}),H.selectedContextText=``}let d=await fk();if(d){a=d+a;for(let e of H.selectedSkills)iO(`skill`,i(`contextBubble.bubbleSkill`,{name:e.name,desc:e.description?`:`+e.description:``}),!1),l.push({type:`skill`,name:e.name,description:e.description||``});ak()}let f=null,p=yk();if(p){let e=H.selectedMcpServices.map(e=>e.serverId).filter(Boolean);f=e.length>0?e:null,a=p+a;for(let e of H.selectedMcpServices)iO(`mcp`,i(`contextBubble.bubbleMcp`,{name:e.serverName}),!1),l.push({type:`mcp`,serverName:e.serverName,serverId:e.serverId||``});vk()}if(H.knowledgeRefs.length>0){let e=H.knowledgeRefs.slice();H.isGenerating=!0;let t=iO(`knowledge`,i(`contextBubble.bubbleKnowledgeSearching`),!0),r=null;try{r=await ZD(n,e)}catch(e){o.warn(`[SidePanel] knowledge search failed:`,e)}t&&t.parentNode&&t.remove(),r&&(a=r.text+a,QD(r.refs,r.failed===!0),l.push({type:`knowledge`,refs:r.refs,failed:r.failed||void 0})),pE()}H.selectedPage&&(a=`[网页上下文]\n标题: ${H.selectedPage.title}\nURL: ${H.selectedPage.url}\ntabId: ${H.selectedPage.id}\n`+a,iO(`page`,i(`contextBubble.bubblePage`,{title:H.selectedPage.title,url:H.selectedPage.url}),!1),l.push({type:`page`,title:H.selectedPage.title,url:H.selectedPage.url}),OE());let h=H.attachedFiles.slice();if(h.length>0){let e=tl();e&&(a+=e),h.forEach(e=>{e.status===`done`&&l.push({type:`file`,name:e.name,size:e.size,fileType:e.type})})}let{messageId:g,timestamp:_}=sO(`user`,vc(n),!0,[],null,!1,a,null,h);H.messageHistory.push({role:`user`,content:vc(a),messageId:g,timestamp:_,contextBubbles:l}),GD(),lt(n),H.inputHistoryIndex=-1,e.value=``,e.style.height=`auto`,(s||c)&&BD(),H.isGenerating=!0;let v=H.activeSessionId,b=pO(),x=H.enableImageInput&&H.attachedImages.length>0&&H.imageModelName||H.currentModel;if(H.attachedImages.length>0){let e=document.getElementById(`imagePreviewBar`);e&&(e.innerHTML=``,e.style.display=`none`)}H.attachedFiles.length>0&&$c();try{await Ze();let e=await cA(),t=lA(e),n=e?.skillIds??null;H.activeAgentToolIds=t,H.activeAgentSkillIds=n,H.activeAgentMcpExcludedServerIds=e?e.mcpExcludedServerIds??null:null,o.debug(`[SidePanel] sendmessagedebuginfo:`),o.debug(` - agent:`,e?e.name:`default assistant`),o.debug(` - agentToolIds:`,t),o.debug(` - isolateChat:`,H.isolateChat),o.debug(` - chatConfig:`,H.chatConfig),o.debug(` - messageHistory.length:`,H.messageHistory.length);let r=[{role:`system`,content:await Ke(e)}];if(H.isolateChat){let e=k(r[0]?.content||``),t=E(x,0,H.customModelMap)-e-4096-2e3,n=Math.floor(t*.7),i=H.messageHistory[H.messageHistory.length-1],a=at(H.messageHistory.slice(0,-1),{isolateChat:!0,maxMemoryMessages:H.chatConfig.maxMemoryMessages,compaction:H.activeCompaction,historyBudget:n,currentMessage:i});a.compactionApplied?r[0]={...r[0],content:ot(r[0].content,H.activeCompaction)}:H.activeCompaction&&o.warn(`[SidePanel] contextCompaction invalid (upToMessageId not found), ignored this send`),a.historySummaryText&&(r[0]={...r[0],content:r[0].content+`
|
|
1906
1912
|
|
|
1907
|
-
`+a.historySummaryText}),o.debug(`[SidePanel] history selection: keep ${a.keptHistory.length}/${H.messageHistory.length-1}, trimmed ${a.trimmedCount}, compactionApplied: ${a.compactionApplied}`),r=[...r,...a.messages];for(let e=0;e<r.length-1;e++)r[e]={...r[e],content:yc(r[e].content)}}else{let e=vc(a);r.push({role:`user`,content:e})}let s=await Ye();s._loadingId=b;let c=u(r),l=E(x,0,H.customModelMap),d=A(c,l);if(o.debug(`[SidePanel] send context: ${c} tokens (message: ${r.length} ), pressure: ${d.level}(${Math.round(d.ratio*100)}%)`),d.level===`critical`){o.warn(`[SidePanel] context pressure too high,maindynamictrimming...`);let e=k(r[0]?.content||``),t=await
|
|
1913
|
+
`+a.historySummaryText}),o.debug(`[SidePanel] history selection: keep ${a.keptHistory.length}/${H.messageHistory.length-1}, trimmed ${a.trimmedCount}, compactionApplied: ${a.compactionApplied}`),r=[...r,...a.messages];for(let e=0;e<r.length-1;e++)r[e]={...r[e],content:yc(r[e].content)}}else{let e=vc(a);r.push({role:`user`,content:e})}let s=await Ye();s._loadingId=b;let c=u(r),l=E(x,0,H.customModelMap),d=A(c,l);if(o.debug(`[SidePanel] send context: ${c} tokens (message: ${r.length} ), pressure: ${d.level}(${Math.round(d.ratio*100)}%)`),d.level===`critical`){o.warn(`[SidePanel] context pressure too high,maindynamictrimming...`);let e=k(r[0]?.content||``),t=await xO(f),n=(H.enabledTools.length+t)*200,i=l-e-n-4096-2e3,a=m(r,Math.max(i,2e3),{generateSummary:!1});r=a.messages,o.warn(`[SidePanel] proactively trimmed: ${c} → ${u(r)} tokens (${a.trimmedCount} )`)}let p,h,g,_=!1,y=!1,S=null,C=!0,w=null;try{let e=await SO(r,x,H.useTools,s,{forcedMcpServerIds:f});p=e.content,h=e.executionLog||[],g=e.reflectionScore,_=e.wasRevised||!1,y=e.wasStreamed||!1,S=e.streamingHtml||null,C=e.streamingConnected===void 0||e.streamingConnected,w=e.streamingMsgId||null}catch(e){if(H.activeSessionId!==v){let t=!!e.checkpoint||e.swRestarted||e.message===i(`chatMsg.errTaskStopped`);e.message===i(`chatMsg.errTaskStopped`)?Rt(v,{role:`assistant`,content:i(`chatResume.taskCancelled`),executionLog:e.executionLog||[],resumable:t}):e.swRestarted?Rt(v,{role:`assistant`,content:i(`chat.taskInterruptedSwRestart`),executionLog:e.executionLog||[],resumable:t}):Rt(v,{role:`assistant`,content:$D(e.message),executionLog:e.executionLog||[],resumable:t}),document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:v}})),mO(b),H.substituteLoadingIds.delete(v);return}if(e.message===i(`chatMsg.errTaskStopped`)){mO(b),H.substituteLoadingIds.delete(v);let{messageId:t}=sO(`assistant`,i(`chatResume.taskCancelled`),!1,e.executionLog||[],null,!1,null,null,[],!0);H.messageHistory.push({role:`assistant`,content:i(`chatResume.taskCancelled`),executionLog:e.executionLog||[],messageId:t,resumable:!0}),GD();return}if(e.swRestarted){mO(b),H.substituteLoadingIds.delete(v);let t=!!e.checkpoint,{messageId:n}=sO(`assistant`,i(`chat.taskInterruptedSwRestart`),!1,e.executionLog||[],null,!1,null,null,[],t);H.messageHistory.push({role:`assistant`,content:i(`chat.taskInterruptedSwRestart`),executionLog:e.executionLog||[],messageId:n,resumable:t}),GD(),ns(v,i(`chat.taskInterruptedSwRestart`));return}mO(b),H.substituteLoadingIds.delete(v),p=$D(e.message),h=e.executionLog||[];let{element:t,messageId:n}=sO(`assistant`,p,!0,h,g,!1,null,null,[],!0);H.messageHistory.push({role:`assistant`,content:p,executionLog:h,reflectionScore:g,messageId:n,resumable:!0}),ns(v,p);return}if(H.activeSessionId!==v){let e={role:`assistant`,content:p,executionLog:h,reflectionScore:g,wasRevised:_,messageId:w||`msg_`+Date.now().toString(36)+`_`+Math.random().toString(36).substring(2,8)};y&&S&&(e.htmlContent=S),Rt(v,e),document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:v}})),mO(b),H.substituteLoadingIds.delete(v);return}let T=null;if(!y||!S){if(mO(b),H.substituteLoadingIds.has(v)&&(mO(H.substituteLoadingIds.get(v)),H.substituteLoadingIds.delete(v)),y)H.substituteLoadingIds.has(v)&&(mO(H.substituteLoadingIds.get(v)),H.substituteLoadingIds.delete(v)),T=w;else{let{element:e,messageId:t}=sO(`assistant`,p,!0,h,g,_);T=t,await Ui(e),sD()}}else T=w;let D={role:`assistant`,content:p,executionLog:h,reflectionScore:g,wasRevised:_,messageId:T};if(y&&S&&(D.htmlContent=S,!C&&!document.querySelector(`[data-message-id="${T}"]`))){gO(S),uO(),fO();let e=document.getElementById(`chatContainer`);e&&(e.scrollTop=e.scrollHeight)}H.messageHistory.push(D),ts(v)}catch(e){o.error(`[SidePanel] sendMessage exception:`,e?.message||e)}finally{GD(),H.generatingSessionIds.delete(v),Dt(v),document.dispatchEvent(new CustomEvent(`generating-state-changed`)),e.focus(),H.attachedImages=[];let t=document.getElementById(`imagePreviewBar`);t&&(t.style.display=`none`)}}function tO(e,t){let n=document.getElementById(`userInput`);if(!t||H.isGenerating){o.debug(`[SidePanel] triggerSelectionSearch skip:`,{hasText:!!t,isGenerating:H.isGenerating});return}H.selectedContextText=t,H.quotedContextText=``,n.value=i(`chatMsg.searchPrompt`),n.dispatchEvent(new Event(`input`)),eO()}function nO(e){let t=document.getElementById(`userInput`);!t||!e||(t.value=e,t.dispatchEvent(new Event(`input`)),t.focus())}async function rO(e,t=``){await HD;let n=document.getElementById(`userInput`);!n||!e||H.isGenerating||(t&&(H.selectedContextText=t,H.quotedContextText=``),n.value=e,n.dispatchEvent(new Event(`input`)),n.focus(),eO())}function iO(e,t,n=!0,r=null){let a=document.getElementById(`chatContainer`),o=document.createElement(`div`);o.className=`user-context-bubble`,o.dataset.role=`context`;let s=e===`quoted`?`💬`:e===`skill`?`🧩`:e===`mcp`?`🔌`:e===`page`?`🌐`:e===`file`?`📎`:e===`knowledge`?`📚`:`📌`,c=i(e===`quoted`?`contextBubble.labelQuoted`:e===`skill`?`contextBubble.labelSkill`:e===`mcp`?`contextBubble.labelMcp`:e===`page`?`contextBubble.labelPage`:e===`file`?`contextBubble.labelFile`:e===`knowledge`?`contextBubble.labelKnowledge`:`contextBubble.labelSelection`),l=W(t);if(e===`knowledge`&&Array.isArray(r)&&r.length>0){let e=r.map(e=>{let t=typeof e.score==`number`?e.score.toFixed(3):``,n=t?`<span class="kb-bubble-hit-score">${t}</span>`:``,r=e.truncated?`<span class="kb-bubble-hit-truncated" title="${i(`contextBubble.kbHitTruncatedTitle`)}">${i(`contextBubble.kbHitTruncated`,{total:e.fullLength||0,kept:XD})}</span>`:``;return`<div class="kb-bubble-hit"><div class="kb-bubble-hit-text" title="${i(`contextBubble.kbHitToggle`)}">${n}${W(e.content||``)}</div>${r}</div>`}).join(``),n=r.filter(e=>e.truncated).length,a=n>0?`<span class="kb-bubble-truncated-badge">${i(`contextBubble.kbHitTruncatedBadge`,{count:n})}</span>`:``;l=`<div class="kb-bubble-summary">${W(t)}${a}</div>${e}`}o.innerHTML=`
|
|
1908
1914
|
<div class="context-bubble-inner">
|
|
1909
1915
|
<div class="context-bubble-header" title="${i(`contextBubble.clickToExpand`)}">
|
|
1910
1916
|
<span class="context-icon">${s}</span>
|
|
@@ -1912,7 +1918,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1912
1918
|
</div>
|
|
1913
1919
|
<div class="context-bubble-content">${l}</div>
|
|
1914
1920
|
</div>
|
|
1915
|
-
`;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 iO(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 aO(e){let t=e,n;do n=t,t=t.replace(/^\[(?:已选MCP服务|Selected MCP service):\s*[^\]]+\]\n(?:请使用「[^」]+」MCP服务来处理以下问题:|Please use the "[^"]+" MCP service to handle the following problem:)\s*\n/,``);while(t!==n);return t}function oO(e,t,n=!0,r=[],a=null,s=!1,c=null,l=null,u=[],d=!1,f=void 0){let p=document.getElementById(`chatContainer`),m=document.createElement(`div`);m.className=`message ${e}`;let h=f===void 0?new Date().toISOString():f||null;h&&(m.dataset.timestamp=h);let g=l||`msg_`+Date.now().toString(36)+`_`+Math.random().toString(36).substring(2,8);m.dataset.messageId=g;let _=Array.isArray(t)?t.filter(e=>e.type===`text`).map(e=>e.text).join(``):t,v=Array.isArray(t)&&t.some(e=>e.type===`image_url`);m.dataset.rawContent=Array.isArray(t)?JSON.stringify(t):t,m.dataset.textContent_=c||_;let y=_;if(m.dataset.executionLog=JSON.stringify(r),s&&(m.dataset.wasRevised=`true`),e===`assistant`){m.innerHTML=Pi(t);let e=document.createElement(`div`);e.className=`message-footer`;let n=document.createElement(`button`);n.className=`copy-btn`,n.title=i(`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>${i(`common.copy`)}</span>`].join(``),n.addEventListener(`click`,e=>{e.stopPropagation(),NE(m,n,e)}),e.appendChild(n);let c=document.createElement(`button`);c.className=`quote-btn`,c.title=i(`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>${i(`chat.quote`)}</span>`].join(``),c.addEventListener(`click`,e=>{e.stopPropagation(),VE(m)}),e.appendChild(c);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>${i(`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>${i(`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>${i(`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>${i(`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>${i(`chatMsg.exportMarkdown`)}</span>`,`</button>`].join(``);let p=f.querySelector(`.export-docx-item`);p.addEventListener(`click`,e=>{e.stopPropagation(),Ub(m,p,f)});let h=f.querySelector(`.export-md-item`);h.addEventListener(`click`,e=>{e.stopPropagation(),Gb(m,h,f)});let _=f.querySelector(`.export-pdf-item`);_.addEventListener(`click`,e=>{e.stopPropagation(),Wb(m,_,f)});let v=f.querySelector(`.export-image-item`);v.addEventListener(`click`,e=>{e.stopPropagation(),Kb(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=ze(r);if(x){let e=document.createElement(`span`);e.className=`token-usage-tag`,e.title=i(`chatStream.tokenUsageTitle`,{total:Le(x.totalTokens),prompt:Le(x.promptTokens),completion:Le(x.completionTokens)}),e.innerHTML=`<span class="token-tag-icon">⬤</span><span class="token-tag-value">${Le(x.totalTokens)}</span>`,e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Be(x,e)}),b.appendChild(e)}let S=r&&r.length>0,C=a!=null,w=r?r.filter(e=>e.nodeType===`reflection`&&e.reflectionType===`post`&&e.status===`success`).length:0;lO(),dO();let T=r?.find(e=>e.nodeType===`reflection`&&e.reflectionType===`post`),E=gT(r);if(PT(E),console.log(`[addMessage] executionLog entries:`,r?.length,`| agent_file entries:`,r?.filter(e=>e.nodeType===`tool_exec`&&e.action?.name===`agent_file`).length,`| artifacts:`,E.length),E.length>0){let e=document.createElement(`button`);e.className=`artifacts-btn`,e.type=`button`,e.title=i(`artifacts.btnTitle`,{count:E.length}),e.innerHTML=`
|
|
1921
|
+
`;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 aO(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 oO(e){let t=e,n;do n=t,t=t.replace(/^\[(?:已选MCP服务|Selected MCP service):\s*[^\]]+\]\n(?:请使用「[^」]+」MCP服务来处理以下问题:|Please use the "[^"]+" MCP service to handle the following problem:)\s*\n/,``);while(t!==n);return t}function sO(e,t,n=!0,r=[],a=null,s=!1,c=null,l=null,u=[],d=!1,f=void 0){let p=document.getElementById(`chatContainer`),m=document.createElement(`div`);m.className=`message ${e}`;let h=f===void 0?new Date().toISOString():f||null;h&&(m.dataset.timestamp=h);let g=l||`msg_`+Date.now().toString(36)+`_`+Math.random().toString(36).substring(2,8);m.dataset.messageId=g;let _=Array.isArray(t)?t.filter(e=>e.type===`text`).map(e=>e.text).join(``):t,v=Array.isArray(t)&&t.some(e=>e.type===`image_url`);m.dataset.rawContent=Array.isArray(t)?JSON.stringify(t):t,m.dataset.textContent_=c||_;let y=_;if(m.dataset.executionLog=JSON.stringify(r),s&&(m.dataset.wasRevised=`true`),e===`assistant`){m.innerHTML=Pi(t);let e=document.createElement(`div`);e.className=`message-footer`;let n=document.createElement(`button`);n.className=`copy-btn`,n.title=i(`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>${i(`common.copy`)}</span>`].join(``),n.addEventListener(`click`,e=>{e.stopPropagation(),PE(m,n,e)}),e.appendChild(n);let c=document.createElement(`button`);c.className=`quote-btn`,c.title=i(`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>${i(`chat.quote`)}</span>`].join(``),c.addEventListener(`click`,e=>{e.stopPropagation(),HE(m)}),e.appendChild(c);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>${i(`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>${i(`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>${i(`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>${i(`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>${i(`chatMsg.exportMarkdown`)}</span>`,`</button>`].join(``);let p=f.querySelector(`.export-docx-item`);p.addEventListener(`click`,e=>{e.stopPropagation(),Ub(m,p,f)});let h=f.querySelector(`.export-md-item`);h.addEventListener(`click`,e=>{e.stopPropagation(),Gb(m,h,f)});let _=f.querySelector(`.export-pdf-item`);_.addEventListener(`click`,e=>{e.stopPropagation(),Wb(m,_,f)});let v=f.querySelector(`.export-image-item`);v.addEventListener(`click`,e=>{e.stopPropagation(),Kb(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=ze(r);if(x){let e=document.createElement(`span`);e.className=`token-usage-tag`,e.title=i(`chatStream.tokenUsageTitle`,{total:Le(x.totalTokens),prompt:Le(x.promptTokens),completion:Le(x.completionTokens)}),e.innerHTML=`<span class="token-tag-icon">⬤</span><span class="token-tag-value">${Le(x.totalTokens)}</span>`,e.style.cursor=`pointer`,e.addEventListener(`click`,t=>{t.stopPropagation(),Be(x,e)}),b.appendChild(e)}let S=r&&r.length>0,C=a!=null,w=r?r.filter(e=>e.nodeType===`reflection`&&e.reflectionType===`post`&&e.status===`success`).length:0;uO(),fO();let T=r?.find(e=>e.nodeType===`reflection`&&e.reflectionType===`post`),E=_T(r);if(FT(E),console.log(`[addMessage] executionLog entries:`,r?.length,`| agent_file entries:`,r?.filter(e=>e.nodeType===`tool_exec`&&e.action?.name===`agent_file`).length,`| artifacts:`,E.length),E.length>0){let e=document.createElement(`button`);e.className=`artifacts-btn`,e.type=`button`,e.title=i(`artifacts.btnTitle`,{count:E.length}),e.innerHTML=`
|
|
1916
1922
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="14" height="14">
|
|
1917
1923
|
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
|
|
1918
1924
|
<polyline points="14 2 14 8 20 8"/>
|
|
@@ -1920,7 +1926,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1920
1926
|
<line x1="9" y1="15" x2="15" y2="15"/>
|
|
1921
1927
|
</svg>
|
|
1922
1928
|
<span class="artifacts-btn-count">${E.length}</span>
|
|
1923
|
-
`,e.addEventListener(`click`,t=>{t.stopPropagation(),
|
|
1929
|
+
`,e.addEventListener(`click`,t=>{t.stopPropagation(),IT(E,e)}),b.appendChild(e),PT(E,e)}if(S&&H.chatConfig.enableExecutionLog){let e=document.createElement(`button`);e.className=`execution-log-btn`,e.type=`button`,e.title=i(`chatMsg.executionLogTitle`),e.innerHTML=[`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<circle cx="12" cy="12" r="10"></circle>`,`<polyline points="12 6 12 12 16 14"></polyline>`,`</svg>`].join(``),b.appendChild(e)}if(C&&H.chatConfig.enableExecutionLog){let e=a>=8?`score-high`:a>=5?`score-mid`:`score-low`,t=a>=8?`✅`:a>=5?`🔍`:`⚠️`,n=s?` <span class="reflection-revised-tag">${i(`chatMsg.revisedTag`)}</span>`:``,r=w>1?i(`chatMsg.roundsTag`,{count:w}):``,o=document.createElement(`button`);o.className=`reflection-score-btn`,o.type=`button`,o.title=i(`chatMsg.scoreBadgeTitle`,{score:a,rounds:r,revised:s?i(`chatMsg.revisedSuffix`):``}),o.innerHTML=`<span class="reflection-badge ${e}">${t} ${a}/10${n}</span>`,o.dataset.reflectionData=JSON.stringify({overallScore:T?.overallScore??a,dimensions:T?.dimensions||null,issues:T?.issues||null,suggestions:T?.suggestions||null,decision:T?.action?.decision||null,useful:T?.useful??null,reasoning:T?.reasoning||null,suggestion:T?.suggestion||null,rounds:w,wasRevised:s}),b.appendChild(o)}else if(!C&&T&&T.status===`failed`&&H.chatConfig?.enableExecutionLog){let e=document.createElement(`button`);e.className=`reflection-score-btn`,e.type=`button`,e.title=i(`chatMsg.reflectionFailedTitle`),e.innerHTML=`<span class="reflection-badge score-low">${i(`chatMsg.reflectionFailedBadge`)}</span>`,b.appendChild(e)}let D=r?.slice().reverse().find(e=>e.nodeType===`tool_exec`&&e.action?.name===`preview_ui`||e.action?.name===`preview_preview_ui`&&e.status===`success`);if(D){let e=!1;if(D.observation)try{e=(typeof D.observation==`string`?JSON.parse(D.observation):D.observation)?.localOpened===!0}catch{}let t=document.createElement(`button`);t.className=`prototype-btn-small`,t.type=`button`,t.title=i(e?`chatMsg.prototypeLocalOpened`:`chatMsg.prototypeView`),t.innerHTML=Va,t.addEventListener(`click`,()=>{let e=D.prototypeId;if(!e&&D.observation)try{e=(typeof D.observation==`string`?JSON.parse(D.observation):D.observation)?.prototypeId}catch{}e?io(e):o.error(`[SidePanel] not found prototypeId,entry keys:`,Object.keys(D),`observation:`,D.observation)}),b.appendChild(t)}let O=document.createElement(`button`);O.className=`bookmark-btn`,O.title=i(`chatMsg.bookmarkMessage`),O.innerHTML=`
|
|
1924
1930
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1925
1931
|
<path d="M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"/>
|
|
1926
1932
|
</svg>
|
|
@@ -1934,17 +1940,17 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1934
1940
|
<polyline points="3 6 5 6 21 6"></polyline>
|
|
1935
1941
|
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
|
|
1936
1942
|
</svg>
|
|
1937
|
-
`,A.addEventListener(`click`,e=>{e.stopPropagation(),
|
|
1943
|
+
`,A.addEventListener(`click`,e=>{e.stopPropagation(),bO(m)}),b.appendChild(A),e.appendChild(b),d){let t=document.createElement(`button`);t.className=`resume-task-btn`,t.type=`button`,t.title=i(`chatMsg.resumeTaskTitle`),t.innerHTML=`
|
|
1938
1944
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1939
1945
|
<polygon points="5 3 19 12 5 21 5 3"></polygon>
|
|
1940
1946
|
</svg>
|
|
1941
1947
|
<span>${i(`chatMsg.resumeTaskBtn`)}</span>
|
|
1942
|
-
`,t.addEventListener(`click`,async e=>{if(e.stopPropagation(),t.disabled)return;let n=await
|
|
1948
|
+
`,t.addEventListener(`click`,async e=>{if(e.stopPropagation(),t.disabled)return;let n=await GE();n!==null&&(t.disabled=!0,t.style.opacity=`0.6`,t.style.cursor=`not-allowed`,YE(H.activeSessionId,n).finally(()=>{t.disabled=!1,t.style.opacity=``,t.style.cursor=``}))}),e.appendChild(t),m.dataset.resumable=`true`,qE(m,H.activeSessionId)}m.appendChild(e)}else{let e=y;e=e.replace(/^\[网页上下文\]\n标题: .+\nURL: .+\ntabId: \d+\n/,``),e=e.replace(/\[知识库检索结果\][^\n]*\n[\s\S]*?\[\/知识库检索结果\]\n\n?/,``),e=oO(e),e=aO(e);let n=e.match(/^\[引用内容(?:摘要)?\]\n([\s\S]+?)\n\n\[用户问题\]\n([\s\S]*)$/),r=e.match(/^\[选中内容(?:摘要)?\]\n([\s\S]+?)\n\n\[用户问题\]\n([\s\S]*)$/),a=n||r;if(a){let e=n?`quoted`:`selected`,t=a[1].trim(),r=a[2].trim();if(u&&u.length>0){let e=r.search(/\n\n\[(?:工作目录)?文件(?:内容)?:/);e!==-1&&(r=r.substring(0,e))}r=r.replace(/^\[网页上下文\]\n标题: .+\nURL: .+\ntabId: \d+\n/,``),r=oO(r),r=aO(r),r=r.replace(/\[工作目录文件: [^\]]+\]/g,``),m._pendingContext={type:e,contextText:t,userQuestion:r},m.textContent=r}else{let e=y;if(u&&u.length>0){let t=e.search(/\n\n\[(?:工作目录)?文件(?:内容)?:/);t!==-1&&(e=e.substring(0,t))}e=e.replace(/^\[网页上下文\]\n标题: .+\nURL: .+\ntabId: \d+\n/,``),e=e.replace(/\[知识库检索结果\][^\n]*\n[\s\S]*?\[\/知识库检索结果\]\n\n?/,``),e=oO(e),e=aO(e),e=e.replace(/\[工作目录文件: [^\]]+\]/g,``),m.textContent=e}if(v){let e=document.createElement(`div`);e.className=`user-message-images`,t.filter(e=>e.type===`image_url`).forEach((t,n)=>{let r=document.createElement(`img`),a=t.image_url.original_url||t.image_url.url;r.src=a,r.className=`user-message-image`,r.title=i(`chatMsg.clickToEnlarge`),r.addEventListener(`click`,()=>{cc(a,r)}),e.appendChild(r)}),m.appendChild(e)}if(u&&u.length>0){m.dataset.attachedFiles=JSON.stringify(u.map(e=>({name:e.name,size:e.size,type:e.type,text:e.text,status:e.status,agentPath:e.agentPath||``})));let e=document.createElement(`div`);e.className=`user-message-files`;let t=u.filter(e=>e.status===`done`),n=u.filter(e=>e.status!==`done`);[...t,...n].forEach(t=>{let n=document.createElement(`span`);n.className=`user-message-file-tag ${t.status}`,n.textContent=`${Hc(t.name)} ${t.name} (${Uc(t.size)})`,t.status===`extracting`?n.textContent+=i(`chatMsg.fileExtracting`):t.status===`error`&&(n.textContent+=i(`chatMsg.fileFailed`),n.title=t.error||i(`chatMsg.fileExtractFailed`)),e.appendChild(n)}),m.appendChild(e)}let o=document.createElement(`div`);o.className=`message-toolbar`;let s=document.createElement(`button`);s.className=`message-toolbar-btn copy-btn`,s.title=i(`chatMsg.copyMessageTitle`),s.innerHTML=[`<svg viewBox="0 0 16 16" fill="currentColor">`,`<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25zM5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25z"/>`,`</svg>`].join(``),s.addEventListener(`click`,e=>{e.stopPropagation(),NE(m,s)});let c=document.createElement(`button`);c.className=`message-toolbar-btn edit-btn`,c.title=i(`chatMsg.editAndResend`),c.innerHTML=[`<svg viewBox="0 0 16 16" fill="currentColor">`,`<path d="M12.146.146a.5.5 0 0 1 .708 0l2.5 2.5a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168l10-10zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207 11.207 2.5zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293l6.5-6.5zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12h.5a.5.5 0 0 1 .5.5v.5a.5.5 0 0 1-.5.5h-.5a.5.5 0 0 1-.468-.325z"/>`,`</svg>`].join(``),c.addEventListener(`click`,e=>{e.stopPropagation(),CO(m)}),o.appendChild(s),o.appendChild(c);let l=document.createElement(`button`);if(l.className=`message-toolbar-btn delete-btn`,l.title=i(`chatMsg.deleteMessageTitle`),l.innerHTML=`
|
|
1943
1949
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1944
1950
|
<polyline points="3 6 5 6 21 6"></polyline>
|
|
1945
1951
|
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
|
|
1946
1952
|
</svg>
|
|
1947
|
-
`,l.addEventListener(`click`,e=>{e.stopPropagation(),
|
|
1953
|
+
`,l.addEventListener(`click`,e=>{e.stopPropagation(),bO(m)}),o.appendChild(l),m.appendChild(o),h){m.classList.add(`has-time`);let e=document.createElement(`time`);e.className=`message-time`,e.dateTime=h,e.textContent=Fe(h),e.title=Ie(h),m.appendChild(e)}}if(p.appendChild(m),m._pendingContext){let{type:e,contextText:t}=m._pendingContext,n=iO(e,t,!1);p.insertBefore(n,m),delete m._pendingContext}return n&&iD(p,{smooth:!0}),e===`assistant`&&Ki(),{element:m,messageId:g,timestamp:h}}function cO(e){let t=document.getElementById(`chatContainer`);t&&t.classList.toggle(`timestamps-hidden`,e===!1)}var lO=!1;function uO(){if(lO)return;let e=document.getElementById(`chatContainer`);e&&(e.addEventListener(`click`,e=>{let t=e.target.closest(`.execution-log-btn`);if(!t)return;let n=t.closest(`.message`);if(!n)return;e.preventDefault(),e.stopPropagation();let r=n.dataset.executionLog;if(r)try{let e=JSON.parse(r);o.debug(`[chat-manager] exec log buttonclick(delegate), entries:`,e.length),WE(e)}catch(e){o.error(`[chat-manager] parse executionLog failed:`,e)}}),lO=!0)}var dO=!1;function fO(){if(dO)return;let e=document.getElementById(`chatContainer`);e&&(e.addEventListener(`click`,e=>{let t=e.target.closest(`.reflection-score-btn`);if(!t)return;e.preventDefault(),e.stopPropagation();let n=t.dataset.reflectionData;if(n)try{UE(JSON.parse(n),t)}catch(e){o.error(`[chat-manager] parse reflectionData failed:`,e)}}),dO=!0)}function pO(){let e=document.getElementById(`chatContainer`),t=`loading-`+Date.now(),n=document.createElement(`div`);n.className=`loading-message`,n.id=t,n.innerHTML=`
|
|
1948
1954
|
<div class="loading-content">
|
|
1949
1955
|
<div class="loading-dots">
|
|
1950
1956
|
<span></span>
|
|
@@ -1968,7 +1974,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1968
1974
|
<span class="current-node-name">${i(`chatMsg.preparing`)}</span>
|
|
1969
1975
|
</div>
|
|
1970
1976
|
</div>
|
|
1971
|
-
`,e.appendChild(n),requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight});let r=n.querySelector(`.stop-task-btn`),a=n.querySelector(`.loading-text`);r&&r.addEventListener(`click`,e=>{e.stopPropagation(),r.disabled=!0,r.style.opacity=`0.6`,r.style.cursor=`not-allowed`,a&&(a.textContent=i(`chatMsg.stopping`)),chrome.runtime.sendMessage({type:`CANCEL_REACT`,tabId:null,sessionId:H.activeSessionId}),H.pendingCancelApi&&H.pendingCancelApi({message:i(`chatMsg.errTaskStopped`),executionLog:H.currentExecutionStatus?.executionLog||[]})});let s=H.activeSessionId;if(H.executionLogListener=(e,n,r)=>e.sessionId&&e.sessionId!==s?!1:e.type===`EXECUTION_STATUS_UPDATE`&&(o.debug(`[SidePanel] recei to execution statusupdate:`,e.nodeName,e.status,`log count:`,e.executionLog?.length),ws(t,e.nodeName,e.status,e.executionLog),!1),chrome.runtime.onMessage.addListener(H.executionLogListener),H.chatConfig.enableExecutionLog){let e=n.querySelector(`.execution-status-container`);e&&(e.style.display=`flex`)}let c=n.querySelector(`.execution-log-toggle-btn`);return c&&c.addEventListener(`click`,e=>{e.stopPropagation(),Cs(t)}),t}function
|
|
1977
|
+
`,e.appendChild(n),requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight});let r=n.querySelector(`.stop-task-btn`),a=n.querySelector(`.loading-text`);r&&r.addEventListener(`click`,e=>{e.stopPropagation(),r.disabled=!0,r.style.opacity=`0.6`,r.style.cursor=`not-allowed`,a&&(a.textContent=i(`chatMsg.stopping`)),chrome.runtime.sendMessage({type:`CANCEL_REACT`,tabId:null,sessionId:H.activeSessionId}),H.pendingCancelApi&&H.pendingCancelApi({message:i(`chatMsg.errTaskStopped`),executionLog:H.currentExecutionStatus?.executionLog||[]})});let s=H.activeSessionId;if(H.executionLogListener=(e,n,r)=>e.sessionId&&e.sessionId!==s?!1:e.type===`EXECUTION_STATUS_UPDATE`&&(o.debug(`[SidePanel] recei to execution statusupdate:`,e.nodeName,e.status,`log count:`,e.executionLog?.length),ws(t,e.nodeName,e.status,e.executionLog),!1),chrome.runtime.onMessage.addListener(H.executionLogListener),H.chatConfig.enableExecutionLog){let e=n.querySelector(`.execution-status-container`);e&&(e.style.display=`flex`)}let c=n.querySelector(`.execution-log-toggle-btn`);return c&&c.addEventListener(`click`,e=>{e.stopPropagation(),Cs(t)}),t}function mO(e){let t=document.getElementById(e);if(t){let e=t.querySelector(`.loading-text`);e&&(e.textContent=i(`chatMsg.thinking`)),t.remove()}H.executionLogListener&&(chrome.runtime.onMessage.removeListener(H.executionLogListener),H.executionLogListener=null),H.currentExecutionStatus=null;let n=document.querySelector(`.execution-log-panel.realtime-mode`);n&&n.remove()}function hO(e){if(!e)return;let t=_T((()=>{try{let t=e.dataset.executionLog;return t?JSON.parse(t):[]}catch{return[]}})());if(FT(t),t.length===0)return;let n=e.querySelector(`.artifacts-btn`);if(!n){let r=e.querySelector(`.footer-right-actions`);if(!r)return;n=document.createElement(`button`),n.className=`artifacts-btn`,n.type=`button`,n.title=i(`artifacts.btnTitle`,{count:t.length}),n.innerHTML=`
|
|
1972
1978
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="14" height="14">
|
|
1973
1979
|
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
|
|
1974
1980
|
<polyline points="14 2 14 8 20 8"/>
|
|
@@ -1976,20 +1982,20 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
1976
1982
|
<line x1="9" y1="15" x2="15" y2="15"/>
|
|
1977
1983
|
</svg>
|
|
1978
1984
|
<span class="artifacts-btn-count">${t.length}</span>
|
|
1979
|
-
`;let a=r.querySelector(`.execution-log-btn`);a?r.insertBefore(n,a):r.prepend(n)}n._artifactsBound||(n.addEventListener(`click`,e=>{e.stopPropagation(),
|
|
1985
|
+
`;let a=r.querySelector(`.execution-log-btn`);a?r.insertBefore(n,a):r.prepend(n)}n._artifactsBound||(n.addEventListener(`click`,e=>{e.stopPropagation(),IT(t,n)}),n._artifactsBound=!0,PT(t,n))}function gO(e,t=null,n=!1){let r=document.getElementById(`chatContainer`);if(!r||!e)return;let a=document.createElement(`div`);a.innerHTML=e;let s=a.firstElementChild;if(!s)return;if(t&&(s.dataset.messageId=t),n){s.dataset.resumable=`true`;let e=s.querySelector(`:scope > .message-footer`);if(e&&!e.querySelector(`.resume-task-btn`)){let t=document.createElement(`button`);t.className=`resume-task-btn`,t.type=`button`,t.title=i(`chatMsg.resumeTaskTitle`),t.innerHTML=`
|
|
1980
1986
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1981
1987
|
<polygon points="5 3 19 12 5 21 5 3"></polygon>
|
|
1982
1988
|
</svg>
|
|
1983
1989
|
<span>${i(`chatMsg.resumeTaskBtn`)}</span>
|
|
1984
|
-
`,t.addEventListener(`click`,async e=>{if(e.stopPropagation(),t.disabled)return;let n=await
|
|
1990
|
+
`,t.addEventListener(`click`,async e=>{if(e.stopPropagation(),t.disabled)return;let n=await GE();n!==null&&(t.disabled=!0,t.style.opacity=`0.6`,t.style.cursor=`not-allowed`,YE(H.activeSessionId,n).finally(()=>{t.disabled=!1,t.style.opacity=``,t.style.cursor=``}))}),e.appendChild(t),qE(s,H.activeSessionId)}}s.classList.remove(`streaming`);let c=s.querySelector(`.thinking-process-header`);c&&lD(c),s.querySelectorAll(`.tool-call-header`).forEach(e=>{e.addEventListener(`click`,t=>{t.ctrlKey||t.metaKey||e.closest(`.tool-call-item`).classList.toggle(`expanded`)})}),s.querySelectorAll(`.tool-call-result`).forEach(e=>{let t=e.querySelector(`code`);if(!t)return;let n=t.dataset.fullContent;if(!n||n.length<=500)return;let r=t.textContent||``,i=!1;e.style.cursor=`pointer`,e.addEventListener(`click`,e=>{e.ctrlKey||e.metaKey||(e.stopPropagation(),i=!i,t.textContent=i?n:r)})}),s.querySelectorAll(`.tool-call-body > pre, .tool-result-content > pre, .agent-stream-output > pre`).forEach(e=>{if(e.parentElement.classList.contains(`code-block-container`))return;let t=document.createElement(`div`);t.className=`code-block-container`,t.style.position=`relative`,t.innerHTML=`<button class="code-copy-btn" title="${i(`chatMsg.copyCode`)}">
|
|
1985
1991
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
1986
1992
|
<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"/>
|
|
1987
1993
|
</svg>
|
|
1988
|
-
</button>`,e.parentElement.insertBefore(t,e),t.appendChild(e)}),s.querySelectorAll(`.subtask-progress`).forEach(e=>{e.addEventListener(`click`,t=>{t.target.closest(`.subtask-header`)&&e.classList.toggle(`subtask-expanded`)})}),s.querySelectorAll(`.tool-call-terminate-btn, .agent-stream-terminate-btn`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation(),
|
|
1994
|
+
</button>`,e.parentElement.insertBefore(t,e),t.appendChild(e)}),s.querySelectorAll(`.subtask-progress`).forEach(e=>{e.addEventListener(`click`,t=>{t.target.closest(`.subtask-header`)&&e.classList.toggle(`subtask-expanded`)})}),s.querySelectorAll(`.tool-call-terminate-btn, .agent-stream-terminate-btn`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation(),vO(H.activeSessionId)})}),s.querySelectorAll(`.tool-call-abort-btn`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),chrome.runtime.sendMessage({type:`ABORT_CURRENT_TOOL`,sessionId:H.activeSessionId}),e.disabled=!0,e.title=i(`chatMsg.aborting`)})});let l=s.querySelector(`.message-footer`);if(l){let e=l.querySelector(`.copy-btn`);e&&e.addEventListener(`click`,t=>{t.stopPropagation(),PE(s,e,t)});let t=l.querySelector(`.quote-btn`);t&&t.addEventListener(`click`,e=>{e.stopPropagation(),HE(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`,e=>{e.stopPropagation(),Ub(s,e.currentTarget,r)}),r.querySelector(`.export-md-item`)?.addEventListener(`click`,e=>{e.stopPropagation(),Gb(s,e.currentTarget,r)}),r.querySelector(`.export-pdf-item`)?.addEventListener(`click`,e=>{e.stopPropagation(),Wb(s,e.currentTarget,r)}),r.querySelector(`.export-image-item`)?.addEventListener(`click`,e=>{e.stopPropagation(),Kb(s,e.currentTarget,r)}));let i=l.querySelector(`.prototype-btn-small`);if(i){let e=(()=>{try{let e=s.dataset.executionLog;return e?JSON.parse(e):[]}catch{return[]}})().find(e=>e.nodeType===`tool_exec`&&e.action?.name===`preview_ui`||e.action?.name===`preview_preview_ui`&&e.status===`success`);e&&i.addEventListener(`click`,()=>{let t=e.prototypeId;if(!t&&e.observation)try{t=(typeof e.observation==`string`?JSON.parse(e.observation):e.observation)?.prototypeId}catch{}t?io(t):o.error(`[SidePanel] not found prototypeId,entry keys:`,Object.keys(e),`observation:`,e.observation)})}let a=l.querySelector(`.bookmark-btn`);a&&(_l(a,H.activeSessionId,s.dataset.messageId),a.addEventListener(`click`,async e=>{e.stopPropagation();let t=H.activeSessionId,n=s.dataset.messageId;if(a.classList.contains(`bookmarked`)){await al(t,n),_l(a,t,n);let{refreshBookmarkPanel:e}=await fe(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>ll);return{refreshBookmarkPanel:e}},void 0);e()}else{await il(t,n,s.dataset.textContent_||``,H.sessions.find(e=>e.id===t)?.title||``),_l(a,t,n);let{refreshBookmarkPanel:e}=await fe(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>ll);return{refreshBookmarkPanel:e}},void 0);e()}}));let c=l.querySelector(`.delete-btn`);c&&c.addEventListener(`click`,e=>{e.stopPropagation(),bO(s)});let u=l.querySelector(`.fork-btn`);u&&u.addEventListener(`click`,async e=>{e.stopPropagation();let t=s.dataset.messageId;t&&await ja(H.activeSessionId,t)});let d=l.querySelector(`.resume-task-btn`);d&&d.addEventListener(`click`,async e=>{if(e.stopPropagation(),d.disabled)return;let t=await GE();t!==null&&(d.disabled=!0,d.style.opacity=`0.6`,d.style.cursor=`not-allowed`,YE(H.activeSessionId,t).finally(()=>{d.disabled=!1,d.style.opacity=``,d.style.cursor=``}))}),hO(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=ze(e?JSON.parse(e):[]);t&&Be(t,f)}catch{}}))}let u=s.querySelector(`.message-toolbar`);if(u){let e=u.querySelector(`.edit-btn`);e&&e.addEventListener(`click`,e=>{e.stopPropagation(),CO(s)});let t=u.querySelector(`.copy-btn`);t&&t.addEventListener(`click`,e=>{e.stopPropagation(),NE(s,t)});let n=u.querySelector(`.delete-btn`);n&&n.addEventListener(`click`,e=>{e.stopPropagation(),bO(s)})}s.querySelectorAll(`.user-message-image`).forEach(e=>{e.addEventListener(`click`,()=>{cc(e.src,e)})}),s.querySelectorAll(`.code-copy-btn, .copy-md-btn, .download-excel-btn, .export-table-img-btn`).forEach(e=>{delete e.dataset.bound,delete e.dataset.boundMd,delete e.dataset.boundExcel,delete e.dataset.boundImg}),r.appendChild(s),jA()}function _O(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="${i(`chatMsg.copyCode`)}">
|
|
1989
1995
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
1990
1996
|
<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"/>
|
|
1991
1997
|
</svg>
|
|
1992
|
-
</button>`,e.parentElement.insertBefore(t,e),t.appendChild(e)}),e.querySelectorAll(`.thinking-process-header`).forEach(e=>{
|
|
1998
|
+
</button>`,e.parentElement.insertBefore(t,e),t.appendChild(e)}),e.querySelectorAll(`.thinking-process-header`).forEach(e=>{lD(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=>{e.addEventListener(`click`,t=>{t.target.closest(`.subtask-header`)&&e.classList.toggle(`subtask-expanded`)})}),e.querySelectorAll(`.tool-call-terminate-btn, .agent-stream-terminate-btn`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation(),vO(H.activeSessionId)})}),e.querySelectorAll(`.tool-call-abort-btn`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),chrome.runtime.sendMessage({type:`ABORT_CURRENT_TOOL`,sessionId:H.activeSessionId}),e.disabled=!0,e.title=i(`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(),PE(t,n,e)});let r=e.querySelector(`.quote-btn`);r&&r.addEventListener(`click`,e=>{e.stopPropagation(),HE(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`,e=>{e.stopPropagation(),Ub(t,e.currentTarget,a)}),a.querySelector(`.export-md-item`)?.addEventListener(`click`,e=>{e.stopPropagation(),Gb(t,e.currentTarget,a)}),a.querySelector(`.export-pdf-item`)?.addEventListener(`click`,e=>{e.stopPropagation(),Wb(t,e.currentTarget,a)}),a.querySelector(`.export-image-item`)?.addEventListener(`click`,e=>{e.stopPropagation(),Kb(t,e.currentTarget,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&&io(t)})}let s=e.querySelector(`.bookmark-btn`);s&&(_l(s,H.activeSessionId,t.dataset.messageId),s.addEventListener(`click`,async e=>{e.stopPropagation();let n=H.activeSessionId,r=t.dataset.messageId;if(s.classList.contains(`bookmarked`)){await al(n,r),_l(s,n,r);let{refreshBookmarkPanel:e}=await fe(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>ll);return{refreshBookmarkPanel:e}},void 0);e()}else{await il(n,r,t.dataset.textContent_||``,H.sessions.find(e=>e.id===n)?.title||``),_l(s,n,r);let{refreshBookmarkPanel:e}=await fe(async()=>{let{refreshBookmarkPanel:e}=await Promise.resolve().then(()=>ll);return{refreshBookmarkPanel:e}},void 0);e()}}));let c=e.querySelector(`.delete-btn`);c&&c.addEventListener(`click`,e=>{e.stopPropagation(),bO(t)});let l=e.querySelector(`.fork-btn`);l&&l.addEventListener(`click`,async e=>{e.stopPropagation();let n=t.dataset.messageId;n&&await ja(H.activeSessionId,n)});let u=e.querySelector(`.resume-task-btn`);u&&u.addEventListener(`click`,async e=>{if(e.stopPropagation(),u.disabled)return;let t=await GE();t!==null&&(u.disabled=!0,u.style.opacity=`0.6`,u.style.cursor=`not-allowed`,YE(H.activeSessionId,t).finally(()=>{u.disabled=!1,u.style.opacity=``,u.style.cursor=``}))}),hO(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=ze(e?JSON.parse(e):[]);n&&Be(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(),CO(t)});let r=e.querySelector(`.copy-btn`);r&&r.addEventListener(`click`,e=>{e.stopPropagation(),NE(t,r)});let i=e.querySelector(`.delete-btn`);i&&i.addEventListener(`click`,e=>{e.stopPropagation(),bO(t)})}),e.querySelectorAll(`.user-message-image`).forEach(e=>{e.addEventListener(`click`,()=>{cc(e.src,e)})}),e.querySelectorAll(`.mermaid-controls`).forEach(e=>e.remove()),e.querySelectorAll(`.code-copy-btn, .copy-md-btn, .download-excel-btn, .export-table-img-btn`).forEach(e=>{delete e.dataset.bound,delete e.dataset.boundMd,delete e.dataset.boundExcel,delete e.dataset.boundImg}),Ji(),uO(),fO(),jA()}function vO(e){return new Promise(t=>{let n=document.querySelector(`.command-terminate-overlay`);n&&n.remove();let r=document.createElement(`div`);r.className=`command-terminate-overlay`,r.innerHTML=`
|
|
1993
1999
|
<div class="command-terminate-modal">
|
|
1994
2000
|
<div class="command-terminate-header">
|
|
1995
2001
|
<div class="command-terminate-icon">⏹</div>
|
|
@@ -2018,7 +2024,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
2018
2024
|
<button class="command-terminate-cancel">${i(`common.cancel`)}</button>
|
|
2019
2025
|
</div>
|
|
2020
2026
|
</div>
|
|
2021
|
-
`,document.body.appendChild(r);let a=()=>{r.remove()};r.querySelector(`.command-terminate-cancel`).addEventListener(`click`,()=>{a(),t(null)}),r.querySelector(`.wait-btn`).addEventListener(`click`,()=>{a(),chrome.runtime.sendMessage({type:`TERMINATE_COMMAND`,sessionId:e,mode:`wait`}),t(`wait`)}),r.querySelector(`.kill-btn`).addEventListener(`click`,()=>{a(),chrome.runtime.sendMessage({type:`TERMINATE_COMMAND`,sessionId:e,mode:`kill`}),t(`kill`)})})}function
|
|
2027
|
+
`,document.body.appendChild(r);let a=()=>{r.remove()};r.querySelector(`.command-terminate-cancel`).addEventListener(`click`,()=>{a(),t(null)}),r.querySelector(`.wait-btn`).addEventListener(`click`,()=>{a(),chrome.runtime.sendMessage({type:`TERMINATE_COMMAND`,sessionId:e,mode:`wait`}),t(`wait`)}),r.querySelector(`.kill-btn`).addEventListener(`click`,()=>{a(),chrome.runtime.sendMessage({type:`TERMINATE_COMMAND`,sessionId:e,mode:`kill`}),t(`kill`)})})}function yO(e){return new Promise(t=>{let n=document.querySelector(`.delete-confirm-overlay`);n&&n.remove();let r=document.createElement(`div`);r.className=`delete-confirm-overlay`;let a=e.length>50?e.substring(0,50)+`...`:e;r.innerHTML=`
|
|
2022
2028
|
<div class="delete-confirm-modal">
|
|
2023
2029
|
<div class="delete-confirm-header">
|
|
2024
2030
|
<div class="delete-confirm-icon">🗑️</div>
|
|
@@ -2033,7 +2039,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
2033
2039
|
<button class="delete-confirm-confirm">${i(`chatMsg.confirmDelete`)}</button>
|
|
2034
2040
|
</div>
|
|
2035
2041
|
</div>
|
|
2036
|
-
`,document.body.appendChild(r);let o=r.querySelector(`.delete-confirm-cancel`),s=r.querySelector(`.delete-confirm-confirm`);o.addEventListener(`click`,()=>{r.remove(),t(!1)}),s.addEventListener(`click`,()=>{r.remove(),t(!0)}),r.addEventListener(`click`,e=>{e.target})})}async function
|
|
2042
|
+
`,document.body.appendChild(r);let o=r.querySelector(`.delete-confirm-cancel`),s=r.querySelector(`.delete-confirm-confirm`);o.addEventListener(`click`,()=>{r.remove(),t(!1)}),s.addEventListener(`click`,()=>{r.remove(),t(!0)}),r.addEventListener(`click`,e=>{e.target})})}async function bO(e,t=!1){let n=e.dataset.messageId,r=e.classList.contains(`user`)?`user`:`assistant`,a=``;if(a=r===`user`?e.textContent.trim():e.dataset.textContent_||``,!t&&!await yO(a))return;if(n){let e=H.messageHistory.findIndex(e=>e.messageId===n);e!==-1&&H.messageHistory.splice(e,1)}else{let t=e.dataset.timestamp,n=H.messageHistory.findIndex(e=>e.timestamp===t);n!==-1&&H.messageHistory.splice(n,1)}let s=e.previousElementSibling;s&&s.classList.contains(`user-context-bubble`)&&s.remove(),e.remove();let c=document.getElementById(`chatContainer`);c.querySelectorAll(`.message`).length===0&&(c.innerHTML=`
|
|
2037
2043
|
<div class="welcome-message">
|
|
2038
2044
|
<div class="icon-wrapper">
|
|
2039
2045
|
<div class="icon">💬</div>
|
|
@@ -2041,7 +2047,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
2041
2047
|
<h2>${i(`chat.welcomeTitle`)}</h2>
|
|
2042
2048
|
<p>${i(`chat.welcomeSubtitle`)}</p>
|
|
2043
2049
|
</div>
|
|
2044
|
-
`),await
|
|
2050
|
+
`),await KD(),n&&H.activeSessionId&&F(H.activeSessionId,n).then(e=>{e||o.warn(`[SidePanel] IndexedDB messagecleanup failed, messageId:`,n)}).catch(e=>{o.error(`[SidePanel] IndexedDB messagecleanup exception:`,e)}),o.debug(`[SidePanel] deletedmessage: ${r}, messageId: ${n}`)}async function xO(e=null){try{let{mcpTools:t}=await chrome.storage.local.get([`mcpTools`]),n=t||[],r=new Set(Array.isArray(H.mcpClosedServers)?H.mcpClosedServers:[]),i=new Set(Array.isArray(H.activeAgentMcpExcludedServerIds)?H.activeAgentMcpExcludedServerIds:[]),a=new Set(Array.isArray(e)?e:[]);return n.filter(e=>{let t=e.serverId||`unknown`;return a.has(t)?!0:!r.has(t)&&!i.has(t)}).length}catch{return 0}}async function SO(e,t,n=!1,r={},a={}){let{resumeFromCheckpoint:s=!1,userGuidance:c=``,loadingId:l=null,forcedMcpServerIds:u=null}=a,d=(await $e()).loopTimeout,f=await new Promise(e=>{chrome.storage.local.get(`reflectionConfig`,t=>{e(t.reflectionConfig||{enabled:!1})})}),p=H.activeSessionId,m=s?`resume_${Date.now()}_${Math.random().toString(36).substring(2,8)}`:`call_${Date.now()}_${Math.random().toString(36).substring(2,8)}`;if(o.debug(`[SidePanel] callApi: generating callId: ${m}${s?` (restoremode)`:``}`),s&&l&&(r={...r,_loadingId:l}),H.pendingCancelApiMap&&H.pendingCancelApiMap.has(p)){o.debug(`[SidePanel] callApi: detectedsession has ongoing API call with , first cancelold`);let e=H.pendingCancelApiMap.get(p);e&&e({message:i(`chatMsg.errTaskReplaced`),executionLog:[]})}H.pendingCallApiSessionIds&&H.pendingCallApiSessionIds.has(p)&&(H.pendingCallApiSessionIds.delete(p),ID());let h=_D(p),g=chrome.runtime.connect({name:`keepalive-`+p});o.debug(`[SidePanel] keepalive portconnected, sessionId:`,p),Ao(p);try{let e=ko();g.postMessage({type:`KEEPALIVE_IDENTITY`,identity:e==null?null:{windowId:e}})}catch{}let _={restarted:!1,rejectFn:null,cleanup:null,checkpoint:null};g.onMessage.addListener(e=>{if(e.type===`HOST_TAB_RESOLVED`&&e.sessionId===p){jo(p,e.hostTabId);return}e.type===`SW_RESTARTED`&&e.sessionId===p&&(o.warn(`[SidePanel] ⚠️ recei to SW_RESTARTED notification,background re started,API call lost`),_.restarted=!0,_.checkpoint=e.checkpoint||null,_.rejectFn&&_.cleanup&&(_.cleanup(),_.rejectFn({message:i(`chatMsg.errSwRestarted`),executionLog:[],checkpoint:_.checkpoint,swRestarted:!0}))),e.type===`SHOW_CLARIFY_DIALOG`?On(e.data):e.type===`CLARIFY_TIMEOUT`?Nn(e):e.type===`SHOW_CONFIRM_DIALOG`&&zn(e.data)});let v={timeoutId:null,removeListener:()=>{}},y=()=>{try{g.disconnect()}catch{}v.timeoutId&&=(clearTimeout(v.timeoutId),null),v.removeListener(),H.pendingCancelApiMap.delete(p),H.pendingCallApiSessionIds.delete(p),vD(p),ID()};return new Promise((a,l)=>{if(_.cleanup=y,_.rejectFn=l,_.restarted){y(),l({message:i(`chatMsg.errSwRestarted`),executionLog:[],checkpoint:_.checkpoint,swRestarted:!0});return}let g=[],b=Math.round(d/1e3);h(null),xD(null),CD(0);let x=``,S={},C=e=>{h()&&PD(h()),y(),(!e.executionLog||e.executionLog.length===0||g.length>0)&&(e.executionLog=g),l(e)};H.pendingCancelApi=C,H.pendingCallApiSessionIds.add(p),ID(),o.debug(`[SidePanel] callApi: add pendingCallApiSessionIds, mySessionId =`,p,`, set:`,[...H.pendingCallApiSessionIds]),v.timeoutId=setTimeout(()=>{C({message:i(`chatMsg.errTimeout`,{seconds:b}),executionLog:g}),chrome.runtime.sendMessage({type:`CANCEL_REACT`,tabId:H.currentTabId,sessionId:H.activeSessionId}).catch(e=>{o.debug(`[SidePanel] sendcancelrequest failed:`,e.message)})},d);let w=Date.now(),T=0,E=null,D=()=>{E===null&&v.timeoutId!==null&&(E=Date.now(),clearTimeout(v.timeoutId),v.timeoutId=null,o.debug(`[SidePanel] before sidetimeoutpaused (waitinguser response:clarification/sensitive toolconfirm)`))},O=()=>{if(E!==null){let e=Date.now()-E;T+=e,E=null;let t=Date.now()-w,n=d+T-t;if(n<=0){C({message:i(`chatMsg.errTimeout`,{seconds:b}),executionLog:g});return}v.timeoutId=setTimeout(()=>{C({message:i(`chatMsg.errTimeout`,{seconds:b}),executionLog:g}),chrome.runtime.sendMessage({type:`CANCEL_REACT`,tabId:H.currentTabId,sessionId:p}).catch(e=>{o.debug(`[SidePanel] sendcancelrequest failed:`,e.message)})},n),o.debug(`[SidePanel] before sidetimeoutrestored,pause duration:`,Math.round(e/1e3),`s,remaining time:`,Math.round(n/1e3),`s`)}},k=e=>{if(e.sessionId&&e.sessionId!==p||e.callId&&e.callId!==m)return!1;if(e.type===`EXECUTION_STATUS_UPDATE`){let t=e.executionLog||[];if(t.length>0&&t.forEach(e=>{let t=g.findIndex(t=>t.id===e.id);t===-1?g.push(e):g[t]={...g[t],...e}}),e.subtaskTotal&&e.subtaskTotal>0){let t=h();if(t){let n=t.querySelector(`.stream-content`);if(n){let t=e.subtaskIndex??0,r=`.subtask-progress[data-subtask-index="${t}"]`,a=n.querySelector(r),o=a?a.classList.contains(`subtask-expanded`):!1;a||(a=document.createElement(`div`),a.className=`subtask-progress`,a.dataset.subtaskIndex=t,n.appendChild(a));let s=t+1,c=e.subtaskTotal,l=e.subtaskName||``,u=`<span class="subtask-badge">${s}/${c}</span>`,d=e.status!==`success`&&e.status!==`failed`,f=``;e.status===`success`?(f=`<span class="subtask-status-done">${i(`chatMsg.subtaskDone`)}</span>`,a.classList.add(`subtask-progress-done`),a.classList.remove(`subtask-progress-active`)):e.status===`failed`?(f=`<span class="subtask-status-failed">${i(`chatMsg.subtaskFailed`)}</span>`,a.classList.add(`subtask-progress-failed`),a.classList.remove(`subtask-progress-active`)):(f=`<span class="subtask-status-label"><span class="subtask-spinner"></span>${i(`chatMsg.subtaskExecuting`)}</span>`,a.classList.add(`subtask-progress-active`));let p=g.filter(e=>e.subtaskIndex===t&&e.nodeType!==`subtask`),m=p.length,h=p.filter(e=>e.status===`success`).length,_=p.filter(e=>e.status===`failed`).length,v=p.find(e=>e.status===`processing`),y=``;if(d&&m>0){let e=v?v.nodeType===`tool_exec`?`🔧`:v.nodeType===`api_call`?`📡`:v.nodeType===`reflection`?`🎯`:v.nodeType===`preselect`?`🔍`:`○`:`○`,t=v?W(v.nodeName||``):i(`chatMsg.preparing`),n=v?ps(v):``;y=`<div class="subtask-progress-line">
|
|
2045
2051
|
<span class="subtask-current-node"><span class="subtask-current-spinner"></span><span class="node-label">${e} ${t}</span>${n?` <span class="subtask-current-cmd" title="${je(n)}">${W(n)}</span>`:``}</span>
|
|
2046
2052
|
<span class="subtask-node-stats">
|
|
2047
2053
|
<span class="subtask-stat-total">${m}</span>
|
|
@@ -2063,7 +2069,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
2063
2069
|
<span class="subtask-node-status">${n}</span>
|
|
2064
2070
|
<span class="subtask-node-name">${o}${s}</span>
|
|
2065
2071
|
${a?`<span class="subtask-node-dur">${a}</span>`:``}
|
|
2066
|
-
</div>`}).join(``))}a._clickDelegated||(a._clickDelegated=!0,a.addEventListener(`click`,e=>{e.target.closest(`.subtask-header`)&&a.classList.toggle(`subtask-expanded`)})),e.status===`success`&&s>=c&&n.querySelectorAll(`.subtask-progress`).forEach(e=>e.classList.add(`subtask-progress-all-done`))}}}return!1}if(e.type===`CLARIFY_START`)return D(),!1;if(e.type===`CLARIFY_END`)return O(),!1;if(e.type===`TOOL_CONFIRM_START`)return D(),!1;if(e.type===`TOOL_CONFIRM_END`)return O(),!1;if(e.type===`STREAM_PRESELECT`){if(o.debug(`[SidePanel] received pre-filterlog,:`,e.preselectLog?.length),
|
|
2072
|
+
</div>`}).join(``))}a._clickDelegated||(a._clickDelegated=!0,a.addEventListener(`click`,e=>{e.target.closest(`.subtask-header`)&&a.classList.toggle(`subtask-expanded`)})),e.status===`success`&&s>=c&&n.querySelectorAll(`.subtask-progress`).forEach(e=>e.classList.add(`subtask-progress-all-done`))}}}return!1}if(e.type===`CLARIFY_START`)return D(),!1;if(e.type===`CLARIFY_END`)return O(),!1;if(e.type===`TOOL_CONFIRM_START`)return D(),!1;if(e.type===`TOOL_CONFIRM_END`)return O(),!1;if(e.type===`STREAM_PRESELECT`){if(o.debug(`[SidePanel] received pre-filterlog,:`,e.preselectLog?.length),xD(e.preselectLog||null),h()&&bD()&&bD().length>0){let e=h().querySelector(`.message-content`);e&&(bD().forEach(t=>{let n=jD(t);e.insertBefore(n,e.firstChild)}),xD(null),o.debug(`[SidePanel] pre-filtercard imageappended to existingstreamingelement`))}return!1}if(e.type===`API_RETRYING`){let t=i(`chatMsg.retrying`,{attempt:e.attempt,max:e.maxRetries}),n=h();if(n){let e=n.querySelector(`.thinking-indicator:not(.hidden) .thinking-label`);e&&(e.textContent=t,e.dataset.retrying=`1`)}else{let e=document.querySelector(`.loading-message .loading-text`);e&&(e.textContent=t)}return!1}if(e.type===`STREAM_START`){o.debug(`[SidePanel] streamingoutput start`);let e=r._loadingId,t=e?document.getElementById(e):document.querySelector(`.loading-message`);if(t&&t.remove(),H.executionLogListener&&(chrome.runtime.onMessage.removeListener(H.executionLogListener),H.executionLogListener=null),H.currentExecutionStatus=null,h()){let e=h().querySelector(`.stream-content`);if(e){let t=e.querySelector(`.thinking-indicator:not(.hidden)`);if(t&&o.warn(`[STREAM_START] has can seen thinking indicator,skipcreate:`,t),!t){let t=document.createElement(`div`);t.className=`thinking-indicator`,t.innerHTML=`
|
|
2067
2073
|
<svg class="thinking-icon pulse-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2068
2074
|
<path d="M12 2a3 3 0 0 0-3 3v1a3 3 0 0 0 3 3 3 3 0 0 1 3 3v1a3 3 0 0 1-3 3 3 3 0 0 0-3 3v1a3 3 0 0 0 3 3"/>
|
|
2069
2075
|
<circle cx="8" cy="12" r="1.5"/>
|
|
@@ -2076,20 +2082,20 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
2076
2082
|
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
|
|
2077
2083
|
</svg>
|
|
2078
2084
|
</button>
|
|
2079
|
-
`;let n=t.querySelector(`.streaming-stop-btn`);n&&n.addEventListener(`click`,e=>{e.stopPropagation(),
|
|
2085
|
+
`;let n=t.querySelector(`.streaming-stop-btn`);n&&n.addEventListener(`click`,e=>{e.stopPropagation(),ND(n)}),e.appendChild(t)}}}else if(h(TD(p)),CD(Date.now()),bD()&&bD().length>0){let e=h().querySelector(`.message-content`);bD().forEach(t=>{let n=jD(t);e.insertBefore(n,e.firstChild)}),xD(null)}return x=``,yD(p,``),SD(Date.now()),!1}if(e.type===`STREAM_CHUNK`)return h()&&(x+=e.delta,yD(p,x),h().isConnected&&DD(h(),x)),!1;if(e.type===`STREAM_TOOL_CALL`)return h()||(h(TD(p)),CD(Date.now())),h()&&e.toolCalls?.length>0&&OD(h(),e.toolCalls),!1;if(e.type===`STREAM_TOOL_RESULT`)return h()&&e.result&&AD(e.result,h()),!1;if(e.type===`AGENT_STREAM`){if(h()&&e.execId){let t=S[e.execId];if(!t){let n=document.createElement(`div`);if(n.className=`agent-stream-output`,n.innerHTML=`
|
|
2080
2086
|
<div class="tool-result-title">${i(`chatMsg.toolResultTitle`)}</div>
|
|
2081
|
-
${
|
|
2087
|
+
${kD(``,`agent-stream-content`)}
|
|
2082
2088
|
`,e.toolCallId){let t=h().querySelector(`.tool-call-item[data-tool-call-id="${e.toolCallId}"]`);if(t){let e=t.querySelector(`.tool-call-body`);e?e.appendChild(n):t.appendChild(n)}}if(!n.isConnected){let e=h().querySelector(`.stream-content`);e&&e.appendChild(n)}t={element:n,stdout:``,stderr:``},S[e.execId]=t,Ki()}let n=t.element.querySelector(`code`);n&&(e.streamType===`stderr`?t.stderr+=e.data:t.stdout+=e.data,n.textContent=t.stdout+(t.stderr?`
|
|
2083
|
-
`+t.stderr:``),n.parentElement.scrollTop=n.parentElement.scrollHeight)}return!1}if(e.type===`AGENT_STREAM_DONE`){if(e.execId){let t=S[e.execId];t&&e.exitCode!==0&&t.element.classList.add(`agent-stream-error`)}return!1}if(e.type===`STREAM_DONE`){if(h()){let e=h().querySelector(`.stream-status`);e&&(e.textContent=f?.enabled?i(`chatMsg.reflectionInProgress`):``)}return!1}if(e.type===`API_COMPLETE`){
|
|
2089
|
+
`+t.stderr:``),n.parentElement.scrollTop=n.parentElement.scrollHeight)}return!1}if(e.type===`AGENT_STREAM_DONE`){if(e.execId){let t=S[e.execId];t&&e.exitCode!==0&&t.element.classList.add(`agent-stream-error`)}return!1}if(e.type===`STREAM_DONE`){if(h()){let e=h().querySelector(`.stream-status`);e&&(e.textContent=f?.enabled?i(`chatMsg.reflectionInProgress`):``)}return!1}if(e.type===`API_COMPLETE`){let t=e.content&&String(e.content).trim()?e.content:i(`chatMsg.emptyModelReply`);h()&&MD(h(),t,e.executionLog||[],e.reflectionScore,e.reasoningContent,e.wasRevised);let n=h(),r=!!n,o=n?n.dataset.htmlContent||n.outerHTML:null,s=n?n.isConnected:!1,c=n?n.dataset.messageId:null;return y(),console.log(`[callApi API_COMPLETE] wasStreamed:`,r,`| message.executionLog entries:`,e.executionLog?.length||0,`| local executionLog entries:`,g.length,`| agent_file entries:`,(e.executionLog||g)?.filter(e=>e.nodeType===`tool_exec`&&e.action?.name===`agent_file`).length||0),a({content:t,executionLog:e.executionLog||g,reflectionScore:e.reflectionScore,wasStreamed:r,wasRevised:e.wasRevised,streamingHtml:o,streamingConnected:s,streamingMsgId:c}),!1}if(e.type===`API_ERROR`){let t=h();return t&&t.isConnected&&t.remove(),y(),l({message:e.error,executionLog:e.executionLog||g}),!1}return!1};chrome.runtime.onMessage.addListener(k),v.removeListener=()=>{chrome.runtime.onMessage.removeListener(k)},s?(o.debug(`[SidePanel] send RESUME_REACT message,sessionId:`,H.activeSessionId,`userGuidance:`,c?`"${c.substring(0,50)}..."`:`( no )`,`timeout:`,d),chrome.runtime.sendMessage({type:`RESUME_REACT`,sessionId:H.activeSessionId,callId:m,userGuidance:c||``})):(o.debug(`[SidePanel] send CALL_API message,useTools:`,n,`tabId:`,H.currentTabId,`sessionId:`,H.activeSessionId,`apiParams:`,r,`timeout:`,d),chrome.runtime.sendMessage({type:`CALL_API`,sessionId:H.activeSessionId,messages:e,model:t,useTools:n,tabId:H.currentTabId,apiParams:r,agentId:H.activeAgentId,agentToolIds:H.activeAgentToolIds,agentSkillIds:H.activeAgentSkillIds,forcedMcpServerIds:Array.isArray(u)&&u.length>0?u:null,agentMcpExcludedServerIds:H.activeAgentMcpExcludedServerIds??null,callId:m,imageApiBase:H.enableImageInput&&H.attachedImages.length>0&&H.imageApiBase||``,imageApiKey:H.enableImageInput&&H.attachedImages.length>0&&H.imageApiKey||``}))})}function CO(e){try{let t=e.dataset.rawContent||``,n=e.dataset.textContent_||``;if(!n&&!t){U(i(`chatMsg.cannotGetMessageContent`),`error`);return}if(H.attachedImages=[],t.startsWith(`[`))try{let e=JSON.parse(t);if(Array.isArray(e)){let t=e.filter(e=>e.type===`image_url`);for(let e of t){let t=e.image_url.original_url||e.image_url.url;H.attachedImages.push({originalUrl:t,compressedUrl:e.image_url.url,width:e.image_url.width,height:e.image_url.height})}}}catch{}if(_c(),H.attachedFiles=[],e.dataset.attachedFiles)try{let t=JSON.parse(e.dataset.attachedFiles);for(let e of t)H.attachedFiles.push({name:e.name,size:e.size,type:e.type,text:e.text||``,status:e.status||`done`,agentPath:e.agentPath||``})}catch{}fe(()=>Promise.resolve().then(()=>zc).then(e=>{e.renderFilePreviews()}),void 0),OE();let r=n.match(/^\[网页上下文\]\n标题: (.+)\nURL: (.+)\ntabId: (\d+)\n/);if(r){H.selectedPage={id:parseInt(r[3]),title:r[1],url:r[2],favIconUrl:``};let e=document.getElementById(`pageIndicator`),t=document.getElementById(`pageIndicatorName`);if(e&&t){let n=r[1],i=r[2];t.textContent=n&&n!==`无标题`&&i?`${n} · ${i}`:n||i,e.style.display=`flex`}}pE();let a=n.match(/\[知识库检索结果\](引用: ([^)]+))/);if(a){let e=a[1].split(`、`).map(e=>e.trim()).filter(Boolean);e.length>0&&(H.knowledgeRefs=e.map(e=>({id:``,name:e})),mE(),vE().then(e=>{if(e&&e.ok){let t=new Map((e.collections||[]).map(e=>[e.name,e]));H.knowledgeRefs=H.knowledgeRefs.map(e=>{if(e.id)return e;let n=t.get(e.name);return{id:n?.id||``,name:e.name,enabled:!n||n.enabled!==!1}}),mE()}}).catch(()=>{}))}ak(),vk();let s=Array.from(new Set([...n.matchAll(/\[(?:已选技能|Selected skill):\s*([^\n\]]+)\]/g)].map(e=>e[1].split(` - `)[0].trim()).filter(Boolean)));s.length>0&&(H.selectedSkills=s.map(e=>({name:e,description:``,type:`agent`})),ok());let c=Array.from(new Set([...n.matchAll(/\[(?:已选MCP服务|Selected MCP service):\s*([^\n\]]+)\]/g)].map(e=>e[1].split(` - `)[0].trim()).filter(Boolean)));c.length>0&&(H.selectedMcpServices=c.map(e=>({serverId:``,serverName:e,toolCount:0})),bk(),chrome.storage.local.get([`mcpTools`],e=>{let t=e.mcpTools||[];c.forEach(e=>{let n=H.selectedMcpServices.find(t=>t.serverName===e);if(!n||n.serverId)return;let r=t.find(t=>(t.serverName||``)===e)||t.find(t=>(t.serverName||``).startsWith(e));r&&(n.serverId=r.serverId||``,n.toolCount=t.filter(e=>e.serverId===r.serverId).length)}),bk()}));let l=n;r&&(l=l.replace(/^\[网页上下文\]\n标题: .+\nURL: .+\ntabId: \d+\n/,``)),a&&(l=l.replace(/\[知识库检索结果\][^\n]*\n[\s\S]*?\[\/知识库检索结果\]\n\n?/,``)),c.length>0&&(l=oO(l)),s.length>0&&(l=aO(l));let u=H.quotedContextText,d=H.selectedContextText;H.quotedContextText=``,H.selectedContextText=``;let f=l.match(/^\[引用内容(?:摘要)?\]\n([\s\S]+?)\n\n\[用户问题\]\n([\s\S]*)$/),p=l.match(/^\[选中内容(?:摘要)?\]\n([\s\S]+?)\n\n\[用户问题\]\n([\s\S]*)$/),m=f||p,h=l;if(m){let e=f?`quoted`:`selected`,t=m[1].trim(),n=m[2].trim();if(H.attachedFiles.length>0){let e=n.search(/\n\n\[(?:工作目录)?文件(?:内容)?:/);e!==-1&&(n=n.substring(0,e).trim())}let r=document.getElementById(`selectionIndicator`),a=document.getElementById(`selectionText`);if(r&&a){let n;n=t.length>100?t.substring(0,100)+`...`:t.length>50?t.substring(0,50)+`...`:t,e===`quoted`?(H.quotedContextText=t,a.textContent=i(`chatMsg.quotedContextLabel`,{text:n})):(H.selectedContextText=t,a.textContent=i(`chatMsg.selectedContextLabel`,{text:n})),r.classList.add(`show`)}h=n}else if(H.quotedContextText=u,H.selectedContextText=d,H.attachedFiles.length>0){let e=h.search(/\n\n\[(?:工作目录)?文件(?:内容)?:/);e!==-1&&(h=h.substring(0,e).trim())}let g=document.getElementById(`userInput`);g.value=h,ke(),g.focus(),g.selectionStart=g.selectionEnd=g.value.length,o.debug(`[SidePanel] loadedmessagecontent to input box,waitingafter user editsend`)}catch(e){o.error(`[SidePanel] editmessage failed:`,e),U(i(`chatMsg.editFailed`,{message:e.message}),`error`)}}r(`zh`,{promptMgr:{promptsTabCount:`提示词 ({count})`,skillsTabCount:`技能 ({count})`,mcpTabCount:`MCP ({count})`,noMatchPrompt:`暂无匹配的提示词`,mergedHeaderHint:`方向键切换 · Enter发送/选择 · Ctrl+Enter带入/选中并关闭 · Esc取消`,noMatchResult:`暂无匹配结果`,requestFailed:`❌ 请求失败:{message}`,emptyPromptHint:`暂无提示词,请添加`,menuDisplayTitle:`菜单显示`,codeAndContentRequired:`请填写编码和内容`,codeExists:`编码已存在`,saveChanges:`保存修改`,confirmDeletePrompt:`确定要删除提示词 "/{code}" 吗?`}}),r(`en`,{promptMgr:{promptsTabCount:`Prompts ({count})`,skillsTabCount:`Skills ({count})`,mcpTabCount:`MCP ({count})`,noMatchPrompt:`No matching prompts`,mergedHeaderHint:`Arrow keys to switch · Enter to send/select · Ctrl+Enter to insert/select & close · Esc to cancel`,noMatchResult:`No matching results`,requestFailed:`❌ Request failed: {message}`,emptyPromptHint:`No prompts yet, please add one`,menuDisplayTitle:`Show in menu`,codeAndContentRequired:`Please fill in both code and content`,codeExists:`Code already exists`,saveChanges:`Save changes`,confirmDeletePrompt:`Are you sure you want to delete prompt "/{code}"?`}});var wO=`<svg viewBox="0 0 1024 1024" width="12" height="12" fill="currentColor"><path d="M674.56 231.552l101.568 56.96-56.896-101.632 56.96-101.568-101.632 56.896-101.632-56.896 56.96 101.568-56.896 101.632 101.568-56.96zM186.944 629.76l-101.504-56.896 56.832 101.632-56.832 101.568 101.504-56.96 101.632 56.96-56.896-101.568 56.896-101.568-101.568 56.832zM85.44 85.312l56.832 101.568-56.832 101.632 101.504-56.96 101.632 56.96L231.68 186.88l56.896-101.568-101.568 56.896-101.568-56.896z m351.872 438.016l-99.2-99.136L424.32 337.984l99.072 99.264-86.08 86.144m-41.856-223.04L300.352 395.392a40.448 40.448 0 0 0 0 57.28l474.24 474.112a40.448 40.448 0 0 0 57.344 0l94.912-95.04a40.448 40.448 0 0 0 0-57.344L452.736 300.288a40.448 40.448 0 0 0-57.28 0z"/></svg>`;function TO(){o.debug(`[SidePanel] clear selectedcontenttext `),H.selectedContextText=``,H.quotedContextText=``;let e=document.getElementById(`selectionIndicator`),t=document.getElementById(`userInput`);if(e&&(e.classList.remove(`show`),o.debug(`[SidePanel] hiddenselected contentprompt`)),typeof window.hideFloatingMenu==`function`&&window.hideFloatingMenu(),t&&t.value.startsWith(`[选中内容]`)){let e=t.value.split(`
|
|
2084
2090
|
`),n=0;for(let t=0;t<e.length;t++)if(e[t].startsWith(`[用户问题]`)){n=t;break}n>0&&(t.value=e.slice(n).join(`
|
|
2085
|
-
`),t.dispatchEvent(new Event(`input`)),o.debug(`[SidePanel] removedinput box selected content before suffix`))}H.lastSelectedText=``,H.currentSelectionRange=null}function
|
|
2091
|
+
`),t.dispatchEvent(new Event(`input`)),o.debug(`[SidePanel] removedinput box selected content before suffix`))}H.lastSelectedText=``,H.currentSelectionRange=null}function EO(){let e=document.getElementById(`promptManageList`).querySelectorAll(`.prompt-manage-item`);e.forEach(t=>{t.addEventListener(`dragstart`,e=>{H.draggedItemIndex=parseInt(t.dataset.index),t.classList.add(`dragging`),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,H.draggedItemIndex)}),t.addEventListener(`dragend`,()=>{t.classList.remove(`dragging`),e.forEach(e=>e.classList.remove(`drag-over`)),H.draggedItemIndex=null}),t.addEventListener(`dragover`,e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,t.classList.add(`drag-over`)}),t.addEventListener(`dragleave`,()=>{t.classList.remove(`drag-over`)}),t.addEventListener(`drop`,e=>{e.stopPropagation(),e.preventDefault();let n=parseInt(t.dataset.index);if(H.draggedItemIndex!==null&&H.draggedItemIndex!==n){let e=H.customPrompts[H.draggedItemIndex];H.customPrompts.splice(H.draggedItemIndex,1),H.customPrompts.splice(n,0,e),chrome.storage.local.set({customPrompts:H.customPrompts}),zO()}t.classList.remove(`drag-over`)})})}function DO(){let e=document.querySelector(`#promptDropdown .prompt-dropdown-header`);if(!e||e.querySelector(`.prompt-manage-btn`))return;let t=document.createElement(`button`);t.className=`prompt-manage-btn`,t.title=i(`promptManager.title`),t.style.fontSize=`13px`,t.innerHTML=`✚`,t.addEventListener(`click`,e=>{e.stopPropagation(),LO()}),e.appendChild(t)}async function OO(e=``,t=null){let n=document.getElementById(`promptSelector`),r=document.getElementById(`promptDropdown`);Ae(),n.style.display=`block`,r.classList.add(`show`);let i=document.getElementById(`skillsTab`),a=document.getElementById(`mcpTab`),o=i?await QO():!1,s=a?await pk():!1;if(i&&(i.style.display=o?`block`:`none`),a&&(a.style.display=s?`block`:`none`),AO(o,s),e)await NO(e);else{let n=t||H.lastActiveDropdownTab||`prompts`,r=document.querySelector(`#promptDropdownTabs .prompt-tab[data-tab="${n}"]`),i=`prompts`;if(r&&r.style.display!==`none`)i=n;else{let e=document.querySelectorAll(`#promptDropdownTabs .prompt-tab`);for(let t of e)if(t.style.display!==`none`){i=t.dataset.tab;break}}await lk(i),MO(e)}}function kO(){let e=document.getElementById(`promptSelector`),t=document.getElementById(`promptDropdown`);e.style.display=`none`,t.classList.remove(`show`),H.selectedPromptIndex=-1,H.showMergedList=!1;let n=document.getElementById(`promptDropdownTabs`);n&&n.classList.remove(`merged-mode`)}async function AO(e,t){try{let n=H.customPrompts.length,r=document.querySelector(`#promptDropdownTabs .prompt-tab[data-tab="prompts"]`);if(r&&(r.textContent=i(`promptMgr.promptsTabCount`,{count:n})),e){let e=await ek(),t=document.getElementById(`skillsTab`);t&&(t.textContent=i(`promptMgr.skillsTabCount`,{count:e.length}))}if(t){let e=await mk(),t=document.getElementById(`mcpTab`);t&&(t.textContent=i(`promptMgr.mcpTabCount`,{count:e.length}))}}catch{}}function jO(e=``){e?NO(e):MO(e)}function MO(e=``){let t=document.getElementById(`promptList`),n=e.toLowerCase(),r=H.customPrompts.filter(t=>!e||t.code.toLowerCase().includes(n)||t.content.toLowerCase().includes(n));if(r.length===0){t.innerHTML=`<div class="prompt-empty">${i(`promptMgr.noMatchPrompt`)}</div>`,H.selectedPromptIndex=-1;return}H.selectedPromptIndex=0,t.innerHTML=r.map((e,t)=>`
|
|
2086
2092
|
<div class="prompt-item ${t===H.selectedPromptIndex?`selected`:``}" data-index="${t}" data-code="${e.code}">
|
|
2087
2093
|
<span class="prompt-item-index">${t+1}</span>
|
|
2088
|
-
<span class="prompt-item-icon">${
|
|
2094
|
+
<span class="prompt-item-icon">${wO}</span>
|
|
2089
2095
|
<span class="prompt-item-content">${e.content}</span>
|
|
2090
2096
|
<span class="prompt-item-code">/${e.code}</span>
|
|
2091
2097
|
</div>
|
|
2092
|
-
`).join(``),t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,t=>{let n=e.dataset.code;t.ctrlKey||t.metaKey?
|
|
2098
|
+
`).join(``),t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,t=>{let n=e.dataset.code;t.ctrlKey||t.metaKey?FO(n):IO(n)})})}async function NO(e=``){let t=document.getElementById(`promptList`),n=document.getElementById(`skillList`),r=document.getElementById(`mcpList`),a=document.getElementById(`promptDropdownTabs`),o=document.querySelector(`#promptDropdownHeader .prompt-dropdown-header-text`),s=document.querySelector(`#promptDropdownHeader .prompt-manage-btn`),c=document.querySelector(`#promptDropdownHeader .skill-manage-btn`),l=document.querySelector(`#promptDropdownHeader .mcp-manage-btn`);a&&a.classList.add(`merged-mode`),n&&(n.style.display=`none`),r&&(r.style.display=`none`),t&&(t.style.display=`block`),o&&(o.textContent=i(`promptMgr.mergedHeaderHint`)),s&&(s.style.display=``),c&&(c.style.display=`none`),l&&(l.style.display=`none`),H.showMergedList=!0,H.activeDropdownTab=`prompts`;let u=e.toLowerCase(),d=H.customPrompts.filter(t=>!e||t.code.toLowerCase().includes(u)||t.content.toLowerCase().includes(u)),f=[];await QO()&&(f=(await ek()).filter(t=>!e||(t.name||``).toLowerCase().includes(u)||(t.description||``).toLowerCase().includes(u)));let p=[];await pk()&&(p=(await mk()).filter(t=>!e||(t.serverName||``).toLowerCase().includes(u)||(t.serverId||``).toLowerCase().includes(u)));let m=d.length+f.length+p.length,h=document.getElementById(`promptMergedTitle`);if(h&&(h.textContent=i(`promptSelector.mergedTitleCount`,{count:m})),m===0){t.innerHTML=`<div class="prompt-empty">${i(`promptMgr.noMatchResult`)}</div>`,H.selectedPromptIndex=-1;return}H.selectedPromptIndex=0;let g=0,_=d.map(e=>{let t=`
|
|
2093
2099
|
<div class="prompt-item ${g===0?`selected`:``}" data-index="${g}" data-type="prompt" data-code="${e.code}">
|
|
2094
2100
|
<span class="prompt-item-index">${g+1}</span>
|
|
2095
2101
|
<span class="prompt-item-icon">📋</span>
|
|
@@ -2107,13 +2113,13 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
2107
2113
|
<span class="prompt-item-content">🔌 ${W(e.serverName)}</span>
|
|
2108
2114
|
${t?`<span class="merged-item-badge badge-mcp-inactive">${i(`skillSelector.mcpInactiveBadge`)}</span>`:``}
|
|
2109
2115
|
<span class="merged-item-badge badge-mcp">MCP</span>
|
|
2110
|
-
</div>`;return g++,n}).join(``);t.innerHTML=_+v+y,t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,async t=>{let n=e.dataset.type;if(n===`skill`){let n=e.dataset.skillName;
|
|
2116
|
+
</div>`;return g++,n}).join(``);t.innerHTML=_+v+y,t.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,async t=>{let n=e.dataset.type;if(n===`skill`){let n=e.dataset.skillName;ik(n,await ek()),(t.ctrlKey||t.metaKey)&&kO()}else if(n===`mcp`){let n=e.dataset.serverId,r=e.dataset.serverName;_k(n,r,await mk()),(t.ctrlKey||t.metaKey)&&kO()}else{let n=e.dataset.code;t.ctrlKey||t.metaKey?FO(n):IO(n)}})}),sk(),xk()}function PO(e){e.forEach((e,t)=>{t===H.selectedPromptIndex?(e.classList.add(`selected`),e.scrollIntoView({block:`nearest`})):e.classList.remove(`selected`)})}function FO(e,{skipTriggerStrip:t=!1}={}){let n=H.customPrompts.find(t=>t.code===e);if(!n)return;let r=document.getElementById(`userInput`),i=r.value,a=i.lastIndexOf(`/`),s=i;if(!t&&a!==-1){let e=-1;for(let t=a-1;t>=0;t--)if(i[t]===`
|
|
2111
2117
|
`){e=t;break}s=e===-1?i.substring(0,a).trimEnd():i.substring(0,e+1).trimEnd()}r.value=s+(s&&!s.endsWith(`
|
|
2112
2118
|
`)?`
|
|
2113
2119
|
|
|
2114
|
-
`:``)+n.content,r.focus(),r.selectionStart=r.selectionEnd=r.value.length,
|
|
2120
|
+
`:``)+n.content,r.focus(),r.selectionStart=r.selectionEnd=r.value.length,kO(),ke(),o.debug(`[SidePanel] trackaddpromptword to input box:`,n.code,n.content)}async function IO(e){let t=H.customPrompts.find(t=>t.code===e);if(!t)return;if(H.isGenerating){o.debug(`[SidePanel] generating,please wait...`);return}kO();let n=document.getElementById(`chatContainer`).querySelector(`.welcome-message`);n&&n.remove();let r=t.content,a=H.selectedContextText&&H.selectedContextText.trim(),s=H.quotedContextText&&H.quotedContextText.trim(),c=[];if(s){let e=H.quotedContextText.trim(),{compressed:n,wasCompressed:i}=y(e);r=`[引用内容${i?`摘要`:``}]\n${n}\n\n[用户问题]\n${t.content}`,iO(`quoted`,e,!1),c.push({type:`quoted`,text:e}),H.quotedContextText=``}else if(a){let e=H.selectedContextText.trim(),{compressed:n,wasCompressed:i}=y(e);r=`[选中内容${i?`摘要`:``}]\n${n}\n\n[用户问题]\n${t.content}`,iO(`selected`,e,!1),c.push({type:`selected`,text:e}),H.selectedContextText=``}let l=await fk();if(l){r=l+r;for(let e of H.selectedSkills)iO(`skill`,i(`contextBubble.bubbleSkill`,{name:e.name,desc:e.description?`:`+e.description:``}),!1),c.push({type:`skill`,name:e.name,description:e.description||``});ak()}let u=null,d=yk();if(d){let e=H.selectedMcpServices.map(e=>e.serverId).filter(Boolean);u=e.length>0?e:null,r=d+r;for(let e of H.selectedMcpServices)iO(`mcp`,i(`contextBubble.bubbleMcp`,{name:e.serverName}),!1),c.push({type:`mcp`,serverName:e.serverName,serverId:e.serverId||``});vk()}if(H.knowledgeRefs.length>0){let e=H.knowledgeRefs.slice(),n=iO(`knowledge`,i(`contextBubble.bubbleKnowledgeSearching`),!1),a=null;try{a=await ZD(t.content,e)}catch(e){o.warn(`[SidePanel] knowledge search failed:`,e)}n&&n.parentNode&&n.remove(),a&&(r=a.text+r,QD(a.refs,a.failed===!0),c.push({type:`knowledge`,refs:a.refs,failed:a.failed||void 0})),pE()}H.selectedPage&&(r=`[网页上下文]\n标题: ${H.selectedPage.title}\nURL: ${H.selectedPage.url}\ntabId: ${H.selectedPage.id}\n`+r,iO(`page`,i(`contextBubble.bubblePage`,{title:H.selectedPage.title,url:H.selectedPage.url}),!1),c.push({type:`page`,title:H.selectedPage.title,url:H.selectedPage.url}),OE()),(a||s)&&TO();let f=H.attachedFiles.slice();if(f.length>0){let e=tl();e&&(r+=e),f.forEach(e=>{e.status===`done`&&c.push({type:`file`,name:e.name,size:e.size,fileType:e.type})})}let p=vc(r),{messageId:m,timestamp:g}=sO(`user`,vc(t.content),!0,[],null,!1,r,null,f);H.messageHistory.push({role:`user`,content:p,messageId:m,timestamp:g,contextBubbles:c}),GD(),lt(t.content);let _=document.getElementById(`userInput`);_.value=``,_.style.height=`auto`,H.isGenerating=!0;let v=pO(),b=H.activeSessionId,x=H.enableImageInput&&H.attachedImages.length>0&&H.imageModelName||H.currentModel;if(H.attachedImages.length>0){let e=document.getElementById(`imagePreviewBar`);e&&(e.innerHTML=``,e.style.display=`none`)}H.attachedFiles.length>0&&$c();try{await Ze(),o.debug(`[SidePanel] sendmessagedebuginfo:`),o.debug(` - isolateChat:`,H.isolateChat),o.debug(` - chatConfig:`,H.chatConfig),o.debug(` - messageHistory.length:`,H.messageHistory.length);let e=[{role:`system`,content:await Ke()}];if(H.isolateChat){let t=H.enabledTools.length||50,n=h(x,t,0,H.customModelMap),r=Math.floor(n*.7),i=H.messageHistory[H.messageHistory.length-1],a=at(H.messageHistory.slice(0,-1),{isolateChat:!0,maxMemoryMessages:H.chatConfig.maxMemoryMessages,compaction:H.activeCompaction,historyBudget:r,currentMessage:i});a.compactionApplied?e[0]={...e[0],content:ot(e[0].content,H.activeCompaction)}:H.activeCompaction&&o.warn(`[SidePanel] contextCompaction invalid (upToMessageId not found), ignored this send`),a.historySummaryText&&(e[0]={...e[0],content:e[0].content+`
|
|
2115
2121
|
|
|
2116
|
-
`+a.historySummaryText}),e=[...e,...a.messages];for(let t=0;t<e.length-1;t++)e[t]={...e[t],content:yc(e[t].content)}}else e.push({role:`user`,content:p});let t=await Ye(),n,r,a=!1,s=null,c=null;try{let i=await
|
|
2122
|
+
`+a.historySummaryText}),e=[...e,...a.messages];for(let t=0;t<e.length-1;t++)e[t]={...e[t],content:yc(e[t].content)}}else e.push({role:`user`,content:p});let t=await Ye(),n,r,a=!1,s=null,c=null;try{let i=await SO(e,x,H.useTools,t,{forcedMcpServerIds:u});n=i.content,r=i.executionLog||[],a=i.wasStreamed||!1,s=i.streamingHtml||null,i.streamingConnected!==void 0&&i.streamingConnected,c=i.streamingMsgId||null}catch(e){mO(v),n=i(`promptMgr.requestFailed`,{message:e.message||i(`agentConfig.unknownError`)}),r=e.executionLog||[];let{element:t,messageId:a}=sO(`assistant`,n,!0,r);throw H.messageHistory.push({role:`assistant`,content:n,executionLog:r,messageId:a}),GD(),e.message!==i(`chatMsg.errTaskStopped`)&&ns(b,n),e}let l=null;if(!a||!s){if(mO(v),a)l=c;else{let{element:e,messageId:t}=sO(`assistant`,n,!0,r);l=t,await Ui(e)}}else l=c;H.messageHistory.push({role:`assistant`,content:n,executionLog:r,messageId:l}),GD(),ts(b)}catch{}finally{H.generatingSessionIds.delete(b),Dt(b),document.dispatchEvent(new CustomEvent(`generating-state-changed`)),_.focus(),H.attachedImages=[]}}function LO(){document.getElementById(`promptManageModal`).classList.add(`show`),zO()}function RO(){document.getElementById(`promptManageModal`).classList.remove(`show`);let e=document.getElementById(`editPromptIndex`),t=document.getElementById(`newPromptCode`),n=document.getElementById(`newPromptContent`),r=document.getElementById(`promptManageAddBtn`);e&&(e.value=``),t&&(t.value=``),n&&(n.value=``),r&&(r.textContent=i(`promptManager.addPrompt`),r.style.background=`#667eea`)}function zO(){let e=document.getElementById(`promptManageList`);if(H.customPrompts.length===0){e.innerHTML=`<div class="prompt-empty">${i(`promptMgr.emptyPromptHint`)}</div>`;return}e.innerHTML=H.customPrompts.map((e,t)=>`
|
|
2117
2123
|
<div class="prompt-manage-item" draggable="true" data-index="${t}">
|
|
2118
2124
|
<div class="prompt-manage-item-left">
|
|
2119
2125
|
<span class="prompt-drag-handle" title="${i(`toolbar.dragSort`)}">⋮⋮</span>
|
|
@@ -2141,7 +2147,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
2141
2147
|
</button>
|
|
2142
2148
|
</div>
|
|
2143
2149
|
</div>
|
|
2144
|
-
`).join(``),e.querySelectorAll(`.move-up-btn`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let n=parseInt(e.dataset.index);if(n>0){let e=H.customPrompts[n];H.customPrompts[n]=H.customPrompts[n-1],H.customPrompts[n-1]=e,chrome.storage.local.set({customPrompts:H.customPrompts}),
|
|
2150
|
+
`).join(``),e.querySelectorAll(`.move-up-btn`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let n=parseInt(e.dataset.index);if(n>0){let e=H.customPrompts[n];H.customPrompts[n]=H.customPrompts[n-1],H.customPrompts[n-1]=e,chrome.storage.local.set({customPrompts:H.customPrompts}),zO()}})}),e.querySelectorAll(`.move-down-btn`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let n=parseInt(e.dataset.index);if(n<H.customPrompts.length-1){let e=H.customPrompts[n];H.customPrompts[n]=H.customPrompts[n+1],H.customPrompts[n+1]=e,chrome.storage.local.set({customPrompts:H.customPrompts}),zO()}})}),e.querySelectorAll(`.menu-toggle-btn`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let n=parseInt(e.dataset.index);H.customPrompts[n].enabledInMenu=!H.customPrompts[n].enabledInMenu,chrome.storage.local.set({customPrompts:H.customPrompts}),zO()})}),e.querySelectorAll(`.edit-btn`).forEach(e=>{e.addEventListener(`click`,()=>{UO(parseInt(e.dataset.index))})}),e.querySelectorAll(`.delete-btn`).forEach(e=>{e.addEventListener(`click`,()=>{WO(parseInt(e.dataset.index))})}),EO()}function BO(e){let t=document.getElementById(`promptErrorModal`),n=document.getElementById(`promptErrorMessage`);n.textContent=e,t.classList.add(`show`)}function VO(){document.getElementById(`promptErrorModal`).classList.remove(`show`)}function HO(){let e=document.getElementById(`editPromptIndex`),t=document.getElementById(`newPromptCode`),n=document.getElementById(`newPromptContent`),r=t.value.trim(),a=n.value.trim();if(!r||!a){BO(i(`promptMgr.codeAndContentRequired`));return}let o=e?parseInt(e.value):-1,s=H.customPrompts.findIndex(e=>e.code===r);if(s!==-1&&s!==o){BO(i(`promptMgr.codeExists`));return}o>=0&&o<H.customPrompts.length?H.customPrompts[o]={...H.customPrompts[o],code:r,content:a}:H.customPrompts.push({code:r,content:a,enabledInMenu:!1}),chrome.storage.local.set({customPrompts:H.customPrompts}),t.value=``,n.value=``,e&&(e.value=``);let c=document.getElementById(`promptManageAddBtn`);c.textContent=i(`promptManager.addPrompt`),c.style.background=`#667eea`,zO()}function UO(e){let t=H.customPrompts[e];if(!t)return;let n=document.getElementById(`editPromptIndex`),r=document.getElementById(`newPromptCode`),a=document.getElementById(`newPromptContent`),o=document.getElementById(`promptManageAddBtn`);n&&(n.value=e),r.value=t.code,a.value=t.content,o.textContent=i(`promptMgr.saveChanges`),o.style.background=`#ffa502`,r.scrollIntoView({behavior:`smooth`})}function WO(e){let t=H.customPrompts[e];if(!t)return;H.pendingDeleteIndex=e;let n=document.getElementById(`deleteConfirmModal`),r=document.getElementById(`deleteConfirmMessage`);r.textContent=i(`promptMgr.confirmDeletePrompt`,{code:t.code}),n.classList.add(`show`)}function GO(){document.getElementById(`deleteConfirmModal`).classList.remove(`show`),H.pendingDeleteIndex=-1}function KO(e){H.customPrompts.splice(e,1),chrome.storage.local.set({customPrompts:H.customPrompts}),zO()}function qO(){let e=document.getElementById(`promptManageCancelBtn`),t=document.getElementById(`promptManageAddBtn`),n=document.getElementById(`promptModalCloseBtn`);e&&e.addEventListener(`click`,RO),t&&t.addEventListener(`click`,HO),n&&n.addEventListener(`click`,RO);let r=document.getElementById(`deleteCancelBtn`),i=document.getElementById(`deleteConfirmBtn`);r&&r.addEventListener(`click`,GO),i&&i.addEventListener(`click`,()=>{H.pendingDeleteIndex>=0&&KO(H.pendingDeleteIndex),GO()});let a=document.getElementById(`deleteConfirmModal`);a&&a.addEventListener(`click`,e=>{e.target===a&&GO()});let o=document.getElementById(`promptErrorConfirmBtn`);o&&o.addEventListener(`click`,VO);let s=document.getElementById(`promptErrorModal`);s&&s.addEventListener(`click`,e=>{e.target===s&&VO()});let c=document.getElementById(`promptDropdown`);c&&c.addEventListener(`mousedown`,e=>{e.target.closest(`.prompt-item, .prompt-tab, .skill-list-item, .mcp-list-item`)&&e.preventDefault()})}r(`zh`,{promptSelector:{noMatchSkill:`暂无匹配的技能`,skillManageTitle:`管理技能`,noMatchMcp:`暂无匹配的 MCP 服务`,toolCount:`{count} 个工具`,mcpManageTitle:`管理 MCP 服务`}}),r(`en`,{promptSelector:{noMatchSkill:`No matching skills`,skillManageTitle:`Manage skills`,noMatchMcp:`No matching MCP services`,toolCount:`{count} tools`,mcpManageTitle:`Manage MCP services`}}),r(`zh`,{skillSelector:{selectedSkillStart:`[已选技能: {name}`,useSkillToolsHint:`请根据上述技能说明,使用相关工具处理以下问题:
|
|
2145
2151
|
`,loadSkillHint:"请使用 `agent_skill`(action=load)加载「{name}」的完整说明,然后根据说明自主调用相关工具处理以下问题。\n",runSkillHint:"请使用 `agent_skill`(action=run)执行「{name}」技能来处理以下问题",requiredParam:`必填`,optionalParam:`可选`,callParamsPrefix:`,调用参数:`,paramItem:`({flag},{type}:{desc})`,paramJoin:`、`,sentenceEnd:`。
|
|
2146
2152
|
`,selectedMcpContext:`[已选MCP服务: {name}]
|
|
2147
2153
|
请使用「{name}」MCP服务来处理以下问题:
|
|
@@ -2149,7 +2155,7 @@ Click to view assessment details`,reflectionFailedTitle:`Reflection assessment f
|
|
|
2149
2155
|
`,loadSkillHint:'Please use `agent_skill` (action=load) to load the full description of "{name}", then autonomously call relevant tools to handle the following problem.\n',runSkillHint:'Please use `agent_skill` (action=run) to execute the "{name}" skill to handle the following problem',requiredParam:`required`,optionalParam:`optional`,callParamsPrefix:`, parameters: `,paramItem:`({flag}, {type}: {desc})`,paramJoin:`, `,sentenceEnd:`.
|
|
2150
2156
|
`,selectedMcpContext:`[Selected MCP service: {name}]
|
|
2151
2157
|
Please use the "{name}" MCP service to handle the following problem:
|
|
2152
|
-
`,disabledBadge:`Disabled`,disabledTooltip:`Not enabled (won't be auto-injected into the AI prompt), but you can still select and use it manually`,mcpInactiveBadge:`Inactive`,mcpInactiveTooltip:`This service is currently inactive (closed or excluded by the current agent). Selecting it will force-enable it for this request.`,manualUseSuffix:`Manual`}});var
|
|
2158
|
+
`,disabledBadge:`Disabled`,disabledTooltip:`Not enabled (won't be auto-injected into the AI prompt), but you can still select and use it manually`,mcpInactiveBadge:`Inactive`,mcpInactiveTooltip:`This service is currently inactive (closed or excluded by the current agent). Selecting it will force-enable it for this request.`,manualUseSuffix:`Manual`}});var JO=[],YO=0,XO=3e4;async function ZO(e=!1){let t=Date.now();return!e&&JO.length>0&&t-YO<XO?JO:new Promise(e=>{chrome.runtime.sendMessage({type:`GET_SKILL_LIST`},t=>{if(chrome.runtime.lastError||!t?.success){e(JO);return}JO=t.skills||[],YO=Date.now(),e(JO)})})}async function QO(){if(!H.agentPlatform?.connected||(await new Promise(e=>{chrome.storage.local.get([`skillsEnabled`],e)})).skillsEnabled===!1)return!1;try{return(await ek()).length>0}catch{return!1}}async function $O(e=!1){return(await ZO(e)).filter(e=>e.enabled!==!1)}async function ek(e=!1){let t=[...await ZO(e)];return t.sort((e,t)=>(e.enabled===!1)-+(t.enabled===!1)),t}async function tk(e=``){let t=document.getElementById(`skillList`);if(!t)return;let n=await ek(!0),r=e.toLowerCase(),a=n.filter(t=>!e||(t.name||``).toLowerCase().includes(r)||(t.description||``).toLowerCase().includes(r));if(a.length===0){t.innerHTML=`<div class="prompt-empty">${i(`promptSelector.noMatchSkill`)}</div>`,H.selectedSkillIndex=-1;return}H.selectedSkillIndex=0,t.innerHTML=a.map((e,t)=>{let n=e.type===`agent`?`Agent`:`Workflow`,r=e.description||``,a=e.enabled===!1,o=a?`${e.name}\n${i(`skillSelector.disabledTooltip`)}`:e.name;return`
|
|
2153
2159
|
<div class="skill-list-item ${t===0?`selected`:``} ${a?`skill-list-item-disabled`:``}" data-index="${t}" data-skill-name="${W(e.name)}" title="${je(o)}">
|
|
2154
2160
|
<span class="skill-list-item-index">${t+1}</span>
|
|
2155
2161
|
<span class="skill-list-item-icon">🧩</span>
|
|
@@ -2160,15 +2166,15 @@ Please use the "{name}" MCP service to handle the following problem:
|
|
|
2160
2166
|
<span class="skill-list-item-badge">${n}</span>
|
|
2161
2167
|
${a?`<span class="skill-list-item-badge badge-disabled">${i(`skillSelector.disabledBadge`)}</span>`:``}
|
|
2162
2168
|
</div>
|
|
2163
|
-
`}).join(``),t.querySelectorAll(`.skill-list-item`).forEach(e=>{e.addEventListener(`click`,t=>{let r=e.dataset.skillName;
|
|
2169
|
+
`}).join(``),t.querySelectorAll(`.skill-list-item`).forEach(e=>{e.addEventListener(`click`,t=>{let r=e.dataset.skillName;ik(r,n),(t.ctrlKey||t.metaKey)&&kO()})}),sk()}function nk(e){e.forEach((e,t)=>{t===H.selectedSkillIndex?(e.classList.add(`selected`),e.scrollIntoView({block:`nearest`})):e.classList.remove(`selected`)})}function rk(){let e=document.getElementById(`userInput`);if(!e)return;let t=e.value,n=t.lastIndexOf(`/`);n!==-1&&(e.value=t.substring(0,n)),e.focus(),e.selectionStart=e.selectionEnd=e.value.length,ke()}function ik(e,t,{clearTrigger:n=!0}={}){let r=t.find(t=>t.name===e);if(!r)return;let i=H.selectedSkills.findIndex(t=>t.name===e);if(i>=0?H.selectedSkills.splice(i,1):H.selectedSkills.push({name:r.name,description:r.description||``,type:r.type||`agent`,stepCount:r.stepCount||0,parameters:r.parameters||{},enabled:r.enabled!==!1}),sk(),ok(),n)rk();else{let e=document.getElementById(`userInput`);e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length),ke()}o.debug(`[SidePanel] skill toggled:`,r.name,`count:`,H.selectedSkills.length)}function ak(){H.selectedSkills=[],H.selectedSkillIndex=-1,ok(),sk(),o.debug(`[SidePanel] skill clearedselect`)}function ok(){let e=document.getElementById(`skillIndicator`);if(e){if(H.selectedSkills.length===0){e.style.display=`none`,e.innerHTML=``;return}e.innerHTML=H.selectedSkills.map(e=>{let t=e.enabled===!1,n=t?`${e.name} (${i(`skillSelector.manualUseSuffix`)})`:e.name,r=t?i(`skillSelector.disabledTooltip`):e.name;return`
|
|
2164
2170
|
<span class="ref-chip skill-ref-chip${t?` skill-ref-chip-manual`:``}">
|
|
2165
2171
|
<span class="ref-chip-name" title="${je(r)}">🧩 ${W(n)}</span>
|
|
2166
2172
|
<button class="ref-chip-close" data-skill-name="${je(e.name)}" title="${i(`common.delete`)}">✕</button>
|
|
2167
2173
|
</span>
|
|
2168
|
-
`}).join(``),e.querySelectorAll(`.ref-chip-close`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),H.selectedSkills=H.selectedSkills.filter(t=>t.name!==e.dataset.skillName),
|
|
2174
|
+
`}).join(``),e.querySelectorAll(`.ref-chip-close`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),H.selectedSkills=H.selectedSkills.filter(t=>t.name!==e.dataset.skillName),ok(),sk()})}),e.style.display=`flex`}}function sk(){let e=new Set(H.selectedSkills.map(e=>e.name));document.querySelectorAll(`.skill-list-item, .merged-skill-item`).forEach(t=>{t.classList.toggle(`picked`,e.has(t.dataset.skillName))})}function ck(){let e=document.getElementById(`skillIndicatorClose`);e&&e.addEventListener(`click`,ak)}async function lk(e){H.activeDropdownTab=e,H.lastActiveDropdownTab=e,H.showMergedList=!1;let t=document.getElementById(`promptList`),n=document.getElementById(`skillList`),r=document.getElementById(`mcpList`),a=document.getElementById(`promptDropdownTabs`),o=document.querySelectorAll(`#promptDropdownTabs .prompt-tab`),s=document.querySelector(`#promptDropdownHeader .prompt-dropdown-header-text`);a&&a.classList.remove(`merged-mode`),o.forEach(t=>{t.classList.toggle(`active`,t.dataset.tab===e)}),e===`skills`?(t&&(t.style.display=`none`),n&&(n.style.display=`block`),r&&(r.style.display=`none`),s&&(s.textContent=i(`promptSelector.switchHintSelect`)),H.selectedPromptIndex=-1,H.selectedMcpServiceIndex=-1,await tk()):e===`mcp`?(t&&(t.style.display=`none`),n&&(n.style.display=`none`),r&&(r.style.display=`block`),s&&(s.textContent=i(`promptSelector.switchHintSelect`)),H.selectedPromptIndex=-1,H.selectedSkillIndex=-1,await hk()):(t&&(t.style.display=`block`),n&&(n.style.display=`none`),r&&(r.style.display=`none`),s&&(s.textContent=i(`promptSelector.switchHint`)),H.selectedSkillIndex=-1,H.selectedMcpServiceIndex=-1);let c=document.querySelector(`#promptDropdownHeader .prompt-manage-btn`),l=document.querySelector(`#promptDropdownHeader .skill-manage-btn`),u=document.querySelector(`#promptDropdownHeader .mcp-manage-btn`);c&&(c.style.display=e===`prompts`?``:`none`),l&&(l.style.display=e===`skills`?``:`none`),u&&(u.style.display=e===`mcp`?``:`none`);let d=document.getElementById(`userInput`);d&&d.focus()}function uk(){let e=document.getElementById(`promptDropdownHeader`);if(!e||e.querySelector(`.skill-manage-btn`))return;let t=document.createElement(`button`);t.className=`skill-manage-btn`,t.title=i(`promptSelector.skillManageTitle`),t.style.display=`none`,t.style.fontSize=`13px`,t.innerHTML=`✚`,t.addEventListener(`click`,e=>{e.stopPropagation(),chrome.runtime.sendMessage({type:`OPEN_OPTIONS_PAGE`,hash:`toolbox`})}),e.appendChild(t)}function dk(){let e=document.getElementById(`promptDropdownTabs`);e&&(uk(),Ck(),e.addEventListener(`click`,e=>{let t=e.target.closest(`.prompt-tab`);if(!t)return;let n=t.dataset.tab;n!==H.activeDropdownTab&&lk(n)}))}async function fk(){if(H.selectedSkills.length===0)return``;let e=[];for(let t of H.selectedSkills){let n=t.type===`agent`,r=i(`skillSelector.selectedSkillStart`,{name:t.name});if(t.description&&(r+=` - ${t.description}`),r+=`]
|
|
2169
2175
|
`,n)try{let e=await new Promise(e=>{chrome.runtime.sendMessage({type:`GET_AGENT_SKILL_PROMPT`,name:t.name},t=>{if(chrome.runtime.lastError||!t?.success){e(null);return}e(t)})});e&&e.prompt?r+=`${e.prompt}\n\n${i(`skillSelector.useSkillToolsHint`)}`:r+=i(`skillSelector.loadSkillHint`,{name:t.name})}catch{r+=i(`skillSelector.loadSkillHint`,{name:t.name})}else{r+=i(`skillSelector.runSkillHint`,{name:t.name});let e=t.parameters;if(e&&e.properties&&Object.keys(e.properties).length>0){let t=e.required||[],n=Object.entries(e.properties).map(([e,n])=>i(`skillSelector.paramItem`,{flag:t.includes(e)?i(`skillSelector.requiredParam`):i(`skillSelector.optionalParam`),type:n.type||`string`,desc:n.description||``})).join(i(`skillSelector.paramJoin`));r+=i(`skillSelector.callParamsPrefix`)+n}r+=i(`skillSelector.sentenceEnd`)}e.push(r)}return e.join(`
|
|
2170
2176
|
|
|
2171
|
-
`)}async function
|
|
2177
|
+
`)}async function pk(){return!H.agentPlatform?.connected||!await new Promise(e=>{chrome.storage.local.get([`mcpEnabled`],t=>e(t.mcpEnabled))})?!1:(await mk()).length>0}async function mk(){return new Promise(e=>{chrome.storage.local.get([`mcpTools`],t=>{let n=t.mcpTools||[],r=new Set(Array.isArray(H.mcpClosedServers)?H.mcpClosedServers:[]),i=new Set(Array.isArray(H.activeAgentMcpExcludedServerIds)?H.activeAgentMcpExcludedServerIds:[]),a=new Map;n.forEach(e=>{let t=e.serverId||`unknown`;a.has(t)||a.set(t,{serverId:t,serverName:e.serverName||t,toolCount:0,effectiveOpen:!r.has(t)&&!i.has(t)}),a.get(t).toolCount++});let o=Array.from(a.values());e([...o.filter(e=>e.effectiveOpen),...o.filter(e=>!e.effectiveOpen)])})})}async function hk(e=``){let t=document.getElementById(`mcpList`);if(!t)return;let n=await mk(),r=e.toLowerCase(),a=n.filter(t=>!e||(t.serverName||``).toLowerCase().includes(r)||(t.serverId||``).toLowerCase().includes(r));if(a.length===0){t.innerHTML=`<div class="prompt-empty">${i(`promptSelector.noMatchMcp`)}</div>`,H.selectedMcpServiceIndex=-1;return}H.selectedMcpServiceIndex=0,t.innerHTML=a.map((e,t)=>{let n=e.effectiveOpen===!1,r=n?`${e.serverName}\n${i(`skillSelector.mcpInactiveTooltip`)}`:e.serverName;return`
|
|
2172
2178
|
<div class="mcp-list-item ${t===0?`selected`:``} ${n?`mcp-list-item-inactive`:``}" data-index="${t}" data-server-id="${W(e.serverId)}" data-server-name="${W(e.serverName)}" title="${je(r)}">
|
|
2173
2179
|
<span class="mcp-list-item-index">${t+1}</span>
|
|
2174
2180
|
<span class="mcp-list-item-icon">🔌</span>
|
|
@@ -2179,49 +2185,49 @@ Please use the "{name}" MCP service to handle the following problem:
|
|
|
2179
2185
|
${n?`<span class="mcp-list-item-badge mcp-badge-inactive">${i(`skillSelector.mcpInactiveBadge`)}</span>`:``}
|
|
2180
2186
|
<span class="mcp-list-item-badge">${i(`promptSelector.toolCount`,{count:e.toolCount})}</span>
|
|
2181
2187
|
</div>
|
|
2182
|
-
`}).join(``),t.querySelectorAll(`.mcp-list-item`).forEach(e=>{e.addEventListener(`click`,t=>{let r=e.dataset.serverId,i=e.dataset.serverName;
|
|
2183
|
-
`)}function
|
|
2188
|
+
`}).join(``),t.querySelectorAll(`.mcp-list-item`).forEach(e=>{e.addEventListener(`click`,t=>{let r=e.dataset.serverId,i=e.dataset.serverName;_k(r,i,n),(t.ctrlKey||t.metaKey)&&kO()})}),xk()}function gk(e){e.forEach((e,t)=>{t===H.selectedMcpServiceIndex?(e.classList.add(`selected`),e.scrollIntoView({block:`nearest`})):e.classList.remove(`selected`)})}function _k(e,t,n,{clearTrigger:r=!0}={}){let i=n?.find(t=>t.serverId===e)?.toolCount||0,a=t||e,s=H.selectedMcpServices.findIndex(e=>e.serverName===a);if(s>=0?H.selectedMcpServices.splice(s,1):H.selectedMcpServices.push({serverId:e,serverName:a,toolCount:i}),xk(),bk(),r)rk();else{let e=document.getElementById(`userInput`);e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length),ke()}o.debug(`[SidePanel] MCP service toggled:`,a,`count:`,H.selectedMcpServices.length)}function vk(){H.selectedMcpServices=[],H.selectedMcpServiceIndex=-1,bk(),xk(),o.debug(`[SidePanel] cleared MCP serviceselect`)}function yk(){return H.selectedMcpServices.length===0?``:H.selectedMcpServices.map(e=>i(`skillSelector.selectedMcpContext`,{name:e.serverName})).join(`
|
|
2189
|
+
`)}function bk(){let e=document.getElementById(`mcpIndicator`);if(e){if(H.selectedMcpServices.length===0){e.style.display=`none`,e.innerHTML=``;return}e.innerHTML=H.selectedMcpServices.map(e=>`
|
|
2184
2190
|
<span class="ref-chip mcp-ref-chip">
|
|
2185
2191
|
<span class="ref-chip-name" title="${je(e.serverName)}">🔌 ${W(e.serverName)}</span>
|
|
2186
2192
|
<button class="ref-chip-close" data-server-name="${je(e.serverName)}" title="${i(`common.delete`)}">✕</button>
|
|
2187
2193
|
</span>
|
|
2188
|
-
`).join(``),e.querySelectorAll(`.ref-chip-close`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),H.selectedMcpServices=H.selectedMcpServices.filter(t=>t.serverName!==e.dataset.serverName),yk(),bk()})}),e.style.display=`flex`}}function bk(){let e=new Set(H.selectedMcpServices.map(e=>e.serverName));document.querySelectorAll(`.mcp-list-item, .merged-mcp-item`).forEach(t=>{t.classList.toggle(`picked`,e.has(t.dataset.serverName))})}function xk(){let e=document.getElementById(`mcpIndicatorClose`);e&&e.addEventListener(`click`,_k)}function Sk(){let e=document.getElementById(`promptDropdownHeader`);if(!e||e.querySelector(`.mcp-manage-btn`))return;let t=document.createElement(`button`);t.className=`mcp-manage-btn`,t.title=i(`promptSelector.mcpManageTitle`),t.style.display=`none`,t.style.fontSize=`13px`,t.innerHTML=`✚`,t.addEventListener(`click`,e=>{e.stopPropagation(),chrome.runtime.sendMessage({type:`OPEN_OPTIONS_PAGE`,hash:`toolbox`})}),e.appendChild(t)}var Ck=[[`🀄`,`mahjong tile red dragon`,`symbols`,`麻将,红中`],[`🃏`,`playing card black joker`,`symbols`,``],[`🅰`,`negative squared latin capital letter a`,`symbols`,``],[`🅱`,`negative squared latin capital letter b`,`symbols`,``],[`🅾`,`negative squared latin capital letter o`,`symbols`,``],[`🅿`,`negative squared latin capital letter p`,`symbols`,``],[`🆎`,`negative squared ab`,`symbols`,``],[`🆑`,`squared cl`,`symbols`,``],[`🆒`,`squared cool`,`symbols`,``],[`🆓`,`squared free`,`symbols`,``],[`🆔`,`squared id`,`symbols`,``],[`🆕`,`squared new`,`symbols`,``],[`🆖`,`squared ng`,`symbols`,``],[`🆗`,`squared ok`,`symbols`,``],[`🆘`,`squared sos`,`symbols`,``],[`🆙`,`squared up with exclamation mark`,`symbols`,``],[`🆚`,`squared vs`,`symbols`,``],[`🇨🇩`,`regional indicator symbol letter c`,`flags`,``],[`🇬🇭`,`regional indicator symbol letter g`,`flags`,``],[`🇲🇳`,`regional indicator symbol letter m`,`flags`,``],[`🇷🇸`,`regional indicator symbol letter r`,`flags`,``],[`🈁`,`squared katakana koko`,`symbols`,``],[`🈂`,`squared katakana sa`,`symbols`,``],[`🈚`,`squared cjk unified ideograph-7121`,`symbols`,``],[`🈯`,`squared cjk unified ideograph-6307`,`symbols`,``],[`🈲`,`squared cjk unified ideograph-7981`,`symbols`,``],[`🈳`,`squared cjk unified ideograph-7a7a`,`symbols`,``],[`🈴`,`squared cjk unified ideograph-5408`,`symbols`,``],[`🈵`,`squared cjk unified ideograph-6e80`,`symbols`,``],[`🈶`,`squared cjk unified ideograph-6709`,`symbols`,``],[`🈷`,`squared cjk unified ideograph-6708`,`symbols`,``],[`🈸`,`squared cjk unified ideograph-7533`,`symbols`,``],[`🈹`,`squared cjk unified ideograph-5272`,`symbols`,``],[`🈺`,`squared cjk unified ideograph-55b6`,`symbols`,``],[`🉐`,`circled ideograph advantage`,`symbols`,``],[`🉑`,`circled ideograph accept`,`symbols`,``],[`🌀`,`cyclone`,`symbols`,`台风,龙卷风,旋风`],[`🌁`,`foggy`,`symbols`,`雾,雾霾,朦胧`],[`🌂`,`closed umbrella`,`symbols`,``],[`🌃`,`night with stars`,`symbols`,`夜晚,星空,城市`],[`🌄`,`sunrise over mountains`,`symbols`,`日出,山,早晨`],[`🌅`,`sunrise`,`symbols`,`日出,太阳,早晨`],[`🌆`,`cityscape at dusk`,`symbols`,`黄昏,傍晚,城市`],[`🌇`,`sunset over buildings`,`symbols`,`日落,黄昏`],[`🌈`,`rainbow`,`symbols`,`彩虹,雨后`],[`🌉`,`bridge at night`,`symbols`,`桥,大桥`],[`🌊`,`water wave`,`symbols`,`海浪,波浪,海`],[`🌋`,`volcano`,`symbols`,`火山,爆发`],[`🌌`,`milky way`,`symbols`,``],[`🌍`,`earth globe europe-africa`,`symbols`,``],[`🌎`,`earth globe americas`,`symbols`,`地球,美洲`],[`🌏`,`earth globe asia-australia`,`symbols`,`地球,亚洲`],[`🌐`,`globe with meridians`,`symbols`,``],[`🌑`,`new moon symbol`,`symbols`,``],[`🌒`,`waxing crescent moon symbol`,`symbols`,``],[`🌓`,`first quarter moon symbol`,`symbols`,``],[`🌔`,`waxing gibbous moon symbol`,`symbols`,``],[`🌕`,`full moon symbol`,`symbols`,``],[`🌖`,`waning gibbous moon symbol`,`symbols`,``],[`🌗`,`last quarter moon symbol`,`symbols`,``],[`🌘`,`waning crescent moon symbol`,`symbols`,``],[`🌙`,`crescent moon`,`symbols`,``],[`🌚`,`new moon with face`,`symbols`,``],[`🌛`,`first quarter moon with face`,`symbols`,``],[`🌜`,`last quarter moon with face`,`symbols`,``],[`🌝`,`full moon with face`,`symbols`,``],[`🌞`,`sun with face`,`symbols`,``],[`🌟`,`glowing star`,`symbols`,`星星,闪光,闪耀`],[`🌠`,`shooting star`,`symbols`,``],[`🌡`,`thermometer`,`symbols`,``],[`🌤`,`white sun with small cloud`,`symbols`,``],[`🌥`,`white sun behind cloud`,`symbols`,``],[`🌦`,`white sun behind cloud with rain`,`symbols`,``],[`🌧`,`cloud with rain`,`symbols`,``],[`🌨`,`cloud with snow`,`symbols`,``],[`🌩`,`cloud with lightning`,`symbols`,``],[`🌪`,`cloud with tornado`,`symbols`,``],[`🌫`,`fog`,`symbols`,``],[`🌬`,`wind blowing face`,`symbols`,``],[`🌭`,`hot dog`,`food`,`热狗`],[`🌮`,`taco`,`food`,`墨西哥卷饼`],[`🌯`,`burrito`,`food`,`墨西哥卷,卷饼`],[`🌰`,`chestnut`,`food`,`栗子,坚果`],[`🌱`,`seedling`,`food`,``],[`🌲`,`evergreen tree`,`food`,`松树,树`],[`🌳`,`deciduous tree`,`food`,`树,大树`],[`🌴`,`palm tree`,`food`,`棕榈树,热带,度假`],[`🌵`,`cactus`,`food`,`仙人掌,沙漠`],[`🌶`,`hot pepper`,`food`,``],[`🌷`,`tulip`,`food`,`郁金香,花`],[`🌸`,`cherry blossom`,`food`,`樱花,花,春天`],[`🌹`,`rose`,`food`,`玫瑰,花,爱情`],[`🌺`,`hibiscus`,`food`,`花,芙蓉`],[`🌻`,`sunflower`,`food`,`向日葵,花,太阳`],[`🌼`,`blossom`,`food`,`雏菊,花`],[`🌽`,`ear of maize`,`food`,`玉米`],[`🌾`,`ear of rice`,`food`,``],[`🌿`,`herb`,`food`,`草,植物,草药`],[`🍀`,`four leaf clover`,`food`,`四叶草,幸运,好运`],[`🍁`,`maple leaf`,`food`,`枫叶,秋天,红叶`],[`🍂`,`fallen leaf`,`food`,`落叶,秋天`],[`🍃`,`leaf fluttering in wind`,`food`,`树叶,风`],[`🍄`,`mushroom`,`food`,`蘑菇,菌`],[`🍅`,`tomato`,`food`,`番茄,西红柿`],[`🍆`,`aubergine`,`food`,`茄子`],[`🍇`,`grapes`,`food`,`葡萄`],[`🍈`,`melon`,`food`,`哈密瓜,甜瓜`],[`🍉`,`watermelon`,`food`,`西瓜`],[`🍊`,`tangerine`,`food`,`橙子,橘子`],[`🍋`,`lemon`,`food`,`柠檬`],[`🍌`,`banana`,`food`,`香蕉`],[`🍍`,`pineapple`,`food`,`菠萝`],[`🍎`,`red apple`,`food`,`苹果`],[`🍏`,`green apple`,`food`,``],[`🍐`,`pear`,`food`,`梨`],[`🍑`,`peach`,`food`,`桃子,蜜桃`],[`🍒`,`cherries`,`food`,`樱桃,车厘子`],[`🍓`,`strawberry`,`food`,`草莓`],[`🍔`,`hamburger`,`food`,`汉堡,汉堡包`],[`🍕`,`slice of pizza`,`food`,`披萨,比萨`],[`🍖`,`meat on bone`,`food`,`骨头,肉,排骨`],[`🍗`,`poultry leg`,`food`,`鸡腿,炸鸡`],[`🍘`,`rice cracker`,`food`,`米饼,仙贝`],[`🍙`,`rice ball`,`food`,`饭团`],[`🍚`,`cooked rice`,`food`,`米饭,饭`],[`🍛`,`curry and rice`,`food`,`咖喱,咖喱饭`],[`🍜`,`steaming bowl`,`food`,`面条,拉面,面`],[`🍝`,`spaghetti`,`food`,`意大利面,意面`],[`🍞`,`bread`,`food`,`面包`],[`🍟`,`french fries`,`food`,`薯条,炸薯条`],[`🍠`,`roasted sweet potato`,`food`,`红薯,地瓜`],[`🍡`,`dango`,`food`,`团子,丸子`],[`🍢`,`oden`,`food`,`关东煮,串`],[`🍣`,`sushi`,`food`,`寿司,三文鱼`],[`🍤`,`fried shrimp`,`food`,`炸虾,天妇罗`],[`🍥`,`fish cake with swirl design`,`food`,`鱼板,鸣门卷`],[`🍦`,`soft ice cream`,`food`,`冰淇淋,甜筒`],[`🍧`,`shaved ice`,`food`,`刨冰,冰沙`],[`🍨`,`ice cream`,`food`,`冰淇淋,圣代`],[`🍩`,`doughnut`,`food`,``],[`🍪`,`cookie`,`food`,``],[`🍫`,`chocolate bar`,`food`,`巧克力`],[`🍬`,`candy`,`food`,`糖果,糖`],[`🍭`,`lollipop`,`food`,`棒棒糖`],[`🍮`,`custard`,`food`,`布丁,焦糖`],[`🍯`,`honey pot`,`food`,`蜂蜜,蜜`],[`🍰`,`shortcake`,`food`,`蛋糕,奶油蛋糕`],[`🍱`,`bento box`,`food`,`便当,盒饭`],[`🍲`,`pot of food`,`food`,`火锅,汤锅,炖菜`],[`🍳`,`cooking`,`food`,`煎蛋,鸡蛋`],[`🍴`,`fork and knife`,`food`,`刀叉,餐具`],[`🍵`,`teacup without handle`,`food`,`绿茶,茶,抹茶`],[`🍶`,`sake bottle and cup`,`food`,`清酒,日本酒`],[`🍷`,`wine glass`,`food`,`红酒,葡萄酒,酒`],[`🍸`,`cocktail glass`,`food`,`鸡尾酒,马提尼`],[`🍹`,`tropical drink`,`food`,`果汁,鸡尾酒`],[`🍺`,`beer mug`,`food`,`啤酒,啤酒杯`],[`🍻`,`clinking beer mugs`,`food`,`干杯,碰杯,啤酒`],[`🍼`,`baby bottle`,`food`,`奶瓶,婴儿,奶粉`],[`🍽`,`fork and knife with plate`,`food`,``],[`🍾`,`bottle with popping cork`,`food`,`香槟,起泡酒,庆祝`],[`🍿`,`popcorn`,`food`,``],[`🎀`,`ribbon`,`activity`,`蝴蝶结,礼物,装饰`],[`🎁`,`wrapped present`,`activity`,`礼物,礼盒,生日`],[`🎂`,`birthday cake`,`activity`,`生日蛋糕,生日,蛋糕`],[`🎃`,`jack-o-lantern`,`activity`,``],[`🎄`,`christmas tree`,`activity`,``],[`🎅`,`father christmas`,`activity`,`圣诞老人,圣诞,圣诞节`],[`🎆`,`fireworks`,`activity`,``],[`🎇`,`firework sparkler`,`activity`,``],[`🎈`,`balloon`,`activity`,`气球,庆祝,派对`],[`🎉`,`party popper`,`activity`,`彩带,庆祝,派对,欢呼`],[`🎊`,`confetti ball`,`activity`,`庆祝`],[`🎋`,`tanabata tree`,`activity`,``],[`🎌`,`crossed flags`,`flags`,`旗,日本,交叉旗`],[`🎍`,`pine decoration`,`activity`,``],[`🎎`,`japanese dolls`,`activity`,`人偶,日本人偶`],[`🎏`,`carp streamer`,`activity`,`鲤鱼旗,日本,端午节`],[`🎐`,`wind chime`,`activity`,`风铃,夏天`],[`🎑`,`moon viewing ceremony`,`activity`,``],[`🎒`,`school satchel`,`activity`,`书包,背包`],[`🎓`,`graduation cap`,`activity`,`学士帽,毕业,学位`],[`🎖`,`military medal`,`activity`,``],[`🎗`,`reminder ribbon`,`activity`,``],[`🎙`,`studio microphone`,`activity`,``],[`🎚`,`level slider`,`activity`,``],[`🎛`,`control knobs`,`activity`,``],[`🎞`,`film frames`,`activity`,``],[`🎟`,`admission tickets`,`activity`,``],[`🎠`,`carousel horse`,`activity`,`旋转木马,游乐园`],[`🎡`,`ferris wheel`,`activity`,`摩天轮,游乐园`],[`🎢`,`roller coaster`,`activity`,`过山车,游乐园`],[`🎣`,`fishing pole and fish`,`activity`,`钓鱼`],[`🎤`,`microphone`,`activity`,`麦克风,唱歌,K歌`],[`🎥`,`movie camera`,`activity`,`摄影机,电影,拍摄`],[`🎦`,`cinema`,`activity`,``],[`🎧`,`headphone`,`activity`,`耳机,听歌,音乐,戴`],[`🎨`,`artist palette`,`activity`,`调色板,画画,美术,艺术`],[`🎩`,`top hat`,`activity`,`礼帽,魔术帽,帽子`],[`🎪`,`circus tent`,`activity`,`马戏团`],[`🎫`,`ticket`,`activity`,`门票,票,入场券`],[`🎬`,`clapper board`,`activity`,`场记板,电影,拍戏,导演`],[`🎭`,`performing arts`,`activity`,`面具,戏剧,表演,舞台`],[`🎮`,`video game`,`activity`,`游戏机,游戏,手柄,玩`],[`🎯`,`direct hit`,`activity`,`目标`],[`🎰`,`slot machine`,`activity`,``],[`🎱`,`billiards`,`activity`,`台球`],[`🎲`,`game die`,`activity`,`骰子,赌博,游戏`],[`🎳`,`bowling`,`activity`,`保龄球,球`],[`🎴`,`flower playing cards`,`activity`,`花牌,卡牌,纸牌`],[`🎵`,`musical note`,`activity`,`音符,音乐,歌`],[`🎶`,`multiple musical notes`,`activity`,`音符,音乐,唱歌`],[`🎷`,`saxophone`,`activity`,`萨克斯,爵士,乐器`],[`🎸`,`guitar`,`activity`,`吉他,弹吉他,摇滚`],[`🎹`,`musical keyboard`,`activity`,`钢琴,键盘,弹琴`],[`🎺`,`trumpet`,`activity`,`小号,喇叭,乐器`],[`🎻`,`violin`,`activity`,`小提琴,弦乐`],[`🎼`,`musical score`,`activity`,`乐谱,音乐,谱`],[`🎽`,`running shirt with sash`,`activity`,`背心`],[`🎾`,`tennis racquet and ball`,`activity`,`网球,球`],[`🎿`,`ski and ski boot`,`activity`,`滑雪`],[`🏀`,`basketball and hoop`,`activity`,`篮球,球`],[`🏁`,`chequered flag`,`flags`,`终点,旗帜,赛车,比赛`],[`🏂`,`snowboarder`,`activity`,``],[`🏃`,`runner`,`activity`,`跑步,跑,奔跑`],[`🏄`,`surfer`,`activity`,``],[`🏅`,`sports medal`,`activity`,`奖牌,奖章,荣誉`],[`🏆`,`trophy`,`activity`,``],[`🏇`,`horse racing`,`activity`,``],[`🏈`,`american football`,`activity`,`橄榄球,美式足球`],[`🏉`,`rugby football`,`activity`,`橄榄球,英式`],[`🏊`,`swimmer`,`activity`,``],[`🏋`,`weight lifter`,`activity`,``],[`🏌`,`golfer`,`activity`,``],[`🏍`,`racing motorcycle`,`activity`,``],[`🏎`,`racing car`,`activity`,``],[`🏏`,`cricket bat and ball`,`activity`,``],[`🏐`,`volleyball`,`activity`,`排球,球`],[`🏑`,`field hockey stick and ball`,`activity`,``],[`🏒`,`ice hockey stick and puck`,`activity`,``],[`🏓`,`table tennis paddle and ball`,`activity`,`乒乓球,乒乓,球`],[`🏔`,`snow capped mountain`,`activity`,``],[`🏕`,`camping`,`activity`,``],[`🏖`,`beach with umbrella`,`activity`,``],[`🏗`,`building construction`,`activity`,``],[`🏘`,`house buildings`,`activity`,``],[`🏙`,`cityscape`,`activity`,``],[`🏚`,`derelict house building`,`activity`,``],[`🏛`,`classical building`,`activity`,``],[`🏜`,`desert`,`activity`,``],[`🏝`,`desert island`,`activity`,``],[`🏞`,`national park`,`activity`,``],[`🏟`,`stadium`,`activity`,``],[`🏠`,`house building`,`travel`,`房子,家,住宅`],[`🏡`,`house with garden`,`travel`,`房子,家,花园`],[`🏢`,`office building`,`travel`,`办公楼,大楼,写字楼`],[`🏣`,`japanese post office`,`travel`,`邮局,邮政`],[`🏤`,`european post office`,`travel`,`邮局`],[`🏥`,`hospital`,`travel`,`医院,医疗`],[`🏦`,`bank`,`travel`,`银行,金融`],[`🏧`,`automated teller machine`,`travel`,``],[`🏨`,`hotel`,`travel`,`酒店,旅馆`],[`🏩`,`love hotel`,`travel`,`爱情旅馆,酒店`],[`🏪`,`convenience store`,`travel`,`便利店,商店`],[`🏫`,`school`,`travel`,`学校,校园`],[`🏬`,`department store`,`travel`,`商场,百货,购物`],[`🏭`,`factory`,`travel`,`工厂,工业`],[`🏮`,`izakaya lantern`,`travel`,``],[`🏯`,`japanese castle`,`objects`,`城堡,日本城堡`],[`🏰`,`european castle`,`travel`,`城堡,童话`],[`🏳`,`waving white flag`,`flags`,``],[`🏴`,`waving black flag`,`flags`,`黑旗`],[`🏵`,`rosette`,`objects`,``],[`🏷`,`label`,`objects`,``],[`🏸`,`badminton racquet and shuttlecock`,`activity`,`羽毛球,球`],[`🏹`,`bow and arrow`,`activity`,`射箭,弓箭,弓`],[`🏺`,`amphora`,`activity`,`陶罐,花瓶,双耳瓶`],[`🏻`,`emoji modifier fitzpatrick type-1-2`,`symbols`,``],[`🏼`,`emoji modifier fitzpatrick type-3`,`symbols`,``],[`🏽`,`emoji modifier fitzpatrick type-4`,`symbols`,``],[`🏾`,`emoji modifier fitzpatrick type-5`,`symbols`,``],[`🏿`,`emoji modifier fitzpatrick type-6`,`symbols`,``],[`🐀`,`rat`,`animals`,`老鼠,鼠`],[`🐁`,`mouse`,`animals`,`老鼠,鼠`],[`🐂`,`ox`,`animals`,`公牛,牛`],[`🐃`,`water buffalo`,`animals`,`水牛,牛`],[`🐄`,`cow`,`animals`,`奶牛,牛`],[`🐅`,`tiger`,`animals`,``],[`🐆`,`leopard`,`animals`,``],[`🐇`,`rabbit`,`animals`,`兔子,兔`],[`🐈`,`cat`,`animals`,`猫,猫咪`],[`🐉`,`dragon`,`animals`,`龙,中国龙`],[`🐊`,`crocodile`,`animals`,`鳄鱼,短吻鳄`],[`🐋`,`whale`,`animals`,`鲸鱼`],[`🐌`,`snail`,`animals`,``],[`🐍`,`snake`,`animals`,`蛇,爬行动物`],[`🐎`,`horse`,`animals`,``],[`🐏`,`ram`,`animals`,`羊,公羊`],[`🐐`,`goat`,`animals`,`山羊,羊`],[`🐑`,`sheep`,`animals`,`羊,绵羊`],[`🐒`,`monkey`,`animals`,``],[`🐓`,`rooster`,`animals`,`公鸡,鸡`],[`🐔`,`chicken`,`animals`,`鸡,母鸡`],[`🐕`,`dog`,`animals`,`狗,小狗`],[`🐖`,`pig`,`animals`,`猪`],[`🐗`,`boar`,`animals`,`野猪,猪`],[`🐘`,`elephant`,`animals`,`大象`],[`🐙`,`octopus`,`animals`,`章鱼,八爪鱼`],[`🐚`,`spiral shell`,`animals`,``],[`🐛`,`bug`,`animals`,``],[`🐜`,`ant`,`animals`,``],[`🐝`,`honeybee`,`animals`,``],[`🐞`,`lady beetle`,`animals`,``],[`🐟`,`fish`,`animals`,`鱼,鱼`],[`🐠`,`tropical fish`,`animals`,`热带鱼,鱼`],[`🐡`,`blowfish`,`animals`,`河豚,鱼`],[`🐢`,`turtle`,`animals`,`乌龟,慢`],[`🐣`,`hatching chick`,`animals`,`小鸡,破壳,孵化`],[`🐤`,`baby chick`,`animals`,`小鸡,黄,可爱`],[`🐥`,`front-facing baby chick`,`animals`,`小鸡,正面`],[`🐦`,`bird`,`animals`,`鸟`],[`🐧`,`penguin`,`animals`,`企鹅,南极`],[`🐨`,`koala`,`animals`,`考拉,无尾熊`],[`🐩`,`poodle`,`animals`,`贵宾犬,狗`],[`🐪`,`dromedary camel`,`animals`,`骆驼`],[`🐫`,`bactrian camel`,`animals`,`骆驼,双峰`],[`🐬`,`dolphin`,`animals`,`海豚,海洋`],[`🐭`,`mouse face`,`animals`,`老鼠,鼠`],[`🐮`,`cow face`,`animals`,`牛,奶牛`],[`🐯`,`tiger face`,`animals`,``],[`🐰`,`rabbit face`,`animals`,`兔子,兔,可爱`],[`🐱`,`cat face`,`animals`,``],[`🐲`,`dragon face`,`animals`,`龙,龙头`],[`🐳`,`spouting whale`,`animals`,`鲸鱼,喷水`],[`🐴`,`horse face`,`animals`,`马`],[`🐵`,`monkey face`,`animals`,``],[`🐶`,`dog face`,`animals`,``],[`🐷`,`pig face`,`animals`,`猪,猪头`],[`🐸`,`frog face`,`animals`,`青蛙,蛙`],[`🐹`,`hamster face`,`animals`,`仓鼠`],[`🐺`,`wolf face`,`animals`,``],[`🐻`,`bear face`,`animals`,`熊,泰迪熊`],[`🐼`,`panda face`,`animals`,``],[`🐽`,`pig nose`,`animals`,`猪鼻子,猪`],[`🐾`,`paw prints`,`animals`,`爪印,脚印`],[`🐿`,`chipmunk`,`animals`,``],[`👀`,`eyes`,`people`,``],[`👁`,`eye`,`people`,``],[`👂`,`ear`,`people`,`耳朵,听`],[`👃`,`nose`,`people`,`鼻子,闻`],[`👄`,`mouth`,`people`,`嘴巴,嘴唇,吻`],[`👅`,`tongue`,`people`,`舌头,舔`],[`👆`,`white up pointing backhand index`,`people`,`指,上面,向上`],[`👇`,`white down pointing backhand index`,`people`,`指,下面,向下`],[`👈`,`white left pointing backhand index`,`people`,`指,左边,指向`],[`👉`,`white right pointing backhand index`,`people`,`指,右边,指向`],[`👊`,`fisted hand sign`,`people`,`拳头,打,战斗`],[`👋`,`waving hand sign`,`people`,`挥手,再见,你好`],[`👌`,`ok hand sign`,`people`,`OK,好,可以`],[`👍`,`thumbs up sign`,`people`,`点赞,好,赞,棒`],[`👎`,`thumbs down sign`,`people`,`差评,不好,踩`],[`👏`,`clapping hands sign`,`people`,`鼓掌,拍手,掌声`],[`👐`,`open hands sign`,`people`,`张开,手,开放`],[`👑`,`crown`,`people`,`皇冠,王冠,国王,女王`],[`👒`,`womans hat`,`people`,`帽子,草帽,遮阳帽`],[`👓`,`eyeglasses`,`people`,`眼镜`],[`👔`,`necktie`,`people`,`领带,西装,工作`],[`👕`,`t-shirt`,`people`,`衣服,T恤`],[`👖`,`jeans`,`people`,`裤子,牛仔裤`],[`👗`,`dress`,`people`,`裙子,连衣裙`],[`👘`,`kimono`,`people`,`和服`],[`👙`,`bikini`,`people`,`比基尼,泳装`],[`👚`,`womans clothes`,`people`,`女装,衣服`],[`👛`,`purse`,`people`,`钱包,小包`],[`👜`,`handbag`,`people`,`手提包,包包`],[`👝`,`pouch`,`people`,`手拿包,包包`],[`👞`,`mans shoe`,`people`,`皮鞋,鞋`],[`👟`,`athletic shoe`,`people`,`运动鞋,跑鞋`],[`👠`,`high-heeled shoe`,`people`,`高跟鞋,鞋`],[`👡`,`womans sandal`,`people`,`凉鞋,鞋`],[`👢`,`womans boots`,`people`,`靴子,长靴`],[`👣`,`footprints`,`people`,`脚印,脚步,足迹`],[`👤`,`bust in silhouette`,`people`,`人,剪影,用户`],[`👥`,`busts in silhouette`,`people`,`人群,人,多个人`],[`👦`,`boy`,`people`,`男孩,小男孩`],[`👧`,`girl`,`people`,`女孩,小女孩`],[`👨`,`man`,`people`,`男人,男士`],[`👩`,`woman`,`people`,`女人,女士`],[`👪`,`family`,`people`,`家庭`],[`👫`,`woman and man holding hands`,`people`,``],[`👬`,`men holding hands`,`people`,``],[`👭`,`women holding hands`,`people`,``],[`👮`,`police officer`,`people`,`警察,警官`],[`👯`,`woman with bunny ears`,`people`,`兔子舞,蹦迪,派对`],[`👰`,`bride with veil`,`people`,`新娘,婚纱,结婚`],[`👱`,`person with blond hair`,`people`,``],[`👲`,`man with gua pi mao`,`people`,`中国人`],[`👳`,`man with turban`,`people`,`包头巾,印度,阿拉伯`],[`👴`,`older man`,`people`,`老人,老爷爷`],[`👵`,`older woman`,`people`,`老人,老奶奶`],[`👶`,`baby`,`people`,`婴儿,宝宝,小孩`],[`👷`,`construction worker`,`people`,`工人`],[`👸`,`princess`,`people`,`公主,女王`],[`👹`,`japanese ogre`,`people`,`妖怪,鬼,怪物`],[`👺`,`japanese goblin`,`people`,`天狗,怪物,鬼`],[`👻`,`ghost`,`people`,`幽灵,鬼,万圣节`],[`👼`,`baby angel`,`people`,`天使,婴儿,可爱`],[`👽`,`extraterrestrial alien`,`people`,`外星人,ET,飞碟`],[`👾`,`alien monster`,`people`,`外星人,怪兽,游戏`],[`👿`,`imp`,`people`,`恶魔,愤怒`],[`💀`,`skull`,`people`,`骷髅,死亡,骨头`],[`💁`,`information desk person`,`people`,``],[`💂`,`guardsman`,`people`,`卫兵,士兵`],[`💃`,`dancer`,`people`,`跳舞,舞女,跳舞`],[`💄`,`lipstick`,`people`,`口红,化妆`],[`💅`,`nail polish`,`people`,`美甲,指甲,涂`],[`💆`,`face massage`,`people`,`按摩,放松,头部`],[`💇`,`haircut`,`people`,`理发,剪发,发型`],[`💈`,`barber pole`,`people`,`理发店,理发`],[`💉`,`syringe`,`people`,`注射器,针,疫苗`],[`💊`,`pill`,`people`,`药丸,药,胶囊`],[`💋`,`kiss mark`,`people`,`吻,口红印,亲亲`],[`💌`,`love letter`,`people`,`情书,信,爱情`],[`💍`,`ring`,`people`,`戒指,钻戒,结婚`],[`💎`,`gem stone`,`people`,`钻石,宝石,珠宝`],[`💏`,`kiss`,`people`,``],[`💐`,`bouquet`,`smileys`,`花束,花,礼物`],[`💑`,`couple with heart`,`smileys`,``],[`💒`,`wedding`,`smileys`,`教堂,婚礼,教堂婚礼`],[`💓`,`beating heart`,`smileys`,`爱心,跳动,心跳`],[`💔`,`broken heart`,`smileys`,`心碎,伤心,破碎`],[`💕`,`two hearts`,`smileys`,`爱心,两个,喜欢`],[`💖`,`sparkling heart`,`smileys`,`爱心,闪光,喜欢`],[`💗`,`growing heart`,`smileys`,`爱心,跳动,喜欢`],[`💘`,`heart with arrow`,`smileys`,`爱心,箭,丘比特`],[`💙`,`blue heart`,`smileys`,``],[`💚`,`green heart`,`smileys`,``],[`💛`,`yellow heart`,`smileys`,``],[`💜`,`purple heart`,`smileys`,``],[`💝`,`heart with ribbon`,`smileys`,`爱心,礼物,蝴蝶结`],[`💞`,`revolving hearts`,`smileys`,`爱心,旋转,轮回`],[`💟`,`heart decoration`,`smileys`,`爱心,符号`],[`💠`,`diamond shape with a dot inside`,`objects`,``],[`💡`,`electric light bulb`,`objects`,``],[`💢`,`anger symbol`,`objects`,`生气,怒气`],[`💣`,`bomb`,`objects`,`炸弹,爆炸`],[`💤`,`sleeping symbol`,`objects`,`睡觉,打呼,困`],[`💥`,`collision symbol`,`objects`,``],[`💦`,`splashing sweat symbol`,`objects`,`汗,水,泪`],[`💧`,`droplet`,`objects`,`水滴,水,眼泪`],[`💨`,`dash symbol`,`objects`,`风,跑,快,烟雾`],[`💩`,`pile of poo`,`objects`,`大便,屎,狗屎`],[`💪`,`flexed biceps`,`people`,`肌肉,力量,加油,强壮`],[`💫`,`dizzy symbol`,`objects`,`星星,旋转`],[`💬`,`speech balloon`,`objects`,`对话,聊天`],[`💭`,`thought balloon`,`objects`,`想法,思考,气泡`],[`💮`,`white flower`,`objects`,``],[`💯`,`hundred points symbol`,`objects`,``],[`💰`,`money bag`,`objects`,`钱袋,钱,金钱`],[`💱`,`currency exchange`,`objects`,``],[`💲`,`heavy dollar sign`,`objects`,``],[`💳`,`credit card`,`objects`,`信用卡,银行卡,支付`],[`💴`,`banknote with yen sign`,`objects`,`日元,日圆,钱`],[`💵`,`banknote with dollar sign`,`objects`,`美元,美金,钱`],[`💶`,`banknote with euro sign`,`objects`,`欧元,钱`],[`💷`,`banknote with pound sign`,`objects`,`英镑,钱`],[`💸`,`money with wings`,`objects`,`钱,飞钱,花钱`],[`💹`,`chart with upwards trend and yen sign`,`objects`,`股票,上涨,图表,增长`],[`💺`,`seat`,`objects`,`座位,椅子,飞机座位`],[`💻`,`personal computer`,`objects`,`电脑,笔记本,笔记本电脑`],[`💼`,`briefcase`,`objects`,`公文包,工作,商务`],[`💽`,`minidisc`,`objects`,`光盘,磁盘`],[`💾`,`floppy disk`,`objects`,`软盘,保存`],[`💿`,`optical disc`,`objects`,`光盘,CD`],[`📀`,`dvd`,`objects`,`光盘,DVD`],[`📁`,`file folder`,`objects`,`文件夹`],[`📂`,`open file folder`,`objects`,`文件夹,打开`],[`📃`,`page with curl`,`objects`,`文件,文档`],[`📄`,`page facing up`,`objects`,`文件,文档,纸`],[`📅`,`calendar`,`objects`,`日历`],[`📆`,`tear-off calendar`,`objects`,`日历,日历页`],[`📇`,`card index`,`objects`,`名片,索引卡`],[`📈`,`chart with upwards trend`,`objects`,``],[`📉`,`chart with downwards trend`,`objects`,``],[`📊`,`bar chart`,`objects`,``],[`📋`,`clipboard`,`objects`,`剪贴板,清单,列表`],[`📌`,`pushpin`,`objects`,``],[`📍`,`round pushpin`,`objects`,``],[`📎`,`paperclip`,`objects`,``],[`📏`,`straight ruler`,`objects`,``],[`📐`,`triangular ruler`,`objects`,``],[`📑`,`bookmark tabs`,`objects`,`书签,标签,文件`],[`📒`,`ledger`,`objects`,``],[`📓`,`notebook`,`objects`,``],[`📔`,`notebook with decorative cover`,`objects`,``],[`📕`,`closed book`,`objects`,``],[`📖`,`open book`,`objects`,``],[`📗`,`green book`,`objects`,``],[`📘`,`blue book`,`objects`,``],[`📙`,`orange book`,`objects`,``],[`📚`,`books`,`objects`,``],[`📛`,`name badge`,`objects`,``],[`📜`,`scroll`,`objects`,``],[`📝`,`memo`,`objects`,`笔记,备忘录,写作,文档`],[`📞`,`telephone receiver`,`objects`,`电话`],[`📟`,`pager`,`objects`,`寻呼机,传呼机`],[`📠`,`fax machine`,`objects`,`传真机,传真`],[`📡`,`satellite antenna`,`objects`,`天线,卫星,信号`],[`📢`,`public address loudspeaker`,`objects`,``],[`📣`,`cheering megaphone`,`objects`,``],[`📤`,`outbox tray`,`objects`,`发送,输出,上传`],[`📥`,`inbox tray`,`objects`,`接收,下载,收件箱`],[`📦`,`package`,`objects`,`包裹,快递,箱子`],[`📧`,`e-mail symbol`,`objects`,`邮件,电子邮件`],[`📨`,`incoming envelope`,`objects`,`邮件,收到`],[`📩`,`envelope with downwards arrow above`,`objects`,`邮件,发送`],[`📪`,`closed mailbox with lowered flag`,`objects`,`邮箱,关闭`],[`📫`,`closed mailbox with raised flag`,`objects`,`邮箱,信箱,邮件`],[`📬`,`open mailbox with raised flag`,`objects`,`邮箱,有信`],[`📭`,`open mailbox with lowered flag`,`objects`,`邮箱,无信`],[`📮`,`postbox`,`objects`,`邮筒,邮政`],[`📯`,`postal horn`,`objects`,``],[`📰`,`newspaper`,`objects`,`报纸,新闻,报`],[`📱`,`mobile phone`,`objects`,`手机,智能手机,电话`],[`📲`,`mobile phone with rightwards arrow at left`,`objects`,`手机,接收,信号`],[`📳`,`vibration mode`,`objects`,``],[`📴`,`mobile phone off`,`objects`,``],[`📵`,`no mobile phones`,`objects`,``],[`📶`,`antenna with bars`,`objects`,``],[`📷`,`camera`,`objects`,`相机,拍照,照片`],[`📸`,`camera with flash`,`objects`,`相机,闪光灯,拍照`],[`📹`,`video camera`,`objects`,`摄像机,录像`],[`📺`,`television`,`objects`,``],[`📻`,`radio`,`objects`,`收音机,广播`],[`📼`,`videocassette`,`objects`,`录像带,磁带`],[`📽`,`film projector`,`objects`,``],[`📿`,`prayer beads`,`objects`,`念珠,佛珠,项链`],[`🔀`,`twisted rightwards arrows`,`objects`,``],[`🔁`,`clockwise rightwards and leftwards open circle arrows`,`objects`,``],[`🔂`,`clockwise rightwards and leftwards open circle arrows with circled one overlay`,`objects`,``],[`🔃`,`clockwise downwards and upwards open circle arrows`,`objects`,``],[`🔄`,`anticlockwise downwards and upwards open circle arrows`,`objects`,``],[`🔅`,`low brightness symbol`,`objects`,``],[`🔆`,`high brightness symbol`,`objects`,``],[`🔇`,`speaker with cancellation stroke`,`objects`,``],[`🔈`,`speaker`,`objects`,``],[`🔉`,`speaker with one sound wave`,`objects`,``],[`🔊`,`speaker with three sound waves`,`objects`,``],[`🔋`,`battery`,`objects`,``],[`🔌`,`electric plug`,`objects`,``],[`🔍`,`left-pointing magnifying glass`,`objects`,`搜索,放大镜,查找,查询`],[`🔎`,`right-pointing magnifying glass`,`objects`,`搜索,放大镜,查找`],[`🔏`,`lock with ink pen`,`objects`,`锁,保密,笔`],[`🔐`,`closed lock with key`,`objects`,`锁,安全,钥匙`],[`🔑`,`key`,`objects`,`钥匙,解锁`],[`🔒`,`lock`,`objects`,`锁,锁定,安全`],[`🔓`,`open lock`,`objects`,`解锁,打开`],[`🔔`,`bell`,`objects`,``],[`🔕`,`bell with cancellation stroke`,`objects`,``],[`🔖`,`bookmark`,`objects`,`书签,标记`],[`🔗`,`link symbol`,`objects`,``],[`🔘`,`radio button`,`objects`,``],[`🔙`,`back with leftwards arrow above`,`objects`,``],[`🔚`,`end with leftwards arrow above`,`objects`,``],[`🔛`,`on with exclamation mark with left right arrow above`,`objects`,``],[`🔜`,`soon with rightwards arrow above`,`objects`,``],[`🔝`,`top with upwards arrow above`,`objects`,``],[`🔞`,`no one under eighteen symbol`,`objects`,``],[`🔟`,`keycap 10`,`objects`,``],[`🔠`,`input symbol for latin capital letters`,`objects`,``],[`🔡`,`input symbol for latin small letters`,`objects`,``],[`🔢`,`input symbol for numbers`,`objects`,``],[`🔣`,`input symbol for symbols`,`objects`,``],[`🔤`,`input symbol for latin letters`,`objects`,``],[`🔥`,`fire`,`objects`,``],[`🔦`,`electric torch`,`objects`,``],[`🔧`,`wrench`,`objects`,`扳手,工具,维修`],[`🔨`,`hammer`,`objects`,`锤子,工具`],[`🔩`,`nut and bolt`,`objects`,`螺丝,螺母`],[`🔪`,`hocho`,`objects`,``],[`🔫`,`pistol`,`objects`,`枪`],[`🔬`,`microscope`,`objects`,`显微镜,科学,研究`],[`🔭`,`telescope`,`objects`,`望远镜,天文,观察`],[`🔮`,`crystal ball`,`objects`,``],[`🔯`,`six pointed star with middle dot`,`objects`,``],[`🔰`,`japanese symbol for beginner`,`objects`,``],[`🔱`,`trident emblem`,`objects`,``],[`🔲`,`black square button`,`objects`,``],[`🔳`,`white square button`,`objects`,``],[`🔴`,`large red circle`,`objects`,``],[`🔵`,`large blue circle`,`objects`,``],[`🔶`,`large orange diamond`,`objects`,``],[`🔷`,`large blue diamond`,`objects`,``],[`🔸`,`small orange diamond`,`objects`,``],[`🔹`,`small blue diamond`,`objects`,``],[`🔺`,`up-pointing red triangle`,`objects`,``],[`🔻`,`down-pointing red triangle`,`objects`,``],[`🔼`,`up-pointing small red triangle`,`objects`,``],[`🔽`,`down-pointing small red triangle`,`objects`,``],[`🕉`,`om symbol`,`objects`,``],[`🕊`,`dove of peace`,`objects`,``],[`🕋`,`kaaba`,`objects`,`天房,麦加,伊斯兰`],[`🕌`,`mosque`,`objects`,`清真寺,伊斯兰`],[`🕍`,`synagogue`,`objects`,`犹太教堂,犹太`],[`🕎`,`menorah with nine branches`,`objects`,``],[`🕐`,`clock face one oclock`,`objects`,`一点,时钟`],[`🕑`,`clock face two oclock`,`objects`,`两点,时钟`],[`🕒`,`clock face three oclock`,`objects`,`三点,时钟`],[`🕓`,`clock face four oclock`,`objects`,`四点,时钟`],[`🕔`,`clock face five oclock`,`objects`,`五点,时钟`],[`🕕`,`clock face six oclock`,`objects`,`六点,时钟`],[`🕖`,`clock face seven oclock`,`objects`,`七点,时钟`],[`🕗`,`clock face eight oclock`,`objects`,`八点,时钟`],[`🕘`,`clock face nine oclock`,`objects`,`九点,时钟`],[`🕙`,`clock face ten oclock`,`objects`,`十点,时钟`],[`🕚`,`clock face eleven oclock`,`objects`,`十一点,时钟`],[`🕛`,`clock face twelve oclock`,`objects`,`十二点,时钟,时间`],[`🕜`,`clock face one-thirty`,`objects`,``],[`🕝`,`clock face two-thirty`,`objects`,``],[`🕞`,`clock face three-thirty`,`objects`,``],[`🕟`,`clock face four-thirty`,`objects`,``],[`🕠`,`clock face five-thirty`,`objects`,``],[`🕡`,`clock face six-thirty`,`objects`,``],[`🕢`,`clock face seven-thirty`,`objects`,``],[`🕣`,`clock face eight-thirty`,`objects`,``],[`🕤`,`clock face nine-thirty`,`objects`,``],[`🕥`,`clock face ten-thirty`,`objects`,``],[`🕦`,`clock face eleven-thirty`,`objects`,``],[`🕧`,`clock face twelve-thirty`,`objects`,``],[`🕯`,`candle`,`objects`,``],[`🕰`,`mantelpiece clock`,`objects`,``],[`🕳`,`hole`,`objects`,``],[`🕴`,`man in business suit levitating`,`objects`,``],[`🕵`,`sleuth or spy`,`objects`,``],[`🕶`,`dark sunglasses`,`objects`,``],[`🕷`,`spider`,`objects`,``],[`🕸`,`spider web`,`objects`,``],[`🕹`,`joystick`,`objects`,``],[`🕺`,`man dancing`,`objects`,`跳舞,舞男`],[`🖇`,`linked paperclips`,`objects`,``],[`🖊`,`lower left ballpoint pen`,`objects`,``],[`🖋`,`lower left fountain pen`,`objects`,``],[`🖌`,`lower left paintbrush`,`objects`,``],[`🖍`,`lower left crayon`,`objects`,``],[`🖐`,`raised hand with fingers splayed`,`objects`,``],[`🖕`,`reversed hand with middle finger extended`,`objects`,`中指,骂人`],[`🖖`,`raised hand with part between middle and ring fingers`,`objects`,`瓦肯,举手,胜利`],[`🖤`,`black heart`,`objects`,``],[`🖥`,`desktop computer`,`objects`,``],[`🖨`,`printer`,`objects`,``],[`🖱`,`three button mouse`,`objects`,``],[`🖲`,`trackball`,`objects`,``],[`🖼`,`frame with picture`,`objects`,``],[`🗂`,`card index dividers`,`objects`,``],[`🗃`,`card file box`,`objects`,``],[`🗄`,`file cabinet`,`objects`,``],[`🗑`,`wastebasket`,`objects`,``],[`🗒`,`spiral note pad`,`objects`,``],[`🗓`,`spiral calendar pad`,`objects`,``],[`🗜`,`compression`,`objects`,``],[`🗝`,`old key`,`objects`,``],[`🗞`,`rolled-up newspaper`,`objects`,``],[`🗡`,`dagger knife`,`objects`,``],[`🗣`,`speaking head in silhouette`,`objects`,``],[`🗨`,`left speech bubble`,`objects`,``],[`🗯`,`right anger bubble`,`objects`,``],[`🗳`,`ballot box with ballot`,`objects`,``],[`🗺`,`world map`,`objects`,``],[`🗻`,`mount fuji`,`objects`,`富士山,山`],[`🗼`,`tokyo tower`,`objects`,`塔,东京塔`],[`🗽`,`statue of liberty`,`objects`,`自由女神像,纽约`],[`🗾`,`silhouette of japan`,`objects`,``],[`🗿`,`moyai`,`objects`,`雕像`],[`😀`,`grinning face`,`smileys`,`笑脸,开心,高兴`],[`😁`,`grinning face with smiling eyes`,`smileys`,`笑脸,开心`],[`😂`,`face with tears of joy`,`smileys`,`笑哭,大笑,笑`],[`😃`,`smiling face with open mouth`,`smileys`,`笑脸,开心`],[`😄`,`smiling face with open mouth and smiling eyes`,`smileys`,`笑脸,开心`],[`😅`,`smiling face with open mouth and cold sweat`,`smileys`,`笑脸,汗,尴尬`],[`😆`,`smiling face with open mouth and tightly-closed eyes`,`smileys`,`笑脸,大笑`],[`😇`,`smiling face with halo`,`smileys`,`天使,微笑,善良`],[`😈`,`smiling face with horns`,`smileys`,`恶魔,坏笑,邪恶`],[`😉`,`winking face`,`smileys`,`眨眼,调皮`],[`😊`,`smiling face with smiling eyes`,`smileys`,`微笑,开心,脸红`],[`😋`,`face savouring delicious food`,`smileys`,`好吃,美味,舔`],[`😌`,`relieved face`,`smileys`,`放松,安心`],[`😍`,`smiling face with heart-shaped eyes`,`smileys`,`爱,喜欢,花痴`],[`😎`,`smiling face with sunglasses`,`smileys`,`酷,墨镜,帅气`],[`😏`,`smirking face`,`smileys`,`得意,微笑,坏笑`],[`😐`,`neutral face`,`smileys`,`无语,面无表情`],[`😑`,`expressionless face`,`smileys`,`无语,面无表情`],[`😒`,`unamused face`,`smileys`,`不满,无语,翻白眼`],[`😓`,`face with cold sweat`,`smileys`,`冷汗,尴尬`],[`😔`,`pensive face`,`smileys`,`难过,低落`],[`😕`,`confused face`,`smileys`,`困惑,不解`],[`😖`,`confounded face`,`smileys`,`纠结,痛苦`],[`😗`,`kissing face`,`smileys`,`亲亲,吻`],[`😘`,`face throwing a kiss`,`smileys`,`飞吻,亲亲,爱`],[`😙`,`kissing face with smiling eyes`,`smileys`,``],[`😚`,`kissing face with closed eyes`,`smileys`,`亲亲,吻`],[`😛`,`face with stuck-out tongue`,`smileys`,`吐舌头,调皮`],[`😜`,`face with stuck-out tongue and winking eye`,`smileys`,`吐舌头,调皮,眨眼`],[`😝`,`face with stuck-out tongue and tightly-closed eyes`,`smileys`,`吐舌头,调皮`],[`😞`,`disappointed face`,`smileys`,`失望,难过`],[`😟`,`worried face`,`smileys`,`担心,忧虑`],[`😠`,`angry face`,`smileys`,`生气,愤怒`],[`😡`,`pouting face`,`smileys`,`生气,愤怒,红脸`],[`😢`,`crying face`,`smileys`,`哭,伤心,流泪`],[`😣`,`persevering face`,`smileys`,`挣扎,痛苦`],[`😤`,`face with look of triumph`,`smileys`,`生气,冒烟,气`],[`😥`,`disappointed but relieved face`,`smileys`,`难过,失望,松气`],[`😦`,`frowning face with open mouth`,`smileys`,`惊讶,张嘴`],[`😧`,`anguished face`,`smileys`,`震惊,痛苦`],[`😨`,`fearful face`,`smileys`,`害怕,恐惧`],[`😩`,`weary face`,`smileys`,`累,疲惫,哭`],[`😪`,`sleepy face`,`smileys`,`困,想睡`],[`😫`,`tired face`,`smileys`,`累,疲惫`],[`😬`,`grimacing face`,`smileys`,`尴尬,咧嘴`],[`😭`,`loudly crying face`,`smileys`,`大哭,伤心,哭`],[`😮`,`face with open mouth`,`smileys`,`惊讶,哇`],[`😯`,`hushed face`,`smileys`,`惊讶,安静`],[`😰`,`face with open mouth and cold sweat`,`smileys`,`担心,冷汗`],[`😱`,`face screaming in fear`,`smileys`,`尖叫,害怕,恐怖`],[`😲`,`astonished face`,`smileys`,`震惊,惊讶`],[`😳`,`flushed face`,`smileys`,`脸红,害羞,震惊`],[`😴`,`sleeping face`,`smileys`,`睡觉,睡觉`],[`😵`,`dizzy face`,`smileys`,`晕,头晕,死`],[`😶`,`face without mouth`,`smileys`,`沉默,无语`],[`😷`,`face with medical mask`,`smileys`,`生病,口罩,感冒`],[`😸`,`grinning cat face with smiling eyes`,`smileys`,`猫,笑脸`],[`😹`,`cat face with tears of joy`,`smileys`,`猫,笑哭`],[`😺`,`smiling cat face with open mouth`,`smileys`,`猫,笑脸,开心`],[`😻`,`smiling cat face with heart-shaped eyes`,`smileys`,`猫,爱,喜欢`],[`😼`,`cat face with wry smile`,`smileys`,`猫,坏笑`],[`😽`,`kissing cat face with closed eyes`,`smileys`,`猫,亲亲`],[`😾`,`pouting cat face`,`smileys`,`猫,生气`],[`😿`,`crying cat face`,`smileys`,`猫,哭,伤心`],[`🙀`,`weary cat face`,`smileys`,`猫,震惊,害怕`],[`🙁`,`slightly frowning face`,`smileys`,`难过,失望`],[`🙂`,`slightly smiling face`,`smileys`,`微笑,笑`],[`🙃`,`upside-down face`,`smileys`,`微笑,倒`],[`🙄`,`face with rolling eyes`,`smileys`,`翻白眼,无语`],[`🙅`,`face with no good gesture`,`smileys`,``],[`🙆`,`face with ok gesture`,`smileys`,``],[`🙇`,`person bowing deeply`,`smileys`,``],[`🙈`,`see-no-evil monkey`,`smileys`,``],[`🙉`,`hear-no-evil monkey`,`smileys`,``],[`🙊`,`speak-no-evil monkey`,`smileys`,``],[`🙋`,`happy person raising one hand`,`smileys`,``],[`🙌`,`person raising both hands in celebration`,`smileys`,`欢呼,举起,庆祝`],[`🙍`,`person frowning`,`smileys`,``],[`🙎`,`person with pouting face`,`smileys`,``],[`🙏`,`person with folded hands`,`smileys`,`祈祷,拜托,感谢,合十`],[`🚀`,`rocket`,`travel`,`火箭,发射,太空`],[`🚁`,`helicopter`,`travel`,`直升机`],[`🚂`,`steam locomotive`,`travel`,`火车,蒸汽火车`],[`🚃`,`railway car`,`travel`,`电车,火车`],[`🚄`,`high-speed train`,`travel`,`高铁,动车,火车`],[`🚅`,`high-speed train with bullet nose`,`travel`,``],[`🚆`,`train`,`travel`,`火车,铁路`],[`🚇`,`metro`,`travel`,`地铁,地铁站`],[`🚈`,`light rail`,`travel`,`轻轨,轨道交通`],[`🚉`,`station`,`travel`,`火车站,车站`],[`🚊`,`tram`,`travel`,`电车`],[`🚋`,`tram car`,`travel`,`电车,有轨电车`],[`🚌`,`bus`,`travel`,`公交车,巴士`],[`🚍`,`oncoming bus`,`travel`,`公交车`],[`🚎`,`trolleybus`,`travel`,`无轨电车,巴士`],[`🚏`,`bus stop`,`travel`,`公交站,车站`],[`🚐`,`minibus`,`travel`,`面包车,小巴`],[`🚑`,`ambulance`,`travel`,`救护车,急救`],[`🚒`,`fire engine`,`travel`,`消防车,救火`],[`🚓`,`police car`,`travel`,`警车,警察`],[`🚔`,`oncoming police car`,`travel`,`警车,巡逻`],[`🚕`,`taxi`,`travel`,`出租车,的士`],[`🚖`,`oncoming taxi`,`travel`,`出租车`],[`🚗`,`automobile`,`travel`,`汽车,轿车,车`],[`🚘`,`oncoming automobile`,`travel`,`汽车`],[`🚙`,`recreational vehicle`,`travel`,`SUV,越野车,汽车`],[`🚚`,`delivery truck`,`travel`,`卡车,货车`],[`🚛`,`articulated lorry`,`travel`,`卡车,货车`],[`🚜`,`tractor`,`travel`,`拖拉机,农用`],[`🚝`,`monorail`,`travel`,`单轨,单轨列车`],[`🚞`,`mountain railway`,`travel`,`火车,山区铁路`],[`🚟`,`suspension railway`,`travel`,`缆车,悬挂列车`],[`🚠`,`mountain cableway`,`travel`,`缆车,高山`],[`🚡`,`aerial tramway`,`travel`,`缆车,索道`],[`🚢`,`ship`,`travel`,`轮船,船,大海`],[`🚣`,`rowboat`,`travel`,``],[`🚤`,`speedboat`,`travel`,`快艇,汽艇`],[`🚥`,`horizontal traffic light`,`travel`,`红绿灯,交通信号灯`],[`🚦`,`vertical traffic light`,`travel`,`红绿灯,信号灯`],[`🚧`,`construction sign`,`travel`,`施工,施工中,路障`],[`🚨`,`police cars revolving light`,`travel`,`警车灯,警报,紧急`],[`🚩`,`triangular flag on post`,`travel`,`红旗,旗帜,标志`],[`🚪`,`door`,`travel`,`门,房门`],[`🚫`,`no entry sign`,`travel`,``],[`🚬`,`smoking symbol`,`travel`,`香烟,烟,吸烟`],[`🚭`,`no smoking symbol`,`travel`,``],[`🚮`,`put litter in its place symbol`,`travel`,`垃圾,清理`],[`🚯`,`do not litter symbol`,`travel`,``],[`🚰`,`potable water symbol`,`travel`,``],[`🚱`,`non-potable water symbol`,`travel`,``],[`🚲`,`bicycle`,`travel`,`自行车,单车,骑行`],[`🚳`,`no bicycles`,`travel`,``],[`🚴`,`bicyclist`,`travel`,``],[`🚵`,`mountain bicyclist`,`travel`,``],[`🚶`,`pedestrian`,`travel`,`走路,步行,散步`],[`🚷`,`no pedestrians`,`travel`,``],[`🚸`,`children crossing`,`travel`,``],[`🚹`,`mens symbol`,`travel`,``],[`🚺`,`womens symbol`,`travel`,``],[`🚻`,`restroom`,`travel`,``],[`🚼`,`baby symbol`,`travel`,``],[`🚽`,`toilet`,`travel`,`马桶,厕所,卫生间`],[`🚾`,`water closet`,`travel`,``],[`🚿`,`shower`,`travel`,`淋浴,洗澡`],[`🛀`,`bath`,`travel`,`泡澡`],[`🛁`,`bathtub`,`travel`,`浴缸,洗澡,泡澡`],[`🛂`,`passport control`,`travel`,``],[`🛃`,`customs`,`travel`,``],[`🛄`,`baggage claim`,`travel`,``],[`🛅`,`left luggage`,`travel`,``],[`🛋`,`couch and lamp`,`travel`,``],[`🛌`,`sleeping accommodation`,`travel`,`睡觉`],[`🛍`,`shopping bags`,`travel`,``],[`🛎`,`bellhop bell`,`travel`,``],[`🛏`,`bed`,`travel`,``],[`🛐`,`place of worship`,`travel`,``],[`🛑`,`octagonal sign`,`travel`,`停止,停车,红圈`],[`🛒`,`shopping trolley`,`travel`,`购物车,购物`],[`🛕`,`hindu temple`,`travel`,`印度教神庙`],[`🛖`,`hut`,`travel`,`草屋,小屋`],[`🛗`,`elevator`,`travel`,``],[`🛜`,`wireless`,`travel`,``],[`🛝`,`playground slide`,`travel`,``],[`🛞`,`wheel`,`travel`,`车轮,轮胎`],[`🛟`,`ring buoy`,`travel`,`救生圈,救生`],[`🛠`,`hammer and wrench`,`travel`,``],[`🛡`,`shield`,`travel`,``],[`🛢`,`oil drum`,`travel`,``],[`🛣`,`motorway`,`travel`,``],[`🛤`,`railway track`,`travel`,``],[`🛥`,`motor boat`,`travel`,``],[`🛩`,`small airplane`,`travel`,``],[`🛫`,`airplane departure`,`travel`,`起飞,飞机,出发`],[`🛬`,`airplane arriving`,`travel`,`降落,飞机,到达`],[`🛰`,`satellite`,`travel`,``],[`🛳`,`passenger ship`,`travel`,``],[`🛴`,`scooter`,`travel`,`滑板车,平衡车`],[`🛵`,`motor scooter`,`travel`,`摩托车,电动车,踏板车`],[`🛶`,`canoe`,`travel`,`独木舟,皮划艇`],[`🛷`,`sled`,`travel`,`雪橇,雪车`],[`🛸`,`flying saucer`,`travel`,`飞碟,UFO,外星人`],[`🛹`,`skateboard`,`travel`,`滑板`],[`🛺`,`auto rickshaw`,`travel`,`三轮车,突突车`],[`🛻`,`pickup truck`,`travel`,`皮卡,卡车`],[`🛼`,`roller skate`,`travel`,`轮滑`],[`🟠`,`large orange circle`,`symbols`,``],[`🟡`,`large yellow circle`,`symbols`,``],[`🟢`,`large green circle`,`symbols`,``],[`🟣`,`large purple circle`,`symbols`,``],[`🟤`,`large brown circle`,`symbols`,``],[`🟥`,`large red square`,`symbols`,``],[`🟦`,`large blue square`,`symbols`,``],[`🟧`,`large orange square`,`symbols`,``],[`🟨`,`large yellow square`,`symbols`,``],[`🟩`,`large green square`,`symbols`,``],[`🟪`,`large purple square`,`symbols`,``],[`🟫`,`large brown square`,`symbols`,``],[`🟰`,`heavy equals sign`,`symbols`,``],[`🤌`,`pinched fingers`,`symbols`,`手指,捏,意大利`],[`🤍`,`white heart`,`symbols`,`白心,白色,爱心`],[`🤎`,`brown heart`,`symbols`,`棕心,棕色,爱心`],[`🤏`,`pinching hand`,`symbols`,`捏,一点点,微小`],[`🤐`,`zipper-mouth face`,`smileys`,`闭嘴,不说`],[`🤑`,`money-mouth face`,`smileys`,`发财,金钱,贪婪`],[`🤒`,`face with thermometer`,`smileys`,`发烧,生病,温度计`],[`🤓`,`nerd face`,`smileys`,`书呆子,眼镜`],[`🤔`,`thinking face`,`smileys`,`思考,疑问,想`],[`🤕`,`face with head-bandage`,`smileys`,`受伤,包扎,头`],[`🤖`,`robot face`,`smileys`,`机器人,AI,机械`],[`🤗`,`hugging face`,`smileys`,`拥抱,欢迎`],[`🤘`,`sign of the horns`,`smileys`,`摇滚,手势,牛`],[`🤙`,`call me hand`,`smileys`,`打电话,挂,酷`],[`🤚`,`raised back of hand`,`smileys`,`手,举手,停`],[`🤛`,`left-facing fist`,`smileys`,`拳头,左边`],[`🤜`,`right-facing fist`,`smileys`,`拳头,右边`],[`🤝`,`handshake`,`smileys`,`握手,合作,协议`],[`🤞`,`hand with index and middle fingers crossed`,`smileys`,`祈祷,好运,手指交叉`],[`🤟`,`i love you hand sign`,`smileys`,`爱你,摇滚`],[`🤠`,`face with cowboy hat`,`smileys`,`牛仔,帽子`],[`🤡`,`clown face`,`smileys`,`小丑,马戏团`],[`🤢`,`nauseated face`,`smileys`,`恶心,呕吐`],[`🤣`,`rolling on the floor laughing`,`smileys`,`笑哭,大笑,笑`],[`🤤`,`drooling face`,`smileys`,`流口水,馋`],[`🤥`,`lying face`,`smileys`,`说谎,撒谎`],[`🤦`,`face palm`,`smileys`,`捂脸,无奈,扶额`],[`🤧`,`sneezing face`,`smileys`,`打喷嚏,感冒`],[`🤨`,`face with one eyebrow raised`,`symbols`,`怀疑,挑眉`],[`🤩`,`grinning face with star eyes`,`symbols`,`星星眼,兴奋,惊讶`],[`🤪`,`grinning face with one large and one small eye`,`symbols`,`疯狂,搞怪`],[`🤫`,`face with finger covering closed lips`,`symbols`,`嘘,安静`],[`🤬`,`serious face with symbols covering mouth`,`symbols`,`骂人,脏话,生气`],[`🤭`,`smiling face with smiling eyes and hand covering mouth`,`symbols`,`捂嘴,偷笑,惊讶`],[`🤮`,`face with open mouth vomiting`,`symbols`,`呕吐,恶心`],[`🤯`,`shocked face with exploding head`,`smileys`,`爆炸,震惊,头炸`],[`🤰`,`pregnant woman`,`people`,`孕妇,怀孕`],[`🤱`,`breast-feeding`,`people`,``],[`🤲`,`palms up together`,`people`,``],[`🤳`,`selfie`,`people`,`自拍,拍照`],[`🤴`,`prince`,`people`,`王子,国王`],[`🤵`,`man in tuxedo`,`people`,`新郎,西装,燕尾服`],[`🤶`,`mother christmas`,`people`,`圣诞奶奶,圣诞老人`],[`🤷`,`shrug`,`people`,`耸肩,无奈,不知道`],[`🤸`,`person doing cartwheel`,`people`,`翻跟头,体操,空翻`],[`🤹`,`juggling`,`people`,`杂耍`],[`🤺`,`fencer`,`people`,`击剑,剑术`],[`🤼`,`wrestlers`,`activity`,`摔跤,格斗`],[`🤽`,`water polo`,`activity`,``],[`🤾`,`handball`,`activity`,``],[`🤿`,`diving mask`,`activity`,`潜水面罩,潜水`],[`🥀`,`wilted flower`,`symbols`,``],[`🥁`,`drum with drumsticks`,`symbols`,`鼓,打鼓,乐器`],[`🥂`,`clinking glasses`,`symbols`,`干杯,香槟杯`],[`🥃`,`tumbler glass`,`symbols`,`威士忌,酒杯`],[`🥄`,`spoon`,`symbols`,`勺子,汤匙`],[`🥅`,`goal net`,`symbols`,`球门,网,进球`],[`🥇`,`first place medal`,`symbols`,`金牌,冠军,第一名,奖牌`],[`🥈`,`second place medal`,`symbols`,`银牌,第二名,奖牌`],[`🥉`,`third place medal`,`symbols`,`铜牌,第三名,奖牌`],[`🥊`,`boxing glove`,`symbols`,`拳击,拳击手套,打拳`],[`🥋`,`martial arts uniform`,`symbols`,`道服,武术,空手道`],[`🥌`,`curling stone`,`symbols`,`冰壶,冰壶`],[`🥍`,`lacrosse stick and ball`,`symbols`,``],[`🥎`,`softball`,`symbols`,`垒球,球`],[`🥏`,`flying disc`,`symbols`,`飞盘,飞碟`],[`🥐`,`croissant`,`food`,`牛角包,可颂`],[`🥑`,`avocado`,`food`,`牛油果,鳄梨`],[`🥒`,`cucumber`,`food`,`黄瓜`],[`🥓`,`bacon`,`food`,`培根,腊肉`],[`🥔`,`potato`,`food`,`土豆,马铃薯`],[`🥕`,`carrot`,`food`,`胡萝卜`],[`🥖`,`baguette bread`,`food`,`法棍,面包`],[`🥗`,`green salad`,`food`,`沙拉,蔬菜`],[`🥘`,`shallow pan of food`,`food`,`炖锅,海鲜饭`],[`🥙`,`stuffed flatbread`,`food`,`卷饼,肉夹馍`],[`🥚`,`egg`,`food`,`鸡蛋,蛋`],[`🥛`,`glass of milk`,`food`,`牛奶,奶`],[`🥜`,`peanuts`,`food`,``],[`🥝`,`kiwifruit`,`food`,`猕猴桃,奇异果`],[`🥞`,`pancakes`,`food`,`松饼,煎饼`],[`🥟`,`dumpling`,`food`,`饺子,锅贴`],[`🥠`,`fortune cookie`,`food`,`幸运饼干`],[`🥡`,`takeout box`,`food`,``],[`🥢`,`chopsticks`,`food`,`筷子`],[`🥣`,`bowl with spoon`,`food`,``],[`🥤`,`cup with straw`,`food`,`饮料,杯`],[`🥥`,`coconut`,`food`,`椰子`],[`🥦`,`broccoli`,`food`,`西兰花`],[`🥧`,`pie`,`food`,`派,馅饼`],[`🥨`,`pretzel`,`food`,`椒盐卷饼`],[`🥩`,`cut of meat`,`food`,`牛排,肉`],[`🥪`,`sandwich`,`food`,`三明治`],[`🥫`,`canned food`,`food`,`罐头,罐装`],[`🥬`,`leafy green`,`symbols`,`青菜,白菜,生菜`],[`🥭`,`mango`,`symbols`,`芒果`],[`🥮`,`moon cake`,`symbols`,``],[`🥯`,`bagel`,`symbols`,`贝果,面包圈`],[`🥰`,`smiling face with smiling eyes and three hearts`,`smileys`,`爱,微笑,爱心`],[`🥱`,`yawning face`,`smileys`,`打哈欠,困,无聊`],[`🥲`,`smiling face with tear`,`smileys`,``],[`🥳`,`face with party horn and party hat`,`smileys`,`庆祝,派对,欢呼`],[`🥴`,`face with uneven eyes and wavy mouth`,`smileys`,`晕,醉,头昏`],[`🥵`,`overheated face`,`smileys`,`热`],[`🥶`,`freezing face`,`smileys`,`冷`],[`🥷`,`ninja`,`people`,`忍者,忍者`],[`🥸`,`disguised face`,`symbols`,`伪装`],[`🥹`,`face holding back tears`,`symbols`,`感动,忍住,哭,泪目`],[`🥺`,`face with pleading eyes`,`smileys`,`可怜,委屈,求`],[`🥻`,`sari`,`symbols`,`纱丽,印度`],[`🥼`,`lab coat`,`symbols`,``],[`🥽`,`goggles`,`symbols`,``],[`🥾`,`hiking boot`,`symbols`,`靴子,登山鞋`],[`🥿`,`flat shoe`,`symbols`,`平底鞋,鞋`],[`🦀`,`crab`,`animals`,`螃蟹,海鲜`],[`🦁`,`lion face`,`animals`,``],[`🦂`,`scorpion`,`animals`,``],[`🦃`,`turkey`,`animals`,`火鸡,感恩节`],[`🦄`,`unicorn face`,`animals`,`独角兽,梦幻`],[`🦅`,`eagle`,`animals`,`老鹰,鹰`],[`🦆`,`duck`,`animals`,`鸭子,鸭`],[`🦇`,`bat`,`animals`,`蝙蝠`],[`🦈`,`shark`,`animals`,`鲨鱼,鱼`],[`🦉`,`owl`,`animals`,`猫头鹰,智慧`],[`🦊`,`fox face`,`animals`,``],[`🦋`,`butterfly`,`animals`,``],[`🦌`,`deer`,`animals`,`鹿,麋鹿`],[`🦍`,`gorilla`,`animals`,``],[`🦎`,`lizard`,`animals`,`蜥蜴,爬行动物`],[`🦏`,`rhinoceros`,`animals`,`犀牛`],[`🦐`,`shrimp`,`animals`,`虾,海鲜`],[`🦑`,`squid`,`animals`,`鱿鱼,海鲜`],[`🦒`,`giraffe face`,`animals`,`长颈鹿`],[`🦓`,`zebra face`,`animals`,`斑马`],[`🦔`,`hedgehog`,`animals`,`刺猬`],[`🦕`,`sauropod`,`animals`,`恐龙,雷龙`],[`🦖`,`t-rex`,`animals`,`恐龙,霸王龙`],[`🦗`,`cricket`,`animals`,``],[`🦘`,`kangaroo`,`animals`,`袋鼠`],[`🦙`,`llama`,`animals`,`羊驼,草泥马`],[`🦚`,`peacock`,`animals`,`孔雀,开屏`],[`🦛`,`hippopotamus`,`animals`,`河马`],[`🦜`,`parrot`,`animals`,`鹦鹉`],[`🦝`,`raccoon`,`animals`,`浣熊`],[`🦞`,`lobster`,`animals`,`龙虾,海鲜`],[`🦟`,`mosquito`,`animals`,``],[`🦠`,`microbe`,`animals`,``],[`🦡`,`badger`,`animals`,`獾`],[`🦢`,`swan`,`animals`,`天鹅,鹅`],[`🦣`,`mammoth`,`animals`,`猛犸象`],[`🦤`,`dodo`,`animals`,`渡渡鸟`],[`🦥`,`sloth`,`animals`,`树懒`],[`🦦`,`otter`,`animals`,`水獭`],[`🦧`,`orangutan`,`animals`,``],[`🦨`,`skunk`,`animals`,`臭鼬`],[`🦩`,`flamingo`,`animals`,`火烈鸟,红鹤`],[`🦪`,`oyster`,`animals`,`生蚝,牡蛎`],[`🦫`,`beaver`,`animals`,`河狸,海狸`],[`🦬`,`bison`,`animals`,`野牛,水牛`],[`🦭`,`seal`,`animals`,`海豹,海狮`],[`🦮`,`guide dog`,`animals`,`导盲犬,狗`],[`🦯`,`probing cane`,`symbols`,``],[`🦰`,`emoji component red hair`,`people`,`红发,头发,发色`],[`🦱`,`emoji component curly hair`,`people`,`卷发,头发`],[`🦲`,`emoji component bald`,`people`,`光头,秃头`],[`🦳`,`emoji component white hair`,`people`,`白发,头发`],[`🦴`,`bone`,`people`,``],[`🦵`,`leg`,`people`,`腿,大腿`],[`🦶`,`foot`,`people`,`脚,足`],[`🦷`,`tooth`,`people`,`牙齿,牙`],[`🦸`,`superhero`,`people`,`英雄`],[`🦹`,`supervillain`,`people`,`超级反派,坏人,反派`],[`🦺`,`safety vest`,`symbols`,``],[`🦻`,`ear with hearing aid`,`symbols`,`助听器,耳朵`],[`🦼`,`motorized wheelchair`,`people`,``],[`🦽`,`manual wheelchair`,`people`,``],[`🦾`,`mechanical arm`,`people`,`机械臂,机器人,义肢`],[`🦿`,`mechanical leg`,`people`,`机械腿,义肢`],[`🧀`,`cheese wedge`,`food`,`奶酪,芝士`],[`🧁`,`cupcake`,`food`,`纸杯蛋糕,杯子蛋糕`],[`🧂`,`salt shaker`,`food`,``],[`🧃`,`beverage box`,`food`,`果汁盒,饮料`],[`🧄`,`garlic`,`food`,`大蒜,蒜`],[`🧅`,`onion`,`food`,`洋葱`],[`🧆`,`falafel`,`food`,`鹰嘴豆丸子`],[`🧇`,`waffle`,`food`,`华夫饼`],[`🧈`,`butter`,`food`,`黄油,奶油`],[`🧉`,`mate drink`,`food`,`马黛茶`],[`🧊`,`ice cube`,`food`,`冰块,冰`],[`🧋`,`bubble tea`,`food`,`奶茶,珍珠奶茶`],[`🧌`,`troll`,`symbols`,`巨魔,妖怪`],[`🧍`,`standing person`,`symbols`,`站立,站着,人`],[`🧎`,`kneeling person`,`symbols`,`跪,跪下,祈祷`],[`🧏`,`deaf person`,`symbols`,``],[`🧐`,`face with monocle`,`people`,`检查,研究,眼镜`],[`🧑`,`adult`,`people`,`人`],[`🧒`,`child`,`people`,``],[`🧓`,`older adult`,`people`,`老人,奶奶,爷爷`],[`🧔`,`bearded person`,`people`,`胡子,胡须,大叔`],[`🧕`,`person with headscarf`,`people`,`头巾`],[`🧖`,`person in steamy room`,`people`,`桑拿,蒸汽,洗澡`],[`🧗`,`person climbing`,`people`,`攀岩`],[`🧘`,`person in lotus position`,`people`,`打坐`],[`🧙`,`mage`,`people`,`巫师,魔法师,法师`],[`🧚`,`fairy`,`people`,`仙女,精灵,小仙女`],[`🧛`,`vampire`,`people`,`吸血鬼,德古拉`],[`🧜`,`merperson`,`people`,`美人鱼,人鱼`],[`🧝`,`elf`,`people`,`精灵,耳朵`],[`🧞`,`genie`,`people`,`灯神,精灵,神灯`],[`🧟`,`zombie`,`people`,`僵尸,丧尸`],[`🧠`,`brain`,`people`,`大脑,思考,记忆,AI`],[`🧡`,`orange heart`,`people`,``],[`🧢`,`billed cap`,`people`,`棒球帽,帽子`],[`🧣`,`scarf`,`people`,`围巾,冬天`],[`🧤`,`gloves`,`people`,`手套,冬天`],[`🧥`,`coat`,`people`,`大衣,外套`],[`🧦`,`socks`,`people`,`袜子`],[`🧧`,`red gift envelope`,`objects`,`红包,利是,新年`],[`🧨`,`firecracker`,`objects`,``],[`🧩`,`jigsaw puzzle piece`,`objects`,`拼图,拼图游戏`],[`🧪`,`test tube`,`objects`,`试管,实验,化学,科学`],[`🧫`,`petri dish`,`objects`,`培养皿,实验,细菌`],[`🧬`,`dna double helix`,`objects`,`DNA,基因,生物`],[`🧭`,`compass`,`objects`,`指南针`],[`🧮`,`abacus`,`objects`,`算盘,计算`],[`🧯`,`fire extinguisher`,`objects`,`灭火器,消防`],[`🧰`,`toolbox`,`objects`,`工具箱,工具`],[`🧱`,`brick`,`objects`,`砖`],[`🧲`,`magnet`,`objects`,`磁铁,磁性`],[`🧳`,`luggage`,`objects`,`行李箱`],[`🧴`,`lotion bottle`,`objects`,`乳液,护肤,防晒`],[`🧵`,`spool of thread`,`objects`,`线,针线,缝纫`],[`🧶`,`ball of yarn`,`objects`,`毛线,织毛衣`],[`🧷`,`safety pin`,`objects`,`别针,安全别针`],[`🧸`,`teddy bear`,`objects`,`泰迪熊,玩具熊`],[`🧹`,`broom`,`objects`,`扫帚`],[`🧺`,`basket`,`objects`,`篮子`],[`🧻`,`roll of paper`,`objects`,`纸巾`],[`🧼`,`bar of soap`,`objects`,`肥皂,洗手,清洁`],[`🧽`,`sponge`,`objects`,`海绵,清洁`],[`🧾`,`receipt`,`objects`,`收据`],[`🧿`,`nazar amulet`,`objects`,`护身符`],[`🩰`,`ballet shoes`,`activity`,`芭蕾`],[`🩱`,`one-piece swimsuit`,`activity`,`泳衣`],[`🩲`,`briefs`,`activity`,`泳裤`],[`🩳`,`shorts`,`activity`,`短裤`],[`🩴`,`thong sandal`,`activity`,`凉拖`],[`🩵`,`light blue heart`,`activity`,`浅蓝`],[`🩶`,`grey heart`,`activity`,`灰心`],[`🩷`,`pink heart`,`activity`,`粉色`],[`🩸`,`drop of blood`,`activity`,`血`],[`🩹`,`adhesive bandage`,`activity`,`创可贴`],[`🩺`,`stethoscope`,`activity`,`听诊器`],[`🩻`,`x-ray`,`activity`,`X光`],[`🩼`,`crutch`,`activity`,`拐杖`],[`🪀`,`yo-yo`,`objects`,`玩具`],[`🪁`,`kite`,`objects`,`风筝`],[`🪂`,`parachute`,`objects`,`跳伞`],[`🪃`,`boomerang`,`objects`,``],[`🪄`,`magic wand`,`objects`,`魔杖,魔法,魔术`],[`🪅`,`pinata`,`objects`,`皮纳塔`],[`🪆`,`nesting dolls`,`objects`,``],[`🪇`,`maracas`,`objects`,`沙锤`],[`🪈`,`flute`,`objects`,`笛子`],[`🪐`,`ringed planet`,`objects`,``],[`🪑`,`chair`,`objects`,`椅子`],[`🪒`,`razor`,`objects`,`剃须刀,剃刀`],[`🪓`,`axe`,`objects`,`斧头,斧子`],[`🪔`,`diya lamp`,`objects`,`油灯`],[`🪕`,`banjo`,`objects`,`班卓琴`],[`🪖`,`military helmet`,`objects`,`军盔`],[`🪗`,`accordion`,`objects`,`手风琴`],[`🪘`,`long drum`,`objects`,`鼓`],[`🪙`,`coin`,`objects`,`金币`],[`🪚`,`carpentry saw`,`objects`,`锯子,锯`],[`🪛`,`screwdriver`,`objects`,`螺丝刀`],[`🪜`,`ladder`,`objects`,`梯子`],[`🪝`,`hook`,`objects`,`钩子,挂钩`],[`🪞`,`mirror`,`objects`,`镜子`],[`🪟`,`window`,`objects`,`窗户`],[`🪠`,`plunger`,`objects`,`皮搋子,通马桶`],[`🪡`,`sewing needle`,`objects`,`针,缝纫,刺绣`],[`🪢`,`knot`,`objects`,``],[`🪣`,`bucket`,`objects`,`水桶,桶`],[`🪤`,`mouse trap`,`objects`,`捕鼠器`],[`🪥`,`toothbrush`,`objects`,`牙刷,刷牙`],[`🪦`,`headstone`,`objects`,`墓碑`],[`🪧`,`placard`,`objects`,`告示牌`],[`🪨`,`rock`,`objects`,`石头,岩石`],[`🪩`,`mirror ball`,`objects`,`迪斯科球`],[`🪪`,`identification card`,`objects`,`身份证`],[`🪫`,`low battery`,`objects`,`电池,没电,低电量`],[`🪬`,`hamsa`,`objects`,`手掌印,护身符`],[`🪭`,`folding hand fan`,`objects`,``],[`🪮`,`hair pick`,`objects`,`梳子`],[`🪯`,`khanda`,`objects`,``],[`🪰`,`fly`,`objects`,`苍蝇,飞虫`],[`🪱`,`worm`,`objects`,``],[`🪲`,`beetle`,`objects`,`甲虫,昆虫`],[`🪳`,`cockroach`,`objects`,`蟑螂,虫子`],[`🪴`,`potted plant`,`objects`,`盆栽,植物,绿植`],[`🪵`,`wood`,`objects`,`木头,柴火,木`],[`🪶`,`feather`,`objects`,`羽毛,羽毛笔`],[`🪷`,`lotus`,`objects`,`莲花`],[`🪸`,`coral`,`objects`,`珊瑚`],[`🪹`,`empty nest`,`objects`,`鸟巢`],[`🪺`,`nest with eggs`,`objects`,`鸟巢`],[`🪻`,`hyacinth`,`objects`,`风信子`],[`🪼`,`jellyfish`,`objects`,`水母`],[`🪽`,`wing`,`objects`,`翅膀`],[`🪿`,`goose`,`objects`,`鹅`],[`🫀`,`anatomical heart`,`objects`,`心脏,心跳`],[`🫁`,`lungs`,`objects`,`肺,呼吸`],[`🫂`,`people hugging`,`objects`,`拥抱,人,朋友`],[`🫃`,`pregnant man`,`objects`,`孕妇,怀孕`],[`🫄`,`pregnant person`,`objects`,`孕妇,怀孕`],[`🫅`,`person with crown`,`objects`,`国王,王子,皇冠`],[`🫎`,`moose`,`objects`,`驼鹿,麋鹿`],[`🫏`,`donkey`,`objects`,`驴,动物`],[`🫐`,`blueberries`,`food`,`蓝莓`],[`🫑`,`bell pepper`,`food`,`甜椒,彩椒`],[`🫒`,`olive`,`food`,`橄榄`],[`🫓`,`flatbread`,`food`,`薄饼,饼`],[`🫔`,`tamale`,`food`,`玉米粉蒸肉`],[`🫕`,`fondue`,`food`,`奶酪火锅`],[`🫖`,`teapot`,`food`,`茶壶,茶`],[`🫗`,`pouring liquid`,`food`,`倒,倒水,水杯`],[`🫘`,`beans`,`food`,`豆子,红豆`],[`🫙`,`jar`,`food`,`罐子,玻璃罐`],[`🫚`,`ginger root`,`food`,`姜,生姜`],[`🫛`,`pea pod`,`food`,`豌豆荚,豆`],[`🫠`,`melting face`,`smileys`,`融化`],[`🫡`,`saluting face`,`smileys`,`敬礼`],[`🫢`,`face with open eyes and hand over mouth`,`smileys`,`捂眼`],[`🫣`,`face with peeking eye`,`smileys`,`偷看`],[`🫤`,`face with diagonal mouth`,`smileys`,`撇嘴`],[`🫥`,`dotted line face`,`smileys`,`隐形`],[`🫦`,`biting lip`,`smileys`,`咬唇,嘴唇`],[`🫧`,`bubbles`,`smileys`,`泡泡`],[`🫨`,`shaking face`,`smileys`,`摇晃,震动,抖`],[`🫰`,`hand with index finger and thumb crossed`,`people`,`比心,手指,捏`],[`🫱`,`rightwards hand`,`people`,`手,右边,推`],[`🫲`,`leftwards hand`,`people`,`手,左边,推`],[`🫳`,`palm down hand`,`people`,`手,向下,放`],[`🫴`,`palm up hand`,`people`,`手,向上,举`],[`🫵`,`index pointing at the viewer`,`people`,`指,你`],[`🫶`,`heart hands`,`people`,`比心,爱心,手势`],[`🫷`,`leftwards pushing hand`,`people`,`手,推,右边`],[`🫸`,`rightwards pushing hand`,`people`,`手,推,左边`],[`‼`,`double exclamation mark`,`symbols`,``],[`‼️`,`double exclamation mark`,`symbols`,``],[`⁉`,`exclamation question mark`,`symbols`,``],[`⁉️`,`exclamation question mark`,`symbols`,``],[`™`,`trade mark sign`,`symbols`,``],[`™️`,`trade mark sign`,`symbols`,``],[`ℹ`,`information source`,`symbols`,``],[`ℹ️`,`information source`,`symbols`,``],[`↔`,`left right arrow`,`symbols`,``],[`↔️`,`left right arrow`,`symbols`,``],[`↕`,`up down arrow`,`symbols`,``],[`↕️`,`up down arrow`,`symbols`,``],[`↖`,`north west arrow`,`symbols`,``],[`↖️`,`north west arrow`,`symbols`,``],[`↗`,`north east arrow`,`symbols`,``],[`↗️`,`north east arrow`,`symbols`,``],[`↘`,`south east arrow`,`symbols`,``],[`↘️`,`south east arrow`,`symbols`,``],[`↙`,`south west arrow`,`symbols`,``],[`↙️`,`south west arrow`,`symbols`,``],[`↩`,`leftwards arrow with hook`,`symbols`,``],[`↩️`,`leftwards arrow with hook`,`symbols`,``],[`↪`,`rightwards arrow with hook`,`symbols`,``],[`↪️`,`rightwards arrow with hook`,`symbols`,``],[`⌚`,`watch`,`objects`,`手表`],[`⌚️`,`watch`,`objects`,``],[`⌛`,`hourglass`,`objects`,`沙漏,时间,等待`],[`⌛️`,`hourglass`,`objects`,``],[`⌨`,`keyboard`,`symbols`,``],[`⌨️`,`keyboard`,`symbols`,`键盘,打字`],[`⏏`,`eject symbol`,`symbols`,``],[`⏏️`,`eject symbol`,`symbols`,``],[`⏩`,`black right-pointing double triangle`,`objects`,``],[`⏪`,`black left-pointing double triangle`,`objects`,``],[`⏫`,`black up-pointing double triangle`,`objects`,``],[`⏬`,`black down-pointing double triangle`,`objects`,``],[`⏭`,`black right-pointing double triangle with vertical bar`,`objects`,``],[`⏭️`,`black right-pointing double triangle with vertical bar`,`objects`,``],[`⏮`,`black left-pointing double triangle with vertical bar`,`objects`,``],[`⏮️`,`black left-pointing double triangle with vertical bar`,`objects`,``],[`⏯`,`black right-pointing triangle with double vertical bar`,`objects`,``],[`⏯️`,`black right-pointing triangle with double vertical bar`,`objects`,``],[`⏰`,`alarm clock`,`objects`,`闹钟,时间,起床`],[`⏱`,`stopwatch`,`objects`,``],[`⏱️`,`stopwatch`,`objects`,`秒表`],[`⏲`,`timer clock`,`objects`,``],[`⏲️`,`timer clock`,`objects`,`计时器`],[`⏳`,`hourglass with flowing sand`,`objects`,`沙漏`],[`⏸`,`double vertical bar`,`symbols`,``],[`⏸️`,`double vertical bar`,`symbols`,``],[`⏹`,`black square for stop`,`symbols`,``],[`⏹️`,`black square for stop`,`symbols`,``],[`⏺`,`black circle for record`,`symbols`,``],[`⏺️`,`black circle for record`,`symbols`,``],[`Ⓜ`,`circled latin capital letter m`,`symbols`,``],[`Ⓜ️`,`circled latin capital letter m`,`symbols`,``],[`▪`,`black small square`,`symbols`,``],[`▪️`,`black small square`,`symbols`,``],[`▫`,`white small square`,`symbols`,``],[`▫️`,`white small square`,`symbols`,``],[`▶`,`black right-pointing triangle`,`symbols`,``],[`▶️`,`black right-pointing triangle`,`symbols`,``],[`◀`,`black left-pointing triangle`,`symbols`,``],[`◀️`,`black left-pointing triangle`,`symbols`,``],[`◻`,`white medium square`,`symbols`,``],[`◻️`,`white medium square`,`symbols`,``],[`◼`,`black medium square`,`symbols`,``],[`◼️`,`black medium square`,`symbols`,``],[`◽`,`white medium small square`,`symbols`,``],[`◾`,`black medium small square`,`symbols`,``],[`◾️`,`black medium small square`,`symbols`,``],[`☀`,`black sun with rays`,`symbols`,``],[`☀️`,`black sun with rays`,`symbols`,`太阳,晴天,阳光`],[`☁`,`cloud`,`symbols`,``],[`☁️`,`cloud`,`symbols`,`云,多云,天气`],[`☂`,`umbrella`,`symbols`,``],[`☂️`,`umbrella`,`symbols`,``],[`☃`,`snowman`,`symbols`,``],[`☃️`,`snowman`,`symbols`,`雪人,冬天,雪`],[`☄`,`comet`,`symbols`,``],[`☄️`,`comet`,`symbols`,``],[`☎`,`black telephone`,`symbols`,``],[`☎️`,`black telephone`,`symbols`,`电话`],[`☑`,`ballot box with check`,`symbols`,``],[`☑️`,`ballot box with check`,`symbols`,``],[`☔`,`umbrella with rain drops`,`symbols`,``],[`☔️`,`umbrella with rain drops`,`symbols`,``],[`☕`,`hot beverage`,`food`,`咖啡,热饮`],[`☕️`,`hot beverage`,`food`,``],[`☘`,`shamrock`,`symbols`,``],[`☘️`,`shamrock`,`symbols`,``],[`☝`,`white up pointing index`,`symbols`,``],[`☝️`,`white up pointing index`,`symbols`,`指,上面,向上`],[`☠`,`skull and crossbones`,`symbols`,``],[`☠️`,`skull and crossbones`,`symbols`,`骷髅,死亡,危险`],[`☢`,`radioactive sign`,`symbols`,``],[`☢️`,`radioactive sign`,`symbols`,``],[`☣`,`biohazard sign`,`symbols`,``],[`☣️`,`biohazard sign`,`symbols`,``],[`☦`,`orthodox cross`,`symbols`,``],[`☦️`,`orthodox cross`,`symbols`,``],[`☪`,`star and crescent`,`symbols`,``],[`☪️`,`star and crescent`,`symbols`,``],[`☮`,`peace symbol`,`symbols`,``],[`☮️`,`peace symbol`,`symbols`,``],[`☯`,`yin yang`,`symbols`,``],[`☯️`,`yin yang`,`symbols`,``],[`☸`,`wheel of dharma`,`symbols`,``],[`☸️`,`wheel of dharma`,`symbols`,``],[`☹`,`white frowning face`,`smileys`,``],[`☹️`,`white frowning face`,`smileys`,``],[`☺`,`white smiling face`,`smileys`,``],[`☺️`,`white smiling face`,`smileys`,``],[`♀`,`female sign`,`symbols`,``],[`♀️`,`female sign`,`symbols`,``],[`♂`,`male sign`,`symbols`,``],[`♂️`,`male sign`,`symbols`,``],[`♈`,`aries`,`symbols`,``],[`♈️`,`aries`,`symbols`,``],[`♉`,`taurus`,`symbols`,``],[`♉️`,`taurus`,`symbols`,``],[`♊`,`gemini`,`symbols`,``],[`♊️`,`gemini`,`symbols`,``],[`♋`,`cancer`,`symbols`,``],[`♋️`,`cancer`,`symbols`,``],[`♌`,`leo`,`symbols`,``],[`♌️`,`leo`,`symbols`,``],[`♍`,`virgo`,`symbols`,``],[`♍️`,`virgo`,`symbols`,``],[`♎`,`libra`,`symbols`,``],[`♎️`,`libra`,`symbols`,``],[`♏`,`scorpius`,`symbols`,``],[`♏️`,`scorpius`,`symbols`,``],[`♐`,`sagittarius`,`symbols`,``],[`♐️`,`sagittarius`,`symbols`,``],[`♑`,`capricorn`,`symbols`,``],[`♑️`,`capricorn`,`symbols`,``],[`♒`,`aquarius`,`symbols`,``],[`♒️`,`aquarius`,`symbols`,``],[`♓`,`pisces`,`symbols`,``],[`♓️`,`pisces`,`symbols`,``],[`♟`,`black chess pawn`,`symbols`,``],[`♟️`,`black chess pawn`,`symbols`,`棋子,国际象棋,象棋`],[`♠`,`black spade suit`,`symbols`,``],[`♠️`,`black spade suit`,`symbols`,``],[`♣`,`black club suit`,`symbols`,``],[`♣️`,`black club suit`,`symbols`,``],[`♥`,`black heart suit`,`symbols`,``],[`♥️`,`black heart suit`,`symbols`,``],[`♦`,`black diamond suit`,`symbols`,``],[`♦️`,`black diamond suit`,`symbols`,``],[`♨`,`hot springs`,`symbols`,``],[`♨️`,`hot springs`,`symbols`,`温泉,热泉`],[`♻`,`black universal recycling symbol`,`symbols`,``],[`♻️`,`black universal recycling symbol`,`symbols`,``],[`♾`,`permanent paper sign`,`symbols`,``],[`♾️`,`permanent paper sign`,`symbols`,``],[`♿`,`wheelchair symbol`,`symbols`,``],[`♿️`,`wheelchair symbol`,`symbols`,``],[`⚒`,`hammer and pick`,`symbols`,``],[`⚒️`,`hammer and pick`,`symbols`,`锤子,工具`],[`⚓`,`anchor`,`symbols`,`锚,航海,停泊`],[`⚔`,`crossed swords`,`symbols`,``],[`⚔️`,`crossed swords`,`symbols`,`剑,交叉,战斗`],[`⚕`,`staff of aesculapius`,`symbols`,``],[`⚕️`,`staff of aesculapius`,`symbols`,``],[`⚖`,`scales`,`symbols`,``],[`⚖️`,`scales`,`symbols`,``],[`⚗`,`alembic`,`symbols`,``],[`⚗️`,`alembic`,`symbols`,``],[`⚙`,`gear`,`symbols`,``],[`⚙️`,`gear`,`symbols`,``],[`⚛`,`atom symbol`,`symbols`,``],[`⚛️`,`atom symbol`,`symbols`,``],[`⚜`,`fleur-de-lis`,`symbols`,``],[`⚜️`,`fleur-de-lis`,`symbols`,``],[`⚠`,`warning sign`,`symbols`,``],[`⚠️`,`warning sign`,`symbols`,``],[`⚡`,`high voltage sign`,`symbols`,``],[`⚧`,`male with stroke and male and female sign`,`symbols`,``],[`⚧️`,`male with stroke and male and female sign`,`symbols`,``],[`⚪`,`medium white circle`,`symbols`,``],[`⚪️`,`medium white circle`,`symbols`,``],[`⚫`,`medium black circle`,`symbols`,``],[`⚰`,`coffin`,`symbols`,``],[`⚰️`,`coffin`,`symbols`,`棺材,死亡`],[`⚱`,`funeral urn`,`symbols`,``],[`⚱️`,`funeral urn`,`symbols`,`骨灰盒,死亡`],[`⚽`,`soccer ball`,`activity`,`足球,球`],[`⚽️`,`soccer ball`,`activity`,``],[`⚾`,`baseball`,`activity`,`棒球,球`],[`⚾️`,`baseball`,`activity`,``],[`⛄`,`snowman without snow`,`symbols`,`雪人,冬天`],[`⛄️`,`snowman without snow`,`symbols`,``],[`⛅`,`sun behind cloud`,`symbols`,`太阳,云,多云`],[`⛈`,`thunder cloud and rain`,`symbols`,``],[`⛈️`,`thunder cloud and rain`,`symbols`,`雷雨,雷暴,天气`],[`⛎`,`ophiuchus`,`symbols`,``],[`⛏`,`pick`,`symbols`,``],[`⛏️`,`pick`,`symbols`,`镐,工具`],[`⛑`,`helmet with white cross`,`symbols`,``],[`⛑️`,`helmet with white cross`,`symbols`,`头盔,救援,安全`],[`⛓`,`chains`,`symbols`,``],[`⛓️`,`chains`,`symbols`,``],[`⛔`,`no entry`,`symbols`,``],[`⛩`,`shinto shrine`,`travel`,``],[`⛩️`,`shinto shrine`,`travel`,`鸟居,神社,日本`],[`⛪`,`church`,`travel`,`教堂`],[`⛰`,`mountain`,`travel`,``],[`⛰️`,`mountain`,`travel`,`山,山峰`],[`⛱`,`umbrella on ground`,`travel`,``],[`⛱️`,`umbrella on ground`,`travel`,``],[`⛲`,`fountain`,`travel`,`喷泉`],[`⛲️`,`fountain`,`travel`,``],[`⛳`,`flag in hole`,`activity`,`高尔夫,高尔夫球,球洞`],[`⛳️`,`flag in hole`,`activity`,``],[`⛴`,`ferry`,`travel`,``],[`⛴️`,`ferry`,`travel`,`渡轮,船`],[`⛵`,`sailboat`,`travel`,`帆船,船`],[`⛵️`,`sailboat`,`travel`,``],[`⛷`,`skier`,`activity`,``],[`⛷️`,`skier`,`activity`,``],[`⛸`,`ice skate`,`activity`,``],[`⛸️`,`ice skate`,`activity`,`溜冰,冰刀,滑冰`],[`⛹`,`person with ball`,`activity`,``],[`⛹️`,`person with ball`,`activity`,``],[`⛺`,`tent`,`travel`,`帐篷,露营`],[`⛺️`,`tent`,`travel`,``],[`⛽`,`fuel pump`,`travel`,`加油站,加油,汽油`],[`✂`,`black scissors`,`symbols`,``],[`✂️`,`black scissors`,`symbols`,``],[`✅`,`white heavy check mark`,`symbols`,``],[`✈`,`airplane`,`travel`,``],[`✈️`,`airplane`,`travel`,`飞机,航班,起飞`],[`✉`,`envelope`,`symbols`,``],[`✉️`,`envelope`,`symbols`,`信封,邮件,信`],[`✊`,`raised fist`,`people`,`拳头,加油,力量`],[`✋`,`raised hand`,`people`,`手,举手,停`],[`✌`,`victory hand`,`symbols`,``],[`✌️`,`victory hand`,`symbols`,`胜利,耶,剪刀手`],[`✍`,`writing hand`,`symbols`,``],[`✍️`,`writing hand`,`symbols`,`写字,写作,手`],[`✏`,`pencil`,`symbols`,``],[`✏️`,`pencil`,`symbols`,``],[`✒`,`black nib`,`symbols`,``],[`✒️`,`black nib`,`symbols`,``],[`✔`,`heavy check mark`,`symbols`,``],[`✔️`,`heavy check mark`,`symbols`,``],[`✖`,`heavy multiplication x`,`symbols`,``],[`✖️`,`heavy multiplication x`,`symbols`,``],[`✝`,`latin cross`,`symbols`,``],[`✝️`,`latin cross`,`symbols`,``],[`✡`,`star of david`,`symbols`,``],[`✡️`,`star of david`,`symbols`,``],[`✨`,`sparkles`,`symbols`,`星星,闪光,发光`],[`✳`,`eight spoked asterisk`,`symbols`,``],[`✳️`,`eight spoked asterisk`,`symbols`,``],[`✴`,`eight pointed black star`,`symbols`,``],[`✴️`,`eight pointed black star`,`symbols`,``],[`❄`,`snowflake`,`symbols`,``],[`❄️`,`snowflake`,`symbols`,`雪花,雪,冬天,冷`],[`❇`,`sparkle`,`symbols`,``],[`❇️`,`sparkle`,`symbols`,``],[`❌`,`cross mark`,`symbols`,``],[`❎`,`negative squared cross mark`,`symbols`,``],[`❓`,`black question mark ornament`,`symbols`,``],[`❔`,`white question mark ornament`,`symbols`,``],[`❕`,`white exclamation mark ornament`,`symbols`,``],[`❗`,`heavy exclamation mark symbol`,`symbols`,``],[`❗️`,`heavy exclamation mark symbol`,`symbols`,``],[`❣`,`heavy heart exclamation mark ornament`,`symbols`,``],[`❣️`,`heavy heart exclamation mark ornament`,`symbols`,`爱心,感叹号`],[`❤`,`heavy black heart`,`smileys`,``],[`❤️`,`heavy black heart`,`smileys`,`爱心,红心,爱`],[`➕`,`heavy plus sign`,`symbols`,``],[`➖`,`heavy minus sign`,`symbols`,``],[`➗`,`heavy division sign`,`symbols`,``],[`➡`,`black rightwards arrow`,`symbols`,``],[`➡️`,`black rightwards arrow`,`symbols`,``],[`➰`,`curly loop`,`symbols`,``],[`➿`,`double curly loop`,`symbols`,``],[`⬅`,`leftwards black arrow`,`symbols`,``],[`⬅️`,`leftwards black arrow`,`symbols`,``],[`⬆`,`upwards black arrow`,`symbols`,``],[`⬆️`,`upwards black arrow`,`symbols`,``],[`⬇`,`downwards black arrow`,`symbols`,``],[`⬇️`,`downwards black arrow`,`symbols`,``],[`⬛`,`black large square`,`symbols`,``],[`⬛️`,`black large square`,`symbols`,``],[`⬜`,`white large square`,`symbols`,``],[`⬜️`,`white large square`,`symbols`,``],[`⭐`,`white medium star`,`symbols`,`星星,五星,评分`],[`⭕`,`heavy large circle`,`symbols`,``],[`⭕️`,`heavy large circle`,`symbols`,``],[`⤴`,`arrow pointing rightwards then curving upwards`,`symbols`,``],[`⤴️`,`arrow pointing rightwards then curving upwards`,`symbols`,``],[`⤵`,`arrow pointing rightwards then curving downwards`,`symbols`,``],[`⤵️`,`arrow pointing rightwards then curving downwards`,`symbols`,``],[`〰`,`wavy dash`,`symbols`,``],[`〰️`,`wavy dash`,`symbols`,``],[`〽`,`part alternation mark`,`symbols`,``],[`〽️`,`part alternation mark`,`symbols`,``],[`㊗`,`circled ideograph congratulation`,`symbols`,``],[`㊗️`,`circled ideograph congratulation`,`symbols`,``],[`㊙`,`circled ideograph secret`,`symbols`,``],[`㊙️`,`circled ideograph secret`,`symbols`,``],[`©`,`copyright sign`,`symbols`,``],[`©️`,`copyright sign`,`symbols`,``],[`®`,`registered sign`,`symbols`,``],[`®️`,`registered sign`,`symbols`,``],[`👨💻`,`man technologist`,`people`,`程序员,开发者,工程师,码农`],[`👩💻`,`woman technologist`,`people`,`程序员,开发者,工程师`],[`🧑💻`,`technologist`,`people`,`程序员,开发者,工程师`],[`👨🔧`,`man mechanic`,`people`,``],[`👩🔧`,`woman mechanic`,`people`,``],[`👨🎨`,`man artist`,`people`,``],[`👩🎨`,`woman artist`,`people`,``],[`👨🚀`,`man astronaut`,`people`,``],[`👩🚀`,`woman astronaut`,`people`,``],[`👨⚕️`,`man health worker`,`people`,``],[`👩⚕️`,`woman health worker`,`people`,``],[`👨🏫`,`man teacher`,`people`,``],[`👩🏫`,`woman teacher`,`people`,``],[`👨🍳`,`man cook`,`people`,``],[`👩🍳`,`woman cook`,`people`,``],[`👨🌾`,`man farmer`,`people`,``],[`👩🌾`,`woman farmer`,`people`,``],[`👩🏭`,`woman factory worker`,`people`,``],[`👨🎓`,`man student`,`people`,``],[`👩🎓`,`woman student`,`people`,``],[`👨🚒`,`man firefighter`,`people`,``],[`👩🚒`,`woman firefighter`,`people`,``],[`👨⚖️`,`man judge`,`people`,``],[`👩⚖️`,`woman judge`,`people`,``],[`👨💼`,`man office worker`,`people`,``],[`👩💼`,`woman office worker`,`people`,``],[`👨🎤`,`man singer`,`people`,``],[`👩🎤`,`woman singer`,`people`,``],[`👨🦰`,`man red hair`,`people`,``],[`👩🦰`,`woman red hair`,`people`,``],[`👨🦱`,`man curly hair`,`people`,``],[`👩🦱`,`woman curly hair`,`people`,``],[`👩🦲`,`woman bald`,`people`,``],[`👨🦳`,`man white hair`,`people`,``],[`👩🦳`,`woman white hair`,`people`,``],[`👩❤️👨`,`couple with heart`,`people`,``],[`👨❤️👨`,`couple with heart`,`people`,``],[`👩❤️👩`,`couple with heart`,`people`,``],[`👨👩👧`,`family man woman girl`,`people`,``],[`👨👩👦`,`family man woman boy`,`people`,``],[`👨👩👧👦`,`family man woman girl boy`,`people`,``],[`👨👩👦👦`,`man`,`people`,``],[`👨👩👧👧`,`family man woman girl girl`,`people`,``],[`👩👩👧`,`family woman woman girl`,`people`,``],[`👨👨👧`,`family man man girl`,`people`,``],[`👨👦`,`family man boy`,`people`,``],[`👩👧`,`family woman girl`,`people`,``],[`👨👧👦`,`family man girl boy`,`people`,``],[`👩❤️💋👨`,`kiss woman man`,`people`,``],[`🧑🤝🧑`,`people holding hands`,`people`,``],[`❤️🔥`,`heart on fire`,`smileys`,``],[`🧑🚒`,`firefighter`,`people`,`消防员`],[`🧑🏭`,`factory worker`,`people`,``],[`🧑🎓`,`student`,`people`,`学生,毕业生,大学生`],[`🧑🏫`,`teacher`,`people`,`老师,教师,教授`],[`🧑🎤`,`singer`,`people`,`歌手,歌星`],[`🧑⚕️`,`health worker`,`people`,`医生,医疗`],[`🧑⚖️`,`judge`,`people`,`法官,审判`],[`🧑🍳`,`cook`,`people`,`厨师,大厨`],[`🧑🌾`,`farmer`,`people`,`农民,农夫`],[`🧑🎨`,`artist`,`people`,`画家,艺术家`],[`🧑🔬`,`scientist`,`people`,``],[`🧑🔧`,`mechanic`,`people`,`技工,维修工`],[`🧑💼`,`office worker`,`people`,`白领,上班族,职员`],[`🧑🚀`,`astronaut`,`people`,`宇航员,太空人`],[`🏃♂️`,`man running`,`activity`,``],[`🏃♀️`,`woman running`,`activity`,``],[`🚶♂️`,`man walking`,`travel`,``],[`🚶♀️`,`woman walking`,`travel`,``],[`🧎♂️`,`man kneeling`,`symbols`,``],[`🧎♀️`,`woman kneeling`,`symbols`,``],[`🏋️♂️`,`man lifting weights`,`activity`,``],[`🏋️♀️`,`woman lifting weights`,`activity`,``],[`🤸♂️`,`man cartwheeling`,`people`,``],[`🤸♀️`,`woman cartwheeling`,`people`,``],[`⛹️♂️`,`man bouncing ball`,`activity`,``],[`⛹️♀️`,`woman bouncing ball`,`activity`,``],[`🤾♂️`,`man playing handball`,`activity`,``],[`🤾♀️`,`woman playing handball`,`activity`,``],[`🧘♀️`,`woman in lotus position`,`people`,``],[`🏄♂️`,`man surfing`,`activity`,``],[`🏄♀️`,`woman surfing`,`activity`,``],[`🏊♂️`,`man swimming`,`activity`,``],[`🏊♀️`,`woman swimming`,`activity`,``],[`🚴♂️`,`man biking`,`travel`,``],[`🚴♀️`,`woman biking`,`travel`,``],[`🚵♂️`,`man mountain biking`,`travel`,``],[`🚵♀️`,`woman mountain biking`,`travel`,``],[`👯♂️`,`men with bunny ears`,`people`,``],[`👯♀️`,`women with bunny ears`,`people`,``],[`🧖♂️`,`man in steamy room`,`people`,``],[`🧖♀️`,`woman in steamy room`,`people`,``],[`🧗♂️`,`man climbing`,`people`,``],[`🧗♀️`,`woman climbing`,`people`,``],[`🤦♂️`,`man facepalming`,`smileys`,``],[`🤦♀️`,`woman facepalming`,`smileys`,``],[`🤷♂️`,`man shrugging`,`people`,``],[`🤷♀️`,`woman shrugging`,`people`,``],[`🙍♂️`,`person frowning`,`smileys`,``],[`🙍♀️`,`woman frowning`,`smileys`,``],[`🙎♂️`,`man pouting`,`smileys`,``],[`🙎♀️`,`woman pouting`,`smileys`,``],[`🙅♂️`,`man gesturing no`,`smileys`,``],[`🙅♀️`,`woman gesturing no`,`smileys`,``],[`🙆♂️`,`man gesturing ok`,`smileys`,``],[`🙆♀️`,`woman gesturing ok`,`smileys`,``],[`💁♂️`,`man tipping hand`,`people`,``],[`💁♀️`,`woman tipping hand`,`people`,``],[`🙋♂️`,`man raising hand`,`smileys`,``],[`🙋♀️`,`woman raising hand`,`smileys`,``],[`🙇♂️`,`man bowing`,`smileys`,``],[`🙇♀️`,`woman bowing`,`smileys`,``],[`💆♂️`,`man getting massage`,`people`,``],[`💆♀️`,`woman getting massage`,`people`,``],[`💇♂️`,`man getting haircut`,`people`,``],[`💇♀️`,`woman getting haircut`,`people`,``],[`🧞♂️`,`man genie`,`people`,``],[`🧞♀️`,`woman genie`,`people`,``],[`🧟♂️`,`man zombie`,`people`,``],[`🧟♀️`,`woman zombie`,`people`,``],[`🧜♂️`,`merman`,`people`,``],[`🧚♂️`,`man fairy`,`people`,``],[`🧚♀️`,`woman fairy`,`people`,``],[`🧛♂️`,`man vampire`,`people`,``],[`🧛♀️`,`woman vampire`,`people`,``],[`🧙♂️`,`man mage`,`people`,``],[`🧙♀️`,`mage`,`people`,``],[`🧝♂️`,`man elf`,`people`,``],[`🧝♀️`,`woman elf`,`people`,``],[`🦸♂️`,`man superhero`,`people`,``],[`🦸♀️`,`woman superhero`,`people`,``],[`🦹♂️`,`man supervillain`,`people`,``],[`🦹♀️`,`woman supervillain`,`people`,``],[`0️⃣`,`keycap 0`,`symbols`,``],[`1️⃣`,`keycap 1`,`symbols`,``],[`2️⃣`,`keycap 2`,`symbols`,``],[`3️⃣`,`keycap 3`,`symbols`,``],[`4️⃣`,`keycap 4`,`symbols`,``],[`5️⃣`,`keycap 5`,`symbols`,``],[`6️⃣`,`keycap 6`,`symbols`,``],[`7️⃣`,`keycap 7`,`symbols`,``],[`8️⃣`,`keycap 8`,`symbols`,``],[`9️⃣`,`keycap 9`,`symbols`,``],[`#️⃣`,`keycap #`,`symbols`,``],[`*️⃣`,`keycap *`,`symbols`,``],[`🇨🇳`,`flag china`,`flags`,`中国,国旗,五星红旗`],[`🇺🇸`,`flag united states`,`flags`,`美国,国旗,USA`],[`🇬🇧`,`flag united kingdom`,`flags`,`英国,国旗,UK`],[`🇯🇵`,`flag japan`,`flags`,`日本,国旗`],[`🇫🇷`,`flag france`,`flags`,`法国,国旗`],[`🇩🇪`,`flag germany`,`flags`,`德国,国旗`],[`🇮🇹`,`flag italy`,`flags`,`意大利,国旗`],[`🇪🇸`,`flag spain`,`flags`,`西班牙,国旗`],[`🇷🇺`,`flag russia`,`flags`,`俄罗斯,国旗`],[`🇮🇳`,`regional indicator symbol letter i`,`flags`,`印度,国旗`],[`🇧🇷`,`flag brazil`,`flags`,`巴西,国旗`],[`🇨🇦`,`flag canada`,`flags`,`加拿大,国旗`],[`🇦🇺`,`flag australia`,`flags`,`澳大利亚,国旗`],[`🇸🇬`,`flag singapore`,`flags`,`新加坡,国旗`],[`🇭🇰`,`flag hong kong`,`flags`,`香港,国旗,区旗`],[`🇹🇼`,`flag taiwan`,`flags`,`台湾,国旗`],[`🇲🇴`,`flag macau`,`flags`,`澳门,国旗`],[`🇻🇳`,`flag vietnam`,`flags`,`越南,国旗`],[`🇲🇾`,`regional indicator symbol letter m`,`flags`,`马来西亚,国旗`],[`🇮🇩`,`flag indonesia`,`flags`,`印尼,国旗`],[`🇵🇭`,`flag philippines`,`flags`,`菲律宾,国旗`],[`🇹🇷`,`flag turkey`,`flags`,`土耳其,国旗`],[`🇸🇦`,`flag saudi arabia`,`flags`,`沙特,国旗`],[`🇦🇪`,`flag united arab emirates`,`flags`,`阿联酋,国旗`],[`🇳🇱`,`flag netherlands`,`flags`,`荷兰,国旗`],[`🇸🇪`,`flag sweden`,`flags`,`瑞典,国旗`],[`🇨🇭`,`flag switzerland`,`flags`,`瑞士,国旗`],[`🇦🇹`,`flag austria`,`flags`,`奥地利,国旗`],[`🇧🇪`,`flag belgium`,`flags`,`比利时,国旗`],[`🇵🇹`,`flag portugal`,`flags`,`葡萄牙,国旗`],[`🇬🇷`,`flag greece`,`flags`,`希腊,国旗`],[`🇳🇴`,`flag norway`,`flags`,`挪威,国旗`],[`🇩🇰`,`flag denmark`,`flags`,`丹麦,国旗`],[`🇫🇮`,`flag finland`,`flags`,`芬兰,国旗`],[`🇵🇱`,`flag poland`,`flags`,`波兰,国旗`],[`🇺🇦`,`flag ukraine`,`flags`,`乌克兰,国旗`],[`🇮🇱`,`flag israel`,`flags`,`以色列,国旗`],[`🇪🇬`,`flag egypt`,`flags`,`埃及,国旗`],[`🇿🇦`,`flag south africa`,`flags`,`南非,国旗`],[`🇳🇬`,`flag nigeria`,`flags`,`尼日利亚,国旗`],[`🇲🇽`,`flag mexico`,`flags`,`墨西哥,国旗`],[`🇦🇷`,`flag argentina`,`flags`,``],[`🇨🇱`,`flag chile`,`flags`,`智利,国旗`],[`🇰🇿`,`flag kazakhstan`,`flags`,`哈萨克斯坦,国旗`],[`🇺🇿`,`flag uzbekistan`,`flags`,`乌兹别克斯坦,国旗`],[`🇳🇿`,`flag new zealand`,`flags`,`新西兰,国旗`],[`🇮🇪`,`flag ireland`,`flags`,`爱尔兰,国旗`],[`🇨🇿`,`flag czechia`,`flags`,`捷克,国旗`],[`👍🏻`,`thumbs up light skin`,`people`,``],[`👍🏽`,`thumbs up sign`,`people`,``],[`👍🏾`,`thumbs up medium dark skin`,`people`,``],[`👍🏿`,`thumbs up dark skin`,`people`,``],[`👏🏻`,`clapping hands light skin`,`people`,``],[`👏🏼`,`clapping hands medium light skin`,`people`,``],[`👏🏽`,`clapping hands medium skin`,`people`,``],[`👏🏾`,`clapping hands medium dark skin`,`people`,``],[`👏🏿`,`clapping hands dark skin`,`people`,``],[`🙏🏻`,`folded hands light skin`,`smileys`,``],[`🙏🏼`,`folded hands medium light skin`,`smileys`,``],[`🙏🏽`,`folded hands medium skin`,`smileys`,``],[`🙏🏾`,`folded hands medium dark skin`,`smileys`,``],[`🙏🏿`,`folded hands dark skin`,`smileys`,``],[`🏳️🌈`,`rainbow flag`,`flags`,``],[`🏴☠️`,`pirate flag`,`flags`,`海盗旗,海盗`]];r(`zh`,{agentMgr:{allTools:`全部`,defaultAgentName:`默认助手`,defaultAgentDesc:`全能 AI 助手,拥有所有工具能力`,switchedTo:`已切换到:{name}`,editAgent:`编辑助手`,templateLoaded:`已加载模板:{name}`,noSkillsHint:`暂无启用技能(请先确认 Agent 已连接且技能开关已开启)`,nameRequired:`请输入助手名称`,agentUpdated:`助手已更新`,agentCreated:`助手 "{name}" 已创建`,saveFailed:`保存失败:{message}`,confirmDeleteAgentMessage:`确定要删除助手 "{name}" 吗?
|
|
2194
|
+
`).join(``),e.querySelectorAll(`.ref-chip-close`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),H.selectedMcpServices=H.selectedMcpServices.filter(t=>t.serverName!==e.dataset.serverName),bk(),xk()})}),e.style.display=`flex`}}function xk(){let e=new Set(H.selectedMcpServices.map(e=>e.serverName));document.querySelectorAll(`.mcp-list-item, .merged-mcp-item`).forEach(t=>{t.classList.toggle(`picked`,e.has(t.dataset.serverName))})}function Sk(){let e=document.getElementById(`mcpIndicatorClose`);e&&e.addEventListener(`click`,vk)}function Ck(){let e=document.getElementById(`promptDropdownHeader`);if(!e||e.querySelector(`.mcp-manage-btn`))return;let t=document.createElement(`button`);t.className=`mcp-manage-btn`,t.title=i(`promptSelector.mcpManageTitle`),t.style.display=`none`,t.style.fontSize=`13px`,t.innerHTML=`✚`,t.addEventListener(`click`,e=>{e.stopPropagation(),chrome.runtime.sendMessage({type:`OPEN_OPTIONS_PAGE`,hash:`toolbox`})}),e.appendChild(t)}var wk=[[`🀄`,`mahjong tile red dragon`,`symbols`,`麻将,红中`],[`🃏`,`playing card black joker`,`symbols`,``],[`🅰`,`negative squared latin capital letter a`,`symbols`,``],[`🅱`,`negative squared latin capital letter b`,`symbols`,``],[`🅾`,`negative squared latin capital letter o`,`symbols`,``],[`🅿`,`negative squared latin capital letter p`,`symbols`,``],[`🆎`,`negative squared ab`,`symbols`,``],[`🆑`,`squared cl`,`symbols`,``],[`🆒`,`squared cool`,`symbols`,``],[`🆓`,`squared free`,`symbols`,``],[`🆔`,`squared id`,`symbols`,``],[`🆕`,`squared new`,`symbols`,``],[`🆖`,`squared ng`,`symbols`,``],[`🆗`,`squared ok`,`symbols`,``],[`🆘`,`squared sos`,`symbols`,``],[`🆙`,`squared up with exclamation mark`,`symbols`,``],[`🆚`,`squared vs`,`symbols`,``],[`🇨🇩`,`regional indicator symbol letter c`,`flags`,``],[`🇬🇭`,`regional indicator symbol letter g`,`flags`,``],[`🇲🇳`,`regional indicator symbol letter m`,`flags`,``],[`🇷🇸`,`regional indicator symbol letter r`,`flags`,``],[`🈁`,`squared katakana koko`,`symbols`,``],[`🈂`,`squared katakana sa`,`symbols`,``],[`🈚`,`squared cjk unified ideograph-7121`,`symbols`,``],[`🈯`,`squared cjk unified ideograph-6307`,`symbols`,``],[`🈲`,`squared cjk unified ideograph-7981`,`symbols`,``],[`🈳`,`squared cjk unified ideograph-7a7a`,`symbols`,``],[`🈴`,`squared cjk unified ideograph-5408`,`symbols`,``],[`🈵`,`squared cjk unified ideograph-6e80`,`symbols`,``],[`🈶`,`squared cjk unified ideograph-6709`,`symbols`,``],[`🈷`,`squared cjk unified ideograph-6708`,`symbols`,``],[`🈸`,`squared cjk unified ideograph-7533`,`symbols`,``],[`🈹`,`squared cjk unified ideograph-5272`,`symbols`,``],[`🈺`,`squared cjk unified ideograph-55b6`,`symbols`,``],[`🉐`,`circled ideograph advantage`,`symbols`,``],[`🉑`,`circled ideograph accept`,`symbols`,``],[`🌀`,`cyclone`,`symbols`,`台风,龙卷风,旋风`],[`🌁`,`foggy`,`symbols`,`雾,雾霾,朦胧`],[`🌂`,`closed umbrella`,`symbols`,``],[`🌃`,`night with stars`,`symbols`,`夜晚,星空,城市`],[`🌄`,`sunrise over mountains`,`symbols`,`日出,山,早晨`],[`🌅`,`sunrise`,`symbols`,`日出,太阳,早晨`],[`🌆`,`cityscape at dusk`,`symbols`,`黄昏,傍晚,城市`],[`🌇`,`sunset over buildings`,`symbols`,`日落,黄昏`],[`🌈`,`rainbow`,`symbols`,`彩虹,雨后`],[`🌉`,`bridge at night`,`symbols`,`桥,大桥`],[`🌊`,`water wave`,`symbols`,`海浪,波浪,海`],[`🌋`,`volcano`,`symbols`,`火山,爆发`],[`🌌`,`milky way`,`symbols`,``],[`🌍`,`earth globe europe-africa`,`symbols`,``],[`🌎`,`earth globe americas`,`symbols`,`地球,美洲`],[`🌏`,`earth globe asia-australia`,`symbols`,`地球,亚洲`],[`🌐`,`globe with meridians`,`symbols`,``],[`🌑`,`new moon symbol`,`symbols`,``],[`🌒`,`waxing crescent moon symbol`,`symbols`,``],[`🌓`,`first quarter moon symbol`,`symbols`,``],[`🌔`,`waxing gibbous moon symbol`,`symbols`,``],[`🌕`,`full moon symbol`,`symbols`,``],[`🌖`,`waning gibbous moon symbol`,`symbols`,``],[`🌗`,`last quarter moon symbol`,`symbols`,``],[`🌘`,`waning crescent moon symbol`,`symbols`,``],[`🌙`,`crescent moon`,`symbols`,``],[`🌚`,`new moon with face`,`symbols`,``],[`🌛`,`first quarter moon with face`,`symbols`,``],[`🌜`,`last quarter moon with face`,`symbols`,``],[`🌝`,`full moon with face`,`symbols`,``],[`🌞`,`sun with face`,`symbols`,``],[`🌟`,`glowing star`,`symbols`,`星星,闪光,闪耀`],[`🌠`,`shooting star`,`symbols`,``],[`🌡`,`thermometer`,`symbols`,``],[`🌤`,`white sun with small cloud`,`symbols`,``],[`🌥`,`white sun behind cloud`,`symbols`,``],[`🌦`,`white sun behind cloud with rain`,`symbols`,``],[`🌧`,`cloud with rain`,`symbols`,``],[`🌨`,`cloud with snow`,`symbols`,``],[`🌩`,`cloud with lightning`,`symbols`,``],[`🌪`,`cloud with tornado`,`symbols`,``],[`🌫`,`fog`,`symbols`,``],[`🌬`,`wind blowing face`,`symbols`,``],[`🌭`,`hot dog`,`food`,`热狗`],[`🌮`,`taco`,`food`,`墨西哥卷饼`],[`🌯`,`burrito`,`food`,`墨西哥卷,卷饼`],[`🌰`,`chestnut`,`food`,`栗子,坚果`],[`🌱`,`seedling`,`food`,``],[`🌲`,`evergreen tree`,`food`,`松树,树`],[`🌳`,`deciduous tree`,`food`,`树,大树`],[`🌴`,`palm tree`,`food`,`棕榈树,热带,度假`],[`🌵`,`cactus`,`food`,`仙人掌,沙漠`],[`🌶`,`hot pepper`,`food`,``],[`🌷`,`tulip`,`food`,`郁金香,花`],[`🌸`,`cherry blossom`,`food`,`樱花,花,春天`],[`🌹`,`rose`,`food`,`玫瑰,花,爱情`],[`🌺`,`hibiscus`,`food`,`花,芙蓉`],[`🌻`,`sunflower`,`food`,`向日葵,花,太阳`],[`🌼`,`blossom`,`food`,`雏菊,花`],[`🌽`,`ear of maize`,`food`,`玉米`],[`🌾`,`ear of rice`,`food`,``],[`🌿`,`herb`,`food`,`草,植物,草药`],[`🍀`,`four leaf clover`,`food`,`四叶草,幸运,好运`],[`🍁`,`maple leaf`,`food`,`枫叶,秋天,红叶`],[`🍂`,`fallen leaf`,`food`,`落叶,秋天`],[`🍃`,`leaf fluttering in wind`,`food`,`树叶,风`],[`🍄`,`mushroom`,`food`,`蘑菇,菌`],[`🍅`,`tomato`,`food`,`番茄,西红柿`],[`🍆`,`aubergine`,`food`,`茄子`],[`🍇`,`grapes`,`food`,`葡萄`],[`🍈`,`melon`,`food`,`哈密瓜,甜瓜`],[`🍉`,`watermelon`,`food`,`西瓜`],[`🍊`,`tangerine`,`food`,`橙子,橘子`],[`🍋`,`lemon`,`food`,`柠檬`],[`🍌`,`banana`,`food`,`香蕉`],[`🍍`,`pineapple`,`food`,`菠萝`],[`🍎`,`red apple`,`food`,`苹果`],[`🍏`,`green apple`,`food`,``],[`🍐`,`pear`,`food`,`梨`],[`🍑`,`peach`,`food`,`桃子,蜜桃`],[`🍒`,`cherries`,`food`,`樱桃,车厘子`],[`🍓`,`strawberry`,`food`,`草莓`],[`🍔`,`hamburger`,`food`,`汉堡,汉堡包`],[`🍕`,`slice of pizza`,`food`,`披萨,比萨`],[`🍖`,`meat on bone`,`food`,`骨头,肉,排骨`],[`🍗`,`poultry leg`,`food`,`鸡腿,炸鸡`],[`🍘`,`rice cracker`,`food`,`米饼,仙贝`],[`🍙`,`rice ball`,`food`,`饭团`],[`🍚`,`cooked rice`,`food`,`米饭,饭`],[`🍛`,`curry and rice`,`food`,`咖喱,咖喱饭`],[`🍜`,`steaming bowl`,`food`,`面条,拉面,面`],[`🍝`,`spaghetti`,`food`,`意大利面,意面`],[`🍞`,`bread`,`food`,`面包`],[`🍟`,`french fries`,`food`,`薯条,炸薯条`],[`🍠`,`roasted sweet potato`,`food`,`红薯,地瓜`],[`🍡`,`dango`,`food`,`团子,丸子`],[`🍢`,`oden`,`food`,`关东煮,串`],[`🍣`,`sushi`,`food`,`寿司,三文鱼`],[`🍤`,`fried shrimp`,`food`,`炸虾,天妇罗`],[`🍥`,`fish cake with swirl design`,`food`,`鱼板,鸣门卷`],[`🍦`,`soft ice cream`,`food`,`冰淇淋,甜筒`],[`🍧`,`shaved ice`,`food`,`刨冰,冰沙`],[`🍨`,`ice cream`,`food`,`冰淇淋,圣代`],[`🍩`,`doughnut`,`food`,``],[`🍪`,`cookie`,`food`,``],[`🍫`,`chocolate bar`,`food`,`巧克力`],[`🍬`,`candy`,`food`,`糖果,糖`],[`🍭`,`lollipop`,`food`,`棒棒糖`],[`🍮`,`custard`,`food`,`布丁,焦糖`],[`🍯`,`honey pot`,`food`,`蜂蜜,蜜`],[`🍰`,`shortcake`,`food`,`蛋糕,奶油蛋糕`],[`🍱`,`bento box`,`food`,`便当,盒饭`],[`🍲`,`pot of food`,`food`,`火锅,汤锅,炖菜`],[`🍳`,`cooking`,`food`,`煎蛋,鸡蛋`],[`🍴`,`fork and knife`,`food`,`刀叉,餐具`],[`🍵`,`teacup without handle`,`food`,`绿茶,茶,抹茶`],[`🍶`,`sake bottle and cup`,`food`,`清酒,日本酒`],[`🍷`,`wine glass`,`food`,`红酒,葡萄酒,酒`],[`🍸`,`cocktail glass`,`food`,`鸡尾酒,马提尼`],[`🍹`,`tropical drink`,`food`,`果汁,鸡尾酒`],[`🍺`,`beer mug`,`food`,`啤酒,啤酒杯`],[`🍻`,`clinking beer mugs`,`food`,`干杯,碰杯,啤酒`],[`🍼`,`baby bottle`,`food`,`奶瓶,婴儿,奶粉`],[`🍽`,`fork and knife with plate`,`food`,``],[`🍾`,`bottle with popping cork`,`food`,`香槟,起泡酒,庆祝`],[`🍿`,`popcorn`,`food`,``],[`🎀`,`ribbon`,`activity`,`蝴蝶结,礼物,装饰`],[`🎁`,`wrapped present`,`activity`,`礼物,礼盒,生日`],[`🎂`,`birthday cake`,`activity`,`生日蛋糕,生日,蛋糕`],[`🎃`,`jack-o-lantern`,`activity`,``],[`🎄`,`christmas tree`,`activity`,``],[`🎅`,`father christmas`,`activity`,`圣诞老人,圣诞,圣诞节`],[`🎆`,`fireworks`,`activity`,``],[`🎇`,`firework sparkler`,`activity`,``],[`🎈`,`balloon`,`activity`,`气球,庆祝,派对`],[`🎉`,`party popper`,`activity`,`彩带,庆祝,派对,欢呼`],[`🎊`,`confetti ball`,`activity`,`庆祝`],[`🎋`,`tanabata tree`,`activity`,``],[`🎌`,`crossed flags`,`flags`,`旗,日本,交叉旗`],[`🎍`,`pine decoration`,`activity`,``],[`🎎`,`japanese dolls`,`activity`,`人偶,日本人偶`],[`🎏`,`carp streamer`,`activity`,`鲤鱼旗,日本,端午节`],[`🎐`,`wind chime`,`activity`,`风铃,夏天`],[`🎑`,`moon viewing ceremony`,`activity`,``],[`🎒`,`school satchel`,`activity`,`书包,背包`],[`🎓`,`graduation cap`,`activity`,`学士帽,毕业,学位`],[`🎖`,`military medal`,`activity`,``],[`🎗`,`reminder ribbon`,`activity`,``],[`🎙`,`studio microphone`,`activity`,``],[`🎚`,`level slider`,`activity`,``],[`🎛`,`control knobs`,`activity`,``],[`🎞`,`film frames`,`activity`,``],[`🎟`,`admission tickets`,`activity`,``],[`🎠`,`carousel horse`,`activity`,`旋转木马,游乐园`],[`🎡`,`ferris wheel`,`activity`,`摩天轮,游乐园`],[`🎢`,`roller coaster`,`activity`,`过山车,游乐园`],[`🎣`,`fishing pole and fish`,`activity`,`钓鱼`],[`🎤`,`microphone`,`activity`,`麦克风,唱歌,K歌`],[`🎥`,`movie camera`,`activity`,`摄影机,电影,拍摄`],[`🎦`,`cinema`,`activity`,``],[`🎧`,`headphone`,`activity`,`耳机,听歌,音乐,戴`],[`🎨`,`artist palette`,`activity`,`调色板,画画,美术,艺术`],[`🎩`,`top hat`,`activity`,`礼帽,魔术帽,帽子`],[`🎪`,`circus tent`,`activity`,`马戏团`],[`🎫`,`ticket`,`activity`,`门票,票,入场券`],[`🎬`,`clapper board`,`activity`,`场记板,电影,拍戏,导演`],[`🎭`,`performing arts`,`activity`,`面具,戏剧,表演,舞台`],[`🎮`,`video game`,`activity`,`游戏机,游戏,手柄,玩`],[`🎯`,`direct hit`,`activity`,`目标`],[`🎰`,`slot machine`,`activity`,``],[`🎱`,`billiards`,`activity`,`台球`],[`🎲`,`game die`,`activity`,`骰子,赌博,游戏`],[`🎳`,`bowling`,`activity`,`保龄球,球`],[`🎴`,`flower playing cards`,`activity`,`花牌,卡牌,纸牌`],[`🎵`,`musical note`,`activity`,`音符,音乐,歌`],[`🎶`,`multiple musical notes`,`activity`,`音符,音乐,唱歌`],[`🎷`,`saxophone`,`activity`,`萨克斯,爵士,乐器`],[`🎸`,`guitar`,`activity`,`吉他,弹吉他,摇滚`],[`🎹`,`musical keyboard`,`activity`,`钢琴,键盘,弹琴`],[`🎺`,`trumpet`,`activity`,`小号,喇叭,乐器`],[`🎻`,`violin`,`activity`,`小提琴,弦乐`],[`🎼`,`musical score`,`activity`,`乐谱,音乐,谱`],[`🎽`,`running shirt with sash`,`activity`,`背心`],[`🎾`,`tennis racquet and ball`,`activity`,`网球,球`],[`🎿`,`ski and ski boot`,`activity`,`滑雪`],[`🏀`,`basketball and hoop`,`activity`,`篮球,球`],[`🏁`,`chequered flag`,`flags`,`终点,旗帜,赛车,比赛`],[`🏂`,`snowboarder`,`activity`,``],[`🏃`,`runner`,`activity`,`跑步,跑,奔跑`],[`🏄`,`surfer`,`activity`,``],[`🏅`,`sports medal`,`activity`,`奖牌,奖章,荣誉`],[`🏆`,`trophy`,`activity`,``],[`🏇`,`horse racing`,`activity`,``],[`🏈`,`american football`,`activity`,`橄榄球,美式足球`],[`🏉`,`rugby football`,`activity`,`橄榄球,英式`],[`🏊`,`swimmer`,`activity`,``],[`🏋`,`weight lifter`,`activity`,``],[`🏌`,`golfer`,`activity`,``],[`🏍`,`racing motorcycle`,`activity`,``],[`🏎`,`racing car`,`activity`,``],[`🏏`,`cricket bat and ball`,`activity`,``],[`🏐`,`volleyball`,`activity`,`排球,球`],[`🏑`,`field hockey stick and ball`,`activity`,``],[`🏒`,`ice hockey stick and puck`,`activity`,``],[`🏓`,`table tennis paddle and ball`,`activity`,`乒乓球,乒乓,球`],[`🏔`,`snow capped mountain`,`activity`,``],[`🏕`,`camping`,`activity`,``],[`🏖`,`beach with umbrella`,`activity`,``],[`🏗`,`building construction`,`activity`,``],[`🏘`,`house buildings`,`activity`,``],[`🏙`,`cityscape`,`activity`,``],[`🏚`,`derelict house building`,`activity`,``],[`🏛`,`classical building`,`activity`,``],[`🏜`,`desert`,`activity`,``],[`🏝`,`desert island`,`activity`,``],[`🏞`,`national park`,`activity`,``],[`🏟`,`stadium`,`activity`,``],[`🏠`,`house building`,`travel`,`房子,家,住宅`],[`🏡`,`house with garden`,`travel`,`房子,家,花园`],[`🏢`,`office building`,`travel`,`办公楼,大楼,写字楼`],[`🏣`,`japanese post office`,`travel`,`邮局,邮政`],[`🏤`,`european post office`,`travel`,`邮局`],[`🏥`,`hospital`,`travel`,`医院,医疗`],[`🏦`,`bank`,`travel`,`银行,金融`],[`🏧`,`automated teller machine`,`travel`,``],[`🏨`,`hotel`,`travel`,`酒店,旅馆`],[`🏩`,`love hotel`,`travel`,`爱情旅馆,酒店`],[`🏪`,`convenience store`,`travel`,`便利店,商店`],[`🏫`,`school`,`travel`,`学校,校园`],[`🏬`,`department store`,`travel`,`商场,百货,购物`],[`🏭`,`factory`,`travel`,`工厂,工业`],[`🏮`,`izakaya lantern`,`travel`,``],[`🏯`,`japanese castle`,`objects`,`城堡,日本城堡`],[`🏰`,`european castle`,`travel`,`城堡,童话`],[`🏳`,`waving white flag`,`flags`,``],[`🏴`,`waving black flag`,`flags`,`黑旗`],[`🏵`,`rosette`,`objects`,``],[`🏷`,`label`,`objects`,``],[`🏸`,`badminton racquet and shuttlecock`,`activity`,`羽毛球,球`],[`🏹`,`bow and arrow`,`activity`,`射箭,弓箭,弓`],[`🏺`,`amphora`,`activity`,`陶罐,花瓶,双耳瓶`],[`🏻`,`emoji modifier fitzpatrick type-1-2`,`symbols`,``],[`🏼`,`emoji modifier fitzpatrick type-3`,`symbols`,``],[`🏽`,`emoji modifier fitzpatrick type-4`,`symbols`,``],[`🏾`,`emoji modifier fitzpatrick type-5`,`symbols`,``],[`🏿`,`emoji modifier fitzpatrick type-6`,`symbols`,``],[`🐀`,`rat`,`animals`,`老鼠,鼠`],[`🐁`,`mouse`,`animals`,`老鼠,鼠`],[`🐂`,`ox`,`animals`,`公牛,牛`],[`🐃`,`water buffalo`,`animals`,`水牛,牛`],[`🐄`,`cow`,`animals`,`奶牛,牛`],[`🐅`,`tiger`,`animals`,``],[`🐆`,`leopard`,`animals`,``],[`🐇`,`rabbit`,`animals`,`兔子,兔`],[`🐈`,`cat`,`animals`,`猫,猫咪`],[`🐉`,`dragon`,`animals`,`龙,中国龙`],[`🐊`,`crocodile`,`animals`,`鳄鱼,短吻鳄`],[`🐋`,`whale`,`animals`,`鲸鱼`],[`🐌`,`snail`,`animals`,``],[`🐍`,`snake`,`animals`,`蛇,爬行动物`],[`🐎`,`horse`,`animals`,``],[`🐏`,`ram`,`animals`,`羊,公羊`],[`🐐`,`goat`,`animals`,`山羊,羊`],[`🐑`,`sheep`,`animals`,`羊,绵羊`],[`🐒`,`monkey`,`animals`,``],[`🐓`,`rooster`,`animals`,`公鸡,鸡`],[`🐔`,`chicken`,`animals`,`鸡,母鸡`],[`🐕`,`dog`,`animals`,`狗,小狗`],[`🐖`,`pig`,`animals`,`猪`],[`🐗`,`boar`,`animals`,`野猪,猪`],[`🐘`,`elephant`,`animals`,`大象`],[`🐙`,`octopus`,`animals`,`章鱼,八爪鱼`],[`🐚`,`spiral shell`,`animals`,``],[`🐛`,`bug`,`animals`,``],[`🐜`,`ant`,`animals`,``],[`🐝`,`honeybee`,`animals`,``],[`🐞`,`lady beetle`,`animals`,``],[`🐟`,`fish`,`animals`,`鱼,鱼`],[`🐠`,`tropical fish`,`animals`,`热带鱼,鱼`],[`🐡`,`blowfish`,`animals`,`河豚,鱼`],[`🐢`,`turtle`,`animals`,`乌龟,慢`],[`🐣`,`hatching chick`,`animals`,`小鸡,破壳,孵化`],[`🐤`,`baby chick`,`animals`,`小鸡,黄,可爱`],[`🐥`,`front-facing baby chick`,`animals`,`小鸡,正面`],[`🐦`,`bird`,`animals`,`鸟`],[`🐧`,`penguin`,`animals`,`企鹅,南极`],[`🐨`,`koala`,`animals`,`考拉,无尾熊`],[`🐩`,`poodle`,`animals`,`贵宾犬,狗`],[`🐪`,`dromedary camel`,`animals`,`骆驼`],[`🐫`,`bactrian camel`,`animals`,`骆驼,双峰`],[`🐬`,`dolphin`,`animals`,`海豚,海洋`],[`🐭`,`mouse face`,`animals`,`老鼠,鼠`],[`🐮`,`cow face`,`animals`,`牛,奶牛`],[`🐯`,`tiger face`,`animals`,``],[`🐰`,`rabbit face`,`animals`,`兔子,兔,可爱`],[`🐱`,`cat face`,`animals`,``],[`🐲`,`dragon face`,`animals`,`龙,龙头`],[`🐳`,`spouting whale`,`animals`,`鲸鱼,喷水`],[`🐴`,`horse face`,`animals`,`马`],[`🐵`,`monkey face`,`animals`,``],[`🐶`,`dog face`,`animals`,``],[`🐷`,`pig face`,`animals`,`猪,猪头`],[`🐸`,`frog face`,`animals`,`青蛙,蛙`],[`🐹`,`hamster face`,`animals`,`仓鼠`],[`🐺`,`wolf face`,`animals`,``],[`🐻`,`bear face`,`animals`,`熊,泰迪熊`],[`🐼`,`panda face`,`animals`,``],[`🐽`,`pig nose`,`animals`,`猪鼻子,猪`],[`🐾`,`paw prints`,`animals`,`爪印,脚印`],[`🐿`,`chipmunk`,`animals`,``],[`👀`,`eyes`,`people`,``],[`👁`,`eye`,`people`,``],[`👂`,`ear`,`people`,`耳朵,听`],[`👃`,`nose`,`people`,`鼻子,闻`],[`👄`,`mouth`,`people`,`嘴巴,嘴唇,吻`],[`👅`,`tongue`,`people`,`舌头,舔`],[`👆`,`white up pointing backhand index`,`people`,`指,上面,向上`],[`👇`,`white down pointing backhand index`,`people`,`指,下面,向下`],[`👈`,`white left pointing backhand index`,`people`,`指,左边,指向`],[`👉`,`white right pointing backhand index`,`people`,`指,右边,指向`],[`👊`,`fisted hand sign`,`people`,`拳头,打,战斗`],[`👋`,`waving hand sign`,`people`,`挥手,再见,你好`],[`👌`,`ok hand sign`,`people`,`OK,好,可以`],[`👍`,`thumbs up sign`,`people`,`点赞,好,赞,棒`],[`👎`,`thumbs down sign`,`people`,`差评,不好,踩`],[`👏`,`clapping hands sign`,`people`,`鼓掌,拍手,掌声`],[`👐`,`open hands sign`,`people`,`张开,手,开放`],[`👑`,`crown`,`people`,`皇冠,王冠,国王,女王`],[`👒`,`womans hat`,`people`,`帽子,草帽,遮阳帽`],[`👓`,`eyeglasses`,`people`,`眼镜`],[`👔`,`necktie`,`people`,`领带,西装,工作`],[`👕`,`t-shirt`,`people`,`衣服,T恤`],[`👖`,`jeans`,`people`,`裤子,牛仔裤`],[`👗`,`dress`,`people`,`裙子,连衣裙`],[`👘`,`kimono`,`people`,`和服`],[`👙`,`bikini`,`people`,`比基尼,泳装`],[`👚`,`womans clothes`,`people`,`女装,衣服`],[`👛`,`purse`,`people`,`钱包,小包`],[`👜`,`handbag`,`people`,`手提包,包包`],[`👝`,`pouch`,`people`,`手拿包,包包`],[`👞`,`mans shoe`,`people`,`皮鞋,鞋`],[`👟`,`athletic shoe`,`people`,`运动鞋,跑鞋`],[`👠`,`high-heeled shoe`,`people`,`高跟鞋,鞋`],[`👡`,`womans sandal`,`people`,`凉鞋,鞋`],[`👢`,`womans boots`,`people`,`靴子,长靴`],[`👣`,`footprints`,`people`,`脚印,脚步,足迹`],[`👤`,`bust in silhouette`,`people`,`人,剪影,用户`],[`👥`,`busts in silhouette`,`people`,`人群,人,多个人`],[`👦`,`boy`,`people`,`男孩,小男孩`],[`👧`,`girl`,`people`,`女孩,小女孩`],[`👨`,`man`,`people`,`男人,男士`],[`👩`,`woman`,`people`,`女人,女士`],[`👪`,`family`,`people`,`家庭`],[`👫`,`woman and man holding hands`,`people`,``],[`👬`,`men holding hands`,`people`,``],[`👭`,`women holding hands`,`people`,``],[`👮`,`police officer`,`people`,`警察,警官`],[`👯`,`woman with bunny ears`,`people`,`兔子舞,蹦迪,派对`],[`👰`,`bride with veil`,`people`,`新娘,婚纱,结婚`],[`👱`,`person with blond hair`,`people`,``],[`👲`,`man with gua pi mao`,`people`,`中国人`],[`👳`,`man with turban`,`people`,`包头巾,印度,阿拉伯`],[`👴`,`older man`,`people`,`老人,老爷爷`],[`👵`,`older woman`,`people`,`老人,老奶奶`],[`👶`,`baby`,`people`,`婴儿,宝宝,小孩`],[`👷`,`construction worker`,`people`,`工人`],[`👸`,`princess`,`people`,`公主,女王`],[`👹`,`japanese ogre`,`people`,`妖怪,鬼,怪物`],[`👺`,`japanese goblin`,`people`,`天狗,怪物,鬼`],[`👻`,`ghost`,`people`,`幽灵,鬼,万圣节`],[`👼`,`baby angel`,`people`,`天使,婴儿,可爱`],[`👽`,`extraterrestrial alien`,`people`,`外星人,ET,飞碟`],[`👾`,`alien monster`,`people`,`外星人,怪兽,游戏`],[`👿`,`imp`,`people`,`恶魔,愤怒`],[`💀`,`skull`,`people`,`骷髅,死亡,骨头`],[`💁`,`information desk person`,`people`,``],[`💂`,`guardsman`,`people`,`卫兵,士兵`],[`💃`,`dancer`,`people`,`跳舞,舞女,跳舞`],[`💄`,`lipstick`,`people`,`口红,化妆`],[`💅`,`nail polish`,`people`,`美甲,指甲,涂`],[`💆`,`face massage`,`people`,`按摩,放松,头部`],[`💇`,`haircut`,`people`,`理发,剪发,发型`],[`💈`,`barber pole`,`people`,`理发店,理发`],[`💉`,`syringe`,`people`,`注射器,针,疫苗`],[`💊`,`pill`,`people`,`药丸,药,胶囊`],[`💋`,`kiss mark`,`people`,`吻,口红印,亲亲`],[`💌`,`love letter`,`people`,`情书,信,爱情`],[`💍`,`ring`,`people`,`戒指,钻戒,结婚`],[`💎`,`gem stone`,`people`,`钻石,宝石,珠宝`],[`💏`,`kiss`,`people`,``],[`💐`,`bouquet`,`smileys`,`花束,花,礼物`],[`💑`,`couple with heart`,`smileys`,``],[`💒`,`wedding`,`smileys`,`教堂,婚礼,教堂婚礼`],[`💓`,`beating heart`,`smileys`,`爱心,跳动,心跳`],[`💔`,`broken heart`,`smileys`,`心碎,伤心,破碎`],[`💕`,`two hearts`,`smileys`,`爱心,两个,喜欢`],[`💖`,`sparkling heart`,`smileys`,`爱心,闪光,喜欢`],[`💗`,`growing heart`,`smileys`,`爱心,跳动,喜欢`],[`💘`,`heart with arrow`,`smileys`,`爱心,箭,丘比特`],[`💙`,`blue heart`,`smileys`,``],[`💚`,`green heart`,`smileys`,``],[`💛`,`yellow heart`,`smileys`,``],[`💜`,`purple heart`,`smileys`,``],[`💝`,`heart with ribbon`,`smileys`,`爱心,礼物,蝴蝶结`],[`💞`,`revolving hearts`,`smileys`,`爱心,旋转,轮回`],[`💟`,`heart decoration`,`smileys`,`爱心,符号`],[`💠`,`diamond shape with a dot inside`,`objects`,``],[`💡`,`electric light bulb`,`objects`,``],[`💢`,`anger symbol`,`objects`,`生气,怒气`],[`💣`,`bomb`,`objects`,`炸弹,爆炸`],[`💤`,`sleeping symbol`,`objects`,`睡觉,打呼,困`],[`💥`,`collision symbol`,`objects`,``],[`💦`,`splashing sweat symbol`,`objects`,`汗,水,泪`],[`💧`,`droplet`,`objects`,`水滴,水,眼泪`],[`💨`,`dash symbol`,`objects`,`风,跑,快,烟雾`],[`💩`,`pile of poo`,`objects`,`大便,屎,狗屎`],[`💪`,`flexed biceps`,`people`,`肌肉,力量,加油,强壮`],[`💫`,`dizzy symbol`,`objects`,`星星,旋转`],[`💬`,`speech balloon`,`objects`,`对话,聊天`],[`💭`,`thought balloon`,`objects`,`想法,思考,气泡`],[`💮`,`white flower`,`objects`,``],[`💯`,`hundred points symbol`,`objects`,``],[`💰`,`money bag`,`objects`,`钱袋,钱,金钱`],[`💱`,`currency exchange`,`objects`,``],[`💲`,`heavy dollar sign`,`objects`,``],[`💳`,`credit card`,`objects`,`信用卡,银行卡,支付`],[`💴`,`banknote with yen sign`,`objects`,`日元,日圆,钱`],[`💵`,`banknote with dollar sign`,`objects`,`美元,美金,钱`],[`💶`,`banknote with euro sign`,`objects`,`欧元,钱`],[`💷`,`banknote with pound sign`,`objects`,`英镑,钱`],[`💸`,`money with wings`,`objects`,`钱,飞钱,花钱`],[`💹`,`chart with upwards trend and yen sign`,`objects`,`股票,上涨,图表,增长`],[`💺`,`seat`,`objects`,`座位,椅子,飞机座位`],[`💻`,`personal computer`,`objects`,`电脑,笔记本,笔记本电脑`],[`💼`,`briefcase`,`objects`,`公文包,工作,商务`],[`💽`,`minidisc`,`objects`,`光盘,磁盘`],[`💾`,`floppy disk`,`objects`,`软盘,保存`],[`💿`,`optical disc`,`objects`,`光盘,CD`],[`📀`,`dvd`,`objects`,`光盘,DVD`],[`📁`,`file folder`,`objects`,`文件夹`],[`📂`,`open file folder`,`objects`,`文件夹,打开`],[`📃`,`page with curl`,`objects`,`文件,文档`],[`📄`,`page facing up`,`objects`,`文件,文档,纸`],[`📅`,`calendar`,`objects`,`日历`],[`📆`,`tear-off calendar`,`objects`,`日历,日历页`],[`📇`,`card index`,`objects`,`名片,索引卡`],[`📈`,`chart with upwards trend`,`objects`,``],[`📉`,`chart with downwards trend`,`objects`,``],[`📊`,`bar chart`,`objects`,``],[`📋`,`clipboard`,`objects`,`剪贴板,清单,列表`],[`📌`,`pushpin`,`objects`,``],[`📍`,`round pushpin`,`objects`,``],[`📎`,`paperclip`,`objects`,``],[`📏`,`straight ruler`,`objects`,``],[`📐`,`triangular ruler`,`objects`,``],[`📑`,`bookmark tabs`,`objects`,`书签,标签,文件`],[`📒`,`ledger`,`objects`,``],[`📓`,`notebook`,`objects`,``],[`📔`,`notebook with decorative cover`,`objects`,``],[`📕`,`closed book`,`objects`,``],[`📖`,`open book`,`objects`,``],[`📗`,`green book`,`objects`,``],[`📘`,`blue book`,`objects`,``],[`📙`,`orange book`,`objects`,``],[`📚`,`books`,`objects`,``],[`📛`,`name badge`,`objects`,``],[`📜`,`scroll`,`objects`,``],[`📝`,`memo`,`objects`,`笔记,备忘录,写作,文档`],[`📞`,`telephone receiver`,`objects`,`电话`],[`📟`,`pager`,`objects`,`寻呼机,传呼机`],[`📠`,`fax machine`,`objects`,`传真机,传真`],[`📡`,`satellite antenna`,`objects`,`天线,卫星,信号`],[`📢`,`public address loudspeaker`,`objects`,``],[`📣`,`cheering megaphone`,`objects`,``],[`📤`,`outbox tray`,`objects`,`发送,输出,上传`],[`📥`,`inbox tray`,`objects`,`接收,下载,收件箱`],[`📦`,`package`,`objects`,`包裹,快递,箱子`],[`📧`,`e-mail symbol`,`objects`,`邮件,电子邮件`],[`📨`,`incoming envelope`,`objects`,`邮件,收到`],[`📩`,`envelope with downwards arrow above`,`objects`,`邮件,发送`],[`📪`,`closed mailbox with lowered flag`,`objects`,`邮箱,关闭`],[`📫`,`closed mailbox with raised flag`,`objects`,`邮箱,信箱,邮件`],[`📬`,`open mailbox with raised flag`,`objects`,`邮箱,有信`],[`📭`,`open mailbox with lowered flag`,`objects`,`邮箱,无信`],[`📮`,`postbox`,`objects`,`邮筒,邮政`],[`📯`,`postal horn`,`objects`,``],[`📰`,`newspaper`,`objects`,`报纸,新闻,报`],[`📱`,`mobile phone`,`objects`,`手机,智能手机,电话`],[`📲`,`mobile phone with rightwards arrow at left`,`objects`,`手机,接收,信号`],[`📳`,`vibration mode`,`objects`,``],[`📴`,`mobile phone off`,`objects`,``],[`📵`,`no mobile phones`,`objects`,``],[`📶`,`antenna with bars`,`objects`,``],[`📷`,`camera`,`objects`,`相机,拍照,照片`],[`📸`,`camera with flash`,`objects`,`相机,闪光灯,拍照`],[`📹`,`video camera`,`objects`,`摄像机,录像`],[`📺`,`television`,`objects`,``],[`📻`,`radio`,`objects`,`收音机,广播`],[`📼`,`videocassette`,`objects`,`录像带,磁带`],[`📽`,`film projector`,`objects`,``],[`📿`,`prayer beads`,`objects`,`念珠,佛珠,项链`],[`🔀`,`twisted rightwards arrows`,`objects`,``],[`🔁`,`clockwise rightwards and leftwards open circle arrows`,`objects`,``],[`🔂`,`clockwise rightwards and leftwards open circle arrows with circled one overlay`,`objects`,``],[`🔃`,`clockwise downwards and upwards open circle arrows`,`objects`,``],[`🔄`,`anticlockwise downwards and upwards open circle arrows`,`objects`,``],[`🔅`,`low brightness symbol`,`objects`,``],[`🔆`,`high brightness symbol`,`objects`,``],[`🔇`,`speaker with cancellation stroke`,`objects`,``],[`🔈`,`speaker`,`objects`,``],[`🔉`,`speaker with one sound wave`,`objects`,``],[`🔊`,`speaker with three sound waves`,`objects`,``],[`🔋`,`battery`,`objects`,``],[`🔌`,`electric plug`,`objects`,``],[`🔍`,`left-pointing magnifying glass`,`objects`,`搜索,放大镜,查找,查询`],[`🔎`,`right-pointing magnifying glass`,`objects`,`搜索,放大镜,查找`],[`🔏`,`lock with ink pen`,`objects`,`锁,保密,笔`],[`🔐`,`closed lock with key`,`objects`,`锁,安全,钥匙`],[`🔑`,`key`,`objects`,`钥匙,解锁`],[`🔒`,`lock`,`objects`,`锁,锁定,安全`],[`🔓`,`open lock`,`objects`,`解锁,打开`],[`🔔`,`bell`,`objects`,``],[`🔕`,`bell with cancellation stroke`,`objects`,``],[`🔖`,`bookmark`,`objects`,`书签,标记`],[`🔗`,`link symbol`,`objects`,``],[`🔘`,`radio button`,`objects`,``],[`🔙`,`back with leftwards arrow above`,`objects`,``],[`🔚`,`end with leftwards arrow above`,`objects`,``],[`🔛`,`on with exclamation mark with left right arrow above`,`objects`,``],[`🔜`,`soon with rightwards arrow above`,`objects`,``],[`🔝`,`top with upwards arrow above`,`objects`,``],[`🔞`,`no one under eighteen symbol`,`objects`,``],[`🔟`,`keycap 10`,`objects`,``],[`🔠`,`input symbol for latin capital letters`,`objects`,``],[`🔡`,`input symbol for latin small letters`,`objects`,``],[`🔢`,`input symbol for numbers`,`objects`,``],[`🔣`,`input symbol for symbols`,`objects`,``],[`🔤`,`input symbol for latin letters`,`objects`,``],[`🔥`,`fire`,`objects`,``],[`🔦`,`electric torch`,`objects`,``],[`🔧`,`wrench`,`objects`,`扳手,工具,维修`],[`🔨`,`hammer`,`objects`,`锤子,工具`],[`🔩`,`nut and bolt`,`objects`,`螺丝,螺母`],[`🔪`,`hocho`,`objects`,``],[`🔫`,`pistol`,`objects`,`枪`],[`🔬`,`microscope`,`objects`,`显微镜,科学,研究`],[`🔭`,`telescope`,`objects`,`望远镜,天文,观察`],[`🔮`,`crystal ball`,`objects`,``],[`🔯`,`six pointed star with middle dot`,`objects`,``],[`🔰`,`japanese symbol for beginner`,`objects`,``],[`🔱`,`trident emblem`,`objects`,``],[`🔲`,`black square button`,`objects`,``],[`🔳`,`white square button`,`objects`,``],[`🔴`,`large red circle`,`objects`,``],[`🔵`,`large blue circle`,`objects`,``],[`🔶`,`large orange diamond`,`objects`,``],[`🔷`,`large blue diamond`,`objects`,``],[`🔸`,`small orange diamond`,`objects`,``],[`🔹`,`small blue diamond`,`objects`,``],[`🔺`,`up-pointing red triangle`,`objects`,``],[`🔻`,`down-pointing red triangle`,`objects`,``],[`🔼`,`up-pointing small red triangle`,`objects`,``],[`🔽`,`down-pointing small red triangle`,`objects`,``],[`🕉`,`om symbol`,`objects`,``],[`🕊`,`dove of peace`,`objects`,``],[`🕋`,`kaaba`,`objects`,`天房,麦加,伊斯兰`],[`🕌`,`mosque`,`objects`,`清真寺,伊斯兰`],[`🕍`,`synagogue`,`objects`,`犹太教堂,犹太`],[`🕎`,`menorah with nine branches`,`objects`,``],[`🕐`,`clock face one oclock`,`objects`,`一点,时钟`],[`🕑`,`clock face two oclock`,`objects`,`两点,时钟`],[`🕒`,`clock face three oclock`,`objects`,`三点,时钟`],[`🕓`,`clock face four oclock`,`objects`,`四点,时钟`],[`🕔`,`clock face five oclock`,`objects`,`五点,时钟`],[`🕕`,`clock face six oclock`,`objects`,`六点,时钟`],[`🕖`,`clock face seven oclock`,`objects`,`七点,时钟`],[`🕗`,`clock face eight oclock`,`objects`,`八点,时钟`],[`🕘`,`clock face nine oclock`,`objects`,`九点,时钟`],[`🕙`,`clock face ten oclock`,`objects`,`十点,时钟`],[`🕚`,`clock face eleven oclock`,`objects`,`十一点,时钟`],[`🕛`,`clock face twelve oclock`,`objects`,`十二点,时钟,时间`],[`🕜`,`clock face one-thirty`,`objects`,``],[`🕝`,`clock face two-thirty`,`objects`,``],[`🕞`,`clock face three-thirty`,`objects`,``],[`🕟`,`clock face four-thirty`,`objects`,``],[`🕠`,`clock face five-thirty`,`objects`,``],[`🕡`,`clock face six-thirty`,`objects`,``],[`🕢`,`clock face seven-thirty`,`objects`,``],[`🕣`,`clock face eight-thirty`,`objects`,``],[`🕤`,`clock face nine-thirty`,`objects`,``],[`🕥`,`clock face ten-thirty`,`objects`,``],[`🕦`,`clock face eleven-thirty`,`objects`,``],[`🕧`,`clock face twelve-thirty`,`objects`,``],[`🕯`,`candle`,`objects`,``],[`🕰`,`mantelpiece clock`,`objects`,``],[`🕳`,`hole`,`objects`,``],[`🕴`,`man in business suit levitating`,`objects`,``],[`🕵`,`sleuth or spy`,`objects`,``],[`🕶`,`dark sunglasses`,`objects`,``],[`🕷`,`spider`,`objects`,``],[`🕸`,`spider web`,`objects`,``],[`🕹`,`joystick`,`objects`,``],[`🕺`,`man dancing`,`objects`,`跳舞,舞男`],[`🖇`,`linked paperclips`,`objects`,``],[`🖊`,`lower left ballpoint pen`,`objects`,``],[`🖋`,`lower left fountain pen`,`objects`,``],[`🖌`,`lower left paintbrush`,`objects`,``],[`🖍`,`lower left crayon`,`objects`,``],[`🖐`,`raised hand with fingers splayed`,`objects`,``],[`🖕`,`reversed hand with middle finger extended`,`objects`,`中指,骂人`],[`🖖`,`raised hand with part between middle and ring fingers`,`objects`,`瓦肯,举手,胜利`],[`🖤`,`black heart`,`objects`,``],[`🖥`,`desktop computer`,`objects`,``],[`🖨`,`printer`,`objects`,``],[`🖱`,`three button mouse`,`objects`,``],[`🖲`,`trackball`,`objects`,``],[`🖼`,`frame with picture`,`objects`,``],[`🗂`,`card index dividers`,`objects`,``],[`🗃`,`card file box`,`objects`,``],[`🗄`,`file cabinet`,`objects`,``],[`🗑`,`wastebasket`,`objects`,``],[`🗒`,`spiral note pad`,`objects`,``],[`🗓`,`spiral calendar pad`,`objects`,``],[`🗜`,`compression`,`objects`,``],[`🗝`,`old key`,`objects`,``],[`🗞`,`rolled-up newspaper`,`objects`,``],[`🗡`,`dagger knife`,`objects`,``],[`🗣`,`speaking head in silhouette`,`objects`,``],[`🗨`,`left speech bubble`,`objects`,``],[`🗯`,`right anger bubble`,`objects`,``],[`🗳`,`ballot box with ballot`,`objects`,``],[`🗺`,`world map`,`objects`,``],[`🗻`,`mount fuji`,`objects`,`富士山,山`],[`🗼`,`tokyo tower`,`objects`,`塔,东京塔`],[`🗽`,`statue of liberty`,`objects`,`自由女神像,纽约`],[`🗾`,`silhouette of japan`,`objects`,``],[`🗿`,`moyai`,`objects`,`雕像`],[`😀`,`grinning face`,`smileys`,`笑脸,开心,高兴`],[`😁`,`grinning face with smiling eyes`,`smileys`,`笑脸,开心`],[`😂`,`face with tears of joy`,`smileys`,`笑哭,大笑,笑`],[`😃`,`smiling face with open mouth`,`smileys`,`笑脸,开心`],[`😄`,`smiling face with open mouth and smiling eyes`,`smileys`,`笑脸,开心`],[`😅`,`smiling face with open mouth and cold sweat`,`smileys`,`笑脸,汗,尴尬`],[`😆`,`smiling face with open mouth and tightly-closed eyes`,`smileys`,`笑脸,大笑`],[`😇`,`smiling face with halo`,`smileys`,`天使,微笑,善良`],[`😈`,`smiling face with horns`,`smileys`,`恶魔,坏笑,邪恶`],[`😉`,`winking face`,`smileys`,`眨眼,调皮`],[`😊`,`smiling face with smiling eyes`,`smileys`,`微笑,开心,脸红`],[`😋`,`face savouring delicious food`,`smileys`,`好吃,美味,舔`],[`😌`,`relieved face`,`smileys`,`放松,安心`],[`😍`,`smiling face with heart-shaped eyes`,`smileys`,`爱,喜欢,花痴`],[`😎`,`smiling face with sunglasses`,`smileys`,`酷,墨镜,帅气`],[`😏`,`smirking face`,`smileys`,`得意,微笑,坏笑`],[`😐`,`neutral face`,`smileys`,`无语,面无表情`],[`😑`,`expressionless face`,`smileys`,`无语,面无表情`],[`😒`,`unamused face`,`smileys`,`不满,无语,翻白眼`],[`😓`,`face with cold sweat`,`smileys`,`冷汗,尴尬`],[`😔`,`pensive face`,`smileys`,`难过,低落`],[`😕`,`confused face`,`smileys`,`困惑,不解`],[`😖`,`confounded face`,`smileys`,`纠结,痛苦`],[`😗`,`kissing face`,`smileys`,`亲亲,吻`],[`😘`,`face throwing a kiss`,`smileys`,`飞吻,亲亲,爱`],[`😙`,`kissing face with smiling eyes`,`smileys`,``],[`😚`,`kissing face with closed eyes`,`smileys`,`亲亲,吻`],[`😛`,`face with stuck-out tongue`,`smileys`,`吐舌头,调皮`],[`😜`,`face with stuck-out tongue and winking eye`,`smileys`,`吐舌头,调皮,眨眼`],[`😝`,`face with stuck-out tongue and tightly-closed eyes`,`smileys`,`吐舌头,调皮`],[`😞`,`disappointed face`,`smileys`,`失望,难过`],[`😟`,`worried face`,`smileys`,`担心,忧虑`],[`😠`,`angry face`,`smileys`,`生气,愤怒`],[`😡`,`pouting face`,`smileys`,`生气,愤怒,红脸`],[`😢`,`crying face`,`smileys`,`哭,伤心,流泪`],[`😣`,`persevering face`,`smileys`,`挣扎,痛苦`],[`😤`,`face with look of triumph`,`smileys`,`生气,冒烟,气`],[`😥`,`disappointed but relieved face`,`smileys`,`难过,失望,松气`],[`😦`,`frowning face with open mouth`,`smileys`,`惊讶,张嘴`],[`😧`,`anguished face`,`smileys`,`震惊,痛苦`],[`😨`,`fearful face`,`smileys`,`害怕,恐惧`],[`😩`,`weary face`,`smileys`,`累,疲惫,哭`],[`😪`,`sleepy face`,`smileys`,`困,想睡`],[`😫`,`tired face`,`smileys`,`累,疲惫`],[`😬`,`grimacing face`,`smileys`,`尴尬,咧嘴`],[`😭`,`loudly crying face`,`smileys`,`大哭,伤心,哭`],[`😮`,`face with open mouth`,`smileys`,`惊讶,哇`],[`😯`,`hushed face`,`smileys`,`惊讶,安静`],[`😰`,`face with open mouth and cold sweat`,`smileys`,`担心,冷汗`],[`😱`,`face screaming in fear`,`smileys`,`尖叫,害怕,恐怖`],[`😲`,`astonished face`,`smileys`,`震惊,惊讶`],[`😳`,`flushed face`,`smileys`,`脸红,害羞,震惊`],[`😴`,`sleeping face`,`smileys`,`睡觉,睡觉`],[`😵`,`dizzy face`,`smileys`,`晕,头晕,死`],[`😶`,`face without mouth`,`smileys`,`沉默,无语`],[`😷`,`face with medical mask`,`smileys`,`生病,口罩,感冒`],[`😸`,`grinning cat face with smiling eyes`,`smileys`,`猫,笑脸`],[`😹`,`cat face with tears of joy`,`smileys`,`猫,笑哭`],[`😺`,`smiling cat face with open mouth`,`smileys`,`猫,笑脸,开心`],[`😻`,`smiling cat face with heart-shaped eyes`,`smileys`,`猫,爱,喜欢`],[`😼`,`cat face with wry smile`,`smileys`,`猫,坏笑`],[`😽`,`kissing cat face with closed eyes`,`smileys`,`猫,亲亲`],[`😾`,`pouting cat face`,`smileys`,`猫,生气`],[`😿`,`crying cat face`,`smileys`,`猫,哭,伤心`],[`🙀`,`weary cat face`,`smileys`,`猫,震惊,害怕`],[`🙁`,`slightly frowning face`,`smileys`,`难过,失望`],[`🙂`,`slightly smiling face`,`smileys`,`微笑,笑`],[`🙃`,`upside-down face`,`smileys`,`微笑,倒`],[`🙄`,`face with rolling eyes`,`smileys`,`翻白眼,无语`],[`🙅`,`face with no good gesture`,`smileys`,``],[`🙆`,`face with ok gesture`,`smileys`,``],[`🙇`,`person bowing deeply`,`smileys`,``],[`🙈`,`see-no-evil monkey`,`smileys`,``],[`🙉`,`hear-no-evil monkey`,`smileys`,``],[`🙊`,`speak-no-evil monkey`,`smileys`,``],[`🙋`,`happy person raising one hand`,`smileys`,``],[`🙌`,`person raising both hands in celebration`,`smileys`,`欢呼,举起,庆祝`],[`🙍`,`person frowning`,`smileys`,``],[`🙎`,`person with pouting face`,`smileys`,``],[`🙏`,`person with folded hands`,`smileys`,`祈祷,拜托,感谢,合十`],[`🚀`,`rocket`,`travel`,`火箭,发射,太空`],[`🚁`,`helicopter`,`travel`,`直升机`],[`🚂`,`steam locomotive`,`travel`,`火车,蒸汽火车`],[`🚃`,`railway car`,`travel`,`电车,火车`],[`🚄`,`high-speed train`,`travel`,`高铁,动车,火车`],[`🚅`,`high-speed train with bullet nose`,`travel`,``],[`🚆`,`train`,`travel`,`火车,铁路`],[`🚇`,`metro`,`travel`,`地铁,地铁站`],[`🚈`,`light rail`,`travel`,`轻轨,轨道交通`],[`🚉`,`station`,`travel`,`火车站,车站`],[`🚊`,`tram`,`travel`,`电车`],[`🚋`,`tram car`,`travel`,`电车,有轨电车`],[`🚌`,`bus`,`travel`,`公交车,巴士`],[`🚍`,`oncoming bus`,`travel`,`公交车`],[`🚎`,`trolleybus`,`travel`,`无轨电车,巴士`],[`🚏`,`bus stop`,`travel`,`公交站,车站`],[`🚐`,`minibus`,`travel`,`面包车,小巴`],[`🚑`,`ambulance`,`travel`,`救护车,急救`],[`🚒`,`fire engine`,`travel`,`消防车,救火`],[`🚓`,`police car`,`travel`,`警车,警察`],[`🚔`,`oncoming police car`,`travel`,`警车,巡逻`],[`🚕`,`taxi`,`travel`,`出租车,的士`],[`🚖`,`oncoming taxi`,`travel`,`出租车`],[`🚗`,`automobile`,`travel`,`汽车,轿车,车`],[`🚘`,`oncoming automobile`,`travel`,`汽车`],[`🚙`,`recreational vehicle`,`travel`,`SUV,越野车,汽车`],[`🚚`,`delivery truck`,`travel`,`卡车,货车`],[`🚛`,`articulated lorry`,`travel`,`卡车,货车`],[`🚜`,`tractor`,`travel`,`拖拉机,农用`],[`🚝`,`monorail`,`travel`,`单轨,单轨列车`],[`🚞`,`mountain railway`,`travel`,`火车,山区铁路`],[`🚟`,`suspension railway`,`travel`,`缆车,悬挂列车`],[`🚠`,`mountain cableway`,`travel`,`缆车,高山`],[`🚡`,`aerial tramway`,`travel`,`缆车,索道`],[`🚢`,`ship`,`travel`,`轮船,船,大海`],[`🚣`,`rowboat`,`travel`,``],[`🚤`,`speedboat`,`travel`,`快艇,汽艇`],[`🚥`,`horizontal traffic light`,`travel`,`红绿灯,交通信号灯`],[`🚦`,`vertical traffic light`,`travel`,`红绿灯,信号灯`],[`🚧`,`construction sign`,`travel`,`施工,施工中,路障`],[`🚨`,`police cars revolving light`,`travel`,`警车灯,警报,紧急`],[`🚩`,`triangular flag on post`,`travel`,`红旗,旗帜,标志`],[`🚪`,`door`,`travel`,`门,房门`],[`🚫`,`no entry sign`,`travel`,``],[`🚬`,`smoking symbol`,`travel`,`香烟,烟,吸烟`],[`🚭`,`no smoking symbol`,`travel`,``],[`🚮`,`put litter in its place symbol`,`travel`,`垃圾,清理`],[`🚯`,`do not litter symbol`,`travel`,``],[`🚰`,`potable water symbol`,`travel`,``],[`🚱`,`non-potable water symbol`,`travel`,``],[`🚲`,`bicycle`,`travel`,`自行车,单车,骑行`],[`🚳`,`no bicycles`,`travel`,``],[`🚴`,`bicyclist`,`travel`,``],[`🚵`,`mountain bicyclist`,`travel`,``],[`🚶`,`pedestrian`,`travel`,`走路,步行,散步`],[`🚷`,`no pedestrians`,`travel`,``],[`🚸`,`children crossing`,`travel`,``],[`🚹`,`mens symbol`,`travel`,``],[`🚺`,`womens symbol`,`travel`,``],[`🚻`,`restroom`,`travel`,``],[`🚼`,`baby symbol`,`travel`,``],[`🚽`,`toilet`,`travel`,`马桶,厕所,卫生间`],[`🚾`,`water closet`,`travel`,``],[`🚿`,`shower`,`travel`,`淋浴,洗澡`],[`🛀`,`bath`,`travel`,`泡澡`],[`🛁`,`bathtub`,`travel`,`浴缸,洗澡,泡澡`],[`🛂`,`passport control`,`travel`,``],[`🛃`,`customs`,`travel`,``],[`🛄`,`baggage claim`,`travel`,``],[`🛅`,`left luggage`,`travel`,``],[`🛋`,`couch and lamp`,`travel`,``],[`🛌`,`sleeping accommodation`,`travel`,`睡觉`],[`🛍`,`shopping bags`,`travel`,``],[`🛎`,`bellhop bell`,`travel`,``],[`🛏`,`bed`,`travel`,``],[`🛐`,`place of worship`,`travel`,``],[`🛑`,`octagonal sign`,`travel`,`停止,停车,红圈`],[`🛒`,`shopping trolley`,`travel`,`购物车,购物`],[`🛕`,`hindu temple`,`travel`,`印度教神庙`],[`🛖`,`hut`,`travel`,`草屋,小屋`],[`🛗`,`elevator`,`travel`,``],[`🛜`,`wireless`,`travel`,``],[`🛝`,`playground slide`,`travel`,``],[`🛞`,`wheel`,`travel`,`车轮,轮胎`],[`🛟`,`ring buoy`,`travel`,`救生圈,救生`],[`🛠`,`hammer and wrench`,`travel`,``],[`🛡`,`shield`,`travel`,``],[`🛢`,`oil drum`,`travel`,``],[`🛣`,`motorway`,`travel`,``],[`🛤`,`railway track`,`travel`,``],[`🛥`,`motor boat`,`travel`,``],[`🛩`,`small airplane`,`travel`,``],[`🛫`,`airplane departure`,`travel`,`起飞,飞机,出发`],[`🛬`,`airplane arriving`,`travel`,`降落,飞机,到达`],[`🛰`,`satellite`,`travel`,``],[`🛳`,`passenger ship`,`travel`,``],[`🛴`,`scooter`,`travel`,`滑板车,平衡车`],[`🛵`,`motor scooter`,`travel`,`摩托车,电动车,踏板车`],[`🛶`,`canoe`,`travel`,`独木舟,皮划艇`],[`🛷`,`sled`,`travel`,`雪橇,雪车`],[`🛸`,`flying saucer`,`travel`,`飞碟,UFO,外星人`],[`🛹`,`skateboard`,`travel`,`滑板`],[`🛺`,`auto rickshaw`,`travel`,`三轮车,突突车`],[`🛻`,`pickup truck`,`travel`,`皮卡,卡车`],[`🛼`,`roller skate`,`travel`,`轮滑`],[`🟠`,`large orange circle`,`symbols`,``],[`🟡`,`large yellow circle`,`symbols`,``],[`🟢`,`large green circle`,`symbols`,``],[`🟣`,`large purple circle`,`symbols`,``],[`🟤`,`large brown circle`,`symbols`,``],[`🟥`,`large red square`,`symbols`,``],[`🟦`,`large blue square`,`symbols`,``],[`🟧`,`large orange square`,`symbols`,``],[`🟨`,`large yellow square`,`symbols`,``],[`🟩`,`large green square`,`symbols`,``],[`🟪`,`large purple square`,`symbols`,``],[`🟫`,`large brown square`,`symbols`,``],[`🟰`,`heavy equals sign`,`symbols`,``],[`🤌`,`pinched fingers`,`symbols`,`手指,捏,意大利`],[`🤍`,`white heart`,`symbols`,`白心,白色,爱心`],[`🤎`,`brown heart`,`symbols`,`棕心,棕色,爱心`],[`🤏`,`pinching hand`,`symbols`,`捏,一点点,微小`],[`🤐`,`zipper-mouth face`,`smileys`,`闭嘴,不说`],[`🤑`,`money-mouth face`,`smileys`,`发财,金钱,贪婪`],[`🤒`,`face with thermometer`,`smileys`,`发烧,生病,温度计`],[`🤓`,`nerd face`,`smileys`,`书呆子,眼镜`],[`🤔`,`thinking face`,`smileys`,`思考,疑问,想`],[`🤕`,`face with head-bandage`,`smileys`,`受伤,包扎,头`],[`🤖`,`robot face`,`smileys`,`机器人,AI,机械`],[`🤗`,`hugging face`,`smileys`,`拥抱,欢迎`],[`🤘`,`sign of the horns`,`smileys`,`摇滚,手势,牛`],[`🤙`,`call me hand`,`smileys`,`打电话,挂,酷`],[`🤚`,`raised back of hand`,`smileys`,`手,举手,停`],[`🤛`,`left-facing fist`,`smileys`,`拳头,左边`],[`🤜`,`right-facing fist`,`smileys`,`拳头,右边`],[`🤝`,`handshake`,`smileys`,`握手,合作,协议`],[`🤞`,`hand with index and middle fingers crossed`,`smileys`,`祈祷,好运,手指交叉`],[`🤟`,`i love you hand sign`,`smileys`,`爱你,摇滚`],[`🤠`,`face with cowboy hat`,`smileys`,`牛仔,帽子`],[`🤡`,`clown face`,`smileys`,`小丑,马戏团`],[`🤢`,`nauseated face`,`smileys`,`恶心,呕吐`],[`🤣`,`rolling on the floor laughing`,`smileys`,`笑哭,大笑,笑`],[`🤤`,`drooling face`,`smileys`,`流口水,馋`],[`🤥`,`lying face`,`smileys`,`说谎,撒谎`],[`🤦`,`face palm`,`smileys`,`捂脸,无奈,扶额`],[`🤧`,`sneezing face`,`smileys`,`打喷嚏,感冒`],[`🤨`,`face with one eyebrow raised`,`symbols`,`怀疑,挑眉`],[`🤩`,`grinning face with star eyes`,`symbols`,`星星眼,兴奋,惊讶`],[`🤪`,`grinning face with one large and one small eye`,`symbols`,`疯狂,搞怪`],[`🤫`,`face with finger covering closed lips`,`symbols`,`嘘,安静`],[`🤬`,`serious face with symbols covering mouth`,`symbols`,`骂人,脏话,生气`],[`🤭`,`smiling face with smiling eyes and hand covering mouth`,`symbols`,`捂嘴,偷笑,惊讶`],[`🤮`,`face with open mouth vomiting`,`symbols`,`呕吐,恶心`],[`🤯`,`shocked face with exploding head`,`smileys`,`爆炸,震惊,头炸`],[`🤰`,`pregnant woman`,`people`,`孕妇,怀孕`],[`🤱`,`breast-feeding`,`people`,``],[`🤲`,`palms up together`,`people`,``],[`🤳`,`selfie`,`people`,`自拍,拍照`],[`🤴`,`prince`,`people`,`王子,国王`],[`🤵`,`man in tuxedo`,`people`,`新郎,西装,燕尾服`],[`🤶`,`mother christmas`,`people`,`圣诞奶奶,圣诞老人`],[`🤷`,`shrug`,`people`,`耸肩,无奈,不知道`],[`🤸`,`person doing cartwheel`,`people`,`翻跟头,体操,空翻`],[`🤹`,`juggling`,`people`,`杂耍`],[`🤺`,`fencer`,`people`,`击剑,剑术`],[`🤼`,`wrestlers`,`activity`,`摔跤,格斗`],[`🤽`,`water polo`,`activity`,``],[`🤾`,`handball`,`activity`,``],[`🤿`,`diving mask`,`activity`,`潜水面罩,潜水`],[`🥀`,`wilted flower`,`symbols`,``],[`🥁`,`drum with drumsticks`,`symbols`,`鼓,打鼓,乐器`],[`🥂`,`clinking glasses`,`symbols`,`干杯,香槟杯`],[`🥃`,`tumbler glass`,`symbols`,`威士忌,酒杯`],[`🥄`,`spoon`,`symbols`,`勺子,汤匙`],[`🥅`,`goal net`,`symbols`,`球门,网,进球`],[`🥇`,`first place medal`,`symbols`,`金牌,冠军,第一名,奖牌`],[`🥈`,`second place medal`,`symbols`,`银牌,第二名,奖牌`],[`🥉`,`third place medal`,`symbols`,`铜牌,第三名,奖牌`],[`🥊`,`boxing glove`,`symbols`,`拳击,拳击手套,打拳`],[`🥋`,`martial arts uniform`,`symbols`,`道服,武术,空手道`],[`🥌`,`curling stone`,`symbols`,`冰壶,冰壶`],[`🥍`,`lacrosse stick and ball`,`symbols`,``],[`🥎`,`softball`,`symbols`,`垒球,球`],[`🥏`,`flying disc`,`symbols`,`飞盘,飞碟`],[`🥐`,`croissant`,`food`,`牛角包,可颂`],[`🥑`,`avocado`,`food`,`牛油果,鳄梨`],[`🥒`,`cucumber`,`food`,`黄瓜`],[`🥓`,`bacon`,`food`,`培根,腊肉`],[`🥔`,`potato`,`food`,`土豆,马铃薯`],[`🥕`,`carrot`,`food`,`胡萝卜`],[`🥖`,`baguette bread`,`food`,`法棍,面包`],[`🥗`,`green salad`,`food`,`沙拉,蔬菜`],[`🥘`,`shallow pan of food`,`food`,`炖锅,海鲜饭`],[`🥙`,`stuffed flatbread`,`food`,`卷饼,肉夹馍`],[`🥚`,`egg`,`food`,`鸡蛋,蛋`],[`🥛`,`glass of milk`,`food`,`牛奶,奶`],[`🥜`,`peanuts`,`food`,``],[`🥝`,`kiwifruit`,`food`,`猕猴桃,奇异果`],[`🥞`,`pancakes`,`food`,`松饼,煎饼`],[`🥟`,`dumpling`,`food`,`饺子,锅贴`],[`🥠`,`fortune cookie`,`food`,`幸运饼干`],[`🥡`,`takeout box`,`food`,``],[`🥢`,`chopsticks`,`food`,`筷子`],[`🥣`,`bowl with spoon`,`food`,``],[`🥤`,`cup with straw`,`food`,`饮料,杯`],[`🥥`,`coconut`,`food`,`椰子`],[`🥦`,`broccoli`,`food`,`西兰花`],[`🥧`,`pie`,`food`,`派,馅饼`],[`🥨`,`pretzel`,`food`,`椒盐卷饼`],[`🥩`,`cut of meat`,`food`,`牛排,肉`],[`🥪`,`sandwich`,`food`,`三明治`],[`🥫`,`canned food`,`food`,`罐头,罐装`],[`🥬`,`leafy green`,`symbols`,`青菜,白菜,生菜`],[`🥭`,`mango`,`symbols`,`芒果`],[`🥮`,`moon cake`,`symbols`,``],[`🥯`,`bagel`,`symbols`,`贝果,面包圈`],[`🥰`,`smiling face with smiling eyes and three hearts`,`smileys`,`爱,微笑,爱心`],[`🥱`,`yawning face`,`smileys`,`打哈欠,困,无聊`],[`🥲`,`smiling face with tear`,`smileys`,``],[`🥳`,`face with party horn and party hat`,`smileys`,`庆祝,派对,欢呼`],[`🥴`,`face with uneven eyes and wavy mouth`,`smileys`,`晕,醉,头昏`],[`🥵`,`overheated face`,`smileys`,`热`],[`🥶`,`freezing face`,`smileys`,`冷`],[`🥷`,`ninja`,`people`,`忍者,忍者`],[`🥸`,`disguised face`,`symbols`,`伪装`],[`🥹`,`face holding back tears`,`symbols`,`感动,忍住,哭,泪目`],[`🥺`,`face with pleading eyes`,`smileys`,`可怜,委屈,求`],[`🥻`,`sari`,`symbols`,`纱丽,印度`],[`🥼`,`lab coat`,`symbols`,``],[`🥽`,`goggles`,`symbols`,``],[`🥾`,`hiking boot`,`symbols`,`靴子,登山鞋`],[`🥿`,`flat shoe`,`symbols`,`平底鞋,鞋`],[`🦀`,`crab`,`animals`,`螃蟹,海鲜`],[`🦁`,`lion face`,`animals`,``],[`🦂`,`scorpion`,`animals`,``],[`🦃`,`turkey`,`animals`,`火鸡,感恩节`],[`🦄`,`unicorn face`,`animals`,`独角兽,梦幻`],[`🦅`,`eagle`,`animals`,`老鹰,鹰`],[`🦆`,`duck`,`animals`,`鸭子,鸭`],[`🦇`,`bat`,`animals`,`蝙蝠`],[`🦈`,`shark`,`animals`,`鲨鱼,鱼`],[`🦉`,`owl`,`animals`,`猫头鹰,智慧`],[`🦊`,`fox face`,`animals`,``],[`🦋`,`butterfly`,`animals`,``],[`🦌`,`deer`,`animals`,`鹿,麋鹿`],[`🦍`,`gorilla`,`animals`,``],[`🦎`,`lizard`,`animals`,`蜥蜴,爬行动物`],[`🦏`,`rhinoceros`,`animals`,`犀牛`],[`🦐`,`shrimp`,`animals`,`虾,海鲜`],[`🦑`,`squid`,`animals`,`鱿鱼,海鲜`],[`🦒`,`giraffe face`,`animals`,`长颈鹿`],[`🦓`,`zebra face`,`animals`,`斑马`],[`🦔`,`hedgehog`,`animals`,`刺猬`],[`🦕`,`sauropod`,`animals`,`恐龙,雷龙`],[`🦖`,`t-rex`,`animals`,`恐龙,霸王龙`],[`🦗`,`cricket`,`animals`,``],[`🦘`,`kangaroo`,`animals`,`袋鼠`],[`🦙`,`llama`,`animals`,`羊驼,草泥马`],[`🦚`,`peacock`,`animals`,`孔雀,开屏`],[`🦛`,`hippopotamus`,`animals`,`河马`],[`🦜`,`parrot`,`animals`,`鹦鹉`],[`🦝`,`raccoon`,`animals`,`浣熊`],[`🦞`,`lobster`,`animals`,`龙虾,海鲜`],[`🦟`,`mosquito`,`animals`,``],[`🦠`,`microbe`,`animals`,``],[`🦡`,`badger`,`animals`,`獾`],[`🦢`,`swan`,`animals`,`天鹅,鹅`],[`🦣`,`mammoth`,`animals`,`猛犸象`],[`🦤`,`dodo`,`animals`,`渡渡鸟`],[`🦥`,`sloth`,`animals`,`树懒`],[`🦦`,`otter`,`animals`,`水獭`],[`🦧`,`orangutan`,`animals`,``],[`🦨`,`skunk`,`animals`,`臭鼬`],[`🦩`,`flamingo`,`animals`,`火烈鸟,红鹤`],[`🦪`,`oyster`,`animals`,`生蚝,牡蛎`],[`🦫`,`beaver`,`animals`,`河狸,海狸`],[`🦬`,`bison`,`animals`,`野牛,水牛`],[`🦭`,`seal`,`animals`,`海豹,海狮`],[`🦮`,`guide dog`,`animals`,`导盲犬,狗`],[`🦯`,`probing cane`,`symbols`,``],[`🦰`,`emoji component red hair`,`people`,`红发,头发,发色`],[`🦱`,`emoji component curly hair`,`people`,`卷发,头发`],[`🦲`,`emoji component bald`,`people`,`光头,秃头`],[`🦳`,`emoji component white hair`,`people`,`白发,头发`],[`🦴`,`bone`,`people`,``],[`🦵`,`leg`,`people`,`腿,大腿`],[`🦶`,`foot`,`people`,`脚,足`],[`🦷`,`tooth`,`people`,`牙齿,牙`],[`🦸`,`superhero`,`people`,`英雄`],[`🦹`,`supervillain`,`people`,`超级反派,坏人,反派`],[`🦺`,`safety vest`,`symbols`,``],[`🦻`,`ear with hearing aid`,`symbols`,`助听器,耳朵`],[`🦼`,`motorized wheelchair`,`people`,``],[`🦽`,`manual wheelchair`,`people`,``],[`🦾`,`mechanical arm`,`people`,`机械臂,机器人,义肢`],[`🦿`,`mechanical leg`,`people`,`机械腿,义肢`],[`🧀`,`cheese wedge`,`food`,`奶酪,芝士`],[`🧁`,`cupcake`,`food`,`纸杯蛋糕,杯子蛋糕`],[`🧂`,`salt shaker`,`food`,``],[`🧃`,`beverage box`,`food`,`果汁盒,饮料`],[`🧄`,`garlic`,`food`,`大蒜,蒜`],[`🧅`,`onion`,`food`,`洋葱`],[`🧆`,`falafel`,`food`,`鹰嘴豆丸子`],[`🧇`,`waffle`,`food`,`华夫饼`],[`🧈`,`butter`,`food`,`黄油,奶油`],[`🧉`,`mate drink`,`food`,`马黛茶`],[`🧊`,`ice cube`,`food`,`冰块,冰`],[`🧋`,`bubble tea`,`food`,`奶茶,珍珠奶茶`],[`🧌`,`troll`,`symbols`,`巨魔,妖怪`],[`🧍`,`standing person`,`symbols`,`站立,站着,人`],[`🧎`,`kneeling person`,`symbols`,`跪,跪下,祈祷`],[`🧏`,`deaf person`,`symbols`,``],[`🧐`,`face with monocle`,`people`,`检查,研究,眼镜`],[`🧑`,`adult`,`people`,`人`],[`🧒`,`child`,`people`,``],[`🧓`,`older adult`,`people`,`老人,奶奶,爷爷`],[`🧔`,`bearded person`,`people`,`胡子,胡须,大叔`],[`🧕`,`person with headscarf`,`people`,`头巾`],[`🧖`,`person in steamy room`,`people`,`桑拿,蒸汽,洗澡`],[`🧗`,`person climbing`,`people`,`攀岩`],[`🧘`,`person in lotus position`,`people`,`打坐`],[`🧙`,`mage`,`people`,`巫师,魔法师,法师`],[`🧚`,`fairy`,`people`,`仙女,精灵,小仙女`],[`🧛`,`vampire`,`people`,`吸血鬼,德古拉`],[`🧜`,`merperson`,`people`,`美人鱼,人鱼`],[`🧝`,`elf`,`people`,`精灵,耳朵`],[`🧞`,`genie`,`people`,`灯神,精灵,神灯`],[`🧟`,`zombie`,`people`,`僵尸,丧尸`],[`🧠`,`brain`,`people`,`大脑,思考,记忆,AI`],[`🧡`,`orange heart`,`people`,``],[`🧢`,`billed cap`,`people`,`棒球帽,帽子`],[`🧣`,`scarf`,`people`,`围巾,冬天`],[`🧤`,`gloves`,`people`,`手套,冬天`],[`🧥`,`coat`,`people`,`大衣,外套`],[`🧦`,`socks`,`people`,`袜子`],[`🧧`,`red gift envelope`,`objects`,`红包,利是,新年`],[`🧨`,`firecracker`,`objects`,``],[`🧩`,`jigsaw puzzle piece`,`objects`,`拼图,拼图游戏`],[`🧪`,`test tube`,`objects`,`试管,实验,化学,科学`],[`🧫`,`petri dish`,`objects`,`培养皿,实验,细菌`],[`🧬`,`dna double helix`,`objects`,`DNA,基因,生物`],[`🧭`,`compass`,`objects`,`指南针`],[`🧮`,`abacus`,`objects`,`算盘,计算`],[`🧯`,`fire extinguisher`,`objects`,`灭火器,消防`],[`🧰`,`toolbox`,`objects`,`工具箱,工具`],[`🧱`,`brick`,`objects`,`砖`],[`🧲`,`magnet`,`objects`,`磁铁,磁性`],[`🧳`,`luggage`,`objects`,`行李箱`],[`🧴`,`lotion bottle`,`objects`,`乳液,护肤,防晒`],[`🧵`,`spool of thread`,`objects`,`线,针线,缝纫`],[`🧶`,`ball of yarn`,`objects`,`毛线,织毛衣`],[`🧷`,`safety pin`,`objects`,`别针,安全别针`],[`🧸`,`teddy bear`,`objects`,`泰迪熊,玩具熊`],[`🧹`,`broom`,`objects`,`扫帚`],[`🧺`,`basket`,`objects`,`篮子`],[`🧻`,`roll of paper`,`objects`,`纸巾`],[`🧼`,`bar of soap`,`objects`,`肥皂,洗手,清洁`],[`🧽`,`sponge`,`objects`,`海绵,清洁`],[`🧾`,`receipt`,`objects`,`收据`],[`🧿`,`nazar amulet`,`objects`,`护身符`],[`🩰`,`ballet shoes`,`activity`,`芭蕾`],[`🩱`,`one-piece swimsuit`,`activity`,`泳衣`],[`🩲`,`briefs`,`activity`,`泳裤`],[`🩳`,`shorts`,`activity`,`短裤`],[`🩴`,`thong sandal`,`activity`,`凉拖`],[`🩵`,`light blue heart`,`activity`,`浅蓝`],[`🩶`,`grey heart`,`activity`,`灰心`],[`🩷`,`pink heart`,`activity`,`粉色`],[`🩸`,`drop of blood`,`activity`,`血`],[`🩹`,`adhesive bandage`,`activity`,`创可贴`],[`🩺`,`stethoscope`,`activity`,`听诊器`],[`🩻`,`x-ray`,`activity`,`X光`],[`🩼`,`crutch`,`activity`,`拐杖`],[`🪀`,`yo-yo`,`objects`,`玩具`],[`🪁`,`kite`,`objects`,`风筝`],[`🪂`,`parachute`,`objects`,`跳伞`],[`🪃`,`boomerang`,`objects`,``],[`🪄`,`magic wand`,`objects`,`魔杖,魔法,魔术`],[`🪅`,`pinata`,`objects`,`皮纳塔`],[`🪆`,`nesting dolls`,`objects`,``],[`🪇`,`maracas`,`objects`,`沙锤`],[`🪈`,`flute`,`objects`,`笛子`],[`🪐`,`ringed planet`,`objects`,``],[`🪑`,`chair`,`objects`,`椅子`],[`🪒`,`razor`,`objects`,`剃须刀,剃刀`],[`🪓`,`axe`,`objects`,`斧头,斧子`],[`🪔`,`diya lamp`,`objects`,`油灯`],[`🪕`,`banjo`,`objects`,`班卓琴`],[`🪖`,`military helmet`,`objects`,`军盔`],[`🪗`,`accordion`,`objects`,`手风琴`],[`🪘`,`long drum`,`objects`,`鼓`],[`🪙`,`coin`,`objects`,`金币`],[`🪚`,`carpentry saw`,`objects`,`锯子,锯`],[`🪛`,`screwdriver`,`objects`,`螺丝刀`],[`🪜`,`ladder`,`objects`,`梯子`],[`🪝`,`hook`,`objects`,`钩子,挂钩`],[`🪞`,`mirror`,`objects`,`镜子`],[`🪟`,`window`,`objects`,`窗户`],[`🪠`,`plunger`,`objects`,`皮搋子,通马桶`],[`🪡`,`sewing needle`,`objects`,`针,缝纫,刺绣`],[`🪢`,`knot`,`objects`,``],[`🪣`,`bucket`,`objects`,`水桶,桶`],[`🪤`,`mouse trap`,`objects`,`捕鼠器`],[`🪥`,`toothbrush`,`objects`,`牙刷,刷牙`],[`🪦`,`headstone`,`objects`,`墓碑`],[`🪧`,`placard`,`objects`,`告示牌`],[`🪨`,`rock`,`objects`,`石头,岩石`],[`🪩`,`mirror ball`,`objects`,`迪斯科球`],[`🪪`,`identification card`,`objects`,`身份证`],[`🪫`,`low battery`,`objects`,`电池,没电,低电量`],[`🪬`,`hamsa`,`objects`,`手掌印,护身符`],[`🪭`,`folding hand fan`,`objects`,``],[`🪮`,`hair pick`,`objects`,`梳子`],[`🪯`,`khanda`,`objects`,``],[`🪰`,`fly`,`objects`,`苍蝇,飞虫`],[`🪱`,`worm`,`objects`,``],[`🪲`,`beetle`,`objects`,`甲虫,昆虫`],[`🪳`,`cockroach`,`objects`,`蟑螂,虫子`],[`🪴`,`potted plant`,`objects`,`盆栽,植物,绿植`],[`🪵`,`wood`,`objects`,`木头,柴火,木`],[`🪶`,`feather`,`objects`,`羽毛,羽毛笔`],[`🪷`,`lotus`,`objects`,`莲花`],[`🪸`,`coral`,`objects`,`珊瑚`],[`🪹`,`empty nest`,`objects`,`鸟巢`],[`🪺`,`nest with eggs`,`objects`,`鸟巢`],[`🪻`,`hyacinth`,`objects`,`风信子`],[`🪼`,`jellyfish`,`objects`,`水母`],[`🪽`,`wing`,`objects`,`翅膀`],[`🪿`,`goose`,`objects`,`鹅`],[`🫀`,`anatomical heart`,`objects`,`心脏,心跳`],[`🫁`,`lungs`,`objects`,`肺,呼吸`],[`🫂`,`people hugging`,`objects`,`拥抱,人,朋友`],[`🫃`,`pregnant man`,`objects`,`孕妇,怀孕`],[`🫄`,`pregnant person`,`objects`,`孕妇,怀孕`],[`🫅`,`person with crown`,`objects`,`国王,王子,皇冠`],[`🫎`,`moose`,`objects`,`驼鹿,麋鹿`],[`🫏`,`donkey`,`objects`,`驴,动物`],[`🫐`,`blueberries`,`food`,`蓝莓`],[`🫑`,`bell pepper`,`food`,`甜椒,彩椒`],[`🫒`,`olive`,`food`,`橄榄`],[`🫓`,`flatbread`,`food`,`薄饼,饼`],[`🫔`,`tamale`,`food`,`玉米粉蒸肉`],[`🫕`,`fondue`,`food`,`奶酪火锅`],[`🫖`,`teapot`,`food`,`茶壶,茶`],[`🫗`,`pouring liquid`,`food`,`倒,倒水,水杯`],[`🫘`,`beans`,`food`,`豆子,红豆`],[`🫙`,`jar`,`food`,`罐子,玻璃罐`],[`🫚`,`ginger root`,`food`,`姜,生姜`],[`🫛`,`pea pod`,`food`,`豌豆荚,豆`],[`🫠`,`melting face`,`smileys`,`融化`],[`🫡`,`saluting face`,`smileys`,`敬礼`],[`🫢`,`face with open eyes and hand over mouth`,`smileys`,`捂眼`],[`🫣`,`face with peeking eye`,`smileys`,`偷看`],[`🫤`,`face with diagonal mouth`,`smileys`,`撇嘴`],[`🫥`,`dotted line face`,`smileys`,`隐形`],[`🫦`,`biting lip`,`smileys`,`咬唇,嘴唇`],[`🫧`,`bubbles`,`smileys`,`泡泡`],[`🫨`,`shaking face`,`smileys`,`摇晃,震动,抖`],[`🫰`,`hand with index finger and thumb crossed`,`people`,`比心,手指,捏`],[`🫱`,`rightwards hand`,`people`,`手,右边,推`],[`🫲`,`leftwards hand`,`people`,`手,左边,推`],[`🫳`,`palm down hand`,`people`,`手,向下,放`],[`🫴`,`palm up hand`,`people`,`手,向上,举`],[`🫵`,`index pointing at the viewer`,`people`,`指,你`],[`🫶`,`heart hands`,`people`,`比心,爱心,手势`],[`🫷`,`leftwards pushing hand`,`people`,`手,推,右边`],[`🫸`,`rightwards pushing hand`,`people`,`手,推,左边`],[`‼`,`double exclamation mark`,`symbols`,``],[`‼️`,`double exclamation mark`,`symbols`,``],[`⁉`,`exclamation question mark`,`symbols`,``],[`⁉️`,`exclamation question mark`,`symbols`,``],[`™`,`trade mark sign`,`symbols`,``],[`™️`,`trade mark sign`,`symbols`,``],[`ℹ`,`information source`,`symbols`,``],[`ℹ️`,`information source`,`symbols`,``],[`↔`,`left right arrow`,`symbols`,``],[`↔️`,`left right arrow`,`symbols`,``],[`↕`,`up down arrow`,`symbols`,``],[`↕️`,`up down arrow`,`symbols`,``],[`↖`,`north west arrow`,`symbols`,``],[`↖️`,`north west arrow`,`symbols`,``],[`↗`,`north east arrow`,`symbols`,``],[`↗️`,`north east arrow`,`symbols`,``],[`↘`,`south east arrow`,`symbols`,``],[`↘️`,`south east arrow`,`symbols`,``],[`↙`,`south west arrow`,`symbols`,``],[`↙️`,`south west arrow`,`symbols`,``],[`↩`,`leftwards arrow with hook`,`symbols`,``],[`↩️`,`leftwards arrow with hook`,`symbols`,``],[`↪`,`rightwards arrow with hook`,`symbols`,``],[`↪️`,`rightwards arrow with hook`,`symbols`,``],[`⌚`,`watch`,`objects`,`手表`],[`⌚️`,`watch`,`objects`,``],[`⌛`,`hourglass`,`objects`,`沙漏,时间,等待`],[`⌛️`,`hourglass`,`objects`,``],[`⌨`,`keyboard`,`symbols`,``],[`⌨️`,`keyboard`,`symbols`,`键盘,打字`],[`⏏`,`eject symbol`,`symbols`,``],[`⏏️`,`eject symbol`,`symbols`,``],[`⏩`,`black right-pointing double triangle`,`objects`,``],[`⏪`,`black left-pointing double triangle`,`objects`,``],[`⏫`,`black up-pointing double triangle`,`objects`,``],[`⏬`,`black down-pointing double triangle`,`objects`,``],[`⏭`,`black right-pointing double triangle with vertical bar`,`objects`,``],[`⏭️`,`black right-pointing double triangle with vertical bar`,`objects`,``],[`⏮`,`black left-pointing double triangle with vertical bar`,`objects`,``],[`⏮️`,`black left-pointing double triangle with vertical bar`,`objects`,``],[`⏯`,`black right-pointing triangle with double vertical bar`,`objects`,``],[`⏯️`,`black right-pointing triangle with double vertical bar`,`objects`,``],[`⏰`,`alarm clock`,`objects`,`闹钟,时间,起床`],[`⏱`,`stopwatch`,`objects`,``],[`⏱️`,`stopwatch`,`objects`,`秒表`],[`⏲`,`timer clock`,`objects`,``],[`⏲️`,`timer clock`,`objects`,`计时器`],[`⏳`,`hourglass with flowing sand`,`objects`,`沙漏`],[`⏸`,`double vertical bar`,`symbols`,``],[`⏸️`,`double vertical bar`,`symbols`,``],[`⏹`,`black square for stop`,`symbols`,``],[`⏹️`,`black square for stop`,`symbols`,``],[`⏺`,`black circle for record`,`symbols`,``],[`⏺️`,`black circle for record`,`symbols`,``],[`Ⓜ`,`circled latin capital letter m`,`symbols`,``],[`Ⓜ️`,`circled latin capital letter m`,`symbols`,``],[`▪`,`black small square`,`symbols`,``],[`▪️`,`black small square`,`symbols`,``],[`▫`,`white small square`,`symbols`,``],[`▫️`,`white small square`,`symbols`,``],[`▶`,`black right-pointing triangle`,`symbols`,``],[`▶️`,`black right-pointing triangle`,`symbols`,``],[`◀`,`black left-pointing triangle`,`symbols`,``],[`◀️`,`black left-pointing triangle`,`symbols`,``],[`◻`,`white medium square`,`symbols`,``],[`◻️`,`white medium square`,`symbols`,``],[`◼`,`black medium square`,`symbols`,``],[`◼️`,`black medium square`,`symbols`,``],[`◽`,`white medium small square`,`symbols`,``],[`◾`,`black medium small square`,`symbols`,``],[`◾️`,`black medium small square`,`symbols`,``],[`☀`,`black sun with rays`,`symbols`,``],[`☀️`,`black sun with rays`,`symbols`,`太阳,晴天,阳光`],[`☁`,`cloud`,`symbols`,``],[`☁️`,`cloud`,`symbols`,`云,多云,天气`],[`☂`,`umbrella`,`symbols`,``],[`☂️`,`umbrella`,`symbols`,``],[`☃`,`snowman`,`symbols`,``],[`☃️`,`snowman`,`symbols`,`雪人,冬天,雪`],[`☄`,`comet`,`symbols`,``],[`☄️`,`comet`,`symbols`,``],[`☎`,`black telephone`,`symbols`,``],[`☎️`,`black telephone`,`symbols`,`电话`],[`☑`,`ballot box with check`,`symbols`,``],[`☑️`,`ballot box with check`,`symbols`,``],[`☔`,`umbrella with rain drops`,`symbols`,``],[`☔️`,`umbrella with rain drops`,`symbols`,``],[`☕`,`hot beverage`,`food`,`咖啡,热饮`],[`☕️`,`hot beverage`,`food`,``],[`☘`,`shamrock`,`symbols`,``],[`☘️`,`shamrock`,`symbols`,``],[`☝`,`white up pointing index`,`symbols`,``],[`☝️`,`white up pointing index`,`symbols`,`指,上面,向上`],[`☠`,`skull and crossbones`,`symbols`,``],[`☠️`,`skull and crossbones`,`symbols`,`骷髅,死亡,危险`],[`☢`,`radioactive sign`,`symbols`,``],[`☢️`,`radioactive sign`,`symbols`,``],[`☣`,`biohazard sign`,`symbols`,``],[`☣️`,`biohazard sign`,`symbols`,``],[`☦`,`orthodox cross`,`symbols`,``],[`☦️`,`orthodox cross`,`symbols`,``],[`☪`,`star and crescent`,`symbols`,``],[`☪️`,`star and crescent`,`symbols`,``],[`☮`,`peace symbol`,`symbols`,``],[`☮️`,`peace symbol`,`symbols`,``],[`☯`,`yin yang`,`symbols`,``],[`☯️`,`yin yang`,`symbols`,``],[`☸`,`wheel of dharma`,`symbols`,``],[`☸️`,`wheel of dharma`,`symbols`,``],[`☹`,`white frowning face`,`smileys`,``],[`☹️`,`white frowning face`,`smileys`,``],[`☺`,`white smiling face`,`smileys`,``],[`☺️`,`white smiling face`,`smileys`,``],[`♀`,`female sign`,`symbols`,``],[`♀️`,`female sign`,`symbols`,``],[`♂`,`male sign`,`symbols`,``],[`♂️`,`male sign`,`symbols`,``],[`♈`,`aries`,`symbols`,``],[`♈️`,`aries`,`symbols`,``],[`♉`,`taurus`,`symbols`,``],[`♉️`,`taurus`,`symbols`,``],[`♊`,`gemini`,`symbols`,``],[`♊️`,`gemini`,`symbols`,``],[`♋`,`cancer`,`symbols`,``],[`♋️`,`cancer`,`symbols`,``],[`♌`,`leo`,`symbols`,``],[`♌️`,`leo`,`symbols`,``],[`♍`,`virgo`,`symbols`,``],[`♍️`,`virgo`,`symbols`,``],[`♎`,`libra`,`symbols`,``],[`♎️`,`libra`,`symbols`,``],[`♏`,`scorpius`,`symbols`,``],[`♏️`,`scorpius`,`symbols`,``],[`♐`,`sagittarius`,`symbols`,``],[`♐️`,`sagittarius`,`symbols`,``],[`♑`,`capricorn`,`symbols`,``],[`♑️`,`capricorn`,`symbols`,``],[`♒`,`aquarius`,`symbols`,``],[`♒️`,`aquarius`,`symbols`,``],[`♓`,`pisces`,`symbols`,``],[`♓️`,`pisces`,`symbols`,``],[`♟`,`black chess pawn`,`symbols`,``],[`♟️`,`black chess pawn`,`symbols`,`棋子,国际象棋,象棋`],[`♠`,`black spade suit`,`symbols`,``],[`♠️`,`black spade suit`,`symbols`,``],[`♣`,`black club suit`,`symbols`,``],[`♣️`,`black club suit`,`symbols`,``],[`♥`,`black heart suit`,`symbols`,``],[`♥️`,`black heart suit`,`symbols`,``],[`♦`,`black diamond suit`,`symbols`,``],[`♦️`,`black diamond suit`,`symbols`,``],[`♨`,`hot springs`,`symbols`,``],[`♨️`,`hot springs`,`symbols`,`温泉,热泉`],[`♻`,`black universal recycling symbol`,`symbols`,``],[`♻️`,`black universal recycling symbol`,`symbols`,``],[`♾`,`permanent paper sign`,`symbols`,``],[`♾️`,`permanent paper sign`,`symbols`,``],[`♿`,`wheelchair symbol`,`symbols`,``],[`♿️`,`wheelchair symbol`,`symbols`,``],[`⚒`,`hammer and pick`,`symbols`,``],[`⚒️`,`hammer and pick`,`symbols`,`锤子,工具`],[`⚓`,`anchor`,`symbols`,`锚,航海,停泊`],[`⚔`,`crossed swords`,`symbols`,``],[`⚔️`,`crossed swords`,`symbols`,`剑,交叉,战斗`],[`⚕`,`staff of aesculapius`,`symbols`,``],[`⚕️`,`staff of aesculapius`,`symbols`,``],[`⚖`,`scales`,`symbols`,``],[`⚖️`,`scales`,`symbols`,``],[`⚗`,`alembic`,`symbols`,``],[`⚗️`,`alembic`,`symbols`,``],[`⚙`,`gear`,`symbols`,``],[`⚙️`,`gear`,`symbols`,``],[`⚛`,`atom symbol`,`symbols`,``],[`⚛️`,`atom symbol`,`symbols`,``],[`⚜`,`fleur-de-lis`,`symbols`,``],[`⚜️`,`fleur-de-lis`,`symbols`,``],[`⚠`,`warning sign`,`symbols`,``],[`⚠️`,`warning sign`,`symbols`,``],[`⚡`,`high voltage sign`,`symbols`,``],[`⚧`,`male with stroke and male and female sign`,`symbols`,``],[`⚧️`,`male with stroke and male and female sign`,`symbols`,``],[`⚪`,`medium white circle`,`symbols`,``],[`⚪️`,`medium white circle`,`symbols`,``],[`⚫`,`medium black circle`,`symbols`,``],[`⚰`,`coffin`,`symbols`,``],[`⚰️`,`coffin`,`symbols`,`棺材,死亡`],[`⚱`,`funeral urn`,`symbols`,``],[`⚱️`,`funeral urn`,`symbols`,`骨灰盒,死亡`],[`⚽`,`soccer ball`,`activity`,`足球,球`],[`⚽️`,`soccer ball`,`activity`,``],[`⚾`,`baseball`,`activity`,`棒球,球`],[`⚾️`,`baseball`,`activity`,``],[`⛄`,`snowman without snow`,`symbols`,`雪人,冬天`],[`⛄️`,`snowman without snow`,`symbols`,``],[`⛅`,`sun behind cloud`,`symbols`,`太阳,云,多云`],[`⛈`,`thunder cloud and rain`,`symbols`,``],[`⛈️`,`thunder cloud and rain`,`symbols`,`雷雨,雷暴,天气`],[`⛎`,`ophiuchus`,`symbols`,``],[`⛏`,`pick`,`symbols`,``],[`⛏️`,`pick`,`symbols`,`镐,工具`],[`⛑`,`helmet with white cross`,`symbols`,``],[`⛑️`,`helmet with white cross`,`symbols`,`头盔,救援,安全`],[`⛓`,`chains`,`symbols`,``],[`⛓️`,`chains`,`symbols`,``],[`⛔`,`no entry`,`symbols`,``],[`⛩`,`shinto shrine`,`travel`,``],[`⛩️`,`shinto shrine`,`travel`,`鸟居,神社,日本`],[`⛪`,`church`,`travel`,`教堂`],[`⛰`,`mountain`,`travel`,``],[`⛰️`,`mountain`,`travel`,`山,山峰`],[`⛱`,`umbrella on ground`,`travel`,``],[`⛱️`,`umbrella on ground`,`travel`,``],[`⛲`,`fountain`,`travel`,`喷泉`],[`⛲️`,`fountain`,`travel`,``],[`⛳`,`flag in hole`,`activity`,`高尔夫,高尔夫球,球洞`],[`⛳️`,`flag in hole`,`activity`,``],[`⛴`,`ferry`,`travel`,``],[`⛴️`,`ferry`,`travel`,`渡轮,船`],[`⛵`,`sailboat`,`travel`,`帆船,船`],[`⛵️`,`sailboat`,`travel`,``],[`⛷`,`skier`,`activity`,``],[`⛷️`,`skier`,`activity`,``],[`⛸`,`ice skate`,`activity`,``],[`⛸️`,`ice skate`,`activity`,`溜冰,冰刀,滑冰`],[`⛹`,`person with ball`,`activity`,``],[`⛹️`,`person with ball`,`activity`,``],[`⛺`,`tent`,`travel`,`帐篷,露营`],[`⛺️`,`tent`,`travel`,``],[`⛽`,`fuel pump`,`travel`,`加油站,加油,汽油`],[`✂`,`black scissors`,`symbols`,``],[`✂️`,`black scissors`,`symbols`,``],[`✅`,`white heavy check mark`,`symbols`,``],[`✈`,`airplane`,`travel`,``],[`✈️`,`airplane`,`travel`,`飞机,航班,起飞`],[`✉`,`envelope`,`symbols`,``],[`✉️`,`envelope`,`symbols`,`信封,邮件,信`],[`✊`,`raised fist`,`people`,`拳头,加油,力量`],[`✋`,`raised hand`,`people`,`手,举手,停`],[`✌`,`victory hand`,`symbols`,``],[`✌️`,`victory hand`,`symbols`,`胜利,耶,剪刀手`],[`✍`,`writing hand`,`symbols`,``],[`✍️`,`writing hand`,`symbols`,`写字,写作,手`],[`✏`,`pencil`,`symbols`,``],[`✏️`,`pencil`,`symbols`,``],[`✒`,`black nib`,`symbols`,``],[`✒️`,`black nib`,`symbols`,``],[`✔`,`heavy check mark`,`symbols`,``],[`✔️`,`heavy check mark`,`symbols`,``],[`✖`,`heavy multiplication x`,`symbols`,``],[`✖️`,`heavy multiplication x`,`symbols`,``],[`✝`,`latin cross`,`symbols`,``],[`✝️`,`latin cross`,`symbols`,``],[`✡`,`star of david`,`symbols`,``],[`✡️`,`star of david`,`symbols`,``],[`✨`,`sparkles`,`symbols`,`星星,闪光,发光`],[`✳`,`eight spoked asterisk`,`symbols`,``],[`✳️`,`eight spoked asterisk`,`symbols`,``],[`✴`,`eight pointed black star`,`symbols`,``],[`✴️`,`eight pointed black star`,`symbols`,``],[`❄`,`snowflake`,`symbols`,``],[`❄️`,`snowflake`,`symbols`,`雪花,雪,冬天,冷`],[`❇`,`sparkle`,`symbols`,``],[`❇️`,`sparkle`,`symbols`,``],[`❌`,`cross mark`,`symbols`,``],[`❎`,`negative squared cross mark`,`symbols`,``],[`❓`,`black question mark ornament`,`symbols`,``],[`❔`,`white question mark ornament`,`symbols`,``],[`❕`,`white exclamation mark ornament`,`symbols`,``],[`❗`,`heavy exclamation mark symbol`,`symbols`,``],[`❗️`,`heavy exclamation mark symbol`,`symbols`,``],[`❣`,`heavy heart exclamation mark ornament`,`symbols`,``],[`❣️`,`heavy heart exclamation mark ornament`,`symbols`,`爱心,感叹号`],[`❤`,`heavy black heart`,`smileys`,``],[`❤️`,`heavy black heart`,`smileys`,`爱心,红心,爱`],[`➕`,`heavy plus sign`,`symbols`,``],[`➖`,`heavy minus sign`,`symbols`,``],[`➗`,`heavy division sign`,`symbols`,``],[`➡`,`black rightwards arrow`,`symbols`,``],[`➡️`,`black rightwards arrow`,`symbols`,``],[`➰`,`curly loop`,`symbols`,``],[`➿`,`double curly loop`,`symbols`,``],[`⬅`,`leftwards black arrow`,`symbols`,``],[`⬅️`,`leftwards black arrow`,`symbols`,``],[`⬆`,`upwards black arrow`,`symbols`,``],[`⬆️`,`upwards black arrow`,`symbols`,``],[`⬇`,`downwards black arrow`,`symbols`,``],[`⬇️`,`downwards black arrow`,`symbols`,``],[`⬛`,`black large square`,`symbols`,``],[`⬛️`,`black large square`,`symbols`,``],[`⬜`,`white large square`,`symbols`,``],[`⬜️`,`white large square`,`symbols`,``],[`⭐`,`white medium star`,`symbols`,`星星,五星,评分`],[`⭕`,`heavy large circle`,`symbols`,``],[`⭕️`,`heavy large circle`,`symbols`,``],[`⤴`,`arrow pointing rightwards then curving upwards`,`symbols`,``],[`⤴️`,`arrow pointing rightwards then curving upwards`,`symbols`,``],[`⤵`,`arrow pointing rightwards then curving downwards`,`symbols`,``],[`⤵️`,`arrow pointing rightwards then curving downwards`,`symbols`,``],[`〰`,`wavy dash`,`symbols`,``],[`〰️`,`wavy dash`,`symbols`,``],[`〽`,`part alternation mark`,`symbols`,``],[`〽️`,`part alternation mark`,`symbols`,``],[`㊗`,`circled ideograph congratulation`,`symbols`,``],[`㊗️`,`circled ideograph congratulation`,`symbols`,``],[`㊙`,`circled ideograph secret`,`symbols`,``],[`㊙️`,`circled ideograph secret`,`symbols`,``],[`©`,`copyright sign`,`symbols`,``],[`©️`,`copyright sign`,`symbols`,``],[`®`,`registered sign`,`symbols`,``],[`®️`,`registered sign`,`symbols`,``],[`👨💻`,`man technologist`,`people`,`程序员,开发者,工程师,码农`],[`👩💻`,`woman technologist`,`people`,`程序员,开发者,工程师`],[`🧑💻`,`technologist`,`people`,`程序员,开发者,工程师`],[`👨🔧`,`man mechanic`,`people`,``],[`👩🔧`,`woman mechanic`,`people`,``],[`👨🎨`,`man artist`,`people`,``],[`👩🎨`,`woman artist`,`people`,``],[`👨🚀`,`man astronaut`,`people`,``],[`👩🚀`,`woman astronaut`,`people`,``],[`👨⚕️`,`man health worker`,`people`,``],[`👩⚕️`,`woman health worker`,`people`,``],[`👨🏫`,`man teacher`,`people`,``],[`👩🏫`,`woman teacher`,`people`,``],[`👨🍳`,`man cook`,`people`,``],[`👩🍳`,`woman cook`,`people`,``],[`👨🌾`,`man farmer`,`people`,``],[`👩🌾`,`woman farmer`,`people`,``],[`👩🏭`,`woman factory worker`,`people`,``],[`👨🎓`,`man student`,`people`,``],[`👩🎓`,`woman student`,`people`,``],[`👨🚒`,`man firefighter`,`people`,``],[`👩🚒`,`woman firefighter`,`people`,``],[`👨⚖️`,`man judge`,`people`,``],[`👩⚖️`,`woman judge`,`people`,``],[`👨💼`,`man office worker`,`people`,``],[`👩💼`,`woman office worker`,`people`,``],[`👨🎤`,`man singer`,`people`,``],[`👩🎤`,`woman singer`,`people`,``],[`👨🦰`,`man red hair`,`people`,``],[`👩🦰`,`woman red hair`,`people`,``],[`👨🦱`,`man curly hair`,`people`,``],[`👩🦱`,`woman curly hair`,`people`,``],[`👩🦲`,`woman bald`,`people`,``],[`👨🦳`,`man white hair`,`people`,``],[`👩🦳`,`woman white hair`,`people`,``],[`👩❤️👨`,`couple with heart`,`people`,``],[`👨❤️👨`,`couple with heart`,`people`,``],[`👩❤️👩`,`couple with heart`,`people`,``],[`👨👩👧`,`family man woman girl`,`people`,``],[`👨👩👦`,`family man woman boy`,`people`,``],[`👨👩👧👦`,`family man woman girl boy`,`people`,``],[`👨👩👦👦`,`man`,`people`,``],[`👨👩👧👧`,`family man woman girl girl`,`people`,``],[`👩👩👧`,`family woman woman girl`,`people`,``],[`👨👨👧`,`family man man girl`,`people`,``],[`👨👦`,`family man boy`,`people`,``],[`👩👧`,`family woman girl`,`people`,``],[`👨👧👦`,`family man girl boy`,`people`,``],[`👩❤️💋👨`,`kiss woman man`,`people`,``],[`🧑🤝🧑`,`people holding hands`,`people`,``],[`❤️🔥`,`heart on fire`,`smileys`,``],[`🧑🚒`,`firefighter`,`people`,`消防员`],[`🧑🏭`,`factory worker`,`people`,``],[`🧑🎓`,`student`,`people`,`学生,毕业生,大学生`],[`🧑🏫`,`teacher`,`people`,`老师,教师,教授`],[`🧑🎤`,`singer`,`people`,`歌手,歌星`],[`🧑⚕️`,`health worker`,`people`,`医生,医疗`],[`🧑⚖️`,`judge`,`people`,`法官,审判`],[`🧑🍳`,`cook`,`people`,`厨师,大厨`],[`🧑🌾`,`farmer`,`people`,`农民,农夫`],[`🧑🎨`,`artist`,`people`,`画家,艺术家`],[`🧑🔬`,`scientist`,`people`,``],[`🧑🔧`,`mechanic`,`people`,`技工,维修工`],[`🧑💼`,`office worker`,`people`,`白领,上班族,职员`],[`🧑🚀`,`astronaut`,`people`,`宇航员,太空人`],[`🏃♂️`,`man running`,`activity`,``],[`🏃♀️`,`woman running`,`activity`,``],[`🚶♂️`,`man walking`,`travel`,``],[`🚶♀️`,`woman walking`,`travel`,``],[`🧎♂️`,`man kneeling`,`symbols`,``],[`🧎♀️`,`woman kneeling`,`symbols`,``],[`🏋️♂️`,`man lifting weights`,`activity`,``],[`🏋️♀️`,`woman lifting weights`,`activity`,``],[`🤸♂️`,`man cartwheeling`,`people`,``],[`🤸♀️`,`woman cartwheeling`,`people`,``],[`⛹️♂️`,`man bouncing ball`,`activity`,``],[`⛹️♀️`,`woman bouncing ball`,`activity`,``],[`🤾♂️`,`man playing handball`,`activity`,``],[`🤾♀️`,`woman playing handball`,`activity`,``],[`🧘♀️`,`woman in lotus position`,`people`,``],[`🏄♂️`,`man surfing`,`activity`,``],[`🏄♀️`,`woman surfing`,`activity`,``],[`🏊♂️`,`man swimming`,`activity`,``],[`🏊♀️`,`woman swimming`,`activity`,``],[`🚴♂️`,`man biking`,`travel`,``],[`🚴♀️`,`woman biking`,`travel`,``],[`🚵♂️`,`man mountain biking`,`travel`,``],[`🚵♀️`,`woman mountain biking`,`travel`,``],[`👯♂️`,`men with bunny ears`,`people`,``],[`👯♀️`,`women with bunny ears`,`people`,``],[`🧖♂️`,`man in steamy room`,`people`,``],[`🧖♀️`,`woman in steamy room`,`people`,``],[`🧗♂️`,`man climbing`,`people`,``],[`🧗♀️`,`woman climbing`,`people`,``],[`🤦♂️`,`man facepalming`,`smileys`,``],[`🤦♀️`,`woman facepalming`,`smileys`,``],[`🤷♂️`,`man shrugging`,`people`,``],[`🤷♀️`,`woman shrugging`,`people`,``],[`🙍♂️`,`person frowning`,`smileys`,``],[`🙍♀️`,`woman frowning`,`smileys`,``],[`🙎♂️`,`man pouting`,`smileys`,``],[`🙎♀️`,`woman pouting`,`smileys`,``],[`🙅♂️`,`man gesturing no`,`smileys`,``],[`🙅♀️`,`woman gesturing no`,`smileys`,``],[`🙆♂️`,`man gesturing ok`,`smileys`,``],[`🙆♀️`,`woman gesturing ok`,`smileys`,``],[`💁♂️`,`man tipping hand`,`people`,``],[`💁♀️`,`woman tipping hand`,`people`,``],[`🙋♂️`,`man raising hand`,`smileys`,``],[`🙋♀️`,`woman raising hand`,`smileys`,``],[`🙇♂️`,`man bowing`,`smileys`,``],[`🙇♀️`,`woman bowing`,`smileys`,``],[`💆♂️`,`man getting massage`,`people`,``],[`💆♀️`,`woman getting massage`,`people`,``],[`💇♂️`,`man getting haircut`,`people`,``],[`💇♀️`,`woman getting haircut`,`people`,``],[`🧞♂️`,`man genie`,`people`,``],[`🧞♀️`,`woman genie`,`people`,``],[`🧟♂️`,`man zombie`,`people`,``],[`🧟♀️`,`woman zombie`,`people`,``],[`🧜♂️`,`merman`,`people`,``],[`🧚♂️`,`man fairy`,`people`,``],[`🧚♀️`,`woman fairy`,`people`,``],[`🧛♂️`,`man vampire`,`people`,``],[`🧛♀️`,`woman vampire`,`people`,``],[`🧙♂️`,`man mage`,`people`,``],[`🧙♀️`,`mage`,`people`,``],[`🧝♂️`,`man elf`,`people`,``],[`🧝♀️`,`woman elf`,`people`,``],[`🦸♂️`,`man superhero`,`people`,``],[`🦸♀️`,`woman superhero`,`people`,``],[`🦹♂️`,`man supervillain`,`people`,``],[`🦹♀️`,`woman supervillain`,`people`,``],[`0️⃣`,`keycap 0`,`symbols`,``],[`1️⃣`,`keycap 1`,`symbols`,``],[`2️⃣`,`keycap 2`,`symbols`,``],[`3️⃣`,`keycap 3`,`symbols`,``],[`4️⃣`,`keycap 4`,`symbols`,``],[`5️⃣`,`keycap 5`,`symbols`,``],[`6️⃣`,`keycap 6`,`symbols`,``],[`7️⃣`,`keycap 7`,`symbols`,``],[`8️⃣`,`keycap 8`,`symbols`,``],[`9️⃣`,`keycap 9`,`symbols`,``],[`#️⃣`,`keycap #`,`symbols`,``],[`*️⃣`,`keycap *`,`symbols`,``],[`🇨🇳`,`flag china`,`flags`,`中国,国旗,五星红旗`],[`🇺🇸`,`flag united states`,`flags`,`美国,国旗,USA`],[`🇬🇧`,`flag united kingdom`,`flags`,`英国,国旗,UK`],[`🇯🇵`,`flag japan`,`flags`,`日本,国旗`],[`🇫🇷`,`flag france`,`flags`,`法国,国旗`],[`🇩🇪`,`flag germany`,`flags`,`德国,国旗`],[`🇮🇹`,`flag italy`,`flags`,`意大利,国旗`],[`🇪🇸`,`flag spain`,`flags`,`西班牙,国旗`],[`🇷🇺`,`flag russia`,`flags`,`俄罗斯,国旗`],[`🇮🇳`,`regional indicator symbol letter i`,`flags`,`印度,国旗`],[`🇧🇷`,`flag brazil`,`flags`,`巴西,国旗`],[`🇨🇦`,`flag canada`,`flags`,`加拿大,国旗`],[`🇦🇺`,`flag australia`,`flags`,`澳大利亚,国旗`],[`🇸🇬`,`flag singapore`,`flags`,`新加坡,国旗`],[`🇭🇰`,`flag hong kong`,`flags`,`香港,国旗,区旗`],[`🇹🇼`,`flag taiwan`,`flags`,`台湾,国旗`],[`🇲🇴`,`flag macau`,`flags`,`澳门,国旗`],[`🇻🇳`,`flag vietnam`,`flags`,`越南,国旗`],[`🇲🇾`,`regional indicator symbol letter m`,`flags`,`马来西亚,国旗`],[`🇮🇩`,`flag indonesia`,`flags`,`印尼,国旗`],[`🇵🇭`,`flag philippines`,`flags`,`菲律宾,国旗`],[`🇹🇷`,`flag turkey`,`flags`,`土耳其,国旗`],[`🇸🇦`,`flag saudi arabia`,`flags`,`沙特,国旗`],[`🇦🇪`,`flag united arab emirates`,`flags`,`阿联酋,国旗`],[`🇳🇱`,`flag netherlands`,`flags`,`荷兰,国旗`],[`🇸🇪`,`flag sweden`,`flags`,`瑞典,国旗`],[`🇨🇭`,`flag switzerland`,`flags`,`瑞士,国旗`],[`🇦🇹`,`flag austria`,`flags`,`奥地利,国旗`],[`🇧🇪`,`flag belgium`,`flags`,`比利时,国旗`],[`🇵🇹`,`flag portugal`,`flags`,`葡萄牙,国旗`],[`🇬🇷`,`flag greece`,`flags`,`希腊,国旗`],[`🇳🇴`,`flag norway`,`flags`,`挪威,国旗`],[`🇩🇰`,`flag denmark`,`flags`,`丹麦,国旗`],[`🇫🇮`,`flag finland`,`flags`,`芬兰,国旗`],[`🇵🇱`,`flag poland`,`flags`,`波兰,国旗`],[`🇺🇦`,`flag ukraine`,`flags`,`乌克兰,国旗`],[`🇮🇱`,`flag israel`,`flags`,`以色列,国旗`],[`🇪🇬`,`flag egypt`,`flags`,`埃及,国旗`],[`🇿🇦`,`flag south africa`,`flags`,`南非,国旗`],[`🇳🇬`,`flag nigeria`,`flags`,`尼日利亚,国旗`],[`🇲🇽`,`flag mexico`,`flags`,`墨西哥,国旗`],[`🇦🇷`,`flag argentina`,`flags`,``],[`🇨🇱`,`flag chile`,`flags`,`智利,国旗`],[`🇰🇿`,`flag kazakhstan`,`flags`,`哈萨克斯坦,国旗`],[`🇺🇿`,`flag uzbekistan`,`flags`,`乌兹别克斯坦,国旗`],[`🇳🇿`,`flag new zealand`,`flags`,`新西兰,国旗`],[`🇮🇪`,`flag ireland`,`flags`,`爱尔兰,国旗`],[`🇨🇿`,`flag czechia`,`flags`,`捷克,国旗`],[`👍🏻`,`thumbs up light skin`,`people`,``],[`👍🏽`,`thumbs up sign`,`people`,``],[`👍🏾`,`thumbs up medium dark skin`,`people`,``],[`👍🏿`,`thumbs up dark skin`,`people`,``],[`👏🏻`,`clapping hands light skin`,`people`,``],[`👏🏼`,`clapping hands medium light skin`,`people`,``],[`👏🏽`,`clapping hands medium skin`,`people`,``],[`👏🏾`,`clapping hands medium dark skin`,`people`,``],[`👏🏿`,`clapping hands dark skin`,`people`,``],[`🙏🏻`,`folded hands light skin`,`smileys`,``],[`🙏🏼`,`folded hands medium light skin`,`smileys`,``],[`🙏🏽`,`folded hands medium skin`,`smileys`,``],[`🙏🏾`,`folded hands medium dark skin`,`smileys`,``],[`🙏🏿`,`folded hands dark skin`,`smileys`,``],[`🏳️🌈`,`rainbow flag`,`flags`,``],[`🏴☠️`,`pirate flag`,`flags`,`海盗旗,海盗`]];r(`zh`,{agentMgr:{allTools:`全部`,defaultAgentName:`默认助手`,defaultAgentDesc:`全能 AI 助手,拥有所有工具能力`,switchedTo:`已切换到:{name}`,editAgent:`编辑助手`,templateLoaded:`已加载模板:{name}`,noSkillsHint:`暂无启用技能(请先确认 Agent 已连接且技能开关已开启)`,nameRequired:`请输入助手名称`,agentUpdated:`助手已更新`,agentCreated:`助手 "{name}" 已创建`,saveFailed:`保存失败:{message}`,confirmDeleteAgentMessage:`确定要删除助手 "{name}" 吗?
|
|
2189
2195
|
正在使用该助手的会话将恢复为默认助手。`,deleteAgentTitle:`删除助手`,agentDeleted:`助手已删除`,deleteFailed:`删除失败:{message}`,cannotDeleteDefault:`默认助手不支持删除`,emojiCatSmileys:`笑脸与表情`,emojiCatPeople:`人物与身体`,emojiCatAnimals:`动物与自然`,emojiCatFood:`食物与饮品`,emojiCatTravel:`旅行与交通`,emojiCatActivity:`活动与运动`,emojiCatObjects:`物品`,emojiCatSymbols:`符号`,emojiCatFlags:`旗帜`,emojiSearchPlaceholder:`搜索 Emoji(英文名 / 中文关键词)`,emojiSearchClear:`清空搜索`,emojiNoMatch:`未找到匹配的 Emoji`,confirm:`确认`},agentTemplates:{codeReviewName:`代码审查专家`,codeReviewDesc:`专注于代码审查和质量保证`,webAutomationName:`网页自动化助手`,webAutomationDesc:`专注于网页交互和自动化`,dataAnalystName:`数据分析师`,dataAnalystDesc:`专注于数据提取、分析和可视化`,documentationName:`文档助手`,documentationDesc:`专注于技术文档和内容整理`}}),r(`en`,{agentMgr:{allTools:`All`,defaultAgentName:`Default Assistant`,defaultAgentDesc:`All-purpose AI assistant with all tool capabilities`,switchedTo:`Switched to: {name}`,editAgent:`Edit assistant`,templateLoaded:`Template loaded: {name}`,noSkillsHint:`No enabled skills (please confirm Agent is connected and skill switch is on)`,nameRequired:`Please enter assistant name`,agentUpdated:`Assistant updated`,agentCreated:`Assistant "{name}" created`,saveFailed:`Save failed: {message}`,confirmDeleteAgentMessage:`Are you sure you want to delete assistant "{name}"?
|
|
2190
|
-
Sessions using this assistant will revert to the default assistant.`,deleteAgentTitle:`Delete assistant`,agentDeleted:`Assistant deleted`,deleteFailed:`Delete failed: {message}`,cannotDeleteDefault:`Default assistant cannot be deleted`,emojiCatSmileys:`Smileys & Emotion`,emojiCatPeople:`People & Body`,emojiCatAnimals:`Animals & Nature`,emojiCatFood:`Food & Drink`,emojiCatTravel:`Travel & Places`,emojiCatActivity:`Activities`,emojiCatObjects:`Objects`,emojiCatSymbols:`Symbols`,emojiCatFlags:`Flags`,emojiSearchPlaceholder:`Search emoji (name / keyword)`,emojiSearchClear:`Clear search`,emojiNoMatch:`No matching emoji`,confirm:`Confirm`},agentTemplates:{codeReviewName:`Code Review Expert`,codeReviewDesc:`Focused on code review and quality assurance`,webAutomationName:`Web Automation Assistant`,webAutomationDesc:`Focused on web interaction and automation`,dataAnalystName:`Data Analyst`,dataAnalystDesc:`Focused on data extraction, analysis, and visualization`,documentationName:`Documentation Assistant`,documentationDesc:`Focused on technical documentation and content organization`}});async function
|
|
2191
|
-
<div class="agent-item ${t?`active`:``} ${e.isBuiltin?``:`is-editable`}" data-agent-id="${
|
|
2192
|
-
<span class="agent-item-icon">${
|
|
2196
|
+
Sessions using this assistant will revert to the default assistant.`,deleteAgentTitle:`Delete assistant`,agentDeleted:`Assistant deleted`,deleteFailed:`Delete failed: {message}`,cannotDeleteDefault:`Default assistant cannot be deleted`,emojiCatSmileys:`Smileys & Emotion`,emojiCatPeople:`People & Body`,emojiCatAnimals:`Animals & Nature`,emojiCatFood:`Food & Drink`,emojiCatTravel:`Travel & Places`,emojiCatActivity:`Activities`,emojiCatObjects:`Objects`,emojiCatSymbols:`Symbols`,emojiCatFlags:`Flags`,emojiSearchPlaceholder:`Search emoji (name / keyword)`,emojiSearchClear:`Clear search`,emojiNoMatch:`No matching emoji`,confirm:`Confirm`},agentTemplates:{codeReviewName:`Code Review Expert`,codeReviewDesc:`Focused on code review and quality assurance`,webAutomationName:`Web Automation Assistant`,webAutomationDesc:`Focused on web interaction and automation`,dataAnalystName:`Data Analyst`,dataAnalystDesc:`Focused on data extraction, analysis, and visualization`,documentationName:`Documentation Assistant`,documentationDesc:`Focused on technical documentation and content organization`}});async function Tk(){await Ek(),await Dk(),Ak(),Mk(),o.debug(`[AgentMgr] Agent managerinitialization complete, activeAgentId:`,H.activeAgentId)}async function Ek(){let[e,t]=await Promise.all([Se(),we()]);H.activeSessionId||(H.activeAgentId=e),H.customAgents=t.filter(e=>!e.isBuiltin);let n=H.activeAgentId||e,r=t.find(e=>e.id===n||!n&&e.id==="default");H.activeAgentToolIds=r?r.toolIds:null,o.debug(`[AgentMgr] Agent state loaded, activeAgentId:`,H.activeAgentId,`total:`,t.length,`toolIds:`,H.activeAgentToolIds)}async function Dk(){let e=document.getElementById(`agentListItems`),t=document.getElementById(`agentDropdownFooter`);if(!e)return;let n=await we(),r=H.activeAgentId,a=``;for(let e of n){let t=e.id===r||!r&&e.id==="default",n=e.toolIds?e.toolIds.length:i(`agentMgr.allTools`),o=e.id==="default"?i(`agentMgr.defaultAgentName`):e.name,s=e.id==="default"?i(`agentMgr.defaultAgentDesc`):e.description||i(`agentConfig.toolCount`,{count:n});a+=`
|
|
2197
|
+
<div class="agent-item ${t?`active`:``} ${e.isBuiltin?``:`is-editable`}" data-agent-id="${dA(e.id)}">
|
|
2198
|
+
<span class="agent-item-icon">${uA(e.icon)}</span>
|
|
2193
2199
|
<div class="agent-item-info">
|
|
2194
|
-
<span class="agent-item-name">${
|
|
2195
|
-
<span class="agent-item-desc" title="${
|
|
2200
|
+
<span class="agent-item-name">${uA(o)}</span>
|
|
2201
|
+
<span class="agent-item-desc" title="${dA(s)}">${uA(s)}</span>
|
|
2196
2202
|
</div>
|
|
2197
2203
|
<div class="agent-item-actions">
|
|
2198
|
-
${e.isBuiltin?``:`<button class="agent-item-edit" data-action="edit" data-agent-id="${
|
|
2199
|
-
${e.isBuiltin?``:`<button class="agent-item-delete" data-action="delete" data-agent-id="${
|
|
2204
|
+
${e.isBuiltin?``:`<button class="agent-item-edit" data-action="edit" data-agent-id="${dA(e.id)}" title="${dA(i(`common.edit`))}">✎</button>`}
|
|
2205
|
+
${e.isBuiltin?``:`<button class="agent-item-delete" data-action="delete" data-agent-id="${dA(e.id)}" title="${dA(i(`common.delete`))}">✕</button>`}
|
|
2200
2206
|
${t?`<span class="agent-item-check">✓</span>`:``}
|
|
2201
2207
|
</div>
|
|
2202
2208
|
</div>`}e.innerHTML=a,t&&(t.innerHTML=`
|
|
2203
2209
|
<div class="agent-item" id="agentAddBtn" style="color:#667eea;">
|
|
2204
2210
|
<span class="agent-item-icon" style="color:#667eea;">+</span>
|
|
2205
2211
|
<span class="agent-item-name">${i(`agentEditor.createNew`)}</span>
|
|
2206
|
-
</div>`),Dk(n,r)}function Dk(e,t){let n=document.getElementById(`agentSelectorBtn`),r=document.getElementById(`agentSelectorText`),a=document.getElementById(`agentSelectorEmoji`);if(!n||!r)return;let o=e.find(e=>e.id===t)||e.find(e=>e.id==="default");if(o){let e=o.id==="default"?i(`agentMgr.defaultAgentName`):o.name;r.textContent=`${o.icon} ${e}`,a&&(a.textContent=o.icon),n.title=`${i(`header.switchAgent`)}: ${o.icon} ${e}`}else r.textContent=i(`header.defaultAssistant`),a&&(a.textContent=`🤖`),n.title=i(`header.switchAgent`)}function Ok(){let e=document.getElementById(`agentSelectorBtn`),t=document.getElementById(`agentSelectorDropdown`),n=document.getElementById(`agentSelectorWrapper`);if(!e||!t||!n)return;let r=n.getBoundingClientRect(),i=document.body.clientWidth;t.style.left=``,t.style.right=`auto`,t.style.maxWidth=Math.min(320,i-16)+`px`;let a=t.getBoundingClientRect().width,o=Math.min(a,i-16),s=e.getBoundingClientRect(),c=s.left+s.width/2,l=i-o-8,u=Math.max(8,Math.min(l,c-o/2));t.style.left=u-r.left+`px`}function kk(){let e=document.getElementById(`agentSelectorBtn`),t=document.getElementById(`agentSelectorDropdown`);!e||!t||(e.addEventListener(`click`,async e=>{if(e.stopPropagation(),t.style.display===`flex`)t.style.display=`none`;else{t.style.left=``,t.style.right=`auto`,t.style.maxWidth=Math.min(320,document.body.clientWidth-16)+`px`,t.style.display=`flex`,Ok();try{await Ek()}catch{}Ok()}}),document.addEventListener(`click`,()=>{t.style.display=`none`}),t.addEventListener(`click`,async e=>{let n=e.target.closest(`.agent-item`);if(!n)return;let r=e.target.closest(`[data-action]`);if(r&&r.dataset.action===`edit`){e.stopPropagation();let t=r.dataset.agentId;Wk(t);return}if(r&&r.dataset.action===`delete`){e.stopPropagation(),await oA(r.dataset.agentId);return}if(n.id===`agentAddBtn`){Wk(null);return}let i=n.dataset.agentId;i&&(await Ak(i),t.style.display=`none`)}))}async function Ak(e){let t=e?await be(e):null;if(H.activeAgentId=e,H.activeAgentToolIds=t?t.toolIds:null,H.activeAgentMcpExcludedServerIds=t?t.mcpExcludedServerIds??null:null,await Ee(e),At().catch(()=>{}),t&&!t.isBuiltin)t.model&&(H.currentModel=t.model),t.temperature!==null&&t.temperature!==void 0&&(H.temperature=t.temperature,H.topP=t.topP!==null&&t.topP!==void 0?t.topP:1),document.dispatchEvent(new CustomEvent(`agent-model-changed`));else if(!t||t.isBuiltin)try{let e=await chrome.storage.local.get([`modelName`,`temperature`,`topP`]);e.modelName&&(H.currentModel=e.modelName),e.temperature!==void 0&&(H.temperature=e.temperature),e.topP!==void 0&&(H.topP=e.topP),document.dispatchEvent(new CustomEvent(`agent-model-changed`))}catch{}await Ek();let n=`agentMcpClosedServers_${e||`default`}`,r=await chrome.storage.local.get([n,`ragTools`,`ragToolsIntroduced`]),a=r.ragTools||[];H.mcpClosedServers=r[n]||[];let s=`agentEnabledTools_${e||`default`}`,c=await chrome.storage.local.get([s,`enabledTools`]),l=!!c[s],u=c[s]||c.enabledTools;if(l||u&&u.length>0){let e=new Set([...f.map(e=>e.id),...a.map(e=>e.id)]),t=u.filter(t=>e.has(t));if(l)H.enabledTools=t;else{let e=f.filter(e=>e.enabled&&!t.includes(e.id)).map(e=>e.id);H.enabledTools=[...t,...e]}let n=xn(H.enabledTools,a,r.ragToolsIntroduced);H.enabledTools=n.tools,H.enabledTools.length!==u.length&&chrome.storage.local.set({[s]:H.enabledTools,...n.migrated?{ragToolsIntroduced:!0}:{}})}else{H.enabledTools=f.filter(e=>e.enabled).map(e=>e.id);let e=xn(H.enabledTools,a,r.ragToolsIntroduced);H.enabledTools=e.tools,e.migrated&&chrome.storage.local.set({ragToolsIntroduced:!0,[s]:H.enabledTools})}let d=document.getElementById(`toolsPopupOverlay`);d&&d.classList.contains(`show`)&&(sn(),hn(),gn()),yn();let p=t&&t.id!=="default"?t.name:i(`agentMgr.defaultAgentName`);U(i(`agentMgr.switchedTo`,{name:p}),`info`,2e3),o.debug(`[AgentMgr] switched Agent:`,e,p)}function jk(){let e=document.getElementById(`agentEditModal`);if(!e)return;e.querySelector(`#agentModalCloseBtn`)?.addEventListener(`click`,Gk),e.querySelector(`#agentSaveBtn`)?.addEventListener(`click`,iA),e.querySelector(`#agentDeleteBtn`)?.addEventListener(`click`,aA),e.querySelector(`#agentTemplateSelect`)?.addEventListener(`change`,qk),Ik();let t=document.getElementById(`agentToolActions`);t&&t.addEventListener(`click`,e=>{let t=e.target.closest(`button`);if(!t)return;let n=t.dataset.action;n===`selectAll`?Lk():n===`deselectAll`&&Rk()});let n=document.getElementById(`agentSkillActions`);n&&n.addEventListener(`click`,e=>{let t=e.target.closest(`button`);if(!t)return;let n=t.dataset.action;n===`selectAllSkills`?zk():n===`deselectAllSkills`&&Bk()});let r=document.getElementById(`agentToolList`);r&&(r.addEventListener(`click`,e=>{let t=e.target.closest(`.agent-mcp-expand-btn`);if(t){e.preventDefault(),Yk(t.dataset.serverId,t);return}let n=e.target.closest(`.agent-mcp-service-item`);if(n&&!e.target.closest(`input[type="checkbox"]`)){e.preventDefault(),Yk(n.dataset.mcpServerId,n.querySelector(`.agent-mcp-expand-btn`));return}let r=e.target.closest(`.agent-tool-category-clickable`);r&&Vk(r.dataset.category)}),r.addEventListener(`change`,e=>{e.target.matches(`input[type="checkbox"]`)&&Hk()}));let i=document.getElementById(`agentSkillList`);i&&i.addEventListener(`change`,e=>{e.target.matches(`input[type="checkbox"]`)&&Uk()}),document.addEventListener(`click`,e=>{let t=document.getElementById(`emojiPicker`),n=document.getElementById(`agentEditIconBtn`);t&&n&&t.style.display===`block`&&!n.contains(e.target)&&!t.contains(e.target)&&(t.style.display=`none`)})}var Mk=[[`smileys`,`emojiCatSmileys`],[`people`,`emojiCatPeople`],[`animals`,`emojiCatAnimals`],[`food`,`emojiCatFood`],[`travel`,`emojiCatTravel`],[`activity`,`emojiCatActivity`],[`objects`,`emojiCatObjects`],[`symbols`,`emojiCatSymbols`],[`flags`,`emojiCatFlags`]];function Nk(e,t){return!!(e[1].includes(t)||e[3]&&e[3].includes(t))}function Pk(e){let t=``;for(let[e,n]of Mk){let r=Ck.filter(t=>t[2]===e);if(r.length){t+=`<div class="emoji-category-label">${i(`agentMgr.`+n)}</div>`,t+=`<div class="emoji-picker-grid">`;for(let e of r)t+=`<button type="button" class="emoji-picker-item" data-emoji="${uA(e[0])}" title="${uA(e[1])}">${e[0]}</button>`;t+=`</div>`}}e.innerHTML=t}function Fk(e,t){let n=Ck.filter(e=>Nk(e,t));if(!n.length){e.innerHTML=`<div class="emoji-picker-empty">${i(`agentMgr.emojiNoMatch`)}</div>`;return}let r=`<div class="emoji-picker-grid">`;for(let e of n)r+=`<button type="button" class="emoji-picker-item" data-emoji="${uA(e[0])}" title="${uA(e[1])}">${e[0]}</button>`;r+=`</div>`,e.innerHTML=r}function Ik(){let e=document.getElementById(`emojiPicker`),t=document.getElementById(`agentEditIconBtn`),n=document.getElementById(`agentEditIcon`),r=document.getElementById(`emojiSearchInput`),i=document.getElementById(`emojiSearchClear`),a=document.getElementById(`emojiPickerBody`);if(!e||!t)return;let o=()=>{let e=r?r.value.trim().toLowerCase():``;e?Fk(a,e):Pk(a),i&&(i.style.display=e?`flex`:`none`)};t.addEventListener(`click`,n=>{if(n.stopPropagation(),e.style.display===`block`){e.style.display=`none`;return}r&&(r.value=``),o();let i=t.getBoundingClientRect();document.body.clientWidth-i.left>=330?(e.style.left=`0`,e.style.right=`auto`):(e.style.left=`auto`,e.style.right=`0`),e.style.display=`block`}),r&&r.addEventListener(`input`,o),i&&i.addEventListener(`click`,e=>{e.stopPropagation(),r&&(r.value=``),o(),r&&r.focus()}),e.addEventListener(`click`,r=>{let i=r.target.closest(`.emoji-picker-item`);if(!i)return;let a=i.dataset.emoji;t.textContent=a,n&&(n.value=a),e.style.display=`none`})}function Lk(){document.querySelectorAll(`#agentToolList input[type="checkbox"]`).forEach(e=>{e.checked=!0}),Hk()}function Rk(){document.querySelectorAll(`#agentToolList input[type="checkbox"]`).forEach(e=>{e.checked=!1}),Hk()}function zk(){document.querySelectorAll(`#agentSkillList input[type="checkbox"]`).forEach(e=>{e.checked=!0}),Uk()}function Bk(){document.querySelectorAll(`#agentSkillList input[type="checkbox"]`).forEach(e=>{e.checked=!1}),Uk()}function Vk(e){let t=document.querySelectorAll(`#agentToolList .agent-tool-item[data-category="${e}"]`),n=[];if(t.forEach(e=>{let t=e.querySelector(`input[type="checkbox"]`);t&&n.push(t)}),n.length===0)return;let r=n.every(e=>e.checked);n.forEach(e=>{e.checked=!r}),Hk()}function Hk(){let e=document.getElementById(`agentToolList`);if(!e)return;let t=0,n=0,r=Array.from(e.querySelectorAll(`.agent-tool-item`));e.querySelectorAll(`.agent-tool-category-clickable`).forEach(e=>{let i=e.dataset.category,a=r.filter(e=>e.dataset.category===i),o=0,s=0;o=a.length,a.forEach(e=>{let t=e.querySelector(`input[type="checkbox"]`);t&&t.checked&&(s+=1)}),t+=o,n+=s;let c=e.querySelector(`.agent-tool-cat-count`);c&&(c.textContent=`${s}/${o}`)});let a=document.getElementById(`agentToolCount`);a&&(a.textContent=i(`agentConfig.selectedTotalCount`,{selected:n,total:t}))}function Uk(){let e=document.getElementById(`agentSkillList`),t=document.getElementById(`agentSkillCount`);if(!e||!t)return;let n=e.querySelectorAll(`input[type="checkbox"]`).length,r=e.querySelectorAll(`input[type="checkbox"]:checked`).length;t.textContent=i(`agentConfig.selectedTotalCount`,{selected:r,total:n})}async function Wk(e){let t=document.getElementById(`agentEditModal`);if(!t)return;await eA(),tA(-1),t.querySelector(`#agentEditId`).value=``,t.querySelector(`#agentEditName`).value=``,t.querySelector(`#agentEditIcon`).value=`🤖`;let n=t.querySelector(`#agentEditIconBtn`);n&&(n.textContent=`🤖`),t.querySelector(`#agentEditDesc`).value=``,t.querySelector(`#agentEditPrompt`).value=``,t.querySelector(`#agentEditAllowSub`).checked=!1,t.querySelector(`#agentTemplateSelect`).value=``,t.querySelector(`#agentEditModel`).value=``;let r=t.querySelector(`#agentDeleteBtn`),a=t.querySelector(`#agentEditTitle`);if(e){let n=await be(e);if(!n||n.isBuiltin)return;a.textContent=i(`agentMgr.editAgent`),t.querySelector(`#agentEditId`).value=n.id,t.querySelector(`#agentEditName`).value=n.name,t.querySelector(`#agentEditIcon`).value=n.icon||`🤖`;let o=t.querySelector(`#agentEditIconBtn`);o&&(o.textContent=n.icon||`🤖`),t.querySelector(`#agentEditDesc`).value=n.description||``,t.querySelector(`#agentEditPrompt`).value=n.systemPrompt||``,t.querySelector(`#agentEditAllowSub`).checked=n.allowSubDispatch||!1,t.querySelector(`#agentEditModel`).value=n.model||``,tA(rA(n.temperature,n.topP)),r.style.display=`block`,Jk(n.toolIds,n.mcpExcludedServerIds??[]),Qk(n.skillIds)}else a.textContent=i(`agentEditor.createNew`),r.style.display=`none`,Jk(null,[]),Qk(null);Kk(),t.style.display=`flex`;let o=t.querySelector(`#agentEditModel`);if(o){let e=o.value,t=o.cloneNode(!0);o.parentNode.replaceChild(t,o),t.value=e,t.addEventListener(`mousedown`,()=>{let e=t.value;e&&(t.dataset._saved=e,t.value=``)}),t.addEventListener(`blur`,()=>{setTimeout(()=>{t.value||=t.dataset._saved||``},150)})}}function Gk(){let e=document.getElementById(`agentEditModal`);e&&(e.style.display=`none`)}function Kk(){let e=document.getElementById(`agentTemplateSelect`);if(!e)return;let t=[i(`agentTemplates.codeReviewName`),i(`agentTemplates.webAutomationName`),i(`agentTemplates.dataAnalystName`),i(`agentTemplates.documentationName`)],n=`<option value="">${i(`agentEditor.selectTemplate`)}</option>`;for(let e=0;e<se.length;e++){let r=se[e];n+=`<option value="${e}">${r.icon} ${t[e]}</option>`}e.innerHTML=n}function qk(e){let t=parseInt(e.target.value);if(isNaN(t)||t<0||t>=se.length)return;let n=se[t],r=document.getElementById(`agentEditModal`);if(!r)return;let a=[`agentTemplates.codeReviewName`,`agentTemplates.webAutomationName`,`agentTemplates.dataAnalystName`,`agentTemplates.documentationName`],o=[`agentTemplates.codeReviewDesc`,`agentTemplates.webAutomationDesc`,`agentTemplates.dataAnalystDesc`,`agentTemplates.documentationDesc`];r.querySelector(`#agentEditName`).value=i(a[t]),r.querySelector(`#agentEditIcon`).value=n.icon;let s=r.querySelector(`#agentEditIconBtn`);s&&(s.textContent=n.icon),r.querySelector(`#agentEditDesc`).value=i(o[t]),r.querySelector(`#agentEditPrompt`).value=c()===`en`?n.systemPrompt:n.systemPromptZh||n.systemPrompt,r.querySelector(`#agentEditAllowSub`).checked=n.allowSubDispatch||!1,r.querySelector(`#agentEditModel`).value=n.model||``,tA(rA(n.temperature,n.topP)),Jk(n.toolIds,[]),Qk(n.skillIds||null),U(i(`agentMgr.templateLoaded`,{name:n.name}),`info`,2e3)}async function Jk(e,t){let n=document.getElementById(`agentToolList`);if(!n)return;let r=[];try{r=(await chrome.storage.local.get([`mcpTools`])).mcpTools||[]}catch{}let{mcpEnabled:a,skillsEnabled:o}=await chrome.storage.local.get([`mcpEnabled`,`skillsEnabled`]),s=H.agentPlatform?.connected===!0,c=[...f];s||(c=c.filter(e=>!e.id.startsWith(`agent_`))),o===!1&&(c=c.filter(e=>e.id!==`agent_skill`));let l=[];if(a===!0&&s){let e=new Map;for(let t of r){let n=t.serverId||`unknown`;e.has(n)||e.set(n,{serverId:n,serverName:t.serverName||n,tools:[]}),e.get(n).tools.push(t)}l=Array.from(e.values())}let u=new Set(Array.isArray(t)?t:[]),d=new Set(e||[]),p=e?e.length:c.length,m=l.filter(e=>!u.has(e.serverId)).length,h={};for(let e of c){let t=e.category||`other`;h[t]||(h[t]=[]),h[t].push(e)}let g=``;for(let[e,t]of Object.entries(h)){let n=i(`toolCategory.${e}`)===`toolCategory.${e}`?e:i(`toolCategory.${e}`),r=t.length,a=t.filter(e=>d.has(e.id)).length;g+=`<div class="agent-tool-category agent-tool-category-clickable" data-category="${uA(e)}" title="${uA(i(`agentConfig.toggleCategoryAll`))}">${n} <span class="agent-tool-cat-count" style="font-weight:400;color:#999;">${a}/${r}</span></div>`;for(let n of t){let t=d.has(n.id)?`checked`:``,r=Ht(n),i=r.length>40?r.substring(0,40)+`...`:r;g+=`
|
|
2207
|
-
<label class="agent-tool-item" data-category="${
|
|
2208
|
-
<input type="checkbox" value="${
|
|
2209
|
-
<span class="agent-tool-name" title="${
|
|
2210
|
-
<span class="agent-tool-desc" title="${
|
|
2211
|
-
</label>`}}if(l.length>0){let e=i(`toolCategory.mcp`)===`toolCategory.mcp`?`mcp`:i(`toolCategory.mcp`);g+=`<div class="agent-tool-category agent-tool-category-clickable" data-category="mcp" title="${
|
|
2212
|
-
<label class="agent-tool-item agent-mcp-service-item" data-category="mcp" data-mcp-server-id="${
|
|
2213
|
-
<input type="checkbox" ${t} data-mcp-server-id="${
|
|
2214
|
-
<span class="agent-tool-name" title="${
|
|
2215
|
-
<span class="agent-tool-desc" title="${
|
|
2216
|
-
<span class="agent-mcp-service-id" title="ID: ${
|
|
2217
|
-
<button type="button" class="agent-mcp-expand-btn" data-server-id="${
|
|
2212
|
+
</div>`),Ok(n,r)}function Ok(e,t){let n=document.getElementById(`agentSelectorBtn`),r=document.getElementById(`agentSelectorText`),a=document.getElementById(`agentSelectorEmoji`);if(!n||!r)return;let o=e.find(e=>e.id===t)||e.find(e=>e.id==="default");if(o){let e=o.id==="default"?i(`agentMgr.defaultAgentName`):o.name;r.textContent=`${o.icon} ${e}`,a&&(a.textContent=o.icon),n.title=`${i(`header.switchAgent`)}: ${o.icon} ${e}`}else r.textContent=i(`header.defaultAssistant`),a&&(a.textContent=`🤖`),n.title=i(`header.switchAgent`)}function kk(){let e=document.getElementById(`agentSelectorBtn`),t=document.getElementById(`agentSelectorDropdown`),n=document.getElementById(`agentSelectorWrapper`);if(!e||!t||!n)return;let r=n.getBoundingClientRect(),i=document.body.clientWidth;t.style.left=``,t.style.right=`auto`,t.style.maxWidth=Math.min(320,i-16)+`px`;let a=t.getBoundingClientRect().width,o=Math.min(a,i-16),s=e.getBoundingClientRect(),c=s.left+s.width/2,l=i-o-8,u=Math.max(8,Math.min(l,c-o/2));t.style.left=u-r.left+`px`}function Ak(){let e=document.getElementById(`agentSelectorBtn`),t=document.getElementById(`agentSelectorDropdown`);!e||!t||(e.addEventListener(`click`,async e=>{if(e.stopPropagation(),t.style.display===`flex`)t.style.display=`none`;else{t.style.left=``,t.style.right=`auto`,t.style.maxWidth=Math.min(320,document.body.clientWidth-16)+`px`,t.style.display=`flex`,kk();try{await Dk()}catch{}kk()}}),document.addEventListener(`click`,()=>{t.style.display=`none`}),t.addEventListener(`click`,async e=>{let n=e.target.closest(`.agent-item`);if(!n)return;let r=e.target.closest(`[data-action]`);if(r&&r.dataset.action===`edit`){e.stopPropagation();let t=r.dataset.agentId;Gk(t);return}if(r&&r.dataset.action===`delete`){e.stopPropagation(),await sA(r.dataset.agentId);return}if(n.id===`agentAddBtn`){Gk(null);return}let i=n.dataset.agentId;i&&(await jk(i),t.style.display=`none`)}))}async function jk(e){let t=e?await be(e):null;if(H.activeAgentId=e,H.activeAgentToolIds=t?t.toolIds:null,H.activeAgentMcpExcludedServerIds=t?t.mcpExcludedServerIds??null:null,await Ee(e),At().catch(()=>{}),t&&!t.isBuiltin)t.model&&(H.currentModel=t.model),t.temperature!==null&&t.temperature!==void 0&&(H.temperature=t.temperature,H.topP=t.topP!==null&&t.topP!==void 0?t.topP:1),document.dispatchEvent(new CustomEvent(`agent-model-changed`));else if(!t||t.isBuiltin)try{let e=await chrome.storage.local.get([`modelName`,`temperature`,`topP`]);e.modelName&&(H.currentModel=e.modelName),e.temperature!==void 0&&(H.temperature=e.temperature),e.topP!==void 0&&(H.topP=e.topP),document.dispatchEvent(new CustomEvent(`agent-model-changed`))}catch{}await Dk();let n=`agentMcpClosedServers_${e||`default`}`,r=await chrome.storage.local.get([n,`ragTools`,`ragToolsIntroduced`]),a=r.ragTools||[];H.mcpClosedServers=r[n]||[];let s=`agentEnabledTools_${e||`default`}`,c=await chrome.storage.local.get([s,`enabledTools`]),l=!!c[s],u=c[s]||c.enabledTools;if(l||u&&u.length>0){let e=new Set([...f.map(e=>e.id),...a.map(e=>e.id)]),t=u.filter(t=>e.has(t));if(l)H.enabledTools=t;else{let e=f.filter(e=>e.enabled&&!t.includes(e.id)).map(e=>e.id);H.enabledTools=[...t,...e]}let n=xn(H.enabledTools,a,r.ragToolsIntroduced);H.enabledTools=n.tools,H.enabledTools.length!==u.length&&chrome.storage.local.set({[s]:H.enabledTools,...n.migrated?{ragToolsIntroduced:!0}:{}})}else{H.enabledTools=f.filter(e=>e.enabled).map(e=>e.id);let e=xn(H.enabledTools,a,r.ragToolsIntroduced);H.enabledTools=e.tools,e.migrated&&chrome.storage.local.set({ragToolsIntroduced:!0,[s]:H.enabledTools})}let d=document.getElementById(`toolsPopupOverlay`);d&&d.classList.contains(`show`)&&(sn(),hn(),gn()),yn();let p=t&&t.id!=="default"?t.name:i(`agentMgr.defaultAgentName`);U(i(`agentMgr.switchedTo`,{name:p}),`info`,2e3),o.debug(`[AgentMgr] switched Agent:`,e,p)}function Mk(){let e=document.getElementById(`agentEditModal`);if(!e)return;e.querySelector(`#agentModalCloseBtn`)?.addEventListener(`click`,Kk),e.querySelector(`#agentSaveBtn`)?.addEventListener(`click`,aA),e.querySelector(`#agentDeleteBtn`)?.addEventListener(`click`,oA),e.querySelector(`#agentTemplateSelect`)?.addEventListener(`change`,Jk),Lk();let t=document.getElementById(`agentToolActions`);t&&t.addEventListener(`click`,e=>{let t=e.target.closest(`button`);if(!t)return;let n=t.dataset.action;n===`selectAll`?Rk():n===`deselectAll`&&zk()});let n=document.getElementById(`agentSkillActions`);n&&n.addEventListener(`click`,e=>{let t=e.target.closest(`button`);if(!t)return;let n=t.dataset.action;n===`selectAllSkills`?Bk():n===`deselectAllSkills`&&Vk()});let r=document.getElementById(`agentToolList`);r&&(r.addEventListener(`click`,e=>{let t=e.target.closest(`.agent-mcp-expand-btn`);if(t){e.preventDefault(),Xk(t.dataset.serverId,t);return}let n=e.target.closest(`.agent-mcp-service-item`);if(n&&!e.target.closest(`input[type="checkbox"]`)){e.preventDefault(),Xk(n.dataset.mcpServerId,n.querySelector(`.agent-mcp-expand-btn`));return}let r=e.target.closest(`.agent-tool-category-clickable`);r&&Hk(r.dataset.category)}),r.addEventListener(`change`,e=>{e.target.matches(`input[type="checkbox"]`)&&Uk()}));let i=document.getElementById(`agentSkillList`);i&&i.addEventListener(`change`,e=>{e.target.matches(`input[type="checkbox"]`)&&Wk()}),document.addEventListener(`click`,e=>{let t=document.getElementById(`emojiPicker`),n=document.getElementById(`agentEditIconBtn`);t&&n&&t.style.display===`block`&&!n.contains(e.target)&&!t.contains(e.target)&&(t.style.display=`none`)})}var Nk=[[`smileys`,`emojiCatSmileys`],[`people`,`emojiCatPeople`],[`animals`,`emojiCatAnimals`],[`food`,`emojiCatFood`],[`travel`,`emojiCatTravel`],[`activity`,`emojiCatActivity`],[`objects`,`emojiCatObjects`],[`symbols`,`emojiCatSymbols`],[`flags`,`emojiCatFlags`]];function Pk(e,t){return!!(e[1].includes(t)||e[3]&&e[3].includes(t))}function Fk(e){let t=``;for(let[e,n]of Nk){let r=wk.filter(t=>t[2]===e);if(r.length){t+=`<div class="emoji-category-label">${i(`agentMgr.`+n)}</div>`,t+=`<div class="emoji-picker-grid">`;for(let e of r)t+=`<button type="button" class="emoji-picker-item" data-emoji="${dA(e[0])}" title="${dA(e[1])}">${e[0]}</button>`;t+=`</div>`}}e.innerHTML=t}function Ik(e,t){let n=wk.filter(e=>Pk(e,t));if(!n.length){e.innerHTML=`<div class="emoji-picker-empty">${i(`agentMgr.emojiNoMatch`)}</div>`;return}let r=`<div class="emoji-picker-grid">`;for(let e of n)r+=`<button type="button" class="emoji-picker-item" data-emoji="${dA(e[0])}" title="${dA(e[1])}">${e[0]}</button>`;r+=`</div>`,e.innerHTML=r}function Lk(){let e=document.getElementById(`emojiPicker`),t=document.getElementById(`agentEditIconBtn`),n=document.getElementById(`agentEditIcon`),r=document.getElementById(`emojiSearchInput`),i=document.getElementById(`emojiSearchClear`),a=document.getElementById(`emojiPickerBody`);if(!e||!t)return;let o=()=>{let e=r?r.value.trim().toLowerCase():``;e?Ik(a,e):Fk(a),i&&(i.style.display=e?`flex`:`none`)};t.addEventListener(`click`,n=>{if(n.stopPropagation(),e.style.display===`block`){e.style.display=`none`;return}r&&(r.value=``),o();let i=t.getBoundingClientRect();document.body.clientWidth-i.left>=330?(e.style.left=`0`,e.style.right=`auto`):(e.style.left=`auto`,e.style.right=`0`),e.style.display=`block`}),r&&r.addEventListener(`input`,o),i&&i.addEventListener(`click`,e=>{e.stopPropagation(),r&&(r.value=``),o(),r&&r.focus()}),e.addEventListener(`click`,r=>{let i=r.target.closest(`.emoji-picker-item`);if(!i)return;let a=i.dataset.emoji;t.textContent=a,n&&(n.value=a),e.style.display=`none`})}function Rk(){document.querySelectorAll(`#agentToolList input[type="checkbox"]`).forEach(e=>{e.checked=!0}),Uk()}function zk(){document.querySelectorAll(`#agentToolList input[type="checkbox"]`).forEach(e=>{e.checked=!1}),Uk()}function Bk(){document.querySelectorAll(`#agentSkillList input[type="checkbox"]`).forEach(e=>{e.checked=!0}),Wk()}function Vk(){document.querySelectorAll(`#agentSkillList input[type="checkbox"]`).forEach(e=>{e.checked=!1}),Wk()}function Hk(e){let t=document.querySelectorAll(`#agentToolList .agent-tool-item[data-category="${e}"]`),n=[];if(t.forEach(e=>{let t=e.querySelector(`input[type="checkbox"]`);t&&n.push(t)}),n.length===0)return;let r=n.every(e=>e.checked);n.forEach(e=>{e.checked=!r}),Uk()}function Uk(){let e=document.getElementById(`agentToolList`);if(!e)return;let t=0,n=0,r=Array.from(e.querySelectorAll(`.agent-tool-item`));e.querySelectorAll(`.agent-tool-category-clickable`).forEach(e=>{let i=e.dataset.category,a=r.filter(e=>e.dataset.category===i),o=0,s=0;o=a.length,a.forEach(e=>{let t=e.querySelector(`input[type="checkbox"]`);t&&t.checked&&(s+=1)}),t+=o,n+=s;let c=e.querySelector(`.agent-tool-cat-count`);c&&(c.textContent=`${s}/${o}`)});let a=document.getElementById(`agentToolCount`);a&&(a.textContent=i(`agentConfig.selectedTotalCount`,{selected:n,total:t}))}function Wk(){let e=document.getElementById(`agentSkillList`),t=document.getElementById(`agentSkillCount`);if(!e||!t)return;let n=e.querySelectorAll(`input[type="checkbox"]`).length,r=e.querySelectorAll(`input[type="checkbox"]:checked`).length;t.textContent=i(`agentConfig.selectedTotalCount`,{selected:r,total:n})}async function Gk(e){let t=document.getElementById(`agentEditModal`);if(!t)return;await tA(),nA(-1),t.querySelector(`#agentEditId`).value=``,t.querySelector(`#agentEditName`).value=``,t.querySelector(`#agentEditIcon`).value=`🤖`;let n=t.querySelector(`#agentEditIconBtn`);n&&(n.textContent=`🤖`),t.querySelector(`#agentEditDesc`).value=``,t.querySelector(`#agentEditPrompt`).value=``,t.querySelector(`#agentEditAllowSub`).checked=!1,t.querySelector(`#agentTemplateSelect`).value=``,t.querySelector(`#agentEditModel`).value=``;let r=t.querySelector(`#agentDeleteBtn`),a=t.querySelector(`#agentEditTitle`);if(e){let n=await be(e);if(!n||n.isBuiltin)return;a.textContent=i(`agentMgr.editAgent`),t.querySelector(`#agentEditId`).value=n.id,t.querySelector(`#agentEditName`).value=n.name,t.querySelector(`#agentEditIcon`).value=n.icon||`🤖`;let o=t.querySelector(`#agentEditIconBtn`);o&&(o.textContent=n.icon||`🤖`),t.querySelector(`#agentEditDesc`).value=n.description||``,t.querySelector(`#agentEditPrompt`).value=n.systemPrompt||``,t.querySelector(`#agentEditAllowSub`).checked=n.allowSubDispatch||!1,t.querySelector(`#agentEditModel`).value=n.model||``,nA(iA(n.temperature,n.topP)),r.style.display=`block`,Yk(n.toolIds,n.mcpExcludedServerIds??[]),$k(n.skillIds)}else a.textContent=i(`agentEditor.createNew`),r.style.display=`none`,Yk(null,[]),$k(null);qk(),t.style.display=`flex`;let o=t.querySelector(`#agentEditModel`);if(o){let e=o.value,t=o.cloneNode(!0);o.parentNode.replaceChild(t,o),t.value=e,t.addEventListener(`mousedown`,()=>{let e=t.value;e&&(t.dataset._saved=e,t.value=``)}),t.addEventListener(`blur`,()=>{setTimeout(()=>{t.value||=t.dataset._saved||``},150)})}}function Kk(){let e=document.getElementById(`agentEditModal`);e&&(e.style.display=`none`)}function qk(){let e=document.getElementById(`agentTemplateSelect`);if(!e)return;let t=[i(`agentTemplates.codeReviewName`),i(`agentTemplates.webAutomationName`),i(`agentTemplates.dataAnalystName`),i(`agentTemplates.documentationName`)],n=`<option value="">${i(`agentEditor.selectTemplate`)}</option>`;for(let e=0;e<se.length;e++){let r=se[e];n+=`<option value="${e}">${r.icon} ${t[e]}</option>`}e.innerHTML=n}function Jk(e){let t=parseInt(e.target.value);if(isNaN(t)||t<0||t>=se.length)return;let n=se[t],r=document.getElementById(`agentEditModal`);if(!r)return;let a=[`agentTemplates.codeReviewName`,`agentTemplates.webAutomationName`,`agentTemplates.dataAnalystName`,`agentTemplates.documentationName`],o=[`agentTemplates.codeReviewDesc`,`agentTemplates.webAutomationDesc`,`agentTemplates.dataAnalystDesc`,`agentTemplates.documentationDesc`];r.querySelector(`#agentEditName`).value=i(a[t]),r.querySelector(`#agentEditIcon`).value=n.icon;let s=r.querySelector(`#agentEditIconBtn`);s&&(s.textContent=n.icon),r.querySelector(`#agentEditDesc`).value=i(o[t]),r.querySelector(`#agentEditPrompt`).value=c()===`en`?n.systemPrompt:n.systemPromptZh||n.systemPrompt,r.querySelector(`#agentEditAllowSub`).checked=n.allowSubDispatch||!1,r.querySelector(`#agentEditModel`).value=n.model||``,nA(iA(n.temperature,n.topP)),Yk(n.toolIds,[]),$k(n.skillIds||null),U(i(`agentMgr.templateLoaded`,{name:n.name}),`info`,2e3)}async function Yk(e,t){let n=document.getElementById(`agentToolList`);if(!n)return;let r=[];try{r=(await chrome.storage.local.get([`mcpTools`])).mcpTools||[]}catch{}let{mcpEnabled:a,skillsEnabled:o}=await chrome.storage.local.get([`mcpEnabled`,`skillsEnabled`]),s=H.agentPlatform?.connected===!0,c=[...f];s||(c=c.filter(e=>!e.id.startsWith(`agent_`))),o===!1&&(c=c.filter(e=>e.id!==`agent_skill`));let l=[];if(a===!0&&s){let e=new Map;for(let t of r){let n=t.serverId||`unknown`;e.has(n)||e.set(n,{serverId:n,serverName:t.serverName||n,tools:[]}),e.get(n).tools.push(t)}l=Array.from(e.values())}let u=new Set(Array.isArray(t)?t:[]),d=new Set(e||[]),p=e?e.length:c.length,m=l.filter(e=>!u.has(e.serverId)).length,h={};for(let e of c){let t=e.category||`other`;h[t]||(h[t]=[]),h[t].push(e)}let g=``;for(let[e,t]of Object.entries(h)){let n=i(`toolCategory.${e}`)===`toolCategory.${e}`?e:i(`toolCategory.${e}`),r=t.length,a=t.filter(e=>d.has(e.id)).length;g+=`<div class="agent-tool-category agent-tool-category-clickable" data-category="${dA(e)}" title="${dA(i(`agentConfig.toggleCategoryAll`))}">${n} <span class="agent-tool-cat-count" style="font-weight:400;color:#999;">${a}/${r}</span></div>`;for(let n of t){let t=d.has(n.id)?`checked`:``,r=Ht(n),i=r.length>40?r.substring(0,40)+`...`:r;g+=`
|
|
2213
|
+
<label class="agent-tool-item" data-category="${dA(e)}">
|
|
2214
|
+
<input type="checkbox" value="${dA(n.id)}" ${t} data-tool-id="${dA(n.id)}">
|
|
2215
|
+
<span class="agent-tool-name" title="${dA(n.name)}">${uA(n.name)}</span>
|
|
2216
|
+
<span class="agent-tool-desc" title="${dA(r)}">${uA(i)}</span>
|
|
2217
|
+
</label>`}}if(l.length>0){let e=i(`toolCategory.mcp`)===`toolCategory.mcp`?`mcp`:i(`toolCategory.mcp`);g+=`<div class="agent-tool-category agent-tool-category-clickable" data-category="mcp" title="${dA(i(`agentConfig.toggleCategoryAll`))}">${e} <span class="agent-tool-cat-count" style="font-weight:400;color:#999;">${m}/${l.length}</span></div>`;for(let e of l){let t=u.has(e.serverId)?``:`checked`,n=i(`toolPanel.mcpServiceToolCount`,{count:e.tools.length}),r=e.tools.map(e=>e.name).join(`, `),a=e.tools.map(e=>{let t=e.name||``,n=Ut(e);return`<div class="agent-mcp-tool-row" title="${dA(n?`${t}:${n}`:t)}"><div class="agent-mcp-tool-name">${uA(t)}</div>`+(n?`<div class="agent-mcp-tool-desc">${uA(n)}</div>`:``)+`</div>`}).join(``);g+=`
|
|
2218
|
+
<label class="agent-tool-item agent-mcp-service-item" data-category="mcp" data-mcp-server-id="${dA(e.serverId)}">
|
|
2219
|
+
<input type="checkbox" ${t} data-mcp-server-id="${dA(e.serverId)}">
|
|
2220
|
+
<span class="agent-tool-name" title="${dA(e.serverName)}">${uA(e.serverName)}</span>
|
|
2221
|
+
<span class="agent-tool-desc" title="${dA(r)}">${uA(n)}</span>
|
|
2222
|
+
<span class="agent-mcp-service-id" title="ID: ${dA(e.serverId)}">ID: ${uA(e.serverId)}</span>
|
|
2223
|
+
<button type="button" class="agent-mcp-expand-btn" data-server-id="${dA(e.serverId)}" title="${dA(i(`toolPanel.mcpServiceExpand`))}">▶</button>
|
|
2218
2224
|
</label>
|
|
2219
|
-
<div class="agent-mcp-tool-list collapsed" data-server-id="${
|
|
2225
|
+
<div class="agent-mcp-tool-list collapsed" data-server-id="${dA(e.serverId)}">${a}</div>`}}n.innerHTML=g;let _=document.getElementById(`agentToolCount`);_&&(_.textContent=i(`agentConfig.selectedTotalCount`,{selected:p+m,total:c.length+l.length}))}function Xk(e,t){let n=document.getElementById(`agentToolList`);if(!n||!e)return;let r=Array.from(n.querySelectorAll(`.agent-mcp-tool-list`)).find(t=>t.dataset.serverId===e);if(!r)return;let i=r.classList.toggle(`collapsed`),a=t||r.previousElementSibling?.querySelector(`.agent-mcp-expand-btn`);a&&(a.textContent=i?`▶`:`▼`)}function Zk(){let e=document.getElementById(`agentToolList`);if(!e)return null;let t=e.querySelectorAll(`input[type="checkbox"][data-tool-id]:checked`),n=[];return t.forEach(e=>n.push(e.value)),n.length>0?n:null}function Qk(){let e=document.getElementById(`agentToolList`);if(!e)return;let t=e.querySelectorAll(`.agent-mcp-service-item`);if(t.length===0)return;let n=[];return t.forEach(e=>{let t=e.querySelector(`input[type="checkbox"]`);t&&!t.checked&&n.push(e.dataset.mcpServerId)}),n}async function $k(e){let t=document.getElementById(`agentSkillList`);if(!t)return;let n=[];try{n=await $O()}catch{}let r=new Set(e||[]),a=e?e.length:n.length,o=n.length;if(n.length===0){t.innerHTML=`<div style="color:#999;font-size:12px;padding:8px;text-align:center;">${i(`agentMgr.noSkillsHint`)}</div>`;let e=document.getElementById(`agentSkillCount`);e&&(e.textContent=`(0)`);return}t.innerHTML=n.map(e=>{let t=r.has(e.name)?`checked`:``;return`
|
|
2220
2226
|
<label class="agent-tool-item">
|
|
2221
|
-
<input type="checkbox" value="${
|
|
2222
|
-
<span class="agent-tool-name" title="${
|
|
2223
|
-
<span class="agent-tool-desc" title="${
|
|
2224
|
-
</label>`}).join(``);let s=document.getElementById(`agentSkillCount`);s&&(s.textContent=i(`agentConfig.selectedTotalCount`,{selected:a,total:o}))}function $k(){let e=document.getElementById(`agentSkillList`);if(!e)return null;let t=e.querySelectorAll(`input[type="checkbox"]:checked`),n=[];return t.forEach(e=>n.push(e.value)),n.length>0?n:null}async function eA(){let e=document.getElementById(`agentModelList`);if(e)return new Promise(t=>{chrome.storage.local.get([`customModels`],n=>{let r=[];(n.customModels||[]).forEach(e=>{let t;typeof e==`string`?t=e:e&&e.name&&(t=e.name),t&&!r.includes(t)&&r.push(t)}),e.innerHTML=r.map(e=>`<option value="${uA(e)}">`).join(``),t()})})}function tA(e){let t=document.getElementById(`agentEditTempPreset`);if(t){for(;t.options.length>1;)t.remove(1);Oe.forEach((e,n)=>{let r=document.createElement(`option`);r.value=n,r.textContent=`${i(e.labelKey)}(${e.temp.toFixed(2)})`,t.appendChild(r)}),t.value=e!==void 0&&e>=0?e:``}}function nA(){let e=document.getElementById(`agentEditTempPreset`);if(!e||e.value===``)return{temperature:null,topP:null};let t=parseInt(e.value);if(isNaN(t)||t<0||t>=Oe.length)return{temperature:null,topP:null};let n=Oe[t];return{temperature:n.temp,topP:n.topP}}function rA(e,t){if(e==null)return-1;for(let n=0;n<Oe.length;n++){let r=Oe[n];if(Math.abs(r.temp-e)<.001&&Math.abs(r.topP-(t||1))<.001)return n}return-1}async function iA(){let e=document.getElementById(`agentEditModal`);if(!e)return;let t=e.querySelector(`#agentEditId`).value,n=e.querySelector(`#agentEditName`).value.trim(),r=e.querySelector(`#agentEditIcon`).value.trim()||`🤖`,a=e.querySelector(`#agentEditDesc`).value.trim(),s=e.querySelector(`#agentEditPrompt`).value.trim(),c=e.querySelector(`#agentEditAllowSub`).checked,l=Xk(),u=Zk(),d=$k(),f=e.querySelector(`#agentEditModel`).value.trim()||null,{temperature:p,topP:m}=nA();if(!n){U(i(`agentMgr.nameRequired`),`warning`);return}let h={name:n,icon:r,description:a,systemPrompt:s,allowSubDispatch:c,toolIds:l,skillIds:d,model:f,temperature:p,topP:m};u!==void 0&&(h.mcpExcludedServerIds=u);try{if(t)await xe(t,h),t===H.activeAgentId&&u!==void 0&&(H.activeAgentMcpExcludedServerIds=u),U(i(`agentMgr.agentUpdated`),`success`);else{let e=await Ce(h);U(i(`agentMgr.agentCreated`,{name:e.name}),`success`)}await Tk(),await Ek(),Gk(),yn()}catch(e){o.error(`[AgentMgr] save Agent failed:`,e),U(i(`agentMgr.saveFailed`,{message:e.message}),`error`)}}async function aA(){let e=document.getElementById(`agentEditModal`);if(!e)return;let t=e.querySelector(`#agentEditId`)?.value;if(!t)return;let n=await be(t),r=n?n.name:``;if(await dA(i(`agentMgr.confirmDeleteAgentMessage`,{name:r}),i(`agentMgr.deleteAgentTitle`)))try{await Te(t),U(i(`agentMgr.agentDeleted`),`success`),await Tk(),await Ek(),Gk()}catch(e){o.error(`[AgentMgr] delete Agent failed:`,e),U(i(`agentMgr.deleteFailed`,{message:e.message}),`error`)}}async function oA(e){if(!e)return!1;let t=await be(e);if(!t||t.isBuiltin)return U(i(`agentMgr.cannotDeleteDefault`),`warning`),!1;if(!await dA(i(`agentMgr.confirmDeleteAgentMessage`,{name:t.name}),i(`agentMgr.deleteAgentTitle`)))return!1;try{return await Te(e),U(i(`agentMgr.agentDeleted`),`success`),await Tk(),await Ek(),!0}catch(e){return o.error(`[AgentMgr] delete Agent failed:`,e),U(i(`agentMgr.deleteFailed`,{message:e.message}),`error`),!1}}async function sA(){return H.activeAgentId?await be(H.activeAgentId):null}function cA(e){return e?e.toolIds:null}function lA(e){if(!e)return``;let t=document.createElement(`div`);return t.textContent=e,t.innerHTML}function uA(e){return e?e.replace(/["&<>]/g,e=>({'"':`"`,"&":`&`,"<":`<`,">":`>`})[e]):``}async function dA(e,t){return typeof window.showCustomConfirm==`function`?window.showCustomConfirm(e,t):new Promise(n=>{let r=document.getElementById(`agentConfirmModal`);if(!r){n(confirm(e));return}r.querySelector(`#agentConfirmMessage`).textContent=e,r.querySelector(`#agentConfirmTitle`).textContent=t||i(`agentMgr.confirm`),r.style.display=`flex`;let a=()=>{r.style.display=`none`,r.querySelector(`#agentConfirmOk`).removeEventListener(`click`,o),r.querySelector(`#agentConfirmCancel`).removeEventListener(`click`,s),r.removeEventListener(`click`,c)},o=()=>{a(),n(!0)},s=()=>{a(),n(!1)},c=e=>{e.target===r&&(a(),n(!1))};r.querySelector(`#agentConfirmOk`).addEventListener(`click`,o),r.querySelector(`#agentConfirmCancel`).addEventListener(`click`,s),r.addEventListener(`click`,c)})}r(`zh`,{contextUsage:{indicatorTitle:`上下文占用 {percent}%({used} / {total} tokens)· 点击查看详情`,memoryOffToast:`记忆已关闭,无可压缩内容`,generatingToast:`正在生成回复,请稍后再试`,nothingToCompactToast:`没有新的消息可压缩`,confirmTitle:`压缩上下文`,confirmMessage:`将压缩 {count} 条历史消息(约 {tokens} tokens)为一份摘要{summaryHint}。原始消息仍保留在会话中,发送新消息前可撤销。`,confirmWithOldSummary:`(含已有摘要,将合并为新摘要)`,confirmOk:`开始压缩`,compactingTitle:`正在压缩上下文`,compactingHint:`正在调用模型生成摘要,请稍候…(通常需要几秒到十几秒)`,compactDone:`压缩完成,节约约 {saved} tokens`,compactErrConfig:`无法压缩:API 配置缺失`,compactErrFailed:`压缩失败,请稍后重试`,undoTitle:`撤销压缩`,undoMessage:`撤销后,发送将恢复携带完整历史。确定撤销吗?`,undoOk:`撤销`,undoDone:`已撤销压缩`,dividerText:`⬆ 上方 {count} 条消息已压缩为摘要`,dividerView:`查看`,dividerUndo:`撤销`,popupTitle:`上下文占用明细`,rowSystem:`系统提示词`,rowTools:`工具定义`,rowHistory:`历史消息`,rowInput:`当前输入`,historyMeta:`选中 {selected} 条 / 共 {total} 条`,historyTrimmed:`为控制预算裁剪了 {count} 条(以规则摘要替代)`,refInfo:`输出预留 {output} · 安全余量 {safety}(不计入上方占用)`,memoryLabel:`记忆设置`,memoryAll:`携带全部历史`,memoryLimited:`携带最近 {n} 条`,memoryOff:`不携带历史(仅当前消息)`,compactionActive:`已压缩 {count} 条历史 · 摘要约 {tokens} tokens`,compactionInvalidHint:`压缩点已失效(对应消息已被删除),本次发送未使用压缩`,removeInvalid:`移除失效的压缩记录`,btnCompact:`压缩上下文`,btnCompactAgain:`再次压缩`,btnUndoCompact:`撤销压缩`,undoExpiredToast:`已发送新消息,无法再撤销压缩(可再次压缩合并更新)`,summaryTitle:`上下文摘要(压缩 {count} 条历史)`,summaryTabPreview:`预览`,summaryTabSource:`源码`}}),r(`en`,{contextUsage:{indicatorTitle:`Context usage {percent}% ({used} / {total} tokens) · Click for details`,memoryOffToast:`Memory is off, nothing to compact`,generatingToast:`Generating a reply, please try again later`,nothingToCompactToast:`No new messages to compact`,confirmTitle:`Compact Context`,confirmMessage:`Compact {count} history messages (~{tokens} tokens) into a summary{summaryHint}. Original messages remain in the session; undo is available before sending new messages.`,confirmWithOldSummary:` (including the existing summary, which will be merged into a new one)`,confirmOk:`Start Compaction`,compactingTitle:`Compacting Context`,compactingHint:`Generating a summary with the model, please wait… (usually takes a few seconds)`,compactDone:`Compaction complete, saved ~{saved} tokens`,compactErrConfig:`Cannot compact: API configuration missing`,compactErrFailed:`Compaction failed, please try again later`,undoTitle:`Undo Compaction`,undoMessage:`After undo, sending will include the full history again. Undo?`,undoOk:`Undo`,undoDone:`Compaction undone`,dividerText:`⬆ {count} messages above compacted into a summary`,dividerView:`View`,dividerUndo:`Undo`,popupTitle:`Context Usage Details`,rowSystem:`System prompt`,rowTools:`Tool definitions`,rowHistory:`History messages`,rowInput:`Current input`,historyMeta:`Selected {selected} / {total} total`,historyTrimmed:`{count} messages trimmed for budget (replaced by rule summary)`,refInfo:`Output reserve {output} · Safety margin {safety} (not counted above)`,memoryLabel:`Memory setting`,memoryAll:`Carry all history`,memoryLimited:`Carry latest {n} messages`,memoryOff:`No history (current message only)`,compactionActive:`{count} messages compacted · summary ~{tokens} tokens`,compactionInvalidHint:`Compaction point is stale (its message was deleted); this send ignores the compaction`,removeInvalid:`Remove stale compaction record`,btnCompact:`Compact Context`,btnCompactAgain:`Compact Again`,btnUndoCompact:`Undo Compaction`,undoExpiredToast:`New messages have been sent; compaction can no longer be undone (you can compact again)`,summaryTitle:`Context Summary ({count} messages compacted)`,summaryTabPreview:`Preview`,summaryTabSource:`Source`}});var fA=300,pA=``,mA=0,hA=null;async function gA(){try{let{mcpTools:e}=await chrome.storage.local.get([`mcpTools`]),t=e||[],n=new Set(Array.isArray(H.mcpClosedServers)?H.mcpClosedServers:[]),r=new Set(Array.isArray(H.activeAgentMcpExcludedServerIds)?H.activeAgentMcpExcludedServerIds:[]);return t.filter(e=>{let t=e.serverId||`unknown`;return!n.has(t)&&!r.has(t)}).length}catch{return 0}}function _A(){let e=document.getElementById(`userInput`)?.value||``;return{usage:st({model:H.currentModel,customModelMap:H.customModelMap,systemPromptText:pA,toolCount:(H.useTools?H.enabledTools.length:0)+mA,history:H.messageHistory,inputText:e,maxMemoryMessages:H.chatConfig?.maxMemoryMessages??null,compaction:H.activeCompaction,isolateChat:H.isolateChat}),inputText:e}}function vA(e){let t=document.getElementById(`contextUsageIndicator`);if(!t)return;t._lastUsage=e,t.dataset.level=e.level;let n=Math.round(e.ratio*100),r=t.querySelector(`.context-usage-percent`);r&&(r.textContent=`${n}%`),t.style.setProperty(`--usage-ratio`,String(Math.min(Math.max(e.ratio,0),1))),t.title=i(`contextUsage.indicatorTitle`,{percent:n,used:Le(e.usedTokens),total:Le(e.contextWindow)})}function yA(){try{let{usage:e}=_A();return vA(e),kA(),e}catch(e){return o.warn(`[ContextIndicator] update failed:`,e?.message),null}}function bA(){clearTimeout(hA),hA=setTimeout(()=>yA(),fA)}async function xA(){try{pA=await Ke(await sA())}catch(e){o.warn(`[ContextIndicator] refresh system prompt failed:`,e?.message)}try{mA=await gA()}catch{mA=0}yA()}function SA(){let e=document.getElementById(`contextUsageIndicator`);e&&(e.addEventListener(`click`,()=>NA()),document.getElementById(`userInput`)?.addEventListener(`input`,bA),document.addEventListener(`generating-state-changed`,()=>{xA()}),document.addEventListener(`agent-model-changed`,()=>{xA()}),document.addEventListener(`session-switched`,()=>{bA()}),chrome.storage.onChanged.addListener((e,t)=>{t===`local`&&((e.chatMaxMemoryMessages||e.isolateChat)&&bA(),(e.isolateChat||e.mcpTools||e.mcpEnabled||e.enabledTools||e.enableTools)&&xA())}),xA())}function CA({title:e,message:t,okText:n}){return new Promise(r=>{let a=document.createElement(`div`);a.className=`modal-overlay show`,a.style.zIndex=`10200`,a.innerHTML=`
|
|
2227
|
+
<input type="checkbox" value="${dA(e.name)}" ${t}>
|
|
2228
|
+
<span class="agent-tool-name" title="${dA(e.name)}">${uA(e.name)}</span>
|
|
2229
|
+
<span class="agent-tool-desc" title="${dA(e.description||``)}">${uA((e.description||``).substring(0,40))}${(e.description||``).length>40?`...`:``}</span>
|
|
2230
|
+
</label>`}).join(``);let s=document.getElementById(`agentSkillCount`);s&&(s.textContent=i(`agentConfig.selectedTotalCount`,{selected:a,total:o}))}function eA(){let e=document.getElementById(`agentSkillList`);if(!e)return null;let t=e.querySelectorAll(`input[type="checkbox"]:checked`),n=[];return t.forEach(e=>n.push(e.value)),n.length>0?n:null}async function tA(){let e=document.getElementById(`agentModelList`);if(e)return new Promise(t=>{chrome.storage.local.get([`customModels`],n=>{let r=[];(n.customModels||[]).forEach(e=>{let t;typeof e==`string`?t=e:e&&e.name&&(t=e.name),t&&!r.includes(t)&&r.push(t)}),e.innerHTML=r.map(e=>`<option value="${dA(e)}">`).join(``),t()})})}function nA(e){let t=document.getElementById(`agentEditTempPreset`);if(t){for(;t.options.length>1;)t.remove(1);Oe.forEach((e,n)=>{let r=document.createElement(`option`);r.value=n,r.textContent=`${i(e.labelKey)}(${e.temp.toFixed(2)})`,t.appendChild(r)}),t.value=e!==void 0&&e>=0?e:``}}function rA(){let e=document.getElementById(`agentEditTempPreset`);if(!e||e.value===``)return{temperature:null,topP:null};let t=parseInt(e.value);if(isNaN(t)||t<0||t>=Oe.length)return{temperature:null,topP:null};let n=Oe[t];return{temperature:n.temp,topP:n.topP}}function iA(e,t){if(e==null)return-1;for(let n=0;n<Oe.length;n++){let r=Oe[n];if(Math.abs(r.temp-e)<.001&&Math.abs(r.topP-(t||1))<.001)return n}return-1}async function aA(){let e=document.getElementById(`agentEditModal`);if(!e)return;let t=e.querySelector(`#agentEditId`).value,n=e.querySelector(`#agentEditName`).value.trim(),r=e.querySelector(`#agentEditIcon`).value.trim()||`🤖`,a=e.querySelector(`#agentEditDesc`).value.trim(),s=e.querySelector(`#agentEditPrompt`).value.trim(),c=e.querySelector(`#agentEditAllowSub`).checked,l=Zk(),u=Qk(),d=eA(),f=e.querySelector(`#agentEditModel`).value.trim()||null,{temperature:p,topP:m}=rA();if(!n){U(i(`agentMgr.nameRequired`),`warning`);return}let h={name:n,icon:r,description:a,systemPrompt:s,allowSubDispatch:c,toolIds:l,skillIds:d,model:f,temperature:p,topP:m};u!==void 0&&(h.mcpExcludedServerIds=u);try{if(t)await xe(t,h),t===H.activeAgentId&&u!==void 0&&(H.activeAgentMcpExcludedServerIds=u),U(i(`agentMgr.agentUpdated`),`success`);else{let e=await Ce(h);U(i(`agentMgr.agentCreated`,{name:e.name}),`success`)}await Ek(),await Dk(),Kk(),yn()}catch(e){o.error(`[AgentMgr] save Agent failed:`,e),U(i(`agentMgr.saveFailed`,{message:e.message}),`error`)}}async function oA(){let e=document.getElementById(`agentEditModal`);if(!e)return;let t=e.querySelector(`#agentEditId`)?.value;if(!t)return;let n=await be(t),r=n?n.name:``;if(await fA(i(`agentMgr.confirmDeleteAgentMessage`,{name:r}),i(`agentMgr.deleteAgentTitle`)))try{await Te(t),U(i(`agentMgr.agentDeleted`),`success`),await Ek(),await Dk(),Kk()}catch(e){o.error(`[AgentMgr] delete Agent failed:`,e),U(i(`agentMgr.deleteFailed`,{message:e.message}),`error`)}}async function sA(e){if(!e)return!1;let t=await be(e);if(!t||t.isBuiltin)return U(i(`agentMgr.cannotDeleteDefault`),`warning`),!1;if(!await fA(i(`agentMgr.confirmDeleteAgentMessage`,{name:t.name}),i(`agentMgr.deleteAgentTitle`)))return!1;try{return await Te(e),U(i(`agentMgr.agentDeleted`),`success`),await Ek(),await Dk(),!0}catch(e){return o.error(`[AgentMgr] delete Agent failed:`,e),U(i(`agentMgr.deleteFailed`,{message:e.message}),`error`),!1}}async function cA(){return H.activeAgentId?await be(H.activeAgentId):null}function lA(e){return e?e.toolIds:null}function uA(e){if(!e)return``;let t=document.createElement(`div`);return t.textContent=e,t.innerHTML}function dA(e){return e?e.replace(/["&<>]/g,e=>({'"':`"`,"&":`&`,"<":`<`,">":`>`})[e]):``}async function fA(e,t){return typeof window.showCustomConfirm==`function`?window.showCustomConfirm(e,t):new Promise(n=>{let r=document.getElementById(`agentConfirmModal`);if(!r){n(confirm(e));return}r.querySelector(`#agentConfirmMessage`).textContent=e,r.querySelector(`#agentConfirmTitle`).textContent=t||i(`agentMgr.confirm`),r.style.display=`flex`;let a=()=>{r.style.display=`none`,r.querySelector(`#agentConfirmOk`).removeEventListener(`click`,o),r.querySelector(`#agentConfirmCancel`).removeEventListener(`click`,s),r.removeEventListener(`click`,c)},o=()=>{a(),n(!0)},s=()=>{a(),n(!1)},c=e=>{e.target===r&&(a(),n(!1))};r.querySelector(`#agentConfirmOk`).addEventListener(`click`,o),r.querySelector(`#agentConfirmCancel`).addEventListener(`click`,s),r.addEventListener(`click`,c)})}r(`zh`,{contextUsage:{indicatorTitle:`上下文占用 {percent}%({used} / {total} tokens)· 点击查看详情`,memoryOffToast:`记忆已关闭,无可压缩内容`,generatingToast:`正在生成回复,请稍后再试`,nothingToCompactToast:`没有新的消息可压缩`,confirmTitle:`压缩上下文`,confirmMessage:`将压缩 {count} 条历史消息(约 {tokens} tokens)为一份摘要{summaryHint}。原始消息仍保留在会话中,发送新消息前可撤销。`,confirmWithOldSummary:`(含已有摘要,将合并为新摘要)`,confirmOk:`开始压缩`,compactingTitle:`正在压缩上下文`,compactingHint:`正在调用模型生成摘要,请稍候…(通常需要几秒到十几秒)`,compactDone:`压缩完成,节约约 {saved} tokens`,compactErrConfig:`无法压缩:API 配置缺失`,compactErrFailed:`压缩失败,请稍后重试`,undoTitle:`撤销压缩`,undoMessage:`撤销后,发送将恢复携带完整历史。确定撤销吗?`,undoOk:`撤销`,undoDone:`已撤销压缩`,dividerText:`⬆ 上方 {count} 条消息已压缩为摘要`,dividerView:`查看`,dividerUndo:`撤销`,popupTitle:`上下文占用明细`,rowSystem:`系统提示词`,rowTools:`工具定义`,rowHistory:`历史消息`,rowInput:`当前输入`,historyMeta:`选中 {selected} 条 / 共 {total} 条`,historyTrimmed:`为控制预算裁剪了 {count} 条(以规则摘要替代)`,refInfo:`输出预留 {output} · 安全余量 {safety}(不计入上方占用)`,memoryLabel:`记忆设置`,memoryAll:`携带全部历史`,memoryLimited:`携带最近 {n} 条`,memoryOff:`不携带历史(仅当前消息)`,compactionActive:`已压缩 {count} 条历史 · 摘要约 {tokens} tokens`,compactionInvalidHint:`压缩点已失效(对应消息已被删除),本次发送未使用压缩`,removeInvalid:`移除失效的压缩记录`,btnCompact:`压缩上下文`,btnCompactAgain:`再次压缩`,btnUndoCompact:`撤销压缩`,undoExpiredToast:`已发送新消息,无法再撤销压缩(可再次压缩合并更新)`,summaryTitle:`上下文摘要(压缩 {count} 条历史)`,summaryTabPreview:`预览`,summaryTabSource:`源码`}}),r(`en`,{contextUsage:{indicatorTitle:`Context usage {percent}% ({used} / {total} tokens) · Click for details`,memoryOffToast:`Memory is off, nothing to compact`,generatingToast:`Generating a reply, please try again later`,nothingToCompactToast:`No new messages to compact`,confirmTitle:`Compact Context`,confirmMessage:`Compact {count} history messages (~{tokens} tokens) into a summary{summaryHint}. Original messages remain in the session; undo is available before sending new messages.`,confirmWithOldSummary:` (including the existing summary, which will be merged into a new one)`,confirmOk:`Start Compaction`,compactingTitle:`Compacting Context`,compactingHint:`Generating a summary with the model, please wait… (usually takes a few seconds)`,compactDone:`Compaction complete, saved ~{saved} tokens`,compactErrConfig:`Cannot compact: API configuration missing`,compactErrFailed:`Compaction failed, please try again later`,undoTitle:`Undo Compaction`,undoMessage:`After undo, sending will include the full history again. Undo?`,undoOk:`Undo`,undoDone:`Compaction undone`,dividerText:`⬆ {count} messages above compacted into a summary`,dividerView:`View`,dividerUndo:`Undo`,popupTitle:`Context Usage Details`,rowSystem:`System prompt`,rowTools:`Tool definitions`,rowHistory:`History messages`,rowInput:`Current input`,historyMeta:`Selected {selected} / {total} total`,historyTrimmed:`{count} messages trimmed for budget (replaced by rule summary)`,refInfo:`Output reserve {output} · Safety margin {safety} (not counted above)`,memoryLabel:`Memory setting`,memoryAll:`Carry all history`,memoryLimited:`Carry latest {n} messages`,memoryOff:`No history (current message only)`,compactionActive:`{count} messages compacted · summary ~{tokens} tokens`,compactionInvalidHint:`Compaction point is stale (its message was deleted); this send ignores the compaction`,removeInvalid:`Remove stale compaction record`,btnCompact:`Compact Context`,btnCompactAgain:`Compact Again`,btnUndoCompact:`Undo Compaction`,undoExpiredToast:`New messages have been sent; compaction can no longer be undone (you can compact again)`,summaryTitle:`Context Summary ({count} messages compacted)`,summaryTabPreview:`Preview`,summaryTabSource:`Source`}});var pA=300,mA=``,hA=0,gA=null;async function _A(){try{let{mcpTools:e}=await chrome.storage.local.get([`mcpTools`]),t=e||[],n=new Set(Array.isArray(H.mcpClosedServers)?H.mcpClosedServers:[]),r=new Set(Array.isArray(H.activeAgentMcpExcludedServerIds)?H.activeAgentMcpExcludedServerIds:[]);return t.filter(e=>{let t=e.serverId||`unknown`;return!n.has(t)&&!r.has(t)}).length}catch{return 0}}function vA(){let e=document.getElementById(`userInput`)?.value||``;return{usage:st({model:H.currentModel,customModelMap:H.customModelMap,systemPromptText:mA,toolCount:(H.useTools?H.enabledTools.length:0)+hA,history:H.messageHistory,inputText:e,maxMemoryMessages:H.chatConfig?.maxMemoryMessages??null,compaction:H.activeCompaction,isolateChat:H.isolateChat}),inputText:e}}function yA(e){let t=document.getElementById(`contextUsageIndicator`);if(!t)return;t._lastUsage=e,t.dataset.level=e.level;let n=Math.round(e.ratio*100),r=t.querySelector(`.context-usage-percent`);r&&(r.textContent=`${n}%`),t.style.setProperty(`--usage-ratio`,String(Math.min(Math.max(e.ratio,0),1))),t.title=i(`contextUsage.indicatorTitle`,{percent:n,used:Le(e.usedTokens),total:Le(e.contextWindow)})}function bA(){try{let{usage:e}=vA();return yA(e),AA(),e}catch(e){return o.warn(`[ContextIndicator] update failed:`,e?.message),null}}function xA(){clearTimeout(gA),gA=setTimeout(()=>bA(),pA)}async function SA(){try{mA=await Ke(await cA())}catch(e){o.warn(`[ContextIndicator] refresh system prompt failed:`,e?.message)}try{hA=await _A()}catch{hA=0}bA()}function CA(){let e=document.getElementById(`contextUsageIndicator`);e&&(e.addEventListener(`click`,()=>PA()),document.getElementById(`userInput`)?.addEventListener(`input`,xA),document.addEventListener(`generating-state-changed`,()=>{SA()}),document.addEventListener(`agent-model-changed`,()=>{SA()}),document.addEventListener(`session-switched`,()=>{xA()}),chrome.storage.onChanged.addListener((e,t)=>{t===`local`&&((e.chatMaxMemoryMessages||e.isolateChat)&&xA(),(e.isolateChat||e.mcpTools||e.mcpEnabled||e.enabledTools||e.enableTools)&&SA())}),SA())}function wA({title:e,message:t,okText:n}){return new Promise(r=>{let a=document.createElement(`div`);a.className=`modal-overlay show`,a.style.zIndex=`10200`,a.innerHTML=`
|
|
2225
2231
|
<div class="modal-container">
|
|
2226
2232
|
<div class="modal-title"></div>
|
|
2227
2233
|
<div class="modal-message"></div>
|
|
@@ -2229,20 +2235,20 @@ Sessions using this assistant will revert to the default assistant.`,deleteAgent
|
|
|
2229
2235
|
<button class="modal-btn cancel">${i(`common.cancel`)}</button>
|
|
2230
2236
|
</div>
|
|
2231
2237
|
</div>
|
|
2232
|
-
`,a.querySelector(`.modal-title`).textContent=e,a.querySelector(`.modal-message`).textContent=t;let o=a.querySelector(`.modal-actions`),s=document.createElement(`button`);s.className=`modal-btn confirm`,s.textContent=n,o.appendChild(s),document.body.appendChild(a);let c=e=>{a.remove(),r(e)};a.querySelector(`.modal-btn.cancel`).addEventListener(`click`,()=>c(!1)),s.addEventListener(`click`,()=>c(!0)),a.addEventListener(`click`,e=>{e.target===a&&c(!1)})})}function
|
|
2238
|
+
`,a.querySelector(`.modal-title`).textContent=e,a.querySelector(`.modal-message`).textContent=t;let o=a.querySelector(`.modal-actions`),s=document.createElement(`button`);s.className=`modal-btn confirm`,s.textContent=n,o.appendChild(s),document.body.appendChild(a);let c=e=>{a.remove(),r(e)};a.querySelector(`.modal-btn.cancel`).addEventListener(`click`,()=>c(!1)),s.addEventListener(`click`,()=>c(!0)),a.addEventListener(`click`,e=>{e.target===a&&c(!1)})})}function TA(){let e=document.createElement(`div`);return e.className=`modal-overlay show context-usage-compacting-overlay`,e.style.zIndex=`10200`,e.innerHTML=`
|
|
2233
2239
|
<div class="modal-container context-usage-compacting-modal">
|
|
2234
2240
|
<div class="context-usage-compacting-spinner"></div>
|
|
2235
2241
|
<div class="modal-title"></div>
|
|
2236
2242
|
<div class="modal-message"></div>
|
|
2237
2243
|
</div>
|
|
2238
|
-
`,e.querySelector(`.modal-title`).textContent=i(`contextUsage.compactingTitle`),e.querySelector(`.modal-message`).textContent=i(`contextUsage.compactingHint`),document.body.appendChild(e),{close:()=>e.remove()}}async function
|
|
2244
|
+
`,e.querySelector(`.modal-title`).textContent=i(`contextUsage.compactingTitle`),e.querySelector(`.modal-message`).textContent=i(`contextUsage.compactingHint`),document.body.appendChild(e),{close:()=>e.remove()}}async function EA(){if(!H.isolateChat){U(i(`contextUsage.memoryOffToast`),`warning`);return}if(H.isGenerating){U(i(`contextUsage.generatingToast`),`warning`);return}let e=H.messageHistory;if(!e.length){U(i(`contextUsage.nothingToCompactToast`),`warning`);return}let t=H.activeCompaction,{material:n,includedCount:r,hasOldSummary:a}=ct(e,{maxMemoryMessages:H.chatConfig?.maxMemoryMessages??null,compaction:t});if(r===0){U(i(`contextUsage.nothingToCompactToast`),`warning`);return}let s=u(n.map(e=>({role:e.role,content:e.content})));if(!await wA({title:i(`contextUsage.confirmTitle`),message:i(`contextUsage.confirmMessage`,{count:r,tokens:Le(s),summaryHint:a?i(`contextUsage.confirmWithOldSummary`):``}),okText:i(`contextUsage.confirmOk`)}))return;let c=TA();try{let a=await chrome.runtime.sendMessage({type:`COMPACT_CONTEXT_SUMMARY`,material:n,model:H.currentModel,sessionId:H.activeSessionId});if(!a?.success||!a.summary){let e=a?.error===`config_missing`?`contextUsage.compactErrConfig`:`contextUsage.compactErrFailed`;U(i(e),`error`);return}let o=e[e.length-1],c=k(a.summary);H.activeCompaction={summary:a.summary,upToMessageId:o?.messageId,compressedCount:(t?.compressedCount||0)+r,summaryTokens:c,savedTokens:Math.max(s-c,0),model:H.currentModel,createdAt:Date.now(),revision:(t?.revision||0)+1},await At(),jA(),bA(),U(i(`contextUsage.compactDone`,{saved:Le(H.activeCompaction.savedTokens)}),`success`)}catch(e){o.warn(`[ContextIndicator] compaction failed:`,e?.message),U(i(`contextUsage.compactErrFailed`),`error`)}finally{c.close()}}function DA(){let e=H.activeCompaction;if(!e?.upToMessageId)return!1;let t=H.messageHistory||[],n=t.findIndex(t=>t.messageId===e.upToMessageId);return n>=0&&n<t.length-1}async function OA(e=!1){if(H.activeCompaction){if(DA()){U(i(`contextUsage.undoExpiredToast`),`warning`);return}!e&&!await wA({title:i(`contextUsage.undoTitle`),message:i(`contextUsage.undoMessage`),okText:i(`contextUsage.undoOk`)})||(H.activeCompaction=null,await At(),kA(),bA(),U(i(`contextUsage.undoDone`),`success`))}}function kA(){document.querySelectorAll(`.compaction-divider`).forEach(e=>e.remove())}function AA(){let e=DA();document.querySelectorAll(`.compaction-divider [data-action="undo"]`).forEach(t=>{t.style.display=e?`none`:``})}function jA(){kA();let e=H.activeCompaction;if(!e?.upToMessageId)return;let t=document.getElementById(`chatContainer`);if(!t)return;let n=t.querySelector(`[data-message-id="${CSS.escape(e.upToMessageId)}"]`);if(!n)return;let r=document.createElement(`div`);r.className=`compaction-divider`;let a=!DA();r.innerHTML=`
|
|
2239
2245
|
<span class="compaction-divider-text">${i(`contextUsage.dividerText`,{count:e.compressedCount})}</span>
|
|
2240
2246
|
<button class="compaction-divider-btn" data-action="view">${i(`contextUsage.dividerView`)}</button>
|
|
2241
2247
|
${a?`<button class="compaction-divider-btn" data-action="undo">${i(`contextUsage.dividerUndo`)}</button>`:``}
|
|
2242
|
-
`,r.querySelector(`[data-action="view"]`).addEventListener(`click`,()=>
|
|
2248
|
+
`,r.querySelector(`[data-action="view"]`).addEventListener(`click`,()=>FA(e)),r.querySelector(`[data-action="undo"]`)?.addEventListener(`click`,()=>OA()),n.after(r)}var MA=null;function NA(){document.querySelectorAll(`.context-usage-popup`).forEach(e=>e.remove());let e=document.getElementById(`contextUsageIndicator`);e&&(e._ctxPopupOpen=!1),MA&&=(document.removeEventListener(`click`,MA),null)}function PA(){let e=document.getElementById(`contextUsageIndicator`);if(!e)return;if(e._ctxPopupOpen){NA();return}NA(),e._ctxPopupOpen=!0;let{usage:t}=vA(),n=t.breakdown,r=Math.round(t.ratio*100),a;a=H.isolateChat?H.chatConfig?.maxMemoryMessages>0?i(`contextUsage.memoryLimited`,{n:H.chatConfig.maxMemoryMessages}):i(`contextUsage.memoryAll`):i(`contextUsage.memoryOff`);let o=H.activeCompaction,s;s=o&&n.compactionApplied?`
|
|
2243
2249
|
<div class="context-usage-compaction">
|
|
2244
2250
|
<div class="context-usage-dim">${i(`contextUsage.compactionActive`,{count:o.compressedCount,tokens:Le(o.summaryTokens)})}</div>
|
|
2245
|
-
${
|
|
2251
|
+
${DA()?`<button class="context-usage-btn primary" data-action="compact">${i(`contextUsage.btnCompactAgain`)}</button>`:`<button class="context-usage-btn danger-ghost" data-action="undo">${i(`contextUsage.btnUndoCompact`)}</button>`}
|
|
2246
2252
|
</div>`:n.compactionInvalid?`
|
|
2247
2253
|
<div class="context-usage-compaction">
|
|
2248
2254
|
<div class="context-usage-warn">${i(`contextUsage.compactionInvalidHint`)}</div>
|
|
@@ -2275,7 +2281,7 @@ Sessions using this assistant will revert to the default assistant.`,deleteAgent
|
|
|
2275
2281
|
</div>
|
|
2276
2282
|
${s}
|
|
2277
2283
|
</div>
|
|
2278
|
-
`,document.body.appendChild(u);let d=e.getBoundingClientRect();u.style.left=`${Math.max(d.left,8)}px`,u.style.bottom=`${window.innerHeight-d.top+6}px`,u.querySelector(`.context-usage-popup-close`).addEventListener(`click`,()=>
|
|
2284
|
+
`,document.body.appendChild(u);let d=e.getBoundingClientRect();u.style.left=`${Math.max(d.left,8)}px`,u.style.bottom=`${window.innerHeight-d.top+6}px`,u.querySelector(`.context-usage-popup-close`).addEventListener(`click`,()=>NA()),u.querySelector(`[data-action="compact"]`)?.addEventListener(`click`,()=>{NA(),EA()}),u.querySelector(`[data-action="undo"]`)?.addEventListener(`click`,()=>{NA(),OA(!0)}),u.querySelector(`[data-action="remove-invalid"]`)?.addEventListener(`click`,async()=>{NA(),H.activeCompaction=null,await At(),kA(),bA()}),MA=e=>{e.target.closest(`.context-usage-popup, #contextUsageIndicator`)||NA()},setTimeout(()=>document.addEventListener(`click`,MA),0)}function FA(e=H.activeCompaction){if(!e?.summary)return;let t=document.createElement(`div`);t.className=`modal-overlay show`,t.style.zIndex=`10200`,t.innerHTML=`
|
|
2279
2285
|
<div class="modal-container context-usage-summary-modal">
|
|
2280
2286
|
<button type="button" class="context-usage-summary-close" title="${i(`common.close`)}">×</button>
|
|
2281
2287
|
<div class="modal-title">${i(`contextUsage.summaryTitle`,{count:e.compressedCount})}
|
|
@@ -2286,7 +2292,7 @@ Sessions using this assistant will revert to the default assistant.`,deleteAgent
|
|
|
2286
2292
|
</div>
|
|
2287
2293
|
<div class="context-usage-summary-body"></div>
|
|
2288
2294
|
</div>
|
|
2289
|
-
`,document.body.appendChild(t);let n=t.querySelector(`.context-usage-summary-body`),r=t.querySelectorAll(`.context-usage-summary-tab`),a=t=>{r.forEach(e=>e.classList.toggle(`active`,e.dataset.mode===t)),t===`preview`?(n.classList.add(`markdown-body`),n.innerHTML=Ei(e.summary),Ki()):(n.classList.remove(`markdown-body`),n.textContent=e.summary)};r.forEach(e=>e.addEventListener(`click`,()=>a(e.dataset.mode))),a(`preview`),t.querySelector(`.context-usage-summary-close`).addEventListener(`click`,()=>t.remove()),t.addEventListener(`click`,e=>{e.target===t&&t.remove()})}r(`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:`消息已被删除`}}),r(`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
|
|
2295
|
+
`,document.body.appendChild(t);let n=t.querySelector(`.context-usage-summary-body`),r=t.querySelectorAll(`.context-usage-summary-tab`),a=t=>{r.forEach(e=>e.classList.toggle(`active`,e.dataset.mode===t)),t===`preview`?(n.classList.add(`markdown-body`),n.innerHTML=Ei(e.summary),Ki()):(n.classList.remove(`markdown-body`),n.textContent=e.summary)};r.forEach(e=>e.addEventListener(`click`,()=>a(e.dataset.mode))),a(`preview`),t.querySelector(`.context-usage-summary-close`).addEventListener(`click`,()=>t.remove()),t.addEventListener(`click`,e=>{e.target===t&&t.remove()})}r(`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:`消息已被删除`}}),r(`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 IA=!1,LA=!1,RA=[],zA=``;function BA(){H.searchInputHistory=[],H.searchInputHistoryIndex=-1;try{chrome.storage.local.get([`searchInputHistory`],e=>{e.searchInputHistory&&(H.searchInputHistory=e.searchInputHistory)})}catch{}let e=document.createElement(`div`);e.className=`search-panel-container`,e.id=`searchPanelContainer`,e.innerHTML=`
|
|
2290
2296
|
<button class="search-panel-toggle" id="searchPanelToggle" title="${i(`searchPanel.toggleTitle`)}">
|
|
2291
2297
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2292
2298
|
<circle cx="11" cy="11" r="8"/>
|
|
@@ -2321,13 +2327,13 @@ Sessions using this assistant will revert to the default assistant.`,deleteAgent
|
|
|
2321
2327
|
<div class="search-panel-empty">${i(`searchPanel.startSearchHint`)}</div>
|
|
2322
2328
|
</div>
|
|
2323
2329
|
</div>
|
|
2324
|
-
`,gt(`search`).appendChild(e),
|
|
2330
|
+
`,gt(`search`).appendChild(e),VA(),o.debug(`[SearchPanel] search panelinitializing`)}function VA(){document.getElementById(`searchPanelContainer`);let e=document.getElementById(`searchPanel`),t=document.getElementById(`searchPanelToggle`),n=document.getElementById(`searchPanelInput`),r=document.getElementById(`searchPanelClear`),i=document.getElementById(`searchPanelClose`),a=document.getElementById(`searchModeGlobal`),o=document.getElementById(`searchModeCurrent`);t.addEventListener(`click`,()=>{e.classList.contains(`expanded`)?UA():HA()}),i.addEventListener(`click`,()=>{UA()}),r.addEventListener(`click`,()=>{n.value=``,r.style.display=`none`,WA(),n.focus()}),n.addEventListener(`input`,()=>{let e=n.value.trim();r.style.display=e?``:`none`,e||WA()}),n.addEventListener(`keydown`,e=>{if(e.key===`Enter`){e.stopPropagation();let t=n.value.trim();t&&(s(t),GA(t))}else if(e.key===`Escape`)H.searchInputHistoryIndex>=0?(H.searchInputHistoryIndex=-1,n.value=``):(e.stopPropagation(),UA());else if(e.key===`ArrowUp`){e.preventDefault(),e.stopPropagation();let t=H.searchInputHistory;if(t.length===0)return;H.searchInputHistoryIndex===-1?H.searchInputHistoryIndex=t.length-1:H.searchInputHistoryIndex>0&&H.searchInputHistoryIndex--,n.value=t[H.searchInputHistoryIndex]||``,r.style.display=n.value?``:`none`,n.selectionStart=n.selectionEnd=n.value.length}else if(e.key===`ArrowDown`){e.preventDefault(),e.stopPropagation();let t=H.searchInputHistory;H.searchInputHistoryIndex>=0&&H.searchInputHistoryIndex<t.length-1?(H.searchInputHistoryIndex++,n.value=t[H.searchInputHistoryIndex]||``,n.selectionStart=n.selectionEnd=n.value.length):(H.searchInputHistoryIndex=-1,n.value=``),r.style.display=n.value?``:`none`}});function s(e){if(!e||!e.trim())return;let t=e.trim(),n=H.searchInputHistory,r=n.indexOf(t);r!==-1&&n.splice(r,1),n.push(t),n.length>20&&n.shift(),H.searchInputHistoryIndex=-1;try{chrome.storage.local.set({searchInputHistory:n})}catch{}}a.addEventListener(`click`,()=>{a.classList.contains(`active`)||(a.classList.add(`active`),o.classList.remove(`active`));let e=n.value.trim();e&&GA(e)}),o.addEventListener(`click`,()=>{o.classList.contains(`active`)||(o.classList.add(`active`),a.classList.remove(`active`));let e=n.value.trim();e&&GA(e)}),document.getElementById(`searchPanelContent`).addEventListener(`click`,async e=>{let t=e.target.closest(`.search-result-item`);if(!t)return;let n=t.dataset.sessionId,r=t.dataset.messageId;await $A(n,r)})}function HA(){let e=document.getElementById(`searchPanel`),t=document.getElementById(`searchPanelInput`);e.classList.add(`expanded`),et(e),t.value.trim()&&RA.length===0&&GA(t.value.trim()),setTimeout(()=>t.focus(),100)}function UA(){let e=document.getElementById(`searchPanel`);e.classList.remove(`expanded`),tt(e),LA=!0,IA=!1}function WA(){LA=!0,IA=!1,RA=[],zA=``;let e=document.getElementById(`searchPanelContent`),t=document.getElementById(`searchPanelCount`);e&&(e.innerHTML=`<div class="search-panel-empty">${i(`searchPanel.startSearchHint`)}</div>`),t&&(t.textContent=``)}async function GA(e){if(!e||!e.trim()||(e=e.trim().toLowerCase(),IA&&zA===e))return;LA=!0,await new Promise(e=>setTimeout(e,50)),IA=!0,LA=!1,RA=[],zA=e;let t=document.getElementById(`searchPanelContent`),n=document.getElementById(`searchPanelCount`);t.innerHTML=`<div class="search-panel-loading">${i(`searchPanel.searching`)}</div>`,n.textContent=``;let r=document.getElementById(`searchModeGlobal`).classList.contains(`active`);try{r?await qA(e,t,n):await KA(e,t,n)}catch(e){o.error(`[SearchPanel] search error:`,e),LA||(t.innerHTML=`<div class="search-panel-empty">${i(`searchPanel.searchError`)}</div>`)}LA||(IA=!1)}async function KA(e,t,n){let r=H.activeSessionId;if(!r){t.innerHTML=`<div class="search-panel-empty">${i(`searchPanel.noActiveSession`)}</div>`;return}let a=JA(H.messageHistory||[],e,r);if(!LA){if(RA=a,n.textContent=a.length>0?i(`searchPanel.countResult`,{count:a.length}):i(`searchPanel.noResult`),a.length===0){t.innerHTML=`<div class="search-panel-empty">${i(`searchPanel.noMatch`)}</div>`;return}XA(a,e,t)}}async function qA(e,t,n){let r=H.activeSessionId,a=await P();if(LA)return;if(!a||a.length===0){t.innerHTML=`<div class="search-panel-empty">${i(`searchPanel.noSessionData`)}</div>`;return}let s=[],c=[];if(r){let o=JA(H.messageHistory||[],e,r);if(LA)return;let c=a.find(e=>e.id===r)?.title||i(`searchPanel.currentSession`);for(let e of o)s.push({...e,sessionTitle:c});RA=[...s],n.textContent=i(`searchPanel.searchingWithCount`,{count:s.length}),XA(RA,e,t,!0)}let l=a.filter(e=>e.id!==r);for(let r of l){if(LA)return;try{let a=await z(r.id);if(!a||!a.messageHistory)continue;let o=JA(a.messageHistory||[],e,r.id);if(o.length>0){for(let e of o)c.push({...e,sessionTitle:r.title||i(`searchPanel.unknownSession`)});RA=[...s,...c];let a=s.length+c.length;n.textContent=a>0?i(`searchPanel.countResult`,{count:a}):i(`searchPanel.noResult`),XA(RA,e,t)}}catch(e){o.warn(`[SearchPanel] searchsession failed:`,r.id,e)}await new Promise(e=>setTimeout(e,10))}if(LA)return;let u=RA.length;if(n.textContent=u>0?i(`searchPanel.countResult`,{count:u}):i(`searchPanel.noResult`),u===0){t.innerHTML=`<div class="search-panel-empty">${i(`searchPanel.noMatch`)}</div>`;return}XA(RA,e,t)}function JA(e,t,n){let r=[];if(!e||e.length===0)return r;let i=t.includes(`&`)||t.includes(`|`);for(let a of e){if(a.role!==`assistant`&&a.role!==`user`)continue;let e=a.messageId||a.id;if(!e)continue;let o=YA(a.content);if(!o)continue;let s=o.toLowerCase(),c=-1,l=t;if(i){let e=t.split(`|`).map(e=>e.trim()).filter(Boolean),n=!1;for(let t of e){let e=t.split(`&`).map(e=>e.trim()).filter(Boolean);if(e.length!==0&&e.every(e=>s.includes(e))){n=!0,l=e[0],c=s.indexOf(l);break}}if(!n)continue}else{if(!s.includes(t))continue;c=s.indexOf(t)}let u=l.length,d=Math.max(0,c-30),f=Math.min(o.length,c+u+30),p=o.substring(d,f);d>0&&(p=`...`+p),f<o.length&&(p+=`...`),r.push({messageId:e,content:o.substring(0,200),role:a.role,sessionId:n,matchPreview:p,query:t})}return r}function YA(e){return e?typeof e==`string`?e.replace(/<[^>]*>/g,``):Array.isArray(e)?e.filter(e=>e.type===`text`).map(e=>e.text||``).join(` `):String(e):``}function XA(e,t,n,r){if(n||=document.getElementById(`searchPanelContent`),!n)return;if(e.length===0){n.innerHTML=`<div class="search-panel-empty">${i(`searchPanel.noMatch`)}</div>`;return}let a=H.activeSessionId,o=e.filter(e=>e.sessionId===a),s=e.filter(e=>e.sessionId!==a),c=``,l=r?i(`searchPanel.searchingSuffix`):``;o.length>0&&(c+=`<div class="search-section">
|
|
2325
2331
|
<div class="search-section-title">${i(`searchPanel.currentSessionResults`,{label:l,count:o.length})}</div>
|
|
2326
|
-
${
|
|
2332
|
+
${ZA(o,t)}
|
|
2327
2333
|
</div>`),s.length>0&&(c+=`<div class="search-section">
|
|
2328
2334
|
<div class="search-section-title">${i(`searchPanel.otherSessionsResults`,{count:s.length})}</div>
|
|
2329
|
-
${
|
|
2330
|
-
</div>`),n.innerHTML=c}function
|
|
2335
|
+
${ZA(s,t)}
|
|
2336
|
+
</div>`),n.innerHTML=c}function ZA(e,t){return e.map((e,n)=>{let r=e.role===`user`?`👤`:`🤖`,a=e.role===`user`?i(`searchPanel.roleUser`):i(`searchPanel.roleAssistant`),o=e.sessionTitle||``,s=e.sessionId===H.activeSessionId,c=QA(W(e.matchPreview),t);return`
|
|
2331
2337
|
<div class="search-result-item" data-session-id="${e.sessionId}" data-message-id="${e.messageId}" title="${W(e.content)}">
|
|
2332
2338
|
<div class="search-result-header">
|
|
2333
2339
|
<span class="search-result-role">${r} ${a}</span>
|
|
@@ -2335,7 +2341,7 @@ Sessions using this assistant will revert to the default assistant.`,deleteAgent
|
|
|
2335
2341
|
</div>
|
|
2336
2342
|
<div class="search-result-preview">${c}</div>
|
|
2337
2343
|
</div>
|
|
2338
|
-
`}).join(``)}function
|
|
2344
|
+
`}).join(``)}function QA(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 $A(e,t){if(!(!e||!t)){if(H.activeSessionId!==e)try{let t=H.activeSessionId;if(await Mt(e)===!1||H.activeSessionId!==e){U(i(`searchPanel.sessionNotExist`),`warning`);return}document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:e,previousSessionId:t,skipScrollRestore:!0}}));try{let{renderSessionTabs:e}=await fe(async()=>{let{renderSessionTabs:e}=await Promise.resolve().then(()=>Xi);return{renderSessionTabs:e}},void 0);e()}catch(e){o.warn(`[SearchPanel] refreshsessionTab failed:`,e)}}catch(e){o.error(`[SearchPanel] switchsession failed:`,e);return}setTimeout(async()=>{let n=document.getElementById(`chatContainer`);if(!n){o.warn(`[SearchPanel] chatContainer not found`);return}let r=n.querySelector(`.message[data-message-id="${t}"]`);if(r||=n.querySelector(`[data-message-id="${t}"]`),!r){let r=Array.from(n.querySelectorAll(`[data-message-id]`),e=>e.dataset.messageId);o.warn(`[SearchPanel] positionmessage failed`,{targetSessionId:e,activeSessionId:H.activeSessionId,targetMessageId:t,typeOfMessageId:typeof t,messageIdLength:t.length,domMessageIds:r,chatContainerHtmlLen:n.innerHTML.length})}if(r)r.scrollIntoView({behavior:`instant`,block:`nearest`}),r.classList.add(`bookmark-highlight`),setTimeout(()=>{r.classList.remove(`bookmark-highlight`)},2e3);else{U(i(`searchPanel.messageDeleted`),`warning`);try{if(await F(e,t)){RA=RA.filter(n=>n.sessionId!==e||n.messageId!==t);let n=document.getElementById(`searchPanelContent`),r=document.getElementById(`searchPanelCount`);n&&RA.length>0?(XA(RA,zA,n),r.textContent=i(`searchPanel.countResult`,{count:RA.length})):n&&RA.length===0&&(n.innerHTML=`<div class="search-panel-empty">${i(`searchPanel.noMatch`)}</div>`,r&&(r.textContent=i(`searchPanel.noResult`))),o.debug(`[SearchPanel] cleaned IndexedDB dirtydata:`,e,t)}}catch(e){o.warn(`[SearchPanel] cleanupdirtydata failed:`,e)}}},500)}}r(`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})`}}),r(`en`,{schedPanel:{toggleTitle:`Scheduled tasks`,toggleRunning:`Running`,title:`Scheduled tasks`,newTask:`New task`,close:`Close`,empty:`No scheduled tasks`,nameLabel:`Name`,descLabel:`Description (optional)`,promptLabel:`Prompt`,scheduleLabel:`Schedule`,scheduleTypeOnce:`Once`,scheduleTypeInterval:`Interval`,scheduleTypeCron:`Cron expression`,intervalValuePlaceholder:`e.g. 30m / 2h / 1d`,cronValuePlaceholder:`e.g. 0 9 * * *`,relativeValuePlaceholder:`e.g. 30`,onceModeLabel:`Run mode`,onceModeRelative:`After some minutes`,onceModeAbsolute:`At specific time`,valueLabelInterval:`Interval`,valueLabelCron:`Cron expression`,minutesSuffix:` minutes later`,contextUrlLabel:`Context page URL (optional)`,useCurrentPage:`Use current page`,sessionLabel:`Host session`,sessionAuto:`Auto (recreate if deleted)`,save:`Save`,cancel:`Cancel`,edit:`Edit`,editTitle:`Edit task`,delete:`Delete`,runNow:`Run now`,enable:`Enable`,disable:`Disable`,statusSuccess:`Success`,statusFailed:`Failed`,statusRunning:`Running`,statusDisabled:`Disabled`,nextRun:`Next run`,deleted:`Task deleted`,saved:`Task saved`,runNowToast:`Execution triggered`,deleteConfirmTitle:`Delete scheduled task`,deleteConfirmMsg:`Delete task "{name}"?`,createFailed:`Failed to create task`,nameRequired:`Name is required`,promptRequired:`Prompt is required`,scheduleRequired:`Schedule is required`,loading:`Loading...`,contextModeLabel:`Page context mode`,contextModeFetch:`Fetch page content`,contextModeUrlOnly:`URL only`,maxRunsLabel:`Max runs (optional)`,endAtLabel:`End time (optional)`,runHistoryLabel:`Run history`,runHistoryEmpty:`No runs yet`,runCountLabel:`Run history ({count})`}});function ej(e){return chrome.runtime.sendMessage(e)}function tj(e){return e?new Date(e).toLocaleString(void 0,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`}):`—`}function nj(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 rj(e){return e===`success`?i(`schedPanel.statusSuccess`):e===`failed`?i(`schedPanel.statusFailed`):e===`running`?i(`schedPanel.statusRunning`):``}function ij(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 aj(e){let t=e.schedule||{};return t.type===`once`?t.onceMode===`relative`?i(`schedPanel.scheduleTypeOnce`)+` · `+(t.value||``)+i(`schedPanel.minutesSuffix`):i(`schedPanel.scheduleTypeOnce`)+` · `+tj(new Date(t.value).getTime()):t.type===`interval`?i(`schedPanel.scheduleTypeInterval`)+` · `+(t.value||``):t.type===`cron`?i(`schedPanel.scheduleTypeCron`)+` · `+(t.value||``):``}function oj(e){return e.enabled?e.lastStatus===`running`?`<span class="sched-badge running">${i(`schedPanel.statusRunning`)}</span>`:e.lastStatus===`failed`?`<span class="sched-badge failed">${i(`schedPanel.statusFailed`)}</span>`:e.lastStatus===`success`?`<span class="sched-badge success">${i(`schedPanel.statusSuccess`)}</span>`:``:`<span class="sched-badge muted">${i(`schedPanel.statusDisabled`)}</span>`}function sj(){let e=document.getElementById(`chatContainer`);e&&(e.scrollTop=e.scrollHeight)}async function cj(e){if(e){if(H.activeSessionId!==e){let t=H.activeSessionId;try{if(await Mt(e)===!1||H.activeSessionId!==e)return}catch{return}document.dispatchEvent(new CustomEvent(`session-switched`,{detail:{sessionId:e,previousSessionId:t,skipScrollRestore:!0}}));try{let{renderSessionTabs:e}=await fe(async()=>{let{renderSessionTabs:e}=await Promise.resolve().then(()=>Xi);return{renderSessionTabs:e}},void 0);e()}catch{}}setTimeout(sj,500)}}function lj(){let e=document.createElement(`div`);e.className=`schedule-panel-container`,e.id=`schedulePanelContainer`,e.innerHTML=`
|
|
2339
2345
|
<style>
|
|
2340
2346
|
.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; }
|
|
2341
2347
|
.schedule-panel-toggle { background: linear-gradient(135deg, rgba(39, 174, 96, 0.85) 0%, rgba(31, 145, 80, 0.85) 100%); color: white; border: none; border-radius: 6px 0 0 6px; padding: 8px 4px; cursor: pointer; font-size: 14px; box-shadow: -2px 2px 8px rgba(39, 174, 96, 0.3); transition: all 0.3s ease; display: flex; align-items: center; justify-content: center; opacity: 0.85; }
|
|
@@ -2466,23 +2472,23 @@ Sessions using this assistant will revert to the default assistant.`,deleteAgent
|
|
|
2466
2472
|
<button class="primary" id="scheduleModalSave">${i(`schedPanel.save`)}</button>
|
|
2467
2473
|
</div>
|
|
2468
2474
|
</div>
|
|
2469
|
-
`,document.body.appendChild(t);let n=document.getElementById(`schedulePanelToggle`),r=document.getElementById(`schedulePanel`),a=new Set;function o(){let e=a.size>0;n.classList.toggle(`running`,e),n.title=e?`${i(`schedPanel.toggleTitle`)} · ${i(`schedPanel.toggleRunning`)}`:i(`schedPanel.toggleTitle`)}let s=document.getElementById(`schedulePanelClose`),c=document.getElementById(`scheduleNewTask`),l=document.getElementById(`schedulePanelList`),u=document.getElementById(`scheduleModalOverlay`),d=document.getElementById(`scheduleModalTitle`),f=document.getElementById(`scheduleModalCancel`),p=document.getElementById(`scheduleModalSave`),m=document.getElementById(`schedFormType`),h=document.getElementById(`schedFormValue`),g=document.getElementById(`schedFormOnceMode`),_=document.getElementById(`schedOnceModeWrap`),v=document.getElementById(`schedValueLabel`),y=document.getElementById(`schedEndWrap`),b=null;function x(){let e=m.value,t=g.value;_.style.display=e===`once`?``:`none`,y.style.display=e===`interval`?``:`none`,e===`once`?t===`relative`?(v.textContent=i(`schedPanel.onceModeRelative`),h.type=`text`,h.placeholder=i(`schedPanel.relativeValuePlaceholder`)):(v.textContent=i(`schedPanel.onceModeAbsolute`),h.type=`datetime-local`,h.placeholder=``):e===`interval`?(v.textContent=i(`schedPanel.valueLabelInterval`),h.type=`text`,h.placeholder=i(`schedPanel.intervalValuePlaceholder`)):(v.textContent=i(`schedPanel.valueLabelCron`),h.type=`text`,h.placeholder=i(`schedPanel.cronValuePlaceholder`))}function S(e){e?(r.classList.add(`open`),et(r),C()):(r.classList.remove(`open`),tt(r))}n.addEventListener(`click`,()=>{S(!r.classList.contains(`open`))}),s.addEventListener(`click`,()=>S(!1)),m.addEventListener(`change`,x),g.addEventListener(`change`,x),document.getElementById(`scheduleModalCloseBtn`).addEventListener(`click`,O),f.addEventListener(`click`,O),p.addEventListener(`click`,k),c.addEventListener(`click`,()=>D(null)),document.getElementById(`schedUseCurrentPage`).addEventListener(`click`,async()=>{try{let e=(await chrome.tabs.query({active:!0,currentWindow:!0}))?.[0]?.url||``;e&&(document.getElementById(`schedFormUrl`).value=e)}catch{}});async function C(){try{let e=(await
|
|
2475
|
+
`,document.body.appendChild(t);let n=document.getElementById(`schedulePanelToggle`),r=document.getElementById(`schedulePanel`),a=new Set;function o(){let e=a.size>0;n.classList.toggle(`running`,e),n.title=e?`${i(`schedPanel.toggleTitle`)} · ${i(`schedPanel.toggleRunning`)}`:i(`schedPanel.toggleTitle`)}let s=document.getElementById(`schedulePanelClose`),c=document.getElementById(`scheduleNewTask`),l=document.getElementById(`schedulePanelList`),u=document.getElementById(`scheduleModalOverlay`),d=document.getElementById(`scheduleModalTitle`),f=document.getElementById(`scheduleModalCancel`),p=document.getElementById(`scheduleModalSave`),m=document.getElementById(`schedFormType`),h=document.getElementById(`schedFormValue`),g=document.getElementById(`schedFormOnceMode`),_=document.getElementById(`schedOnceModeWrap`),v=document.getElementById(`schedValueLabel`),y=document.getElementById(`schedEndWrap`),b=null;function x(){let e=m.value,t=g.value;_.style.display=e===`once`?``:`none`,y.style.display=e===`interval`?``:`none`,e===`once`?t===`relative`?(v.textContent=i(`schedPanel.onceModeRelative`),h.type=`text`,h.placeholder=i(`schedPanel.relativeValuePlaceholder`)):(v.textContent=i(`schedPanel.onceModeAbsolute`),h.type=`datetime-local`,h.placeholder=``):e===`interval`?(v.textContent=i(`schedPanel.valueLabelInterval`),h.type=`text`,h.placeholder=i(`schedPanel.intervalValuePlaceholder`)):(v.textContent=i(`schedPanel.valueLabelCron`),h.type=`text`,h.placeholder=i(`schedPanel.cronValuePlaceholder`))}function S(e){e?(r.classList.add(`open`),et(r),C()):(r.classList.remove(`open`),tt(r))}n.addEventListener(`click`,()=>{S(!r.classList.contains(`open`))}),s.addEventListener(`click`,()=>S(!1)),m.addEventListener(`change`,x),g.addEventListener(`change`,x),document.getElementById(`scheduleModalCloseBtn`).addEventListener(`click`,O),f.addEventListener(`click`,O),p.addEventListener(`click`,k),c.addEventListener(`click`,()=>D(null)),document.getElementById(`schedUseCurrentPage`).addEventListener(`click`,async()=>{try{let e=(await chrome.tabs.query({active:!0,currentWindow:!0}))?.[0]?.url||``;e&&(document.getElementById(`schedFormUrl`).value=e)}catch{}});async function C(){try{let e=(await ej({type:`SCHEDULED_TASK_LIST`}))?.tasks||[],t=document.getElementById(`schedulePanelCount`);t&&(t.textContent=e.length>0?`(${e.length})`:``),T(e),a.clear(),e.forEach(e=>{e.lastStatus===`running`&&a.add(e.id)}),o()}catch(e){l.innerHTML=`<div class="sched-empty">${W(String(e?.message||e))}</div>`}}function w(e){return!e||!e.length?`<div class="sched-history"><div class="sched-run">${i(`schedPanel.runHistoryEmpty`)}</div></div>`:`<div class="sched-history">${e.slice().reverse().map(e=>`
|
|
2470
2476
|
<div class="sched-run">
|
|
2471
2477
|
<span class="dot ${W(e.status||``)}"></span>
|
|
2472
|
-
<span class="time">${W(
|
|
2473
|
-
<span>${W(
|
|
2474
|
-
<span class="dur">${W(
|
|
2478
|
+
<span class="time">${W(tj(e.startedAt))}</span>
|
|
2479
|
+
<span>${W(rj(e.status))}</span>
|
|
2480
|
+
<span class="dur">${W(nj(e.durationMs))}</span>
|
|
2475
2481
|
${e.error?`<span class="err" title="${W(e.error)}">${W(e.error)}</span>`:``}
|
|
2476
2482
|
</div>
|
|
2477
2483
|
`).join(``)}</div>`}function T(e){if(!e.length){l.innerHTML=`<div class="sched-empty">${i(`schedPanel.empty`)}</div>`;return}l.innerHTML=e.map(e=>{let t=e.runHistory?.length||0,n=t>0?`<button class="sched-history-btn" data-act="history">${i(`schedPanel.runCountLabel`,{count:t})}</button>`:``;return`
|
|
2478
2484
|
<div class="sched-item" data-id="${W(e.id)}">
|
|
2479
2485
|
<div class="row1">
|
|
2480
2486
|
<span class="name" title="${W(e.name)}">${W(e.name)}</span>
|
|
2481
|
-
${
|
|
2487
|
+
${oj(e)}
|
|
2482
2488
|
</div>
|
|
2483
2489
|
${e.description?`<div class="desc">${W(e.description)}</div>`:``}
|
|
2484
|
-
<div class="meta">${W(
|
|
2485
|
-
<div class="meta">${i(`schedPanel.nextRun`)}: ${W(
|
|
2490
|
+
<div class="meta">${W(aj(e))}</div>
|
|
2491
|
+
<div class="meta">${i(`schedPanel.nextRun`)}: ${W(tj(e.nextRunAt))}</div>
|
|
2486
2492
|
${n}
|
|
2487
2493
|
<div class="sched-history" data-history style="display:none;">${w(e.runHistory)}</div>
|
|
2488
2494
|
<div class="actions">
|
|
@@ -2492,16 +2498,16 @@ Sessions using this assistant will revert to the default assistant.`,deleteAgent
|
|
|
2492
2498
|
<button data-act="delete" class="danger">${i(`schedPanel.delete`)}</button>
|
|
2493
2499
|
</div>
|
|
2494
2500
|
</div>
|
|
2495
|
-
`}).join(``)}l.addEventListener(`click`,async e=>{let t=e.target.closest(`button[data-act]`);if(!t)return;let n=t.closest(`.sched-item`),r=n?.dataset.id;if(!r)return;let a=t.dataset.act;if(a===`toggle`){let e=(await E())[r];if(!e)return;await
|
|
2496
|
-
`)}function
|
|
2501
|
+
`}).join(``)}l.addEventListener(`click`,async e=>{let t=e.target.closest(`button[data-act]`);if(!t)return;let n=t.closest(`.sched-item`),r=n?.dataset.id;if(!r)return;let a=t.dataset.act;if(a===`toggle`){let e=(await E())[r];if(!e)return;await ej({type:`SCHEDULED_TASK_TOGGLE`,id:r,enabled:!e.enabled}),C()}else if(a===`run`){let e=await ej({type:`SCHEDULED_TASK_RUN_NOW`,id:r});e?.success?(U(i(`schedPanel.runNowToast`),`success`),cj(e.sessionId),setTimeout(C,1500)):U(e?.error||i(`schedPanel.createFailed`),`error`)}else if(a===`history`){let e=n.querySelector(`[data-history]`);e&&(e.style.display=e.style.display===`none`?``:`none`)}else if(a===`edit`)D((await E())[r]);else if(a===`delete`){let e=(await E())[r];await window.showCustomConfirm(i(`schedPanel.deleteConfirmMsg`,{name:e?.name||``}),i(`schedPanel.deleteConfirmTitle`))&&(await ej({type:`SCHEDULED_TASK_DELETE`,id:r}),U(i(`schedPanel.deleted`),`success`),C())}});async function E(){let e=await ej({type:`SCHEDULED_TASK_LIST`}),t={};return(e?.tasks||[]).forEach(e=>{t[e.id]=e}),t}async function D(e){b=e||null,d.textContent=i(e?`schedPanel.editTitle`:`schedPanel.newTask`),document.getElementById(`schedFormName`).value=e?.name||``,document.getElementById(`schedFormDesc`).value=e?.description||``,document.getElementById(`schedFormPrompt`).value=e?.prompt||``,document.getElementById(`schedFormUrl`).value=e?.contextUrl||``,m.value=e?.schedule?.type||`interval`,g.value=e?.schedule?.onceMode||`relative`,x(),h.value=e?.schedule?.value||``,document.getElementById(`schedFormContextMode`).value=e?.contextMode||`fetch`,document.getElementById(`schedFormMaxRuns`).value=e?.maxRuns??``,document.getElementById(`schedFormEndAt`).value=e?.endAt?ij(e.endAt):``;let t=document.getElementById(`schedFormSession`),n=`<option value="">${i(`schedPanel.sessionAuto`)}</option>`;try{let{list:t}=await ae(),r=[...t].sort((e,t)=>{let n=e.order??0,r=t.order??0;return n===r?new Date(t.createdAt||0)-new Date(e.createdAt||0):r-n});for(let t of r){let r=e?.sessionId===t.id?`selected`:``,i=W(t.title||t.id);n+=`<option value="${W(t.id)}" ${r}>${i}</option>`}}catch{}t.innerHTML=n,u.classList.add(`open`)}function O(){u.classList.remove(`open`),b=null}async function k(){let e=document.getElementById(`schedFormName`).value.trim(),t=document.getElementById(`schedFormPrompt`).value.trim(),n=m.value,r=h.value.trim();if(!e){U(i(`schedPanel.nameRequired`),`warning`);return}if(!t){U(i(`schedPanel.promptRequired`),`warning`);return}if(!r){U(i(`schedPanel.scheduleRequired`),`warning`);return}let a=n===`interval`&&parseInt(document.getElementById(`schedFormMaxRuns`).value,10)||null,o=n===`interval`?document.getElementById(`schedFormEndAt`).value:``,s=o?new Date(o).getTime():null,c={name:e,description:document.getElementById(`schedFormDesc`).value.trim(),prompt:t,schedule:n===`once`?{type:n,value:r,onceMode:g.value}:{type:n,value:r},contextUrl:document.getElementById(`schedFormUrl`).value.trim()||null,contextMode:document.getElementById(`schedFormContextMode`).value||`fetch`,sessionId:document.getElementById(`schedFormSession`).value||null,maxRuns:a,endAt:s,enabled:!b||b.enabled};try{let e=await ej({type:b?`SCHEDULED_TASK_UPDATE`:`SCHEDULED_TASK_CREATE`,task:b?{...c,id:b.id}:c});e?.success?(U(i(`schedPanel.saved`),`success`),O(),C()):U(e?.error||i(`schedPanel.createFailed`),`error`)}catch(e){U(e?.message||i(`schedPanel.createFailed`),`error`)}}chrome.runtime.onMessage.addListener(e=>{e.type===`SCHEDULED_TASK_RUN_STATE`&&e.taskId&&(e.running?a.add(e.taskId):a.delete(e.taskId),o())}),chrome.runtime.onMessage.addListener(e=>{e.type===`SCHEDULED_SESSION_UPDATED`&&(r.classList.contains(`open`)&&C().catch(()=>{}),e.sessionId&&e.sessionId===H.activeSessionId&&setTimeout(sj,600))}),x(),S(!1),C().catch(()=>{})}var uj={version:`2.2.0`,tag:`v2.2.0`,commitId:`00bb2aa92d59f4dc4c077f2edbb58498a4e938ef`,publishedAt:`2026-10-12T04:52:54.418Z`},dj=`—`,fj=[{labelKey:`versionInfo.website`,url:`https://xiweicheng.github.io/ai-helper/`,icon:`<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z"/></svg>`},{labelKey:`versionInfo.discussions`,url:`https://github.com/xiweicheng/ai-helper/discussions`,icon:`<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z"/></svg>`},{labelKey:`versionInfo.reportIssue`,url:`https://github.com/xiweicheng/ai-helper/issues/new`,icon:`<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z"/></svg>`},{labelKey:`versionInfo.githubRepo`,url:`https://github.com/xiweicheng/ai-helper`,icon:`<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M12 .5C5.73.5.5 5.73.5 12c0 5.08 3.29 9.39 7.86 10.91.58.11.79-.25.79-.56 0-.28-.01-1.02-.02-2-3.2.7-3.88-1.54-3.88-1.54-.52-1.33-1.28-1.69-1.28-1.69-1.04-.71.08-.7.08-.7 1.15.08 1.76 1.19 1.76 1.19 1.03 1.76 2.7 1.25 3.36.96.1-.75.4-1.25.72-1.54-2.55-.29-5.24-1.28-5.24-5.68 0-1.26.45-2.28 1.19-3.09-.12-.29-.52-1.46.11-3.05 0 0 .97-.31 3.18 1.18a11.1 11.1 0 012.9-.39c.98 0 1.97.13 2.9.39 2.2-1.49 3.17-1.18 3.17-1.18.63 1.59.23 2.76.11 3.05.74.81 1.19 1.83 1.19 3.09 0 4.41-2.69 5.38-5.25 5.67.41.35.78 1.05.78 2.12 0 1.53-.01 2.76-.01 3.14 0 .31.21.68.8.56A11.51 11.51 0 0023.5 12C23.5 5.73 18.27.5 12 .5z"/></svg>`},{labelKey:`versionInfo.giteeRepo`,url:`https://gitee.com/xiweicheng/ai-helper`,icon:`<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M11.984 0A12 12 0 000 12a12 12 0 0012 12 12 12 0 0012-12A12 12 0 0012 0zm6.09 5.333c.328 0 .593.266.592.593v1.482a.594.594 0 01-.593.592H9.777c-.982 0-1.778.796-1.778 1.778v5.63c0 .327.266.592.593.592h5.63c.982 0 1.778-.796 1.778-1.778v-.296a.593.593 0 00-.592-.593h-4.15a.592.592 0 01-.592-.592v-1.482a.593.593 0 01.593-.592h6.815c.327 0 .593.265.593.592v3.408a4 4 0 01-4 4H8.444a3.556 3.556 0 01-3.555-3.556V8.89a3.556 3.556 0 013.555-3.556h9.63z"/></svg>`}];function pj(e){let t=e=>typeof e==`string`?e.trim():``,n=e&&typeof e==`object`?e:{};return{version:t(n.version),tag:t(n.tag),commitId:t(n.commitId),publishedAt:t(n.publishedAt)}}function mj(e){if(!e)return dj;let t=Date.parse(e);return Number.isNaN(t)?dj:new Date(t).toLocaleString()}function hj(e){let t=pj(uj),n=[{label:i(`versionInfo.version`),value:t.version?`v${t.version}`:dj},{label:i(`versionInfo.tag`),value:t.tag||dj},{label:i(`versionInfo.commit`),value:t.commitId?t.commitId.slice(0,8):dj,title:t.commitId,mono:!0},{label:i(`versionInfo.publishedAt`),value:mj(t.publishedAt)}];e.textContent=``;for(let t of n){let n=document.createElement(`div`);n.className=`version-info-row`;let r=document.createElement(`div`);r.className=`version-info-label`,r.textContent=t.label;let i=document.createElement(`div`);i.className=t.mono?`version-info-value mono`:`version-info-value`,i.textContent=t.value,t.title&&(i.title=t.title),n.appendChild(r),n.appendChild(i),e.appendChild(n)}}function gj(e){e.textContent=``;for(let t of fj){let n=document.createElement(`div`);n.className=`version-info-link`,n.title=t.url;let r=document.createElement(`span`);r.className=`version-info-link-icon`,r.innerHTML=t.icon;let a=document.createElement(`span`);a.className=`version-info-link-label`,a.textContent=i(t.labelKey);let o=document.createElement(`span`);o.className=`version-info-link-arrow`,o.textContent=`↗`,n.appendChild(r),n.appendChild(a),n.appendChild(o),n.addEventListener(`click`,()=>{chrome.tabs.create({url:t.url})}),e.appendChild(n)}}function _j(){let e=pj(uj);return[`AI Helper v${e.version||dj}`,`${i(`versionInfo.tag`)}: ${e.tag||dj}`,`${i(`versionInfo.commit`)}: ${e.commitId||dj}`,`${i(`versionInfo.publishedAt`)}: ${mj(e.publishedAt)}`].join(`
|
|
2502
|
+
`)}function vj(){let e=document.getElementById(`versionInfoBtn`),t=document.getElementById(`versionInfoModal`),n=document.getElementById(`versionInfoCloseBtn`),r=document.getElementById(`versionInfoCopyBtn`),a=document.getElementById(`versionInfoList`),o=document.getElementById(`versionInfoLinks`);if(!e||!t||!a)return;let s=()=>{t.style.display=`none`};e.addEventListener(`click`,e=>{e.stopPropagation();let n=document.getElementById(`headerMoreDropdown`);n&&n.classList.remove(`show`),hj(a),o&&gj(o),t.style.display=`flex`}),n&&n.addEventListener(`click`,s),t.addEventListener(`click`,e=>{e.target===t&&s()}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&t.style.display===`flex`&&s()}),r&&r.addEventListener(`click`,async()=>{try{await navigator.clipboard.writeText(_j()),U(i(`common.copySuccess`),`success`)}catch{U(i(`common.copyFailed`),`error`)}})}var yj=null;function bj(){if(!yj)return;yj.classList.remove(`open`);let e=yj.parentElement?yj.parentElement.querySelector(`.section-select-row`):null;e&&e.classList.remove(`open`),yj=null}function xj(){return`<input type="search" class="section-select-search" placeholder="${i(`sectionSelect.searchPlaceholder`)}" data-i18n-placeholder="sectionSelect.searchPlaceholder" spellcheck="false">`}function Sj(e,t){if(!e)return;let n=String(t||``).trim().toLowerCase(),r=Array.from(e.children).filter(e=>e.hasAttribute(`data-value`)),a=0;for(let e of r){let t=!n||e.textContent.toLowerCase().includes(n);e.style.display=t?``:`none`,t&&(a+=1)}let o=e.querySelector(`.section-select-empty`);n&&a===0?(o||(o=document.createElement(`div`),o.className=`section-select-empty`,e.appendChild(o)),o.textContent=i(`sectionSelect.noMatch`)):o&&o.remove()}function Cj(e,t){bj(),e.classList.add(`open`),t.classList.add(`open`),yj=e;let n=e.querySelector(`.section-select-search`);n&&(n.value=``,Sj(e,``),n.focus())}document.addEventListener(`click`,e=>{let t=e.target.closest(`.section-select-row`);if(t){let e=t.parentElement.querySelector(`.section-select-list`);if(!e)return;e===yj?bj():Cj(e,t);return}yj&&!yj.parentElement.contains(e.target)&&bj()}),document.addEventListener(`input`,e=>{let t=e.target;if(!t||!t.classList||!t.classList.contains(`section-select-search`))return;let n=t.closest(`.section-select-list`);n&&Sj(n,t.value)});var wj=!1;async function Tj(){document.getElementById(`providerList`)&&(wj||(wj=!0,Oj(),kj()),await Ej())}async function Ej(){let e=document.getElementById(`providerList`),t=document.getElementById(`providerSelectValue`),n=document.getElementById(`providerSelectHost`);if(!e)return;let r=await w(),i=r.profiles.find(e=>e.id===r.activeProfileId)||r.profiles[0];t&&(t.textContent=i?i.name:``),n&&(n.textContent=i?O(i.apiBase):``),e.innerHTML=xj();let a=[...r.profiles].sort((e,t)=>T(e.name,t.name));for(let t of a){let n=!!i&&t.id===i.id,r=document.createElement(`div`);r.className=`provider-option`+(n?` selected`:``),r.dataset.value=t.id;let a=document.createElement(`span`);a.className=`provider-option-check`,a.textContent=n?`✓`:``,r.appendChild(a);let o=document.createElement(`span`);o.className=`provider-option-left`,o.textContent=t.name,r.appendChild(o);let s=O(t.apiBase);if(s){let e=document.createElement(`span`);e.className=`provider-option-right`,e.textContent=s,r.appendChild(e)}r.addEventListener(`click`,e=>{e.stopPropagation(),bj(),Dj(t.id)}),e.appendChild(r)}}async function Dj(e){if(e===(await w()).activeProfileId)return;let t=await D(e);t&&(await Ej(),o.debug(`[SidePanel] provider switched:`,t.name))}function Oj(){let e=document.getElementById(`providerManageBtn`);e&&e.addEventListener(`click`,async e=>{e.stopPropagation();let t=chrome.runtime.getURL(`options.html#basic`),n=await chrome.tabs.query({url:chrome.runtime.getURL(`options.html`)});n.length>0?await chrome.tabs.update(n[0].id,{active:!0,url:t}):await chrome.tabs.create({url:t})})}function kj(){chrome.storage.onChanged.addListener((e,t)=>{t===`local`&&(e.modelProfiles||e.activeProfileId)&&Ej()})}var Aj=0;function jj(e,t){let n=e&&e.nodeType===1?e:e?e.parentElement:null;for(let e=n;e&&e!==t;e=e.parentElement)if(getComputedStyle(e).position===`absolute`)return!0;return!1}function Mj(e){let t=[];return e.querySelectorAll(`*`).forEach(e=>{getComputedStyle(e).position===`absolute`&&e.getClientRects().length>0&&t.push(e)}),t}function Nj(e){e.forEach(e=>{(e.getAnimations?.()||[]).forEach(e=>{e.playState!==`idle`&&e.finish?.()})})}function Pj(){Aj||=requestAnimationFrame(()=>{Aj=0,Lj()})}function Fj(){let e=document.getElementById(`selectionToggleGroup`),t=document.getElementById(`inputAddMenuSwitches`);e&&t&&e.parentElement!==t&&t.appendChild(e)}function Ij(){let e=document.getElementById(`selectionToggleGroup`),t=document.querySelector(`.input-bottom-left`);e&&t&&e.parentElement!==t&&t.appendChild(e)}function Lj(){let e=document.querySelector(`.input-bottom-row`),t=e?.closest(`.input-container`)||null;if(!(!e||!t)){t.classList.add(`measuring`);try{Rj(e,t)}finally{t.classList.remove(`measuring`)}}}function Rj(e,t){t.classList.remove(`temp-collapsed`,`agent-collapsed`,`switches-icon`,`selection-in-menu`),Ij();let n=Mj(e),r=n.map(e=>e.style.display);n.forEach(e=>{e.style.display=`none`});let i=()=>{n.forEach((e,t)=>{e.style.display=r[t]}),Nj(n)};if(e.scrollWidth<=e.clientWidth){i();return}if(t.classList.add(`temp-collapsed`),e.scrollWidth<=e.clientWidth){i();return}if(t.classList.add(`agent-collapsed`),e.scrollWidth<=e.clientWidth){i();return}if(t.classList.add(`switches-icon`),e.scrollWidth<=e.clientWidth){i();return}t.classList.add(`selection-in-menu`),Fj(),i()}function zj(){Lj(),window.addEventListener(`resize`,Pj);let e=document.querySelector(`.input-bottom-row`);e&&typeof MutationObserver<`u`&&new MutationObserver(t=>{let n=document.getElementById(`selectionToggleGroup`),r=e=>!!n&&[...e.addedNodes,...e.removedNodes].includes(n);t.some(t=>!jj(t.target,e)&&!r(t))&&Pj()}).observe(e,{subtree:!0,childList:!0,characterData:!0})}r(`zh`,{fileSelector:{workspaceTitle:`工作目录`,switchHint:`方向键切换 · Enter添加到文件问答 · Esc取消`,searching:`搜索中...`,noMatch:`没有匹配的文件或目录`,noWorkspace:`暂无工作目录,请先连接 Agent`,loadFailed:`加载失败: {error}`,truncated:`仅显示前 {count} 条,请继续输入以缩小范围`}}),r(`en`,{fileSelector:{workspaceTitle:`Workspace`,switchHint:`↑↓ navigate · Enter attach · Esc cancel`,searching:`Searching...`,noMatch:`No matching file or directory`,noWorkspace:`No workspace directory. Connect an Agent first.`,loadFailed:`Load failed: {error}`,truncated:`Showing top {count} results. Keep typing to narrow down.`}});var Bj=50,Vj=200,Hj=200,Uj=0,Wj=null,Gj=[];function Kj(e){return(e||``).replace(/\\/g,`/`).replace(/\/+/g,`/`)}function qj(e){let t=document.getElementById(`fileAtTitlePath`);if(!t)return;let n=e?Kj(e):``;t.textContent=n,t.title=n}async function Jj(e=``){let t=document.getElementById(`fileAtSelector`),n=document.getElementById(`fileAtDropdown`);if(!t||!n)return;n.dataset.focusGuard||(n.dataset.focusGuard=`1`,n.addEventListener(`mousedown`,e=>{e.target.closest(`.prompt-item`)&&e.preventDefault()}));let r=document.getElementById(`fileAtWorkspaceOpenBtn`);r&&!r.dataset.bound&&(r.dataset.bound=`1`,r.addEventListener(`click`,async e=>{e.stopPropagation(),Yj(),await Ix()})),Ae(),t.style.display=`block`,n.classList.add(`show`),await Xj(e)}function Yj(){let e=document.getElementById(`fileAtSelector`),t=document.getElementById(`fileAtDropdown`);e&&(e.style.display=`none`),t&&t.classList.remove(`show`),H.selectedFileAtIndex=-1,Wj&&=(clearTimeout(Wj),null),Uj++}function Xj(e=``){let t=document.getElementById(`fileAtList`);if(!t)return;let n=++Uj,r=e.trim();Wj&&clearTimeout(Wj);let a=async()=>{try{let e=await jl();if(n!==Uj)return;if(qj(e),!e){t.innerHTML=`<div class="prompt-empty">${i(`fileSelector.noWorkspace`)}</div>`,H.selectedFileAtIndex=-1;return}let a;if(a=r?await Ul(e,r,Vj):((await Rl(e)).entries||[]).map(t=>({name:t.name,type:t.type||`file`,size:t.size,mtime:t.mtime,fullPath:Kj(`${e}/${t.name}`)})),n!==Uj)return;Qj(a,r,t,e)}catch(e){if(n!==Uj)return;o.warn(`[FileAtSelector] search failed:`,e.message),t.innerHTML=`<div class="prompt-empty">${i(`fileSelector.loadFailed`,{error:e.message})}</div>`,H.selectedFileAtIndex=-1}};r?(t.innerHTML=`<div class="prompt-empty">${i(`fileSelector.searching`)}</div>`,Wj=setTimeout(a,Hj)):Wj=setTimeout(a,0)}function Zj(e,t){let n=t.toLowerCase();return[...e].sort((e,t)=>{let r=(e.name||``).toLowerCase(),i=(t.name||``).toLowerCase();if(n){let e=+!!r.startsWith(n),t=+!!i.startsWith(n);if(e!==t)return t-e}let a=e.mtime||0,o=t.mtime||0;if(a!==o)return o-a;let s=e.type===`directory`?0:1,c=t.type===`directory`?0:1;return s===c?r.localeCompare(i):s-c})}function Qj(e,t,n,r){let a=Zj(e,t),o=a.slice(0,Bj),s=a.length>Bj,c=Kj(r);if(o.length===0){n.innerHTML=`<div class="prompt-empty">${i(`fileSelector.noMatch`)}</div>`,H.selectedFileAtIndex=-1;return}if(H.selectedFileAtIndex=0,Gj=o,n.innerHTML=o.map((e,t)=>{let n=yl(e.name,e.type),r=Kj(e.fullPath),i=r.startsWith(c)?r.substring(c.length).replace(/^\//,``):r;return`
|
|
2497
2503
|
<div class="prompt-item ${t===0?`selected`:``}" data-index="${t}" data-path="${W(r)}" title="${W(r)}">
|
|
2498
2504
|
<span class="prompt-item-index">${t+1}</span>
|
|
2499
2505
|
<span class="prompt-item-icon">${n}</span>
|
|
2500
2506
|
<span class="prompt-item-content">${W(e.name)}</span>
|
|
2501
2507
|
<span class="file-at-path">${W(i)}</span>
|
|
2502
2508
|
</div>
|
|
2503
|
-
`}).join(``),s){let e=document.createElement(`div`);e.className=`file-at-truncated`,e.textContent=i(`fileSelector.truncated`,{count:
|
|
2504
|
-
<span class="input-add-panel-item-title"><span class="input-add-panel-item-inline-icon">${
|
|
2509
|
+
`}).join(``),s){let e=document.createElement(`div`);e.className=`file-at-truncated`,e.textContent=i(`fileSelector.truncated`,{count:Bj}),n.appendChild(e)}n.querySelectorAll(`.prompt-item`).forEach(e=>{e.addEventListener(`click`,()=>{$j(Gj.find(t=>t.fullPath===e.dataset.path)||e.dataset.path)})})}function $j(e){if(!(typeof e==`string`?e:e&&e.fullPath))return;let t=document.getElementById(`userInput`),n=t?t.value:``,r=n.lastIndexOf(`$`);r!==-1&&(t.value=n.substring(0,r)),t&&(t.focus(),t.selectionStart=t.selectionEnd=t.value.length),Yj(),Gw([e]),ke()}function eM(e){let t=H.selectedFileAtIndex;e.forEach((e,n)=>{n===t?(e.classList.add(`selected`),e.scrollIntoView({block:`nearest`})):e.classList.remove(`selected`)})}r(`zh`,{input:{addMenuPanelSearchPlaceholder:`搜索…`,addMenuPanelClear:`清除`,addMenuPanelLoading:`加载中…`,addMenuPanelEmpty:`暂无可用内容`,addMenuPanelNoMatch:`没有匹配项`}}),r(`en`,{input:{addMenuPanelSearchPlaceholder:`Search…`,addMenuPanelClear:`Clear`,addMenuPanelLoading:`Loading…`,addMenuPanelEmpty:`No items available`,addMenuPanelNoMatch:`No matches`}});var tM=null,nM=null,rM=null,iM=null,aM=null,oM=null,sM=null,cM=[],lM=0,uM=()=>{},dM=[{action:`full`,icon:`📷`,nameKey:`input.addMenuScreenshotFull`,descKey:`input.addMenuScreenshotFullDesc`,kbd:`Alt+S`},{action:`region`,icon:`✂️`,nameKey:`input.addMenuScreenshotRegion`,descKey:`input.addMenuScreenshotRegionDesc`,kbd:`Alt+Shift+S`}],fM=new Set([`screenshot`]),pM={prompts:{titleKey:`promptManager.title`,action:()=>LO()},skills:{titleKey:`promptSelector.skillManageTitle`,action:()=>mM(`toolbox`)},mcp:{titleKey:`promptSelector.mcpManageTitle`,action:()=>mM(`toolbox`)},pages:{titleKey:`pageSelector.openNewTab`,action:()=>chrome.tabs.create({})},knowledge:{titleKey:`header.manageKnowledge`,action:()=>mM(`knowledge`)},agents:{titleKey:`header.addEditAssistant`,action:()=>Gk(null)},proxies:{titleKey:`header.addEditAgent`,action:()=>mM(`agent`)},workspace:{titleKey:`workspace.openPanel`,action:()=>Ix()}};function mM(e){chrome.runtime.sendMessage({type:`OPEN_OPTIONS_PAGE`,hash:e})}function hM(){if(!aM)return;let e=sM?pM[sM]:null;if(!e){aM.style.display=`none`;return}let t=i(e.titleKey);aM.title=t,aM.setAttribute(`aria-label`,t),aM.style.display=`flex`}function gM(){iM&&(iM.style.display=fM.has(sM)?`none`:``)}function _M(e={}){if(uM=typeof e.onRequestClose==`function`?e.onRequestClose:()=>{},tM=document.getElementById(`inputAddPanel`),nM=document.getElementById(`inputAddPanelSearch`),rM=document.getElementById(`inputAddPanelSearchClear`),aM=document.getElementById(`inputAddPanelManage`),iM=document.getElementById(`inputAddPanelSearchWrap`),oM=document.getElementById(`inputAddPanelList`),!(!tM||!nM||!oM)){if(aM&&aM.addEventListener(`click`,()=>{let e=sM?pM[sM]:null;e&&(uM(),e.action())}),rM){let e=i(`input.addMenuPanelClear`);rM.title=e,rM.setAttribute(`aria-label`,e),rM.addEventListener(`click`,()=>{nM.value=``,DM(),vM(),nM.focus()})}nM.addEventListener(`input`,()=>{DM(),vM()})}}function vM(){rM&&nM&&(rM.style.display=nM.value?`flex`:`none`)}function yM(){return!!sM}function bM(){return sM}function xM(){return!!nM&&document.activeElement===nM}async function SM(e){if(!tM||!e||sM===e&&tM.style.display!==`none`)return;sM=e,hM(),gM(),nM&&(nM.value=``,nM.placeholder=i(`input.addMenuPanelSearchPlaceholder`),vM()),tM.style.display=`flex`;let t=++lM;oM&&(oM.innerHTML=`<div class="prompt-empty">${i(`input.addMenuPanelLoading`)}</div>`);try{let n=await wM(e);if(t!==lM)return;cM=Array.isArray(n)?n:[],DM()}catch(e){if(t!==lM)return;o.warn(`[InputAddPanel] load failed:`,e&&e.message),cM=[],oM&&(oM.innerHTML=`<div class="prompt-empty">${i(`input.addMenuPanelEmpty`)}</div>`)}}function CM(){sM=null,hM(),gM(),cM=[],lM++,nM&&(nM.value=``,vM()),oM&&(oM.innerHTML=``),tM&&(tM.style.display=`none`)}function wM(e){switch(e){case`prompts`:return Promise.resolve(H.customPrompts||[]);case`skills`:return ek(!0);case`mcp`:return mk();case`pages`:return wE();case`knowledge`:return vE().then(e=>e.ok?e.collections:[]);case`agents`:return we();case`proxies`:return zT();case`workspace`:return TM();case`screenshot`:return Promise.resolve(dM);default:return Promise.resolve([])}}async function TM(){let e=await jl();if(!e)return[];let t=await Rl(e),n=t&&t.entries||[],r=String(e).replace(/\\/g,`/`).replace(/\/+/g,`/`);return n.map(e=>({name:e.name,type:e.type||`file`,size:e.size,mtime:e.mtime,fullPath:`${r}/${e.name}`.replace(/\/+/g,`/`)})).sort((e,t)=>{let n=e.mtime||0,r=t.mtime||0;if(n!==r)return r-n;let i=e.type===`directory`?0:1,a=t.type===`directory`?0:1;return i===a?String(e.name).localeCompare(String(t.name)):i-a})}function EM(e){if(!e)return cM;let t=e.toLowerCase();return cM.filter(e=>{switch(sM){case`prompts`:return String(e.code||``).toLowerCase().includes(t)||String(e.content||``).toLowerCase().includes(t);case`skills`:return String(e.name||``).toLowerCase().includes(t)||String(e.description||``).toLowerCase().includes(t);case`mcp`:return String(e.serverName||``).toLowerCase().includes(t)||String(e.serverId||``).toLowerCase().includes(t);case`pages`:return String(e.title||``).toLowerCase().includes(t)||String(e.url||``).toLowerCase().includes(t);case`knowledge`:return String(e.name||``).toLowerCase().includes(t)||String(e.description||``).toLowerCase().includes(t);case`agents`:return String(JT(e)||``).toLowerCase().includes(t)||String(YT(e)||``).toLowerCase().includes(t);case`proxies`:return String(e.name||``).toLowerCase().includes(t)||String(e.url||``).toLowerCase().includes(t);case`workspace`:return String(e.name||``).toLowerCase().includes(t);case`screenshot`:return i(e.nameKey).toLowerCase().includes(t)||i(e.descKey).toLowerCase().includes(t);default:return!0}})}function DM(){if(!oM)return;let e=nM?nM.value.trim():``,t=EM(e);if(t.length===0){oM.innerHTML=`<div class="prompt-empty">${i(e?`input.addMenuPanelNoMatch`:`input.addMenuPanelEmpty`)}</div>`;return}oM.innerHTML=t.map(e=>OM(e)).join(``),oM.querySelectorAll(`.input-add-panel-item`).forEach(e=>{e.addEventListener(`click`,t=>kM(t,e))}),oM.querySelectorAll(`img.favicon-img`).forEach(e=>{e.addEventListener(`error`,()=>{e.style.display=`none`})}),sM===`proxies`&&t.forEach(e=>nE(e)),sM===`skills`&&sk(),sM===`mcp`&&xk(),sM===`knowledge`&&uE()}function OM(e){switch(sM){case`prompts`:return`<div class="prompt-item input-add-panel-item input-add-panel-item-two-line" data-code="${W(e.code)}" title="${je(e.content||``)}">
|
|
2510
|
+
<span class="input-add-panel-item-title"><span class="input-add-panel-item-inline-icon">${wO}</span>/${W(e.code)}</span>
|
|
2505
2511
|
<span class="input-add-panel-item-sub">${W(e.content||``)}</span>
|
|
2506
2512
|
</div>`;case`skills`:{let t=e.enabled===!1,n=t?`${e.name}\n${i(`skillSelector.disabledTooltip`)}`:e.name,r=e.description||``;return`<div class="skill-list-item input-add-panel-item input-add-panel-item-two-line${t?` skill-list-item-disabled`:``}" data-skill-name="${W(e.name)}" title="${je(n)}">
|
|
2507
2513
|
<span class="input-add-panel-item-title">🧩 ${W(e.name)}</span>
|
|
@@ -2516,12 +2522,12 @@ Sessions using this assistant will revert to the default assistant.`,deleteAgent
|
|
|
2516
2522
|
</div>`}case`knowledge`:{let t=e.enabled===!1,n=i(`knowledgeSelector.docChunk`,{docs:e.documentCount||0,chunks:e.chunkCount||0});return`<div class="prompt-item input-add-panel-item input-add-panel-item-two-line prompt-item-knowledge${t?` knowledge-item-disabled`:``}" data-kb-id="${W(e.id)}" data-kb-name="${W(e.name||``)}" data-kb-disabled="${t?`1`:`0`}"${t?` title="${je(i(`knowledgeSelector.disabledTooltip`))}"`:``}>
|
|
2517
2523
|
<span class="input-add-panel-item-title">📚 ${W(e.name||``)}${t?` <span class="knowledge-item-badge badge-disabled">${i(`knowledgeSelector.disabledBadge`)}</span>`:``}</span>
|
|
2518
2524
|
<span class="input-add-panel-item-sub">${W(n)}</span>
|
|
2519
|
-
</div>`}case`agents`:{let t=
|
|
2525
|
+
</div>`}case`agents`:{let t=JT(e),n=YT(e),r=e.id===H.activeAgentId||!H.activeAgentId&&e.id==="default",a=e.toolIds?e.toolIds.length:e.toolIds===null?null:0,o=a===null?i(`promptSelector.inheritGlobal`):i(`promptSelector.toolCount`,{count:a});return`<div class="prompt-item input-add-panel-item input-add-panel-item-two-line" data-agent-id="${W(e.id)}">
|
|
2520
2526
|
<span class="input-add-panel-item-title">${W([e.icon,t].filter(Boolean).join(` `))}</span>
|
|
2521
2527
|
<span class="input-add-panel-item-sub">${W(n||o)}</span>
|
|
2522
2528
|
${r?`<span class="input-add-panel-item-mark">✓</span>`:``}
|
|
2523
|
-
</div>`}case`proxies`:{let t=e.name||i(`promptSelector.unnamedProxy`),n
|
|
2524
|
-
<span class="input-add-panel-item-title"><span class="agent-at-dot agent-at-dot-${
|
|
2529
|
+
</div>`}case`proxies`:{let t=e.name||i(`promptSelector.unnamedProxy`),n=eE(e),r=n?n.online:!1;return`<div class="prompt-item prompt-item-proxy input-add-panel-item input-add-panel-item-two-line${e.isDisabled?` agent-disabled`:``}" data-proxy-id="${W(e.id)}">
|
|
2530
|
+
<span class="input-add-panel-item-title"><span class="agent-at-dot agent-at-dot-${tE(e,r)}"></span>${W(t)}</span>
|
|
2525
2531
|
<span class="input-add-panel-item-sub">${W(e.url||``)}</span>
|
|
2526
2532
|
${e.isActive?`<span class="input-add-panel-item-mark">✓</span>`:``}
|
|
2527
2533
|
</div>`}case`workspace`:{let t=e.type===`directory`;return`<div class="prompt-item input-add-panel-item" data-path="${W(e.fullPath)}" title="${je(e.fullPath)}">
|
|
@@ -2532,7 +2538,7 @@ Sessions using this assistant will revert to the default assistant.`,deleteAgent
|
|
|
2532
2538
|
<span class="input-add-panel-item-title">${e.icon} ${W(i(e.nameKey))}</span>
|
|
2533
2539
|
<span class="input-add-panel-item-sub">${W(i(e.descKey))}</span>
|
|
2534
2540
|
<kbd class="input-add-panel-item-kbd">${W(e.kbd)}</kbd>
|
|
2535
|
-
</div>`;default:return``}}async function
|
|
2541
|
+
</div>`;default:return``}}async function kM(e,t){let n=e.ctrlKey||e.metaKey;switch(sM){case`prompts`:{let e=t.dataset.code;n?FO(e,{skipTriggerStrip:!0}):IO(e),uM();break}case`skills`:ik(t.dataset.skillName,cM,{clearTrigger:!1}),n&&uM();break;case`mcp`:_k(t.dataset.serverId,t.dataset.serverName,cM,{clearTrigger:!1}),n&&uM();break;case`pages`:{let e=cM.find(e=>String(e.id)===t.dataset.tabId);if(e){DE(e);let t=document.getElementById(`userInput`);t&&t.focus(),ke()}uM();break}case`knowledge`:dE({id:t.dataset.kbId,name:t.dataset.kbName,enabled:t.dataset.kbDisabled!==`1`},{clearTrigger:!1}),n&&uM();break;case`agents`:await cE(t.dataset.agentId,{clearTrigger:!1}),uM();break;case`proxies`:await bE(t.dataset.proxyId,{clearTrigger:!1}),uM();break;case`workspace`:{let e=cM.find(e=>e.fullPath===t.dataset.path);if(e){let t=document.getElementById(`userInput`);t&&t.focus(),await Gw([e]),ke()}uM();break}case`screenshot`:uM(),await(t.dataset.shotAction===`region`?iu:ru)()}}var AM=0,jM=200,MM=150,NM={promptTriggerBtn:`prompts`,addMenuSkillBtn:`skills`,addMenuMcpBtn:`mcp`,addMenuPageBtn:`pages`,addMenuKnowledgeBtn:`knowledge`,addMenuAgentBtn:`agents`,addMenuProxyBtn:`proxies`,addMenuWorkspaceBtn:`workspace`,screenshotBtn:`screenshot`};async function PM(){let e=[{id:`addMenuSkillBtn`,available:()=>QO()},{id:`addMenuMcpBtn`,available:()=>pk()},{id:`addMenuKnowledgeBtn`,available:async()=>(await vE()).ok},{id:`addMenuProxyBtn`,available:async()=>(await zT()).length>0},{id:`addMenuWorkspaceBtn`,available:async()=>!!await jl()}],t=++AM;await Promise.all(e.map(async({id:e,available:n})=>{let r=document.getElementById(e);if(!r)return;let i=!0;try{i=await n()}catch{i=!0}t===AM&&(r.style.display=i?``:`none`)}))}function FM(){let e=document.getElementById(`inputAddBtn`),t=document.getElementById(`inputAddMenu`);if(!e||!t)return;let n=e.closest(`.input-add-wrapper`),r=t.querySelector(`.input-add-nav`),i=null,a=null,o=!1,s=()=>{let e=yM()?bM():null;t.querySelectorAll(`.input-add-item`).forEach(t=>{t.classList.toggle(`panel-active`,!!e&&NM[t.id]===e)})},c=e=>{let n=document.getElementById(`inputAddPanel`);if(!n||n.style.display===`none`)return;n.style.left=``;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=r.right+8;a+i.width>window.innerWidth-8&&(a=window.innerWidth-8-i.width),a<8&&(a=8),n.style.left=`${Math.round(a-r.left)}px`;let o=e||t.querySelector(`.input-add-item.panel-active`),s=(o?o.getBoundingClientRect():r).top;s+i.height>r.bottom&&(s=r.bottom-i.height),s<8&&(s=8),n.style.top=`${Math.round(s-r.top-t.clientTop)}px`},l=n=>{t.style.display=n?``:`none`,e.classList.toggle(`open`,n),e.setAttribute(`aria-expanded`,String(n)),n?(CM(),s(),PM()):(i&&=(clearTimeout(i),null),a&&=(clearTimeout(a),null),CM(),s())},u=()=>t.style.display!==`none`;_M({onRequestClose:()=>l(!1)}),e.addEventListener(`click`,e=>{e.stopPropagation();let t=!u();t&&(kO(),UT(),Yj()),l(t)}),t.addEventListener(`click`,e=>{e.target.closest&&e.target.closest(`.input-add-item`)&&l(!1)},!0),document.addEventListener(`click`,e=>{u()&&(n&&n.contains(e.target)||l(!1))});let d=()=>{i&&=(clearTimeout(i),null),a&&clearTimeout(a),a=setTimeout(()=>{a=null,!xM()&&(CM(),s())},MM)};r&&r.addEventListener(`mouseover`,e=>{if(!u())return;let t=e.target.closest(`.input-add-item`),n=t?NM[t.id]:null;if(!n){d();return}a&&=(clearTimeout(a),null),!(yM()&&bM()===n)&&(i&&clearTimeout(i),i=setTimeout(async()=>{i=null;let e=SM(n);c(t);try{await e}catch{}c(t),s()},jM))}),t.addEventListener(`mouseenter`,()=>{o=!0,a&&=(clearTimeout(a),null)}),t.addEventListener(`mouseleave`,()=>{o=!1,d()});let f=document.getElementById(`inputAddPanelSearch`);f&&f.addEventListener(`blur`,()=>{o||d()}),window.addEventListener(`resize`,()=>{yM()&&c()}),[{id:`promptTriggerBtn`,open:()=>OO(``,`prompts`)},{id:`addMenuSkillBtn`,open:()=>OO(``,`skills`)},{id:`addMenuMcpBtn`,open:()=>OO(``,`mcp`)},{id:`addMenuPageBtn`,open:()=>VT(``,`pages`)},{id:`addMenuKnowledgeBtn`,open:()=>VT(``,`knowledge`)},{id:`addMenuAgentBtn`,open:()=>VT(``,`agents`)},{id:`addMenuProxyBtn`,open:()=>VT(``,`proxies`)},{id:`addMenuWorkspaceBtn`,open:()=>Jj(``)}].forEach(({id:e,open:t})=>{let n=document.getElementById(e);n&&n.addEventListener(`click`,async e=>{e.stopPropagation(),n.blur(),kO(),UT(),Yj();try{await t()}catch{}let r=document.getElementById(`userInput`);r&&r.focus()})});let p=document.getElementById(`inputAddMenuSwitches`),m=()=>{let t=p?.querySelector(`input[type="checkbox"]`);e.classList.toggle(`has-active-switch`,!!(t&&t.checked))};p&&(typeof MutationObserver<`u`&&new MutationObserver(m).observe(p,{subtree:!0,childList:!0}),p.addEventListener(`change`,m)),m()}r(`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 调用`}}),r(`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 IM(e,t){let n=document.getElementById(`tokenStatsOverlay`),r=document.getElementById(`tokenStatsClose`),a=document.getElementById(`tokenStatsRefreshBtn`),s=document.getElementById(`tokenStatsClearBtn`),c=document.getElementById(`tokenStatsTabNav`),l=document.getElementById(`tokenStatsTopCards`);if(!n)return;let u=`trend`,d=`month`;function f(){n.style.display=`flex`,h()}function p(){n.style.display=`none`}if(window.openTokenStats=f,r&&r.addEventListener(`click`,p),n&&n.addEventListener(`click`,e=>{e.target===n&&p()}),a&&a.addEventListener(`click`,h),s&&s.addEventListener(`click`,async()=>{await t(i(`tokenStats.clearConfirmMessage`),i(`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=`#666`}),t.classList.add(`active`),t.style.borderBottomColor=`#667eea`,t.style.color=`#667eea`,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=`#667eea`,e.style.color=`#667eea`)}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 #ddd`,e.style.background=`white`,e.style.color=`#666`}),e.classList.add(`active`),e.style.border=`1px solid #667eea`,e.style.background=`#667eea`,e.style.color=`white`,w())})});async function h(){let t=e(),n=document.getElementById(`tokenStatsLoading`),r=document.getElementById(`tokenStatsEmpty`),a=document.getElementById(`tokenStatsContent`);n&&(n.style.display=``),r&&(r.style.display=`none`),a&&(a.style.display=`none`),c&&(c.style.display=`none`),l&&(l.style.display=`none`);try{let[e,i]=await Promise.all([L(t),ie()]);if(n&&(n.style.display=`none`),!(i&&i.totalApiCalls>0)){r&&(r.style.display=``);return}a&&(a.style.display=``),c&&(c.style.display=`flex`),l&&(l.style.display=``),g(e),_(e),E(e.records||[]),x(i),w()}catch(e){o.error(`[TokenStats] load stats failed:`,e),n&&(n.style.display=`none`),r&&(r.textContent=i(`tokenStats.loadFailed`),r.style.display=``)}}function g(e){if(!l)return;if(!e||e.apiCallCount===0){l.innerHTML=``;return}let t=e.maxContextUsageRate||0,n=O(t);l.innerHTML=`
|
|
2536
2542
|
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;">
|
|
2537
2543
|
<div style="background: #f8f9ff; border-radius: 8px; padding: 10px; text-align: center;">
|
|
2538
2544
|
<div style="font-size: 10px; color: #888; margin-bottom: 4px;">${i(`tokenStats.topCardSessionTokens`)}</div>
|
|
@@ -2661,7 +2667,7 @@ Agent address: {url}
|
|
|
2661
2667
|
Are you sure you want to update the agent? It will install the latest version via npm, then restart the service. The service will be unavailable during update.`,updateAgentTitle:`Update Agent`,agentUpdating:`Updating agent (may take a few minutes)...`,agentUpdateRestarting:`Agent is updating and restarting...`,updateFailed:`Update failed: {error}`,updateRequestFailed:`Update request failed: {error}`,stopAgentConfirm:`Agent name: {name}
|
|
2662
2668
|
Agent address: {url}
|
|
2663
2669
|
|
|
2664
|
-
Are you sure you want to stop the agent service? You will not be able to connect and will need to manually restart it.`,stopAgentTitle:`Stop Agent`,agentStopped:`Agent service stopped, agent is offline`,stopFailed:`Stop failed: {error}`,stopRequestFailed:`Stop request failed: {error}`,agentStatusRefreshed:`Agent status refreshed`,deleteAgentTitle:`Delete Agent`,deleteAgentConfirm:`Are you sure you want to delete agent "{name}"? This action cannot be undone.`,welcomeTitle:`Start a Conversation`,welcomeSubtitle:`Enter your question and the AI assistant will help you`,sendBtnStop:`Stop generating`,sendBtnSend:`Send`,imageNotEnabled:`Image recognition not enabled, image attached as file`,screenshotFailed:`Screenshot failed, please retry`,auditCategoryAuth:`Auth`,auditCategoryFs:`File`,auditCategoryExec:`Command`,auditCategorySecurity:`Security`,auditCategorySystem:`System`,auditDetailSeparator:`; `,auditQueryFailed:`Query failed: {error}`,auditLoadFailed:`Load failed: {error}`,auditNoMatch:`No matching audit logs`,auditEmpty:`No audit logs`,clearStatsConfirm:`Are you sure you want to clear all tool usage stats? This action cannot be undone.`,clearStatsTitle:`Clear Stats`,toolStatsSummary:`Used {used} tools, unused {unused} tools`,toolStatsLoadFailed:`Load failed`,toolNameDescSeparator:`: `}}),window.showCustomConfirm=function(e,t=i(`sidePanel.confirmAction`)){return new Promise(n=>{let r=document.getElementById(`customConfirmOverlay`),i=document.getElementById(`customConfirmTitle`),a=document.getElementById(`customConfirmMessage`),o=document.getElementById(`customConfirmCancelBtn`),s=document.getElementById(`customConfirmOkBtn`);if(!r||!i||!a||!o||!s){n(confirm(e));return}let c=()=>{r.style.display=`none`,s.removeEventListener(`click`,l),o.removeEventListener(`click`,u),r.removeEventListener(`click`,d),document.removeEventListener(`keydown`,f)},l=()=>{c(),n(!0)},u=()=>{c(),n(!1)},d=e=>{e.target===r&&(c(),n(!1))},f=e=>{e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),l()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),u())};i.textContent=t,a.innerHTML=e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/\n/g,`<br>`),r.style.display=`flex`,s.addEventListener(`click`,l),o.addEventListener(`click`,u),r.addEventListener(`click`,d),document.addEventListener(`keydown`,f),requestAnimationFrame(()=>s.focus())})},chrome.storage.onChanged.addListener((e,t)=>{t===`local`&&e.chatMaxMemoryMessages&&(H.chatConfig.maxMemoryMessages=e.chatMaxMemoryMessages.newValue,
|
|
2670
|
+
Are you sure you want to stop the agent service? You will not be able to connect and will need to manually restart it.`,stopAgentTitle:`Stop Agent`,agentStopped:`Agent service stopped, agent is offline`,stopFailed:`Stop failed: {error}`,stopRequestFailed:`Stop request failed: {error}`,agentStatusRefreshed:`Agent status refreshed`,deleteAgentTitle:`Delete Agent`,deleteAgentConfirm:`Are you sure you want to delete agent "{name}"? This action cannot be undone.`,welcomeTitle:`Start a Conversation`,welcomeSubtitle:`Enter your question and the AI assistant will help you`,sendBtnStop:`Stop generating`,sendBtnSend:`Send`,imageNotEnabled:`Image recognition not enabled, image attached as file`,screenshotFailed:`Screenshot failed, please retry`,auditCategoryAuth:`Auth`,auditCategoryFs:`File`,auditCategoryExec:`Command`,auditCategorySecurity:`Security`,auditCategorySystem:`System`,auditDetailSeparator:`; `,auditQueryFailed:`Query failed: {error}`,auditLoadFailed:`Load failed: {error}`,auditNoMatch:`No matching audit logs`,auditEmpty:`No audit logs`,clearStatsConfirm:`Are you sure you want to clear all tool usage stats? This action cannot be undone.`,clearStatsTitle:`Clear Stats`,toolStatsSummary:`Used {used} tools, unused {unused} tools`,toolStatsLoadFailed:`Load failed`,toolNameDescSeparator:`: `}}),window.showCustomConfirm=function(e,t=i(`sidePanel.confirmAction`)){return new Promise(n=>{let r=document.getElementById(`customConfirmOverlay`),i=document.getElementById(`customConfirmTitle`),a=document.getElementById(`customConfirmMessage`),o=document.getElementById(`customConfirmCancelBtn`),s=document.getElementById(`customConfirmOkBtn`);if(!r||!i||!a||!o||!s){n(confirm(e));return}let c=()=>{r.style.display=`none`,s.removeEventListener(`click`,l),o.removeEventListener(`click`,u),r.removeEventListener(`click`,d),document.removeEventListener(`keydown`,f)},l=()=>{c(),n(!0)},u=()=>{c(),n(!1)},d=e=>{e.target===r&&(c(),n(!1))},f=e=>{e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),l()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),u())};i.textContent=t,a.innerHTML=e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/\n/g,`<br>`),r.style.display=`flex`,s.addEventListener(`click`,l),o.addEventListener(`click`,u),r.addEventListener(`click`,d),document.addEventListener(`keydown`,f),requestAnimationFrame(()=>s.focus())})},chrome.storage.onChanged.addListener((e,t)=>{t===`local`&&e.chatMaxMemoryMessages&&(H.chatConfig.maxMemoryMessages=e.chatMaxMemoryMessages.newValue,LM(),o.debug(`[SidePanel] memory limitconfiguration updated:`,H.chatConfig.maxMemoryMessages))});function LM(){let e=document.getElementById(`memoryLimitLabel`);e&&(e.textContent=H.chatConfig.maxMemoryMessages!==null&&H.chatConfig.maxMemoryMessages!==void 0&&H.chatConfig.maxMemoryMessages>0?H.chatConfig.maxMemoryMessages:i(`sidePanel.memoryLimitAll`),e.title=i(`sidePanel.memoryLimitTitle`))}function RM(e){e.preventDefault(),e.stopPropagation();let t=document.getElementById(`memoryLimitDropdown`);if(t.classList.toggle(`show`),t.classList.contains(`show`)){let e=H.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`);n.value=e!==null&&e>0?e:``}}function zM(){let e=document.getElementById(`memoryLimitDropdown`),t=document.getElementById(`memoryLimitLabel`),n=e?.querySelector(`#memoryLimitInput`);if(!e||!t)return;LM(),t.addEventListener(`click`,RM);let r=e.querySelectorAll(`.memory-limit-option`);r.forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let a=parseInt(e.dataset.value),o=a===0?null:a;r.forEach(e=>e.classList.remove(`selected`)),e.classList.add(`selected`),n&&(n.value=a===0?``:a),chrome.storage.local.set({chatMaxMemoryMessages:o},()=>{H.chatConfig.maxMemoryMessages=o,LM(),U(i(`sidePanel.configUpdated`),`success`)})})}),n&&(n.addEventListener(`click`,e=>e.stopPropagation()),n.addEventListener(`mousedown`,e=>e.stopPropagation()),n.addEventListener(`change`,e=>{e.stopPropagation();let t=e.target.value.trim(),n=t&&parseInt(t)>0?parseInt(t):null;r.forEach(e=>e.classList.remove(`selected`)),chrome.storage.local.set({chatMaxMemoryMessages:n},()=>{H.chatConfig.maxMemoryMessages=n,LM(),U(i(`sidePanel.configUpdated`),`success`)})})),document.addEventListener(`click`,n=>{!e.contains(n.target)&&n.target!==t&&e.classList.remove(`show`)})}async function BM(e){if(H.activeAgentId&&H.activeAgentId!=="default")try{let{updateAgent:t}=await fe(async()=>{let{updateAgent:e}=await import(`./agent-store-DOyMdB_7.js`).then(e=>e.t);return{updateAgent:e}},__vite__mapDeps([0,1,2,3]));await t(H.activeAgentId,{model:e})}catch{}else chrome.storage.local.set({modelName:e}),j(e)}async function VM(){try{let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),t=e.pairedAgents||[],n=e.activeAgentId,r=t.find(e=>e.id===n&&!e.disabled);if(!r){H.agentPlatform={connected:!1},XM(H.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){H.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&&H.agentVersions.set(n,t.version),t.workdir&&H.agentWorkdirs.set(n,t.workdir),t.homeDir&&H.agentHomeDirs.set(n,t.homeDir);let e=eN(t.platformName||t.platform,t.arch);e&&H.agentSystemInfos.set(n,e)}else H.agentPlatform={connected:!1}}else H.agentPlatform={connected:!1}}catch{H.agentPlatform={connected:!1}}else H.agentPlatform={connected:!1};XM(H.agentPlatform),tu()}catch{}}async function HM(e,t,n){if(H.activeAgentId&&H.activeAgentId!=="default")try{let{updateAgent:n}=await fe(async()=>{let{updateAgent:e}=await import(`./agent-store-DOyMdB_7.js`).then(e=>e.t);return{updateAgent:e}},__vite__mapDeps([0,1,2,3]));await n(H.activeAgentId,{temperature:e,topP:t})}catch{}else chrome.storage.local.set({temperature:e,topP:t,selectedTempIndex:n})}function UM(){let e=document.getElementById(`currentModelTag`);if(!e)return;let t=H.currentModel||``;e.textContent=t,e.title=t,e.style.display=t?``:`none`}function WM(){let e=document.getElementById(`currentModelTag`);e&&e.addEventListener(`click`,e=>{e.stopPropagation(),document.getElementById(`tempDisplay`)?.click()}),UM()}function GM(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=d(t),r.style.display=``):r.style.display=`none`),UM()}function KM(e,t){let n=document.getElementById(`tempDropdown`);if(!n){typeof t==`function`&&t();return}let r=n.querySelector(`.model-section`),a=[];if((Array.isArray(e)?e:[]).forEach(e=>{typeof e==`string`?a.push({name:e,contextWindow:0}):e&&typeof e==`object`&&e.name&&a.push({name:e.name,contextWindow:e.contextWindow||0})}),r){r.innerHTML=`
|
|
2665
2671
|
<div class="model-section-title" data-i18n="model.selectModel">${i(`model.selectModel`)}</div>
|
|
2666
2672
|
<div class="section-select" id="modelSelect">
|
|
2667
2673
|
<div class="section-select-row" id="modelSelectRow">
|
|
@@ -2670,15 +2676,15 @@ Are you sure you want to stop the agent service? You will not be able to connect
|
|
|
2670
2676
|
<span class="section-select-caret"></span>
|
|
2671
2677
|
</div>
|
|
2672
2678
|
<div class="section-select-list" id="modelSelectList"></div>
|
|
2673
|
-
</div>`;let e=r.querySelector(`#modelSelectList`);e.innerHTML=
|
|
2679
|
+
</div>`;let e=r.querySelector(`#modelSelectList`);e.innerHTML=xj();let t=[...a].sort((e,t)=>T(e.name,t.name));for(let n of t){let t=document.createElement(`div`);t.className=`model-option`,t.dataset.value=n.name,n.contextWindow&&n.contextWindow>0&&(t.dataset.contextWindow=n.contextWindow),t.innerHTML=`<span class="model-option-check"></span><span class="model-option-left">${W(n.name)}</span>`;let r=document.createElement(`span`);r.className=`model-option-right`;let a=document.createElement(`span`);a.className=`model-ctx-badge`;let o=n.contextWindow&&n.contextWindow>0;a.textContent=d(o?n.contextWindow:g(n.name)),o||(a.classList.add(`is-auto`),a.title=i(`settings.ctxBadgeAutoTip`)),r.appendChild(a),t.appendChild(r),t.addEventListener(`click`,e=>{e.stopPropagation(),bj(),H.currentModel=n.name,GM(n.name),BM(n.name)}),e.appendChild(t)}}H.customModelMap=v(e),typeof t==`function`&&t()}function qM(e,t=i(`sidePanel.selectedPrefix`)){if(!H.enableSelectionQuery)return;H.quotedContextText=``,H.selectedContextText=e;let n=document.getElementById(`selectionIndicator`),r=document.getElementById(`selectionText`),a=document.getElementById(`userInput`);if(n&&r&&a){let i;i=e.length>100?e.substring(0,100)+`...`:e.length>50?e.substring(0,50)+`...`:e,r.textContent=`${t}: ${i}`,n.classList.add(`show`)}}function JM(e,t,n=0,r=0){if(!H.enableSelectionQuery)return;let a=document.getElementById(`selectionFloatingMenu`),s=document.getElementById(`selectionMenuItems`);if(!a||!s){let e=document.getElementById(`chatContainer`);if(!e)return;a=document.createElement(`div`),a.className=`selection-floating-menu`,a.id=`selectionFloatingMenu`,a.innerHTML=`
|
|
2674
2680
|
<div class="menu-header">${i(`sidePanel.askBasedOnSelection`)}</div>
|
|
2675
2681
|
<div id="selectionMenuItems"></div>
|
|
2676
2682
|
`,e.appendChild(a),s=document.getElementById(`selectionMenuItems`)}let c=H.customPrompts.filter(e=>e.enabledInMenu===!0);if(c.length===0){o.debug(`[SidePanel] showFloatingMenu skipped: no prompts enabled in menu`);return}s.innerHTML=``,c.forEach(e=>{let n=e.content.length>10?e.content.substring(0,10)+`...`:e.content,r=document.createElement(`div`);r.className=`menu-item`,r.innerHTML=`
|
|
2677
2683
|
<span>${n}</span>
|
|
2678
2684
|
<span class="menu-item-code">/${e.code}</span>
|
|
2679
|
-
`,r.addEventListener(`click`,n=>{n.stopPropagation(),
|
|
2685
|
+
`,r.addEventListener(`click`,n=>{n.stopPropagation(),YM(e,t)}),s.appendChild(r)});let l=document.body.getBoundingClientRect(),u=40+c.length*36,d=r-l.top-u-30,f=n-l.left-20;d<l.top+10&&(d=r-l.top+30),f<l.left+10&&(f=n-l.left+20),f+180>l.right-10&&(f=n-l.left-180-30,f<l.left+10&&(f=n-l.left+20)),d+u>l.bottom-10&&(d=r-l.top-u-30,d<l.top+10&&(d=r-l.top+30)),a.style.top=d+`px`,a.style.left=f+`px`,a.style.maxHeight=l.bottom-d-20+`px`,a.classList.add(`show`)}window.hideFloatingMenu=function(){let e=document.getElementById(`selectionFloatingMenu`);e&&e.classList.remove(`show`),H.lastSelectedText=``,H.currentSelectionRange=null};async function YM(e,t){if(!H.enableSelectionQuery)return;if(window.hideFloatingMenu(),H.isGenerating){o.debug(`[SidePanel] generating,please wait...`);return}H.selectedContextText=t,BD();let n=document.getElementById(`chatContainer`).querySelector(`.welcome-message`);n&&n.remove(),iO(`selected`,t,!1);let{compressed:r,wasCompressed:a}=y(t),s=`[${i(`sidePanel.selectedContentLabel`)}${a?i(`sidePanel.selectedContentSummary`):``}]\n${r}\n\n[${i(`sidePanel.userQuestionLabel`)}]\n${e.content}`,{messageId:c,timestamp:l}=sO(`user`,e.content,!0,[],null,!1,s);H.messageHistory.push({role:`user`,content:s,messageId:c,timestamp:l}),GD(),lt(e.content),H.isGenerating=!0;let u=pO(),d=H.activeSessionId,f=H.currentModel;try{await Ze(),o.debug(`[SidePanel] sendmessagedebuginfo:`),o.debug(` - isolateChat:`,H.isolateChat),o.debug(` - chatConfig:`,H.chatConfig),o.debug(` - messageHistory.length:`,H.messageHistory.length);let e=[{role:`system`,content:await Ke()}];if(H.isolateChat){let t=k(e[0]?.content||``),n=E(f,0,H.customModelMap)-t-4096-2e3,r=Math.floor(n*.7),i=H.messageHistory[H.messageHistory.length-1],a=at(H.messageHistory.slice(0,-1),{isolateChat:!0,maxMemoryMessages:H.chatConfig.maxMemoryMessages,compaction:H.activeCompaction,historyBudget:r,currentMessage:i});a.compactionApplied?e[0]={...e[0],content:ot(e[0].content,H.activeCompaction)}:H.activeCompaction&&o.warn(`[SidePanel] contextCompaction invalid (upToMessageId not found), ignored this send`),a.historySummaryText&&(e[0]={...e[0],content:e[0].content+`
|
|
2680
2686
|
|
|
2681
|
-
`+a.historySummaryText}),e=[...e,...a.messages];for(let t=0;t<e.length-1;t++)e[t]={...e[t],content:p(e[t].content)}}else e.push({role:`user`,content:s});let t=await Ye(),n,r;try{let i=await
|
|
2687
|
+
`+a.historySummaryText}),e=[...e,...a.messages];for(let t=0;t<e.length-1;t++)e[t]={...e[t],content:p(e[t].content)}}else e.push({role:`user`,content:s});let t=await Ye(),n,r;try{let i=await SO(e,f,H.useTools,t);if(n=i.content,r=i.executionLog||[],mO(u),i.wasStreamed)i.streamingMsgId&&(H.messageHistory.push({role:`assistant`,content:n,executionLog:r,messageId:i.streamingMsgId}),GD());else{let{element:e,messageId:t}=sO(`assistant`,n,!0,r);await Ui(e),H.messageHistory.push({role:`assistant`,content:n,executionLog:r,messageId:t}),GD()}ts(d);return}catch(e){mO(u),n=i(`sidePanel.requestFailed`)+(e.message||i(`sidePanel.unknownError`)),r=e.executionLog||[];let{element:t,messageId:a}=sO(`assistant`,n,!0,r);throw H.messageHistory.push({role:`assistant`,content:n,executionLog:r,messageId:a}),GD(),e.message!==i(`chatMsg.errTaskStopped`)&&ns(d,n),e}}catch{}finally{H.generatingSessionIds.delete(d),Dt(d),document.dispatchEvent(new CustomEvent(`generating-state-changed`)),document.getElementById(`userInput`).focus()}}async function XM(e,t=!1){let n=document.getElementById(`headerAgentDot`),r=document.getElementById(`headerAgentName`),a=document.getElementById(`headerAgentTrigger`);if(!n||!r)return;let o=null,s=[];try{let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]);s=e.pairedAgents||[],o=s.find(t=>t.id===e.activeAgentId)}catch{}let c=e?.connected===!0;if(!c||!o?(n.className=`header-agent-dot disconnected`,r.textContent=o?o.name.length>12?o.name.substring(0,12)+`...`:o.name:i(`sidePanel.notConnected`),r.classList.toggle(`truncated`,!!o),a.title=o?o.name:``):(n.className=`header-agent-dot connected`,r.textContent=o.name.length>12?o.name.substring(0,12)+`...`:o.name,r.classList.toggle(`truncated`,o.name.length>12),a.title=o.name),ZM(o,s,c),!t){let e=document.getElementById(`headerAgentDropdown`);e&&e.style.display!==`none`&&rN()}hw(c)}function ZM(e,t,n){let r=document.getElementById(`agentDdList`),a=document.getElementById(`agentDdCopyRow`);if(!r||!a)return;if(e?.url?(a.style.display=``,a.querySelector(`.agent-dd-copy-label`).textContent=e.url):a.style.display=`none`,t.length===0){r.innerHTML=`<div class="agent-dd-empty">`+i(`sidePanel.noPairedAgents`)+`</div>`;let e=document.getElementById(`agentDdRestartBtn`),t=document.getElementById(`agentDdUpdateBtn`),n=document.getElementById(`agentDdStopBtn`);e&&(e.disabled=!0),t&&(t.disabled=!0),n&&(n.disabled=!0);return}r.innerHTML=t.map(t=>{let r=t.id===e?.id,a=!!t.disabled,o=H.agentVersions.get(t.id),s,c;a?(s=`disabled`,c=i(`sidePanel.agentDisabled`)):r?(s=n?`connected`:`disconnected`,c=i(n?`sidePanel.agentConnected`:`sidePanel.notConnected`)):(s=`checking`,c=i(`sidePanel.agentChecking`));let l=H.agentWorkdirs.get(t.id),u=$M(l,H.agentHomeDirs.get(t.id)),d=H.agentSystemInfos.get(t.id);return`
|
|
2682
2688
|
<div class="agent-dd-item${r?` active`:``}${a?` disabled`:``}" data-agent-id="${t.id}">
|
|
2683
2689
|
<span class="agent-dd-item-dot ${s}"></span>
|
|
2684
2690
|
<div class="agent-dd-item-info">
|
|
@@ -2695,7 +2701,7 @@ Are you sure you want to stop the agent service? You will not be able to connect
|
|
|
2695
2701
|
<button class="agent-dd-tool-btn delete" data-action="delete" data-id="${t.id}" title="${i(`sidePanel.deleteAgentBtn`)}">🗑</button>
|
|
2696
2702
|
</div>
|
|
2697
2703
|
</div>
|
|
2698
|
-
`}).join(``);let o=document.getElementById(`agentDdRestartBtn`),s=document.getElementById(`agentDdUpdateBtn`),c=document.getElementById(`agentDdStopBtn`),l=!!(e&&n);o&&(o.disabled=!l),s&&(s.disabled=!l),c&&(c.disabled=!l)}async function ZM(e,t){if(t)try{let n=new AbortController;setTimeout(()=>n.abort(),2e3);let r=await fetch(`${e}/api/status/detail`,{signal:n.signal,headers:{Authorization:`Bearer ${t}`}});if(r.ok){let e=await r.json();if(e.success)return{online:!0,version:e.version||null,workdir:e.workdir||null,homeDir:e.homeDir||null,platformName:e.platformName||e.platform||null,arch:e.arch||null}}}catch{}try{let t=new AbortController;setTimeout(()=>t.abort(),2e3);let n=await fetch(`${e}/api/status`,{signal:t.signal});if(!n.ok)return{online:!1,version:null,workdir:null,homeDir:null,platformName:null,arch:null};let r=await n.json();return{online:!0,version:r.version||null,workdir:null,homeDir:null,platformName:r.platformName||r.platform||null,arch:r.arch||null}}catch{return{online:!1,version:null,workdir:null,homeDir:null,platformName:null,arch:null}}}function QM(e,t){return e?t&&e.startsWith(t)?`~`+e.substring(t.length):e:``}function $M(e,t){return e||``}function eN(e,t){let n=document.querySelector(`.agent-dd-item[data-agent-id="${e}"]`);if(!n)return;let r=n.querySelector(`.agent-dd-item-dot`),a=n.querySelector(`.agent-dd-item-status`),o=n.classList.contains(`active`);r&&(r.classList.remove(`checking`,`connected`,`disconnected`,`online`,`offline`),r.classList.add(o?t?`connected`:`disconnected`:t?`online`:`offline`)),a&&(o?a.textContent=i(t?`sidePanel.agentConnected`:`sidePanel.notConnected`):a.textContent===i(`sidePanel.agentChecking`)&&(a.textContent=i(t?`sidePanel.agentOnline`:`sidePanel.agentOffline`)))}function tN(e,t){if(!t)return;let n=document.querySelector(`.agent-dd-item[data-agent-id="${e}"]`);if(!n)return;let r=n.querySelector(`.agent-dd-item-info`);if(!r)return;let a=QM(t,H.agentHomeDirs.get(e)),o=r.querySelector(`.agent-dd-item-workdir`);o?(o.textContent=a,o.title=i(`sidePanel.workingDirectory`,{path:t})):(o=document.createElement(`span`),o.className=`agent-dd-item-workdir`,o.title=i(`sidePanel.workingDirectory`,{path:t}),o.textContent=a,r.appendChild(o))}window.updateAgentItemWorkdir=tN;async function nN(){try{let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),t=e.pairedAgents||[],n=e.activeAgentId;await Promise.all(t.filter(e=>!e.disabled).map(async e=>{let t=await ZM(e.url,e.token),r=t.online;t.version&&H.agentVersions.set(e.id,t.version),t.workdir&&H.agentWorkdirs.set(e.id,t.workdir),t.homeDir&&H.agentHomeDirs.set(e.id,t.homeDir);let i=$M(t.platformName,t.arch);i&&H.agentSystemInfos.set(e.id,i),t.workdir&&tN(e.id,t.workdir),eN(e.id,r),e.id===n&&r!==(H.agentPlatform?.connected===!0)&&(H.agentPlatform={...H.agentPlatform,connected:r},YM(H.agentPlatform,!0),r&&rN(e))}))}catch{}}async function rN(e){try{let t=e;if(!t){let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=e.pairedAgents||[],r=e.activeAgentId;t=n.find(e=>e.id===r&&!e.disabled)}if(!t||!t.url){H.agentPlatform={...H.agentPlatform,connected:!0},YM(H.agentPlatform),tu();return}if(t.token)try{let e=new AbortController;setTimeout(()=>e.abort(),3e3);let n=await fetch(`${t.url}/api/status/detail`,{signal:e.signal,headers:{Authorization:`Bearer ${t.token}`}});if(n.ok){let e=await n.json();if(e.success){H.agentPlatform={platformName:e.platformName||`Unknown`,platform:e.platform||`unknown`,arch:e.arch||`unknown`,shell:e.shell||`/bin/sh`,homeDir:e.homeDir||``,workdir:e.workdir||``,connected:!0},e.version&&H.agentVersions.set(t.id,e.version),e.workdir&&(H.agentWorkdirs.set(t.id,e.workdir),tN(t.id,e.workdir)),e.homeDir&&H.agentHomeDirs.set(t.id,e.homeDir);let n=$M(e.platformName||e.platform,e.arch);n&&H.agentSystemInfos.set(t.id,n),YM(H.agentPlatform),tu();return}}}catch{}try{let e=new abortController;setTimeout(()=>e.abort(),3e3);let n=await fetch(`${t.url}/api/status`,{signal:e.signal});if(n.ok){let e=await n.json();H.agentPlatform={platformName:e.platformName||e.platform||`Unknown`,platform:e.platform||`unknown`,arch:e.arch||`unknown`,connected:!0},YM(H.agentPlatform),tu();return}}catch{}H.agentPlatform={...H.agentPlatform,connected:!0},YM(H.agentPlatform),tu()}catch{H.agentPlatform={...H.agentPlatform,connected:!0},YM(H.agentPlatform),tu()}}var iN=null;function aN(e,t=20){iN&&clearInterval(iN);let n=0;iN=setInterval(async()=>{if(n++,n>t||!e){clearInterval(iN),iN=null;return}try{let t=((await chrome.storage.local.get([`pairedAgents`])).pairedAgents||[]).find(t=>t.id===e);if(!t){clearInterval(iN),iN=null;return}let n=await ZM(t.url,t.token);if(n.online){clearInterval(iN),iN=null,n.version&&H.agentVersions.set(e,n.version),n.workdir&&H.agentWorkdirs.set(e,n.workdir),n.homeDir&&H.agentHomeDirs.set(e,n.homeDir);let r=$M(n.platformName,n.arch);r&&H.agentSystemInfos.set(e,r),n.workdir&&tN(e,n.workdir),await rN(t),eN(e,!0)}}catch{}},3e3)}function oN(){let e=document.getElementById(`headerAgentDropdown`),t=document.getElementById(`headerAgentWrapper`);if(!e||!t)return;let n=document.body.clientWidth,r=t.getBoundingClientRect(),i=e.offsetWidth;n<312?(e.style.minWidth=n-16+`px`,e.style.maxWidth=n-16+`px`):(e.style.minWidth=``,e.style.maxWidth=``);let a=r.right+20-i,o=n-i-8;a=Math.max(8,Math.min(o,a)),e.style.left=a-r.left+`px`}async function sN(){let e=document.getElementById(`headerAgentTrigger`),t=document.getElementById(`headerAgentDropdown`),n=document.getElementById(`agentDdCopyBtn`),r=document.getElementById(`agentDdAddBtn`),a=document.getElementById(`agentDdRestartBtn`),o=document.getElementById(`agentDdUpdateBtn`),s=document.getElementById(`agentDdStopBtn`),c=document.getElementById(`agentDdRefreshBtn`);if(!e||!t)return;e.addEventListener(`click`,e=>{e.stopPropagation();let n=t.style.display!==`none`;t.style.display=n?`none`:``,n||(oN(),YM(H.agentPlatform||{}),nN())}),document.addEventListener(`click`,n=>{!t.contains(n.target)&&n.target!==e&&(t.style.display=`none`)}),n.addEventListener(`click`,async e=>{e.stopPropagation(),H.activeAgentId;let t=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=(t.pairedAgents||[]).find(e=>e.id===t.activeAgentId);n?.url&&(await navigator.clipboard.writeText(n.url),U(i(`sidePanel.agentAddressCopied`),`success`))}),r.addEventListener(`click`,async()=>{t.style.display=`none`,await chrome.storage.local.set({optionsInitialTab:`agent`});let e=await chrome.tabs.query({}),n=chrome.runtime.getURL(`options/index.html`),r=e.find(e=>e.url&&e.url.startsWith(n));if(r){chrome.tabs.update(r.id,{active:!0});try{chrome.tabs.sendMessage(r.id,{type:`SWITCH_TAB`,tab:`agent`})}catch{}}else chrome.runtime.openOptionsPage()}),a.addEventListener(`click`,async()=>{t.style.display=`none`;let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=(e.pairedAgents||[]).find(t=>t.id===e.activeAgentId),r=n?.name||i(`sidePanel.unknownAgent`),a=n?.url||i(`sidePanel.unknownAgent`);if(await window.showCustomConfirm(i(`sidePanel.restartAgentConfirm`,{name:r,url:a}),i(`sidePanel.restartAgentTitle`)))try{chrome.runtime.sendMessage({type:`AGENT_RESTART`},async e=>{e?.success?(U(i(`sidePanel.agentRestarting`),`success`),H.agentPlatform={...H.agentPlatform,connected:!1},await YM(H.agentPlatform,!0),n?.id&&eN(n.id,!1),aN(n?.id)):U(i(`sidePanel.restartFailed`,{error:e?.error||i(`sidePanel.unknownError`)}),`error`)})}catch(e){U(i(`sidePanel.restartRequestFailed`,{error:e.message}),`error`)}}),o.addEventListener(`click`,async()=>{t.style.display=`none`;let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=(e.pairedAgents||[]).find(t=>t.id===e.activeAgentId),r=n?.name||i(`sidePanel.unknownAgent`),a=n?.url||i(`sidePanel.unknownAgent`);if(await window.showCustomConfirm(i(`sidePanel.updateAgentConfirm`,{name:r,url:a}),i(`sidePanel.updateAgentTitle`))){U(i(`sidePanel.agentUpdating`),`info`);try{chrome.runtime.sendMessage({type:`AGENT_UPDATE`},async e=>{e?.success?(U(i(`sidePanel.agentUpdateRestarting`),`success`),H.agentPlatform={...H.agentPlatform,connected:!1},await YM(H.agentPlatform,!0),n?.id&&eN(n.id,!1),aN(n?.id)):U(i(`sidePanel.updateFailed`,{error:e?.error||i(`sidePanel.unknownError`)}),`error`)})}catch(e){U(i(`sidePanel.updateRequestFailed`,{error:e.message}),`error`)}}}),s.addEventListener(`click`,async()=>{t.style.display=`none`;let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=(e.pairedAgents||[]).find(t=>t.id===e.activeAgentId),r=n?.name||i(`sidePanel.unknownAgent`),a=n?.url||i(`sidePanel.unknownAgent`);if(await window.showCustomConfirm(i(`sidePanel.stopAgentConfirm`,{name:r,url:a}),i(`sidePanel.stopAgentTitle`)))try{chrome.runtime.sendMessage({type:`AGENT_STOP`},async e=>{e?.success?(U(i(`sidePanel.agentStopped`),`success`),H.agentPlatform={...H.agentPlatform,connected:!1},await YM(H.agentPlatform,!0),n?.id&&eN(n.id,!1)):U(i(`sidePanel.stopFailed`,{error:e?.error||i(`sidePanel.unknownError`)}),`error`)})}catch(e){U(i(`sidePanel.stopRequestFailed`,{error:e.message}),`error`)}}),c&&c.addEventListener(`click`,async()=>{document.querySelectorAll(`.agent-dd-item-dot`).forEach(e=>{e.classList.remove(`online`,`offline`),e.classList.add(`checking`)}),document.querySelectorAll(`.agent-dd-item-status`).forEach(e=>{e.textContent=i(`sidePanel.agentChecking`)}),await nN(),U(i(`sidePanel.agentStatusRefreshed`),`success`)}),document.getElementById(`agentDdList`).addEventListener(`click`,async e=>{let t=e.target.closest(`.agent-dd-tool-btn`),n=e.target.closest(`.agent-dd-item`);if(t){e.stopPropagation(),l(t.dataset.action,t.dataset.id);return}n&&!n.classList.contains(`disabled`)&&!n.classList.contains(`active`)&&(e.stopPropagation(),l(`switch`,n.dataset.agentId))});async function l(e,t){let n=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),r=n.pairedAgents||[];switch(e){case`enable`:r=r.map(e=>e.id===t?{...e,disabled:!1}:e),await chrome.storage.local.set({pairedAgents:r});break;case`disable`:{r=r.map(e=>e.id===t?{...e,disabled:!0}:e);let e=n.activeAgentId;n.activeAgentId===t&&(e=r.find(e=>e.id!==t&&!e.disabled)?.id||null),await chrome.storage.local.set({pairedAgents:r,activeAgentId:e||``}),e?chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!0,agentId:e}):chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!1});break}case`switch`:await chrome.storage.local.set({activeAgentId:t}),chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!0,agentId:t});break;case`disconnect`:await chrome.storage.local.set({activeAgentId:``}),chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!1});break;case`delete`:{let e=r.find(e=>e.id===t);if(!await window.showCustomConfirm(i(`sidePanel.deleteAgentTitle`),i(`sidePanel.deleteAgentConfirm`,{name:e?.name||t})))return;r=r.filter(e=>e.id!==t);let a=n.activeAgentId===t?r.find(e=>!e.disabled)?.id||null:n.activeAgentId;await chrome.storage.local.set({pairedAgents:r,activeAgentId:a||``}),a?chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!0,agentId:a}):chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!1});break}}let a=document.getElementById(`headerAgentDropdown`);a&&(a.style.display=`none`)}}var cN=new Map,lN=8;function uN(e,t){for(cN.has(e)&&cN.delete(e),cN.set(e,t);cN.size>lN;)cN.delete(cN.keys().next().value)}function dN(e){let t=cN.get(e);if(t!==void 0)return cN.delete(e),cN.set(e,t),t}function fN(e){cN.delete(e)}document.addEventListener(`DOMContentLoaded`,async()=>{Oo(),await Promise.allSettled([a().then(()=>{s(),bn(),l(()=>{s(),bn()})}),Qe(),ID(),Tt()]),window.__tableBlocks=[],chrome.runtime.onMessage.addListener(e=>{if(e.type===`SCHEDULED_SESSION_UPDATED`){let t=e.sessionId;t===H.activeSessionId?HD().catch(()=>{}):t&&(Dt(t).catch(()=>{}),document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:t}})));return}if(e.type===`CLOSE_SIDEPANEL`){o.debug(`[SidePanel] recei to CLOSE_SIDEPANEL,closesidebar`);try{window.close()}catch{}return}if(e.type===`SELECTION_AI_SEARCH`&&e.prompt&&(o.debug(`[SidePanel] received selectedtext AI search:`,e.selectedText?.substring(0,50)),e.selectedText&&KM(e.selectedText),eO(e.prompt,e.selectedText),chrome.storage.session.remove(`pendingSelectionSearch`).catch(()=>{})),e.type===`FILL_SIDEPANEL_INPUT`&&e.text&&(o.debug(`[SidePanel] received follow-upfill:`,e.text?.substring(0,50)),tO(e.text),chrome.storage.session.remove(`pendingFillInput`).catch(()=>{})),e.type===`DIRECT_SEND`&&e.text&&(o.debug(`[SidePanel] received directsend:`,e.text?.substring(0,50)),e.selectedText&&KM(e.selectedText),nO(e.text,e.selectedText||``),chrome.storage.session.remove(`pendingDirectSend`).catch(()=>{})),e.type===`AGENT_STATUS_CHANGE`&&(o.debug(`[SidePanel] recei to Agent status change:`,e.connected,e.status),H.agentPlatform={...H.agentPlatform,connected:e.connected},YM(H.agentPlatform),tu(),Sn(),e.connected&&rN()),e.type===`AGENT_CONNECTION_CHANGED`){if(o.debug(`[SidePanel] recei to Agent connection statuschanged:`,e.connected,e.agentId),!e.connected){H.agentPlatform={connected:!1},YM(H.agentPlatform),tu(),Sn();return}e.agentId&&(async()=>{try{let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),t=(e.pairedAgents||[]).find(t=>t.id===e.activeAgentId&&!t.disabled);if(!t){H.agentPlatform={connected:!1},YM(H.agentPlatform),tu(),Sn(),pw();return}if(t.token)try{let n=await fetch(`${t.url}/api/status/detail`,{cache:`no-cache`,headers:{Authorization:`Bearer ${t.token}`}});if(n.ok){let t=await n.json();if(t.success){H.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&&H.agentVersions.set(e.activeAgentId,t.version),t.workdir&&H.agentWorkdirs.set(e.activeAgentId,t.workdir),t.homeDir&&H.agentHomeDirs.set(e.activeAgentId,t.homeDir);let n=$M(t.platformName||t.platform,t.arch);n&&H.agentSystemInfos.set(e.activeAgentId,n)}else H.agentPlatform={connected:!1}}else H.agentPlatform={connected:!1}}catch{H.agentPlatform={connected:!1}}else try{let n=await fetch(`${t.url}/api/status`,{cache:`no-cache`});if(n.ok){let t=await n.json();H.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&&H.agentVersions.set(e.activeAgentId,t.version);let r=$M(t.platformName||t.platform,t.arch);r&&H.agentSystemInfos.set(e.activeAgentId,r)}else H.agentPlatform={connected:!1}}catch{H.agentPlatform={connected:!1}}}catch{H.agentPlatform={connected:!1}}YM(H.agentPlatform),tu(),Sn(),pw()})()}e.type===`SCREENSHOT_RESULT`&&e.dataUrl&&(o.debug(`[SidePanel] received pageshortcutscreenshotresult:`,e.mode),ou(e.dataUrl,e.mode,e.rect))});async function e(e){try{let t=await chrome.sidePanel.getOptions({tabId:e});return typeof t?.enabled==`boolean`?t.enabled:(await chrome.sidePanel.getOptions({}))?.enabled!==!1}catch{return!0}}chrome.tabs.onActivated.addListener(async t=>{if(o.debug(`[SidePanel] Tab switch, new Tab ID:`,t.tabId),!await e(t.tabId)){o.debug(`[SidePanel] Tab 无侧边栏,保持 currentTabId:`,H.currentTabId);return}H.currentTabId=t.tabId}),chrome.tabs.onUpdated.addListener(async(e,t)=>{t.status===`complete`&&H.currentTabId===e&&o.debug(`[SidePanel] current Tab page update:`,t)}),typeof marked<`u`&&(marked.setOptions({breaks:!0,gfm:!0}),o.debug(`[SidePanel] Marked library loaded`));let t=document.getElementById(`userInput`),n=document.getElementById(`sendBtn`),r=document.getElementById(`clearChatBtn`),c=document.getElementById(`exportChatBtn`),u=document.getElementById(`chatContainer`),d=document.getElementById(`tempDisplay`),p=document.getElementById(`tempDropdown`),m=document.getElementById(`tempPresetList`),h=document.getElementById(`tempSlider`),g=document.getElementById(`tempNumberInput`);function _(){if(!t||H.isScrolling)return;t.style.height=`auto`;let e=t.scrollHeight;e<=50?t.style.height=``:t.style.height=Math.min(e,100)+`px`,Ae()}chrome.storage.local.get([`temperature`,`topP`,`selectedTempIndex`],e=>{(!H.activeAgentId||H.activeAgentId==="default")&&(e.temperature!==void 0&&(H.temperature=e.temperature),e.topP!==void 0&&(H.topP=e.topP),e.selectedTempIndex!==void 0&&(H.selectedTempIndex=e.selectedTempIndex)),v()});function v(){h&&(h.value=H.temperature),g&&(g.value=H.temperature.toFixed(2));let e=document.getElementById(`tempIconValue`);e&&(e.textContent=H.temperature.toFixed(2)),b()}function y(){let e=0,t=Math.abs(Oe[0].temp-H.temperature);for(let n=1;n<Oe.length;n++){let r=Math.abs(Oe[n].temp-H.temperature);r<t&&(t=r,e=n)}return e}function b(){let e=y();m.innerHTML=Oe.map((t,n)=>`
|
|
2704
|
+
`}).join(``);let o=document.getElementById(`agentDdRestartBtn`),s=document.getElementById(`agentDdUpdateBtn`),c=document.getElementById(`agentDdStopBtn`),l=!!(e&&n);o&&(o.disabled=!l),s&&(s.disabled=!l),c&&(c.disabled=!l)}async function QM(e,t){if(t)try{let n=new AbortController;setTimeout(()=>n.abort(),2e3);let r=await fetch(`${e}/api/status/detail`,{signal:n.signal,headers:{Authorization:`Bearer ${t}`}});if(r.ok){let e=await r.json();if(e.success)return{online:!0,version:e.version||null,workdir:e.workdir||null,homeDir:e.homeDir||null,platformName:e.platformName||e.platform||null,arch:e.arch||null}}}catch{}try{let t=new AbortController;setTimeout(()=>t.abort(),2e3);let n=await fetch(`${e}/api/status`,{signal:t.signal});if(!n.ok)return{online:!1,version:null,workdir:null,homeDir:null,platformName:null,arch:null};let r=await n.json();return{online:!0,version:r.version||null,workdir:null,homeDir:null,platformName:r.platformName||r.platform||null,arch:r.arch||null}}catch{return{online:!1,version:null,workdir:null,homeDir:null,platformName:null,arch:null}}}function $M(e,t){return e?t&&e.startsWith(t)?`~`+e.substring(t.length):e:``}function eN(e,t){return e||``}function tN(e,t){let n=document.querySelector(`.agent-dd-item[data-agent-id="${e}"]`);if(!n)return;let r=n.querySelector(`.agent-dd-item-dot`),a=n.querySelector(`.agent-dd-item-status`),o=n.classList.contains(`active`);r&&(r.classList.remove(`checking`,`connected`,`disconnected`,`online`,`offline`),r.classList.add(o?t?`connected`:`disconnected`:t?`online`:`offline`)),a&&(o?a.textContent=i(t?`sidePanel.agentConnected`:`sidePanel.notConnected`):a.textContent===i(`sidePanel.agentChecking`)&&(a.textContent=i(t?`sidePanel.agentOnline`:`sidePanel.agentOffline`)))}function nN(e,t){if(!t)return;let n=document.querySelector(`.agent-dd-item[data-agent-id="${e}"]`);if(!n)return;let r=n.querySelector(`.agent-dd-item-info`);if(!r)return;let a=$M(t,H.agentHomeDirs.get(e)),o=r.querySelector(`.agent-dd-item-workdir`);o?(o.textContent=a,o.title=i(`sidePanel.workingDirectory`,{path:t})):(o=document.createElement(`span`),o.className=`agent-dd-item-workdir`,o.title=i(`sidePanel.workingDirectory`,{path:t}),o.textContent=a,r.appendChild(o))}window.updateAgentItemWorkdir=nN;async function rN(){try{let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),t=e.pairedAgents||[],n=e.activeAgentId;await Promise.all(t.filter(e=>!e.disabled).map(async e=>{let t=await QM(e.url,e.token),r=t.online;t.version&&H.agentVersions.set(e.id,t.version),t.workdir&&H.agentWorkdirs.set(e.id,t.workdir),t.homeDir&&H.agentHomeDirs.set(e.id,t.homeDir);let i=eN(t.platformName,t.arch);i&&H.agentSystemInfos.set(e.id,i),t.workdir&&nN(e.id,t.workdir),tN(e.id,r),e.id===n&&r!==(H.agentPlatform?.connected===!0)&&(H.agentPlatform={...H.agentPlatform,connected:r},XM(H.agentPlatform,!0),r&&iN(e))}))}catch{}}async function iN(e){try{let t=e;if(!t){let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=e.pairedAgents||[],r=e.activeAgentId;t=n.find(e=>e.id===r&&!e.disabled)}if(!t||!t.url){H.agentPlatform={...H.agentPlatform,connected:!0},XM(H.agentPlatform),tu();return}if(t.token)try{let e=new AbortController;setTimeout(()=>e.abort(),3e3);let n=await fetch(`${t.url}/api/status/detail`,{signal:e.signal,headers:{Authorization:`Bearer ${t.token}`}});if(n.ok){let e=await n.json();if(e.success){H.agentPlatform={platformName:e.platformName||`Unknown`,platform:e.platform||`unknown`,arch:e.arch||`unknown`,shell:e.shell||`/bin/sh`,homeDir:e.homeDir||``,workdir:e.workdir||``,connected:!0},e.version&&H.agentVersions.set(t.id,e.version),e.workdir&&(H.agentWorkdirs.set(t.id,e.workdir),nN(t.id,e.workdir)),e.homeDir&&H.agentHomeDirs.set(t.id,e.homeDir);let n=eN(e.platformName||e.platform,e.arch);n&&H.agentSystemInfos.set(t.id,n),XM(H.agentPlatform),tu();return}}}catch{}try{let e=new abortController;setTimeout(()=>e.abort(),3e3);let n=await fetch(`${t.url}/api/status`,{signal:e.signal});if(n.ok){let e=await n.json();H.agentPlatform={platformName:e.platformName||e.platform||`Unknown`,platform:e.platform||`unknown`,arch:e.arch||`unknown`,connected:!0},XM(H.agentPlatform),tu();return}}catch{}H.agentPlatform={...H.agentPlatform,connected:!0},XM(H.agentPlatform),tu()}catch{H.agentPlatform={...H.agentPlatform,connected:!0},XM(H.agentPlatform),tu()}}var aN=null;function oN(e,t=20){aN&&clearInterval(aN);let n=0;aN=setInterval(async()=>{if(n++,n>t||!e){clearInterval(aN),aN=null;return}try{let t=((await chrome.storage.local.get([`pairedAgents`])).pairedAgents||[]).find(t=>t.id===e);if(!t){clearInterval(aN),aN=null;return}let n=await QM(t.url,t.token);if(n.online){clearInterval(aN),aN=null,n.version&&H.agentVersions.set(e,n.version),n.workdir&&H.agentWorkdirs.set(e,n.workdir),n.homeDir&&H.agentHomeDirs.set(e,n.homeDir);let r=eN(n.platformName,n.arch);r&&H.agentSystemInfos.set(e,r),n.workdir&&nN(e,n.workdir),await iN(t),tN(e,!0)}}catch{}},3e3)}function sN(){let e=document.getElementById(`headerAgentDropdown`),t=document.getElementById(`headerAgentWrapper`);if(!e||!t)return;let n=document.body.clientWidth,r=t.getBoundingClientRect(),i=e.offsetWidth;n<312?(e.style.minWidth=n-16+`px`,e.style.maxWidth=n-16+`px`):(e.style.minWidth=``,e.style.maxWidth=``);let a=r.right+20-i,o=n-i-8;a=Math.max(8,Math.min(o,a)),e.style.left=a-r.left+`px`}async function cN(){let e=document.getElementById(`headerAgentTrigger`),t=document.getElementById(`headerAgentDropdown`),n=document.getElementById(`agentDdCopyBtn`),r=document.getElementById(`agentDdAddBtn`),a=document.getElementById(`agentDdRestartBtn`),o=document.getElementById(`agentDdUpdateBtn`),s=document.getElementById(`agentDdStopBtn`),c=document.getElementById(`agentDdRefreshBtn`);if(!e||!t)return;e.addEventListener(`click`,e=>{e.stopPropagation();let n=t.style.display!==`none`;t.style.display=n?`none`:``,n||(sN(),XM(H.agentPlatform||{}),rN())}),document.addEventListener(`click`,n=>{!t.contains(n.target)&&n.target!==e&&(t.style.display=`none`)}),n.addEventListener(`click`,async e=>{e.stopPropagation(),H.activeAgentId;let t=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=(t.pairedAgents||[]).find(e=>e.id===t.activeAgentId);n?.url&&(await navigator.clipboard.writeText(n.url),U(i(`sidePanel.agentAddressCopied`),`success`))}),r.addEventListener(`click`,async()=>{t.style.display=`none`,await chrome.storage.local.set({optionsInitialTab:`agent`});let e=await chrome.tabs.query({}),n=chrome.runtime.getURL(`options/index.html`),r=e.find(e=>e.url&&e.url.startsWith(n));if(r){chrome.tabs.update(r.id,{active:!0});try{chrome.tabs.sendMessage(r.id,{type:`SWITCH_TAB`,tab:`agent`})}catch{}}else chrome.runtime.openOptionsPage()}),a.addEventListener(`click`,async()=>{t.style.display=`none`;let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=(e.pairedAgents||[]).find(t=>t.id===e.activeAgentId),r=n?.name||i(`sidePanel.unknownAgent`),a=n?.url||i(`sidePanel.unknownAgent`);if(await window.showCustomConfirm(i(`sidePanel.restartAgentConfirm`,{name:r,url:a}),i(`sidePanel.restartAgentTitle`)))try{chrome.runtime.sendMessage({type:`AGENT_RESTART`},async e=>{e?.success?(U(i(`sidePanel.agentRestarting`),`success`),H.agentPlatform={...H.agentPlatform,connected:!1},await XM(H.agentPlatform,!0),n?.id&&tN(n.id,!1),oN(n?.id)):U(i(`sidePanel.restartFailed`,{error:e?.error||i(`sidePanel.unknownError`)}),`error`)})}catch(e){U(i(`sidePanel.restartRequestFailed`,{error:e.message}),`error`)}}),o.addEventListener(`click`,async()=>{t.style.display=`none`;let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=(e.pairedAgents||[]).find(t=>t.id===e.activeAgentId),r=n?.name||i(`sidePanel.unknownAgent`),a=n?.url||i(`sidePanel.unknownAgent`);if(await window.showCustomConfirm(i(`sidePanel.updateAgentConfirm`,{name:r,url:a}),i(`sidePanel.updateAgentTitle`))){U(i(`sidePanel.agentUpdating`),`info`);try{chrome.runtime.sendMessage({type:`AGENT_UPDATE`},async e=>{e?.success?(U(i(`sidePanel.agentUpdateRestarting`),`success`),H.agentPlatform={...H.agentPlatform,connected:!1},await XM(H.agentPlatform,!0),n?.id&&tN(n.id,!1),oN(n?.id)):U(i(`sidePanel.updateFailed`,{error:e?.error||i(`sidePanel.unknownError`)}),`error`)})}catch(e){U(i(`sidePanel.updateRequestFailed`,{error:e.message}),`error`)}}}),s.addEventListener(`click`,async()=>{t.style.display=`none`;let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),n=(e.pairedAgents||[]).find(t=>t.id===e.activeAgentId),r=n?.name||i(`sidePanel.unknownAgent`),a=n?.url||i(`sidePanel.unknownAgent`);if(await window.showCustomConfirm(i(`sidePanel.stopAgentConfirm`,{name:r,url:a}),i(`sidePanel.stopAgentTitle`)))try{chrome.runtime.sendMessage({type:`AGENT_STOP`},async e=>{e?.success?(U(i(`sidePanel.agentStopped`),`success`),H.agentPlatform={...H.agentPlatform,connected:!1},await XM(H.agentPlatform,!0),n?.id&&tN(n.id,!1)):U(i(`sidePanel.stopFailed`,{error:e?.error||i(`sidePanel.unknownError`)}),`error`)})}catch(e){U(i(`sidePanel.stopRequestFailed`,{error:e.message}),`error`)}}),c&&c.addEventListener(`click`,async()=>{document.querySelectorAll(`.agent-dd-item-dot`).forEach(e=>{e.classList.remove(`online`,`offline`),e.classList.add(`checking`)}),document.querySelectorAll(`.agent-dd-item-status`).forEach(e=>{e.textContent=i(`sidePanel.agentChecking`)}),await rN(),U(i(`sidePanel.agentStatusRefreshed`),`success`)}),document.getElementById(`agentDdList`).addEventListener(`click`,async e=>{let t=e.target.closest(`.agent-dd-tool-btn`),n=e.target.closest(`.agent-dd-item`);if(t){e.stopPropagation(),l(t.dataset.action,t.dataset.id);return}n&&!n.classList.contains(`disabled`)&&!n.classList.contains(`active`)&&(e.stopPropagation(),l(`switch`,n.dataset.agentId))});async function l(e,t){let n=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),r=n.pairedAgents||[];switch(e){case`enable`:r=r.map(e=>e.id===t?{...e,disabled:!1}:e),await chrome.storage.local.set({pairedAgents:r});break;case`disable`:{r=r.map(e=>e.id===t?{...e,disabled:!0}:e);let e=n.activeAgentId;n.activeAgentId===t&&(e=r.find(e=>e.id!==t&&!e.disabled)?.id||null),await chrome.storage.local.set({pairedAgents:r,activeAgentId:e||``}),e?chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!0,agentId:e}):chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!1});break}case`switch`:await chrome.storage.local.set({activeAgentId:t}),chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!0,agentId:t});break;case`disconnect`:await chrome.storage.local.set({activeAgentId:``}),chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!1});break;case`delete`:{let e=r.find(e=>e.id===t);if(!await window.showCustomConfirm(i(`sidePanel.deleteAgentTitle`),i(`sidePanel.deleteAgentConfirm`,{name:e?.name||t})))return;r=r.filter(e=>e.id!==t);let a=n.activeAgentId===t?r.find(e=>!e.disabled)?.id||null:n.activeAgentId;await chrome.storage.local.set({pairedAgents:r,activeAgentId:a||``}),a?chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!0,agentId:a}):chrome.runtime.sendMessage({type:`AGENT_CONNECTION_CHANGED`,connected:!1});break}}let a=document.getElementById(`headerAgentDropdown`);a&&(a.style.display=`none`)}}var lN=new Map,uN=8;function dN(e,t){for(lN.has(e)&&lN.delete(e),lN.set(e,t);lN.size>uN;)lN.delete(lN.keys().next().value)}function fN(e){let t=lN.get(e);if(t!==void 0)return lN.delete(e),lN.set(e,t),t}function pN(e){lN.delete(e)}document.addEventListener(`DOMContentLoaded`,async()=>{Oo(),await Promise.allSettled([a().then(()=>{s(),bn(),l(()=>{s(),bn()})}),Qe(),LD(),Tt()]),window.__tableBlocks=[],chrome.runtime.onMessage.addListener(e=>{if(e.type===`SCHEDULED_SESSION_UPDATED`){let t=e.sessionId;t===H.activeSessionId?UD().catch(()=>{}):t&&(Dt(t).catch(()=>{}),document.dispatchEvent(new CustomEvent(`session-cache-invalidate`,{detail:{sessionId:t}})));return}if(e.type===`CLOSE_SIDEPANEL`){o.debug(`[SidePanel] recei to CLOSE_SIDEPANEL,closesidebar`);try{window.close()}catch{}return}if(e.type===`SELECTION_AI_SEARCH`&&e.prompt&&(o.debug(`[SidePanel] received selectedtext AI search:`,e.selectedText?.substring(0,50)),e.selectedText&&qM(e.selectedText),tO(e.prompt,e.selectedText),chrome.storage.session.remove(`pendingSelectionSearch`).catch(()=>{})),e.type===`FILL_SIDEPANEL_INPUT`&&e.text&&(o.debug(`[SidePanel] received follow-upfill:`,e.text?.substring(0,50)),nO(e.text),chrome.storage.session.remove(`pendingFillInput`).catch(()=>{})),e.type===`DIRECT_SEND`&&e.text&&(o.debug(`[SidePanel] received directsend:`,e.text?.substring(0,50)),e.selectedText&&qM(e.selectedText),rO(e.text,e.selectedText||``),chrome.storage.session.remove(`pendingDirectSend`).catch(()=>{})),e.type===`AGENT_STATUS_CHANGE`&&(o.debug(`[SidePanel] recei to Agent status change:`,e.connected,e.status),H.agentPlatform={...H.agentPlatform,connected:e.connected},XM(H.agentPlatform),tu(),Sn(),e.connected&&iN()),e.type===`AGENT_CONNECTION_CHANGED`){if(o.debug(`[SidePanel] recei to Agent connection statuschanged:`,e.connected,e.agentId),!e.connected){H.agentPlatform={connected:!1},XM(H.agentPlatform),tu(),Sn();return}e.agentId&&(async()=>{try{let e=await chrome.storage.local.get([`pairedAgents`,`activeAgentId`]),t=(e.pairedAgents||[]).find(t=>t.id===e.activeAgentId&&!t.disabled);if(!t){H.agentPlatform={connected:!1},XM(H.agentPlatform),tu(),Sn(),mw();return}if(t.token)try{let n=await fetch(`${t.url}/api/status/detail`,{cache:`no-cache`,headers:{Authorization:`Bearer ${t.token}`}});if(n.ok){let t=await n.json();if(t.success){H.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&&H.agentVersions.set(e.activeAgentId,t.version),t.workdir&&H.agentWorkdirs.set(e.activeAgentId,t.workdir),t.homeDir&&H.agentHomeDirs.set(e.activeAgentId,t.homeDir);let n=eN(t.platformName||t.platform,t.arch);n&&H.agentSystemInfos.set(e.activeAgentId,n)}else H.agentPlatform={connected:!1}}else H.agentPlatform={connected:!1}}catch{H.agentPlatform={connected:!1}}else try{let n=await fetch(`${t.url}/api/status`,{cache:`no-cache`});if(n.ok){let t=await n.json();H.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&&H.agentVersions.set(e.activeAgentId,t.version);let r=eN(t.platformName||t.platform,t.arch);r&&H.agentSystemInfos.set(e.activeAgentId,r)}else H.agentPlatform={connected:!1}}catch{H.agentPlatform={connected:!1}}}catch{H.agentPlatform={connected:!1}}XM(H.agentPlatform),tu(),Sn(),mw()})()}e.type===`SCREENSHOT_RESULT`&&e.dataUrl&&(o.debug(`[SidePanel] received pageshortcutscreenshotresult:`,e.mode),ou(e.dataUrl,e.mode,e.rect))});async function e(e){try{let t=await chrome.sidePanel.getOptions({tabId:e});return typeof t?.enabled==`boolean`?t.enabled:(await chrome.sidePanel.getOptions({}))?.enabled!==!1}catch{return!0}}chrome.tabs.onActivated.addListener(async t=>{if(o.debug(`[SidePanel] Tab switch, new Tab ID:`,t.tabId),!await e(t.tabId)){o.debug(`[SidePanel] Tab 无侧边栏,保持 currentTabId:`,H.currentTabId);return}H.currentTabId=t.tabId}),chrome.tabs.onUpdated.addListener(async(e,t)=>{t.status===`complete`&&H.currentTabId===e&&o.debug(`[SidePanel] current Tab page update:`,t)}),typeof marked<`u`&&(marked.setOptions({breaks:!0,gfm:!0}),o.debug(`[SidePanel] Marked library loaded`));let t=document.getElementById(`userInput`),n=document.getElementById(`sendBtn`),r=document.getElementById(`clearChatBtn`),c=document.getElementById(`exportChatBtn`),u=document.getElementById(`chatContainer`),d=document.getElementById(`tempDisplay`),p=document.getElementById(`tempDropdown`),m=document.getElementById(`tempPresetList`),h=document.getElementById(`tempSlider`),g=document.getElementById(`tempNumberInput`);function _(){if(!t||H.isScrolling)return;t.style.height=`auto`;let e=t.scrollHeight;e<=50?t.style.height=``:t.style.height=Math.min(e,100)+`px`,Ae()}chrome.storage.local.get([`temperature`,`topP`,`selectedTempIndex`],e=>{(!H.activeAgentId||H.activeAgentId==="default")&&(e.temperature!==void 0&&(H.temperature=e.temperature),e.topP!==void 0&&(H.topP=e.topP),e.selectedTempIndex!==void 0&&(H.selectedTempIndex=e.selectedTempIndex)),v()});function v(){h&&(h.value=H.temperature),g&&(g.value=H.temperature.toFixed(2));let e=document.getElementById(`tempIconValue`);e&&(e.textContent=H.temperature.toFixed(2)),b()}function y(){let e=0,t=Math.abs(Oe[0].temp-H.temperature);for(let n=1;n<Oe.length;n++){let r=Math.abs(Oe[n].temp-H.temperature);r<t&&(t=r,e=n)}return e}function b(){let e=y();m.innerHTML=Oe.map((t,n)=>`
|
|
2699
2705
|
<div class="temp-preset-item ${n===e?`selected`:``}" data-index="${n}">
|
|
2700
2706
|
<div class="temp-preset-radio"></div>
|
|
2701
2707
|
<div class="temp-preset-info">
|
|
@@ -2704,15 +2710,15 @@ Are you sure you want to stop the agent service? You will not be able to connect
|
|
|
2704
2710
|
</div>
|
|
2705
2711
|
<div class="temp-preset-value">${t.temp.toFixed(2)}</div>
|
|
2706
2712
|
</div>
|
|
2707
|
-
`).join(``),m.querySelectorAll(`.temp-preset-item`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),x(parseInt(e.dataset.index))})})}function x(e){let t=Oe[e];t&&(H.selectedTempIndex=e,H.temperature=t.temp,v(),
|
|
2713
|
+
`).join(``),m.querySelectorAll(`.temp-preset-item`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation(),x(parseInt(e.dataset.index))})})}function x(e){let t=Oe[e];t&&(H.selectedTempIndex=e,H.temperature=t.temp,v(),HM(H.temperature,H.topP,H.selectedTempIndex))}h.addEventListener(`input`,e=>{e.stopPropagation();let t=parseFloat(e.target.value);isNaN(t)&&(t=0),t=Math.max(0,Math.min(1,t)),H.temperature=t,g.value=t.toFixed(2);let n=document.getElementById(`tempIconValue`);n&&(n.textContent=t.toFixed(2)),b(),HM(H.temperature,H.topP,y())}),g.addEventListener(`change`,e=>{e.stopPropagation();let t=parseFloat(e.target.value);isNaN(t)&&(t=0),t=Math.max(0,Math.min(1,t)),H.temperature=t,h.value=t,g.value=t.toFixed(2);let n=document.getElementById(`tempIconValue`);n&&(n.textContent=t.toFixed(2)),b(),HM(H.temperature,H.topP,y())}),d&&p&&(d.addEventListener(`click`,e=>{e.stopPropagation(),p.classList.toggle(`show`)}),document.addEventListener(`click`,e=>{let t=document.querySelector(`.temp-selector`);t&&!t.contains(e.target)&&p.classList.remove(`show`)})),u.addEventListener(`mousedown`,e=>{H.lastMouseX=e.clientX,H.lastMouseY=e.clientY}),u.addEventListener(`mouseup`,e=>{H.lastMouseX=e.clientX,H.lastMouseY=e.clientY,H.enableSelectionQuery&&setTimeout(()=>{let e=window.getSelection();if(e&&!e.isCollapsed&&e.toString().trim()){let t=e.toString().trim();u.contains(e.anchorNode)&&(H.lastSelectedText=t,H.currentSelectionRange=e.getRangeAt(0).cloneRange(),qM(t),JM(e,t,H.lastMouseX,H.lastMouseY))}else u.contains(e.anchorNode)||(H.lastSelectedText=``,H.currentSelectionRange=null,window.hideFloatingMenu())},50)});let S=``,w=null;async function T(){try{let e=await new Promise(e=>{chrome.tabs.query({active:!0,currentWindow:!0},t=>e(t))});if(e&&e.length>0){let t=await new Promise(t=>{chrome.tabs.sendMessage(e[0].id,{action:`getSelectedText`},e=>{chrome.runtime.lastError?(console.debug(`[SidePanel] content script not loaded or unreachable:`,chrome.runtime.lastError.message),t(null)):t(e)})});if(!t)return;let n=t?.text||``;n&&n.trim()?n!==S&&(S=n,qM(n.trim())):S=``}}catch{}}function E(){w&&=(clearInterval(w),null),H.enableSelectionQuery&&(w=setInterval(T,500))}E(),chrome.storage.onChanged.addListener((e,t)=>{if(t===`local`&&`enableSelectionQuery`in e){H.enableSelectionQuery=e.enableSelectionQuery.newValue;let t=document.getElementById(`enableSelectionQueryBtn`);t&&(t.checked=H.enableSelectionQuery),E()}}),await C(),Tj(),chrome.storage.local.get([`modelName`,`customModels`,`customPrompts`,`systemPrompt`,`inputHistory`,`agentPlatform`,`enableImageInput`,`imageModelName`,`imageApiBase`,`imageApiKey`,`enableFileInput`],e=>{let t=e.modelName;t&&(H.currentModel=t),H.customPrompts=e.customPrompts||[],H.systemPrompt=e.systemPrompt||``,H.inputHistory=e.inputHistory||[],e.agentPlatform&&(H.agentPlatform=e.agentPlatform),XM(H.agentPlatform),chrome.runtime.sendMessage({type:`TRIGGER_AGENT_HEALTH_CHECK`}).catch(()=>{}),VM(),H.enableImageInput=e.enableImageInput||!1,H.imageModelName=e.imageModelName||``,H.imageApiBase=e.imageApiBase||``,H.imageApiKey=e.imageApiKey||``,H.enableFileInput=!0,$l(),tu(),DO(),KM(e.customModels,()=>{t&&GM(t)})}),chrome.storage.onChanged.addListener((e,t)=>{if(t===`local`){if(e.customModels&&KM(e.customModels.newValue||[],()=>{GM(H.currentModel)}),e.modelName){let t=e.modelName.newValue;t&&(!H.activeAgentId||H.activeAgentId==="default")&&(H.currentModel=t,GM(t))}if(e.enableImageInput&&(H.enableImageInput=e.enableImageInput.newValue,$l()),e.enableFileInput&&(H.enableFileInput=e.enableFileInput.newValue,tu()),e.enableExecutionLog&&(H.chatConfig.enableExecutionLog=e.enableExecutionLog.newValue),e.showMessageTimestamp){let t=e.showMessageTimestamp.newValue!==!1;H.chatConfig.showMessageTimestamp=t,cO(t)}e.systemPrompt&&(H.systemPrompt=e.systemPrompt.newValue||``),e.imageModelName&&(H.imageModelName=e.imageModelName.newValue||``),e.imageApiBase&&(H.imageApiBase=e.imageApiBase.newValue||``),e.imageApiKey&&(H.imageApiKey=e.imageApiKey.newValue||``)}}),await UD();let D=await chrome.storage.session.get([`pendingSelectionSearch`,`pendingFillInput`,`pendingDirectSend`]),O=[];if(D.pendingSelectionSearch&&D.pendingSelectionSearch.selectedText){let{prompt:e,selectedText:t}=D.pendingSelectionSearch;o.debug(`[SidePanel] pending selected textsearch:`,t?.substring(0,50)),qM(t),setTimeout(()=>{tO(e,t)},500),O.push(`pendingSelectionSearch`)}if(D.pendingFillInput&&D.pendingFillInput.text){let{text:e}=D.pendingFillInput;o.debug(`[SidePanel] pending fill trackasktext:`,e?.substring(0,50)),setTimeout(()=>{nO(e)},500),O.push(`pendingFillInput`)}if(D.pendingDirectSend&&D.pendingDirectSend.text){let{text:e,selectedText:t}=D.pendingDirectSend;o.debug(`[SidePanel] pending directsend text:`,e?.substring(0,50)),t&&qM(t),setTimeout(()=>{rO(e,t||``)},500),O.push(`pendingDirectSend`)}O.length>0&&await chrome.storage.session.remove(O);let k=document.getElementById(`userInput`);k&&k.focus(),document.addEventListener(`session-switched`,e=>{let{sessionId:t,previousSessionId:n}=e.detail||{},r=document.getElementById(`chatContainer`),a=document.getElementById(`userInput`);if(!r)return;let s=n&&H.messageHistory?.some(e=>e.resumable);n&&!H.pendingCallApiSessionIds.has(n)&&!s&&dN(n,r.innerHTML);let c=document.getElementById(`imagePreviewBar`);H.attachedImages.length>0&&c&&c.style.display===`none`&&(H.attachedImages=[]),H.executionLogListener&&(chrome.runtime.onMessage.removeListener(H.executionLogListener),H.executionLogListener=null),A(),a&&a.focus();let l=H.pendingCallApiSessionIds.has(t)&&!!H.pendingCancelApi,u=fN(t),d=H.messageHistory&&H.messageHistory.length>0;if(u&&!l&&d){if(r.innerHTML=u,_O(r),Ni(),Ki(),!e.detail?.skipScrollRestore){let e=`scrollPosition_`+(t||`default`);chrome.storage.local.get([e],t=>{t[e]!==void 0&&setTimeout(()=>{let n=document.getElementById(`chatContainer`);n&&(n.scrollTop=t[e])},150)})}JE();return}if(r.innerHTML=``,d)H.messageHistory.forEach(e=>{e.htmlContent?gO(e.htmlContent,e.messageId,e.resumable):sO(e.role,e.content,!1,e.executionLog||[],e.reflectionScore,e.wasRevised,null,e.messageId,[],!1,e.timestamp??null)}),uO(),fO(),Ni(),Ki(),H.pendingCallApiSessionIds.has(t)||dN(t,r.innerHTML),JE();else{let e=document.createElement(`div`);e.className=`welcome-message`,e.innerHTML=`
|
|
2708
2714
|
<div class="icon-wrapper">
|
|
2709
2715
|
<div class="icon">💬</div>
|
|
2710
2716
|
</div>
|
|
2711
2717
|
<h2>${i(`sidePanel.welcomeTitle`)}</h2>
|
|
2712
2718
|
<p>${i(`sidePanel.welcomeSubtitle`)}</p>
|
|
2713
|
-
`,r.appendChild(e)}if(o.debug(`[SidePanel] session-switched: pendingTask?`,l,`pendingSessionIds:`,[...H.pendingCallApiSessionIds],`activeSessionId:`,t,`hasCancelApi:`,!!H.pendingCancelApi),l&&(o.debug(`[SidePanel] switch back tobackground task session,rebuildstreamingoutput element`),TD(t)),!e.detail?.skipScrollRestore){let e=`scrollPosition_`+(t||`default`);chrome.storage.local.get([e],t=>{t[e]!==void 0&&setTimeout(async()=>{let n=document.getElementById(`chatContainer`);n&&(n.scrollTop=t[e]);let{updateScrollButtonState:r}=await fe(async()=>{let{updateScrollButtonState:e}=await Promise.resolve().then(()=>YE);return{updateScrollButtonState:e}},void 0);r()},150)})}}),document.addEventListener(`session-cache-invalidate`,e=>{let{sessionId:t}=e.detail||{};t&&fN(t)}),document.querySelectorAll(`.model-option`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let n=e.dataset.value;H.currentModel=n,WM(n),zM(n)})}),document.addEventListener(`agent-model-changed`,()=>{WM(H.currentModel);let e=document.getElementById(`tempSlider`),t=document.getElementById(`tempNumberInput`),n=document.getElementById(`tempIconValue`);e&&(e.value=H.temperature),t&&(t.value=H.temperature.toFixed(2)),n&&(n.textContent=H.temperature.toFixed(2)),b()}),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`),OO()),r&&!r.contains(e.target)&&HT();let a=document.getElementById(`fileAtSelector`);if(a&&!a.contains(e.target)&&Jj(),i&&!i.contains(e.target)){let t=window.getSelection(),n=u.contains(e.target),r=t&&!t.isCollapsed&&u.contains(t.anchorNode);(!n||!r)&&window.hideFloatingMenu()}});function A(){H.isGenerating?(n.classList.add(`stop-mode`),n.innerHTML=`<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect></svg>`,n.title=i(`sidePanel.sendBtnStop`),n.disabled=!1):(n.classList.remove(`stop-mode`),n.innerHTML=`<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor"><path d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8-8-8z"/></svg>`,n.title=i(`sidePanel.sendBtnSend`),n.disabled=!1,n.style.opacity=``,n.style.cursor=``)}n.addEventListener(`click`,()=>{H.isGenerating?MD(n):$D()}),document.addEventListener(`generating-state-changed`,A);let j=document.getElementById(`shortcutsBtn`),M=document.getElementById(`shortcutsModal`),ee=document.getElementById(`shortcutsCloseBtn`);function N(){M&&(M.style.display=`flex`)}function P(){M&&(M.style.display=`none`)}j&&j.addEventListener(`click`,e=>{e.stopPropagation(),N();let t=document.getElementById(`headerMoreDropdown`);t&&t.classList.remove(`show`)}),ee&&ee.addEventListener(`click`,P),M&&M.addEventListener(`click`,e=>{e.target===M&&P()});function F(e,t){let n=document.getElementById(`chatContainer`);if(!n)return;let r=n.querySelectorAll(`.message.user, .message.assistant, .user-context-bubble`);if(t){if(r.length===0)return;e===`prev`?r[0].scrollIntoView({behavior:`smooth`,block:`start`}):r[r.length-1].scrollIntoView({behavior:`smooth`,block:`start`});return}if(r.length===0)return;let i=n.getBoundingClientRect().top,a=-1;for(let e=0;e<r.length;e++)if(r[e].getBoundingClientRect().bottom>i+10){a=e;break}if(e===`prev`){a===-1&&(a=r.length);let e=a-1;e>=0&&r[e].scrollIntoView({behavior:`smooth`,block:`start`})}else{if(a===-1)return;let e=a+1;e<r.length&&r[e].scrollIntoView({behavior:`smooth`,block:`start`})}}let I=document.getElementById(`chatNavUp`),L=document.getElementById(`chatNavDown`);I&&I.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),F(`prev`,e.ctrlKey||e.metaKey)}),L&&L.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),F(`next`,e.ctrlKey||e.metaKey)});let R=document.getElementById(`chatNavHotzone`),z=document.getElementById(`chatNavButtons`),te=document.getElementById(`chatNavQuestionPanel`);function ne(){if(!te)return!1;let e=document.querySelectorAll(`#chatContainer .message.user`);if(e.length===0)return te.innerHTML=``,!1;let t=Array.from(e).map((e,t)=>{let n=Array.from(e.childNodes).filter(e=>e.nodeType===Node.TEXT_NODE).map(e=>e.textContent).join(``).replace(/\s+/g,` `).trim()||i(`chat.navQuestionNoText`),r=n.length>40?n.substring(0,40)+`…`:n;return`<button class="chat-nav-question-item" data-index="${t}" title="${W(n)}"><span class="idx">${t+1}</span>${W(r)}</button>`}).join(``);return te.innerHTML=`<div class="chat-nav-question-header"><span>${i(`chat.navQuestionTitle`)}</span><span class="count">${e.length}</span></div>${t}`,te.querySelectorAll(`.chat-nav-question-item`).forEach(t=>{t.addEventListener(`click`,()=>{let n=e[parseInt(t.dataset.index,10)];n&&(n.scrollIntoView({behavior:`instant`,block:`start`}),n.classList.add(`bookmark-highlight`),setTimeout(()=>n.classList.remove(`bookmark-highlight`),2e3))})}),!0}if(R&&z){let e=null,t=()=>{clearTimeout(e),z.classList.add(`expanded`),te&&(ne()?te.classList.add(`expanded`):te.classList.remove(`expanded`))},n=()=>{clearTimeout(e),e=setTimeout(()=>{z.classList.remove(`expanded`),te&&te.classList.remove(`expanded`)},200)};R.addEventListener(`mouseenter`,t),R.addEventListener(`mouseleave`,n),z.addEventListener(`mouseenter`,t),z.addEventListener(`mouseleave`,n),te&&(te.addEventListener(`mouseenter`,t),te.addEventListener(`mouseleave`,n))}document.addEventListener(`keydown`,e=>{if((e.ctrlKey||e.metaKey)&&e.key===`t`){e.preventDefault();let t=document.getElementById(`toolsPopup`);t&&t.style.display!==`none`?on():an()}if(e.key===`Escape`&&M&&M.style.display!==`none`){P();return}if(e.altKey&&e.code===`Slash`){e.preventDefault(),N();return}if(e.altKey&&!e.shiftKey&&e.code===`KeyS`&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),ru();return}if(e.altKey&&e.shiftKey&&e.code===`KeyS`&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),iu();return}if(e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyN`){e.preventDefault(),ia();return}if(e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyW`){e.preventDefault(),Ba();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){SO(n);let e=document.getElementById(`userInput`);e&&e.focus()}return}if(e.altKey&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){e.preventDefault(),F(e.key===`ArrowUp`?`prev`:`next`,e.ctrlKey||e.metaKey);return}}),t.addEventListener(`keydown`,e=>{let n=document.getElementById(`promptSelector`),r=document.getElementById(`promptDropdown`),i=document.getElementById(`agentAtSelector`),a=document.getElementById(`agentAtDropdown`);if(i.style.display!==`none`&&a.classList.contains(`show`)){let t=document.getElementById(`agentAtTabs`),n=t&&t.classList.contains(`merged-mode`);if(!n&&e.key===`Tab`){e.preventDefault();let t=Array.from(document.querySelectorAll(`#agentAtTabs .prompt-tab`)).map(e=>e.dataset.tab),n=e=>{let t=document.querySelector(`#agentAtTabs .prompt-tab[data-tab="${e}"]`);return!!t&&t.style.display!==`none`},r=t.indexOf(LT);for(let e=0;e<t.length;e++)if(r=(r+1)%t.length,n(t[r])){WT(t[r]);break}return}let r,i;n?(r=document.getElementById(`agentAtList`),i=H.selectedAgentAtIndex):LT===`pages`?(r=document.getElementById(`agentPageList`),i=H.selectedPageIndex):LT===`proxies`?(r=document.getElementById(`agentProxyList`),i=H.selectedProxyAtIndex):LT===`knowledge`?(r=document.getElementById(`agentKnowledgeList`),i=H.selectedKnowledgeAtIndex):(r=document.getElementById(`agentAtList`),i=H.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?(H.selectedAgentAtIndex=t,iE(a)):LT===`proxies`?(H.selectedProxyAtIndex=t,iE(a)):LT===`knowledge`?(H.selectedKnowledgeAtIndex=t,iE(a)):LT===`pages`?(H.selectedPageIndex=t,TE(a)):(H.selectedAgentAtIndex=t,iE(a));return}if(e.key===`ArrowUp`){e.preventDefault();let t=i<0||i===0?o-1:i-1;n?(H.selectedAgentAtIndex=t,iE(a)):LT===`proxies`?(H.selectedProxyAtIndex=t,iE(a)):LT===`knowledge`?(H.selectedKnowledgeAtIndex=t,iE(a)):LT===`pages`?(H.selectedPageIndex=t,TE(a)):(H.selectedAgentAtIndex=t,iE(a));return}if(e.key===`Enter`&&i>=0){e.preventDefault(),a[i].click(),(e.ctrlKey||e.metaKey)&&HT();return}if(e.key===`Escape`){HT();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`){if(e.preventDefault(),r>0){let t=e.key===`ArrowDown`?H.selectedFileAtIndex<0?0:(H.selectedFileAtIndex+1)%r:H.selectedFileAtIndex<0||H.selectedFileAtIndex===0?r-1:H.selectedFileAtIndex-1;H.selectedFileAtIndex=t,$j(n)}return}if(e.key===`Enter`&&r>0&&H.selectedFileAtIndex>=0){e.preventDefault(),n[H.selectedFileAtIndex].click();return}if(e.key===`Escape`){e.preventDefault(),Jj();return}}if(n.style.display!==`none`&&r.classList.contains(`show`)){if(H.showMergedList){let t=r.querySelectorAll(`#promptList .prompt-item`),n=t.length;if(e.key===`ArrowDown`){e.preventDefault(),H.selectedPromptIndex<0?H.selectedPromptIndex=0:H.selectedPromptIndex=(H.selectedPromptIndex+1)%n,NO(t);return}if(e.key===`ArrowUp`){e.preventDefault(),H.selectedPromptIndex<0||H.selectedPromptIndex===0?H.selectedPromptIndex=n-1:--H.selectedPromptIndex,NO(t);return}if(e.key===`Enter`&&H.selectedPromptIndex>=0){e.preventDefault();let n=t[H.selectedPromptIndex];n.dataset.type===`skill`||n.dataset.type===`mcp`?(n.click(),(e.ctrlKey||e.metaKey)&&OO()):e.ctrlKey||e.metaKey?PO(n.dataset.code):FO(n.dataset.code);return}if(e.key===`Escape`){OO();return}return}if(H.activeDropdownTab===`skills`){let t=r.querySelectorAll(`#skillList .skill-list-item`),n=t.length;if(e.key===`ArrowDown`){e.preventDefault(),H.selectedSkillIndex<0?H.selectedSkillIndex=0:H.selectedSkillIndex=(H.selectedSkillIndex+1)%n,tk(t);return}if(e.key===`ArrowUp`){e.preventDefault(),H.selectedSkillIndex<0||H.selectedSkillIndex===0?H.selectedSkillIndex=n-1:--H.selectedSkillIndex,tk(t);return}if(e.key===`Enter`&&H.selectedSkillIndex>=0){e.preventDefault(),t[H.selectedSkillIndex].click(),(e.ctrlKey||e.metaKey)&&OO();return}if(e.key===`Escape`){OO();return}if(e.key===`Tab`){e.preventDefault();let t=document.getElementById(`mcpTab`);t&&t.style.display!==`none`?ck(`mcp`):ck(`prompts`);return}return}if(H.activeDropdownTab===`mcp`){let t=r.querySelectorAll(`#mcpList .mcp-list-item`),n=t.length;if(e.key===`ArrowDown`){e.preventDefault(),H.selectedMcpServiceIndex<0?H.selectedMcpServiceIndex=0:H.selectedMcpServiceIndex=(H.selectedMcpServiceIndex+1)%n,hk(t);return}if(e.key===`ArrowUp`){e.preventDefault(),H.selectedMcpServiceIndex<0||H.selectedMcpServiceIndex===0?H.selectedMcpServiceIndex=n-1:--H.selectedMcpServiceIndex,hk(t);return}if(e.key===`Enter`&&H.selectedMcpServiceIndex>=0){e.preventDefault(),t[H.selectedMcpServiceIndex].click(),(e.ctrlKey||e.metaKey)&&OO();return}if(e.key===`Escape`){OO();return}if(e.key===`Tab`){e.preventDefault(),ck(`prompts`);return}return}let t=r.querySelectorAll(`#promptList .prompt-item`),n=t.length;if(e.key===`Tab`){let t=document.getElementById(`skillsTab`),n=document.getElementById(`mcpTab`);if(t&&t.style.display!==`none`){e.preventDefault(),ck(`skills`);return}if(n&&n.style.display!==`none`){e.preventDefault(),ck(`mcp`);return}}if(n!==0&&e.key===`ArrowDown`){e.preventDefault(),H.selectedPromptIndex<0?H.selectedPromptIndex=0:H.selectedPromptIndex=(H.selectedPromptIndex+1)%n,NO(t);return}if(e.key===`ArrowUp`){e.preventDefault(),H.selectedPromptIndex<0||H.selectedPromptIndex===0?H.selectedPromptIndex=n-1:--H.selectedPromptIndex,NO(t);return}if(e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&H.selectedPromptIndex>=0){e.preventDefault();let n=t[H.selectedPromptIndex].dataset.code;PO(n);return}if(e.key===`Enter`&&H.selectedPromptIndex>=0){e.preventDefault();let n=t[H.selectedPromptIndex].dataset.code;FO(n);return}if(e.key===`Escape`){OO();return}}if(e.key===`Escape`){H.inputHistoryIndex>=0&&(H.inputHistoryIndex=-1),t.value&&(t.value=``,t.style.height=`auto`,t.dispatchEvent(new Event(`input`))),e.preventDefault();return}let c=n.style.display!==`none`&&r.classList.contains(`show`),l=i.style.display!==`none`&&a.classList.contains(`show`),u=o.style.display!==`none`&&s.classList.contains(`show`);if(!c&&!l&&!u&&!H.isGenerating){if(e.key===`ArrowUp`){e.preventDefault(),H.inputHistoryIndex===-1?H.inputHistoryIndex=H.inputHistory.length-1:H.inputHistoryIndex>0&&H.inputHistoryIndex--,H.inputHistoryIndex<0&&(H.inputHistoryIndex=0),H.inputHistoryIndex>=0&&H.inputHistory.length>0&&(t.value=H.inputHistory[H.inputHistoryIndex],t.dispatchEvent(new Event(`input`)));return}if(e.key===`ArrowDown`){e.preventDefault(),H.inputHistoryIndex>=0&&H.inputHistoryIndex<H.inputHistory.length-1?(H.inputHistoryIndex++,t.value=H.inputHistory[H.inputHistoryIndex],t.dispatchEvent(new Event(`input`))):(H.inputHistoryIndex=-1,t.value=``,t.dispatchEvent(new Event(`input`)));return}}if(e.key===`Enter`&&!e.shiftKey){if(H.isComposing)return;e.preventDefault(),Jj(),$D()}}),t.addEventListener(`compositionstart`,()=>{H.isComposing=!0}),t.addEventListener(`compositionend`,()=>{H.isComposing=!1}),t.addEventListener(`paste`,e=>{let t=e.clipboardData?.items;if(t)for(let n of t){if(n.type.startsWith(`image/`)&&H.enableImageInput){e.preventDefault();let t=n.getAsFile();t&&gc(t);break}if(n.kind===`file`&&H.enableFileInput){e.preventDefault();let t=n.getAsFile();t&&Zc([t]);break}}});let re=document.getElementById(`fileAttachBtn`),ie=document.getElementById(`fileInput`);re&&ie&&(re.addEventListener(`click`,()=>{ie.click()}),ie.addEventListener(`change`,async()=>{if(ie.files.length>0){let e=Array.from(ie.files),t=e.filter(e=>e.type.startsWith(`image/`)),n=e.filter(e=>!e.type.startsWith(`image/`));if(t.length>0){if(H.enableImageInput)for(let e of t)await gc(e);else U(i(`sidePanel.imageNotEnabled`)),Zc(t)}n.length>0&&Zc(n),ie.value=``}}));let ae=document.querySelector(`.input-wrapper`),oe=0;ae&&(ae.addEventListener(`dragenter`,e=>{e.preventDefault(),e.stopPropagation(),oe++,ae.classList.add(`drag-over`)}),ae.addEventListener(`dragleave`,e=>{e.preventDefault(),e.stopPropagation(),oe--,oe<=0&&(oe=0,ae.classList.remove(`drag-over`))}),ae.addEventListener(`dragover`,e=>{e.preventDefault(),e.stopPropagation()}),ae.addEventListener(`drop`,async e=>{e.preventDefault(),e.stopPropagation(),oe=0,ae.classList.remove(`drag-over`);let t=e.dataTransfer.getData(`application/x-workspace-file`);if(t)try{let{path:e}=JSON.parse(t);if(e){Ww([e]);return}}catch(e){o.warn(`[SidePanel] parse workspace dragdata failed:`,e)}let n=Array.from(e.dataTransfer.files);if(n.length>0){let e=n.filter(e=>e.type.startsWith(`image/`)),t=n.filter(e=>!e.type.startsWith(`image/`));if(e.length>0){if(H.enableImageInput)for(let t of e)await gc(t);else U(i(`sidePanel.imageNotEnabled`)),Zc(e)}t.length>0&&Zc(t)}}));let B=document.getElementById(`screenshotBtn`);B&&B.addEventListener(`click`,async()=>{if(H.enableImageInput)try{await ru()}catch(e){o.error(`[SidePanel] screenshot failed:`,e),U(i(`sidePanel.screenshotFailed`))}}),mc(),t.addEventListener(`wheel`,e=>{H.isScrolling=!0;let n=t.style.height||t.offsetHeight+`px`;t.style.height=n,t.scrollHeight<=t.clientHeight+10&&(e.preventDefault(),e.stopPropagation()),setTimeout(()=>{H.isScrolling=!1},100)},{passive:!1}),t.addEventListener(`input`,e=>{let n=t.value,r=document.getElementById(`promptSelector`),i=document.getElementById(`promptDropdown`);document.getElementById(`agentAtSelector`),document.getElementById(`agentAtDropdown`);let a=n.lastIndexOf(`/`),o=n.lastIndexOf(`@`),s=n.lastIndexOf(`$`),c=e=>{if(e===-1||e!==0&&n[e-1]!==`
|
|
2719
|
+
`,r.appendChild(e)}if(o.debug(`[SidePanel] session-switched: pendingTask?`,l,`pendingSessionIds:`,[...H.pendingCallApiSessionIds],`activeSessionId:`,t,`hasCancelApi:`,!!H.pendingCancelApi),l&&(o.debug(`[SidePanel] switch back tobackground task session,rebuildstreamingoutput element`),ED(t)),!e.detail?.skipScrollRestore){let e=`scrollPosition_`+(t||`default`);chrome.storage.local.get([e],t=>{t[e]!==void 0&&setTimeout(async()=>{let n=document.getElementById(`chatContainer`);n&&(n.scrollTop=t[e]);let{updateScrollButtonState:r}=await fe(async()=>{let{updateScrollButtonState:e}=await Promise.resolve().then(()=>XE);return{updateScrollButtonState:e}},void 0);r()},150)})}}),document.addEventListener(`session-cache-invalidate`,e=>{let{sessionId:t}=e.detail||{};t&&pN(t)}),document.querySelectorAll(`.model-option`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let n=e.dataset.value;H.currentModel=n,GM(n),BM(n)})}),document.addEventListener(`agent-model-changed`,()=>{GM(H.currentModel);let e=document.getElementById(`tempSlider`),t=document.getElementById(`tempNumberInput`),n=document.getElementById(`tempIconValue`);e&&(e.value=H.temperature),t&&(t.value=H.temperature.toFixed(2)),n&&(n.textContent=H.temperature.toFixed(2)),b()}),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`),kO()),r&&!r.contains(e.target)&&UT();let a=document.getElementById(`fileAtSelector`);if(a&&!a.contains(e.target)&&Yj(),i&&!i.contains(e.target)){let t=window.getSelection(),n=u.contains(e.target),r=t&&!t.isCollapsed&&u.contains(t.anchorNode);(!n||!r)&&window.hideFloatingMenu()}});function A(){H.isGenerating?(n.classList.add(`stop-mode`),n.innerHTML=`<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect></svg>`,n.title=i(`sidePanel.sendBtnStop`),n.disabled=!1):(n.classList.remove(`stop-mode`),n.innerHTML=`<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor"><path d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8-8-8z"/></svg>`,n.title=i(`sidePanel.sendBtnSend`),n.disabled=!1,n.style.opacity=``,n.style.cursor=``)}n.addEventListener(`click`,()=>{H.isGenerating?ND(n):eO()}),document.addEventListener(`generating-state-changed`,A);let j=document.getElementById(`shortcutsBtn`),M=document.getElementById(`shortcutsModal`),ee=document.getElementById(`shortcutsCloseBtn`);function N(){M&&(M.style.display=`flex`)}function P(){M&&(M.style.display=`none`)}j&&j.addEventListener(`click`,e=>{e.stopPropagation(),N();let t=document.getElementById(`headerMoreDropdown`);t&&t.classList.remove(`show`)}),ee&&ee.addEventListener(`click`,P),M&&M.addEventListener(`click`,e=>{e.target===M&&P()});function F(e,t){let n=document.getElementById(`chatContainer`);if(!n)return;let r=n.querySelectorAll(`.message.user, .message.assistant, .user-context-bubble`);if(t){if(r.length===0)return;e===`prev`?r[0].scrollIntoView({behavior:`smooth`,block:`start`}):r[r.length-1].scrollIntoView({behavior:`smooth`,block:`start`});return}if(r.length===0)return;let i=n.getBoundingClientRect().top,a=-1;for(let e=0;e<r.length;e++)if(r[e].getBoundingClientRect().bottom>i+10){a=e;break}if(e===`prev`){a===-1&&(a=r.length);let e=a-1;e>=0&&r[e].scrollIntoView({behavior:`smooth`,block:`start`})}else{if(a===-1)return;let e=a+1;e<r.length&&r[e].scrollIntoView({behavior:`smooth`,block:`start`})}}let I=document.getElementById(`chatNavUp`),L=document.getElementById(`chatNavDown`);I&&I.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),F(`prev`,e.ctrlKey||e.metaKey)}),L&&L.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),F(`next`,e.ctrlKey||e.metaKey)});let R=document.getElementById(`chatNavHotzone`),z=document.getElementById(`chatNavButtons`),te=document.getElementById(`chatNavQuestionPanel`);function ne(){if(!te)return!1;let e=document.querySelectorAll(`#chatContainer .message.user`);if(e.length===0)return te.innerHTML=``,!1;let t=Array.from(e).map((e,t)=>{let n=Array.from(e.childNodes).filter(e=>e.nodeType===Node.TEXT_NODE).map(e=>e.textContent).join(``).replace(/\s+/g,` `).trim()||i(`chat.navQuestionNoText`),r=n.length>40?n.substring(0,40)+`…`:n;return`<button class="chat-nav-question-item" data-index="${t}" title="${W(n)}"><span class="idx">${t+1}</span>${W(r)}</button>`}).join(``);return te.innerHTML=`<div class="chat-nav-question-header"><span>${i(`chat.navQuestionTitle`)}</span><span class="count">${e.length}</span></div>${t}`,te.querySelectorAll(`.chat-nav-question-item`).forEach(t=>{t.addEventListener(`click`,()=>{let n=e[parseInt(t.dataset.index,10)];n&&(n.scrollIntoView({behavior:`instant`,block:`start`}),n.classList.add(`bookmark-highlight`),setTimeout(()=>n.classList.remove(`bookmark-highlight`),2e3))})}),!0}if(R&&z){let e=null,t=()=>{clearTimeout(e),z.classList.add(`expanded`),te&&(ne()?te.classList.add(`expanded`):te.classList.remove(`expanded`))},n=()=>{clearTimeout(e),e=setTimeout(()=>{z.classList.remove(`expanded`),te&&te.classList.remove(`expanded`)},200)};R.addEventListener(`mouseenter`,t),R.addEventListener(`mouseleave`,n),z.addEventListener(`mouseenter`,t),z.addEventListener(`mouseleave`,n),te&&(te.addEventListener(`mouseenter`,t),te.addEventListener(`mouseleave`,n))}document.addEventListener(`keydown`,e=>{if((e.ctrlKey||e.metaKey)&&e.key===`t`){e.preventDefault();let t=document.getElementById(`toolsPopup`);t&&t.style.display!==`none`?on():an()}if(e.key===`Escape`&&M&&M.style.display!==`none`){P();return}if(e.altKey&&e.code===`Slash`){e.preventDefault(),N();return}if(e.altKey&&!e.shiftKey&&e.code===`KeyS`&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),ru();return}if(e.altKey&&e.shiftKey&&e.code===`KeyS`&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),iu();return}if(e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyN`){e.preventDefault(),ia();return}if(e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&e.code===`KeyW`){e.preventDefault(),Ba();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){CO(n);let e=document.getElementById(`userInput`);e&&e.focus()}return}if(e.altKey&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){e.preventDefault(),F(e.key===`ArrowUp`?`prev`:`next`,e.ctrlKey||e.metaKey);return}}),t.addEventListener(`keydown`,e=>{let n=document.getElementById(`promptSelector`),r=document.getElementById(`promptDropdown`),i=document.getElementById(`agentAtSelector`),a=document.getElementById(`agentAtDropdown`);if(i.style.display!==`none`&&a.classList.contains(`show`)){let t=document.getElementById(`agentAtTabs`),n=t&&t.classList.contains(`merged-mode`);if(!n&&e.key===`Tab`){e.preventDefault();let t=Array.from(document.querySelectorAll(`#agentAtTabs .prompt-tab`)).map(e=>e.dataset.tab),n=e=>{let t=document.querySelector(`#agentAtTabs .prompt-tab[data-tab="${e}"]`);return!!t&&t.style.display!==`none`},r=t.indexOf(RT);for(let e=0;e<t.length;e++)if(r=(r+1)%t.length,n(t[r])){GT(t[r]);break}return}let r,i;n?(r=document.getElementById(`agentAtList`),i=H.selectedAgentAtIndex):RT===`pages`?(r=document.getElementById(`agentPageList`),i=H.selectedPageIndex):RT===`proxies`?(r=document.getElementById(`agentProxyList`),i=H.selectedProxyAtIndex):RT===`knowledge`?(r=document.getElementById(`agentKnowledgeList`),i=H.selectedKnowledgeAtIndex):(r=document.getElementById(`agentAtList`),i=H.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?(H.selectedAgentAtIndex=t,aE(a)):RT===`proxies`?(H.selectedProxyAtIndex=t,aE(a)):RT===`knowledge`?(H.selectedKnowledgeAtIndex=t,aE(a)):RT===`pages`?(H.selectedPageIndex=t,EE(a)):(H.selectedAgentAtIndex=t,aE(a));return}if(e.key===`ArrowUp`){e.preventDefault();let t=i<0||i===0?o-1:i-1;n?(H.selectedAgentAtIndex=t,aE(a)):RT===`proxies`?(H.selectedProxyAtIndex=t,aE(a)):RT===`knowledge`?(H.selectedKnowledgeAtIndex=t,aE(a)):RT===`pages`?(H.selectedPageIndex=t,EE(a)):(H.selectedAgentAtIndex=t,aE(a));return}if(e.key===`Enter`&&i>=0){e.preventDefault(),a[i].click(),(e.ctrlKey||e.metaKey)&&UT();return}if(e.key===`Escape`){UT();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`){if(e.preventDefault(),r>0){let t=e.key===`ArrowDown`?H.selectedFileAtIndex<0?0:(H.selectedFileAtIndex+1)%r:H.selectedFileAtIndex<0||H.selectedFileAtIndex===0?r-1:H.selectedFileAtIndex-1;H.selectedFileAtIndex=t,eM(n)}return}if(e.key===`Enter`&&r>0&&H.selectedFileAtIndex>=0){e.preventDefault(),n[H.selectedFileAtIndex].click();return}if(e.key===`Escape`){e.preventDefault(),Yj();return}}if(n.style.display!==`none`&&r.classList.contains(`show`)){if(H.showMergedList){let t=r.querySelectorAll(`#promptList .prompt-item`),n=t.length;if(e.key===`ArrowDown`){e.preventDefault(),H.selectedPromptIndex<0?H.selectedPromptIndex=0:H.selectedPromptIndex=(H.selectedPromptIndex+1)%n,PO(t);return}if(e.key===`ArrowUp`){e.preventDefault(),H.selectedPromptIndex<0||H.selectedPromptIndex===0?H.selectedPromptIndex=n-1:--H.selectedPromptIndex,PO(t);return}if(e.key===`Enter`&&H.selectedPromptIndex>=0){e.preventDefault();let n=t[H.selectedPromptIndex];n.dataset.type===`skill`||n.dataset.type===`mcp`?(n.click(),(e.ctrlKey||e.metaKey)&&kO()):e.ctrlKey||e.metaKey?FO(n.dataset.code):IO(n.dataset.code);return}if(e.key===`Escape`){kO();return}return}if(H.activeDropdownTab===`skills`){let t=r.querySelectorAll(`#skillList .skill-list-item`),n=t.length;if(e.key===`ArrowDown`){e.preventDefault(),H.selectedSkillIndex<0?H.selectedSkillIndex=0:H.selectedSkillIndex=(H.selectedSkillIndex+1)%n,nk(t);return}if(e.key===`ArrowUp`){e.preventDefault(),H.selectedSkillIndex<0||H.selectedSkillIndex===0?H.selectedSkillIndex=n-1:--H.selectedSkillIndex,nk(t);return}if(e.key===`Enter`&&H.selectedSkillIndex>=0){e.preventDefault(),t[H.selectedSkillIndex].click(),(e.ctrlKey||e.metaKey)&&kO();return}if(e.key===`Escape`){kO();return}if(e.key===`Tab`){e.preventDefault();let t=document.getElementById(`mcpTab`);t&&t.style.display!==`none`?lk(`mcp`):lk(`prompts`);return}return}if(H.activeDropdownTab===`mcp`){let t=r.querySelectorAll(`#mcpList .mcp-list-item`),n=t.length;if(e.key===`ArrowDown`){e.preventDefault(),H.selectedMcpServiceIndex<0?H.selectedMcpServiceIndex=0:H.selectedMcpServiceIndex=(H.selectedMcpServiceIndex+1)%n,gk(t);return}if(e.key===`ArrowUp`){e.preventDefault(),H.selectedMcpServiceIndex<0||H.selectedMcpServiceIndex===0?H.selectedMcpServiceIndex=n-1:--H.selectedMcpServiceIndex,gk(t);return}if(e.key===`Enter`&&H.selectedMcpServiceIndex>=0){e.preventDefault(),t[H.selectedMcpServiceIndex].click(),(e.ctrlKey||e.metaKey)&&kO();return}if(e.key===`Escape`){kO();return}if(e.key===`Tab`){e.preventDefault(),lk(`prompts`);return}return}let t=r.querySelectorAll(`#promptList .prompt-item`),n=t.length;if(e.key===`Tab`){let t=document.getElementById(`skillsTab`),n=document.getElementById(`mcpTab`);if(t&&t.style.display!==`none`){e.preventDefault(),lk(`skills`);return}if(n&&n.style.display!==`none`){e.preventDefault(),lk(`mcp`);return}}if(n!==0&&e.key===`ArrowDown`){e.preventDefault(),H.selectedPromptIndex<0?H.selectedPromptIndex=0:H.selectedPromptIndex=(H.selectedPromptIndex+1)%n,PO(t);return}if(e.key===`ArrowUp`){e.preventDefault(),H.selectedPromptIndex<0||H.selectedPromptIndex===0?H.selectedPromptIndex=n-1:--H.selectedPromptIndex,PO(t);return}if(e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&H.selectedPromptIndex>=0){e.preventDefault();let n=t[H.selectedPromptIndex].dataset.code;FO(n);return}if(e.key===`Enter`&&H.selectedPromptIndex>=0){e.preventDefault();let n=t[H.selectedPromptIndex].dataset.code;IO(n);return}if(e.key===`Escape`){kO();return}}if(e.key===`Escape`){H.inputHistoryIndex>=0&&(H.inputHistoryIndex=-1),t.value&&(t.value=``,t.style.height=`auto`,t.dispatchEvent(new Event(`input`))),e.preventDefault();return}let c=n.style.display!==`none`&&r.classList.contains(`show`),l=i.style.display!==`none`&&a.classList.contains(`show`),u=o.style.display!==`none`&&s.classList.contains(`show`);if(!c&&!l&&!u&&!H.isGenerating){if(e.key===`ArrowUp`){e.preventDefault(),H.inputHistoryIndex===-1?H.inputHistoryIndex=H.inputHistory.length-1:H.inputHistoryIndex>0&&H.inputHistoryIndex--,H.inputHistoryIndex<0&&(H.inputHistoryIndex=0),H.inputHistoryIndex>=0&&H.inputHistory.length>0&&(t.value=H.inputHistory[H.inputHistoryIndex],t.dispatchEvent(new Event(`input`)));return}if(e.key===`ArrowDown`){e.preventDefault(),H.inputHistoryIndex>=0&&H.inputHistoryIndex<H.inputHistory.length-1?(H.inputHistoryIndex++,t.value=H.inputHistory[H.inputHistoryIndex],t.dispatchEvent(new Event(`input`))):(H.inputHistoryIndex=-1,t.value=``,t.dispatchEvent(new Event(`input`)));return}}if(e.key===`Enter`&&!e.shiftKey){if(H.isComposing)return;e.preventDefault(),Yj(),eO()}}),t.addEventListener(`compositionstart`,()=>{H.isComposing=!0}),t.addEventListener(`compositionend`,()=>{H.isComposing=!1}),t.addEventListener(`paste`,e=>{let t=e.clipboardData?.items;if(t)for(let n of t){if(n.type.startsWith(`image/`)&&H.enableImageInput){e.preventDefault();let t=n.getAsFile();t&&gc(t);break}if(n.kind===`file`&&H.enableFileInput){e.preventDefault();let t=n.getAsFile();t&&Zc([t]);break}}});let re=document.getElementById(`fileAttachBtn`),ie=document.getElementById(`fileInput`);re&&ie&&(re.addEventListener(`click`,()=>{ie.click()}),ie.addEventListener(`change`,async()=>{if(ie.files.length>0){let e=Array.from(ie.files),t=e.filter(e=>e.type.startsWith(`image/`)),n=e.filter(e=>!e.type.startsWith(`image/`));if(t.length>0){if(H.enableImageInput)for(let e of t)await gc(e);else U(i(`sidePanel.imageNotEnabled`)),Zc(t)}n.length>0&&Zc(n),ie.value=``}}));let ae=document.querySelector(`.input-wrapper`),oe=0;ae&&(ae.addEventListener(`dragenter`,e=>{e.preventDefault(),e.stopPropagation(),oe++,ae.classList.add(`drag-over`)}),ae.addEventListener(`dragleave`,e=>{e.preventDefault(),e.stopPropagation(),oe--,oe<=0&&(oe=0,ae.classList.remove(`drag-over`))}),ae.addEventListener(`dragover`,e=>{e.preventDefault(),e.stopPropagation()}),ae.addEventListener(`drop`,async e=>{e.preventDefault(),e.stopPropagation(),oe=0,ae.classList.remove(`drag-over`);let t=e.dataTransfer.getData(`application/x-workspace-file`);if(t)try{let{path:e}=JSON.parse(t);if(e){Gw([e]);return}}catch(e){o.warn(`[SidePanel] parse workspace dragdata failed:`,e)}let n=Array.from(e.dataTransfer.files);if(n.length>0){let e=n.filter(e=>e.type.startsWith(`image/`)),t=n.filter(e=>!e.type.startsWith(`image/`));if(e.length>0){if(H.enableImageInput)for(let t of e)await gc(t);else U(i(`sidePanel.imageNotEnabled`)),Zc(e)}t.length>0&&Zc(t)}}));let B=document.getElementById(`screenshotBtn`);B&&B.addEventListener(`click`,async()=>{if(H.enableImageInput)try{await ru()}catch(e){o.error(`[SidePanel] screenshot failed:`,e),U(i(`sidePanel.screenshotFailed`))}}),mc(),t.addEventListener(`wheel`,e=>{H.isScrolling=!0;let n=t.style.height||t.offsetHeight+`px`;t.style.height=n,t.scrollHeight<=t.clientHeight+10&&(e.preventDefault(),e.stopPropagation()),setTimeout(()=>{H.isScrolling=!1},100)},{passive:!1}),t.addEventListener(`input`,e=>{let n=t.value,r=document.getElementById(`promptSelector`),i=document.getElementById(`promptDropdown`);document.getElementById(`agentAtSelector`),document.getElementById(`agentAtDropdown`);let a=n.lastIndexOf(`/`),o=n.lastIndexOf(`@`),s=n.lastIndexOf(`$`),c=e=>{if(e===-1||e!==0&&n[e-1]!==`
|
|
2714
2720
|
`&&n[e-1]!==` `)return!1;let t=n.substring(e+1);return!(t.includes(` `)||t.includes(`
|
|
2715
|
-
`))},l=c(a),u=c(o),d=c(s),f=null;if(l&&(f={key:`slash`,index:a}),u&&(!f||o>f.index)&&(f={key:`at`,index:o}),d&&(!f||s>f.index)&&(f={key:`dollar`,index:s}),f&&f.key===`dollar`)
|
|
2721
|
+
`))},l=c(a),u=c(o),d=c(s),f=null;if(l&&(f={key:`slash`,index:a}),u&&(!f||o>f.index)&&(f={key:`at`,index:o}),d&&(!f||s>f.index)&&(f={key:`dollar`,index:s}),f&&f.key===`dollar`)kO(),UT(),Jj(n.substring(s+1));else if(f&&f.key===`at`)kO(),Yj(),VT(n.substring(o+1));else if(f&&f.key===`slash`){UT(),Yj();let e=n.substring(a+1);r.style.display!==`none`&&i.classList.contains(`show`)?jO(e):OO(e)}else kO(),UT(),Yj();_()}),u.addEventListener(`scroll`,()=>{let e=`scrollPosition_`+(H.activeSessionId||`default`);chrome.storage.local.set({[e]:u.scrollTop})});let se=document.getElementById(`headerMoreBtn`),V=document.getElementById(`headerMoreDropdown`);se&&V&&(se.addEventListener(`click`,e=>{e.stopPropagation(),V.classList.toggle(`show`)}),document.addEventListener(`click`,e=>{!V.contains(e.target)&&e.target!==se&&V.classList.remove(`show`)})),r.addEventListener(`click`,e=>{e.stopPropagation(),V.classList.remove(`show`),JD()}),c&&c.addEventListener(`click`,e=>{e.stopPropagation(),V.classList.remove(`show`),Ts()});let ce=document.getElementById(`importChatBtn`);ce&&ce.addEventListener(`click`,e=>{e.stopPropagation(),V.classList.remove(`show`),As()});let le=document.getElementById(`importSessionsFile`);le&&le.addEventListener(`change`,e=>{let t=e.target.files[0];t&&js(t)});let ue=document.getElementById(`settingsBtn`);ue&&ue.addEventListener(`click`,()=>{chrome.runtime.openOptionsPage()});let de=document.getElementById(`headerAgentIndicator`);de&&de.addEventListener(`click`,async()=>{let e=chrome.runtime.getURL(`options.html#agent`),t=await chrome.tabs.query({url:chrome.runtime.getURL(`options.html`)});t.length>0?await chrome.tabs.update(t[0].id,{active:!0,url:e}):await chrome.tabs.create({url:e})});let pe=document.getElementById(`prototypeLibraryBtn`);pe&&pe.addEventListener(`click`,e=>{e.stopPropagation(),V.classList.remove(`show`),oo()});let me=document.getElementById(`tokenStatsHeaderBtn`);me&&me.addEventListener(`click`,e=>{e.stopPropagation(),V.classList.remove(`show`),window.openTokenStats&&window.openTokenStats()});let he=document.getElementById(`auditLogBtn`),ge=document.getElementById(`auditLogOverlay`),_e=document.getElementById(`auditLogClose`),ve=document.getElementById(`auditLogRefreshBtn`),ye=document.getElementById(`auditLogCategoryFilter`),be=document.getElementById(`auditLogLimit`),xe=document.getElementById(`auditLogSearch`),Se=document.getElementById(`auditLogSearchClear`),Ce=document.getElementById(`auditLogLoading`),we=document.getElementById(`auditLogEmpty`),Te=document.getElementById(`auditLogList`),Ee=[],De={auth:i(`sidePanel.auditCategoryAuth`),fs:i(`sidePanel.auditCategoryFs`),exec:i(`sidePanel.auditCategoryExec`),security:i(`sidePanel.auditCategorySecurity`),system:i(`sidePanel.auditCategorySystem`)},ke={info:`INFO`,warn:`WARN`,error:`ERROR`},je={info:`audit-level-info`,warn:`audit-level-warn`,error:`audit-level-error`};function Ne(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 Pe(e){let t=new Set([`timestamp`,`level`,`category`,`action`]),n=[];for(let[r,i]of Object.entries(e)){if(t.has(r))continue;let e=typeof i==`string`?i:JSON.stringify(i),a=e.length>60?e.slice(0,60)+`...`:e;n.push(`${r}: ${a}`)}return n.join(i(`sidePanel.auditDetailSeparator`))}async function Fe(){if(!Ce||!we||!Te)return;Ce.style.display=`block`,we.style.display=`none`,Te.style.display=`none`;let e=ye?.value||null,t=parseInt(be?.value||`200`,10);try{let n=await new Promise((n,r)=>{chrome.runtime.sendMessage({type:`QUERY_AUDIT_LOGS`,category:e,limit:t},e=>{chrome.runtime.lastError?r(Error(chrome.runtime.lastError.message)):n(e)})});if(Ce.style.display=`none`,!n||!n.success){we.style.display=`block`,we.textContent=i(`sidePanel.auditQueryFailed`,{error:n?.error||i(`sidePanel.unknownError`)});return}Ee=n.entries||[],Ie()}catch(e){Ce.style.display=`none`,we.style.display=`block`,we.textContent=i(`sidePanel.auditLoadFailed`,{error:e.message})}}function Ie(){if(!Te)return;let e=(xe?.value||``).trim().toLowerCase(),t=Ee;if(e&&(t=t.filter(t=>[t.action||``,t.category||``,...Object.entries(t).filter(([e])=>![`timestamp`,`level`,`category`,`action`].includes(e)).map(([,e])=>typeof e==`string`?e:JSON.stringify(e))].join(` `).toLowerCase().includes(e))),Se&&(Se.style.display=e?`block`:`none`),Ce.style.display=`none`,t.length===0){we.style.display=`block`,we.textContent=i(e?`sidePanel.auditNoMatch`:`sidePanel.auditEmpty`),Te.style.display=`none`;return}we.style.display=`none`,Te.style.display=`block`,Te.innerHTML=t.map(e=>{let t=De[e.category]||e.category||`-`,n=ke[e.level]||e.level?.toUpperCase()||`INFO`,r=je[e.level]||`audit-level-info`,i=Ne(e.timestamp),a=Pe(e);return`<div class="audit-entry">
|
|
2716
2722
|
<div class="audit-entry-header">
|
|
2717
2723
|
<span class="audit-time">${i}</span>
|
|
2718
2724
|
<span class="audit-level ${r}">${n}</span>
|
|
@@ -2720,7 +2726,7 @@ Are you sure you want to stop the agent service? You will not be able to connect
|
|
|
2720
2726
|
<span class="audit-action">${e.action||`-`}</span>
|
|
2721
2727
|
</div>
|
|
2722
2728
|
${a?`<div class="audit-details">${a}</div>`:``}
|
|
2723
|
-
</div>`}).join(``)}function Le(){ge&&(ge.style.display=`flex`,Fe())}function Re(){ge&&(ge.style.display=`none`)}he&&he.addEventListener(`click`,e=>{e.stopPropagation(),V.classList.remove(`show`),Le()}),_e&&_e.addEventListener(`click`,Re),ve&&ve.addEventListener(`click`,Fe),ye&&ye.addEventListener(`change`,Fe),be&&be.addEventListener(`change`,Fe),xe&&xe.addEventListener(`input`,()=>{Ie()}),Se&&Se.addEventListener(`click`,()=>{xe&&(xe.value=``),Ie()}),
|
|
2729
|
+
</div>`}).join(``)}function Le(){ge&&(ge.style.display=`flex`,Fe())}function Re(){ge&&(ge.style.display=`none`)}he&&he.addEventListener(`click`,e=>{e.stopPropagation(),V.classList.remove(`show`),Le()}),_e&&_e.addEventListener(`click`,Re),ve&&ve.addEventListener(`click`,Fe),ye&&ye.addEventListener(`change`,Fe),be&&be.addEventListener(`change`,Fe),xe&&xe.addEventListener(`input`,()=>{Ie()}),Se&&Se.addEventListener(`click`,()=>{xe&&(xe.value=``),Ie()}),IM(()=>H.activeSessionId,showCustomConfirm);let ze=document.getElementById(`isolateChatBtn`),Be=document.getElementById(`enableToolsBtn`),Ve=document.getElementById(`toolsConfigBtn`),He=`agentEnabledTools_${H.activeAgentId||`default`}`,Ue=`agentMcpClosedServers_${H.activeAgentId||`default`}`;chrome.storage.local.get([He,`enabledTools`,`isolateChat`,`enableSelectionQuery`,`enableTools`,Ue,`mcpTools`,`mcpEnabled`,`ragTools`,`ragToolsIntroduced`],e=>{e.isolateChat!==void 0&&(H.isolateChat=e.isolateChat),ze.checked=H.isolateChat,e.enableSelectionQuery!==void 0&&(H.enableSelectionQuery=e.enableSelectionQuery);let t=document.getElementById(`enableSelectionQueryBtn`);t&&(t.checked=H.enableSelectionQuery),e.enableTools!==void 0&&(H.useTools=e.enableTools),H.activeAgentId&&fe(async()=>{let{getAgent:e}=await import(`./agent-store-DOyMdB_7.js`).then(e=>e.t);return{getAgent:e}},__vite__mapDeps([0,1,2,3])).then(({getAgent:e})=>e(H.activeAgentId)).then(e=>{H.activeAgentMcpExcludedServerIds=e?e.mcpExcludedServerIds??null:null,yn()}).catch(()=>{}),H.mcpClosedServers=e[Ue]||[];let n=e.ragTools||[],r=e[He],i=e.enabledTools;if(Array.isArray(r)){let t=new Set([...f.map(e=>e.id),...n.map(e=>e.id)]),i=r.filter(e=>t.has(e));H.enabledTools=i;let a=xn(H.enabledTools,n,e.ragToolsIntroduced);H.enabledTools=a.tools,a.migrated?chrome.storage.local.set({ragToolsIntroduced:!0,[He]:H.enabledTools}):H.enabledTools.length!==r.length&&chrome.storage.local.set({[He]:H.enabledTools})}else if(i&&i.length>0){let t=new Set([...f.map(e=>e.id),...n.map(e=>e.id)]),r=i.filter(e=>t.has(e)),a=f.filter(e=>e.enabled&&!r.includes(e.id)).map(e=>e.id);H.enabledTools=[...r,...a];let o=xn(H.enabledTools,n,e.ragToolsIntroduced);H.enabledTools=o.tools,chrome.storage.local.set({[He]:H.enabledTools,...o.migrated?{ragToolsIntroduced:!0}:{}})}else{H.enabledTools=f.filter(e=>e.enabled).map(e=>e.id);let t=xn(H.enabledTools,n,e.ragToolsIntroduced);H.enabledTools=t.tools,t.migrated&&chrome.storage.local.set({ragToolsIntroduced:!0,[He]:H.enabledTools})}Be&&(Be.checked=H.useTools),yn(),E()}),ze.addEventListener(`change`,()=>{H.isolateChat=ze.checked,chrome.storage.local.set({isolateChat:H.isolateChat}),o.debug(`[SidePanel] conv memory:`,H.isolateChat?`enabled`:`disabled`)});let We=document.getElementById(`enableSelectionQueryBtn`);We&&We.addEventListener(`change`,()=>{H.enableSelectionQuery=We.checked,chrome.storage.local.set({enableSelectionQuery:H.enableSelectionQuery}),o.debug(`[SidePanel] text Q&A:`,H.enableSelectionQuery?`enabled`:`disabled`),!H.enableSelectionQuery&&H.selectedContextText&&BD()}),Be&&Be.addEventListener(`change`,()=>{H.useTools=Be.checked,chrome.storage.local.set({enableTools:H.useTools}),o.debug(`[SidePanel] tool master switch:`,H.useTools?`enabled`:`disabled`),yn()}),Ve&&Ve.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),an()});let Ge=document.getElementById(`toolsPopupOverlay`),Ke=document.getElementById(`toolsPopupClose`),qe=Ge?Ge.querySelector(`.modal-container`):null;Ke&&Ke.addEventListener(`click`,on),qe&&qe.addEventListener(`click`,e=>{e.stopPropagation()});let Je=document.getElementById(`toolsSearchInput`),Ye=document.getElementById(`toolsSearchClear`);Je&&Je.addEventListener(`input`,e=>{H.currentSearch=e.target.value.toLowerCase(),Ye&&(Ye.style.display=e.target.value?``:`none`),sn()}),Ye&&Ye.addEventListener(`click`,()=>{Je&&(Je.value=``,Ye.style.display=`none`,H.currentSearch=``,sn())});let Xe=document.querySelectorAll(`.category-btn`);Xe.forEach(e=>{e.addEventListener(`click`,()=>{Xe.forEach(e=>{e.classList.remove(`active`),e.classList.contains(`category-all`)?(e.style.background=`#f5f3ff`,e.style.color=`#667eea`,e.style.borderColor=`#d4cfff`):(e.style.background=`white`,e.style.color=`#555`,e.style.borderColor=`#ececec`)}),e.classList.add(`active`),e.style.background=`linear-gradient(135deg, #667eea 0%, #764ba2 100%)`,e.style.color=`white`,e.style.borderColor=`transparent`,H.currentCategory=e.dataset.category,sn()})});let Ze=document.getElementById(`toolsCategories`);Ze&&Ze.addEventListener(`wheel`,e=>{e.preventDefault(),Ze.scrollLeft+=e.deltaY*2},{passive:!1});let $e=document.getElementById(`toolsSelectAll`),et=document.getElementById(`toolsSelectNone`);$e&&$e.addEventListener(`click`,()=>{pn().forEach(e=>{let t=document.getElementById(`tool_`+e.id);t&&(t.checked=!0),H.enabledTools.includes(e.id)||H.enabledTools.push(e.id)}),vn(!0),mn(),hn(),gn()}),et&&et.addEventListener(`click`,()=>{pn().forEach(e=>{let t=document.getElementById(`tool_`+e.id);t&&(t.checked=!1);let n=H.enabledTools.indexOf(e.id);n>-1&&H.enabledTools.splice(n,1)}),vn(!1),mn(),hn(),gn()});let tt=document.getElementById(`toolsPopupSave`);tt&&tt.addEventListener(`click`,()=>{_n(),gn()});let nt=document.getElementById(`toolsPreselectToggle`);nt&&nt.addEventListener(`change`,()=>{chrome.storage.local.set({enableToolPreselect:nt.checked},()=>{o.debug(`[SidePanel] toolpre-filter toggle updated:`,nt.checked)})});let rt=document.getElementById(`toolConfirmToggle`);rt&&rt.addEventListener(`change`,()=>{chrome.storage.local.set({toolConfirmationEnabled:rt.checked},()=>{o.debug(`[SidePanel] sensitive-operation confirmation toggle updated:`,rt.checked)})});let it=document.getElementById(`toolsPopupCancel`);it&&it.addEventListener(`click`,()=>{on()});let at=document.getElementById(`modalCancelBtn`),ot=document.getElementById(`modalConfirmBtn`),st=document.getElementById(`toolStatsOverlay`),ct=document.getElementById(`toolStatsClose`),lt=document.getElementById(`toolStatsBtn`);function ut(){st&&(st.style.display=`flex`,ht())}function dt(){st&&(st.style.display=`none`)}lt&<.addEventListener(`click`,e=>{e.stopPropagation(),ut()}),ct&&ct.addEventListener(`click`,dt),st&&st.addEventListener(`click`,e=>{e.target===st&&dt()});let ft=document.getElementById(`toolStatsRefreshBtn`);ft&&ft.addEventListener(`click`,ht);let pt=document.getElementById(`toolStatsClearBtn`);pt&&pt.addEventListener(`click`,async()=>{await showCustomConfirm(i(`sidePanel.clearStatsConfirm`),i(`sidePanel.clearStatsTitle`))&&(await chrome.storage.local.remove([`toolUsageStats`]),ht())});let mt={column:`callCount`,asc:!1};async function ht(){let e=document.getElementById(`toolStatsTable`),t=document.getElementById(`toolStatsTableBody`),n=document.getElementById(`toolStatsLoading`),r=document.getElementById(`toolStatsEmpty`),a=document.getElementById(`toolStatsSummary`),s=document.getElementById(`toolStatsUnusedSection`),c=document.getElementById(`toolStatsUnusedList`);if(!(!e||!t||!n||!r)){e.style.display=`none`,r.style.display=`none`,s&&(s.style.display=`none`),a&&(a.textContent=``),n.style.display=``;try{let t=(await chrome.storage.local.get([`toolUsageStats`])).toolUsageStats||{},o=Object.entries(t);if(o.length===0){n.style.display=`none`,r.style.display=``;return}let l={};f.forEach(e=>{l[e.id]=e.name?`${e.name}${i(`sidePanel.toolNameDescSeparator`)}${e.description||``}`:e.description||e.id}),gt(o,l);let u=f.map(e=>e.id),d=new Set(o.map(([e])=>e)),p=u.filter(e=>!d.has(e)),m=o.length,h=p.length;a&&(a.textContent=i(`sidePanel.toolStatsSummary`,{used:m,unused:h})),s&&c&&h>0&&(c.innerHTML=p.sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())).map(e=>`<code title="${W(l[e]||e)}" style="padding: 3px 10px; background: #f5f5f5; color: #aaa; border: 1px solid #eee; border-radius: 4px; font-size: 11px;">${e}</code>`).join(``),s.style.display=``),n.style.display=`none`,e.style.display=``}catch(e){o.error(`[SidePanel] loadstats failed:`,e),n.style.display=`none`,r.textContent=i(`sidePanel.toolStatsLoadFailed`),r.style.display=``}}}function gt(e,t){let n=document.getElementById(`toolStatsTableBody`);if(!n)return;let{column:r,asc:i}=mt;n.innerHTML=[...e].sort((e,t)=>{let[n,a]=e,[o,s]=t,c=a.callCount>0?a.successCount/a.callCount*100:0,l=s.callCount>0?s.successCount/s.callCount*100:0,u=a.callCount>0?a.totalDuration/a.callCount:0,d=s.callCount>0?s.totalDuration/s.callCount:0,f=0;switch(r){case`name`:f=n.toLowerCase().localeCompare(o.toLowerCase());break;case`callCount`:f=a.callCount-s.callCount;break;case`successCount`:f=a.successCount-s.successCount;break;case`successRate`:f=c-l;break;case`duration`:f=u-d}return i?f:-f}).map(([e,n])=>{let r=n.callCount>0?n.successCount/n.callCount*100:0,i=n.callCount>0?n.totalDuration/n.callCount:0,a=t[e]||e,o=`#38a169`;r<60?o=`#e53e3e`:r<85&&(o=`#d69e2e`);let s=Me(i);return`<tr>
|
|
2724
2730
|
<td style="padding: 6px 10px; border-bottom: 1px solid #eee; color: #333;"><code title="${W(a)}">${e}</code></td>
|
|
2725
2731
|
<td style="padding: 6px 10px; text-align: right; border-bottom: 1px solid #eee; color: #666;">${n.callCount}</td>
|
|
2726
2732
|
<td style="padding: 6px 10px; text-align: right; border-bottom: 1px solid #eee; color: #666;">${n.successCount}</td>
|
|
@@ -2731,5 +2737,5 @@ Are you sure you want to stop the agent service? You will not be able to connect
|
|
|
2731
2737
|
<span style="font-size: 12px; color: ${o}; font-weight: 500;">${r.toFixed(0)}%</span>
|
|
2732
2738
|
</td>
|
|
2733
2739
|
<td style="padding: 6px 10px; text-align: right; border-bottom: 1px solid #eee; color: #888; font-size: 12px;">${s}</td>
|
|
2734
|
-
</tr>`}).join(``),_t()}function _t(){let{column:e,asc:t}=mt,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=`#667eea`):(a.textContent=``,a.style.color=``))})}document.querySelectorAll(`#toolStatsTable th[data-sort]`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.sort;mt.column===t?mt.asc=!mt.asc:(mt.column=t,mt.asc=!1),ht()})}),at.addEventListener(`click`,()=>{
|
|
2735
|
-
//# sourceMappingURL=side_panel-
|
|
2740
|
+
</tr>`}).join(``),_t()}function _t(){let{column:e,asc:t}=mt,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=`#667eea`):(a.textContent=``,a.style.color=``))})}document.querySelectorAll(`#toolStatsTable th[data-sort]`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.sort;mt.column===t?mt.asc=!mt.asc:(mt.column=t,mt.asc=!1),ht()})}),at.addEventListener(`click`,()=>{YD()}),ot.addEventListener(`click`,()=>{YD(),qD()});let vt=document.getElementById(`confirmModal`);vt.addEventListener(`click`,e=>{e.target===vt&&YD()});let yt=document.getElementById(`selectionClose`);yt&&yt.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),o.debug(`[SidePanel] user clickcloseselected content by button`),BD(),window.hideFloatingMenu(),H.lastSelectedText=``,H.currentSelectionRange=null}),t.addEventListener(`input`,()=>{})}),Xe().then(()=>{LM(),cO(H.chatConfig.showMessageTimestamp!==!1)}),document.addEventListener(`DOMContentLoaded`,()=>{zM()}),document.addEventListener(`DOMContentLoaded`,yt),document.addEventListener(`DOMContentLoaded`,CA),document.addEventListener(`DOMContentLoaded`,WM),document.addEventListener(`DOMContentLoaded`,zj),document.addEventListener(`DOMContentLoaded`,FM),document.addEventListener(`DOMContentLoaded`,async()=>{ht(),await nl(),ul(),BA(),lj(),cN(),hx(),vj();let{updateBookmarkButtons:e,updateBookmarkBadge:t}=await fe(async()=>{let{updateBookmarkButtons:e,updateBookmarkBadge:t}=await Promise.resolve().then(()=>ll);return{updateBookmarkButtons:e,updateBookmarkBadge:t}},void 0);e(),t()}),document.addEventListener(`DOMContentLoaded`,qO),document.addEventListener(`DOMContentLoaded`,ck),document.addEventListener(`DOMContentLoaded`,dk),document.addEventListener(`DOMContentLoaded`,Sk),document.addEventListener(`DOMContentLoaded`,jE),document.addEventListener(`DOMContentLoaded`,Pn),document.addEventListener(`DOMContentLoaded`,Vn),document.addEventListener(`DOMContentLoaded`,wo),document.addEventListener(`DOMContentLoaded`,ks),document.addEventListener(`DOMContentLoaded`,()=>Tk()),document.addEventListener(`DOMContentLoaded`,async()=>{let{refreshAgentNames:e,initScrollToBottomBtn:t}=await fe(async()=>{let{refreshAgentNames:e,initScrollToBottomBtn:t}=await Promise.resolve().then(()=>XE);return{refreshAgentNames:e,initScrollToBottomBtn:t}},void 0);e(),t()}),document.addEventListener(`DOMContentLoaded`,()=>{let e=new URLSearchParams(window.location.search).has(`popup`),t=document.getElementById(`detachBtn`),n=document.getElementById(`attachBtn`),r=e?n:t;e?n&&(n.style.display=`flex`):t&&(t.style.display=`flex`);let a=()=>{if(!r)return;let t=H.pendingCallApiSessionIds&&H.pendingCallApiSessionIds.size>0;r.disabled=t,r.style.opacity=t?`0.35`:``,r.style.cursor=t?`not-allowed`:`pointer`,r.title=i(t?`detach.taskRunning`:e?`header.attachTitle`:`header.detachTitle`)};a(),document.addEventListener(`generating-state-changed`,a),t&&t.addEventListener(`click`,async()=>{if(H.pendingCallApiSessionIds&&H.pendingCallApiSessionIds.size>0){U(i(`detach.taskRunning`),`warning`);return}try{if((await chrome.runtime.sendMessage({type:`DETACH_SIDEPANEL`,width:window.innerWidth}))?.success)try{window.close()}catch{}}catch(e){o.warn(`[SidePanel] detach failed:`,e?.message)}}),n&&n.addEventListener(`click`,async()=>{if(H.pendingCallApiSessionIds&&H.pendingCallApiSessionIds.size>0){U(i(`detach.taskRunning`),`warning`);return}try{let e=(await chrome.windows.getCurrent()).id;await chrome.runtime.sendMessage({type:`ATTACH_SIDEPANEL`,windowId:e});try{window.close()}catch{}}catch(e){o.warn(`[SidePanel] attach failed:`,e?.message)}})});
|
|
2741
|
+
//# sourceMappingURL=side_panel-BNz8cBkP.js.map
|