1import{n as e,o as t}from"./rolldown-runtime-CMxvf4Kt.js";import{Bt as n}from"../i18n/i18n-ar-O-z3xW8i.js";import{F as r,G as i,L as a,O as o,S as s,U as c,b as l,w as u,x as d,y as f}from"../vendor/vendor-data-runtime-nLFaCKB0.js";import{Ci as p,Yi as m,mn as h,na as g,vi as _}from"../vendor/vendor-ai-runtime-DrDK77gy.js";import{d as v,m as y}from"./agent-Doq2Q6Wt.js";import{$t as b,Ao as x,Qa as S,So as ee,Yn as te,ca as ne,en as re,g as C,ia as ie,jo as w,la as ae}from"./app-const-BzFqCjOv.js";import{Do as T,Fn as E,Oo as oe,Pn as se,X as ce,bo as D,to as O,vo as k,wo as le,zn as ue}from"./ScrollArea-CdDxdn_v.js";import{Ia as de,Ka as fe,Ki as pe,Un as me,ci as he,fa as ge,n as A,oi as _e,qn as ve}from"./es-D7HWafs1.js";import{Q as ye,_ as be,an as xe,at as Se,n as Ce,s as we,tt as Te}from"./es-D3_QMuVV.js";import{a as Ee,y as De}from"../vendor/vendor-react-Bwss5s6Y.js";import{Cs as Oe,Du as ke,Gh as Ae,Gl as je,La as Me,Ng as Ne,Nh as Pe,Nt as Fe,Tu as Ie,Uc as Le,Ul as Re,Up as ze,Va as Be,Vc as Ve,Vo as He,Zc as Ue,Zs as We,_p as Ge,am as Ke,ar as qe,dh as Je,dp as Ye,et as j,ha as Xe,jc as Ze,jh as Qe,jm as $e,jr as et,kg as tt,ki as nt,ks as rt,ku as it,li as at,lp as ot,lt as st,pd as ct,pn as lt,qc as ut,ql as dt,qt as ft,so as pt,st as mt,t_ as ht,tn as gt,tr as _t,ym as vt,zt as yt}from"../vendor/vendor-icons-BXJMWD35.js";import{O as bt,_ as xt,a as St,n as Ct,r as wt,v as Tt,x as Et}from"./base-ui-Bi3Dz7GG.js";import{Fn as Dt,In as Ot,Wn as kt,Yn as At,_t as jt,a as M,bt as Mt,cn as Nt,ct as Pt,ht as N,ir as Ft,lt as It,n as P,o as F,p as Lt,pt as Rt,rr as zt,ut as Bt,y as Vt}from"./agent-Dh3-_0ai.js";import{Mt as Ht,b as Ut,jt as Wt,y as Gt}from"./selectors-IDJ5-Ts8.js";import{At as Kt,C as qt,Ot as Jt,_n as Yt,o as Xt}from"./agentDocument-GhemY2N0.js";import{h as Zt,m as Qt}from"./swr-C_leGIiU.js";import{c as $t,i as en,n as tn,s as nn}from"./client-DUGXaJW2.js";import{Eo as rn,Ft as an,Mt as on,N as sn,P as cn,S as ln,T as I,Uo as un,Xo as dn,bi as fn,en as pn,n as mn,nn as hn,ns as gn,wo as _n}from"./store-JX60g0Lu.js";import{a as vn,o as yn}from"./device-C93cnKgk.js";import{n as bn,r as xn}from"./connector-CTv0KPI6.js";import{i as Sn,m as Cn,n as wn}from"./global-DfKpeTkj.js";import{n as Tn,t as En}from"./selectors-BLjUqOPJ.js";import{r as Dn}from"./store-DZ_eFvAj.js";import{n as On}from"./file-DreLu7dP.js";import{Cn as kn,G as An,K as jn,Sn as Mn,St as Nn,Ut as Pn,bn as Fn,i as In,r as Ln,vn as Rn,wn as zn,xn as Bn,yn as Vn}from"./ErrorContent-DH2cR0nE.js";import{$i as Hn,Aa as Un,An as Wn,Bo as Gn,Ia as Kn,Io as qn,It as Jn,Ji as Yn,Lo as Xn,Ma as Zn,On as Qn,Qa as $n,Rn as er,Ut as tr,Vo as L,Xa as nr,Zi as rr,cr as ir,ha as ar,is as or,lr as sr,qa as cr,ra as lr,rs as ur,sa as dr,sr as fr,vr as pr,wa as mr,zt as hr}from"./index-Doip7UYu.js";import{n as gr,t as _r}from"./ModelSelect-C_RYxAXZ.js";import{i as vr,o as yr,r as br}from"./BaseErrorForm-DneHtnxu.js";import{n as xr,t as Sr}from"./useWorkspaceAwareNavigate--pLVtz2A.js";import{a as Cr,i as wr,n as Tr,t as Er}from"./useAgentTransferMenuItem-bHSqiEuU.js";import{c as Dr,l as Or}from"./DirIcon-ByU8IWSX.js";import{i as kr,n as Ar,r as jr,t as Mr}from"./useAuthorInfo-BZD7eyD-.js";import{a as Nr,n as Pr,o as Fr,t as Ir}from"./useResourceAccess-CBiX3hN_.js";import{n as Lr,t as Rr}from"./useIsWorkspaceOwner-vpffHA75.js";import{_ as zr,g as Br,h as Vr}from"./PluginDetailModal-DrC6T4fA.js";import{n as Hr,r as Ur}from"./plugins-CwCSz6ZM.js";import{n as Wr,t as Gr}from"./WideScreenContainer-DRafIDbQ.js";import{n as Kr,t as qr}from"./AsyncError-DaHIxwPg.js";import{i as Jr,r as Yr}from"./useInterceptingRoutes-CCQfWbPL.js";import{n as Xr,t as Zr}from"./useOperationState-BCBWDiU_.js";import{n as Qr,t as $r}from"./AsyncBoundary-DPrmGZrq.js";import{n as ei,t as ti}from"./NavHeader-DeWZ4kV0.js";import{n as ni,t as ri}from"./RightPanel-Boprx1Dy.js";import{n as ii,t as ai}from"./AutoSaveHint-CmqIRLY3.js";import{n as oi,t as si}from"./constants-Bb3CxuI1.js";import{a as ci,o as li,t as ui}from"./useHotkeys-D39xskQD.js";import{n as di,t as fi}from"./styles-BfvnHl9u.js";import{n as pi,t as mi}from"./ToggleRightPanelButton-BP3Eb9-s.js";import{a as hi,c as gi,l as _i,o as vi,r as yi}from"./SuggestQuestions-BzcURZbt.js";import{n as bi,t as xi}from"./formatPageEditorInfoTime-BYaelPDa.js";import{n as Si,t as Ci}from"./binary-DsuXnDxA.js";import{n as wi,t as Ti}
1from"./ResourceConfigAccessGate-Bl-F9pHW.js";import{n as Ei,t as Di}from"./AgentBreadcrumb-CahCo-5U.js";import{a as Oi,c as ki,d as Ai,f as ji,i as Mi,l as Ni,n as Pi,o as Fi,r as Ii,s as Li,t as Ri,u as zi}from"./AgentTool-Du68RmNu.js";var Bi,Vi,Hi,Ui,Wi,Gi=e((()=>{A(),D(),Bi=t(n()),j(),Vi=t(w()),r(),ne(),ei(),rn(),Gt(),Hi=t(x()),Ui=le(({css:e,cssVar:t})=>({time:e` 2 margin-inline-start: 6px; 3 font-size: 12px; 4 color: ${t.colorTextTertiary}; 5 `,title:e` 6 overflow: hidden; 7 8 font-size: 14px; 9 font-weight: 500; 10 text-overflow: ellipsis; 11 white-space: nowrap; 12 `})),Wi=(0,Vi.memo)(({agentId:e,disabled:t})=>{let{t:n}=a(`topic`);mn(e=>e.useFetchTopics)(!0,{agentId:e});let[r,i,o]=mn(t=>[t.activeTopicId,t.switchTopic,Ut.getTopicsByAgentId(e)(t)]),s=(0,Vi.useMemo)(()=>o?.find(e=>e.id===r),[o,r]),c=(0,Vi.useMemo)(()=>(o||[]).map(e=>{let n=(0,Bi.default)().diff((0,Bi.default)(e.updatedAt),`d`)<7?(0,Bi.default)(e.updatedAt).fromNow():(0,Bi.default)(e.updatedAt).format(`YYYY-MM-DD`);return{checked:e.id===r,closeOnClick:!0,key:e.id,label:(0,Hi.jsxs)(k,{horizontal:!0,align:`center`,gap:4,justify:`space-between`,width:`100%`,children:[(0,Hi.jsx)(`span`,{className:Ui.title,children:e.title}),(0,Hi.jsx)(`span`,{className:Ui.time,children:n})]}),onCheckedChange:n=>{t||n&&i(e.id)},type:`checkbox`}}),[o,i,Ui,r]),l=!o||o.length===0;return(0,Hi.jsx)(ti,{showTogglePanelButton:!1,left:s?.title?(0,Hi.jsx)(`span`,{className:Ui.title,children:s.title}):void 0,right:(0,Hi.jsxs)(Hi.Fragment,{children:[(0,Hi.jsx)(de,{disabled:t,icon:Me,size:ie,title:n(`actions.addNewTopic`),onClick:()=>{t||i()}}),(0,Hi.jsx)(ce,{items:c,placement:`bottomRight`,popupProps:{style:{maxHeight:400,minWidth:280,overflowY:`auto`}},triggerProps:{disabled:t||l},children:(0,Hi.jsx)(de,{disabled:t||l,icon:vt})})]})})}),Wi.displayName=`TopicSelector`})),Ki,qi,Ji,Yi,Xi,Zi=e((()=>{A(),Ki=t(w()),vr(),Ln(),Gn(),P(),F(),ji(),Ni(),Gi(),qi=t(x()),Ji=[`model`],Yi=[],Xi=(0,Ki.memo)(({agentId:e})=>{let{handleUploadFiles:t}=yr({agentId:e,model:M(t=>Rt.getAgentModelById(e)(t)),provider:M(t=>Rt.getAgentModelProviderById(e)(t))}),{allowed:n}=L(`create_content`);return zi(),(0,qi.jsx)(br,{disabled:!n,style:{flex:1,height:`100%`},onUploadFiles:t,children:(0,qi.jsxs)(k,{flex:1,height:`100%`,children:[(0,qi.jsx)(Wi,{agentId:e,disabled:!n}),(0,qi.jsx)(k,{flex:1,style:{overflow:`hidden`},children:(0,qi.jsx)(In,{welcome:(0,qi.jsx)(Ai,{disabled:!n})})}),(0,qi.jsx)(Nn,{leftActions:Ji,rightActions:Yi,showControlBar:!1})]})})})})),Qi,$i,ea,ta=e((()=>{Qi=t(w()),Ln(),Zr(),rn(),Wt(),$i=t(x()),ea=(0,Qi.memo)(({agentId:e,editingAgentId:t,children:n})=>{let r=mn(e=>e.activeTopicId);(0,Qi.useEffect)(()=>{t&&mn.getState().activeAgentId!==t&&mn.setState({activeAgentId:t},!1,`AgentBuilderProvider/syncEditingAgentId`)},[t]);let i=(0,Qi.useMemo)(()=>({agentId:e,scope:`agent_builder`,topicId:r}),[e,r]),a=(0,Qi.useMemo)(()=>i?Ht(i):null,[i?.agentId,i?.topicId]),o=mn(e=>e.replaceMessages),s=mn(e=>a?e.dbMessagesMap[a]:void 0),c=Xr(i);return(0,$i.jsx)(Pn,{context:i,hasInitMessages:!!s,messages:s,operationState:c,onMessagesChange:(e,t)=>
12{o(e,{context:t})},children:n})})})),na,ra,ia,aa=e((()=>{Mt(),na=t(w()),or(),ni(),P(),F(),wn(),En(),Zi(),ta(),ra=t(x()),ia=(0,na.memo)(()=>{let e=M(e=>e.activeAgentId),t=M(jt.agentBuilderId),[n,r,i,a]=Sn(e=>[Cn.showAgentBuilderPanel(e),e.toggleAgentBuilderPanel,Cn.agentBuilderPanelWidth(e),e.updateSystemStatus]);return M(e=>e.useInitBuiltinAgent)(Nt.agentBuilder),(0,ra.jsx)(ri,{defaultWidth:i,expand:n,onExpandChange:r,onSizeChange:e=>{if(e?.width){let t=typeof e.width==`string`?Number.parseInt(e.width):e.width;t&&a({agentBuilderPanelWidth:t})}},children:e&&t?(0,ra.jsx)(ea,{agentId:t,editingAgentId:e,children:(0,ra.jsx)(Xi,{agentId:t})}):(0,ra.jsx)(ur,{debugId:`AgentBuilder > Init`})})})})),oa,sa=e((()=>{oa={hasEdited:!1,lockState:{holderId:null,lockedByOther:!1,pending:!0},promptLastUpdatedTime:null,promptSaveStatus:`idle`,streamingContent:void 0,streamingInProgress:!1}})),ca,la=e((()=>{C(),ae(),sa(),ca=e=>(t,n)=>{let r=Promise.resolve(),i=0,a,o=e=>{let n={...e,revision:++i};return a=void 0,t({promptSaveStatus:`saving`}),n},s=e=>{let{agentId:n,payload:o,revision:s,updateConfigById:c}=e;return r=r.then(async()=>{try{await c(n,o),s===i&&(a=void 0,t({promptLastUpdatedTime:new Date,promptSaveStatus:`saved`}))}catch(n){console.error(`[ProfileEditor] Failed to save:`,n),s===i&&(a=e,t({promptSaveStatus:`failed`}))}}),r},c=()=>S(e=>s(e),b,{leading:!1,maxWait:re,trailing:!0}),l=new Map,u=e=>{let t=l.get(e);if(t)return t;let n=c();return l.set(e,n),n};return{...oa,...e,appendStreamingContent:e=>{let r=(n().streamingContent||``)+e;t({streamingContent:r});let{editor:i}=n();if(i)try{i.setDocument(`markdown`,r)}catch{}},finishStreaming:async(e,r)=>{let{editor:i,streamingContent:a}=n();if(!a){t({streamingInProgress:!1});return}let c=a,l={};if(i)try{c=i.getDocument(`markdown`)||a,l=i.getDocument(`json`)}catch{}try{await s(o({agentId:e,payload:{editorData:structuredClone(l||{}),systemRole:c},updateConfigById:r}))}catch(e){console.error(`[ProfileEditor] Failed to save streaming content:`,e)}t({streamingContent:void 0,streamingInProgress:!1})},flushSave:async e=>{let t=e?[l.get(e)]:[...l.values()];await Promise.all(t.map(e=>e?.flush())),await r},handleContentChange:(e,t,r)=>{let i=r??n().editor;if(!(!e||!i))try{let n=i.getDocument(`markdown`)||``,r=i.getDocument(`json`);u(e)(o({agentId:e,payload:{editorData:structuredClone(r||{}),systemRole:n||``},updateConfigById:t}))}catch(e){console.error(`[ProfileEditor] Failed to read editor content:`,e)}},retryPromptSave:async()=>{let e=a;e&&(a=void 0,t({promptSaveStatus:`saving`}),await s(e))},setHasEdited:e=>{n().hasEdited!==e&&t({hasEdited:e})},setLockState:e=>{let r=n().lockState;(r.holderId!==e.holderId||r.lockedByOther!==e.lockedByOther||r.pending!==e.pending)&&t({lockState:e})},startStreaming:()=>{let{editor:e}=n();if(e)try{e.setDocument(`markdown`,``)}catch{}t({streamingContent:``,streamingInProgress:!0})}}}})),ua,da=e((()=>{ua={editor:e=>e.editor,editorState:e=>e.editorState,hasEdited:e=>!!e.hasEdited,lockHolderId:e=>e.lockState.holderId,lockPending:e=>e.lockState.pending,lockedByOther:e=>e.lockState.lockedByOther,promptLastUpdatedTime:e=>e.promptLastUpdatedTime,promptSaveStatus:e=>e.promptSaveStatus}})),fa,R,pa,ma,ha=e((()=>{f(),u(),s(),v(),la(),da(),fa=e=>d(l(ca(e)),o),{useStore:R,useStoreApi:pa,Provider:ma}=y()})),ga,_a,va,ya=e((()=>{ga=t(w()),yi(),Gn(),tn(),P(),ha(),_a={acquire:e=>nn.agent.acquireAgentLock.mutate({agentId:e}),peek:e=>nn.agent.getAgentLock.query({agentId:e}),release:async e=>{await nn.agent.releaseAgentLock.mutate({agentId:e})}},va=(0,ga.memo)(()=>{let{allowed:e}=L(`edit_own_content`),t=M(e=>e.activeAgentId),n=M(e=>e.activeAgentId?e.agentMap[e.activeAgentId]?.workspaceId:void 0),r=R(e=>e.hasEdited),i=R(e=>e.setLockState),a=R(e=>e.setHasEdited),o=(0,ga.useRef)(t);(0,ga.useEffect)(()=>{o.current!==t&&(o.current=t,a(!1))},[t,a]);let s=hi({client:_a,enabled:!!(t&&e&&n),isDirty:!!r,resourceId:t??void 0});return(0,ga.useEffect)(()=>{i({holderId:s.holderId,lockedByOther:s.lockedByOther,pending:s.pending})},[s.holderId,s.lockedByOther,s.pending,i]),null})})),ba,xa=e((()=>{ba=e=>null}));
12function Sa(e,t,n=Ca){return e.replaceAll(/[^\w\u4E00-\u9FFF -]/g,`_`).trim().slice(0,n)||t}var Ca,wa=e((()=>{Ca=50})),Ta,Ea,Da,Oa=e((()=>{A(),j(),Ta=t(w()),r(),Sr(),sn(),P(),F(),Ea=t(x()),Da=(0,Ta.memo)(()=>{let{t:e}=a(`setting`),t=xr(),[n,r]=(0,Ta.useState)(null),[i,o]=(0,Ta.useState)(!1),s=M(N.currentAgentMeta)?.marketIdentifier;return(0,Ta.useEffect)(()=>{if(!s){r(null);return}(async()=>{try{o(!0),(await cn.getAgentDetail(s)).forkedFromAgentId?r((await cn.getAgentForkSource(s)).source):r(null)}catch(e){console.error(`Failed to fetch agent fork info:`,e),r(null)}finally{o(!1)}})()},[s]),i||!n?null:(0,Ea.jsxs)(ge,{bordered:!1,color:`default`,icon:(0,Ea.jsx)(O,{icon:ct}),style:{cursor:`pointer`,marginRight:8},title:e(`marketPublish.forkFrom.tooltip`,{agent:n.name,defaultValue:`Forked from ${n.name}`}),onClick:()=>{n?.identifier&&t(`/community/agent/${n.identifier}`)},children:[e(`marketPublish.forkFrom.label`,{defaultValue:`Forked from`}),` `,n.name]})}),Da.displayName=`AgentForkTag`})),ka,Aa,ja,Ma=e((()=>{A(),ka=t(w()),r(),sn(),P(),F(),Aa=t(x()),ja=(0,ka.memo)(()=>{let{t:e}=a(`setting`),[t,n]=(0,ka.useState)(null),[r,i]=(0,ka.useState)(!1),o=M(N.currentAgentMeta)?.marketIdentifier;(0,ka.useEffect)(()=>{if(!o){n(null);return}(async()=>{try{i(!0),n((await cn.getAgentDetail(o)).status)}catch(e){console.error(`Failed to fetch agent status:`,e),n(null)}finally{i(!1)}})()},[o]);let s=(0,ka.useMemo)(()=>t?{archived:{color:`orange`,label:e(`marketPublish.status.archived`,{defaultValue:`Archived`})},deprecated:{color:`red`,label:e(`marketPublish.status.deprecated`,{defaultValue:`Deprecated`})},published:{color:`green`,label:e(`marketPublish.status.published`,{defaultValue:`Published`})},unpublished:{color:`default`,label:e(`marketPublish.status.unpublished`,{defaultValue:`Unpublished`})}}[t]:null,[t,e]);return r||!s?null:(0,Aa.jsx)(ge,{bordered:!1,color:s.color,style:{marginRight:8},children:s.label})}),ja.displayName=`AgentStatusTag`})),Na,Pa,Fa,Ia=e((()=>{A(),Na=t(w()),r(),sn(),P(),F(),Pa=t(x()),Fa=(0,Na.memo)(()=>{let{t:e}=a(`setting`),[t,n]=(0,Na.useState)(null),[r,i]=(0,Na.useState)(!1),o=M(N.currentAgentMeta)?.marketIdentifier;(0,Na.useEffect)(()=>{if(!o){n(null);return}(async()=>{try{i(!0),n((await cn.getAgentDetail(o)).versions||null)}catch(e){console.error(`Failed to fetch agent versions:`,e),n(null)}finally{i(!1)}})()},[o]);let s=(0,Na.useMemo)(()=>!t||t.length===0?!1:t[0].isValidated===!1,[t]);return r||!s?null:(0,Pa.jsx)(ge,{bordered:!1,color:`orange`,style:{marginRight:8},children:e(`marketPublish.status.underReview`,{defaultValue:`Under Review`})})}),Fa.displayName=`AgentVersionReviewTag`})),La,Ra,z,za,Ba,Va=e((()=>{C(),h(),A(),Ct(),D(),La=t(m()),j(),Ra=t(w()),r(),Er(),Mr(),xa(),Nr(),zt(),ne(),Ei(),ei(),bi(),ki(),Ir(),gi(),pi(),Sr(),Gn(),P(),F(),wn(),En(),on(),wa(),Yr(),ha(),Oa(),Ma(),Ia(),z=t(x()),g(),za=e=>{let{description:t,model:n,plugins:r=[],provider:i,systemRole:a,t:o,tags:s=[],title:c}=e,l=[],u=c?.trim()||o(`settingAgent.export.untitled`,{ns:`setting`});l.push(`# ${u}`),t?.trim()&&l.push(t.trim());let d=[i?`- ${o(`settingAgent.export.provider`,{ns:`setting`})}: ${i}`:void 0,n?`- ${o(`settingAgent.export.model`,{ns:`setting`})}: ${n}`:void 0,s.length>0?`- ${o(`settingAgent.export.tags`,{ns:`setting`})}: ${s.join(`, `)}`:void 0].filter(Boolean);return d.length>0&&l.push(`## ${o(`settingAgent.export.metadata`,{ns:`setting`})}\n\n${d.join(` 13`)}`),r.length>0&&l.push(`## ${o(`settingAgent.export.enabledPlugins`,{ns:`setting`})}\n\n${r.map(e=>`- ${e}`).join(` 14`)}`),a?.trim()&&l.push(`## ${o(`settingAgent.prompt.title`,{ns:`setting`})}\n\n${a.trim()}`),`${l.join(` 15 16`)}\n`},Ba=(0,Ra.memo)(()=>{let{i18n:e,t}=a([`setting`,`chat`,`file`,`common`,`spend`]),n=e?.resolvedLanguage||e?.language,r=xr(),i=M(N.currentAgentMeta,La.default),o=M(N.currentAgentConfig,La.default),s=M(N.currentAgentSystemRole),c=M(e=>e.activeAgentId),l=M(N.isCurrentAgentHeterogeneous),u=M(jt.isInboxAgent),d=M(N.currentAgentVisibility),f=M(N.currentAgentAuthorId),p=M(N.currentAgentCreatedAt),m=Ar(f)?.fullName,h=Fr()&&!!c&&d!==`private`,[g,v,y]=Sn(e=>[Cn.showAgentBuilderPanel(e),e.toggleAgentBuilderPanel,Cn.isStatusInit(e)]),b=an(e=>e.removeAgent),x=R(e=>e.editor),S=R(ua.lockedByOther),ee=R(ua.lockPending),{allowed:te}=L(`edit_own_content`),{canEditResource:ne,canManageResource:re}=Pr(`agent`,h?c:void 0),C=te&&re,w=(0,Ra.useCallback)(()=>{!C||!c||xt({okButtonProps:{danger:!0},onOk:async()=>{await b(c),Ft.success(t(`confirmRemoveSessionSuccess`,{ns:`chat`})),r(`/`)},title:t(`confirmRemoveSessionItemAlert`,{ns:`chat`})})},[c,C,r,b,t]),ae=(0,Ra.useCallback)(async()=>{try{let e=l?void 0:x?.getDocument(`markdown`),n=za({description:i?.description,model:o.model,plugins:_(o.plugins),provider:o.provider,systemRole:e??s,t,tags:i?.tags,title:i?.title}),r=`${Sa(i?.title||``,t(`settingAgent.export.untitledFileName`,{ns:`setting`}))}.md`;{let e=new Blob([n],{type:`text/markdown`}),i=URL.createObjectURL(e),a=document.createElement(`a`);a.href=i,a.download=r,document.body.append(a),a.click(),a.remove(),URL.revokeObjectURL(i),Ft.success(t(`settingAgent.export.success`,{ns:`setting`}))}}catch(e){console.error(`Failed to export agent profile markdown:`,e),Ft.error(t(`settingAgent.export.error`,{ns:`setting`}))}},[o.model,o.plugins,o.provider,x,l,i,s,t]),E=ba(c??void 0),oe=Tr(c??void 0,i),se=_i(`agent`,h?c:void 0),D=(0,Ra.useRef)(null);(0,Ra.useEffect)(()=>()=>{D.current?.close(),D.current=null},[]);let le=(0,Ra.useMemo)(()=>{let e=oe??[];return[{disabled:!ne,icon:(0,z.jsx)(O,{icon:nt}),key:`advanced-settings`,label:t(`advancedSettings`,{ns:`setting`}),onClick:()=>{ne&&(D.current?.close(),D.current=Jr())}},{icon:(0,z.jsx)(O,{icon:Ae}),key:`usage-stats`,label:t(`usageStats.entry`,{ns:`spend`}),onClick:()=>{c&&r(`/agent/${c}/stats`)}},se,{type:`divider`},{children:[{key:`export-markdown`,label:t(`pageEditor.menu.export.markdown`,{ns:`file`}),onClick:ae}],icon:(0,z.jsx)(O,{icon:Ge}),key:`export`,label:t(`pageEditor.menu.export`,{ns:`file`})},E?{type:`divider`}:null,E,e.length>0?{type:`divider`}:null,...e,C?{type:`divider`}:null,C?{danger:!0,icon:(0,z.jsx)(O,{icon:lt}),key:`delete`,label:t(`delete`,{ns:`common`}),onClick:w}:null,...!u&&(m||p)?[{type:`divider`},{disabled:!0,icon:m?(0,z.jsx)(O,{icon:yt}):void 0,key:`agent-info`,label:(0,z.jsx)(`span`,{style:{color:T.colorTextTertiary,fontSize:12,lineHeight:1.6},children:[m,p?t(`createdAt`,{ns:`common`,time:xi(p,n)}
16):``].filter(Boolean).join(` · `)})}]:[]].filter(Boolean)},[c,m,ne,C,p,n,ae,w,u,se,r,t,E,oe]);return(0,z.jsx)(ti,{left:(0,z.jsxs)(k,{horizontal:!0,align:`center`,gap:8,children:[c&&(0,z.jsx)(Di,{agentId:c,title:t(`tab.profile`,{ns:`chat`})}),(0,z.jsx)(ja,{}),(0,z.jsx)(Fa,{}),(0,z.jsx)(Da,{}),(0,z.jsx)(Li,{resourceId:h?c??void 0:void 0,resourceType:`agent`})]}),right:(0,z.jsxs)(k,{horizontal:!0,align:`center`,gap:4,children:[(0,z.jsx)(ce,{items:le,children:(0,z.jsx)(de,{icon:ot,size:ie})}),!l&&y&&!S&&!ee&&(0,z.jsx)(mi,{expand:g,icon:Ne,showActive:!0,onToggle:()=>v()})]}),styles:{left:{paddingInlineStart:8}}})})})),Ha,Ua,Wa,Ga=e((()=>{A(),j(),Ha=t(w()),r(),P(),F(),Ua=t(x()),Wa=(0,Ha.memo)(({agentId:e})=>{let{t}=a(`setting`),n=M(e=>e.activeAgentId),r=e||n||``;return(0,Ua.jsx)(ue,{title:t(M(Rt.isWorkspaceAgentById(r))?`settingAgent.agentTools.priorityTooltipWorkspace`:`settingAgent.agentTools.priorityTooltip`),children:(0,Ua.jsxs)(k,{horizontal:!0,align:`center`,gap:4,style:{cursor:`help`,fontSize:12,opacity:.55},children:[(0,Ua.jsx)(O,{icon:dt,size:14}),t(`settingAgent.agentTools.priorityHint`)]})})}),Wa.displayName=`RunPriorityHint`})),Ka,qa=e((()=>{ae(),Ka=(e,t)=>e.replaceAll(/{{([\S\s]+?)}}/g,(e,n)=>{let r=ee(t,n.trim());return r===void 0?``:String(r)})})),Ja,Ya,Xa,Za,Qa=e((()=>{A(),D(),Ja=t(w()),Ya=t(x()),Xa=()=>{let e=window.getSelection();if(!e||e.rangeCount===0)return null;let t=e.getRangeAt(0).getBoundingClientRect();return{x:t.left,y:t.bottom}},Za=(0,Ja.memo)(({activeKey:e,onSelect:t,open:n,options:r,setActiveKey:i})=>{let a=(0,Ja.useRef)(null),[o,s]=(0,Ja.useState)(null);return(0,Ja.useLayoutEffect)(()=>{if(n){let e=Xa();e&&s(e)}},[n]),(0,Ja.useEffect)(()=>{a.current&&a.current.scrollIntoView({behavior:`smooth`,block:`nearest`})},[e]),!n||!r.length||!o?null:(0,Ya.jsx)(k,{style:{background:T.colorBgElevated,border:`1px solid ${T.colorBorderSecondary}`,borderRadius:12,boxShadow:T.boxShadowSecondary,left:o.x,maxHeight:260,maxWidth:400,minWidth:150,overflow:`hidden auto`,position:`fixed`,top:o.y,zIndex:9999},children:r.map(n=>{if(n?.type===`divider`)return(0,Ya.jsx)(`div`,{style:{borderTop:`1px solid ${T.colorBorderSecondary}`}},`divider-${n?.key??`divider`}`);let r=n,o=e===r.key;return(0,Ya.jsxs)(k,{align:`center`,direction:`horizontal`,gap:8,paddingBlock:8,paddingInline:12,ref:o?a:null,style:{background:o?T.colorFillSecondary:void 0,cursor:`pointer`},onMouseEnter:()=>i?.(String(r.key)),onMouseDown:e=>{e.preventDefault(),t?.(r)},children:[r.icon&&(0,Ya.jsx)(k,{style:{flex:`none`},children:r?.icon}),(0,Ya.jsx)(`div`,{style:{color:T.colorText,fontSize:14,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:r.label})]},String(r.key))})})}),Za.displayName=`MentionDropdown`})),$a,eo,to,no,ro,io,ao,oo,so,co,lo,uo,fo=e((()=>{C(),Xt(),qt(),Jn(),A(),D(),$a=t(m()),eo=t(w()),ir(),Ot(),Gn(),P(),ln(),pn(),qa(),Qa(),to=t(x()),no=e=>te.find(t=>t.identifier===e),ro=(0,eo.memo)(({icon:e,label:t})=>typeof e==`string`?(0,to.jsx)(me,{alt:t,height:20,src:e,style:{flex:`none`},width:20}):(0,to.jsx)(O,{fill:T.colorText,icon:e,size:20})),io=new Yt,ao=(e,t)=>t?.api?t.api.map(n=>({desc:n.description||``,name:io.generate(e,n.name,t.type)})):[],oo=e=>e?Ka(e,Dt.getContext()):``,so=(e,t,n)=>e.instructions?e.instructions:t?.systemRole?oo(t.systemRole):e.description||n||_n.getPluginDesc(t?.meta)||``,co=(e,t,n,r)=>{if(e.identifier)return e.identifier;let i=n||t?.identifier||``;if(e.label)return io.generate(i,e.label,t?.type);let a=t?.api?.[0]?.name;return a?io.generate(i,a,t?.type):r},lo=(e,t,n,r)=>{if(e.description)return e.description;if(!t?.api?.length||!r)return``;let i=n||t.identifier;return t.api.find(e=>io.generate(i,e.name,t.type)===r||e.name===r)?.description||``},uo=()=>{let{allowed:e}=L(`edit_own_content`),t=I(hn.discoverableMetaList,$a.default),n=M(e=>e.toggleAgentPlugin),r=(0,eo.useMemo)(()=>{let r=I.getState();return t.map(t=>{let i=hn.getManifestById(t.identifier)(r),a=_n.getPluginTitle(t.meta)||t.identifier,o=_n.getPluginDesc(t.meta),s=ao(i?.identifier||t.identifier,i),c=()=>({apis:s.map(e=>({...e})),description:o,identifier:t.identifier,label:a,pluginType:i?.type,type:`collection`}),l=no(t.identifier);return{description:o,icon:l?(0,to.jsx)(ro,{icon:l.icon,label:l.label}):(0,to.jsx)(fr,{alt:a,avatar:_n.getPluginAvatar(t.meta),size:20}),key:t.identifier,label:a,metadata:c(),onSelect:r=>{e&&(n(t.identifier,!0),r.dispatchCommand(dr,{label:a,metadata:c()}))}}})},[e,t,n]),i=(0,eo.useCallback)(async e=>{let t=e?.matchingString?.toLowerCase()||``;return t?r.filter(e=>{let n=typeof e.label==`string`?e.label.toLowerCase():``,r=e.description?.toLowerCase()||``,i=typeof e.key==`
16string`?e.key.toLowerCase():``;return n.includes(t)||r.includes(t)||i.includes(t)}):r},[r]),a=(0,eo.useCallback)(e=>{let t=e?.metadata||{},n=t.pluginIdentifier||t.identifier,r=I.getState(),i=n?hn.getManifestById(n)(r):void 0;if(t.type===`api`){let r=co(t,i,n,e?.label),a=lo(t,i,n,r);return r?`\n${Jt({desc:a,name:r})}\n`:e?.getTextContent?.()||``}let a=t.apis?.length&&t.apis.length>0?t.apis:ao(n||i?.identifier||``,i),o=t.label||_n.getPluginTitle(i?.meta)||n||e?.label||``,s=so(t,i,t.description);return`\n${Kt({apis:a||[],identifier:n||``,name:o,systemRole:s})}\n`},[]);return(0,eo.useMemo)(()=>({fuseOptions:{keys:[`key`,`label`,`description`],threshold:.4},items:i,markdownWriter:a,renderComp:Za}),[i,a])}})),po=e((()=>{fo()})),mo,ho,go,_o=e((()=>{Jn(),Yn(),j(),mo=t(w()),r(),ha(),ho=t(x()),go=(0,mo.memo)(()=>{let{t:e}=a(`editor`),t=R(e=>e.editorState),n=(0,mo.useMemo)(()=>t?[{active:t.isBold,icon:ht,key:`bold`,label:e(`typobar.bold`),onClick:t.bold,tooltipProps:{hotkey:nr($n.Bold).keys}},{active:t.isItalic,icon:je,key:`italic`,label:e(`typobar.italic`),onClick:t.italic,tooltipProps:{hotkey:nr($n.Italic).keys}},{active:t.isUnderline,icon:gt,key:`underline`,label:e(`typobar.underline`),onClick:t.underline,tooltipProps:{hotkey:nr($n.Underline).keys}},{active:t.isStrikethrough,icon:qe,key:`strikethrough`,label:e(`typobar.strikethrough`),onClick:t.strikethrough,tooltipProps:{hotkey:nr($n.Strikethrough).keys}},{type:`divider`},{icon:Le,key:`bulletList`,label:e(`typobar.bulletList`),onClick:t.bulletList,tooltipProps:{hotkey:nr($n.BulletList).keys}},{icon:Ue,key:`numberlist`,label:e(`typobar.numberList`),onClick:t.numberList,tooltipProps:{hotkey:nr($n.NumberList).keys}},{icon:ut,key:`tasklist`,label:e(`typobar.taskList`),onClick:t.checkList},{type:`divider`},{active:t.isBlockquote,icon:We,key:`blockquote`,label:e(`typobar.blockquote`),onClick:t.blockquote},{type:`divider`},{icon:at,key:`math`,label:e(`typobar.tex`),onClick:t.insertMath},{active:t.isCode,icon:Ke,key:`code`,label:e(`typobar.code`),onClick:t.code,tooltipProps:{hotkey:nr($n.CodeInline).keys}},{icon:et,key:`codeblock`,label:e(`typobar.codeblock`),onClick:t.codeblock}].filter(Boolean):[],[t,e]);return t?(0,ho.jsx)(rr,{items:n}):null}),go.displayName=`TypoBar`})),vo,yo,bo,xo=e((()=>{Jn(),A(),j(),vo=t(w()),r(),ha(),yo=t(x()),bo=()=>{let{t:e}=a(`editor`),t=R(e=>e.editorState);return(0,vo.useMemo)(()=>[{icon:it,key:`h1`,label:e(`slash.h1`),onSelect:e=>{e.dispatchCommand(ar,{tag:`h1`})}},{icon:ke,key:`h2`,label:e(`slash.h2`),onSelect:e=>{e.dispatchCommand(ar,{tag:`h2`})}},{icon:Ie,key:`h3`,label:e(`slash.h3`),onSelect:e=>{e.dispatchCommand(ar,{tag:`h3`})}},{type:`divider`},{icon:ut,key:`tl`,label:e(`typobar.taskList`),onSelect:e=>{e.dispatchCommand(Un,void 0)}},{icon:Le,key:`ul`,label:e(`typobar.bulletList`),onSelect:e=>{e.dispatchCommand(Zn,void 0)}},{icon:Ue,key:`ol`,label:e(`typobar.numberList`),onSelect:e=>{e.dispatchCommand(Kn,void 0)}},{type:`divider`},{icon:rt,key:`hr`,label:e(`slash.hr`),onSelect:e=>{e.dispatchCommand(er,{})}},{icon:_t,key:`table`,label:e(`slash.table`),onSelect:e=>{e.dispatchCommand(Qn,{columns:`3`,rows:`3`})}},{icon:et,key:`codeblock`,label:e(`typobar.codeblock`),onSelect:()=>{t?.codeblock()}},{icon:at,key:`tex`,label:e(`slash.tex`),onSelect:e=>{e.dispatchCommand(Wn,{code:`x^2 + y^2 = z^2`}),queueMicrotask(()=>{e.focus()})}}].map(e=>e.type===`divider`?e:{...e,extra:(0,yo.jsx)(E,{code:!0,fontSize:12,type:`secondary`,children:e.key}),style:{minWidth:200}}),[e])}})),So,B,Co,wo,To,Eo,Do=e((()=>{Jn(),Yn(),A(),D(),So=t(m()),B=t(w()),r(),zt(),ii(),Ur(),yi(),Ir(),Gn(),oi(),P(),po(),ha(),da(),_o(),xo(),Co=t(x()),wo=le(({css:e})=>({desc:e` 17 font-size: 13px; 18 line-height: 1.6; 19 color: ${T.colorTextSecondary}; 20 `,editorShell:e` 21 min-height: 300px; 22 padding-block: 18px; 23 padding-inline: 18px; 24 border: 1px solid ${T.colorBorderSecondary}; 25 border-radius: ${T.borderRadiusLG}; 26 27 background: ${T.colorBgContainer}; 28 `,header:e` 29 max-width: 820px; 30 `,root:e` 31 padding-block-end: 16px; 32 `,title:e` 33 font-size: 16px; 34 font-weight: 600; 35 color: ${T.colorText}; 36 `})),To=(0,B.memo)(({agentId:e})=>{let{t}=a(`setting`),{allowed:n}=L(`edit_own_content`),[r,i]=(0,B.useState)(!1),[o,s]=(0,B.useState)(!1),c=M(t=>t.agentMap[e],So.default),l=c?.editorData,u=c?.systemRole,d=M(e=>e.updateAgentConfigById),f=(0,B.useCallback)((e,t)=>d(e,t,{rethrow:!0,showErrorMessage:!1}),[d]),[p]=(0,B.useState)(l===void 0||l?.root===void 0?si:l),m=uo(),h=R(e=>e.editor),g=R(e=>e.handleContentChange),_=bo(),v=M(e=>e.streamingSystemRoleAgentId),y=M(t=>t.streamingSystemRoleAgentId===e?t.streamingSystemRole:void 0),b=M(t=>t.streamingSystemRoleAgentId===e&&!!t.streamingSystemRoleInProgress),x=(0,B.useRef)(void 0),S=(0,B.useRef)(!1),ee=(0,B.useRef)(void 0),te=(0,B.useRef)(!1),ne=(0,B.useRef)(void 0),re=(0,B.useRef)(void 0),C=R(ua.lockedByOther),ie=R(ua.lockHolderId),w=R(ua.lockPending),ae=
36R(ua.promptLastUpdatedTime),T=R(ua.promptSaveStatus),E=R(e=>e.retryPromptSave),oe=R(e=>e.setHasEdited),{canEditResource:se}=Pr(`agent`,c?.visibility===`private`?void 0:e),ce=n&&se,D=ce&&!C&&!w,O=(0,B.useCallback)((e,t)=>{try{ee.current={format:t,value:structuredClone(e.getDocument(t))}}catch{ee.current=void 0}},[]),le=(0,B.useCallback)(e=>{let t=ee.current,n=e??h;if(!t||!n)return!1;ee.current=void 0;try{return(0,So.default)(n.getDocument(t.format),t.value)}catch{return!1}},[h]),ue=(0,B.useCallback)(t=>{le(t)||D&&(b||(te.current=!0,oe(!0),g(e,f,t)))},[e,D,g,le,oe,b,f]);return(0,B.useEffect)(()=>{if(!(!h||!r)){if(!b){x.current=void 0;return}if(y!==x.current){x.current=y;try{h.setDocument(`markdown`,y||``),O(h,`markdown`)}catch{}}}},[h,r,O,b,y]),(0,B.useEffect)(()=>{if(S.current&&!b&&h&&r){if(v&&v!==e){S.current=!1;return}if(!D)return;let t=setTimeout(()=>{g(e,f)},100);return()=>clearTimeout(t)}S.current=!!b},[e,D,h,r,g,v,b,f]),(0,B.useEffect)(()=>{if(!(!r||!h||o)&&!b)try{l&&l?.root!==void 0?(h.setDocument(`json`,l),O(h,`json`),ne.current=structuredClone(l)):u&&(h.setDocument(`markdown`,u),O(h,`markdown`),re.current=u),s(!0)}catch(e){console.error(`[EditorCanvas] Failed to init editor content:`,e)}},[o,h,l,r,O,b,u]),(0,B.useEffect)(()=>{if(!h||!r||!o||b)return;if(l&&l?.root!==void 0){if(re.current=void 0,te.current||(0,So.default)(ne.current,l))return;try{h.setDocument(`json`,l),O(h,`json`),ne.current=structuredClone(l)}catch(e){console.error(`[EditorCanvas] Failed to sync editor content:`,e)}return}ne.current=void 0;let e=u??``;if(re.current!==e){re.current=e;try{h.setDocument(`markdown`,e),O(h,`markdown`)}catch{}}},[o,h,l,r,O,b,u]),(0,Co.jsxs)(k,{className:wo.root,gap:16,children:[(0,Co.jsxs)(k,{className:wo.header,gap:4,children:[(0,Co.jsxs)(k,{horizontal:!0,align:`center`,distribution:`space-between`,gap:8,children:[(0,Co.jsx)(`div`,{className:wo.title,children:t(`settingAgent.prompt.title`)}),T!==`idle`&&(0,Co.jsx)(ai,{lastUpdatedTime:ae,saveStatus:T,onRetry:D?()=>void E():void 0})]}),(0,Co.jsx)(`div`,{className:wo.desc,children:t(`settingAgent.prompt.desc`)})]}),(0,Co.jsxs)(`div`,{className:wo.editorShell,style:D?void 0:{cursor:`not-allowed`,opacity:.65,pointerEvents:`none`},onClick:e=>{e.stopPropagation()},children:[(0,Co.jsx)(vi,{holderId:C?ie:null,pending:ce&&w}),(0,Co.jsx)(Hn,{content:p,editable:D,editor:h,lineEmptyPlaceholder:t(`settingAgent.prompt.editorPlaceholder`),mentionOption:m,placeholder:t(`settingAgent.prompt.editorPlaceholder`),style:{paddingBottom:0},plugins:[...Hr(),tr,lr,Hn.withProps(hr,{children:(0,Co.jsx)(go,{})})],slashOption:{items:_},onInit:()=>i(!0),onTextChange:ue})]})]})}),Eo=(0,B.memo)(()=>{let{t:e}=a(),t=M(e=>e.activeAgentId),n=R(e=>e.flushSave),r=pa();return(0,B.useEffect)(()=>()=>{t&&n(t).then(()=>{r.getState().promptSaveStatus===`failed`&&Ft.error(e(`saveAgentConfigFail`,{ns:`common`}))})},[t,n,r,e]),t?(0,Co.jsx)(To,{agentId:t},t):null})})),Oo,ko,Ao,jo,Mo,No=e((()=>{C(),A(),Ce(),ae(),Oo=t(m()),j(),ko=t(w()),r(),Xn(),kr(),Gn(),P(),F(),On(),wn(),En(),Ao=t(x()),jo=1024*1024,Mo=(0,ko.memo)(()=>{let{t:e}=a([`setting`,`common`]),t=Sn(Tn.currentLanguage),{allowed:n}=L(`edit_own_content`),r=M(e=>e.activeAgentId||``),i=M(N.getAgentMetaById(r),Oo.default),o=M(e=>e.updateAgentMetaById),s=Dn(e=>e.uploadWithProgress),[c,l]=(0,ko.useState)(!1),[u,d]=(0,ko.useState)(i.title||``);(0,ko.useEffect)(()=>{d(i.title||``)},[r,i.title]);let f=(0,ko.useMemo)(()=>S((e,t)=>{o(e,{title:t})},b),[o]);(0,ko.useEffect)(()=>()=>{f.flush(),f.cancel()},[r,f]);let p=e=>{n&&o(r,{avatar:e})},m=(0,ko.useCallback)(async t=>{if(n){if(t.size>jo){ye.error(e(`settingAgent.avatar.sizeExceeded`,{ns:`setting`}));return}l(!0);try{let e=await s({file:t});e?.url&&o(r,{avatar:e.url})}finally{l(!1)}}},[r,n,s,o,e]),h=(0,ko.useCallback)(()=>{n&&o(r,{avatar:null})},[r,n,o]),g=e=>{n&&e!==void 0&&o(r,{backgroundColor:e})};return(0,Ao.jsxs)(k,{gap:16,paddingBlock:16,style:{cursor:`default`},onClick:e=>{e.stopPropagation(),e.preventDefault()},children:[(0,Ao.jsx)(qn,{allowModelAvatar:!0,allowDelete:n&&!!i.avatar,allowUpload:n,loading:c,locale:t,open:n?void 0:!1,shape:`square`,size:72,value:i.avatar,background:i.backgroundColor&&i.backgroundColor!==`rgba(0,0,0,0)`?i.backgroundColor:void 0,customTabs:[{label:(0,Ao.jsx)(ue,{title:e(`settingAgent.backgroundColor.title`,{ns:`setting`}),children:(0,Ao.jsx)(O,{icon:He,size:{size:20,strokeWidth:2.5}})}),render:()=>(0,Ao.jsx)(k,{padding:8,width:332,children:(0,Ao.jsx)(ko.Suspense,{fallback:(0,Ao.jsxs)(k,{gap:8,children:[(0,Ao.jsx)(ve.Button,{block:!0,style:{height:38}}),(0,Ao.jsx)(ve.Button,{block:!0,style:{height:38}})]}),children:(0,Ao.jsx)(jr,{disabled:!n,gap:8,shape:`square`,size:38,value:i.backgroundColor,onChange:g})})}),value:`background`}],popupProps:{placement:`bottomLeft`},onChange:p,onDelete:h,onUpload:m}),(0,Ao.jsx)(k,{flex:1,style:{minWidth:0},children:(0,Ao.jsx)(_e,{disabled:!n,placeholder:e(`settingAgent.name.placeholder`,{ns:`setting`}),value:u,variant:`borderless`,style:{fontSize:36,fontWeight:600,padding:0,width:`100%`},onChange:e=>{d(e.target.value),!(!r||!n)&&f(r,e.target.value)}})})]})})}
36)),Po,V,Fo,Io,Lo,Ro=e((()=>{h(),Po=t(m()),V=t(w()),tn(),P(),F(),ln(),bn(),Fo=1e3,Io=15e3,Lo=({agentId:e,appSlug:t,identifier:n,label:r})=>{let[i,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(!1),c=(0,V.useRef)(null),l=(0,V.useRef)(null),u=(0,V.useRef)(null),d=(0,V.useRef)(null),f=(0,V.useRef)(null),m=I(xn.agentConnectors(e),Po.default),h=I(e=>e.fetchAgentConnectors),g=I(e=>e.detachConnectorFromAgent),_=M(e=>e.updateAgentConfigById),v=m.find(t=>t.identifier===n&&t.agentId===e&&!!t.metadata?.composio),y=!!v,b=(0,V.useCallback)(()=>{for(let e of[u,d])e.current&&=(clearInterval(e.current),null);f.current&&=(clearTimeout(f.current),null),l.current=null,s(!1)},[]);(0,V.useEffect)(()=>()=>b(),[b]);let x=(0,V.useCallback)(async()=>{let i=c.current;if(i)try{if((await nn.composio.getConnection.query({connectedAccountId:i.connectedAccountId})).status!==`ACTIVE`)return;let a=((await en.composio.listActions.query({appSlug:t})).tools??[]).map(e=>({description:e.description,inputSchema:e.inputSchema,name:e.name}));await nn.composio.updateComposioPlugin.mutate({agentId:e,appSlug:t,authConfigId:i.authConfigId,connectedAccountId:i.connectedAccountId,identifier:n,label:r,redirectUrl:i.redirectUrl,status:`ACTIVE`,tools:a}),await _(e,{plugins:p(N.getAgentConfigById(e)(M.getState())?.plugins,n,`pinned`)}),await h(e),c.current=null}catch(e){console.error(`[AgentSkillStore] activate failed:`,e)}},[e,t,n,r,_,h]),S=(0,V.useCallback)(()=>{d.current||(d.current=setInterval(()=>{x().then(()=>{c.current===null&&b()})},Fo),f.current=setTimeout(b,Io))},[x,b]),ee=(0,V.useCallback)(e=>{u.current=setInterval(async()=>{e.closed&&(u.current&&=(clearInterval(u.current),null),await x(),b())},500)},[x,b]),te=(0,V.useCallback)(e=>{b(),s(!0);let t=window.open(e,`_blank`,`width=600,height=700`);t?(l.current=t,ee(t)):S()},[b,ee,S]);return{handleConnect:(0,V.useCallback)(async()=>{if(!y){a(!0);try{let i=await nn.composio.createConnection.mutate({agentId:e,appSlug:t,identifier:n,label:r});c.current={authConfigId:i.authConfigId,connectedAccountId:i.connectedAccountId,redirectUrl:i.redirectUrl},i.redirectUrl?te(i.redirectUrl):await x()}catch(e){console.error(`[AgentSkillStore] connect failed:`,e)}finally{a(!1)}}},[y,e,t,n,r,te,x]),handleDisconnect:(0,V.useCallback)(async()=>{v&&await g(v.id,e,`delete`)},[v,e,g]),isConnected:y,isConnecting:i||o}}})),zo,Bo,Vo,Ho=e((()=>{A(),Ct(),D(),j(),zo=t(w()),r(),Br(),Gn(),Ro(),Bo=t(x()),Vo=(0,zo.memo)(({agentId:e,appSlug:t,description:n,icon:r,identifier:i,label:o})=>{let{t:s}=a(`setting`),c=zr,{allowed:l}=L(`create_content`),{allowed:u}=L(`edit_own_content`),{handleConnect:d,handleDisconnect:f,isConnected:p,isConnecting:m}=Lo({agentId:e,appSlug:t,identifier:i,label:o}),h=s(`tools.composio.servers.${i}.description`,{defaultValue:n??``});return(0,Bo.jsxs)(fe,{horizontal:!0,align:`center`,className:c.container,gap:12,paddingBlock:12,paddingInline:12,variant:`outlined`,children:[typeof r==`string`?(0,Bo.jsx)(`img`,{alt:o,height:40,src:r,width:40}):(0,Bo.jsx)(O,{fill:T.colorText,icon:r,size:40}),(0,Bo.jsxs)(k,{flex:1,gap:4,style:{minWidth:0,overflow:`hidden`},children:[(0,Bo.jsx)(`span`,{className:c.title,children:o}),h&&(0,Bo.jsx)(`span`,{className:c.description,children:h})]}),(0,Bo.jsx)(`div`,{onClick:se,children:m?(0,Bo.jsx)(de,{loading:!0,icon:Ve}):p?(0,Bo.jsx)(ce,{nativeButton:!1,placement:`bottomRight`,items:[{danger:!0,disabled:!u,icon:(0,Bo.jsx)(O,{icon:ft}),key:`disconnect`,label:s(`tools.lobehubSkill.disconnect`),onClick:()=>{u&&xt({cancelText:s(`cancel`,{ns:`common`}),content:s(`settingAgent.agentTools.removeOwnedConfirm`),okButtonProps:{danger:!0},okText:s(`tools.lobehubSkill.disconnect`),onOk:f})}}],children:(0,Bo.jsx)(de,{disabled:!u,icon:Ye})}):(0,Bo.jsx)(de,{disabled:!l||!u,icon:Me,title:s(`tools.lobehubSkill.connect`),onClick:()=>{!l||!u||d()}})})]})}),Vo.displayName=`AgentSkillStoreItem`})),Uo,Wo,Go,Ko=e((()=>{C(),A(),Uo=t(w()),r(),Br(),Lt(),ln(),bn(),Ho(),Wo=t(x()),Go=(0,Uo.memo)(({agentId:e})=>{let{t}=a(`setting`),n=Vt(Pt.enableComposio),r=I(xn.isAgentConnectorsInit(e)),i=I(e=>e.fetchAgentConnectors);return(0,Uo.useEffect)(()=>{e&&!r&&i(e)},[e,r,i]),(0,Wo.jsx)(k,{gap:8,style:{maxHeight:`75vh`},width:`100%`,children:n?(0,Wo.jsx)(k,{height:496,style:{marginBlockEnd:-12,marginInline:-16,overflow:`auto`}
36,children:(0,Wo.jsx)(`div`,{className:Vr.grid,children:te.map(t=>(0,Wo.jsx)(Vo,{agentId:e,appSlug:t.appSlug,description:t.description,icon:t.icon,identifier:t.identifier,label:t.label},t.identifier))})}):(0,Wo.jsx)(E,{style:{padding:24},type:`secondary`,children:t(`settingAgent.agentTools.pickerEmpty`)})})}),Go.displayName=`AgentSkillStoreContent`})),qo,Jo,Yo=e((()=>{Ct(),c(),Ko(),qo=t(x()),Jo=e=>Tt({content:(0,qo.jsx)(Go,{agentId:e}),footer:null,title:i(`settingAgent.agentTools.connectNewPickerTitle`,{ns:`setting`}),width:`min(80%, 800px)`})})),Xo,Zo,H,Qo,$o=e((()=>{h(),A(),Ct(),Xo=t(m()),j(),Zo=t(w()),r(),Qt(),Rr(),Yo(),Fi(),Gn(),P(),F(),ln(),bn(),kt(),H=t(x()),Qo=(0,Zo.memo)(({agentId:e,onStartCopy:t})=>{let{t:n}=a(`setting`),{allowed:r}=L(`edit_own_content`),i=Zt(),o=Lr(),s=At(e=>e.user?.id),c=I(xn.agentConnectors(e),Xo.default),l=I(e=>e.detachConnectorFromAgent),u=M(e=>e.updateAgentConfigById),d=async t=>{await xt({content:n(`settingAgent.agentTools.removeOwnedConfirm`)})&&(await u(e,{plugins:p(N.getAgentConfigById(e)(M.getState())?.plugins,t.identifier,`auto`)}),await l(t.id,e,`delete`))},f=[{icon:(0,H.jsx)(O,{icon:Be}),key:`connectNew`,label:(0,H.jsxs)(k,{children:[(0,H.jsx)(E,{children:n(`settingAgent.agentTools.connectNew.title`)}),(0,H.jsx)(E,{style:{fontSize:12},type:`secondary`,children:n(`settingAgent.agentTools.connectNew.desc`)})]}),onClick:()=>Jo(e)},{icon:(0,H.jsx)(O,{icon:ze}),key:`copy`,label:(0,H.jsxs)(k,{children:[(0,H.jsx)(E,{children:n(`settingAgent.agentTools.copy.title`)}),(0,H.jsx)(E,{style:{fontSize:12},type:`secondary`,children:n(`settingAgent.agentTools.copy.desc`)})]}),onClick:t}];return(0,H.jsxs)(k,{gap:8,children:[(0,H.jsxs)(E,{style:{fontSize:12,fontWeight:500},type:`secondary`,children:[n(`settingAgent.agentTools.tabAgent`),` · `,c.length]}),(0,H.jsxs)(k,{horizontal:!0,align:`center`,gap:8,wrap:`wrap`,children:[(0,H.jsx)(he,{disabled:!r,menu:{items:f},placement:`bottomLeft`,trigger:[`click`],children:(0,H.jsx)(bt,{icon:(0,H.jsx)(O,{icon:Me}),size:`small`,type:`text`,children:n(`settingAgent.agentTools.add`)})}),c.length===0&&(0,H.jsx)(E,{style:{fontSize:12},type:`secondary`,children:n(`settingAgent.agentTools.agentEmpty`)}),c.map(t=>{let n=!i||!t.userId||t.userId===s||o;return(0,H.jsx)(Oi,{agentId:e,disabled:!r,pluginId:t.identifier,removable:n,showAuthor:!!i,onRemove:()=>{d(t)}},t.id)})]})]})}),Qo.displayName=`AgentToolsSection`})),es,ts,ns,rs,is=e((()=>{h(),A(),Ct(),es=t(m()),ts=t(w()),r(),Qt(),Pi(),Fi(),Mi(),P(),F(),ln(),pn(),bn(),ns=t(x()),rs=(0,ts.memo)(({agentId:e,copyMode:t,copying:n,onCancelCopy:r,onConfirmCopy:i,selected:o,toggleSelected:s,...c})=>{let{t:l}=a(`setting`),u=I(xn.connectorList,es.default),d=M(N.getAgentConfigById(e),es.default),f=d?.chatConfig?.skillActivateMode===`manual`,p=I(xn.agentConnectors(e),es.default),m=(0,ts.useMemo)(()=>new Set(p.map(e=>e.identifier)),[p]),h=I(fn.nonProfileConfigurableBuiltinToolIds({isManualMode:f}),es.default),g=(0,ts.useMemo)(()=>new Set(h),[h]),v=Ii(_(d?.plugins),{agentConnectorIdentifiers:m,nonConfigurableBuiltinToolIdentifiers:g}).length,y=Zt(),b=l(y?`settingAgent.agentTools.tabWorkspace`:`settingAgent.agentTools.tabUser`),x=u.filter(e=>!e.agentId&&!e.metadata?.mountedByAgentId);return t?(0,ns.jsxs)(k,{gap:8,children:[(0,ns.jsxs)(k,{horizontal:!0,align:`center`,justify:`space-between`,children:[(0,ns.jsx)(E,{style:{fontSize:12},type:`secondary`,children:l(`settingAgent.agentTools.copyPick`)}),(0,ns.jsxs)(k,{horizontal:!0,gap:8,children:[(0,ns.jsx)(bt,{disabled:n,size:`small`,type:`text`,onClick:r,children:l(`cancel`,{ns:`common`})}),(0,ns.jsx)(bt,{disabled:o.size===0||n,loading:n,size:`small`,type:`primary`,onClick:i,children:l(`settingAgent.agentTools.copyConfirm`,{count:o.size})})]})]}),(0,ns.jsxs)(k,{horizontal:!0,align:`center`,gap:8,wrap:`wrap`,children:[x.length===0&&(0,ns.jsx)(E,{style:{fontSize:12},type:`secondary`,children:l(`settingAgent.agentTools.pickerEmpty`)}),x.map(e=>(0,ns.jsx)(Oi,{selectable:!0,pluginId:e.identifier,selected:o.has(e.id),onSelect:()=>s(e.id)},e.id))]})]}):(0,ns.jsxs)(k,{gap:8,children:[(0,ns.jsxs)(E,{style:{fontSize:12,fontWeight:500},type:`secondary`,children:[b,` · `,v]}
36),(0,ns.jsx)(Ri,{...c,excludeAgentConnectors:!0,agentId:e,showAuthor:!!y})]})}),rs.displayName=`UserToolsSection`})),as,os,ss,cs,ls=e((()=>{h(),A(),as=t(m()),os=t(w()),P(),F(),ln(),bn(),$o(),is(),ss=t(x()),cs=(0,os.memo)(e=>{let{agentId:t}=e,n=M(e=>e.activeAgentId),r=t||n||``,i=I(xn.isAgentConnectorsInit(r)),a=I(e=>e.fetchAgentConnectors),o=I(e=>e.copyConnectorToAgent),s=I(xn.connectorList,as.default),c=M(e=>e.updateAgentConfigById);(0,os.useEffect)(()=>{r&&!i&&a(r)},[r,i,a]);let[l,u]=(0,os.useState)(!1),[d,f]=(0,os.useState)(!1),[m,h]=(0,os.useState)(()=>new Set),g=e=>h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),_=()=>{u(!1),h(new Set)},v=async()=>{f(!0);try{let e=[];for(let t of m){let n=s.find(e=>e.id===t);n&&(await o(t,r),e.push(n.identifier))}if(e.length>0){let t=N.getAgentConfigById(r)(M.getState())?.plugins;for(let n of e)t=p(t,n,`pinned`);await c(r,{plugins:t})}_()}finally{f(!1)}};return(0,ss.jsxs)(k,{gap:16,width:`100%`,children:[(0,ss.jsx)(Qo,{agentId:r,onStartCopy:()=>u(!0)}),(0,ss.jsx)(rs,{...e,agentId:r,copyMode:l,copying:d,selected:m,toggleSelected:g,onCancelCopy:_,onConfirmCopy:v})]})}),cs.displayName=`AgentUserTools`})),us,ds,fs=e((()=>{ls(),us=t(x()),ds=()=>(0,us.jsx)(cs,{filterAvailableInWeb:!0,useAllMetaList:!0})})),ps,U,ms,W,hs,gs,_s,vs=e((()=>{sr(),A(),Ct(),Ce(),D(),j(),ps=t(w()),r(),Sr(),Gn(),tn(),U=t(x()),ms=`CLAUDE_CODE_OAUTH_TOKEN`,W=le(({css:e})=>({card:e` 37 padding-block: 16px 12px; 38 padding-inline: 16px; 39 border: 1px solid ${T.colorBorderSecondary}; 40 border-radius: ${T.borderRadiusLG}; 41 42 background: ${T.colorBgContainer}; 43 `,credOption:e` 44 display: flex; 45 gap: 8px; 46 align-items: center; 47 `,manageLink:e` 48 cursor: pointer; 49 font-size: 12px; 50 color: ${T.colorPrimary}; 51 52 &:hover { 53 text-decoration: underline; 54 } 55 `,repoItem:e` 56 cursor: pointer; 57 58 display: flex; 59 gap: 8px; 60 align-items: center; 61 62 min-height: 36px; 63 padding-block: 6px; 64 padding-inline: 8px; 65 border-radius: ${T.borderRadiusSM}; 66 67 transition: background 0.15s; 68 69 &:hover { 70 background: ${T.colorFillTertiary}; 71 72 .repo-delete-btn { 73 opacity: 1; 74 } 75 } 76 `,repoItemActive:e` 77 background: ${T.colorFillSecondary}; 78 `,repoDeleteBtn:e` 79 cursor: pointer; 80 81 flex-shrink: 0; 82 83 margin-inline-start: auto; 84 padding: 2px; 85 border: none; 86 border-radius: 4px; 87 88 color: ${T.colorTextTertiary}; 89 90 opacity: 0; 91 background: transparent; 92 93 transition: 94 opacity 0.15s, 95 color 0.15s; 96 97 &:hover { 98 color: ${T.colorError}; 99 } 100 `,repoList:e` 101 display: flex; 102 flex-direction: column; 103 gap: 2px; 104 `,sectionDesc:e` 105 font-size: 12px; 106 color: ${T.colorTextSecondary}; 107 `,sectionDivider:e` 108 margin-block: 12px; 109 border-block-start: 1px solid ${T.colorBorderSecondary}; 110 `,sectionLabel:e` 111 font-size: 12px; 112 color: ${T.colorTextTertiary}; 113 text-transform: uppercase; 114 letter-spacing: 0.04em; 115 `})),hs=(0,ps.memo)(({existingCred:e,onSaved:t,onEnvChange:n})=>{let{t:r}=a(`setting`),{allowed:i}=L(`edit_own_content`),[o,s]=(0,ps.useState)(!e),[c,l]=(0,ps.useState)(``),[u,d]=(0,ps.useState)(!1),f=async()=>{if(!i)return;let e=c.trim();if(e){d(!0);try{await nn.market.creds.createKV.mutate({key:ms,name:`Claude Code OAuth Token`,type:`kv-env`,values:{[ms]:e}}),n({CLAUDE_CODE_CRED_KEY:ms}),l(``),s(!1),t()}finally{d(!1)}}};return(0,U.jsxs)(k,{gap:8,children:[(0,U.jsxs)(k,{horizontal:!0,align:`center`,justify:`space-between`,children:[(0,U.jsxs)(k,{horizontal:!0,align:`center`,gap:6,children:[(0,U.jsx)(Re,{size:12}),(0,U.jsx)(`span`,{className:W.sectionLabel,children:r(`heterogeneousStatus.cloud.tokenLabel`)})]}),e&&!o&&(0,U.jsx)(`span`,{className:W.manageLink,onClick:()=>{i&&s(!0)},children:r(`heterogeneousStatus.cloud.tokenChange`)})]}),e&&!o?(0,U.jsx)(k,{horizontal:!0,align:`center`,gap:8,children:(0,U.jsx)(be,{color:`success`,icon:(0,U.jsx)(Je,{size:11}),style:{display:`flex`,alignItems:`center`,gap:4},children:e.maskedPreview??e.name})}):(0,U.jsxs)(k,{horizontal:!0,gap:8,children:[(0,U.jsx)(Se.Password,{autoComplete:`new-password`,autoFocus:!!e,disabled:!i,placeholder:r(`heterogeneousStatus.cloud.tokenPlaceholder`),style:{flex:1},value:c,onChange:e=>l(e.target.value),onPressEnter:f}),(0,U.jsx)(bt,{disabled:!i,loading:u,type:`primary`,onClick:f,children:r(`heterogeneousStatus.cloud.tokenSave`)}),e&&(0,U.jsx)(bt,{onClick:()=>{s(!1),l(``)},children:r(`heterogeneousStatus.cloud.tokenCancel`)})]}),(0,U.jsx)(`span`,{className:W.sectionDesc,children:r(`heterogeneousStatus.cloud.tokenDesc`)})]})}),gs=(0,ps.memo)(({repos:e,onReposChange:t})=>{let{t:n}=a(`setting`),{allowed:r}=L(`edit_own_content`),[i,o]=(0,ps.useState)(``),s=()=>
115{if(!r)return;let n=i.trim();!n||e.includes(n)||(t([...e,n]),o(``))},c=(n,i)=>{i.stopPropagation(),r&&t(e.filter(e=>e!==n))};return(0,U.jsxs)(k,{gap:8,children:[(0,U.jsx)(`span`,{className:W.sectionLabel,children:n(`heterogeneousStatus.cloud.repoLabel`)}),e.length>0&&(0,U.jsx)(`div`,{className:W.repoList,children:e.map(e=>(0,U.jsxs)(`div`,{className:W.repoItem,children:[(0,U.jsx)(pr,{size:14,style:{flexShrink:0}}),(0,U.jsx)(we.Text,{ellipsis:!0,style:{flex:1,fontSize:13},children:e}),(0,U.jsx)(`button`,{className:`${W.repoDeleteBtn} repo-delete-btn`,disabled:!r,onClick:t=>c(e,t),children:(0,U.jsx)(mt,{size:12})})]},e))}),(0,U.jsxs)(k,{horizontal:!0,gap:8,children:[(0,U.jsx)(Se,{disabled:!r,placeholder:n(`heterogeneousStatus.cloud.repoPlaceholder`),style:{flex:1},value:i,onChange:e=>o(e.target.value),onPressEnter:s}),(0,U.jsx)(bt,{disabled:!r,onClick:s,children:n(`heterogeneousStatus.cloud.repoAdd`)})]}),(0,U.jsx)(`span`,{className:W.sectionDesc,children:n(`heterogeneousStatus.cloud.repoDesc`)})]})}),_s=(0,ps.memo)(({provider:e,onEnvChange:t})=>{let{t:n}=a(`setting`),r=xr(),{allowed:i}=L(`edit_own_content`),o=e.env??{},s=o.GITHUB_CRED_KEY??``,c=(()=>{try{return JSON.parse(o.GITHUB_REPOS??`[]`)}catch{return[]}})(),{data:l,isLoading:u,refetch:d}=$t.market.creds.list.useQuery(void 0),f=l?.data??[],p=f.find(e=>e.key===ms),m=f.filter(e=>e.type===`oauth`&&e.oauthProvider?.toLowerCase().includes(`github`)).map(e=>({label:(0,U.jsxs)(`span`,{className:W.credOption,children:[e.oauthAvatar?(0,U.jsx)(xe,{size:16,src:e.oauthAvatar}):(0,U.jsx)(pr,{size:14}),(0,U.jsx)(`span`,{children:e.name}),e.oauthUsername&&(0,U.jsxs)(we.Text,{style:{fontSize:12},type:`secondary`,children:[`@`,e.oauthUsername]})]}),title:[e.name,e.oauthUsername].filter(Boolean).join(` `),value:e.key})),h=e=>{i&&t({...o,...e})};return u?(0,U.jsx)(k,{align:`center`,justify:`center`,style:{paddingBlock:32},children:(0,U.jsx)(Te,{size:`small`})}):(0,U.jsx)(`div`,{className:W.card,children:(0,U.jsxs)(k,{gap:16,children:[(0,U.jsx)(hs,{existingCred:p,onEnvChange:h,onSaved:()=>d()}),(0,U.jsx)(`div`,{className:W.sectionDivider}),(0,U.jsxs)(k,{gap:8,children:[(0,U.jsxs)(k,{horizontal:!0,align:`center`,justify:`space-between`,children:[(0,U.jsxs)(k,{horizontal:!0,align:`center`,gap:6,children:[(0,U.jsx)(pr,{size:12}),(0,U.jsx)(`span`,{className:W.sectionLabel,children:n(`heterogeneousStatus.cloud.githubLabel`)})]}),(0,U.jsx)(`span`,{className:W.manageLink,onClick:()=>r(`/settings/credential`),children:n(`heterogeneousStatus.cloud.manageCredentials`)})]}),(0,U.jsx)(St,{allowClear:!0,disabled:!i,options:m,style:{width:`100%`},value:s||null,placeholder:m.length>0?n(`heterogeneousStatus.cloud.githubPlaceholder`):n(`heterogeneousStatus.cloud.githubNoCreds`),onChange:e=>h({GITHUB_CRED_KEY:typeof e==`string`?e:``})}),(0,U.jsx)(`span`,{className:W.sectionDesc,children:n(`heterogeneousStatus.cloud.githubDesc`)})]}),(0,U.jsx)(`div`,{className:W.sectionDivider}),(0,U.jsx)(gs,{repos:c,onReposChange:e=>{h({GITHUB_REPOS:JSON.stringify(e)})}})]})})})})),G,K,ys,q,bs,xs=e((()=>{C(),Cr(),A(),D(),j(),G=t(w()),r(),jn(),Sr(),Gn(),Si(),K=t(x()),ys=28,q=le(({css:e})=>({card:e` 116 padding-block: 16px 4px; 117 padding-inline: 16px; 118 border: 1px solid ${T.colorBorderSecondary}; 119 border-radius: ${T.borderRadiusLG}; 120 121 background: ${T.colorBgContainer}; 122 `,cardHeader:e` 123 display: flex; 124 gap: 12px; 125 align-items: flex-start; 126 justify-content: space-between; 127 `,cardTitleWrap:e` 128 display: flex; 129 flex: 1; 130 flex-direction: column; 131 gap: 8px; 132 133 min-width: 0; 134 `,cardTitle:e` 135 display: flex; 136 gap: 8px; 137 align-items: center; 138 `,metaRow:e` 139 display: flex; 140 flex-wrap: wrap; 141 gap: 8px; 142 align-items: center; 143 144 min-width: 0; 145 `,metaText:e` 146 font-size: 13px; 147 color: ${T.colorTextSecondary}; 148 `,pathWrap:e` 149 display: flex; 150 gap: 4px; 151 align-items: center; 152 153 min-width: 0; 154 max-width: 100%; 155 `,detailList:e` 156 margin-block-start: 4px; 157 border-block-start: 1px solid ${T.colorBorderSecondary}; 158 `,detailRow:e` 159 display: flex; 160 gap: 16px; 161 align-items: center; 162 163 min-height: 48px; 164 padding-block: 8px; 165 166 & + & { 167 border-block-start: 1px solid ${T.colorBorderSecondary}; 168 } 169 `,detailLabel:e` 170 flex-shrink: 0; 171 172 width: 96px; 173 174 font-size: 12px; 175 color: ${T.colorTextTertiary}; 176 text-transform: uppercase; 177 letter-spacing: 0.04em; 178 `,detailContent:e` 179 display: flex; 180 flex: 1; 181 flex-wrap: wrap; 182 gap: 8px; 183 align-items: center; 184 185 min-width: 0; 186 height: ${ys}px; 187 `,commandField:e` 188 &:hover .command-edit-button { 189 pointer-events: auto; 190 opacity: 1; 191 } 192 `,commandInput:e` 193 width: 100%; 194 font-family: ${T.fontFamilyCode}; 195 196 &, 197 &.ant-input, 198 &.ant-input-affix-wrapper, 199 &.ant-input-outlined, 200 & input, 201 & .ant-input, 202 & .ant-input-affix-wrapper, 203 & .ant-input-outlined { 204 box-sizing: border-box; 205 height: ${ys}px; 206 min-height: ${ys}px; 207 max-height: ${ys}px; 208 border-radius: 999px !important; 209 210 font-family: ${T.fontFamilyCode}; 211 font-size: 14px; 212 line-height: ${ys-2}px; 213 } 214 215 &, 216 &.ant-input, 217 &.ant-input-outlined, 218 & input, 219 & .ant-input, 220 & .ant-input-outlined { 221 padding-block: 0; 222 padding-inline: 12px; 223 } 224 225 &.ant-input-affix-wrapper, 226 & .ant-input-affix-wrapper { 227 overflow: hidden; 228 padding-block: 0; 229 padding-inline: 12px; 230 } 231 232 &.ant-input-affix-wrapper input, 233 & .ant-input-affix-wrapper input { 234 height: ${ys-2}px; 235 padding: 0; 236 border-radius: 999px !important; 237 line-height: ${ys-2}px; 238 } 239 `,commandInputWrap:e` 240 display: flex; 241 align-items: center; 242 243 width: min(320px, 100%); 244 max-width: 100%; 245 height: ${ys}px; 246 `,commandDisplay:e` 247 display: inline-flex; 248 align-items: center; 249 250 box-sizing: border-box; 251 max-width: 100%; 252 height: ${ys}px; 253 padding-block: 0; 254 padding-inline: 12px; 255 border: 1px solid ${T.colorBorderSecondary}; 256 border-radius: 999px; 257 258 background: ${T.colorFillSecondary}; 259 `,commandEditButton:e` 260 pointer-events: none; 261 opacity: 0; 262 transition: opacity 0.2s ease; 263 `,commandText:e` 264 min-width: 0; 265 266 font-family: ${T.fontFamilyCode}; 267 font-size: 14px; 268 line-height: 20px; 269 color: ${T.colorText}; 270 `,accountValue:e` 271 font-size: 15px; 272 color: ${T.colorText}; 273 `,path:e` 274 font-family: ${T.fontFamilyCode}; 275 font-size: 12px; 276 color: ${T.colorTextTertiary}; 277 `,unavailableText:e` 278 font-size: 13px; 279 color: ${T.colorTextSecondary}; 280 `})),bs=(0,G.memo)(({provider:e,onCommandChange:t})=>{let{t:n}=a(`setting`),r=xr(),{allowed:i}=L(`edit_own_content`),o=wr(e.type),s=o?.command||``,c=e.command?.trim()||s,l=c!==s,[u,d]=(0,G.useState)(),[f,p]=(0,G.useState)(null),[m,h]=(0,G.useState)(c),[g,_]=(0,G.useState)(!0),[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(!1),S=(0,G.useRef)(null),ee=o?.title||e.type,te=o?.icon,ne=(e.type===`amp`||e.type===`claude-code`||e.type===`codex`||e.type===`opencode`)&&!g&&!u?.available&&!l,re=(0,G.useCallback)(async()=>
280{if(e.type!==`claude-code`){p(null);return}try{p(await Ci.getClaudeAuthStatus(c))}catch(e){console.warn(`[HeterogeneousAgentStatusCard] Failed to get Claude auth status:`,e),p(null)}},[e.type,c]),C=(0,G.useCallback)(async()=>{if(gn(e.type)||!0){_(!1);return}_(!0);try{let t=await Ci.detectHeterogeneousAgentCommand({agentType:e.type,command:c});d(t),t.available?re():p(null)}catch(e){console.error(`[HeterogeneousAgentStatusCard] Failed to detect CLI:`,e),d({available:!1,error:e.message}),p(null)}finally{_(!1)}},[re,e.type,c]);(0,G.useEffect)(()=>{C()},[C]),(0,G.useEffect)(()=>{h(c)},[c]),(0,G.useEffect)(()=>{if(!v)return;let e=window.setTimeout(()=>{S.current?.focus(),S.current?.select()},0);return()=>{window.clearTimeout(e)}},[v]);let ie=(0,G.useCallback)(()=>{i&&(b||(h(c),y(!0)))},[i,c,b]),w=(0,G.useCallback)(()=>{h(c),y(!1)},[c]),ae=(0,G.useCallback)(async()=>{if(!i)return;let e=m.trim()||s;if(h(e),!e||e===c||b){y(!1);return}try{x(!0),await t?.(e),y(!1)}finally{x(!1)}},[i,m,s,t,c,b]);return(0,K.jsxs)(k,{className:q.card,gap:12,children:[(0,K.jsxs)(`div`,{className:q.cardHeader,children:[(0,K.jsxs)(`div`,{className:q.cardTitleWrap,children:[(0,K.jsxs)(`div`,{className:q.cardTitle,children:[te&&(0,K.jsx)(te,{size:16}),(0,K.jsx)(E,{strong:!0,children:`${ee} CLI`})]}),(0,K.jsxs)(`div`,{className:q.metaRow,children:[g?(0,K.jsx)(ge,{color:`default`,style:{marginInlineEnd:0},children:n(`settingSystemTools.detecting`)}):!u||!u.available?(0,K.jsx)(ge,{color:`error`,style:{marginInlineEnd:0},children:n(`settingSystemTools.status.unavailable`)}):(0,K.jsx)(ge,{color:`success`,style:{marginInlineEnd:0},children:n(`settingSystemTools.status.available`)}),g?(0,K.jsxs)(k,{horizontal:!0,align:`center`,gap:8,children:[(0,K.jsx)(O,{spin:!0,icon:Ve,size:16,style:{opacity:.6}}),(0,K.jsx)(E,{className:q.metaText,children:n(`heterogeneousStatus.detecting`,{name:ee})})]}):!u||!u.available?(0,K.jsxs)(k,{horizontal:!0,align:`center`,gap:8,style:{flexWrap:`wrap`},children:[(0,K.jsx)(O,{color:`var(--ant-color-error)`,icon:$e,size:16}),(0,K.jsx)(E,{className:q.unavailableText,children:n(`heterogeneousStatus.unavailable`,{name:ee})})]}):(0,K.jsxs)(k,{horizontal:!0,align:`center`,className:q.metaRow,gap:8,children:[u.version&&(0,K.jsx)(ge,{color:`processing`,style:{marginInlineEnd:0},children:u.version}),u.path&&(0,K.jsx)(ue,{title:u.path,children:(0,K.jsxs)(k,{horizontal:!0,align:`center`,className:q.pathWrap,gap:4,children:[(0,K.jsx)(E,{ellipsis:!0,className:q.path,children:u.path}),(0,K.jsx)(pe,{content:u.path,size:`small`})]})})]})]})]}),(0,K.jsx)(ue,{title:n(`heterogeneousStatus.redetect`),children:(0,K.jsx)(de,{"aria-label":n(`heterogeneousStatus.redetect`),disabled:g,icon:Xe,loading:g,size:`small`,onClick:C})})]}),(0,K.jsxs)(`div`,{className:q.detailList,children:[(0,K.jsxs)(`div`,{className:`${q.detailRow} ${q.commandField}`,children:[(0,K.jsx)(E,{className:q.detailLabel,children:n(`heterogeneousStatus.command.label`)}),(0,K.jsxs)(`div`,{className:q.detailContent,children:[v?(0,K.jsx)(`div`,{className:q.commandInputWrap,children:(0,K.jsx)(_e,{className:q.commandInput,disabled:!i||b,placeholder:n(`heterogeneousStatus.command.placeholder`),ref:S,value:m,onBlur:()=>{ae()},onChange:e=>{h(e.target.value)},onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),w();return}e.key===`Enter`&&(e.preventDefault(),ae())}})}):(0,K.jsx)(`div`,{className:q.commandDisplay,children:(0,K.jsx)(E,{ellipsis:!0,className:q.commandText,children:c})}),!v&&!b&&(0,K.jsx)(ue,{title:n(`heterogeneousStatus.command.edit`),children:(0,K.jsx)(de,{"aria-label":n(`heterogeneousStatus.command.edit`),className:`command-edit-button ${q.commandEditButton}`,disabled:!i,icon:pt,size:`small`,onClick:ie})})]})]}),(()=>{if(e.type!==`claude-code`||g||!u?.available||!f?.loggedIn)return null;let t=f.authMethod===`claude.ai`||f.apiProvider===`firstParty`?n(`heterogeneousStatus.auth.subscription`):n(`heterogeneousStatus.auth.api`);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:q.detailRow,children:[(0,K.jsx)(E,{className:q.detailLabel,children:n(`heterogeneousStatus.auth.label`)}),(0,K.jsx)(k,{horizontal:!0,align:`center`,gap:8,style:{flexWrap:`wrap`},children:(0,K.jsx)(E,{className:q.accountValue,children:t})})]}),(0,K.jsxs)(`div`,{className:q.detailRow,children:[(0,K.jsx)(E,{className:q.detailLabel,children:n(`heterogeneousStatus.account.label`)}),(0,K.jsx)(k,{horizontal:!0,align:`center`,gap:8,style:{flexWrap:`wrap`},children:f.email&&(0,K.jsx)(E,{ellipsis:!0,className:q.accountValue,children:f.email})})]}),f.subscriptionType&&(0,K.jsxs)(`div`,{className:q.detailRow,children:[(0,K.jsx)(E,{className:q.detailLabel,children:n(`heterogeneousStatus.plan.label`)}),(0,K.jsx)(k,{horizontal:!0,align:`center`,gap:8,style:{flexWrap:`wrap`},children:(0,K.jsx)(E,{className:q.accountValue,children:f.subscriptionType.toUpperCase()})})]})]})})()]}),ne&&(0,K.jsx)(An,{agentType:e.type,variant:`embedded`,onOpenSystemTools:()=>r(`/settings/system-tools`)})]})}),bs.displayName=`HeterogeneousAgentStatusCard`})),J,Y,X,Ss,Cs,ws,Ts=e((()=>{un(),A(),Ct(),Ce(),D(),c(),j(),J=t(w()),r(),Dr(),yn(),P(),Y=t(x()),X=le(({css:e})=>({card:e` 281 padding-block: 16px 4px; 282 padding-inline: 16px; 283 border: 1px solid ${T.colorBorderSecondary}; 284 border-radius: ${T.borderRadiusLG}; 285
286 background: ${T.colorBgContainer}; 287 `,cardHeader:e` 288 display: flex; 289 gap: 12px; 290 align-items: center; 291 justify-content: space-between; 292 293 padding-block-end: 12px; 294 `,title:e` 295 font-size: 14px; 296 font-weight: 500; 297 `,detailList:e` 298 border-block-start: 1px solid ${T.colorBorderSecondary}; 299 `,detailRow:e` 300 display: flex; 301 gap: 16px; 302 align-items: center; 303 304 min-height: 44px; 305 padding-block: 6px; 306 307 & + & { 308 border-block-start: 1px solid ${T.colorBorderSecondary}; 309 } 310 `,detailLabel:e` 311 flex-shrink: 0; 312 313 width: 96px; 314 315 font-size: 12px; 316 color: ${T.colorTextTertiary}; 317 text-transform: uppercase; 318 letter-spacing: 0.04em; 319 `,detailContent:e` 320 display: flex; 321 flex: 1; 322 flex-wrap: wrap; 323 gap: 6px; 324 align-items: center; 325 326 min-width: 0; 327 `,deviceItem:e` 328 display: flex; 329 gap: 6px; 330 align-items: center; 331 `})),Ss=(0,J.memo)(({currentDeviceId:e,isWorkspaceAgent:t,onConfirm:n,platform:r})=>{let{t:i}=a(`setting`),{close:o,setCanDismissByClickOutside:s}=Et(),[c,l]=(0,J.useState)(e),[u,d]=(0,J.useState)(void 0),[f,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(!1);(0,J.useEffect)(()=>{s(!m)},[m,s]);let{data:g,isLoading:_}=Or(),v=(g??[]).filter(e=>e.online&&(!t||e.scope===`workspace`&&e.visibility===`public`)),y=(0,J.useCallback)(async e=>{p(!0),d(void 0);try{d(await vn.checkCapability({deviceId:e,platform:r}))}catch{d({available:!1,reason:`Check failed`})}finally{p(!1)}},[r]),b=(0,J.useCallback)(e=>{l(e),y(e)},[y]),x=async()=>{if(c){h(!0);try{await n(c),o()}finally{h(!1)}}},S=u?.available===!0,ee=u?.available===!1;return(0,Y.jsxs)(k,{gap:16,children:[(0,Y.jsxs)(k,{gap:12,paddingBlock:`12px 4px`,children:[(0,Y.jsx)(St,{loading:_,placeholder:i(`platformAgentConfig.selectDevice`),style:{width:`100%`},value:c,options:v.map(e=>({label:(0,Y.jsxs)(`div`,{className:X.deviceItem,children:[(0,Y.jsx)(O,{icon:tt,size:14}),(0,Y.jsx)(`span`,{children:e.hostname}),(0,Y.jsx)(be,{color:`success`,style:{marginInlineEnd:0},children:i(`platformAgentConfig.device.online`)})]}),value:e.deviceId})),onChange:b}),f&&(0,Y.jsx)(be,{style:{marginInlineEnd:0},children:i(`platformAgentConfig.availability.checking`)}),S&&(0,Y.jsxs)(k,{horizontal:!0,align:`center`,gap:4,children:[(0,Y.jsx)(O,{color:`var(--ant-color-success)`,icon:Je,size:14}),(0,Y.jsx)(be,{color:`success`,style:{marginInlineEnd:0},children:u?.version??i(`platformAgentConfig.availability.available`)})]}),ee&&(0,Y.jsxs)(k,{horizontal:!0,align:`center`,gap:4,children:[(0,Y.jsx)(O,{color:`var(--ant-color-error)`,icon:$e,size:14}),(0,Y.jsx)(be,{color:`error`,style:{marginInlineEnd:0},children:i(`platformAgentConfig.availability.notInstalled`)})]})]}),(0,Y.jsxs)(k,{horizontal:!0,gap:8,justify:`flex-end`,children:[(0,Y.jsx)(bt,{disabled:m,onClick:o,children:i(`cancel`,{ns:`common`})}),(0,Y.jsx)(bt,{disabled:!c||f||ee,loading:m,type:`primary`,onClick:x,children:i(`platformAgentConfig.changeDevice`)})]})]})}),Ss.displayName=`ChangeDeviceContent`,Cs=e=>Tt({content:(0,Y.jsx)(Ss,{currentDeviceId:e.currentDeviceId,isWorkspaceAgent:e.isWorkspaceAgent,platform:e.platform,onConfirm:e.onConfirm}),footer:null,maskClosable:!0,title:i(`platformAgentConfig.changeDevice`,{ns:`setting`}),width:400}),ws=(0,J.memo)(({provider:e,onBoundDeviceChange:t})=>{let{t:n}=a(`setting`),r=M(e=>e.activeAgentId),i=M(e=>r?e.agentMap[r]?.agencyConfig?.boundDeviceId:void 0),o=!!M(e=>r?e.agentMap[r]?.workspaceId:void 0),[s,c]=(0,J.useState)(void 0),[l,u]=(0,J.useState)(!1),d=dn[e.type]??e.type,{data:f}=Or(),p=f?.find(e=>e.deviceId===i),m=(0,J.useCallback)(async t=>{u(!0),c(void 0);try{c(await vn.checkCapability({deviceId:t,platform:e.type}))}catch{c({available:!1,reason:`Check failed`})}finally{u(!1)}},[e.type]);(0,J.useEffect)(()=>{i&&p?.online&&m(i)},[i,p?.online,m]);let h=(0,J.useCallback)(()=>{Cs({currentDeviceId:i,isWorkspaceAgent:o,onConfirm:async e=>{await t?.(e)},platform:e.type})},[i,o,t,e.type]);return(0,Y.jsxs)(k,{className:X.card,gap:0,children:[(0,Y.jsxs)(`div`,{className:X.cardHeader,children:[(0,Y.jsxs)(k,{horizontal:!0,align:`center`,gap:8,children:[(0,Y.jsx)(O,{icon:Oe,size:16}),(0,Y.jsx)(E,{strong:!0,className:X.title,children:n(`platformAgentConfig.title`)})]}),(0,Y.jsx)(ue,{title:n(`platformAgentConfig.redetect`),children:(0,Y.jsx)(de,{"aria-label":n(`platformAgentConfig.redetect`),disabled:!i||l,icon:Xe,loading:l,size:`small`,onClick:()=>i&&void m(i)})})]}),(0,Y.jsxs)(`div`,{className:X.detailList,children:[(0,Y.jsxs)(`div`,{className:X.detailRow,children:[(0,Y.jsx)(E,{className:X.detailLabel,children:n(`platformAgentConfig.platform.label`)}),(0,Y.jsx)(`div`,{className:X.detailContent,children:(0,Y.jsx)(be,{style:{marginInlineEnd:0},children:d})})]}),(0,Y.jsxs)(`div`,{className:X.detailRow,children:[(0,Y.jsx)(E,{className:X.detailLabel,children:n(`platformAgentConfig.device.label`)}),(0,Y.jsx)(`div`,{className:X.detailContent,children:p?(0,Y.jsxs)(k,{horizontal:!0,align:`center`,gap:6,children:[(0,Y.jsx)(E,{ellipsis:!0,style:{fontSize:14},children:p.hostname}),(0,Y.jsx)(be,{color:p.online?`success`:`default`,style:{marginInlineEnd:0},children:p.online?n(`platformAgentConfig.device.online`):n(`platformAgentConfig.device.offline`)})]}):(0,Y.jsx)(be,{style:{marginInlineEnd:0},children:n(`platformAgentConfig.device.none`)})})]}),(0,Y.jsxs)(`div`,{className:X.detailRow,children:[(0,Y.jsx)(E,{className:X.detailLabel,children:n(`platformAgentConfig.availability.label`)}),(0,Y.jsx)(`div`,{className:X.detailContent,children:i?p?.online?l?(0,Y.jsx)(be,{style:{marginInlineEnd:0},children:n(`platformAgentConfig.availability.checking`)}):s?s.available?(0,Y.jsxs)(k,{horizontal:!0,align:`center`,gap:4,children:[(0,Y.jsx)(O,{color:`var(--ant-color-success)`,icon:Je,size:14}),(0,Y.jsx)(be,{color:`success`,style:{marginInlineEnd:0},children:s.version??n(`platformAgentConfig.availability.available`)})]}):(0,Y.jsxs)(k,{horizontal:!0,align:`center`,gap:4,children:[(0,Y.jsx)(O,{color:`var(--ant-color-error)`,icon:$e,size:14}),(0,Y.jsx)(be,{color:`error`,style:{marginInlineEnd:0},children:n(`platformAgentConfig.availability.notInstalled`)})]}):null:(0,Y.jsx)(be,{color:`warning`,style:{marginInlineEnd:0},children:n(`platformAgentConfig.device.offline`)}):(0,Y.jsx)(be,{style:{marginInlineEnd:0},children:n(`platformAgentConfig.availability.noDevice`)})})]}),(0,Y.jsxs)(`div`,{className:X.detailRow,children:[(0,Y.jsx)(`div`,{className:X.detailLabel}),(0,Y.jsx)(`div`,{className:X.detailContent,children:(0,Y.jsx)(bt,{size:`small`,onClick:h,children:n(`platformAgentConfig.changeDevice`)})})]})]})]})}),ws.displayName=`RemoteAgentConfigCard`})),Es,Ds,Os,ks,As,js=e((()=>{A(),Ct(),D(),j(),Es=t(w()),Ds=t(x()),Os=le(({css:e})=>({card:e`
332 align-self: flex-start; 333 334 width: calc(50% - 4px); 335 padding: 16px; 336 border: 1px solid ${T.colorBorderSecondary}; 337 border-radius: ${T.borderRadiusLG}; 338 339 background: ${T.colorBgContainer}; 340 341 @container (max-width: 840px) { 342 width: 100%; 343 } 344 `,fullWidth:e` 345 width: 100%; 346 `,policyButton:e` 347 color: ${T.colorTextSecondary}; 348 `,title:e` 349 font-size: 14px; 350 font-weight: 500; 351 `})),ks=(0,Es.memo)(({disabled:e,locked:t,lockedDisabled:n,lockedLabel:r,onChange:i,unlockedLabel:a})=>{let[o,s]=(0,Es.useState)(!1),c=t?r:a;return(0,Ds.jsx)(ce,{items:[{extra:t?void 0:(0,Ds.jsx)(O,{icon:Pe,size:14}),icon:Fe,key:`member`,label:a,onClick:()=>{t&&i(!1)}},{disabled:n,extra:t?(0,Ds.jsx)(O,{icon:Pe,size:14}):void 0,icon:Ze,key:`fixed`,label:r,onClick:()=>{t||i(!0)}}],open:o,placement:`bottomRight`,popupProps:{style:{minWidth:180}},onOpenChange:s,children:(0,Ds.jsx)(ue,{disabled:o,title:c,children:(0,Ds.jsx)(bt,{"aria-label":c,className:Os.policyButton,disabled:e,icon:t?Ze:Fe,size:`small`,type:`text`,children:(0,Ds.jsx)(O,{"aria-hidden":!0,icon:Qe,size:12})})})})}),ks.displayName=`WorkspaceAgentSelectionPolicyMenu`,As=(0,Es.memo)(({action:e,children:t,fullWidth:n,icon:r,title:i})=>(0,Ds.jsxs)(k,{className:oe(Os.card,n&&Os.fullWidth),gap:12,children:[(0,Ds.jsxs)(k,{horizontal:!0,align:`center`,justify:`space-between`,children:[(0,Ds.jsxs)(k,{horizontal:!0,align:`center`,gap:8,children:[(0,Ds.jsx)(O,{icon:r,size:16}),(0,Ds.jsx)(E,{className:Os.title,children:i})]}),e]}),t]})),As.displayName=`WorkspaceAgentPolicyCard`})),Ms,Ns=e((()=>{Ms=e=>e?{locked:`settingAgent.selectionPolicy.membersCannotSwitchWhenShared`,unlocked:`settingAgent.selectionPolicy.membersCanSwitchWhenShared`}:{locked:`settingAgent.selectionPolicy.membersCannotSwitch`,unlocked:`settingAgent.selectionPolicy.membersCanSwitch`}})),Ps,Z,Fs,Is,Ls,Rs=e((()=>{un(),A(),Ct(),D(),j(),Ps=t(w()),r(),Kr(),Dr(),Mn(),It(),P(),js(),Ns(),Z=t(x()),Fs=le(({css:e})=>({option:e` 352 display: flex; 353 flex: 1; 354 gap: 8px; 355 align-items: center; 356 357 min-width: 0; 358 `,optionDescription:e` 359 font-size: 12px; 360 line-height: 16px; 361 color: ${T.colorTextDescription}; 362 `,optionIcon:e` 363 display: flex; 364 flex: none; 365 align-items: center; 366 justify-content: center; 367 368 width: 24px; 369 height: 24px; 370 border: 1px solid ${T.colorBorderSecondary}; 371 border-radius: ${T.borderRadius}; 372 373 color: ${T.colorText}; 374 375 background: ${T.colorBgElevated}; 376 `,optionName:e` 377 overflow: hidden; 378 379 font-size: 14px; 380 font-weight: 500; 381 line-height: 20px; 382 color: ${T.colorText}; 383 text-overflow: ellipsis; 384 white-space: nowrap; 385 `,selectItem:e` 386 min-height: 40px; 387 `,selectPopup:e` 388 max-width: calc(100vw - 24px); 389 `,selectValue:e` 390 > span { 391 display: flex; 392 flex: 1; 393 min-width: 0; 394 } 395 `,triggerIcon:e` 396 display: flex; 397 flex: none; 398 align-items: center; 399 justify-content: center; 400 401 width: 20px; 402 height: 20px; 403 404 color: ${T.colorTextSecondary}; 405 `,triggerLabel:e` 406 display: flex; 407 flex: 1; 408 gap: 8px; 409 align-items: center; 410 411 min-width: 0; 412 `,triggerName:e` 413 overflow: hidden; 414 flex: 1; 415 416 text-align: start; 417 text-overflow: ellipsis; 418 white-space: nowrap; 419 `})),Is=(0,Ps.memo)(({compact:e,description:t,device:n,label:r,offlineLabel:i,onlineLabel:a,target:o})=>{let s=(0,Z.jsx)(Vn,{devicePlatform:n?.platform,target:o}),c=n?(0,Z.jsx)(Rn,{offlineLabel:i,online:n.online,onlineLabel:a}):t;return e?(0,Z.jsxs)(`span`,{className:Fs.triggerLabel,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:Fs.triggerIcon,children:s}),(0,Z.jsx)(`span`,{className:Fs.triggerName,children:r}),n?(0,Z.jsx)(`span`,{className:Fs.optionDescription,children:c}):null]}):(0,Z.jsxs)(`span`,{className:Fs.option,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:Fs.optionIcon,children:s}),(0,Z.jsxs)(k,{flex:1,style:{minWidth:0},children:[(0,Z.jsx)(`span`,{className:Fs.optionName,children:r}),(0,Z.jsx)(`span`,{className:Fs.optionDescription,children:c})]})]})}),Is.displayName=`WorkspaceAgentDevicePolicy.ExecutionTargetLabel`,Ls=(0,Ps.memo)(({agentId:e,showDevicePicker:t=!0})=>{let{t:n}=a([`setting`,`chat`]),r=M(t=>t.agentMap[e]),i=M(e=>e.updateAgentConfigById),{data:o,error:s,isLoading:c,mutate:l}=Or(),{publicWorkspace:u}=(0,Ps.useMemo)(()=>Bn(o),[o]),d=r?.agencyConfig,f=d?.heterogeneousProvider?.type,p=!!f,m=Bt(f),h=u.find(e=>e.deviceId===d?.boundDeviceId),g=d?.executionTargetSelectionPolicy===`fixed`,_=(0,Ps.useMemo)(()=>({auto:{description:n(`chat:heteroAgent.executionTarget.autoDesc`),label:n(`chat:heteroAgent.executionTarget.auto`)},none:{description:n(`chat:heteroAgent.executionTarget.noneDesc`),label:n(`chat:heteroAgent.executionTarget.none`)},sandbox:{description:n(m?`chat:heteroAgent.executionTarget.sandboxDesc`:`chat:heteroAgent.executionTarget.sandboxUnsupported`,{name:f?dn[f]:void 0}),label:n(`chat:heteroAgent.executionTarget.sandbox`)}}),[f,m,n]),v=(0,Ps.useCallback)((e,t=!1)=>(0,Z.jsx)(Is,{compact:t,description:_[e].description,label:_[e].label,offlineLabel:n(`chat:heteroAgent.executionTarget.offline`),onlineLabel:n(`chat:heteroAgent.executionTarget.online`),target:e}),[n,_]),y=(0,Ps.useCallback)((e,t=!1)=>(0,Z.jsx)(Is,{compact:t,description:``,device:e,label:e.friendlyName||e.hostname||e.deviceId,offlineLabel:n(`chat:heteroAgent.executionTarget.offline`),onlineLabel:n(`chat:heteroAgent.executionTarget.online`),target:`device`}),[n]),b=(0,Ps.useMemo)(()=>{let e=[...p?[]:[{label:v(`none`),title:_.none.label,value:Fn(`none`)},{label:v(`auto`),title:_.auto.label,value:Fn(`auto`)}],{disabled:!m,label:v(`sandbox`),title:_.sandbox.label,value:Fn(`sandbox`)}],t=c?[{disabled:!0,label:n(`chat:heteroAgent.executionTarget.loading`),value:`status:loading`}]:u.length>0?u.map(e=>({label:y(e),title:e.friendlyName||e.hostname||e.deviceId,value:Fn(`device`,e.deviceId)})):[{disabled:!0,label:n(`settingAgent.devicePolicy.noPublicDevice`),value:`status:empty`}];return[...e,...s?[]:[{label:n(`chat:heteroAgent.executionTarget.workspaceGroup`),options:t}]]},[s,c,p,u,y,v,m,n,_]),x=d?.executionTarget,S=x===`device`&&h?{deviceId:h.deviceId,target:`device`}:kn(x)&&x!==`device`?{target:x}:x===void 0&&!p?{target:`none`}:void 0,ee=S?Fn(S.target,S.deviceId):void 0,te=!!S&&(S.target!==`sandbox`||m),ne=Ms(r?.visibility===`private`),re=(0,Ps.useCallback)(t=>i(e,{agencyConfig:t}),[e,i]);return r?.workspaceId?(0,Z.jsxs)(As,{icon:Oe,title:n(`settingAgent.devicePolicy.title`),action:(0,Z.jsx)(ks,{locked:g,lockedDisabled:!g&&!te,lockedLabel:n(ne.locked),unlockedLabel:n(ne.unlocked),onChange:e=>{if(!e){re({executionTargetSelectionPolicy:`member`});return}S&&re({...S.deviceId?{boundDeviceId:S.deviceId}:{},executionTarget:S.target,executionTargetSelectionPolicy:`fixed`})}}),children:[t?(0,Z.jsx)(St,{optionRender:e=>e.label,options:b,placeholder:n(`settingAgent.devicePolicy.selectTarget`),popupMatchSelectWidth:!0,value:ee,classNames:{item:Fs.selectItem,popup:Fs.selectPopup,value:Fs.selectValue},labelRender:e=>{if(typeof e.value!=`string`)return e.label;let t=zn(e.value);if(!t)return e.label;if(t.target===`device`){let n=u.find(e=>e.deviceId===t.deviceId);return n?y(n,!0):e.label}return t.target===`local`?e.label:v(t.target,!0)},onChange:e=>{if(typeof e!=`string`)return;let t=zn(e);t&&re({...t.deviceId?{boundDeviceId:t.deviceId}:{},executionTarget:t.target})}}
419):null,s?(0,Z.jsx)(qr,{error:s,variant:`inline`,onRetry:()=>void l()}):null]}):null}),Ls.displayName=`WorkspaceAgentDevicePolicy`})),zs,Bs,Vs,Hs,Us=e((()=>{zs=t(m()),j(),Bs=t(w()),r(),gr(),Gn(),P(),F(),js(),Ns(),Vs=t(x()),Hs=(0,Bs.memo)(({agentId:e})=>{let{t}=a(`setting`),{allowed:n}=L(`edit_own_content`),r=M(N.getAgentConfigById(e),zs.default),i=M(Rt.getAgentById(e)),o=M(e=>e.updateAgentConfigById);if(!i?.workspaceId||!r)return null;let s=r.agencyConfig?.modelSelectionPolicy!==`member`,c=Ms(i.visibility===`private`);return(0,Vs.jsx)(As,{icon:tt,title:t(`settingAgent.modelPolicy.title`),action:(0,Vs.jsx)(ks,{disabled:!n,locked:s,lockedLabel:t(c.locked),unlockedLabel:t(c.unlocked),onChange:t=>{n&&o(e,{agencyConfig:{modelSelectionPolicy:t?`fixed`:`member`}})}}),children:(0,Vs.jsx)(_r,{disabled:!n,style:{width:`100%`},value:{model:r.model,provider:r.provider},onChange:t=>{n&&o(e,t)}})})}),Hs.displayName=`WorkspaceAgentModelPolicy`})),Ws,Gs,Q,Ks,qs,Js=e((()=>{C(),un(),A(),Ct(),D(),Ws=t(m()),j(),Gs=t(w()),r(),gr(),Ga(),Gn(),P(),F(),Do(),No(),fs(),vs(),xs(),Ts(),Rs(),Us(),js(),Q=t(x()),Ks=le(({css:e})=>({configLabel:e` 420 font-size: 12px; 421 line-height: 1; 422 color: ${T.colorTextTertiary}; 423 `,configStack:e` 424 container-type: inline-size; 425 `,configPanel:e` 426 padding: 16px; 427 border: 1px solid ${T.colorBorderSecondary}; 428 border-radius: ${T.borderRadiusLG}; 429 background: ${T.colorFillQuaternary}; 430 `,topArea:e` 431 cursor: default; 432 margin-block-end: 28px; 433 `})),qs=(0,Gs.memo)(()=>{let{t:e}=a(`setting`),{allowed:t}=L(`edit_own_content`),n=M(e=>e.activeAgentId||``),r=M(N.getAgentConfigById(n),Ws.default),i=M(Rt.isWorkspaceAgentById(n)),o=M(e=>e.updateAgentConfigById),s=M(N.isCurrentAgentHeterogeneous),c=r?.agencyConfig?.heterogeneousProvider,l=async e=>{t&&c&&await o(n,{agencyConfig:{heterogeneousProvider:{...c,command:e}}})},u=async e=>{t&&c&&await o(n,{agencyConfig:{heterogeneousProvider:{...c,env:e}}})},d=async e=>{await o(n,{agencyConfig:{...r?.agencyConfig,boundDeviceId:e,executionTarget:`device`}})},f=s&&!!c&&gn(c.type),p=c?.type===`claude-code`,m=c?[...p?[{key:`cloud`,label:e(`heterogeneousStatus.cloud.tabLabel`),children:(0,Q.jsx)(_s,{provider:c,onEnvChange:u})}]:[],{key:`desktop`,label:e(`heterogeneousStatus.desktop.tabLabel`),disabled:!0,children:(0,Q.jsx)(bs,{provider:c,onCommandChange:l})}]:[];return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(k,{className:Ks.topArea,onClick:e=>{e.stopPropagation()},children:[(0,Q.jsx)(Mo,{}),(0,Q.jsxs)(k,{className:Ks.configStack,gap:8,paddingBlock:f?`8px 0`:void 0,children:[f&&c?(0,Q.jsx)(ws,{provider:c,onBoundDeviceChange:d}):s&&c?(0,Q.jsx)(wt,{defaultActiveKey:p?`cloud`:`desktop`,items:m,size:`small`}):i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(k,{horizontal:!0,gap:8,wrap:`wrap`,children:[(0,Q.jsx)(Hs,{agentId:n}),(0,Q.jsx)(Ls,{agentId:n})]}),(0,Q.jsx)(As,{fullWidth:!0,action:(0,Q.jsx)(Wa,{agentId:n}),icon:st,title:e(`settingAgent.toolsConfig.title`),children:(0,Q.jsx)(ds,{})})]}):(0,Q.jsxs)(k,{className:Ks.configPanel,gap:10,children:[(0,Q.jsxs)(k,{horizontal:!0,align:`center`,gap:12,justify:`space-between`,children:[(0,Q.jsx)(`div`,{className:Ks.configLabel,children:e(`settingAgent.runtimeConfig.title`)}),(0,Q.jsx)(Wa,{agentId:n})]}),(0,Q.jsx)(k,{horizontal:!0,align:`center`,gap:12,justify:`flex-start`,wrap:`wrap`,children:(0,Q.jsx)(_r,{initialWidth:!0,disabled:!t,popupWidth:400,value:{model:r?.model,provider:r?.provider},onChange:e=>{t&&o(n,e)}})}),(0,Q.jsx)(ds,{})]}),s?(0,Q.jsx)(Ls,{agentId:n,showDevicePicker:!f}):null]})]}),!s&&(0,Q.jsx)(Eo,{})]})})})),Ys,Xs,Zs=e((()=>{Ys=t(w()),ui(),ha(),Xs=(0,Ys.memo)(()=>{let e=R(e=>e.flushSave);return ci(),li(e),null})})),Qs,$s,ec=e((()=>{Yn(),Qs=t(w()),ha(),$s=(0,Qs.memo)(()=>{let e=pa(),t=mr(R(e=>e.editor));return(0,Qs.useEffect)(()=>{e.setState({editorState:t})},[t,e]),null})})),tc,nc,rc,ic,ac=e((()=>{Yn(),tc=t(w()),P(),ha(),ec(),nc=t(x()),rc=(0,tc.memo)(({children:e})=>{let t=cr();return(0,nc.jsxs)(ma,{createStore:()=>fa({editor:t}),children:[(0,nc.jsx)($s,{}),e]})}),ic=(0,tc.memo)(({children:e})=>{let t=M(e=>e.activeAgentId);return(0,nc.jsx)(rc,{children:e},t??`unscoped`)})})),oc,$,sc,cc,lc,uc;e((()=>{A(),oc=t(w()),Ee(),Qr(),or(),aa(),wi(),Wr(),Gn(),P(),F(),di(),ya(),Va(),Js(),Zs(),ac(),ha(),$=t(x()),sc=fi.create({contentWrapper:{cursor:`text`,display:`flex`,overflowY:`auto`,position:`relative`},profileArea:{minWidth:0}}),cc=(0,oc.memo)(()=>{let e=R(e=>e.editor),t=M(N.isAgentConfigLoading),n=M(N.currentAgentConfigError),r=M(e=>e.retryAgentConfigFetch),{allowed:i}=L(`edit_own_content`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(k,{flex:1,height:`100%`,style:sc.profileArea,children:(0,$.jsxs)($r,{data:t?void 0:!0,error:n,errorVariant:`page`,isLoading:t&&!n,loading:(0,$.jsx)(ur,{debugId:`ProfileArea`}),onRetry:()=>r(),children:[(0,$.jsx)(Ba,{}),(0,$.jsx)(k,{horizontal:!0,height:`100%`,style:{...sc.contentWrapper,cursor:i?`text`:`default`},width:`100%`,onClick:t=>{i&&t.currentTarget.contains(t.target)&&e?.focus()},children:(0,$.jsx)(Gr,{children:(0,$.jsx)(qs,{})})})]})}),(0,$.jsx)(va,{}),(0,$.jsx)(oc.Suspense,{fallback:null,children:(0,$.jsx)(Xs,{})})]})}),lc=(0,oc.memo)(()=>{let e=M(N.isCurrentAgentHeterogeneous),t=R(ua.lockedByOther),n=R(ua.lockPending);return e||t||n?null:(0,$.jsx)(ia,{})}),uc=()=>{let{aid:e}=De();return(0,$.jsx)(oc.Suspense,{fallback:(0,$.jsx)(ur,{debugId:`AgentProfile`}),children:(0,$.jsx)(Ti,{redirectPath:`/agent/${e??``}`,resourceId:e,resourceType:`agent`,children:(0,$.jsx)(ic,{children:(0,$.jsxs)(k,{horizontal:!0,height:`100%`,width:`100%`,children:[(0,$.jsx)(cc,{}),(0,$.jsx)(lc,{})]})})})})}}))();export{uc as default};
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.