filecat 6.43.0 → 6.43.1
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/build/dist/{1472.867585ea92a674d71be0.js → 1472.9f2f9993afc6e101c686.js} +1 -1
- package/build/dist/678.dfd1b8d8d60638ed8c01.js +1 -0
- package/build/dist/9572.304acc81bcceeb2ade2a.js +2 -0
- package/build/dist/9572.304acc81bcceeb2ade2a.js.LICENSE.txt +1 -0
- package/build/dist/index.html +1 -1
- package/build/dist/main.f5ae546b9e1a49886e3e.js +2 -0
- package/build/main.js +1 -1
- package/build/threads.work.filecat.js +1 -1
- package/package.json +1 -1
- package/build/dist/1993.b1ba1a029df5a082a3d1.js +0 -1
- package/build/dist/9572.15d24fe0e25a824b3553.js +0 -2
- package/build/dist/9572.15d24fe0e25a824b3553.js.LICENSE.txt +0 -1
- package/build/dist/main.4313cfecedaeb3303051.js +0 -2
- /package/build/dist/{main.4313cfecedaeb3303051.js.LICENSE.txt → main.f5ae546b9e1a49886e3e.js.LICENSE.txt} +0 -0
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[1993,6010],{83277(e,s,t){t.d(s,{$j:()=>o,Lv:()=>a,qq:()=>i});class n{options_agent_url_list;options_agent_key_list;options_agent_model_list;options_local_file_path_prompt_list}class a{token;open=!1;note;index;url;model;request_type;json_params;sys_prompt;dotenv="";tool_mode=!1;show_options;static get_label_by_v(e,s){if(!e||!s?.length)return e;for(const t of s)if(t.value===e)return t.label;return e}static have_label_by_v(e,s){if(!e||!s?.length)return!1;for(const t of s)if(t.value===e)return!0;return!1}}class i extends n{tool_error_max=50;tool_call_max=300;allow_exec_cmd_directly=!1;proxy_url;open_pick_model}const c=JSON.stringify({stream:!0,thinking:{type:"disabled"}});function o(e){return"string"==typeof e?e:Array.isArray(e)?e.map(e=>"text"===e.type?e.text:"[图片]").join("\n"):""}t.d(s,["CP",0,'\n\n# 工具报错最大尝试次数\ntool_error_max=50\n# 聊天循环最大次数\ntool_call_max=300\n# 是否允许AI直接执行命令而不需要用户确认,默认为false,需要用户手动确认,如果使用 workflow 这里等价于为 true\nallow_exec_cmd_directly=false\n\n# 可选的代理 url,如果指定了所有访问大模型的请求将会走代理\n#proxy_url=\n\n# 可选的多个url 以数组分割\n# options_agent_url_list=[{"value":"http://..","label":"openai"}]\n\n# 可选的多个 key\n# options_agent_key_list=[{"value":"sh-aaa","label":"option1"}]\n\n# 可选的多个 model\n# options_agent_model_list=[{"value":"gpt-5.5","label":"gpt"}]\n\n# 存放本地的 prompt 文件 用于每次聊天的时候自动读取并加载\n# options_local_file_path_prompt_list=["/prompt/a.txt"]\n\n# 开启切换模型 ,开启以后,你可以自己写 prompt 提供多个模型让 ai 自己根据每次聊天切换下一步调用其他模型的次数\n# open_pick_model=false\n',"cL",0,c])},88038(e,s,t){t.r(s),t.d(s,{default:()=>Y});var n=t(96540),a=t(34843),i=t(22022),c=t(61973),o=t(92275),l=t(14284),r=t(7463),d=t(78247),u=t(40505),m=t(62042),h=t(45907),g=t(53459),p=t(72693),x=t(82893),_=t(61443),f=t(83277);function j(e){const s=(0,f.$j)(e.content);if(s)return s;const t=e.content_list??[];return t.length?t.map(e=>(0,f.$j)(e.content)).filter(Boolean).join("\n\n"):""}const v=/\.(md|txt|json|js|jsx|ts|tsx|css|html?|xml|ya?ml|py|java|go|rs|c|cpp|h|hpp|sh|bat|cmd|ini|toml|csv|log|sql|env|gitignore|dockerfile)$/i;function b(e){return e.type?.startsWith("image/")?"image":e.type?.startsWith("text/")||v.test(e.name)?"text":"binary"}function y(e){return e.text()}function S(e){return new Promise((s,t)=>{const n=new FileReader;n.onload=()=>s(n.result),n.onerror=t,n.readAsDataURL(e)})}async function w(e){const s=[];for(const t of e){const e=b(t);let n="";if("text"===e)try{const e=await y(t),s=12e4;n=e.length>s?`${e.slice(0,s)}\n\n[内容已截断,原始长度 ${e.length} 字符]`:e}catch{n="[文本读取失败]"}else if("image"===e)try{n=await S(t)}catch{n=`[图片文件: ${t.name}]`}else n=`[二进制文件: ${t.name}]`;s.push({name:t.name,mime_type:t.type,size:t.size,kind:e,content:n})}return s}var N=t(14944);var k=t(52035),C=t(85997),A=t(34299),I=t(74848);function $(e){const s=e.attachments&&e.attachments.length>0?(0,I.jsx)("div",{className:"chat-message-attachments",children:e.attachments.map((e,s)=>(0,I.jsxs)("div",{className:"chat-message-attachment",children:[(0,I.jsx)(C.In,{icon:"attach_file"}),(0,I.jsx)("span",{children:e.name}),(0,I.jsxs)("small",{children:[e.size," B"]})]},`${e.name}_${s}`))}):null,t=[];e.images&&"bot"===e.sender&&t.push((0,I.jsx)(n.Fragment,{children:(0,I.jsx)(D,{images:e.images,text:e.text})},"images")),e.audio&&"bot"===e.sender&&t.push((0,I.jsx)(n.Fragment,{children:(0,I.jsx)(R,{audio:e.audio,text:e.text})},"audio")),e.embeddings&&"bot"===e.sender&&t.push((0,I.jsx)(n.Fragment,{children:(0,I.jsx)(P,{embeddings:e.embeddings,text:e.text})},"embeddings"));const a=function(e){if("bot"!==e.sender||!e.content_list?.length)return e.text?(0,I.jsx)(A.default,{context:e.text}):null;return(0,I.jsxs)(I.Fragment,{children:[e.content_list.map((e,s)=>{const t=[],a=(0,f.$j)(e.content);return a&&t.push((0,I.jsx)(n.Fragment,{children:(0,I.jsx)(A.default,{context:a})},`content-${s}`)),e.tool_call_ends?.length&&t.push((0,I.jsx)(n.Fragment,{children:(0,I.jsx)(M,{callList:e.tool_call_ends})},`tool-${s}`)),(0,I.jsx)(n.Fragment,{children:t},`part-${s}`)}),!e.content_list.some(e=>e.content)&&e.text?(0,I.jsx)(A.default,{context:e.text}):null]})}(e);return 0===t.length?(0,I.jsxs)(I.Fragment,{children:[s,a]}):(0,I.jsxs)(I.Fragment,{children:[t,s,a]})}function M({callList:e}){const[s,t]=n.useState(!1);if(!e?.length)return null;e.filter(e=>e.success).length;const a=e.filter(e=>!e.success).length;return(0,I.jsxs)("div",{className:"chat-message-call-list",children:[(0,I.jsxs)("div",{className:"call-list-header",onClick:()=>t(!s),children:[(0,I.jsx)(C.In,{icon:s?"expand_less":"expand_more"}),(0,I.jsxs)("span",{className:"call-list-summary",children:["工具调用 (",e.length,")",a>0&&(0,I.jsx)("span",{className:"call-list-fail",children:" 失败 "})]})]}),s&&(0,I.jsx)("div",{className:"call-list-body",children:e.map((e,s)=>(0,I.jsxs)("div",{className:"call-list-item "+(e.success?"call-success":"call-fail"),children:[(0,I.jsxs)("div",{className:"call-list-item-header",children:[(0,I.jsx)(C.In,{icon:e.success?"check_circle":"error"}),(0,I.jsx)("span",{className:"call-list-tool-name",children:e.tool_display_name||e.tool_name}),(0,I.jsxs)("span",{className:"call-list-duration",children:[e.duration_ms,"ms"]})]}),e.tool_args&&(0,I.jsxs)("details",{className:"call-list-details",children:[(0,I.jsx)("summary",{children:"参数"}),(0,I.jsx)("pre",{className:"call-list-pre",children:JSON.stringify(e.tool_args,null,2)})]}),!e.success&&e.error&&(0,I.jsxs)("details",{className:"call-list-details",children:[(0,I.jsx)("summary",{children:"错误"}),(0,I.jsx)("pre",{className:"call-list-pre call-list-error-text",children:e.error})]}),e.success&&e.tool_result&&(0,I.jsxs)("details",{className:"call-list-details",children:[(0,I.jsx)("summary",{children:"结果"}),(0,I.jsx)("pre",{className:"call-list-pre",children:e.tool_result.length>500?e.tool_result.slice(0,500)+"...":e.tool_result})]})]},s))})]})}function D({images:e,text:s}){let t=e||[];if(!t.length&&s)try{t=JSON.parse(s).data||[]}catch{}return t.length?(0,I.jsxs)("div",{className:"image-generation-result",children:[t.map((e,s)=>(0,I.jsxs)("div",{className:"image-generation-item",children:[e.url&&(0,I.jsx)("div",{className:"image-generation-image-wrapper",children:(0,I.jsx)("img",{src:e.url,alt:e.revised_prompt||`生成的图片 ${s+1}`,loading:"lazy"})}),e.b64_json&&(0,I.jsx)("div",{className:"image-generation-image-wrapper",children:(0,I.jsx)("img",{src:`data:image/png;base64,${e.b64_json}`,alt:`生成的图片 ${s+1}`})}),e.revised_prompt&&(0,I.jsx)("p",{className:"image-generation-prompt",children:(0,I.jsx)("small",{children:e.revised_prompt})})]},s)),s&&!e&&(0,I.jsx)(A.default,{context:s})]}):(0,I.jsx)(A.default,{context:s||""})}function R({audio:e,text:s}){if(e){if(e.url)return(0,I.jsx)("div",{className:"audio-result",children:(0,I.jsx)("audio",{controls:!0,src:e.url,children:"您的浏览器不支持音频播放"})});if(e.data){const s=e.mime_type||"audio/mpeg";return(0,I.jsx)("div",{className:"audio-result",children:(0,I.jsx)("audio",{controls:!0,src:`data:${s};base64,${e.data}`,children:"您的浏览器不支持音频播放"})})}}const t=s||"";if(t.startsWith("http://")||t.startsWith("https://"))return(0,I.jsx)("div",{className:"audio-result",children:(0,I.jsx)("audio",{controls:!0,src:t,children:"您的浏览器不支持音频播放"})});try{const e=JSON.parse(t);if(e?.data||e?.audio_data){const s=e.data||e.audio_data;return(0,I.jsx)("div",{className:"audio-result",children:(0,I.jsx)("audio",{controls:!0,src:`data:audio/mpeg;base64,${s}`,children:"您的浏览器不支持音频播放"})})}}catch{}return(0,I.jsx)(A.default,{context:t})}function H({content:e,label:s}){const[t,a]=n.useState(!1);return(0,I.jsxs)("button",{className:"embeddings-copy-btn",onClick:()=>{(0,u.lW)(e),a(!0),setTimeout(()=>a(!1),1500)},children:[(0,I.jsx)(C.In,{icon:t?"check":"content_copy"}),t?"已复制":s||"复制"]})}function P({embeddings:e,text:s}){let t=e||null;if(!t&&s)try{t=JSON.parse(s)}catch{return(0,I.jsx)(A.default,{context:s})}if(!t)return(0,I.jsx)(A.default,{context:s||""});const n=t?.data||[],a=t?.usage,i=JSON.stringify(t,null,2);return(0,I.jsxs)("div",{className:"embeddings-result",children:[(0,I.jsxs)("div",{className:"embeddings-summary",children:[(0,I.jsx)("strong",{children:"向量嵌入结果"}),(0,I.jsxs)("span",{children:["维度: ",n[0]?.embedding?.length??"N/A"]}),(0,I.jsxs)("span",{children:["数量: ",n.length]}),a&&(0,I.jsxs)("span",{children:["使用 tokens: ",a.total_tokens??"N/A"]})]}),(0,I.jsxs)("div",{className:"embeddings-toolbar",children:[(0,I.jsx)(H,{content:i,label:"复制全部结果"}),n.length>0&&n[0]?.embedding&&(0,I.jsx)(H,{content:JSON.stringify(n[0].embedding,null,2),label:"复制第一条向量"}),n.length>0&&(0,I.jsx)(H,{content:JSON.stringify(n.map(e=>e.embedding),null,2),label:"复制所有向量数据"})]}),n.length>0&&n[0]?.embedding&&(0,I.jsx)("div",{className:"embeddings-preview",children:(0,I.jsxs)("span",{children:["向量预览: [",n[0].embedding.slice(0,5).join(", "),n[0].embedding.length>5?", ...":"","]"]})}),n.length>0&&(0,I.jsxs)("details",{children:[(0,I.jsx)("summary",{children:"查看详细数据"}),(0,I.jsx)("pre",{className:"embeddings-raw",children:i})]})]})}async function T(e,s){const t=function(){try{return(0,k.zp)().get(x.AG.ai_images_extra_params)||{}}catch{return{}}}(),n={prompt:e,n:t.n??1,size:t.size??"1024x1024",session_id:s};if(t.quality&&(n.quality=t.quality),t.style&&(n.style=t.style),t.extra_json)try{const e=JSON.parse(t.extra_json);Object.assign(n,e)}catch(e){console.warn("图片额外参数 JSON 解析失败:",e)}const a=await l.jV.post("images/generations",n);if(0!==a.code)throw new Error(a.message||"图片生成失败");const i=a.data||{},c=(i.data||[]).map(e=>({url:e.url,b64_json:e.b64_json,revised_prompt:e.revised_prompt})),o=c.map((e,s)=>`${e.revised_prompt?`\n> ${e.revised_prompt}`:""}`).join("\n\n");return{session_id:i.session_id||s,images:c,text:o||`生成了 ${c.length} 张图片`}}async function F(e,s,t,n){try{switch(e){case"images":{const e=await T(s,t);return e&&n(e.text,{images:e.images}),!0}case"audio_speech":{const e=await async function(e,s){const t={input:e,session_id:s};try{const e=localStorage.getItem("ai_audio_extra_params");if(e){const s=JSON.parse(e);s.voice&&(t.voice=s.voice),s.speed&&(t.speed=parseFloat(s.speed))}}catch{}const n=localStorage.getItem("token")||"",a=await fetch("/api/ai_agent/audio/speech",{method:"POST",headers:{"Content-Type":"application/json",Authorization:n},body:JSON.stringify(t)});if(!a.ok)throw new Error(`语音合成失败: ${a.statusText}`);const i=a.headers.get("X-Session-Id")||s,c=await a.arrayBuffer();return{session_id:i,audio:{data:btoa(String.fromCharCode(...Array.from(new Uint8Array(c)))),mime_type:a.headers.get("content-type")||"audio/mpeg"},text:`[音频文件: ${e.slice(0,50)}...]`}}(s,t);return e&&n(e.text,{audio:e.audio}),!0}case"embeddings":{const e=await async function(e,s){const t=await l.jV.post("embeddings",{input:e,session_id:s});if(0!==t.code)throw new Error(t.message||"Embeddings 请求失败");const n=t.data||{},a=n?.data??[],i=`向量维度: ${a[0]?.embedding?.length??0}, 数量: ${a.length}`;return{session_id:n.session_id||s,embeddings:n,text:`✅ Embeddings 结果 - ${i}\n\`\`\`json\n${JSON.stringify(n,null,2).slice(0,2e3)}\n\`\`\``}}(s,t);return e&&n(e.text,{embeddings:e.embeddings}),!0}default:return!1}}catch(e){return n(`请求失败: ${e?.message||JSON.stringify(e)}`),!0}}var O=t(57952),V=t(23430),q=t(87361);const B=({currentModelName:e,setCurrentModelName:s,envConfigRef:t,sysPromptList:n,batchMode:o,selectedMsgCount:r,onToggleSessionPanel:u,onCreateSession:h,onToggleBatchMode:p,onBatchDeleteMessages:f,bgProcessVisible:j,bgProcessCount:v,onToggleBgProcess:b,selectedSysPromptId:y,setSelectedSysPromptId:S})=>{const{t:w}=(0,i.Bd)(),N=(0,c.Zp)(),{check_user_auth:k}=(0,d.MH)(),[,A]=(0,a.fp)(x.AG.ai_session_collapsed);return(0,I.jsxs)(O.A,{children:[(0,I.jsx)(C.rA,{icon:"menu",title:w("会话"),onClick:u}),(0,I.jsx)(C.rA,{icon:"add",title:w("新会话"),onClick:()=>h()}),n.length>0&&(0,I.jsx)(_.l6,{value:y,options:[{title:w("选择系统提示词"),value:""},...n.map(e=>({title:e.note||e.prompt.slice(0,30),value:String(e.index)}))],onChange:e=>{S(e)},no_border:!0,width:"10rem"}),(t.current?.ai_config_env?.options_agent_model_list?.length??0)>0&&(0,I.jsx)(_.l6,{value:e,options:t.current.ai_config_env.options_agent_model_list?.map(e=>({title:e.label,value:e.value}))??[],onChange:e=>{s(e),l.jV.post("set_active_model",{model_name:e}).then(()=>{(0,m.SK)("success"),l.XO.get("ai_agent_setting/env").then(e=>{e.code===g.m.Success&&(t.current=e.data)})}).catch(console.error)},no_border:!0,width:"auto"}),o&&r>0&&(0,I.jsx)(C.rA,{icon:"delete",title:w("删除选中消息"),onClick:f}),(0,I.jsx)(C.rA,{icon:"terminal",title:w("后台进程"),onClick:b,selected:j,tip:v||null}),k(V.oV.ai_agent_setting)&&(0,I.jsx)(C.rA,{icon:"smart_toy",title:"机器人配置",onClick:()=>{N(`/${q.o.ai_rebot_setting_page}`)}}),k(V.oV.ai_agent_setting)&&(0,I.jsx)(C.rA,{icon:"settings",title:"ai setting",onClick:()=>{N(`/${q.o.ai_agent_setting_page}`)}})]})};var E=t(27690);function K({sessions:e,activeSessionId:s,onSelectSession:t,onRenameSession:c,onDeleteSession:o,onShowUsageStats:l,batchMode:r,selectedSessionIds:d,onToggleSessionSelect:u,onToggleBatchMode:m,onBatchDeleteSessions:h,onClearAllSessions:g}){const{t:p}=(0,i.Bd)(),[_,f]=(0,a.fp)(x.AG.ai_session_collapsed),[j,v]=(0,n.useState)(""),b=j.trim()?e.filter(e=>(e.title||"").toLowerCase().includes(j.toLowerCase())||(e.summary||"").toLowerCase().includes(j.toLowerCase())||(e.long_term_memory||"").toLowerCase().includes(j.toLowerCase())):e;return(0,I.jsxs)("aside",{className:`chat-session-list ${_?"active":""} ${_?"collapsed":""}`,children:[(0,I.jsx)("div",{className:"chat-session-search",children:(0,I.jsx)("input",{type:"text",className:"chat-session-search-input",placeholder:p("搜索会话"),value:j,onChange:e=>v(e.target.value)})}),(0,I.jsx)("div",{className:"chat-session-items-wrap",children:b.map(e=>{return(0,I.jsx)("div",{children:(0,I.jsxs)("button",{className:`chat-session-item ${s===e.id?"active":""} ${r?"batch-mode":""}`,onClick:()=>{r&&u?u(e.id):t(e.id)},title:e.summary||e.long_term_memory||e.title,children:[r&&(0,I.jsx)("input",{type:"checkbox",className:"chat-session-checkbox",checked:d?.has(e.id)??!1,onChange:()=>u?.(e.id),onClick:e=>e.stopPropagation()}),(0,I.jsx)("span",{children:(n=e.title,n||"新会话")}),(0,I.jsx)("small",{children:e.message_count}),"web"!==e.source&&(0,I.jsx)("em",{className:"chat-session-source",children:e.source}),!r&&(0,I.jsx)(E.MenuSelect,{list:[{name:p("重命名"),click:()=>c(e.id,e.title)},{name:p("字符消耗统计"),click:()=>l(e.id)},{name:p("删除"),click:()=>o(e.id)}],children:(0,I.jsx)(C.In,{icon:"more_horiz"})})]})},e.id);var n})}),(0,I.jsxs)("div",{className:"chat-session-actions",children:[(0,I.jsx)(C.rA,{icon:r?"check_circle":"checklist",title:p(r?"取消批量选择":"批量选择"),onClick:m}),r&&(d?.size??0)>0&&(0,I.jsx)(C.rA,{icon:"delete",title:p("删除选中会话"),onClick:h}),!r&&(0,I.jsx)(C.rA,{icon:"delete_sweep",title:p("删除全部会话"),onClick:g})]})]})}const L=({messages:e,batchMode:s,selectedMsgIds:t,sending:n,chatContainerRef:a,messagesEndRef:i,onToggleMsgSelect:c,onDelete:o,onCopy:l,onToggleBatchMode:r,t:d})=>(0,I.jsxs)("div",{className:"chat-messages",ref:a,"data-sending":n?"true":"false",children:[e.map(e=>(0,I.jsxs)("div",{className:`chat-message ${e.sender} ${s?"batch-mode":""} ${e.is_loading?"is-loading":""}`,children:[s&&(0,I.jsx)("input",{type:"checkbox",className:"chat-message-checkbox",checked:t.has(e.id),onChange:()=>c(e.id)}),e.is_loading?(0,I.jsxs)("div",{className:"ai-loading-bubble",children:[(0,I.jsxs)("div",{className:"ai-loading-dots",children:[(0,I.jsx)("span",{className:"ai-loading-dot"}),(0,I.jsx)("span",{className:"ai-loading-dot"}),(0,I.jsx)("span",{className:"ai-loading-dot"})]}),(0,I.jsx)("span",{className:"ai-loading-text",children:e.text})]}):(0,I.jsxs)(I.Fragment,{children:[$(e),(0,I.jsx)("div",{className:"message-actions",children:s?(0,I.jsx)("button",{onClick:()=>c(e.id),children:t.has(e.id)?d("取消选择"):d("选择")}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)("button",{onClick:()=>o(e.id),children:d("删除")}),(0,I.jsx)("button",{onClick:()=>l(e.text),children:d("复制")}),(0,I.jsx)("button",{onClick:r,children:d("多选")})]})})]})]},e.id)),(0,I.jsx)("div",{ref:i})]});function z({onClose:e}){const{t:s}=(0,i.Bd)(),[t,c]=(0,a.fp)(x.AG.ai_images_extra_params),[o,l]=(0,n.useState)(t.size||"1024x1024"),[r,d]=(0,n.useState)(String(t.n??1)),[u,m]=(0,n.useState)(t.quality||""),[h,g]=(0,n.useState)(t.style||""),[p,f]=(0,n.useState)(t.extra_json||"");return(0,I.jsxs)("div",{className:"card floating",children:[(0,I.jsx)("div",{className:"card-title",children:(0,I.jsx)("h2",{children:s("图片生成参数设置")})}),(0,I.jsxs)("div",{className:"card-content",children:[(0,I.jsx)(_.Sm,{placeholderOut:s("图片尺寸 (size)"),value:o,handleInputChange:l,placeholder:"1024x1024"}),(0,I.jsx)(_.Sm,{placeholderOut:s("生成数量 (n)"),value:r,handleInputChange:d,type:"number"}),(0,I.jsx)(_.Sm,{placeholderOut:s("画质 (quality)"),value:u,handleInputChange:m,placeholder:"standard / hd"}),(0,I.jsx)(_.Sm,{placeholderOut:s("风格 (style)"),value:h,handleInputChange:g,placeholder:"vivid / natural"}),(0,I.jsx)(_.Sm,{placeholderOut:s("额外参数 JSON"),value:p,handleInputChange:f,placeholder:'{"key":"value"}'})]}),(0,I.jsxs)("div",{className:"card-action",children:[(0,I.jsx)("button",{className:"button button--flat button--grey",onClick:e,children:s("取消")}),(0,I.jsx)("button",{className:"button button--flat",onClick:()=>{const s={size:o,n:parseInt(r)||1};u&&(s.quality=u),h&&(s.style=h),p&&(s.extra_json=p),c(s),e()},children:s("确定")})]})]})}function J({requestType:e}){const{t:s}=(0,i.Bd)(),[t,a]=(0,n.useState)(!1);return"completions"===e?null:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(C.rA,{icon:"tune",title:s("模型参数设置"),onClick:()=>a(!0)}),t&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)("div",{className:"overlay",onClick:()=>a(!1)}),"images"===e&&(0,I.jsx)(z,{onClose:()=>a(!1)})]})]})}const G=(0,n.forwardRef)(function({placeholder:e="",disabled:s=!1,className:t,style:a,onEnter:i,onPaste:c,onChange:o},l){const r=(0,n.useRef)(null),[d,u]=(0,n.useState)(!0),[m,h]=(0,n.useState)(!1),g=(0,n.useCallback)(()=>{const e=r.current;return e?(e.textContent??"").replace(/\u00A0/g," ").trimEnd():""},[]);(0,n.useImperativeHandle)(l,()=>({getValue:()=>g(),setValue:e=>{const s=r.current;if(!s)return;s.textContent=e,u(!e);const t=document.createRange();t.selectNodeContents(s),t.collapse(!1);const n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)},clear:()=>{const e=r.current;e&&(e.textContent="",u(!0))},focus:()=>r.current?.focus()})),(0,n.useEffect)(()=>{const e=r.current;if(!e)return;const s=()=>u(!e.textContent);return e.addEventListener("input",s),()=>e.removeEventListener("input",s)},[]);return(0,I.jsx)("div",{ref:r,contentEditable:!s,suppressContentEditableWarning:!0,className:"rich-textarea"+(t?" "+t:""),style:a,onKeyDown:e=>{m||"Enter"!==e.key||e.shiftKey||e.ctrlKey||e.metaKey||e.altKey||(e.preventDefault(),i?.())},onPaste:c,onInput:()=>o?.(g()),onCompositionStart:()=>h(!0),onCompositionEnd:()=>h(!1),"data-placeholder":d?e:void 0})});function W({pendingAttachments:e,onRemove:s}){return 0===e.length?null:(0,I.jsx)("div",{className:"chat-attachment-strip",children:e.map((e,t)=>(0,I.jsxs)("div",{className:"chat-attachment-chip",children:[(0,I.jsx)(C.In,{icon:"attach_file"}),(0,I.jsx)("span",{title:e.name,children:e.name}),(0,I.jsx)("button",{type:"button",onClick:()=>s(t),children:(0,I.jsx)(C.In,{icon:"close"})})]},`${e.name}_${t}`))})}const Q=(0,n.forwardRef)(({onSend:e,sending:s,onAbort:t,pendingAttachments:a,onRemoveAttachment:c,onOpenFilePicker:o,onAddFiles:l,onDrop:r,onDragOver:d,fileInputRef:u,requestType:m},h)=>{const{t:g}=(0,i.Bd)(),p=(0,n.useRef)(null);return(0,n.useImperativeHandle)(h,()=>({getValue:()=>p.current?.getValue()??"",setValue:e=>p.current?.setValue(e),clear:()=>p.current?.clear()})),(0,I.jsxs)("div",{className:"chat-input-area",onDrop:r,onDragOver:d,children:[(0,I.jsx)("input",{ref:u,type:"file",multiple:!0,style:{display:"none"},onChange:e=>{e.target.files?.length&&(l(e.target.files),e.currentTarget.value="")}}),(0,I.jsxs)("div",{className:"chat-input-shell",children:[(0,I.jsx)(W,{pendingAttachments:a,onRemove:c}),(0,I.jsx)(G,{ref:p,placeholder:g("输入消息"),onEnter:()=>e(),onPaste:e=>{const s=e.clipboardData?.files;s&&s.length>0&&(e.preventDefault(),l(s))},className:"chat-input"})]}),(0,I.jsx)(C.rA,{title:g("添加文件"),icon:"attach_file",onClick:o}),(0,I.jsx)(J,{requestType:m}),s?(0,I.jsx)(C.Vi,{color:"var( --icon-red)",text:g("暂停"),clickFun:t}):(0,I.jsx)(C.Vi,{text:g("发送"),clickFun:e})]})}),U={},X=function(){const{t:e}=(0,i.Bd)(),[s,t]=(0,n.useState)([]),[c,l]=(0,n.useState)(!1),[r,d]=(0,n.useState)(null),[u,h]=(0,n.useState)(null),[g,p]=(0,n.useState)(!1),[_,f]=(0,a.fp)(x.AG.ai_bg_expanded),[,j]=(0,a.fp)(x.AG.ai_session_collapsed),v=()=>{f(!1)},b=(0,n.useCallback)(async()=>{l(!0);try{const e=new o.hf(o.HK.ai_bg_process_list_req);e.context={};const s=await N.ws.send(e);s?.context?.processes&&(t(s.context.processes),U.onCountChange?.(s.context.processes.length))}catch(e){console.error("获取后台进程列表失败",e)}finally{l(!1)}},[]);U.refresh=b;const y=(0,n.useCallback)(async e=>{p(!0),d(e);try{const s=new o.hf(o.HK.ai_bg_process_output_req);s.context={pid:e};const t=await N.ws.send(s);h(t.context)}catch(e){console.error("获取进程输出失败",e),(0,m.zN)("获取进程输出失败")}finally{p(!1)}},[]),S=(0,n.useCallback)(async e=>{try{const s=new o.hf(o.HK.ai_bg_process_kill_req);s.context={pid:e};const t=await N.ws.send(s);t?.context?.success?((0,m.SK)("进程已终止"),b(),r===e&&(d(null),h(null))):(0,m.zN)(t?.context?.message||"终止失败")}catch(e){console.error("终止进程失败",e),(0,m.zN)("终止进程失败")}},[b,r]);(0,n.useEffect)(()=>{b();const e=setInterval(b,5e3);return()=>clearInterval(e)},[b]);const w=s.filter(e=>e.running),k=s.filter(e=>!e.running);return(0,I.jsxs)(I.Fragment,{children:[_&&(0,I.jsx)("div",{className:"chat-session-overlay",onClick:v}),(0,I.jsxs)("aside",{className:"chat-bg-process-panel "+(_?"expanded":""),children:[(0,I.jsxs)("div",{className:"chat-bg-process-header",children:[(0,I.jsx)("span",{className:"chat-bg-process-title",children:e("后台进程")}),(0,I.jsx)(C.rA,{icon:"close",title:e("关闭"),onClick:v})]}),(0,I.jsxs)("div",{className:"chat-bg-process-toolbar",children:[(0,I.jsx)(C.rA,{icon:"refresh",title:e("刷新"),onClick:b}),(0,I.jsxs)("span",{className:"chat-bg-process-count",children:[w.length," ",e("个运行中"),k.length>0&&` / ${k.length} ${e("个已退出")}`]})]}),(0,I.jsxs)("div",{className:"chat-bg-process-list",children:[c&&0===s.length&&(0,I.jsx)("div",{className:"chat-bg-process-empty",children:e("加载中...")}),!c&&0===s.length&&(0,I.jsx)("div",{className:"chat-bg-process-empty",children:e("暂无后台进程")}),w.map(s=>(0,I.jsxs)("div",{className:`chat-bg-process-item ${r===s.pid?"active":""} running`,children:[(0,I.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>y(s.pid),children:[(0,I.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",s.pid]}),(0,I.jsx)("span",{className:"chat-bg-process-cmd",title:s.cmd,children:s.cmd.length>40?s.cmd.slice(0,40)+"...":s.cmd}),(0,I.jsx)("span",{className:"chat-bg-process-time",children:new Date(s.start_time).toLocaleTimeString()}),(0,I.jsx)("span",{className:"chat-bg-process-status running-dot",title:e("运行中"),children:"●"})]}),(0,I.jsxs)("div",{className:"chat-bg-process-item-actions",children:[(0,I.jsx)(C.rA,{icon:"terminal",title:e("查看输出"),onClick:()=>y(s.pid)}),(0,I.jsx)(C.rA,{icon:"stop",title:e("终止进程"),onClick:()=>S(s.pid)})]})]},s.pid)),k.map(e=>(0,I.jsx)("div",{className:`chat-bg-process-item ${r===e.pid?"active":""} finished`,children:(0,I.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>y(e.pid),children:[(0,I.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",e.pid]}),(0,I.jsx)("span",{className:"chat-bg-process-cmd",title:e.cmd,children:e.cmd.length>30?e.cmd.slice(0,30)+"...":e.cmd}),(0,I.jsx)("span",{className:"chat-bg-process-time",children:new Date(e.start_time).toLocaleTimeString()}),(0,I.jsxs)("span",{className:"chat-bg-process-exit-code",children:["exit: ",e.exit_code]})]})},e.pid))]}),null!==r&&(0,I.jsxs)("div",{className:"chat-bg-process-output",children:[(0,I.jsxs)("div",{className:"chat-bg-process-output-header",children:[(0,I.jsxs)("span",{children:["PID: ",r," ",e("输出")]}),(0,I.jsx)(C.rA,{icon:"close",title:e("关闭"),onClick:()=>{d(null),h(null)}})]}),(0,I.jsx)("div",{className:"chat-bg-process-output-content",children:g?(0,I.jsx)("div",{className:"chat-bg-process-empty",children:e("加载中...")}):u?(0,I.jsx)("pre",{className:"chat-bg-process-output-pre",children:u.output||e("(无输出)")}):null})]})]})]})},Z=e=>null==e||e<0?"0":e.toLocaleString();function Y(){const{t:e}=(0,i.Bd)(),s=((0,c.Zp)(),(0,h.y)()),{check_user_auth:t}=(0,d.MH)();(0,p.w)();const[v,b]=(0,n.useState)([]),[y,S]=(0,n.useState)([]),[k,C]=(0,n.useState)(""),[A,$]=(0,n.useState)(!1),M=(0,n.useRef)(null),[D,R]=(0,n.useState)([]),[H,P]=(0,a.fp)(x.AG.ai_session_collapsed),[T,O]=(0,a.fp)(x.AG.ai_bg_expanded),[V,q]=(0,a.fp)(x.AG.prompt_card),[E,z]=(0,n.useState)(!1),[J,G]=(0,n.useState)(new Set),[W,Y]=(0,n.useState)(new Set),[ee,se]=(0,n.useState)(""),te=(0,n.useRef)(null),ne=(0,n.useRef)(null),ae=(0,n.useRef)(null),ie=(0,n.useRef)(!0),ce=(0,n.useRef)(new f.qq),[oe,le]=(0,n.useState)([]),[re,de]=(0,n.useState)(""),[ue,me]=(0,n.useState)(0),he=()=>ce?.current?.ai_config?.request_type||"completions",ge=(0,n.useRef)((0,r.sg)(e=>{b(e),ie.current&&pe(!1)},50)).current,pe=(e=!1)=>{const s=ae.current;s&&s.scrollTo({top:s.scrollHeight,behavior:e?"smooth":"auto"})},xe=async()=>{const e=await l.jV.get("sessions");e.code===g.m.Success&&S(e.data??[])},_e=function(e){const{getMessages:s,setMessages:t,setMessagesDebounced:a,setSending:i,getActiveSessionId:c,setActiveSessionId:l,refreshSessions:r,scrollToBottom:d,buildRequestMessages:u,getSelectedSysPromptId:m}=e,h=(0,n.useRef)([]),g=(0,n.useRef)(null),p=(e,n,c)=>{const l=[...s(),n];t(l),i(!0),g.current={abort:()=>{}};const h={id:n.id+1,sender:"bot",text:"AI思考中...",is_loading:!0};l.push(h),t([...l]);const p=new Map;let x=!0,_=h;const f=e=>{const s=e.context||{},t=s.text||"",n=s.tool_call_ends,i=s.chunk_index??0;if("[DONE]"!==t)if(x)x=!1,_.text=t,n&&(_.content_list=[{tool_call_ends:n,content:_.text,role:"assistant"}]),_.is_loading=!1,_.chunk_index=i,p.set(i,_),a([...l]);else{const e=p.get(i);if(e)e.text+=t,n&&(e.content_list=[{tool_call_ends:n,content:e.text,role:"assistant"}]),a([...l]);else{const e={id:Date.now()+Math.random(),sender:"bot",text:t,chunk_index:i};n&&(e.content_list=[{tool_call_ends:n,content:e.text,role:"assistant"}]),l.push(e),p.set(i,e),a([...l])}}},j=e=>{b(),g.current=null,i(!1),_.is_loading=!1,r(),d(!0),c()},v=e=>{b(),g.current=null,i(!1);const s=e.context||{};_.text="AI请求出错: "+(s.message||"未知错误"),_.is_loading=!1,t([...l]),c()},b=()=>{N.ws.off_message(`message_${o.HK.ai_chat_msg}`,f),N.ws.off_message(`message_${o.HK.ai_chat_end}`,j),N.ws.off_message(`message_${o.HK.ai_chat_error}`,v)};N.ws.addMsg(o.HK.ai_chat_msg,f),N.ws.addMsg(o.HK.ai_chat_end,j),N.ws.addMsg(o.HK.ai_chat_error,v),N.ws.sendData(o.HK.ai_chat_req,{messages:u(n),session_id:e,sys_prompt_id:m()})},x=()=>{const e=h.current;if(0===e.length)return;const s=e.shift();if(!s)return;t(e=>e.map(e=>"user"===e.sender&&e.text.includes("⏳(排队中...)")?{...e,text:e.text.replace(" ⏳(排队中...)","")}:e));const n={id:Date.now(),sender:"user",text:s.text,attachments:s.attachments};p(c(),n,x)};return{startChatStream:p,processPendingQueue:x,enqueueMessage:(e,s)=>{h.current.push({text:e,attachments:s})},getQueueLength:()=>h.current.length,abort:()=>{g.current&&(N.ws.sendData(o.HK.ai_chat_abort,{session_id:c()}),g.current=null,i(!1))}}}({getMessages:()=>v,setMessages:b,setMessagesDebounced:ge,setSending:$,getActiveSessionId:()=>k,setActiveSessionId:C,refreshSessions:xe,scrollToBottom:pe,buildRequestMessages:e=>{const s=(e.attachments??[]).filter(e=>"image"===e.kind);if(s.length>0){const t=[];e.text&&t.push({type:"text",text:e.text});for(const e of s)t.push({type:"image_url",image_url:{url:e.content}});return[{content:t,role:"user",attachments:e.attachments??[]}]}return[{content:e.text,role:"bot"===e.sender?"assistant":"user",attachments:e.attachments??[]}]},getSelectedSysPromptId:()=>ee}),fe=async e=>{const s=await l.jV.get("sessions");if(s.code!==g.m.Success)return;const t=s.data??[];S(t);const n=null===e?t[0]?.id??"":e||k||t[0]?.id||"";n?await je(n):(b([]),C(""))},je=async(e,s=!1)=>{const t=await l.jV.post("session/get",{session_id:e});if(t.code!==g.m.Success||!t.data)return;const n=t.data;C(n.id),b(function(e=[]){return e.filter(e=>"user"===e.role||"assistant"===e.role).map((e,s)=>({id:Date.now()+s,sender:"assistant"===e.role?"bot":"user",text:j(e),attachments:e.attachments??[],content_list:e.content_list,images:e.images,audio:e.audio,embeddings:e.embeddings}))}(n.messages)),s&&P(!1),U.refresh?.(),requestAnimationFrame(()=>pe(!1))},ve=e=>{const s=Array.from(e??[]).filter(Boolean);s.length&&R(e=>[...e,...s])},be=()=>{E&&(G(new Set),Y(new Set)),z(e=>!e)};(0,n.useEffect)(()=>((async()=>{const e=await l.XO.get("ai_agent_setting/env");if(e.code===g.m.Success){ce.current=e.data;const s=e.data.ai_config?.model||"",t=(e.data.ai_config_env?.options_agent_model_list??[]).find(e=>e.label===s);de(t?t.value:s)}await fe();const s=await l.jV.get("system_prompts");s.code===g.m.Success&&le(s.data??[])})(),requestAnimationFrame(()=>pe(!1)),U.onCountChange=me,U.refresh?.(),N.ws.addMsg(o.HK.ai_bg_process_count_notify,e=>{const s=e?.context?.count;"number"==typeof s&&me(s)}),()=>{N.ws.removeMsg(o.HK.ai_bg_process_count_notify)}),[]),(0,n.useEffect)(()=>{const e=ae.current;if(!e)return;const s=()=>{ie.current=((e,s=120)=>{const{scrollTop:t,scrollHeight:n,clientHeight:a}=e;return n-(t+a)<s})(e)};return e.addEventListener("scroll",s),()=>e.removeEventListener("scroll",s)},[]),(0,n.useLayoutEffect)(()=>{ie.current&&pe(!1)},[v]);return(0,I.jsxs)(n.Fragment,{children:[(0,I.jsx)(B,{currentModelName:re,setCurrentModelName:de,envConfigRef:ce,sysPromptList:oe,batchMode:E,selectedMsgCount:J.size,onToggleSessionPanel:()=>{P(e=>!e)},onCreateSession:async e=>{const s=await l.jV.post("session",{title:"新会话"});if(s.code!==g.m.Success)return;const t=s.data;C(t.id),b([]),P(!1),await fe(t.id),requestAnimationFrame(()=>{const e=document.querySelector(".chat-input");e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,200)+"px")})},onBatchDeleteMessages:()=>{0!==J.size&&s({sub_title:e("确认删除选中的聊天消息吗?"),confirm_fun:async()=>{const e=[];v.forEach((s,t)=>{J.has(s.id)&&e.push(t)}),b(v.filter(e=>!J.has(e.id))),G(new Set),z(!1),k&&e.length>0&&l.jV.post("session/message/delete",{session_id:k,indices:e}).catch(console.error)}})},bgProcessVisible:T,bgProcessCount:ue,onToggleBgProcess:()=>O(e=>!e),selectedSysPromptId:ee,setSelectedSysPromptId:se}),(0,I.jsxs)("div",{className:"chat-page chat-page-with-sessions",children:[H&&(0,I.jsx)("div",{className:"chat-session-overlay",onClick:()=>P(!1)}),(0,I.jsx)(K,{sessions:y,activeSessionId:k,onSelectSession:e=>je(e,!1),onRenameSession:(e,t)=>{let n=t;s({confirm_fun:async()=>{await l.jV.post("sessions/update/meta",{id:e,title:n}),await fe(k)},context_div:(0,I.jsx)("div",{className:"card-content",children:(0,I.jsx)(_.Sm,{value:n,handleInputChange:e=>{n=e}})})})},onDeleteSession:e=>{s({sub_title:"确认删除这个会话吗?",confirm_fun:async()=>{await l.jV.post("session/delete",{session_id:e}),k===e?(C(""),await fe(null)):await fe(k)}})},onShowUsageStats:async s=>{q({open:!0,title:e("字符消耗统计"),context_div:(0,I.jsx)("div",{className:"usage-stats-loading",children:e("加载中...")}),cancel:()=>q({open:!1})});try{const t=await l.jV.post("session/usage_stats",{session_id:s});if(t.code===g.m.Success&&t.data){const s=t.data;q({open:!0,title:e("字符消耗统计"),context_div:(0,I.jsxs)("div",{className:"usage-stats-panel",children:[[{l:e("对话轮次"),v:(s.turns??0).toString()},{l:e("AI输入字符"),v:Z(s.input_chars)},{l:e("AI输出字符"),v:Z(s.output_chars)},{l:e("AI输入字符(最近一轮)"),v:Z(s.recent_input_chars)},{l:e("AI输出字符(最近一轮)"),v:Z(s.recent_output_chars)}].map((e,s)=>(0,I.jsxs)("div",{className:"usage-stats-row",children:[(0,I.jsx)("span",{className:"usage-stats-label",children:e.l}),(0,I.jsx)("span",{className:"usage-stats-value",children:e.v})]},s)),(0,I.jsxs)("div",{className:"usage-stats-row usage-stats-total",children:[(0,I.jsx)("span",{className:"usage-stats-label",children:e("AI字符总计消耗")}),(0,I.jsx)("span",{className:"usage-stats-value",children:Z((s.input_chars||0)+(s.output_chars||0))})]})]}),cancel:()=>q({open:!1})})}else q({open:!0,title:e("字符消耗统计"),context_div:(0,I.jsx)("div",{className:"usage-stats-empty",children:e("暂无统计数据")}),cancel:()=>q({open:!1})})}catch{q({open:!0,title:e("字符消耗统计"),context_div:(0,I.jsx)("div",{className:"usage-stats-empty",children:e("暂无统计数据")}),cancel:()=>q({open:!1})})}},batchMode:E,selectedSessionIds:W,onToggleSessionSelect:e=>{Y(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},onToggleBatchMode:be,onBatchDeleteSessions:()=>{0!==W.size&&s({sub_title:e("确认删除选中的会话吗?"),confirm_fun:async()=>{for(const e of W)await l.jV.post("session/delete",{session_id:e});Y(new Set),z(!1),W.has(k)?(C(""),await fe(null)):await fe(k)}})},onClearAllSessions:()=>{s({sub_title:e("确认删除全部聊天会话吗?"),confirm_fun:async()=>{await l.jV.post("sessions/clear",{}),C(""),b([]),await fe(null)}})}}),(0,I.jsx)(X,{}),(0,I.jsxs)("section",{className:"chat-main",children:[0===v?.length&&(0,I.jsx)("div",{className:"chat-header",children:(0,I.jsx)("div",{children:e("询问服务器的一切")})}),(0,I.jsx)(L,{messages:v,batchMode:E,selectedMsgIds:J,sending:A,chatContainerRef:ae,messagesEndRef:ne,onToggleMsgSelect:e=>{G(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},onDelete:t=>{s({sub_title:e("确认删除这条消息吗?"),confirm_fun:async()=>{const e=v.findIndex(e=>e.id===t);if(e<0)return;const s=v.filter(e=>e.id!==t);b(s),k&&l.jV.post("session/message/delete",{session_id:k,indices:[e]}).catch(console.error)}})},onCopy:async e=>{(0,u.lW)(e),(0,m.SK)("复制成功")},onToggleBatchMode:be,t:e}),(0,I.jsx)(Q,{ref:M,onSend:async()=>{const e=(M.current?.getValue()??"").trim();if(!e&&0===D.length)return;if(A){const s=await w(D);_e.enqueueMessage(e,s),M.current?.clear(),R([]);const t={id:Date.now(),sender:"user",text:e+(_e.getQueueLength()>1?" ⏳(排队中...)":""),attachments:s};return void b(e=>[...e,t])}let s=k;if(!s){const t=await l.jV.post("session",{title:(e||D[0]?.name||"新会话").slice(0,28)});if(t.code!==g.m.Success)return;s=t.data.id,C(s),await fe(s)}const t=await w(D),n={id:Date.now(),sender:"user",text:e,attachments:t};M.current?.clear(),R([]);const a=he();if("completions"!==a){const t={id:n.id+1,sender:"bot",text:"处理中...",is_loading:!0},i=[...v,n,t];b(i),$(!0);return void(await F(a,e,s,async(e,s)=>{t.text=e,t.is_loading=!1,s?.images&&(t.images=s.images),s?.audio&&(t.audio=s.audio),s?.embeddings&&(t.embeddings=s.embeddings),b([...i]),$(!1),xe(),pe(!0),_e.processPendingQueue()})||(t.text=`请求类型 "${a}" 的专用处理器尚未实现,请使用 completions 类型。`,t.is_loading=!1,b([...i]),$(!1),_e.processPendingQueue()))}_e.startChatStream(s,n,()=>_e.processPendingQueue())},sending:A,onAbort:_e.abort,pendingAttachments:D,onRemoveAttachment:e=>{R(s=>s.filter((s,t)=>t!==e))},onOpenFilePicker:()=>{te.current?.click()},onAddFiles:ve,onDrop:e=>{const s=e.dataTransfer?.files;s&&s.length>0&&(e.preventDefault(),ve(s))},onDragOver:e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},fileInputRef:te,requestType:he()})]})]})]})}},72693(e,s,t){t.d(s,{w:()=>u});var n=t(96540),a=t(22022),i=t(14944),c=t(92275),o=t(34843),l=t(82893),r=t(85997),d=t(74848);function u(){const[e,s]=(0,o.fp)(l.AG.prompt_card),{t}=(0,a.Bd)(),u=(0,n.useRef)([]),m=(0,n.useRef)(!1),h=(0,n.useCallback)(()=>{if(m.current)return;if(0===u.current.length)return m.current=!1,void s({open:!1});m.current=!0;const e=u.current.shift();e?s({open:!0,title:t("命令确认"),cancel:()=>{i.ws.sendData(c.HK.ai_confirm_cmd,{askId:e.askId,approved:!1}),s({open:!1}),m.current=!1,h()},context_div:(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{style:{maxHeight:"60vh",overflow:"auto",whiteSpace:"pre-wrap",wordBreak:"break-all",background:"var(--surfaceSecondary)",padding:"0.75em",borderRadius:"0.5em",marginBottom:"0.75em",fontFamily:"monospace",fontSize:"0.9em",lineHeight:"1.5"},children:e.cmd}),(0,d.jsxs)("div",{style:{display:"flex",gap:"0.5em",justifyContent:"flex-end"},children:[(0,d.jsx)(r.$n,{text:t("拒绝"),color:"var(--red)",clickFun:()=>{i.ws.sendData(c.HK.ai_confirm_cmd,{askId:e.askId,approved:!1}),s({open:!1}),m.current=!1,h()}}),(0,d.jsx)(r.$n,{text:t("允许"),clickFun:()=>{i.ws.sendData(c.HK.ai_confirm_cmd,{askId:e.askId,approved:!0}),s({open:!1}),m.current=!1,h()}})]})]})}):m.current=!1},[t]),g=(0,n.useCallback)(e=>{u.current.push(e),h()},[h]);(0,n.useEffect)(()=>(i.ws.addMsg(c.HK.ai_confirm_cmd,e=>{const t=e.context||{};if(t.dismiss&&t.askId)return u.current=u.current.filter(e=>e.askId!==t.askId),void(m.current&&(m.current=!1,s({open:!1}),h()));t.askId&&t.cmd&&g({askId:t.askId,cmd:t.cmd})}),()=>{i.ws.removeMsg(c.HK.ai_confirm_cmd)}),[g]),(0,n.useEffect)(()=>()=>{u.current=[],m.current=!1},[])}},34299(e,s,t){t.r(s),t.d(s,{default:()=>p});t(96540);var n=t(73557),a=t(53995),i=t(18569),c=t(77979),o=t(8263),l=t(69428),r=t.n(l),d=(t(3775),t(21499)),u=t(99214),m=t(19878),h=(t(72411),t(74848));const g=new n.A({html:!0,highlight:function(e,s){if(s&&m.A.getLanguage(s))try{return`<pre class="hljs code-block-with-copy"><code class="hljs language-${s}">${m.A.highlight(e,{language:s}).value}</code></pre>`}catch(e){}try{return`<pre class="hljs code-block-with-copy"><code class="hljs">${m.A.highlightAuto(e).value}</code></pre>`}catch(e){}return`<pre class="hljs code-block-with-copy"><code>${g.utils.escapeHtml(e)}</code></pre>`}});function p(e){return(0,u.VD)(),(0,h.jsx)("div",{dangerouslySetInnerHTML:{__html:g.render(e.context)}})}g.use(a.A).use(i.A).use(c.A).use(o.A).use(r()).use(e=>{e.renderer.rules.fence;e.renderer.rules.fence=(s,t,n,a,i)=>{const c=s[t],o=c.content.trim(),l=c.info.trim();let r="";if(l&&m.A.getLanguage(l))try{r=m.A.highlight(o,{language:l}).value}catch(s){r=e.utils.escapeHtml(o)}else try{r=m.A.highlightAuto(o).value}catch(s){r=e.utils.escapeHtml(o)}return`\n <div class="code-block-with-copy">\n <div class="code-header">\n <span class="code-language">${l||"code"}</span>\n <button class="copy-btn" data-code="${e.utils.escapeHtml(o)}">复制</button>\n </div>\n <pre><code class="hljs ${l?`language-${l}`:""}">${r}</code></pre>\n </div>`}}).use(e=>{const s=e.renderer.rules.link_open||function(e,s,t,n,a){return a.renderToken(e,s,t)};e.renderer.rules.link_open=(e,t,n,a,i)=>{const c=e[t],o=c.attrIndex("href");if(o>=0){const e=c.attrs[o][1];c.attrs[o][1]=(0,d.bi)(window.location.href,e)}return s(e,t,n,a,i)}})},45907(e,s,t){t.d(s,{y:()=>i});var n=t(34843),a=t(82893);function i(){const[e,s]=(0,n.fp)(a.AG.confirm);return({sub_title:e,confirm_fun:t,title:n,context_div:a})=>{s({open:!0,sub_title:e,handle:()=>{t(),s({open:!1,handle:null})},title:n,context_div:a})}}},60840(e){e.exports="data:image/svg+xml,<svg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 16 16%27 version=%271.1%27 aria-hidden=%27true%27><path fill-rule=%27evenodd%27 d=%27M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z%27></path></svg>"}}]);
|