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,K as i,L as a,R as o,X as s}from"../vendor/vendor-data-runtime-nLFaCKB0.js";import{Ai as c,Bi as l,Fi as u,Hi as d,Ii as f,Ki as p,Mi as m,O as h,P as ee,Pi as g,Ui as _,Vi as v,Wi as te,Yi as y,ji as ne,ki as re,mn as b}from"../vendor/vendor-ai-runtime-DrDK77gy.js";import{d as x,f as S}from"./agent-Doq2Q6Wt.js";import{Ao as C,Dt as ie,Oo as w,Pi as T,Ri as ae,Rn as E,Sn as oe,Vn as se,Yi as D,g as ce,jo as O,jt as le,ko as ue,lt as de,ut as fe,vn as pe,xn as me}from"./app-const-BzFqCjOv.js";import{A as he,Ba as ge,D as _e,Do as k,Fn as A,Ln as ve,Oo as ye,bo as be,ct as xe,dt as Se,ft as Ce,it as we,lt as Te,mt as Ee,nt as De,ot as Oe,pt as ke,rt as Ae,st as je,to as j,ut as Me,vo as M,wo as Ne,zn as Pe}from"./ScrollArea-CdDxdn_v.js";import{Aa as Fe,I as Ie,Ia as Le,Ka as Re,Sa as ze,n as N,oi as Be,qn as Ve}from"./es-D7HWafs1.js";import{a as He,h as Ue,l as We,y as Ge}from"../vendor/vendor-react-Bwss5s6Y.js";import{$s as Ke,Dh as qe,La as Je,Li as Ye,Ng as Xe,Nh as Ze,Ur as Qe,Vc as $e,Yn as et,at as tt,et as nt,ha as rt,jh as it,kd as at,qn as ot,ra as st,rn as ct,sg as lt,st as ut}from"../vendor/vendor-icons-BXJMWD35.js";import{O as dt,_ as ft,n as pt}from"./base-ui-Bi3Dz7GG.js";import{Ln as mt,M as ht,Vn as gt,Wn as _t,Yn as vt,_t as yt,a as P,dt as bt,ht as xt,k as St,l as Ct,lt as wt,n as F,o as I,pt as L,s as Tt,ut as Et}from"./agent-Dh3-_0ai.js";import{Mt as Dt,b as Ot,f as kt,i as At,jt,p as Mt,t as Nt}from"./selectors-IDJ5-Ts8.js";import{c as Pt,n as Ft,s as It}from"./client-DUGXaJW2.js";import{C as Lt,d as Rt,l as zt,r as Bt,t as Vt,x as Ht}from"./selectors-BZArZxfP.js";import{i as Ut,o as Wt}from"./ipc-XkRXMd72.js";import{Cn as Gt,Eo as Kt,Mn as qt,Sn as R,Uo as Jt,Xo as Yt,n as z,ns as Xt,xn as Zt}from"./store-JX60g0Lu.js";import{a as Qt,o as $t}from"./device-C93cnKgk.js";import{f as en,i as tn,l as nn,t as rn}from"./aiInfra-Db7NbJs1.js";import{Kn as an,i as on,nr as sn,rn as cn}from"./Lexical.prod-ZYFyn_a-.js";import{$n as ln,At as un,Bt as dn,Qn as fn,Rt as pn,St as mn,Ut as hn,Xn as gn,Zn as _n,_n as vn,c as yn,cn as bn,d as xn,dr as Sn,gn as Cn,i as wn,jt as Tn,l as En,or as Dn,r as On,sn as kn,sr as An,ur as jn}from"./ErrorContent-DH2cR0nE.js";import{Bo as Mn,Vo as Nn,is as Pn,rs as Fn}from"./index-Doip7UYu.js";import{i as In,o as Ln,r as Rn}from"./BaseErrorForm-DneHtnxu.js";import{a as zn,n as Bn,o as Vn,t as Hn}from"./useAgentId-SQgiQkxZ.js";import{n as Un,t as Wn}from"./useWorkspaceAwareNavigate--pLVtz2A.js";import{n as Gn,t as Kn}from"./useResourceAccess-CBiX3hN_.js";import{a as qn,c as Jn,o as Yn,s as Xn}from"./useProjectSkills-DrKAm0K1.js";import{l as Zn,p as Qn}from"./plugins-CwCSz6ZM.js";import{n as $n,t as er}from"./WideScreenContainer-DRafIDbQ.js";import{n as tr,t as nr}from"./useOperationState-BCBWDiU_.js";import{o as rr,t as ir}from"./useQueryParam-B9PLc6wW.js";import{n as ar,t as or}from"./useQueryRoute-D4Vkww31.js";import{n as sr,t as cr}from"./useFetchThreads-Bdpegp-k.js";import{a as lr,i as ur,n as dr,r as fr}from"./overlayDispatchStore-CODWbn64.js";import{n as pr,t as mr}from"./useGatewayReconnect-QvZEDzoR.js";import{c as hr,t as gr}from"./useHotkeys-D39xskQD.js";import{n as _r,t as vr}from"./useAgentContext-CsbTAD-9.js";import{n as yr,r as br}from"./composerDraftBus-CCko5o9B.js";import{i as xr,n as Sr,r as Cr,t as wr}from"./useActionsBarConfig-d13CWquL.js";import{n as Tr,t as Er}from"./mergeConversationHooks-CoTLseGl.js";import{a as Dr,i as Or,n as kr,o as Ar,r as jr,t as Mr}from"./Notification-Bph6NZ9A.js";import{r as Nr,t as Pr}from"./heterogeneousAgent-DjV9GlfG.js";var Fr,Ir,Lr=e((()=>{cn(),Zn(),Fr=e=>{e.getLexicalEditor()?.update(()=>{an(on())||sn().selectEnd()})},Ir=(e,t)=>{t.length!==0&&(e.getLexicalEditor()?.focus(),Fr(e),t.forEach(t=>{e.dispatchCommand(Qn,{isDirectory:t.isDirectory,name:t.name,path:t.path})}))}})),Rr,zr,Br=e((()=>{Rr={},zr=e=>Rr})),Vr,Hr,B,Ur,Wr=e((()=>{N(),Vr=t(y()),Hr=t(O()),r(),se(),Zt(),F(),I(),_t(),Bt(),B=t(C()),Ur=(0,Hr.memo)(()=>{let{t:e}=a([`chat`,`welcome`]),t=R(qt.agentId)||``,n=P(yt.inboxAgentId),r=!!n&&t===n,i=P(L.isAgentConfigLoadingById(t)),o=P(xt.getAgentMetaById(t),Vr.default),s=P(e=>xt.getAgentConfigById(t)(e)?.openingMessage||``),c=vt(zt.fontSize),l=r?o.title||`Lobe AI`:o.title||e(`defaultSession`,{ns:`common`}),u=(0,Hr.useMemo)(()=>s||e(`agentDefaultMessageWithSystemRole`,{name:l}),[s,l,e]);return i?(0,B.jsxs)(M,{gap:12,children:[(0,B.jsx)(Ve.Avatar,{active:!0,shape:`square`,size:64}),(0,B.jsx)(Ve.Button,{active:!0,style:{height:32,width:200}}),(0,B.jsx)(M,{width:`min(100%, 640px)`,children:(0,B.jsx)(Ve,{active:!0,paragraph:{rows:2},title:!1})})]}):(0,B.jsxs)(M,{gap:12,children:[(0,B.jsx)(ze,{avatar:r?o.avatar||E:o.avatar||`/avatars/
1agent-default.png`,background:o.backgroundColor,shape:`square`,size:64}),(0,B.jsx)(A,{fontSize:24,weight:`bold`,children:l}),(0,B.jsx)(M,{width:`min(100%, 640px)`,children:(0,B.jsx)(Ie,{fontSize:c,variant:`chat`,children:u})})]})})})),Gr,Kr,qr,Jr,Yr=e((()=>{N(),be(),Gr=t(O()),r(),On(),Kn(),F(),I(),Kr=t(C()),qr=Ne(({css:e,cssVar:t})=>({card:e` 2 padding-block: 8px; 3 padding-inline: 16px; 4 border-radius: 48px; 5 `,cardDisabled:e` 6 cursor: not-allowed; 7 opacity: 0.55; 8 `,container:e` 9 padding-block: 0; 10 padding-inline: 0; 11 `,title:e` 12 color: ${t.colorTextDescription}; 13 `})),Jr=(0,Gr.memo)(({questions:e})=>{let{t}=a([`welcome`,`chat`]),[n]=R(e=>[e.sendMessage]),r=P(e=>e.activeAgentId),i=P(yt.inboxAgentId),o=P(e=>e.activeAgentId?e.agentMap[e.activeAgentId]?.visibility:void 0),{canUseResource:s}=Gn(`agent`,r&&r!==i&&o!==`private`?r:void 0);return(0,Kr.jsxs)(`div`,{className:qr.container,children:[(0,Kr.jsx)(`p`,{className:qr.title,children:t(`guide.questions.title`)}),(0,Kr.jsx)(M,{horizontal:!0,gap:8,wrap:`wrap`,children:e.slice(0,5).map(e=>{let r=(0,Kr.jsx)(Re,{className:ye(qr.card,!s&&qr.cardDisabled),clickable:s,paddingBlock:8,paddingInline:12,variant:`filled`,onClick:s?()=>{n({message:e})}:void 0,children:e},e);return s?r:(0,Kr.jsx)(Pe,{title:t(`input.viewOnlyAgent`,{ns:`chat`}),children:r},e)})})]})})})),Xr,Zr,Qr,$r=e((()=>{Xr=t(O()),Zr=(0,Xr.createContext)({}),Zr.Provider,Qr=()=>(0,Xr.useContext)(Zr).extra})),ei,ti,ni,ri,ii=e((()=>{N(),ei=t(y()),ti=t(O()),Ar(),F(),I(),Wr(),Yr(),$r(),ni=t(C()),ri=(0,ti.memo)(()=>{let e=P(xt.openingQuestions,ei.default),t=Qr();return(0,ni.jsxs)(ni.Fragment,{children:[(0,ni.jsx)(M,{flex:1}),(0,ni.jsxs)(M,{gap:32,style:{paddingBottom:`max(4vh, 16px)`},width:`100%`,children:[(0,ni.jsx)(Ur,{}),t,e.length>0&&(0,ni.jsx)(Jr,{questions:e}),(0,ni.jsx)(Dr,{})]})]})})})),ai,oi,si=e((()=>{ai=t(O()),yr(),Zt(),oi=(0,ai.memo)(()=>{let e=R(e=>e.editor),t=R(e=>e.updateInputMessage),n=br(e=>e.draft);return(0,ai.useEffect)(()=>(br.setState({attached:!!e}),()=>{br.setState({attached:!1})}),[e]),(0,ai.useEffect)(()=>{!n||!e||(e.setDocument(`markdown`,n.text),t(n.text),e.focus(),br.setState({draft:null}))},[n,e,t]),null}),oi.displayName=`ComposerDraftReceiver`})),ci,li,ui=e((()=>{ci=t(O()),li=e=>{(0,ci.useEffect)(()=>{if(e)return window.__mainEditor=e,()=>{window.__mainEditor=void 0}},[e])}})),di,fi,pi=e((()=>{di=t(O()),Zt(),ui(),fi=(0,di.memo)(()=>(li(R(e=>e.editor)),null)),fi.displayName=`ExposeMainEditor`})),mi,hi,gi=e((()=>{ce(),w(),or(),Ft(),F(),I(),mi=`CLAUDE_CODE_OAUTH_TOKEN`,hi=e=>{let t=ar(),n=P(t=>L.getAgencyConfigById(e)(t)?.heterogeneousProvider),r=n?.type===`claude-code`,{data:i,isLoading:a}=Pt.market.creds.list.useQuery(void 0,{enabled:r}),o=(i?.data??[]).some(e=>e.key===mi);return{goToConfig:()=>{e&&t.push(ue(`/agent`,e,`profile`))},isConfigured:!r||!!n?.env?.CLAUDE_CODE_CRED_KEY||o||a}}})),_i,vi,yi=e((()=>{Ft(),Nr(),_i=class{listModels({deviceId:e,...t}){return e?It.device.listHeterogeneousAgentModels.query({deviceId:e,...t}):Pr.listModels(t)}},vi=new _i})),bi,xi,Si=e((()=>{bi=t(O()),xi=e=>{let[t,n]=(0,bi.useState)(!1),[r,i]=(0,bi.useState)(!1),a=(0,bi.useRef)(void 0),o=(0,bi.useCallback)(e=>{i(e),e&&n(!0)},[]);return{contentActive:t,deferSelection:(0,bi.useCallback)(e=>{a.current=e,i(!1)},[]),handleOpenChange:o,handleOpenChangeComplete:(0,bi.useCallback)(t=>{if(t||(n(!1),a.current===void 0))return;let r=a.current;a.current=void 0,e(r)},[e]),open:r}}})),Ci,V,wi,H,Ti,Ei,Di,Oi=e((()=>{b(),N(),pt(),be(),nt(),Ci=t(O()),r(),i(),T(),mt(),wt(),Xn(),qn(),yi(),St(),Si(),V=t(C()),wi=300*1e3,H=Ne(({css:e})=>({check:e` 14 flex: none; 15 color: ${k.colorPrimary}; 16 `,container:e` 17 display: flex; 18 flex-direction: column; 19 20 width: 340px; 21 max-height: 430px; 22 margin: -4px; 23 `,empty:e` 24 padding-block: 24px; 25 padding-inline: 16px; 26 27 font-size: 12px; 28 color: ${k.colorTextTertiary}; 29 text-align: center; 30 `,group:e` 31 padding-block: 8px 3px; 32 padding-inline: 10px; 33 34 font-size: 11px; 35 font-weight: 500; 36 color: ${k.colorTextTertiary}; 37 `,item:e`
38 display: flex; 39 gap: 10px; 40 align-items: center; 41 42 width: calc(100% - 8px); 43 min-height: 42px; 44 margin-inline: 4px; 45 padding-block: 5px; 46 padding-inline: 8px; 47 border-radius: 6px; 48 `,itemBody:e` 49 overflow: hidden; 50 flex: 1; 51 min-width: 0; 52 `,itemSubtitle:e` 53 overflow: hidden; 54 55 font-size: 11px; 56 color: ${k.colorTextTertiary}; 57 text-overflow: ellipsis; 58 white-space: nowrap; 59 `,itemTitle:e` 60 overflow: hidden; 61 62 font-size: 13px; 63 color: ${k.colorText}; 64 text-overflow: ellipsis; 65 white-space: nowrap; 66 `,list:e` 67 overflow-y: auto; 68 flex: 1; 69 min-height: 0; 70 padding-block-end: 4px; 71 `,search:e` 72 display: flex; 73 gap: 6px; 74 align-items: center; 75 76 padding-block: 6px; 77 padding-inline: 10px; 78 border-block-end: 1px solid ${k.colorSplit}; 79 `,spinning:e` 80 animation: opencode-model-spin 0.8s linear infinite; 81 82 @keyframes opencode-model-spin { 83 to { 84 transform: rotate(360deg); 85 } 86 } 87 `,stale:e` 88 color: ${k.colorWarning}; 89 `,trigger:e` 90 cursor: pointer; 91 92 display: flex; 93 flex: none; 94 gap: 6px; 95 align-items: center; 96 97 height: 28px; 98 padding-inline: 8px; 99 border-radius: 6px; 100 101 font-size: 12px; 102 color: ${k.colorTextSecondary}; 103 104 &:hover { 105 color: ${k.colorText}; 106 background: ${k.colorFillSecondary}; 107 } 108 `,triggerDisabled:e` 109 cursor: not-allowed; 110 opacity: 0.5; 111 `,triggerLabel:e` 112 white-space: nowrap; 113 `})),Ti=e=>{let t=JSON.stringify({args:e?.args??[],env:Object.entries(e?.env??{}).sort(([e],[t])=>e.localeCompare(t))}),n=2166136261;for(let e=0;e<t.length;e+=1)n^=t.charCodeAt(e),n=Math.imul(n,16777619);return(n>>>0).toString(36)},Ei=e=>{switch(e){case`cli_not_found`:return`heteroAgent.openCodeModel.cliNotFound`;case`device_unavailable`:return`heteroAgent.openCodeModel.targetUnavailable`;case`timeout`:return`heteroAgent.openCodeModel.timeout`;case`unsupported_client`:return`heteroAgent.openCodeModel.unsupportedClient`;default:return`heteroAgent.openCodeModel.error`}},Di=(0,Ci.memo)(({agentId:e,disabled:t,model:n,onSelect:r,permissionReason:i})=>{let{t:o}=a(`chat`),[c,l]=(0,Ci.useState)(``),{contentActive:u,deferSelection:d,handleOpenChange:f,handleOpenChangeComplete:p,open:h}=xi(r),{agencyConfig:ee,workspaceScoped:g}=Jn(e),_=Yn(e),v=ee?.heterogeneousProvider;ht(e=>e.useFetchGatewayDeviceInfo)();let te=ht(e=>e.gatewayDeviceInfo?.deviceId),y=bt(ee,{clientExecutionAvailable:!1,isHetero:!0,workspaceScoped:g}),ne=gt(ee,te,{workspaceScoped:g}),re=y===`device`&&!!ne,b=n&&n!=="default"?n:m,x=Ti(v),{data:S,error:C,isLoading:ie,isValidating:w,mutate:T}=s(u&&re?[`opencode-model-catalog`,ne,_??``,v?.command??``,x]:null,async()=>{let e=await vi.listModels({command:v?.command,cwd:_,deviceId:ne,env:v?.env,type:`opencode`});if(e.status===`error`){let t=Error(e.error.message);throw t.name=e.error.code,t}return e},{dedupingInterval:wi,revalidateOnFocus:!1,shouldRetryOnError:!1}),ae=(0,Ci.useMemo)(()=>S?.models??[],[S]),E=b!=="default"&&!!S&&!ae.some(e=>e.id===b),oe=(0,Ci.useMemo)(()=>{let e=E?[{id:b,modelId:b.includes(`/`)?b.slice(b.indexOf(`/`)+1):b,providerId:o(`heteroAgent.openCodeModel.saved`)},...ae]:ae,t=c.trim().toLowerCase();return t?e.filter(e=>[e.id,e.providerId,e.modelId].some(e=>e.toLowerCase().includes(t))):e},[ae,b,c,E,o]),se=(0,Ci.useMemo)(()=>oe.reduce((e,t)=>((e[t.providerId]||=[]).push(t),e),{}),[oe]),D=(0,Ci.useCallback)(e=>{p(e),e||l(``)},[p]),ce=(0,V.jsxs)(`div`,{className:ye(H.trigger,t&&H.triggerDisabled),"aria-label":o(`heteroAgent.openCodeModel.ariaLabel`,{model:b==="default"?o(`heteroAgent.modelSelector.default`):b}),children:[(0,V.jsx)(`span`,{className:H.triggerLabel,children:b==="default"?o(`heteroAgent.modelSelector.default`):b}),(0,V.jsx)(j,{icon:it,size:12})]});return t?(0,V.jsx)(Pe,{title:i,children:(0,V.jsx)(`div`,{children:ce})}):(0,V.jsxs)(Me,{open:h,onOpenChange:f,onOpenChangeComplete:D,children:[(0,V.jsx)(Ee,{nativeButton:!1,children:ce}),(0,V.jsx)(xe,{children:(0,V.jsx)(Te,{placement:`topLeft`,sideOffset:8,children:(0,V.jsx)(je,{children:(0,V.jsxs)(`div`,{className:H.container,children:[(0,V.jsxs)(`div`,{className:H.search,children:[(0,V.jsx)(Be,{autoFocus:!0,placeholder:o(`heteroAgent.openCodeModel.search`),prefix:(0,V.jsx)(j,{icon:Ye,size:14}),size:`small`,value:c,variant:`borderless`,onChange:e=>l(e.target.value),onKeyDown:e=>e.stopPropagation()}),(0,V.jsx)(Le,{"aria-label":o(`heteroAgent.openCodeModel.reload`),className:ye(w&&H.spinning),disabled:!re||w,icon:w?$e:rt,size:`small`,title:o(`heteroAgent.openCodeModel.reload`),onClick:()=>void T()})]}),(0,V.jsxs)(`div`,{className:H.list,children:[(0,V.jsxs)(De,{className:H.item,onClick:()=>d(m),children:[(0,V.jsxs)(`div`,{className:H.itemBody,children:[(0,V.jsx)(`div`,{className:H.itemTitle,children:o(`heteroAgent.modelSelector.default`)}),(0,V.jsx)(`div`,{className:H.itemSubtitle,children:o(`heteroAgent.openCodeModel.defaultDesc`)})]}),b==="default"&&(0,V.jsx)(j,{className:H.check,icon:Ze,size:14})]}),ie&&!S&&(0,V.jsx)(`div`,{className:H.empty,children:o(`heteroAgent.openCodeModel.loading`)}),!re&&(0,V.jsx)(`div`,{className:H.empty,children:o(`heteroAgent.openCodeModel.targetUnavailable`)}),C&&(0,V.jsxs)(`div`,{className:H.empty,children:[o(Ei(C.name)),(0,V.jsx)(`br`,{}),(0,V.jsx)(dt,{size:`small`,type:`text`,onClick:()=>void T(),children:o(`heteroAgent.openCodeModel.retry`)}
113)]}),S&&oe.length===0&&(0,V.jsx)(`div`,{className:H.empty,children:c.trim()?o(`heteroAgent.openCodeModel.noMatch`):o(`heteroAgent.openCodeModel.empty`)}),Object.entries(se).map(([e,t])=>(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:H.group,children:e}),t.map(e=>(0,V.jsxs)(De,{className:H.item,onClick:()=>d(e.id),children:[(0,V.jsxs)(`div`,{className:H.itemBody,children:[(0,V.jsx)(`div`,{className:H.itemTitle,children:e.modelId}),(0,V.jsxs)(`div`,{className:ye(H.itemSubtitle,E&&e.id===b&&H.stale),children:[e.id,E&&e.id===b?` · ${o(`heteroAgent.openCodeModel.stale`)}`:``]})]}),e.id===b&&(0,V.jsx)(j,{className:H.check,icon:Ze,size:14})]},e.id))]},e))]})]})})})})]})}),Di.displayName=`OpenCodeModelSelector`})),ki,Ai,U,ji,Mi,Ni,Pi,Fi,W,Ii,Li,Ri,zi,Bi,Vi,Hi,Ui,Wi=e((()=>{b(),N(),pt(),be(),ki=t(y()),nt(),Ai=t(O()),r(),Mn(),F(),I(),Hn(),jn(),Oi(),U=t(C()),ji=[{label:`Fable 5`,value:`fable`},{label:`Opus 4.8`,value:`opus`},{label:`Sonnet 4.6`,value:`sonnet`},{label:`Haiku 4.5`,value:`haiku`}],Mi=[{label:`GPT-5.6 Sol`,value:`gpt-5.6-sol`},{label:`GPT-5.6 Terra`,value:`gpt-5.6-terra`},{label:`GPT-5.6 Luna`,value:`gpt-5.6-luna`},{label:`GPT-5.5`,value:`gpt-5.5`},{label:`GPT-5.4`,value:`gpt-5.4`},{label:`GPT-5.4 Mini`,value:`gpt-5.4-mini`},{label:`GPT-5.3 Codex Spark`,value:`gpt-5.3-codex-spark`}],Ni={"gpt-5.6":`GPT-5.6`,...Object.fromEntries([...ji,...Mi].map(e=>[e.value,e.label]))},Pi={[m]:`heteroAgent.modelSelector.default`,high:`heteroAgent.modelSelector.reasoning.high`,low:`heteroAgent.modelSelector.reasoning.low`,max:`heteroAgent.modelSelector.reasoning.max`,medium:`heteroAgent.modelSelector.reasoning.medium`,ultra:`heteroAgent.modelSelector.reasoning.ultra`,xhigh:`heteroAgent.modelSelector.reasoning.xhigh`},Fi={...Pi,low:`heteroAgent.modelSelector.reasoning.light`},W=Ne(({css:e})=>({check:e` 114 flex: none; 115 color: ${k.colorTextSecondary}; 116 `,label:e` 117 overflow: hidden; 118 max-width: 150px; 119 text-overflow: ellipsis; 120 white-space: nowrap; 121 `,option:e` 122 cursor: pointer; 123 124 display: flex; 125 gap: 18px; 126 align-items: center; 127 justify-content: space-between; 128 129 min-height: 34px; 130 padding-inline: 10px; 131 border-radius: 8px; 132 133 font-size: 14px; 134 line-height: 1.2; 135 color: ${k.colorText}; 136 137 transition: background-color 0.2s; 138 139 &:hover { 140 background: ${k.colorFillTertiary}; 141 } 142 `,optionBody:e` 143 overflow: hidden; 144 display: flex; 145 flex: 1; 146 flex-direction: column; 147 gap: 3px; 148 149 min-width: 0; 150 padding-block: 7px; 151 `,optionDesc:e` 152 overflow: hidden; 153 154 font-size: 12px; 155 color: ${k.colorTextTertiary}; 156 text-overflow: ellipsis; 157 white-space: nowrap; 158 `,optionIcon:e` 159 flex: none; 160 color: ${k.colorTextSecondary}; 161 `,optionLabel:e` 162 overflow: hidden; 163 flex: 1; 164 165 min-width: 0; 166 167 text-overflow: ellipsis; 168 white-space: nowrap; 169 `,optionTitle:e` 170 display: flex; 171 gap: 6px; 172 align-items: center; 173 white-space: nowrap; 174 `,popup:e` 175 padding: 8px; 176 border-radius: 16px; 177 background: ${k.colorBgElevated}; 178 box-shadow: 179 0 0 0 1px ${k.colorBorderSecondary}, 180 0 12px 32px rgb(0 0 0 / 10%), 181 0 4px 12px rgb(0 0 0 / 8%); 182 `,scroll:e` 183 overflow-y: auto; 184 display: flex; 185 flex-direction: column; 186 max-height: 250px; 187 `,sectionTitle:e` 188 padding-block: 0 8px; 189 padding-inline: 10px; 190 191 font-size: 13px; 192 line-height: 1.2; 193 color: ${k.colorTextQuaternary}; 194 `,submenuTrigger:e` 195 min-height: 36px; 196 padding-inline: 10px; 197 `,submenuMeta:e` 198 overflow: hidden; 199 display: inline-flex; 200 flex: none; 201 gap: 4px; 202 align-items: center; 203 204 min-width: 0; 205 max-width: 150px; 206 padding-inline-start: 16px; 207 208 font-family: inherit; 209 font-size: 14px; 210 color: ${k.colorTextSecondary}; 211 `,submenuMetaLabel:e` 212 overflow: hidden; 213 text-overflow: ellipsis; 214 white-space: nowrap; 215 `,trigger:e` 216 cursor: pointer; 217 218 display: flex; 219 flex: none; 220 gap: 6px; 221 align-items: center; 222 223 height: 28px; 224 padding-inline: 8px; 225 border-radius: 6px; 226 227 font-size: 12px; 228 color: ${k.colorTextSecondary}; 229 white-space: nowrap; 230 231 transition: all 0.2s; 232 233 &:hover { 234 color: ${k.colorText}; 235 background: ${k.colorFillSecondary}; 236 } 237 `,triggerDisabled:e`
238 cursor: not-allowed; 239 opacity: 0.5; 240 241 &:hover { 242 color: ${k.colorTextSecondary}; 243 background: transparent; 244 } 245 `})),Ii=({children:e,currentValue:t,icon:n,label:r,popupWidth:i=220})=>(0,U.jsxs)(Ce,{children:[(0,U.jsx)(ke,{className:W.submenuTrigger,label:r,openOnHover:!1,children:(0,U.jsxs)(Ae,{children:[(0,U.jsx)(Oe,{children:r}),(0,U.jsxs)(we,{className:W.submenuMeta,children:[n&&(0,U.jsx)(j,{className:W.optionIcon,icon:n,size:12}),(0,U.jsx)(`span`,{className:W.submenuMetaLabel,children:t})]}),(0,U.jsx)(Se,{children:(0,U.jsx)(j,{icon:qe,size:12})})]})}),(0,U.jsx)(xe,{children:(0,U.jsx)(Te,{alignOffset:-4,anchor:null,placement:`right`,sideOffset:8,children:(0,U.jsxs)(je,{className:W.popup,style:{minWidth:i},children:[(0,U.jsx)(`div`,{className:W.sectionTitle,children:r}),(0,U.jsx)(`div`,{className:W.scroll,children:e})]})})})]}),Li=(e,t)=>{if(!e)return;let n=[];for(let r=0;r<e.length;r+=1){let i=e[r];if(t.includes(i)){let t=e[r+1];t&&!t.startsWith(`-`)&&(r+=1);continue}t.some(e=>i.startsWith(`${e}=`))||n.push(i)}return n},Ri=e=>e.match(/^\s*([\w.-]+)\s*=/)?.[1],zi=(e,t)=>{if(!e)return;let n=[];for(let r=0;r<e.length;r+=1){let i=e[r];if(i===`-c`||i===`--config`){let a=e[r+1];if(a&&Ri(a)===t){r+=1;continue}n.push(i);continue}(i.startsWith(`-c=`)||i.startsWith(`--config=`))&&Ri(i.slice(i.indexOf(`=`)+1))===t||n.push(i)}return n},Bi=e=>e===`claude-code`||e===`codex`||e===`opencode`,Vi=(e,t)=>{if(e==="default")return t;let n=Ni[e];if(n)return n;let r=/^claude-(opus|sonnet|haiku)-(\d+)-(\d+)/.exec(e);if(!r)return e;let[,i,a,o]=r;return`${i[0].toUpperCase()}${i.slice(1)} ${a}.${o}`},Hi=({defaultConfigLabel:e,defaultModelLabel:t,defaultReasoningLabel:n,effort:r,effortLabel:i,model:a,modelLabel:o})=>{let s=a===m,c=r===m;return s&&c?e:`${s?t:o} ${c?n:i}`},Ui=(0,Ai.memo)(()=>{let{t:e}=a(`chat`),t=Bn(),n=P(e=>L.getAgencyConfigById(t)(e)?.heterogeneousProvider,ki.default),r=P(e=>e.updateAgentConfigById),{allowed:i,reason:o}=Nn(`create_content`),{canUseResource:s,isGroupContext:p}=Sn(),h=i&&s,[ee,y]=(0,Ai.useState)(!1),b=(0,Ai.useCallback)(async e=>{if(!h||!t)return;let i={...e},a=n?.type;a===`codex`?(`model`in e&&(i.args=zi(Li(n?.args,[`--model`,`-m`]),`model`)),`effort`in e&&(i.args=zi(i.args??n?.args,c)),`speed`in e&&(i.args=zi(i.args??n?.args,ne))):a===`opencode`?`model`in e&&(i.args=Li(n?.args,[`--model`,`-m`])):(`model`in e&&(i.args=Li(n?.args,[`--model`])),`effort`in e&&(i.args=Li(i.args??n?.args,[`--effort`]))),await r(t,{agencyConfig:{heterogeneousProvider:i}})},[t,h,n?.args,n?.type,r]),x=(0,Ai.useCallback)(()=>{y(!1)},[]),S=(0,Ai.useCallback)(e=>{x();let t=n?.type===`codex`&&te(n)===`fast`&&!g(e),r=n?.type===`codex`?_(n):void 0;b({...r!==void 0&&r!=="default"&&!u(e,r)?{effort:m}:{},model:e,...t?{speed:m}:{}})},[x,b,n]),C=(0,Ai.useCallback)(e=>{x(),b({effort:e})},[x,b]),ie=(0,Ai.useCallback)(e=>{x(),b({speed:e})},[x,b]);if(!Bi(n?.type))return null;if(n.type===`opencode`){let e=n.model&&n.model!=="default"?n.model:m;return(0,U.jsx)(Di,{agentId:t,disabled:!i,model:e,permissionReason:o,onSelect:e=>void b({model:e})})}let w=n.type,T=w===`codex`?d(n):l(n),ae=w===`codex`?_(n):v(n),E=w===`codex`&&g(T),oe=E?te(n):m,se=oe===`fast`,D=e(`heteroAgent.modelSelector.default`),ce=Vi(T,D),O=w===`codex`?Fi:Pi,le=e(O[ae]),ue=w===`codex`?f(T):re,de=w===`codex`?Mi:ji,fe=[{label:D,value:m},...ue.map(t=>({label:e(O[t]),value:t}))],pe=[{label:D,value:m},...de],me=pe.some(e=>e.value===T)?pe:[{label:T,value:T},...pe],he=[{description:e(`heteroAgent.modelSelector.speed.standardDesc`),label:e(`heteroAgent.modelSelector.speed.standard`),value:m},{description:e(`heteroAgent.modelSelector.speed.fastDesc`),icon:tt,label:e(`heteroAgent.modelSelector.speed.fast`),value:`fast`}],ge=e(oe===`fast`?`heteroAgent.modelSelector.speed.fast`:`heteroAgent.modelSelector.speed.standard`),_e=Hi({defaultConfigLabel:e(`heteroAgent.modelSelector.defaultConfig`),defaultModelLabel:e(`heteroAgent.modelSelector.defaultModel`),defaultReasoningLabel:e(`heteroAgent.modelSelector.defaultReasoning`),effort:ae,effortLabel:le,model:T,modelLabel:ce}),k=(0,U.jsxs)(`div`,{className:ye(W.trigger,!h&&W.triggerDisabled),"aria-label":e(`heteroAgent.modelSelector.ariaLabel`,{model:ce,reasoning:le}),children:[se&&(0,U.jsx)(j,{icon:tt,size:12}),(0,U.jsx)(`span`,{className:W.label,children:_e}),(0,U.jsx)(j,{icon:it,size:12})]});if(!h)return(0,U.jsx)(Pe,{title:i?e(p?`input.viewOnlyGroup`:`input.viewOnlyAgent`):o,children:(0,U.jsx)(`div`,{children:k})});let A=(e,t,n,r)=>t.map(t=>(0,U.jsxs)(De,{className:W.option,"data-selected":n===t.value?`true`:void 0,onClick:()=>void r(t.value),children:[t.description?(0,U.jsxs)(`div`,{className:W.optionBody,children:[(0,U.jsxs)(`span`,{className:W.optionTitle,children:[t.icon&&(0,U.jsx)(j,{className:W.optionIcon,icon:t.icon,size:14}),t.label]}),(0,U.jsx)(`span`,{className:W.optionDesc,children:t.description})]}):(0,U.jsx)(`span`,{className:W.optionLabel,children:t.label}),n===t.value&&(0,U.jsx)(j,{className:W.check,icon:Ze,size:16})]},`${e}-${t.value}`));return(0,U.jsxs)(Me,{open:ee,onOpenChange:y,children:[(0,U.jsx)(Ee,{nativeButton:!1,children:k}),(0,U.jsx)(xe,{children:(0,U.jsx)(Te,{placement:`topLeft`,sideOffset:8,children:(0,U.jsxs)(je,{className:W.popup,style:{width:240},children:[(0,U.jsx)(Ii,{currentValue:ce,label:e(`heteroAgent.modelSelector.model`),popupWidth:240,children:A(`model`,me,T,S)}),(0,U.jsx)(Ii,{currentValue:le,label:e(`heteroAgent.modelSelector.reasoning`),children:A(`reasoning`,fe,ae,C)}),E&&(0,U.jsx)(Ii,{currentValue:ge,icon:se?tt:void 0,label:e(`heteroAgent.modelSelector.speed`),popupWidth:240,children:A(`speed`,he,oe,ie)})]})})})]})}),Ui.displayName=`HeteroModel`})),Gi,Ki,qi=e((()=>{Jt(),Gi=t(O()),Xn(),$t(),Ki=({agentId:e,enabled:t=!0})=>{let{agencyConfig:n,isPreferenceLoading:r}=Jn(e),i=n?.boundDeviceId,a=n?.heterogeneousProvider?.type,[o,s]=(0,Gi.useState)(`checking`),c=(0,Gi.useCallback)(async()=>
245{if(t){if(r){s(`checking`);return}if(!i){s(`no-device`);return}s(`checking`);try{let e=(await Qt.listDevices()).find(e=>e.deviceId===i);if(!e||!e.online){s(`device-offline`);return}a&&Xt(a)?s((await Qt.checkCapability({deviceId:i,platform:a})).available?`ok`:`platform-unavailable`):s(`ok`)}catch{s(`ok`)}}},[t,r,i,a]);return(0,Gi.useEffect)(()=>{c()},[c]),(0,Gi.useEffect)(()=>{if(!t)return;let e=()=>void c();return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[t,c]),{refresh:()=>void c(),status:o}}})),Ji,Yi,Xi=e((()=>{Ft(),Ji=class{ingestClaudeSnapshot=async e=>It.agentQuota.ingestSnapshot.mutate({identity:e.identity,provider:`claude-code`,readings:e.readings.map(e=>({...e,scopeKey:e.scopeKey??``}))});listAccounts=async()=>It.agentQuota.listAccounts.query();getWindows=async e=>It.agentQuota.getWindows.query({accountId:e});listBindings=async e=>It.agentQuota.listBindings.query({agentId:e});switchAccount=async(e,t)=>It.agentQuota.switchAccount.mutate({accountId:t,agentId:e});bindAccount=async(e,t,n=`pool`)=>It.agentQuota.bindAccount.mutate({accountId:t,agentId:e,role:n});unbindAccount=async e=>It.agentQuota.unbindAccount.mutate({id:e});updateAccount=async(e,t)=>It.agentQuota.updateAccount.mutate({id:e,value:t});selectAccountForAgent=async(e,t)=>It.agentQuota.selectAccountForAgent.query({agentId:e,modelScope:t})},Yi=new Ji})),G,K,Zi,Qi,q,$i,ea,ta,na,ra,ia,aa=e((()=>{N(),be(),nt(),G=t(O()),r(),K=t(C()),Zi=6e4,Qi=6e4,q=Ne(({css:e})=>({compactItem:e` 246 color: inherit; 247 248 &[data-quota-level='low'] { 249 color: ${k.colorWarningText}; 250 } 251 `,compactItems:e` 252 display: inline-flex; 253 gap: 4px; 254 align-items: center; 255 `,compactSeparator:e` 256 color: ${k.colorTextQuaternary}; 257 `,emptyState:e` 258 padding-block: 10px; 259 font-size: 12px; 260 color: ${k.colorTextDescription}; 261 `,error:e` 262 padding: 8px; 263 border: 1px solid ${k.colorErrorBorder}; 264 border-radius: ${k.borderRadius}; 265 266 font-size: 12px; 267 color: ${k.colorError}; 268 269 background: ${k.colorErrorBg}; 270 `,refreshNotice:e` 271 padding: 8px; 272 border: 1px solid ${k.colorWarningBorder}; 273 border-radius: ${k.borderRadius}; 274 275 font-size: 12px; 276 color: ${k.colorWarningText}; 277 278 background: ${k.colorWarningBg}; 279 `,header:e` 280 padding-block-end: 6px; 281 border-block-end: 1px solid ${k.colorBorderSecondary}; 282 `,popover:e` 283 width: 292px; 284 `,progressFill:e` 285 height: 100%; 286 border-radius: inherit; 287 background: ${k.colorSuccess}; 288 `,progressFillWarning:e` 289 background: ${k.colorWarning}; 290 `,progressTrack:e` 291 overflow: hidden; 292 flex: 1; 293 294 min-width: 24px; 295 height: 6px; 296 border-radius: 999px; 297 298 background: ${k.colorFillQuaternary}; 299 `,resetShort:e` 300 flex: none; 301 white-space: nowrap; 302 `,trigger:e` 303 cursor: pointer; 304 305 display: flex; 306 flex: none; 307 gap: 6px; 308 align-items: center; 309 310 padding-block: 2px; 311 padding-inline: 4px; 312 border: 0; 313 border-radius: 4px; 314 315 font: inherit; 316 font-size: 12px; 317 color: ${k.colorTextSecondary}; 318 white-space: nowrap; 319 320 appearance: none; 321 background: transparent; 322 323 transition: all 0.2s; 324 325 &:hover { 326 color: ${k.colorTextSecondary}; 327 background: ${k.colorFillSecondary}; 328 } 329 330 &[data-quota-level='low'] { 331 color: ${k.colorWarningText}; 332 333 &:hover { 334 color: ${k.colorWarningText}; 335 } 336 } 337 `,triggerOpen:e` 338 color: ${k.colorTextSecondary}; 339 background: ${k.colorFillSecondary}; 340 `,value:e` 341 flex: none; 342 font-variant-numeric: tabular-nums; 343 color: ${k.colorText}; 344 `,valueWarning:e` 345 color: ${k.colorWarningText}; 346 `,window:e` 347 min-width: 0; 348 `,windowExhausted:e` 349 /* nothing to act on until reset â grey the whole row out */ 350 opacity: 0.45; 351 `,windowLabel:e` 352 flex: none; 353 width: 84px; 354 color: ${k.colorTextSecondary}; 355 `})),$i=e=>Math.min(100,Math.max(0,Math.round(e))),ea=15,ta=e=>e<ea,na=e=>!e||typeof e==`string`?e??null:Object.entries(e).sort(([e],[t])=>e.localeCompare(t)),ra=(...e)=>JSON.stringify(e.map(e=>na(e))),ia=({contentWidth:e,createErrorSnapshot:t,fetchQuota:n,getErrorText:r,getRefreshErrorText:i,getUnavailableText:o,getWindows:s,hasExtraData:c,renderFooter:l,renderHeader:u,sourceKey:d=`default`,title:f,tooltip:p})=>{let{t:m}=a(`chat`),[h,ee]=(0,G.useState)(!1),[g,_]=(0,G.useState)(!1),[v,te]=(0,G.useState)(null),[y,ne]=(0,G.useState)(null),[re,b]=(0,G.useState)(()=>Date.now()),x=(0,G.useRef)(0),S=(0,G.useRef)(null),C=(0,G.useRef)(0),ie=(0,G.useRef)(d),w=(0,G.useCallback)(e=>e?s(e).some(e=>e.window)||!!c?.(e):!1,[s,c]),T=(0,G.useCallback)(e=>{S.current=e,te(e)},[]),ae=(0,G.useCallback)(e=>{ie.current===d&&(C.current+=1,_(!1),ne(null),T(e))},[T,d]),E=(0,G.useCallback)((e,t)=>e===C.current&&t===ie.current,[]),oe=(0,G.useCallback)((e,t={},n=C.current,r=ie.current)=>{if(E(n,r)){if(e.status===`error`){if(x.current=Date.now(),w(S.current)){t.manual&&ne(e);return}}else x.current=0;ne(null),T(e)}},[w,E,T]),se=(0,G.useCallback)(async(e={})=>{let r=ie.current,i=C.current+1;C.current=i,ne(null),_(!0);try{oe(await n(e.manual?{force:!0}:void 0),e,i,r)}catch(n){console.error(`Failed to fetch agent quota:`,n),oe(t(n),e,i,r)}finally{E(i,r)&&_(!1)}},[oe,t,n,E]);(0,G.useEffect)(()=>{ie.current=d,S.current=null,x.current=0,te(null),ne(null)},[d]),(0,G.useEffect)(()=>{se()},[se,d]),(0,G.useEffect)(()=>{let e=window.setInterval(()=>b(Date.now()),Zi);return()=>{window.clearInterval(e)}},[]);let D=(0,G.useCallback)(e=>{if(e<=0)return;let t=Math.floor(e/6e4),n=Math.floor(t/1440),r=Math.floor(t%1440/60),i=t%60,a=[];return n>0&&a.push(m(`heteroAgent.quota.duration.day`,{count:n})),r>0&&a.push(m(`heteroAgent.quota.duration.hour`,{count:r})),i>0&&a.length<2&&a.push(m(`heteroAgent.quota.duration.minute`,{count:i})),a.slice(0,2).join(` `)||void 0},[m]),ce=(0,G.useCallback)(e=>{let t=D(re-e);return t?m(`heteroAgent.quota.updatedAgo`,{duration:t}):m(`heteroAgent.quota.updatedJustNow`)},[D,re,m]),O=v?s(v):[],le=new Map;for(let e of O){if(!e.window)continue;let t=$i(100-e.window.usedPercent),n=e.compactGroup??`default`,r=le.get(n);(!r||t<r.leftPercent)&&le.set(n,{key:n,label:e.compactLabel,leftPercent:t})}let ue=[...le.values()],de=w(v),fe=y&&(i?.(y)||m(`heteroAgent.quota.refreshFailed`)),pe=v?.status===`error`&&de?i?.(v)||m(`heteroAgent.quota.refreshFailed`):void 0,me=fe||pe,ge=(0,G.useCallback)(e=>{if(ee(e),!e||g)return;let t=Date.now(),n=x.current>0&&t-x.current<Qi;(!v||t-v.updatedAt>
355Zi)&&!n&&se()},[se,g,v]),_e=({key:e,label:t,window:n})=>{if(!n)return null;let r=$i(100-n.usedPercent),i=n.resetsAt?D(n.resetsAt-re):void 0,a=r===0,o=!a&&ta(r);return(0,K.jsxs)(M,{horizontal:!0,align:`center`,className:ye(q.window,a&&q.windowExhausted),gap:8,children:[(0,K.jsx)(A,{ellipsis:!0,className:q.windowLabel,style:{fontSize:12},children:t}),(0,K.jsx)(`div`,{className:q.progressTrack,children:(0,K.jsx)(`div`,{className:ye(q.progressFill,o&&q.progressFillWarning),"data-quota-level":o?`low`:`normal`,style:{width:`${r}%`}})}),(0,K.jsx)(A,{className:ye(q.value,o&&q.valueWarning),style:{fontSize:12},children:a?m(`heteroAgent.quota.exhausted`):`${r}%`}),i&&(0,K.jsx)(A,{className:q.resetShort,style:{fontSize:12},type:`secondary`,children:i})]},e)},k=(0,K.jsxs)(M,{className:q.popover,gap:10,style:{width:e},children:[(0,K.jsxs)(M,{horizontal:!0,align:`center`,className:q.header,gap:8,justify:`space-between`,children:[(0,K.jsxs)(M,{horizontal:!0,align:`baseline`,gap:6,style:{minWidth:0},children:[(0,K.jsx)(A,{strong:!0,style:{fontSize:13},children:f}),v?.updatedAt&&(0,K.jsx)(A,{ellipsis:!0,style:{fontSize:11},type:`secondary`,children:ce(v.updatedAt)})]}),(0,K.jsx)(Pe,{title:m(`heteroAgent.quota.refresh`),children:(0,K.jsx)(Le,{disabled:g,icon:rt,size:`small`,onClick:()=>void se({manual:!0})})})]}),g&&!de?(0,K.jsxs)(M,{gap:8,children:[(0,K.jsx)(Ve.Button,{active:!0,block:!0,size:`small`,style:{height:18}}),(0,K.jsx)(Ve.Button,{active:!0,block:!0,size:`small`,style:{height:18}}),(0,K.jsx)(Ve.Button,{active:!0,block:!0,size:`small`,style:{height:18}})]}):v?.status===`unavailable`?(0,K.jsx)(`div`,{className:q.emptyState,children:o?.(v)||v.error||m(`heteroAgent.quota.unavailable`)}):v?.status===`error`&&!de?(0,K.jsx)(`div`,{className:q.error,children:r?.(v)||v.error||m(`heteroAgent.quota.unavailable`)}):de?(0,K.jsxs)(K.Fragment,{children:[v&&u?.(v,{applyQuota:ae,formatDuration:D,now:re}),(0,K.jsx)(M,{gap:10,children:O.map(e=>_e(e))}),v&&l?.(v,{applyQuota:ae,formatDuration:D,now:re}),me&&(0,K.jsx)(`div`,{className:q.refreshNotice,children:me})]}):(0,K.jsx)(`div`,{className:q.emptyState,children:m(`heteroAgent.quota.noData`)})]}),ve=(0,K.jsxs)(`button`,{"aria-expanded":h,"aria-haspopup":`dialog`,"aria-label":p,className:ye(q.trigger,h&&q.triggerOpen),type:`button`,"data-quota-level":ue.length===1?ta(ue[0].leftPercent)?`low`:`normal`:void 0,children:[(0,K.jsx)(j,{icon:at,size:14}),ue.length>0&&(0,K.jsx)(`span`,{className:q.compactItems,children:ue.map((e,t)=>(0,K.jsxs)(`span`,{children:[t>0&&(0,K.jsx)(`span`,{"aria-hidden":!0,className:q.compactSeparator,children:` · `}),(0,K.jsxs)(`span`,{className:q.compactItem,"data-quota-level":ue.length>1?ta(e.leftPercent)?`low`:`normal`:void 0,children:[e.label&&`${e.label} `,e.leftPercent===0&&!e.label?m(`heteroAgent.quota.exhausted`):m(`heteroAgent.quota.compactLeft`,{percent:e.leftPercent})]})]},e.key))}),(0,K.jsx)(j,{icon:it,size:12})]});return(0,K.jsx)(he,{content:k,open:h,placement:`topRight`,trigger:`click`,onOpenChange:ge,children:(0,K.jsx)(`div`,{children:h?ve:(0,K.jsx)(Pe,{title:p,children:ve})})})}})),oa,sa,ca,la,ua,da,fa=e((()=>{oa=e=>{if(e==null)return null;let t=e instanceof Date?e.getTime():Date.parse(e);return Number.isNaN(t)?null:t},sa=e=>{if(!e)return null;let t=Math.max(0,Math.min(100,e.lastUtilization??e.peakUtilization??0));return{resetsAt:oa(e.resetsAt),usedPercent:t,windowMinutes:Math.round((e.windowSeconds??0)/60)}},ca=e=>e.limitType===`weekly_all`||e.limitType.startsWith(`weekly`)&&!e.scopeKey,la=e=>({displayName:e.displayName??void 0,email:e.email??void 0,externalAccountId:e.externalAccountId??void 0,organizationId:e.organizationId??void 0,planTier:e.planTier??void 0,rateLimitTier:e.rateLimitTier??void 0}),ua=(e,t)=>{let n=t.find(e=>e.limitType===`session`),r=t.find(ca),i=t.find(e=>e.limitType===`weekly_scoped`&&!!e.scopeKey),a=t.reduce((e,t)=>Math.max(e,oa(t.lastSeenAt)??0),0);return{error:null,identity:la(e),provider:`claude-code`,scopedWeekly:i?{modelName:i.scopeKey,window:sa(i)}:null,session:sa(n),status:`ok`,updatedAt:a||Date.now(),weekly:sa(r)}},da=(e,t,n)=>{if(e.length===0)return!0;let r=e.reduce((e,t)=>
355Math.max(e,oa(t.lastSeenAt)??0),0);return r===0||t-r>n}})),pa,ma,ha,ga,_a,va,ya,ba=e((()=>{pa=t(O()),r(),Hn(),Xi(),Nr(),aa(),fa(),ma=t(C()),ha=3600*1e3,ga=e=>({error:e instanceof Error?e.message:String(e),provider:`claude-code`,scopedWeekly:null,session:null,status:`error`,updatedAt:Date.now(),weekly:null}),_a=e=>({error:null,provider:`claude-code`,reason:e,scopedWeekly:null,session:null,status:`unavailable`,updatedAt:Date.now(),weekly:null}),va=e=>e.error?.includes(`429`)??!1,ya=(0,pa.memo)(({env:e})=>{let{t}=a(`chat`),n=Bn(),r=ra(`claude-code`,e),i=(0,pa.useCallback)(async t=>{let r=!!t?.force,i=await Yi.listAccounts().catch(()=>[]),a=i.filter(e=>e.provider===`claude-code`),o;n&&(o=(await Yi.listBindings(n).catch(()=>[])).find(e=>e.role===`pinned`)?.accountId);let s=a.find(e=>e.id===o)??a[0],c=s?await Yi.getWindows(s.id).catch(()=>[]):[],l=null;if(r||da(c,Date.now(),ha)){l=await Pr.getClaudeCodeQuota({env:e,...r?{force:!0}:{}}).catch(()=>null);let t=l?.identity?.externalAccountId;l?.status===`ok`&&t&&l.readings?.length&&(await Yi.ingestClaudeSnapshot({identity:l.identity,readings:l.readings}).catch(()=>{}),i=await Yi.listAccounts().catch(()=>i),a=i.filter(e=>e.provider===`claude-code`),s=a.find(e=>e.externalAccountId===t)??a.find(e=>e.id===o)??a[0],c=s?await Yi.getWindows(s.id).catch(()=>c):c)}return s&&c.length>0?ua(s,c):l??_a()},[e,n]),o=(0,pa.useCallback)(e=>[{compactGroup:`global`,compactLabel:t(`heteroAgent.quota.session`),key:`session`,label:t(`heteroAgent.quota.session`),window:e.session},{compactGroup:`global`,compactLabel:t(`heteroAgent.quota.weekly`),key:`weekly`,label:t(`heteroAgent.quota.weekly`),window:e.weekly},...e.scopedWeekly?[{compactGroup:`scopedWeekly`,compactLabel:e.scopedWeekly.modelName,key:`scopedWeekly`,label:t(`heteroAgent.claudeQuota.scopedWeekly`,{model:e.scopedWeekly.modelName}),window:e.scopedWeekly.window}]:[]],[t]),s=(0,pa.useCallback)(e=>{switch(e.reason){case`credentials-expired`:return t(`heteroAgent.claudeQuota.unavailableExpired`);case`credentials-not-found`:return t(`heteroAgent.claudeQuota.unavailableNotFound`);case`external-auth`:return t(`heteroAgent.claudeQuota.unavailableExternalAuth`);default:return}},[t]);return(0,ma.jsx)(ia,{createErrorSnapshot:ga,fetchQuota:i,getErrorText:(0,pa.useCallback)(e=>va(e)?t(`heteroAgent.claudeQuota.errorRateLimited`):t(`heteroAgent.claudeQuota.errorGeneric`),[t]),getRefreshErrorText:(0,pa.useCallback)(e=>{if(va(e))return t(`heteroAgent.claudeQuota.refreshRateLimited`)},[t]),getUnavailableText:s,getWindows:o,sourceKey:r,title:t(`heteroAgent.claudeQuota.title`),tooltip:t(`heteroAgent.claudeQuota.tooltip`)})}),ya.displayName=`ClaudeCodeQuotaMenu`})),J,Y,xa,Sa,Ca,wa,Ta,Ea,Da,Oa,ka=e((()=>{h(),N(),pt(),be(),nt(),J=t(O()),r(),Nr(),aa(),Y=t(C()),xa=300,Sa=10080,Ca=672*60,wa=744*60,Ta=Ne(({css:e})=>({credit:e` 356 min-width: 0; 357 padding-block: 8px; 358 padding-inline: 10px; 359 360 &:not(:last-child) { 361 border-block-end: 1px solid ${k.colorBorderSecondary}; 362 } 363 `,creditExpiry:e` 364 flex: none; 365 text-align: end; 366 white-space: nowrap; 367 `,creditIndex:e` 368 flex: 0 0 20px; 369 font-variant-numeric: tabular-nums; 370 color: ${k.colorTextTertiary}; 371 text-align: center; 372 `,creditList:e` 373 overflow: hidden; 374 border: 1px solid ${k.colorBorderSecondary}; 375 border-radius: ${k.borderRadius}; 376 background: ${k.colorFillQuaternary}; 377 `,creditTitle:e` 378 overflow: hidden; 379 flex: 1; 380 381 min-width: 0; 382 383 text-overflow: ellipsis; 384 white-space: nowrap; 385 `,feedback:e` 386 padding: 8px; 387 border: 1px solid ${k.colorInfoBorder}; 388 border-radius: ${k.borderRadius}; 389 390 color: ${k.colorInfoText}; 391 392 background: ${k.colorInfoBg}; 393 394 &[data-kind='error'] { 395 border-color: ${k.colorErrorBorder}; 396 color: ${k.colorErrorText}; 397 background: ${k.colorErrorBg}; 398 } 399 400 &[data-kind='success'] { 401 border-color: ${k.colorSuccessBorder}; 402 color: ${k.colorSuccessText}; 403 background: ${k.colorSuccessBg}; 404 } 405 `,resetCredits:e` 406 padding-block-start: 8px; 407 border-block-start: 1px solid ${k.colorBorderSecondary}; 408 `})),Ea=e=>({error:e instanceof Error?e.message:String(e),provider:`codex`,rateLimitResetCredits:null,session:null,status:`error`,updatedAt:Date.now(),weekly:null}),Da=(e,t)=>[...e??[]].filter(e=>e.status===`available`&&(e.expiresAt===null||e.expiresAt>t)).sort((e,t)=>
408{let n=(e.expiresAt??1/0)-(t.expiresAt??1/0);return n===0?(e.id??``).localeCompare(t.id??``):n}),Oa=(0,J.memo)(({command:e,env:t})=>{let{t:n}=a(`chat`),r=ra(`codex`,e,t),i=(0,J.useRef)(r),o=(0,J.useRef)(null),[s,c]=(0,J.useState)(),[l,u]=(0,J.useState)(!1);(0,J.useEffect)(()=>{i.current=r,o.current=null,c(void 0),u(!1)},[r]);let d=(0,J.useCallback)(n=>Pr.getCodexQuota({command:e,env:t,...n?.force?{force:!0}:{}}),[e,t]),f=(0,J.useCallback)((e,t)=>e?e.windowMinutes===xa?n(`heteroAgent.codexQuota.fiveHour`):e.windowMinutes===Sa?n(`heteroAgent.quota.weekly`):e.windowMinutes>=Ca&&e.windowMinutes<=wa?n(`heteroAgent.codexQuota.monthly`):t:t,[n]),p=(0,J.useCallback)((e,t,n)=>{let r=f(t,n);return e.limitId.toLowerCase()===`codex`?r:`${e.limitName||e.limitId} · ${r}`},[f]),m=(0,J.useCallback)(e=>e.rateLimits?.length?e.rateLimits.flatMap(e=>{let t=[];return e.primary&&t.push({key:`${e.limitId}:primary`,label:p(e,e.primary,n(`heteroAgent.quota.session`)),window:e.primary}),e.secondary&&t.push({key:`${e.limitId}:secondary`,label:p(e,e.secondary,n(`heteroAgent.quota.weekly`)),window:e.secondary}),t}):[{key:`primary`,label:f(e.session,n(`heteroAgent.quota.session`)),window:e.session},{key:`secondary`,label:f(e.weekly,n(`heteroAgent.quota.weekly`)),window:e.weekly}],[p,f,n]),h=(0,J.useCallback)(e=>!!e.rateLimitResetCredits,[]),g=(0,J.useCallback)(async(r,a,s)=>{let l=o.current,d=l&&l.creditId===r?l:{...r?{creditId:r}:{},idempotencyKey:ee()};o.current=d,c(void 0),u(!0);try{let r=await Pr.consumeCodexRateLimitResetCredit({command:e,...d.creditId?{creditId:d.creditId}:{},env:t,idempotencyKey:d.idempotencyKey});if(i.current!==s)return;switch(a(r.quota),o.current=null,r.outcome){case`alreadyRedeemed`:case`reset`:{let e=n(`heteroAgent.codexQuota.resetSuccess`);c({kind:`success`,text:e}),_e.success(e);break}case`nothingToReset`:c({kind:`info`,text:n(`heteroAgent.codexQuota.resetNothingToReset`)});break;case`noCredit`:c({kind:`error`,text:n(`heteroAgent.codexQuota.resetNoCredit`)});break}}catch(e){if(console.error(`Failed to consume Codex rate-limit reset credit:`,e),i.current!==s)return;let t=n(`heteroAgent.codexQuota.resetFailed`);c({kind:`error`,text:t}),_e.error(t)}finally{i.current===s&&u(!1)}},[e,t,n]),_=(0,J.useCallback)((e,t)=>{let i=r;ft({cancelText:n(`cancel`,{ns:`common`}),content:n(`heteroAgent.codexQuota.resetConfirmDescription`),okText:n(`heteroAgent.codexQuota.resetNow`),onOk:()=>g(e,t,i),title:n(`heteroAgent.codexQuota.resetConfirmTitle`)})},[g,r,n]);return(0,Y.jsx)(ia,{contentWidth:360,createErrorSnapshot:Ea,fetchQuota:d,getWindows:m,hasExtraData:h,renderFooter:(0,J.useCallback)((e,{applyQuota:t,formatDuration:r,now:i})=>{let a=e.rateLimitResetCredits;if(!a)return(0,Y.jsx)(M,{className:Ta.resetCredits,gap:4,children:(0,Y.jsxs)(M,{horizontal:!0,align:`center`,gap:4,children:[(0,Y.jsx)(j,{icon:st,size:14}),(0,Y.jsx)(A,{style:{fontSize:12},type:`secondary`,children:n(`heteroAgent.codexQuota.resetCreditsUnavailable`)})]})});let o=a.availableCount,c=Da(a.credits,i).slice(0,o),u=c[0],d=Array.from({length:o},(e,t)=>({credit:c[t],index:t+1}));return(0,Y.jsxs)(M,{className:Ta.resetCredits,gap:8,children:[(0,Y.jsxs)(M,{gap:2,children:[(0,Y.jsxs)(M,{horizontal:!0,align:`center`,gap:4,children:[(0,Y.jsx)(j,{icon:st,size:14}),(0,Y.jsx)(A,{strong:!0,style:{fontSize:12},children:n(`heteroAgent.codexQuota.resetCredits`,{count:o})})]}),a.totalEarnedCount!==void 0&&(0,Y.jsx)(A,{color:k.colorTextTertiary,style:{fontSize:12},children:n(`heteroAgent.codexQuota.totalEarned`,{count:a.totalEarnedCount})})]}),d.length>0&&(0,Y.jsx)(M,{className:Ta.creditList,children:d.map(({credit:e,index:t})=>{let o=t===1?a.nextExpiresAt:void 0,s=e?e.expiresAt:o,c=s?r(s-i):void 0;return(0,Y.jsxs)(M,{horizontal:!0,align:`center`,className:Ta.credit,gap:8,children:[(0,Y.jsx)(A,{className:Ta.creditIndex,style:{fontSize:12},children:`#${t}`}),(0,Y.jsx)(A,{strong:!0,className:Ta.creditTitle,style:{fontSize:12},children:e?.title||n(`heteroAgent.codexQuota.resetCreditTitle`)}),(0,Y.jsx)(A,{className:Ta.creditExpiry,style:{fontSize:12},type:`secondary`,children:s?c?n(`heteroAgent.codexQuota.expiresIn`,{duration:c}):n(`heteroAgent.codexQuota.expiresSoon`):n(e?`heteroAgent.codexQuota.doesNotExpire`:`heteroAgent.codexQuota.resetCreditDetailsUnavailable`)})]},e?.id??`reset-credit-${t}`)})}),s&&(0,Y.jsx)(`div`,{"aria-live":`polite`,className:Ta.feedback,"data-kind":s.kind,role:s.kind===`error`?`alert`:`status`,children:s.text}),o>0&&(0,Y.jsx)(dt,{block:!0,icon:st,loading:l,size:`small`,type:`primary`,onClick:()=>_(u?.id??void 0,t),children:n(l?`heteroAgent.codexQuota.resetting`:`heteroAgent.codexQuota.resetNow`)})]})},[_,s,l,n]),sourceKey:r,title:n(`heteroAgent.codexQuota.title`),tooltip:n(`heteroAgent.codexQuota.tooltip`)})}),Oa.displayName=`CodexQuotaMenu`})),Aa=e((()=>{ba(),ka()})),ja,Ma,Na,Pa,Fa=e((()=>{ce(),Ut(),N(),be(),nt(),ja=t(O()),r(),vn(),bn(),Hn(),jn(),wt(),Xn(),F(),I(),Aa(),Ma=t(C()),Na=Ne(({css:e})=>({bar:e` 409 container: runtimebar / inline-size; 410 padding-block: 0; 411 padding-inline: 4px; 412 `,fullAccess:e` 413 cursor: default; 414 415 display: flex; 416 flex: none; 417 gap: 6px; 418 align-items: center; 419 420 padding-block: 2px; 421 padding-inline: 4px; 422 border-radius: 4px; 423 424 font-size: 12px; 425 color: ${k.colorTextSecondary}; 426 white-space: nowrap; 427 `,fullAccessLabel:e` 428 @container runtimebar (width < 600px) { 429 display: none; 430 } 431 `,sdkRuntime:e` 432 cursor: default; 433 434 display: flex; 435 flex: none; 436 gap: 6px; 437 align-items: center; 438 439 padding-block: 2px; 440 padding-inline: 4px; 441 border-radius: 4px; 442 443 font-size: 12px; 444 color: ${k.colorInfo}; 445 white-space: nowrap; 446 447 background: color-mix(in srgb, ${k.colorInfoBg} 55%, transparent); 448 `,sdkRuntimeClosing:e` 449 color: ${k.colorTextDescription}; 450 background: ${k.colorFillQuaternary}; 451 `,sdkRuntimeError:e` 452 color: ${k.colorError}; 453 background: color-mix(in srgb, ${k.colorErrorBg} 55%, transparent); 454 `,sdkRuntimeIdle:e` 455 color: ${k.colorTextSecondary}; 456 background: ${k.colorFillQuaternary}; 457 `,sdkRuntimeMonitoring:e` 458 color: ${k.colorWarning}; 459 background: color-mix(in srgb, ${k.colorWarningBg} 55%, transparent); 460 `,sdkRuntimeStale:e` 461 color: ${k.colorWarning}; 462 background: color-mix(in srgb, ${k.colorWarningBg} 55%, transparent); 463 `,leftGroup:e` 464 scrollbar-width: none; 465 overflow: auto hidden; 466 flex: 1; 467 min-width: 0; 468 469 &::-webkit-scrollbar {
470 display: none; 471 } 472 `,rightGroup:e` 473 flex: none; 474 `})),new Set([`starting`,`running`,`monitoring`,`idle`,`stale`,`closing`,`error`]),Pa=(0,ja.memo)(()=>{let{t:e}=a(`chat`),t=Bn(),{canConfigureResource:n,isAccessLoading:r}=Sn(),[i,o]=(0,ja.useState)();Wt(`heteroAgentRuntimeStatus`,e=>{e.transport===`claude-sdk`&&o(e)});let s=P(L.isAgentConfigLoadingById(t)),{agencyConfig:c,workspaceScoped:l}=Jn(t);return r?null:n?t?(0,Ma.jsx)(M,{horizontal:!0,align:`center`,className:Na.bar,children:(0,Ma.jsx)(M,{horizontal:!0,align:`center`,className:Na.leftGroup,gap:4,children:(0,Ma.jsx)(kn,{alwaysShowWorkspace:!0,agentId:t})})}):null:!t||s?null:(0,Ma.jsx)(M,{horizontal:!0,align:`center`,className:Na.bar,children:(0,Ma.jsx)(Cn,{agentId:t})})}),Pa.displayName=`HeteroControlBar`})),Ia,La,Ra,za,Ba=e((()=>{Ia=t(n()),La=[1,3,8,24],Ra=10,za=(e,t=(0,Ia.default)())=>{let n=t.add(e,`hour`).startOf(`hour`);return n.diff(t,`minute`)<Ra?n.add(1,`hour`):n}})),Va,Ha,Ua,Wa,Ga=e((()=>{N(),be(),Va=t(n()),nt(),Ha=t(O()),r(),An(),zn(),On(),fn(),gn(),_t(),Vt(),Ba(),Ua=t(C()),Wa=(0,Ha.memo)(()=>{let{t:e}=a(`chat`),{t}=a(`editor`),{t:n}=a(`verify`),[r,i]=(0,Ha.useState)(!1),[o,s]=Vn(e=>[e.showTypoBar,e.setShowTypoBar]),c=R(e=>e.scheduledSendAt),l=R(e=>e.setScheduledSendAt),u=R(e=>e.context.topicId),d=R(e=>e.context.agentId),f=vt(Lt.enableTopicAcceptance),p=(0,Ha.useCallback)(e=>{l(za(e).toISOString()),i(!1)},[l]),m=(0,Ha.useMemo)(()=>{let r=c?La.find(e=>za(e).isSame((0,Va.default)(c),`minute`)):void 0;return[{children:La.map(t=>({extra:r===t?(0,Ua.jsx)(j,{icon:Ze,size:16,style:{color:k.colorSuccess}}):(0,Ua.jsx)(`span`,{style:{color:k.colorTextTertiary,fontSize:12},children:za(t).format(`MM-DD HH:mm`)}),key:`scheduleSend-${t}h`,label:e(`input.schedule.inHours`,{count:t}),onClick:()=>p(t)})),extra:(0,Ua.jsx)(j,{className:`lobe-submenu-chevron`,icon:qe,size:16}),icon:lt,key:`scheduleSend`,label:e(`input.schedule.title`)},{type:`divider`},{checked:!!o,icon:ct,key:`typo`,label:t(`actions.typobar.title`),onCheckedChange:e=>s(e),type:`switch`},...f?[{type:`divider`},{icon:et,key:`set-topic-goal`,label:n(`acceptance.tray.menuSetGoal`),onClick:()=>{i(!1),u?_n(u):d&&ln.getState().arm(d)}}]:[]]},[e,t,n,o,s,p,c,f,d,u]);return(0,Ua.jsx)(Dn,{icon:Je,open:r,size:{blockSize:32,borderRadius:16,size:18},title:e(`input.heteroPlus.tooltip`),tooltipProps:{placement:`top`},dropdown:{menu:{items:m},minWidth:220,placement:`topLeft`},onOpenChange:i})}),Wa.displayName=`HeteroPlus`})),Ka,qa,Ja,Ya,Xa,Za=e((()=>{N(),be(),Ka=t(n()),nt(),qa=t(O()),r(),On(),Ja=t(C()),Ya=Ne(({css:e})=>({chip:e` 475 flex: none; 476 477 height: 28px; 478 padding-inline: 8px 4px; 479 border-radius: 14px; 480 481 background: ${k.colorInfoBg}; 482 `,label:e` 483 font-size: 12px; 484 line-height: 1; 485 color: ${k.colorInfoText}; 486 white-space: nowrap; 487 `})),Xa=(0,qa.memo)(()=>{let{t:e}=a(`chat`),t=R(e=>e.scheduledSendAt),n=R(e=>e.setScheduledSendAt);return t?(0,Ja.jsxs)(M,{horizontal:!0,align:`center`,className:Ya.chip,gap:4,children:[(0,Ja.jsx)(j,{icon:lt,size:12,style:{color:k.colorInfoText}}),(0,Ja.jsx)(A,{className:Ya.label,children:(0,Ka.default)(t).format(`MM-DD HH:mm`)}),(0,Ja.jsx)(Le,{icon:ut,size:`small`,title:e(`input.schedule.clear`),onClick:()=>n(void 0)})]}):null}),Xa.displayName=`ScheduledSendChip`})),Qa,$a=e((()=>{Qa=({boundDeviceId:e,executionTarget:t,isDesktopClient:n,providerType:r})=>r===`opencode`?t===`local`?n:t===`device`&&!!e:!(t===`auto`||t===`device`||!n&&t===`local`&&e)})),eo,X,to,no,ro,io=e((()=>{Jt(),N(),pt(),eo=t(O()),r(),He(),w(),gi(),T(),Wi(),On(),Zt(),$n(),Wn(),wt(),Xn(),qi(),Kt(),Fa(),Ga(),Za(),$a(),X=t(C()),to=[],no=(0,eo.memo)(({title:e,hint:t,action:n})=>(0,X.jsx)(er,{children:(0,X.jsx)(M,{align:`center`,paddingBlock:`0 8px`,paddingInline:12,children:(0,X.jsx)(Fe,{action:n,style:{maxWidth:880,width:`100%`},type:`warning`,title:(0,X.jsxs)(M,{horizontal:!0,align:`baseline`,gap:6,style:{flexWrap:`wrap`},children:[(0,X.jsx)(`span`,{children:e}),t&&(0,X.jsx)(`span`,{style:{fontWeight:400,opacity:.75},children:t})]})})})})),no.displayName=`GuardBanner`,ro=(0,eo.memo)(()=>{let{t:e}=a(`chat`),t=R(qt.agentId),{isConfigured:n,goToConfig:r}=hi(t),i=Ge(),o=Un(),{agencyConfig:s,isPreferenceLoading:c,workspaceScoped:l}=Jn(t),u=s?.heterogeneousProvider?.type,d=bt(s,{isHetero:!!u,clientExecutionAvailable:!1,workspaceScoped:l}),f=!!u&&Xt(u),p=!!u&&!Et(u)&&d===`none`,m=(u===`claude-code`||u===`codex`||u===`opencode`)&&Qa({boundDeviceId:s?.boundDeviceId,executionTarget:d,isDesktopClient:!1,providerType:u}),h=(0,eo.useMemo)(()=>[{alwaysDisplay:!0,children:(0,X.jsx)(Wa,{}),key:`heteroPlus`},{alwaysDisplay:!0,children:(0,X.jsx)(Xa,{}),key:`scheduledSendChip`}],[]),ee=(0,eo.useMemo)(()=>m?(0,X.jsx)(Ui,{}):void 0,[m]),g=f||d===`device`&&!!s?.boundDeviceId,{status:_,refresh:v}=Ki({agentId:t,enabled:g}),te=()=>{i.aid&&o(ue(`/agent`,i.aid,`profile`))}
487,y=g&&(_===`device-offline`||_===`platform-unavailable`||_===`no-device`),ne=()=>{if(!y)return null;let t,n;if(_===`no-device`)t=e(`platformAgent.deviceGuard.noDevice.title`),n=e(`platformAgent.deviceGuard.noDevice.desc`);else if(_===`device-offline`)t=e(`platformAgent.deviceGuard.deviceOffline.title`),n=e(`platformAgent.deviceGuard.deviceOffline.desc`);else{let r=u&&Yt[u]||u||``;t=e(`platformAgent.deviceGuard.platformUnavailable.title`,{name:r}),n=e(`platformAgent.deviceGuard.platformUnavailable.desc`,{name:r})}return(0,X.jsx)(no,{hint:n,title:t,action:(0,X.jsxs)(M,{horizontal:!0,gap:4,children:[(0,X.jsx)(dt,{size:`small`,type:`fill`,onClick:v,children:e(`platformAgent.deviceGuard.refresh`)}),(0,X.jsx)(dt,{size:`small`,type:`primary`,onClick:te,children:e(`platformAgent.deviceGuard.configure`)})]})})},re=()=>c||p||g||n?null:(0,X.jsx)(no,{hint:e(`heteroAgent.cloudNotConfigured.desc`),title:e(`heteroAgent.cloudNotConfigured.title`),action:(0,X.jsx)(dt,{size:`small`,type:`primary`,onClick:r,children:e(`heteroAgent.cloudNotConfigured.action`)})}),b=()=>p?(0,X.jsx)(no,{title:e(`platformAgent.deviceGuard.noDevice.title`),hint:e(`heteroAgent.executionTarget.sandboxUnsupported`,{name:u?Yt[u]:void 0})}):null,x=c||p||!n&&!g||y,S=p||y||!n&&!g;return(0,X.jsxs)(M,{children:[b(),re(),ne(),(0,X.jsx)(mn,{allowExpand:!1,controlBarSlot:(0,X.jsx)(Pa,{}),extraActionItems:h,leftActions:to,sendAreaPrefix:ee,sendButtonProps:{disabled:x,shape:`round`},skipScrollMarginWithList:!S,onEditorReady:e=>{z.setState({mainInputEditor:e})}})]})}),ro.displayName=`HeterogeneousChatInput`})),ao,oo=e((()=>{rn(),nn(),ao=(e,t)=>tn(n=>!e||!t?!1:en.isModelSupportImageOutput(e,t)(n))})),so,co,lo,uo=e((()=>{N(),pt(),so=t(O()),r(),Zt(),F(),I(),co=t(C()),lo=(0,so.memo)(()=>{let{t:e}=a(`chat`),t=R(qt.agentId),n=P(L.getAgentConfigErrorById(t)),r=P(L.isAgentConfigLoadingById(t)),i=P(e=>e.retryAgentConfigFetch);return!n||!r?null:(0,co.jsx)(Fe,{showIcon:!0,description:n,message:e(`agentConfigError.title`),style:{marginBlockEnd:8},type:`error`,action:(0,co.jsx)(dt,{size:`small`,onClick:()=>i(t),children:e(`agentConfigError.retry`)})})}),lo.displayName=`AgentConfigError`})),fo,Z,po,mo=e((()=>{oe(),N(),nt(),fo=t(O()),r(),On(),gr(),_t(),Vt(),Z=t(C()),po=()=>{let{t:e}=a(`chat`),t=Gt(),n=R(e=>e.editor),[r,i]=vt(e=>[Ht.useCmdEnterToSend(e),e.updatePreference]),s=vt(Rt.getHotkeyById(pe.AddUserMessage)),c=(0,fo.useCallback)(()=>{t.getState().addAIMessage(``),n?.clearContent(),n?.focus()},[t,n]),l=(0,fo.useCallback)(()=>{let e=t.getState(),r=e.inputMessage;r.trim()&&(e.addUserMessage({message:r}),n?.clearContent(),n?.focus())},[t,n]);return hr(l),(0,fo.useMemo)(()=>[{icon:r?(0,Z.jsx)(`div`,{}):(0,Z.jsx)(j,{icon:Ze}),key:`sendWithEnter`,label:(0,Z.jsx)(M,{horizontal:!0,align:`center`,gap:4,children:(0,Z.jsx)(o,{i18nKey:`input.sendWithEnter`,ns:`chat`,components:{key:(0,Z.jsx)(ge,{keys:me.Enter,variant:`borderless`})}})}),onClick:()=>{i({useCmdEnterToSend:!1})}},{icon:r?(0,Z.jsx)(j,{icon:Ze}):(0,Z.jsx)(`div`,{}),key:`sendWithCmdEnter`,label:(0,Z.jsx)(M,{horizontal:!0,align:`center`,gap:4,children:(0,Z.jsx)(o,{i18nKey:`input.sendWithCmdEnter`,ns:`chat`,components:{key:(0,Z.jsx)(ge,{keys:[me.Mod,me.Enter].join(`+`),variant:`borderless`})}})}),onClick:()=>{i({useCmdEnterToSend:!0})}},{type:`divider`},{icon:(0,Z.jsx)(j,{icon:Xe}),key:`addAi`,label:e(`input.addAi`),onClick:c},{icon:(0,Z.jsx)(j,{icon:Ke}),key:`addUser`,label:(0,Z.jsxs)(M,{horizontal:!0,align:`center`,gap:24,children:[e(`input.addUser`),(0,Z.jsx)(ge,{keys:s})]}),onClick:l}],[r,i,s,c,l])}})),ho,go,_o,vo,yo,bo=e((()=>{ho=t(O()),On(),Zt(),oo(),F(),I(),Kt(),_t(),Vt(),uo(),mo(),go=t(C()),_o=[`contextWindow`],vo=[`promptTransform`,`contextWindow`],yo=(0,ho.memo)(()=>{let e=vt(e=>zt.config(e).isDevMode),t=po(),n=R(qt.agentId),r=P(L.getAgentModelById(n)),i=P(L.getAgentModelProviderById(n)),a=P(L.isAgentConfigLoadingById(n)),o=ao(r,i)?vo:_o,s=(0,ho.useMemo)(()=>[`model`,`plus`],[]);return(0,go.jsxs)(go.Fragment,{children:[(0,go.jsx)(lo,{}),(0,go.jsx)(mn,{skipScrollMarginWithList:!0,isConfigLoading:a,leftActions:s,rightActions:o,...e?{sendMenu:{items:t}}:{sendButtonProps:{shape:`round`}},onEditorReady:e=>{z.setState({mainInputEditor:e})}})]})}),yo.displayName=`MainChatInput`})),xo,So=e((()=>{xo=({agentId:e,isAgentConfigLoading:t,messagesInit:n,pendingDispatch:r,routeAgentId:i,topicId:a})=>!r||!e||r.agentId!==e||i&&i!==e?!1:!t&&(!a||n)})),Co,wo,To=e((()=>{Co=t(O()),He(),On(),un(),ur(),So(),dr(),Mn(),F(),I(),wo=()=>{let[e,t,n]=R(e=>[e.sendMessage,e.context,e.messagesInit]),r=t.agentId,[i,a]=We(),o=Ue(),s=P(xt.isAgentConfigLoading),{allowed:c}=Nn(`create_content`),{allowed:l}=Nn(`edit_own_content`),{canUseResource:u,isAccessLoading:d}=Tn(),[f,p]=fr(e=>[e.pendingDispatch,e.clearPendingDispatch]),m=(0,Co.useMemo)(()=>o.pathname?.match(/^\/agent\/([^#/?]+)/)?.[1],[o.pathname]),h=(0,Co.useRef)(null),ee=(0,Co.useRef)(null);return(0,Co.useEffect)(()=>{let o=i.get(`message`);if(!o||!c||!r||m&&m!==r)return;let l=!t.topicId;if(!(!s&&(l||n))||d)return;let f=`${r}::${o}`;h.current!==f&&(h.current=f,a(e=>{let t=new URLSearchParams(e);return t.delete(`message`),t},{replace:!0}),u&&e({message:o}))},[i,a,e,r,c,u,d,t.topicId,s,n,m]),(0,Co.useEffect)(()=>
487{if(!f||!c||d||!xo({agentId:r,isAgentConfigLoading:s,messagesInit:n,pendingDispatch:f,routeAgentId:m,topicId:t.topicId})||ee.current===f.dispatchId)return;if(ee.current=f.dispatchId,!u){let{captureIds:e,dispatchId:t}=f;for(let t of e)lr.remove(t);p(t);return}let{captureIds:i,modelId:a,prompt:o,provider:h}=f,g=i.map(e=>({entry:lr.get(e),id:e})).filter(e=>!!e.entry);(async()=>{try{if(l&&a&&h){let e=P.getState(),t=L.getAgentModelById(r)(e),n=L.getAgentModelProviderById(r)(e);(t!==a||n!==h)&&await e.updateAgentConfigById(r,{model:a,provider:h})}let t=(await Promise.all(g.map(({entry:e})=>e.promise))).filter(e=>!!e);if(!o&&t.length===0)return;await e({files:t,message:o})}finally{for(let{id:e}of g)lr.remove(e);p(f.dispatchId)}})()},[r,c,l,u,p,t.topicId,d,s,n,f,m,e]),null}})),Eo,Do,Oo=e((()=>{Eo=t(O()),x(),cr(),ir(),Kt(),Mt(),Do=(0,Eo.memo)(()=>{let e=S(z),[t,n]=rr(`portalThread`);return e(`portalThreadId`,t),(0,Eo.useLayoutEffect)(()=>{let e=z.subscribe(e=>e.portalThreadId,e=>{n(e||null)});return()=>{e()}},[n]),(0,Eo.useEffect)(()=>{t&&!z.getState().showPortal&&z.getState().pushPortalView({threadId:t,type:kt.Thread})},[t]),sr(z(e=>e.activeTopicId)),null})})),ko,Ao,Q,jo,Mo,No,Po=e((()=>{N(),be(),ko=t(p()),Ao=t(O()),r(),Br(),ii(),Or(),On(),si(),Cr(),yn(),Er(),mr(),nr(),F(),I(),Kt(),Nt(),jt(),pi(),io(),bo(),To(),Oo(),wr(),vr(),Q=t(C()),jo=(0,ko.default)(`lobe-render:agent:ConversationArea`),Mo=Ne(({css:e})=>({floatingHeaderSpacer:e` 488 height: 0; 489 490 @container agent-chat-layout (min-width: 1200px) { 491 height: 44px; 492 } 493 `})),No=(0,Ao.memo)(()=>{let{t:e}=a(`chat`),t=_r(),n=(0,Ao.useMemo)(()=>Dt(t),[t.agentId,t.topicId,t.threadId]),r=z(e=>e.replaceMessages),i=z(e=>e.dbMessagesMap[n]);jo(`contextKey %s: %o`,n,i);let o=tr(t),s=Sr(),c=P(L.isAgentHeterogeneousById(t.agentId)),l=z(At.isActiveThreadSubagent),u=z(e=>t.topicId?Ot.getTopicById(t.topicId)(e)?.metadata?.runningOperation:void 0);pr(t.topicId,u);let d=xr({agentChatConfig:P(Ct.getChatConfigById(t.agentId)),conversationKey:n,threadId:t.threadId??void 0,topicId:t.topicId??void 0}),f=zr(t),p=(0,Ao.useMemo)(()=>Tr(f,d),[f,d]);return(0,Q.jsxs)(hn,{actionsBar:s,context:t,hasInitMessages:!!i,hooks:p,messages:i,operationState:o,onMessagesChange:(e,t)=>
493{r(e,{context:t})},children:[(0,Q.jsx)(M,{flex:1,width:`100%`,style:{overflowX:`hidden`,overflowY:`auto`,position:`relative`},children:(0,Q.jsx)(wn,{defaultWorkflowExpandLevel:c?{streaming:`full`}:void 0,headerSlot:(0,Q.jsx)(`div`,{"aria-hidden":!0,className:Mo.floatingHeaderSpacer}),welcome:(0,Q.jsx)(ri,{}),footerSlot:l?(0,Q.jsx)(M,{horizontal:!0,align:`center`,justify:`center`,paddingBlock:6,paddingInline:16,children:(0,Q.jsx)(`span`,{style:{color:k.colorTextDescription,fontSize:12,textAlign:`center`},children:e(`thread.subagentReadOnlyHint`)})}):void 0})}),!l&&(0,Q.jsx)(En,{children:c?(0,Q.jsx)(ro,{}):(0,Q.jsx)(yo,{})}),(0,Q.jsx)(fi,{}),(0,Q.jsx)(oi,{}),(0,Q.jsx)(Do,{}),(0,Q.jsx)(jr,{}),(0,Q.jsx)(xn,{}),(0,Q.jsx)(Ao.Suspense,{children:(0,Q.jsx)(wo,{})})]})}),No.displayName=`ConversationArea`})),Fo,Io,Lo,Ro,zo=e((()=>{ce(),N(),Fo=t(O()),In(),Pn(),Lr(),Kn(),qn(),F(),I(),Kt(),Po(),Io=t(C()),Lo={flex:1,height:`100%`,minWidth:300,width:`100%`},Ro=(0,Fo.memo)(()=>{let e=P(e=>e.activeAgentId||``),t=P(xt.currentAgentModel),n=P(xt.currentAgentModelProvider);P(xt.isCurrentAgentHeterogeneous),P(Tt.isLocalSystemEnabled);let r=P(yt.inboxAgentId),i=P(t=>e?t.agentMap[e]?.visibility:void 0),{canUseResource:a}=Gn(`agent`,e&&e!==r&&i!==`private`?e:void 0),{handleUploadFiles:o}=Ln({agentId:e,model:t,provider:n});Yn(e),(0,Fo.useCallback)(e=>{let t=z.getState().mainInputEditor?.instance;t&&Ir(t,e)},[]);let s=(0,Io.jsx)(M,{flex:1,height:`100%`,style:{minWidth:0},children:(0,Io.jsx)(ve,{children:(0,Io.jsx)(No,{})})});return(0,Io.jsx)(Fo.Suspense,{fallback:(0,Io.jsx)(Fn,{debugId:`Agent > ChatConversation`}),children:a?(0,Io.jsx)(Rn,{enableLocalPathReference:!1,style:Lo,onLocalPaths:void 0,onUploadFiles:o,children:s}):(0,Io.jsx)(`div`,{style:Lo,children:s})})}),Ro.displayName=`ChatConversation`})),Bo,Vo,Ho,Uo=e((()=>{ce(),Bo=t(O()),He(),pn(),Wn(),ir(),Kt(),Nt(),Vo=e=>{let t=e.toString();return t?`?${t}`:``},Ho=(0,Bo.memo)(()=>{let e=Ue(),t=Un(),n=Ge(),[r]=We(),[i,a]=rr(`thread`,{history:`replace`,throttleMs:500}),o=n.topicId,s=z(e=>e.activeAgentId),c=z(e=>o?Ot.getTopicById(o)(e)?.metadata:void 0),l=z(e=>e.useFetchTopicLinkedPullRequest);dn(),l(s?o:void 0,c),(0,Bo.useLayoutEffect)(()=>{let e=o??null;z.getState().activeTopicId!==e&&z.setState({activeTopicId:e},!1,`ChatHydration/syncTopicFromUrl`)},[o]),(0,Bo.useLayoutEffect)(()=>{let e=i??null;z.getState().activeThreadId!==e&&z.setState({activeThreadId:e},!1,`ChatHydration/syncThreadFromUrl`)},[i]);let u=(0,Bo.useRef)(e),d=(0,Bo.useRef)(n),f=(0,Bo.useRef)(r);return u.current=e,d.current=n,f.current=r,(0,Bo.useLayoutEffect)(()=>{let e=z.subscribe(e=>e.activeTopicId,e=>{let{aid:n,topicId:r}=d.current;if(!n||e===r)return;if(e===void 0&&r){z.setState({activeTopicId:r},!1,`ChatHydration/restoreTopicAfterScopedReset`);return}let i=new URLSearchParams(f.current);i.delete(`topic`);let a=`${e?de(n,e):fe(n)}${Vo(i)}${u.current.hash}`;`${u.current.pathname}${u.current.search}${u.current.hash}`!==a&&t(a,{replace:!0})}),n=z.subscribe(e=>e.activeThreadId,e=>{a(e||null)});return()=>{e(),n()}},[t,a]),null})})),Wo,$,Go,Ko,qo=e((()=>{ae(),N(),pt(),be(),nt(),Wo=t(O()),r(),kr(),le(),_t(),Vt(),$=t(C()),Go=Ne(({css:e,cssVar:t})=>({desc:e` 494 color: ${t.colorTextSecondary}; 495 `,title:e` 496 font-size: 18px; 497 font-weight: bold; 498 `})),Ko=(0,Wo.memo)(({mobile:e})=>{let{t}=a(`common`),n=vt(Ht.isPreferenceInit),[r,i]=vt(e=>[e.useCheckTrace,e.updatePreference]),{data:o,mutate:s}=r(n),c=e=>{i({telemetry:e}),s()};return(0,$.jsxs)(Mr,{mobile:e,show:o,showCloseIcon:!1,children:[(0,$.jsx)(M,{children:(0,$.jsx)(ze,{avatar:(0,$.jsx)(ot,{}),background:k.geekblue1,style:{color:k.geekblue7}})}),(0,$.jsxs)(M,{gap:16,children:[(0,$.jsxs)(M,{gap:12,children:[(0,$.jsx)(M,{className:Go.title,children:t(`telemetry.title`,{appName:D})}),(0,$.jsxs)(`div`,{className:Go.desc,children:[t(`telemetry.desc`,{appName:D}),(0,$.jsx)(`span`,{children:(0,$.jsxs)(`a`,{href:ie,rel:`noreferrer`,target:`_blank`,children:[t(`telemetry.learnMore`),(0,$.jsx)(j,{icon:Qe,style:{marginInlineStart:4}})]})})]})]}),(0,$.jsxs)(M,{horizontal:!0,gap:8,children:[(0,$.jsx)(dt,{type:`primary`,onClick:()=>{c(!0)},children:t(`telemetry.allow`)}),(0,$.jsx)(dt,{type:`text`,onClick:()=>{c(!1)},children:t(`telemetry.deny`)})]})]})]})})})),Jo,Yo,Xo;e((()=>{N(),Jo=t(O()),zo(),Uo(),qo(),Yo=t(C()),Xo=(0,Jo.memo)(()=>(0,Yo.jsxs)(Yo.Fragment,{children:[(0,Yo.jsx)(Ho,{}),(0,Yo.jsx)(M,{height:`100%`,style:{minHeight:0,overflow:`hidden`,position:`relative`},width:`100%`,children:(0,Yo.jsx)(Ro,{})}),(0,Yo.jsx)(Ko,{mobile:!1})]}))}))();export{Xo 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.