1import{r as o,j as P}from"./react-vendor-Dc5dhXQW.js";import{y as q,u as B,p as _,q as G,r as V,x as D}from"./index-DuU_YjY9.js";import{u as I}from"./i18n-vendor-CyU1p4Oa.js";import{S as K,n as Y}from"./ui-vendor-CrBP-qRZ.js";import"./utils-vendor-DBzSxgRl.js";import"./markdown-vendor-elH94dlU.js";import"./dnd-vendor-zA92mhJ9.js";function ee(){const{t:n}=I(),{message:s}=q(),{selectedAgent:S}=B(),[f]=K.useForm(),[R,b]=o.useState(!0),[F,A]=o.useState(!1),[L,k]=o.useState(null),[d,v]=o.useState("zh"),[N,E]=o.useState(!1),[y,T]=o.useState("UTC"),[O,M]=o.useState(!1),[h,z]=o.useState("AUTO"),C=o.useRef(null),x=o.useCallback(async()=>{var a,t,r;b(!0),k(null);try{const[e,l,c]=await Promise.all([_.getAgentRunningConfig(),_.getAgentLanguage(),_.getUserTimezone()]),g=(e.approval_level||"AUTO").toUpperCase();z(g);const u=e.context_manager_backend in G?e.context_manager_backend:"light",m=e.memory_manager_backend in V||D.some(i=>i.value===e.memory_manager_backend)?e.memory_manager_backend:"remelight";f.setFieldsValue({shell_command_timeout:e.shell_command_timeout??60,shell_command_executable:e.shell_command_executable??"",loop:{...e.loop,iteration:{...(a=e.loop)==null?void 0:a.iteration,max_iterations:((r=(t=e.loop)==null?void 0:t.iteration)==null?void 0:r.max_iterations)??e.max_iters??100}},llm_retry_enabled:e.llm_retry_enabled,llm_max_retries:e.llm_max_retries,llm_backoff_base:e.llm_backoff_base,llm_backoff_cap:e.llm_backoff_cap,llm_max_concurrent:e.llm_max_concurrent,llm_max_qpm:e.llm_max_qpm,llm_rate_limit_pause:e.llm_rate_limit_pause,llm_rate_limit_jitter:e.llm_rate_limit_jitter,llm_acquire_timeout:e.llm_acquire_timeout,history_max_length:e.history_max_length,context_manager_backend:u,light_context_config:e.light_context_config,memory_manager_backend:m,reme_light_memory_config:e.reme_light_memory_config,adbpg_memory_config:e.adbpg_memory_config,auto_title_config:e.auto_title_config??{enabled:!0,timeout_seconds:30}}),C.current=e,v(l.language),T(c.timezone||"UTC")}catch(e){const l=e instanceof Error?e.message:n("agentConfig.loadFailed");k(l)}finally{b(!1)}},[f,n,S]);o.useEffect(()=>{x()},[x]);const j=o.useCallback(async()=>{try{const a=await f.validateFields();A(!0);const t=C.current,r=a,e=(c,g)=>{if(!c)return g??void 0;if(!g)return c;const u={...c};for(const m of Object.keys(g)){const i=g[m],p=c[m];i!=null&&typeof i=="object"&&!Array.isArray(i)&&p!=null&&typeof p=="object"&&!Array.isArray(p)?u[m]=e(p,i):u[m]=i}return u},l={...t,...r,reme_light_memory_config:e(t.reme_light_memory_config,r.reme_light_memory_config),light_context_config:e(t.light_context_config,r.light_context_config),adbpg_memory_config:e(t.adbpg_memory_config,r.adbpg_memory_config),auto_title_config:e(t.auto_title_config,r.auto_title_config),approval_level:h};await _.updateAgentRunningConfig(l),C.current=l,s.success(n("agentConfig.saveSuccess"))}catch(a){if(a instanceof Error&&"errorFields"in a)return;const t=a instanceof Error?a.message:n("agentConfig.saveFailed");s.error(t)}finally{A(!1)}},[f,n,S,h]),U=o.useCallback(a=>{a!==d&&Y.confirm({title:n("agentConfig.languageConfirmTitle"),content:P.jsx("span",{style:{whiteSpace:"pre-line"},children:n("agentConfig.languageConfirmContent")}),okText:n("agentConfig.languageConfirmOk"),cancelText:n("common.cancel"),onOk:async()=>{E(!0);try{const t=await _.updateAgentLanguage(a);v(t.language),t.copied_files&&t.copied_files.length>0?s.success(n("agentConfig.languageSaveSuccessWithFiles",{count:t.copied_files.length})):s.success(n("agentConfig.languageSaveSuccess"))}catch(t){const r=t instanceof Error?t.message:n("agentConfig.languageSaveFailed");s.error(r)}finally{E(!1)}}})},[d,n]),w=o.useCallback(async a=>{if(a!==y){M(!0);try{await _.updateUserTimezone(a),T(a),s.success(n("agentConfig.timezoneSaveSuccess"))}catch(t){const r=t instanceof Error?t.message:n("agentConfig.timezoneSaveFailed");s.error(r)}finally{M(!1)}}},[y,n]);return{form:f,loading:R,saving:F,error:L,language:d,savingLang:N,timezone:y,savingTimezone:O,approvalLevel:h,setApprovalLevel:z,fetchConfig:x,handleSave:j,handleLanguageChange:U,handleTimezoneChange:w}}export{ee as useAgentConfig};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.