nextclaw 0.13.18 → 0.13.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +331 -249
- package/package.json +8 -8
- package/ui-dist/assets/{ChannelsList-BEbqjBdM.js → ChannelsList-CIMYaIji.js} +1 -1
- package/ui-dist/assets/{ChatPage-BaUQCtqU.js → ChatPage-B5UpeEIp.js} +1 -1
- package/ui-dist/assets/{DocBrowser-CtDiU1-0.js → DocBrowser-BJ610SPa.js} +1 -1
- package/ui-dist/assets/{LogoBadge-Cy-EHxZ6.js → LogoBadge-BKq1GKWP.js} +1 -1
- package/ui-dist/assets/{MarketplacePage-D_r1Xy_C.js → MarketplacePage-Bs3sLsgx.js} +1 -1
- package/ui-dist/assets/{McpMarketplacePage-Bftp9zkB.js → McpMarketplacePage-BWTguHCs.js} +1 -1
- package/ui-dist/assets/{ModelConfig-CdFIVFue.js → ModelConfig-B-oTP-Bc.js} +1 -1
- package/ui-dist/assets/ProvidersList-r7bD0-R0.js +1 -0
- package/ui-dist/assets/{RemoteAccessPage-3JbDaO3y.js → RemoteAccessPage-D7On6waK.js} +1 -1
- package/ui-dist/assets/{RuntimeConfig-V2C7bIJt.js → RuntimeConfig-C11xVxH9.js} +1 -1
- package/ui-dist/assets/{SearchConfig-Wq9VNK2x.js → SearchConfig-BVZdCxiM.js} +1 -1
- package/ui-dist/assets/{SecretsConfig-DuYOs4z3.js → SecretsConfig-DuEDdC3X.js} +1 -1
- package/ui-dist/assets/{SessionsConfig-fuPlbwC7.js → SessionsConfig-Y-Blf_-K.js} +1 -1
- package/ui-dist/assets/{chat-message-D729qtQ5.js → chat-message-B6VCCEXF.js} +1 -1
- package/ui-dist/assets/{index-D3eWL7gT.js → index-DvA7S11O.js} +2 -2
- package/ui-dist/assets/{label-DCtPX8p3.js → label-DzwitL78.js} +1 -1
- package/ui-dist/assets/{page-layout-Dr5ymRVA.js → page-layout-DEq5N_8L.js} +1 -1
- package/ui-dist/assets/{popover-YWmgsAlv.js → popover-CY54V8F6.js} +1 -1
- package/ui-dist/assets/provider-models-BOeNnjk9.js +1 -0
- package/ui-dist/assets/{security-config-bwP5X0a-.js → security-config-CgbYP57d.js} +1 -1
- package/ui-dist/assets/{skeleton-C4iXwmBW.js → skeleton-zjQZMWu9.js} +1 -1
- package/ui-dist/assets/{status-dot-SDG0WNvL.js → status-dot-CU_P0tvO.js} +1 -1
- package/ui-dist/assets/{switch-lC_seKUL.js → switch-PvjTvlcs.js} +1 -1
- package/ui-dist/assets/{tabs-custom-LAWD0u69.js → tabs-custom-Bke5J9ny.js} +1 -1
- package/ui-dist/assets/{useConfirmDialog-D0akncY4.js → useConfirmDialog-8tzzp_oW.js} +1 -1
- package/ui-dist/index.html +1 -1
- package/ui-dist/assets/ProvidersList-Bx3w67f2.js +0 -1
- package/ui-dist/assets/provider-models-D3B_xWXx.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,j as t,a3 as oe,bb as ae,bc as ne,X as W,at as ie,$ as le,bd as ce,G as de,ah as ue,be as me}from"./vendor-CmQZsDAE.js";import{n as we,D as Y,t as i,c as X,ar as xe}from"./index-
|
|
1
|
+
import{r as s,j as t,a3 as oe,bb as ae,bc as ne,X as W,at as ie,$ as le,bd as ce,G as de,ah as ue,be as me}from"./vendor-CmQZsDAE.js";import{n as we,D as Y,t as i,c as X,ar as xe}from"./index-DvA7S11O.js";function pe(){const{isOpen:T,mode:g,tabs:F,activeTabId:N,currentTab:x,currentUrl:l,navVersion:p,close:$,toggleMode:A,goBack:I,goForward:O,canGoBack:G,canGoForward:_,navigate:y,syncUrl:S,setActiveTab:V,closeTab:H,openNewTab:q}=we(),[k,j]=s.useState(""),[E,C]=s.useState(!1),[J,h]=s.useState(!1),[d,D]=s.useState(()=>({x:Math.max(40,window.innerWidth-520),y:80})),[n,B]=s.useState({w:480,h:600}),[L,K]=s.useState(420),u=s.useRef(null),m=s.useRef(null),b=s.useRef(null),z=s.useRef(null),P=s.useRef(p),a=(x==null?void 0:x.kind)==="docs";s.useEffect(()=>{if(!a){j("");return}try{const e=new URL(l);j(e.pathname)}catch{j(l)}},[l,N,a]),s.useEffect(()=>{var e;if(a){if(p!==P.current){P.current=p;return}if((e=z.current)!=null&&e.contentWindow)try{const r=new URL(l).pathname;z.current.contentWindow.postMessage({type:"docs-navigate",path:r},"*")}catch{}}},[l,p,a]),s.useEffect(()=>{g==="floating"&&D(e=>({x:Math.max(40,window.innerWidth-n.w-40),y:e.y}))},[g,n.w]),s.useEffect(()=>{const e=r=>{var o;a&&((o=r.data)==null?void 0:o.type)==="docs-route-change"&&typeof r.data.url=="string"&&S(r.data.url)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[S,a]);const Q=s.useCallback(e=>{if(e.preventDefault(),!a)return;const r=k.trim();r&&(r.startsWith("/")?y(`${Y}${r}`):r.startsWith("http")?y(r):y(`${Y}/${r}`))},[k,y,a]),Z=s.useCallback(e=>{g==="floating"&&(C(!0),u.current={startX:e.clientX,startY:e.clientY,startPosX:d.x,startPosY:d.y})},[g,d]);s.useEffect(()=>{if(!E)return;const e=o=>{u.current&&D({x:u.current.startPosX+(o.clientX-u.current.startX),y:u.current.startPosY+(o.clientY-u.current.startY)})},r=()=>{C(!1),u.current=null};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",r),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",r)}},[E]);const M=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),h(!0);const r=e.currentTarget.dataset.axis;m.current={startX:e.clientX,startY:e.clientY,startW:n.w,startH:n.h};const o=w=>{m.current&&B(v=>({w:r==="y"?v.w:Math.max(360,m.current.startW+(w.clientX-m.current.startX)),h:r==="x"?v.h:Math.max(400,m.current.startH+(w.clientY-m.current.startY))}))},f=()=>{h(!1),m.current=null,window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",f)};window.addEventListener("mousemove",o),window.addEventListener("mouseup",f)},[n]),ee=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),h(!0),b.current={startX:e.clientX,startW:L};const r=f=>{if(!b.current)return;const w=b.current.startX-f.clientX;K(Math.max(320,Math.min(860,b.current.startW+w)))},o=()=>{h(!1),b.current=null,window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",o)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",o)},[L]),te=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),h(!0);const r=e.clientX,o=n.w,f=d.x,w=re=>{const se=r-re.clientX,U=Math.max(360,o+se);B(R=>({...R,w:U})),D(R=>({...R,x:f-(U-o)}))},v=()=>{h(!1),window.removeEventListener("mousemove",w),window.removeEventListener("mouseup",v)};window.addEventListener("mousemove",w),window.addEventListener("mouseup",v)},[n.w,d.x]);if(!T)return null;const c=g==="docked";return t.jsxs("div",{className:X("flex flex-col bg-white overflow-hidden relative",c?"h-full border-l border-gray-200 shrink-0":"rounded-2xl shadow-2xl border border-gray-200"),style:c?{width:L}:{position:"fixed",left:d.x,top:d.y,width:n.w,height:n.h,zIndex:9999},children:[c&&t.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:ee}),t.jsxs("div",{className:X("flex items-center justify-between px-4 py-2.5 bg-gray-50 border-b border-gray-200 shrink-0 select-none",!c&&"cursor-grab active:cursor-grabbing"),onMouseDown:c?void 0:Z,children:[t.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[t.jsx(oe,{className:"w-4 h-4 text-primary shrink-0"}),t.jsx("span",{className:"text-sm font-semibold text-gray-900 truncate",children:i("docBrowserTitle")})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:A,className:"hover:bg-gray-200 rounded-md p-1.5 text-gray-500 hover:text-gray-700 transition-colors",title:c?i("docBrowserFloatMode"):i("docBrowserDockMode"),children:c?t.jsx(ae,{className:"w-3.5 h-3.5"}):t.jsx(ne,{className:"w-3.5 h-3.5"})}),t.jsx("button",{onClick:$,className:"hover:bg-gray-200 rounded-md p-1.5 text-gray-500 hover:text-gray-700 transition-colors",title:i("docBrowserClose"),children:t.jsx(W,{className:"w-3.5 h-3.5"})})]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-2 bg-white border-b border-gray-100 overflow-x-auto custom-scrollbar",children:[F.map(e=>{const r=e.id===N;return t.jsxs("div",{className:X("inline-flex items-center gap-1 h-7 px-1.5 rounded-lg text-xs border max-w-[220px] shrink-0 transition-colors",r?"bg-blue-50 border-blue-300 text-blue-700":"bg-gray-50 border-gray-200 text-gray-600 hover:bg-gray-100"),children:[t.jsx("button",{type:"button",onClick:()=>V(e.id),className:"truncate text-left px-1",title:e.title,children:e.title||i("docBrowserTabUntitled")}),t.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),H(e.id)},className:"rounded p-0.5 hover:bg-black/10","aria-label":i("docBrowserCloseTab"),children:t.jsx(W,{className:"w-3 h-3"})})]},e.id)}),t.jsx("button",{onClick:()=>q(void 0,{kind:"docs",title:"Docs"}),className:"inline-flex items-center justify-center w-7 h-7 rounded-lg border border-gray-200 bg-white text-gray-600 hover:bg-gray-100 shrink-0",title:i("docBrowserNewTab"),children:t.jsx(ie,{className:"w-3.5 h-3.5"})})]}),a&&t.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2 bg-white border-b border-gray-100 shrink-0",children:[t.jsx("button",{onClick:I,disabled:!G,className:"p-1.5 rounded-md hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-600 transition-colors",children:t.jsx(le,{className:"w-4 h-4"})}),t.jsx("button",{onClick:O,disabled:!_,className:"p-1.5 rounded-md hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-600 transition-colors",children:t.jsx(ce,{className:"w-4 h-4"})}),t.jsxs("form",{onSubmit:Q,className:"flex-1 relative",children:[t.jsx(de,{className:"w-3.5 h-3.5 absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),t.jsx("input",{type:"text",value:k,onChange:e=>j(e.target.value),placeholder:i("docBrowserSearchPlaceholder"),className:"w-full h-8 pl-8 pr-3 rounded-lg bg-gray-50 border border-gray-200 text-xs text-gray-700 focus:outline-none focus:ring-1 focus:ring-primary/30 focus:border-primary/40 transition-colors placeholder:text-gray-400"})]})]}),t.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[t.jsx("iframe",{ref:z,src:l,className:"absolute inset-0 w-full h-full border-0",title:(x==null?void 0:x.title)||"NextClaw Docs",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms",allow:"clipboard-read; clipboard-write"},`${N}:${p}`),(J||E)&&t.jsx("div",{className:"absolute inset-0 z-10"})]}),a&&xe(l)&&t.jsx("div",{className:"flex items-center justify-between px-4 py-2 bg-gray-50 border-t border-gray-200 shrink-0",children:t.jsxs("a",{href:l,target:"_blank",rel:"noopener noreferrer","data-doc-external":!0,className:"flex items-center gap-1.5 text-xs text-primary hover:text-primary-hover font-medium transition-colors",children:[i("docBrowserOpenExternal"),t.jsx(ue,{className:"w-3 h-3"})]})}),!c&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:te}),t.jsx("div",{className:"absolute top-0 right-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:M,"data-axis":"x"}),t.jsx("div",{className:"absolute bottom-0 left-0 h-1.5 w-full cursor-ns-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:M,"data-axis":"y"}),t.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-se-resize z-30 flex items-center justify-center text-gray-300 hover:text-gray-500 transition-colors",onMouseDown:M,children:t.jsx(me,{className:"w-3 h-3 rotate-[-45deg]"})})]})]})}export{pe as DocBrowser};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as d,j as e}from"./vendor-CmQZsDAE.js";import{c as t}from"./index-
|
|
1
|
+
import{r as d,j as e}from"./vendor-CmQZsDAE.js";import{c as t}from"./index-DvA7S11O.js";function x({name:s,src:o,className:a,imgClassName:r,fallback:l}){const[n,i]=d.useState(!1),c=!!o&&!n;return e.jsx("div",{className:t("inline-flex shrink-0 items-center justify-center overflow-hidden",a),children:c?e.jsx("img",{src:o,alt:`${s} logo`,className:t("block h-6 w-6 object-contain",r),onError:()=>i(!0),draggable:!1}):l??e.jsx("span",{className:"text-lg font-bold uppercase",children:s.slice(0,1)})})}export{x as L};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{u as Ie,f as Ne,g as Re,e as J,r as i,j as s,aL as et,aJ as tt,aK as nt,aM as Me,aP as at,aN as st,aO as A,aQ as Ee,aR as Le,aS as rt,aT as lt,aZ as ot,a_ as it,b8 as ct,b9 as ut,a$ as dt,ba as pt,aD as gt,aE as ft}from"./vendor-CmQZsDAE.js";import{aj as z,t as c,c as De,S as mt,e as xt,f as ht,g as yt,h as Ce,p as bt,n as kt}from"./index-D3eWL7gT.js";import{T as vt}from"./tabs-custom-LAWD0u69.js";import{u as wt}from"./useConfirmDialog-D0akncY4.js";import{S as U}from"./skeleton-C4iXwmBW.js";import{b as Tt,p as oe}from"./marketplace-localization-Dk31LJJJ.js";import{P as St,a as Ct}from"./page-layout-Dr5ymRVA.js";function ne(e){return Array.from(new Set(e.map(t=>t.spec).filter(Boolean)))}function Pt(e){const t=new Date().toISOString();return e.result.type==="skill"?{type:"skill",spec:e.result.spec,id:e.request.skill??e.result.spec,label:e.request.skill??e.result.name??e.result.spec,source:"workspace",installPath:e.request.installPath,installedAt:t}:{type:e.result.type,spec:e.result.spec,id:e.result.name??e.result.spec,label:e.result.name??e.result.spec,source:"marketplace",origin:"marketplace",enabled:e.request.enabled??!0,runtimeStatus:e.request.enabled===!1?"disabled":"ready",installedAt:t}}function ae(e,t){return!!(t.spec&&e.spec===t.spec||t.id&&e.id===t.id)}function $e(e,t){return t??{type:e,total:0,specs:[],records:[]}}function jt(e){const t=$e(e.result.type,e.view),n=Pt(e),a=t.records.findIndex(l=>ae(l,{id:n.id,spec:n.spec})),r=[...t.records];return a>=0?r[a]={...r[a],...n}:r.unshift(n),{...t,type:e.result.type,records:r,specs:ne(r),total:r.length}}function It(e){const t=$e(e.result.type,e.view);if(e.result.action==="uninstall"||e.result.action==="remove"){const a=t.records.filter(r=>!ae(r,{id:e.result.id,spec:e.request.spec}));return{...t,records:a,specs:ne(a),total:a.length}}const n=t.records.map(a=>ae(a,{id:e.result.id,spec:e.request.spec})?e.result.action==="disable"?{...a,enabled:!1,runtimeStatus:"disabled"}:{...a,enabled:!0,runtimeStatus:"ready"}:a);return{...t,records:n,specs:ne(n),total:n.length}}function Y(e){return e==="plugin"?"plugins":e==="skill"?"skills":"mcp"}async function Nt(e){var l,g;const t=new URLSearchParams,n=Y(e.type);(l=e.q)!=null&&l.trim()&&t.set("q",e.q.trim()),(g=e.tag)!=null&&g.trim()&&t.set("tag",e.tag.trim()),e.sort&&t.set("sort",e.sort),typeof e.page=="number"&&Number.isFinite(e.page)&&t.set("page",String(Math.max(1,Math.trunc(e.page)))),typeof e.pageSize=="number"&&Number.isFinite(e.pageSize)&&t.set("pageSize",String(Math.max(1,Math.trunc(e.pageSize))));const a=t.toString(),r=await z.get(a?`/api/marketplace/${n}/items?${a}`:`/api/marketplace/${n}/items`);if(!r.ok)throw new Error(r.error.message);return r.data}async function Rt(e){const t=await z.get(`/api/marketplace/skills/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function Mt(e){const t=await z.get(`/api/marketplace/plugins/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function Et(e){const t=Y(e.type),n=await z.post(`/api/marketplace/${t}/install`,e);if(!n.ok)throw new Error(n.error.message);return n.data}async function Lt(e){const t=Y(e),n=await z.get(`/api/marketplace/${t}/installed`);if(!n.ok)throw new Error(n.error.message);return n.data}async function Dt(e){const t=Y(e.type),n=await z.post(`/api/marketplace/${t}/manage`,e);if(!n.ok)throw new Error(n.error.message);return n.data}function $t(e){return Ie({queryKey:["marketplace-items",e],queryFn:()=>Nt(e),placeholderData:(t,n)=>{var l;const a=(l=n==null?void 0:n.queryKey)==null?void 0:l[1];return!a||typeof a!="object"||a===null?void 0:("type"in a?a.type:void 0)===e.type?t:void 0},staleTime:15e3})}function _t(e){return Ie({queryKey:["marketplace-installed",e],queryFn:()=>Lt(e),staleTime:1e4})}function Ot(){const e=Ne();return Re({mutationFn:t=>Et(t),onSuccess:(t,n)=>{e.setQueryData(["marketplace-installed",t.type],r=>jt({view:r,request:n,result:t})),e.invalidateQueries({queryKey:["marketplace-installed",t.type],refetchType:"inactive"}),t.type==="plugin"&&e.invalidateQueries({queryKey:["ncp-session-types"]});const a=t.type==="plugin"?c("marketplaceInstallSuccessPlugin"):c("marketplaceInstallSuccessSkill");J.success(t.message||a)},onError:t=>{J.error(t.message||c("marketplaceInstallFailed"))}})}function At(){const e=Ne();return Re({mutationFn:t=>Dt(t),onSuccess:(t,n)=>{e.setQueryData(["marketplace-installed",t.type],r=>It({view:r,request:n,result:t})),e.invalidateQueries({queryKey:["marketplace-installed",t.type],refetchType:"inactive"}),t.type==="plugin"&&e.invalidateQueries({queryKey:["ncp-session-types"]});const a=t.action==="enable"?c("marketplaceEnableSuccess"):t.action==="disable"?c("marketplaceDisableSuccess"):c("marketplaceUninstallSuccess");J.success(t.message||a)},onError:t=>{J.error(t.message||c("marketplaceOperationFailed"))}})}var[X]=lt("Tooltip",[Ee]),Z=Ee(),_e="TooltipProvider",Ut=700,se="tooltip.open",[Ft,ie]=X(_e),Oe=e=>{const{__scopeTooltip:t,delayDuration:n=Ut,skipDelayDuration:a=300,disableHoverableContent:r=!1,children:l}=e,g=i.useRef(!0),f=i.useRef(!1),d=i.useRef(0);return i.useEffect(()=>{const k=d.current;return()=>window.clearTimeout(k)},[]),s.jsx(Ft,{scope:t,isOpenDelayedRef:g,delayDuration:n,onOpen:i.useCallback(()=>{window.clearTimeout(d.current),g.current=!1},[]),onClose:i.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>g.current=!0,a)},[a]),isPointerInTransitRef:f,onPointerInTransitChange:i.useCallback(k=>{f.current=k},[]),disableHoverableContent:r,children:l})};Oe.displayName=_e;var K="Tooltip",[qt,G]=X(K),Ae=e=>{const{__scopeTooltip:t,children:n,open:a,defaultOpen:r,onOpenChange:l,disableHoverableContent:g,delayDuration:f}=e,d=ie(K,e.__scopeTooltip),k=Z(t),[u,b]=i.useState(null),v=et(),h=i.useRef(0),w=g??d.disableHoverableContent,m=f??d.delayDuration,S=i.useRef(!1),[j,P]=tt({prop:a,defaultProp:r??!1,onChange:E=>{E?(d.onOpen(),document.dispatchEvent(new CustomEvent(se))):d.onClose(),l==null||l(E)},caller:K}),L=i.useMemo(()=>j?S.current?"delayed-open":"instant-open":"closed",[j]),C=i.useCallback(()=>{window.clearTimeout(h.current),h.current=0,S.current=!1,P(!0)},[P]),M=i.useCallback(()=>{window.clearTimeout(h.current),h.current=0,P(!1)},[P]),$=i.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{S.current=!0,P(!0),h.current=0},m)},[m,P]);return i.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),s.jsx(nt,{...k,children:s.jsx(qt,{scope:t,contentId:v,open:j,stateAttribute:L,trigger:u,onTriggerChange:b,onTriggerEnter:i.useCallback(()=>{d.isOpenDelayedRef.current?$():C()},[d.isOpenDelayedRef,$,C]),onTriggerLeave:i.useCallback(()=>{w?M():(window.clearTimeout(h.current),h.current=0)},[M,w]),onOpen:C,onClose:M,disableHoverableContent:w,children:n})})};Ae.displayName=K;var re="TooltipTrigger",Ue=i.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=G(re,n),l=ie(re,n),g=Z(n),f=i.useRef(null),d=Me(t,f,r.onTriggerChange),k=i.useRef(!1),u=i.useRef(!1),b=i.useCallback(()=>k.current=!1,[]);return i.useEffect(()=>()=>document.removeEventListener("pointerup",b),[b]),s.jsx(at,{asChild:!0,...g,children:s.jsx(st.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...a,ref:d,onPointerMove:A(e.onPointerMove,v=>{v.pointerType!=="touch"&&!u.current&&!l.isPointerInTransitRef.current&&(r.onTriggerEnter(),u.current=!0)}),onPointerLeave:A(e.onPointerLeave,()=>{r.onTriggerLeave(),u.current=!1}),onPointerDown:A(e.onPointerDown,()=>{r.open&&r.onClose(),k.current=!0,document.addEventListener("pointerup",b,{once:!0})}),onFocus:A(e.onFocus,()=>{k.current||r.onOpen()}),onBlur:A(e.onBlur,r.onClose),onClick:A(e.onClick,r.onClose)})})});Ue.displayName=re;var ce="TooltipPortal",[zt,Ht]=X(ce,{forceMount:void 0}),Fe=e=>{const{__scopeTooltip:t,forceMount:n,children:a,container:r}=e,l=G(ce,t);return s.jsx(zt,{scope:t,forceMount:n,children:s.jsx(Le,{present:n||l.open,children:s.jsx(rt,{asChild:!0,container:r,children:a})})})};Fe.displayName=ce;var q="TooltipContent",qe=i.forwardRef((e,t)=>{const n=Ht(q,e.__scopeTooltip),{forceMount:a=n.forceMount,side:r="top",...l}=e,g=G(q,e.__scopeTooltip);return s.jsx(Le,{present:a||g.open,children:g.disableHoverableContent?s.jsx(ze,{side:r,...l,ref:t}):s.jsx(Bt,{side:r,...l,ref:t})})}),Bt=i.forwardRef((e,t)=>{const n=G(q,e.__scopeTooltip),a=ie(q,e.__scopeTooltip),r=i.useRef(null),l=Me(t,r),[g,f]=i.useState(null),{trigger:d,onClose:k}=n,u=r.current,{onPointerInTransitChange:b}=a,v=i.useCallback(()=>{f(null),b(!1)},[b]),h=i.useCallback((w,m)=>{const S=w.currentTarget,j={x:w.clientX,y:w.clientY},P=Jt(j,S.getBoundingClientRect()),L=Yt(j,P),C=Xt(m.getBoundingClientRect()),M=Wt([...L,...C]);f(M),b(!0)},[b]);return i.useEffect(()=>()=>v(),[v]),i.useEffect(()=>{if(d&&u){const w=S=>h(S,u),m=S=>h(S,d);return d.addEventListener("pointerleave",w),u.addEventListener("pointerleave",m),()=>{d.removeEventListener("pointerleave",w),u.removeEventListener("pointerleave",m)}}},[d,u,h,v]),i.useEffect(()=>{if(g){const w=m=>{const S=m.target,j={x:m.clientX,y:m.clientY},P=(d==null?void 0:d.contains(S))||(u==null?void 0:u.contains(S)),L=!Zt(j,g);P?v():L&&(v(),k())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[d,u,g,k,v]),s.jsx(ze,{...e,ref:l})}),[Kt,Gt]=X(K,{isInside:!1}),Vt=ut("TooltipContent"),ze=i.forwardRef((e,t)=>{const{__scopeTooltip:n,children:a,"aria-label":r,onEscapeKeyDown:l,onPointerDownOutside:g,...f}=e,d=G(q,n),k=Z(n),{onClose:u}=d;return i.useEffect(()=>(document.addEventListener(se,u),()=>document.removeEventListener(se,u)),[u]),i.useEffect(()=>{if(d.trigger){const b=v=>{const h=v.target;h!=null&&h.contains(d.trigger)&&u()};return window.addEventListener("scroll",b,{capture:!0}),()=>window.removeEventListener("scroll",b,{capture:!0})}},[d.trigger,u]),s.jsx(ot,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:g,onFocusOutside:b=>b.preventDefault(),onDismiss:u,children:s.jsxs(it,{"data-state":d.stateAttribute,...k,...f,ref:t,style:{...f.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[s.jsx(Vt,{children:a}),s.jsx(Kt,{scope:n,isInside:!0,children:s.jsx(ct,{id:d.contentId,role:"tooltip",children:r||a})})]})})});qe.displayName=q;var He="TooltipArrow",Qt=i.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=Z(n);return Gt(He,n).isInside?null:s.jsx(dt,{...r,...a,ref:t})});Qt.displayName=He;function Jt(e,t){const n=Math.abs(t.top-e.y),a=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),l=Math.abs(t.left-e.x);switch(Math.min(n,a,r,l)){case l:return"left";case r:return"right";case n:return"top";case a:return"bottom";default:throw new Error("unreachable")}}function Yt(e,t,n=5){const a=[];switch(t){case"top":a.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":a.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":a.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":a.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return a}function Xt(e){const{top:t,right:n,bottom:a,left:r}=e;return[{x:r,y:t},{x:n,y:t},{x:n,y:a},{x:r,y:a}]}function Zt(e,t){const{x:n,y:a}=e;let r=!1;for(let l=0,g=t.length-1;l<t.length;g=l++){const f=t[l],d=t[g],k=f.x,u=f.y,b=d.x,v=d.y;u>a!=v>a&&n<(b-k)*(a-u)/(v-u)+k&&(r=!r)}return r}function Wt(e){const t=e.slice();return t.sort((n,a)=>n.x<a.x?-1:n.x>a.x?1:n.y<a.y?-1:n.y>a.y?1:0),en(t)}function en(e){if(e.length<=1)return e.slice();const t=[];for(let a=0;a<e.length;a++){const r=e[a];for(;t.length>=2;){const l=t[t.length-1],g=t[t.length-2];if((l.x-g.x)*(r.y-g.y)>=(l.y-g.y)*(r.x-g.x))t.pop();else break}t.push(r)}t.pop();const n=[];for(let a=e.length-1;a>=0;a--){const r=e[a];for(;n.length>=2;){const l=n[n.length-1],g=n[n.length-2];if((l.x-g.x)*(r.y-g.y)>=(l.y-g.y)*(r.x-g.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var tn=Oe,nn=Ae,an=Ue,sn=Fe,Be=qe;const rn=tn,ee=nn,te=an,Q=i.forwardRef(({className:e,sideOffset:t=4,...n},a)=>s.jsx(sn,{children:s.jsx(Be,{ref:a,sideOffset:t,className:De("z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Q.displayName=Be.displayName;function ln(e){return s.jsx("div",{className:"mb-4",children:s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsxs("div",{className:"flex-1 min-w-0 relative",children:[s.jsx(pt,{className:"h-4 w-4 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2"}),s.jsx("input",{value:e.searchText,onChange:t=>e.onSearchTextChange(t.target.value),placeholder:e.searchPlaceholder,className:"w-full h-9 border border-gray-200/80 rounded-xl pl-9 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-primary/40"})]}),e.scope==="all"&&s.jsxs(mt,{value:e.sort,onValueChange:t=>e.onSortChange(t),children:[s.jsx(xt,{className:"h-9 w-[150px] shrink-0 rounded-lg",children:s.jsx(ht,{})}),s.jsxs(yt,{children:[s.jsx(Ce,{value:"relevance",children:c("marketplaceSortRelevance")}),s.jsx(Ce,{value:"updated",children:c("marketplaceSortUpdated")})]})]})]})})}function on(e){return s.jsx(s.Fragment,{children:Array.from({length:e.count},(t,n)=>s.jsx("article",{className:"rounded-2xl border border-gray-200/40 bg-white px-5 py-4 shadow-sm",children:s.jsxs("div",{className:"flex items-start gap-3.5 justify-between",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 gap-3",children:[s.jsx(U,{className:"h-10 w-10 shrink-0 rounded-xl"}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-2 pt-0.5",children:[s.jsx(U,{className:"h-4 w-32 max-w-[70%]"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(U,{className:"h-3 w-12"}),s.jsx(U,{className:"h-3 w-24"})]}),s.jsx(U,{className:"h-3 w-full"})]})]}),s.jsx(U,{className:"h-8 w-20 shrink-0 rounded-xl"})]})},`marketplace-skeleton-${n}`))})}function cn(e){return s.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2",children:[s.jsx("button",{className:"h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40",onClick:e.onPrev,disabled:e.page<=1||e.busy,children:c("prev")}),s.jsx("div",{className:"text-sm text-gray-600 min-w-20 text-center",children:e.totalPages===0?"0 / 0":`${e.page} / ${e.totalPages}`}),s.jsx("button",{className:"h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40",onClick:e.onNext,disabled:e.totalPages===0||e.page>=e.totalPages||e.busy,children:c("next")})]})}const Ke=12,un=Ke;function le(e){return(e??"").trim().toLowerCase()}function F(e,t){const n=le(t);return n.length>0?`${e}:${n}`:""}function dn(e){const t=new Map;for(const n of e){const a=[n.install.spec,n.slug,n.id];for(const r of a){const l=F(n.type,r);!l||t.has(l)||t.set(l,n)}}return t}function pn(e){const t=new Map;for(const n of e){const a=[n.spec,n.id,n.label];for(const r of a){const l=F(n.type,r);!l||t.has(l)||t.set(l,n)}}return t}function Pe(e,t){const n=[e.install.spec,e.slug,e.id];for(const a of n){const r=F(e.type,a);if(!r)continue;const l=t.get(r);if(l)return l}}function gn(e,t){const n=t.get(F(e.type,e.spec));if(n)return n;const a=t.get(F(e.type,e.id));return a||t.get(F(e.type,e.label))}function fn(e,t,n,a){const r=le(n);if(!r)return!0;const l=oe(t==null?void 0:t.summaryI18n,t==null?void 0:t.summary,a);return[e.id,e.spec,e.label,t==null?void 0:t.name,t==null?void 0:t.slug,t==null?void 0:t.summary,l,...(t==null?void 0:t.tags)??[]].map(f=>le(f)).filter(Boolean).some(f=>f.includes(r))}function mn(e){const t=["bg-amber-600","bg-orange-500","bg-yellow-600","bg-emerald-600","bg-teal-600","bg-cyan-600","bg-stone-600","bg-rose-500","bg-violet-500"];let n=0;for(let a=0;a<e.length;a++)n=e.charCodeAt(a)+((n<<5)-n);return t[Math.abs(n)%t.length]}function xn({name:e,fallback:t}){const n=e||t,a=n.substring(0,2).toUpperCase(),r=mn(n);return s.jsx("div",{className:De("flex items-center justify-center w-10 h-10 rounded-xl text-white font-semibold text-sm shrink-0",r),children:a})}function I(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function B(e){var f,d,k,u;const t=((f=e.metadataRaw)==null?void 0:f.trim())||"-",n=((d=e.contentRaw)==null?void 0:d.trim())||"-",a=(k=e.summary)==null?void 0:k.trim(),r=(u=e.description)==null?void 0:u.trim(),l=!!r&&r!==a,g=`<!doctype html>
|
|
1
|
+
import{u as Ie,f as Ne,g as Re,e as J,r as i,j as s,aL as et,aJ as tt,aK as nt,aM as Me,aP as at,aN as st,aO as A,aQ as Ee,aR as Le,aS as rt,aT as lt,aZ as ot,a_ as it,b8 as ct,b9 as ut,a$ as dt,ba as pt,aD as gt,aE as ft}from"./vendor-CmQZsDAE.js";import{aj as z,t as c,c as De,S as mt,e as xt,f as ht,g as yt,h as Ce,p as bt,n as kt}from"./index-DvA7S11O.js";import{T as vt}from"./tabs-custom-Bke5J9ny.js";import{u as wt}from"./useConfirmDialog-8tzzp_oW.js";import{S as U}from"./skeleton-zjQZMWu9.js";import{b as Tt,p as oe}from"./marketplace-localization-Dk31LJJJ.js";import{P as St,a as Ct}from"./page-layout-DEq5N_8L.js";function ne(e){return Array.from(new Set(e.map(t=>t.spec).filter(Boolean)))}function Pt(e){const t=new Date().toISOString();return e.result.type==="skill"?{type:"skill",spec:e.result.spec,id:e.request.skill??e.result.spec,label:e.request.skill??e.result.name??e.result.spec,source:"workspace",installPath:e.request.installPath,installedAt:t}:{type:e.result.type,spec:e.result.spec,id:e.result.name??e.result.spec,label:e.result.name??e.result.spec,source:"marketplace",origin:"marketplace",enabled:e.request.enabled??!0,runtimeStatus:e.request.enabled===!1?"disabled":"ready",installedAt:t}}function ae(e,t){return!!(t.spec&&e.spec===t.spec||t.id&&e.id===t.id)}function $e(e,t){return t??{type:e,total:0,specs:[],records:[]}}function jt(e){const t=$e(e.result.type,e.view),n=Pt(e),a=t.records.findIndex(l=>ae(l,{id:n.id,spec:n.spec})),r=[...t.records];return a>=0?r[a]={...r[a],...n}:r.unshift(n),{...t,type:e.result.type,records:r,specs:ne(r),total:r.length}}function It(e){const t=$e(e.result.type,e.view);if(e.result.action==="uninstall"||e.result.action==="remove"){const a=t.records.filter(r=>!ae(r,{id:e.result.id,spec:e.request.spec}));return{...t,records:a,specs:ne(a),total:a.length}}const n=t.records.map(a=>ae(a,{id:e.result.id,spec:e.request.spec})?e.result.action==="disable"?{...a,enabled:!1,runtimeStatus:"disabled"}:{...a,enabled:!0,runtimeStatus:"ready"}:a);return{...t,records:n,specs:ne(n),total:n.length}}function Y(e){return e==="plugin"?"plugins":e==="skill"?"skills":"mcp"}async function Nt(e){var l,g;const t=new URLSearchParams,n=Y(e.type);(l=e.q)!=null&&l.trim()&&t.set("q",e.q.trim()),(g=e.tag)!=null&&g.trim()&&t.set("tag",e.tag.trim()),e.sort&&t.set("sort",e.sort),typeof e.page=="number"&&Number.isFinite(e.page)&&t.set("page",String(Math.max(1,Math.trunc(e.page)))),typeof e.pageSize=="number"&&Number.isFinite(e.pageSize)&&t.set("pageSize",String(Math.max(1,Math.trunc(e.pageSize))));const a=t.toString(),r=await z.get(a?`/api/marketplace/${n}/items?${a}`:`/api/marketplace/${n}/items`);if(!r.ok)throw new Error(r.error.message);return r.data}async function Rt(e){const t=await z.get(`/api/marketplace/skills/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function Mt(e){const t=await z.get(`/api/marketplace/plugins/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function Et(e){const t=Y(e.type),n=await z.post(`/api/marketplace/${t}/install`,e);if(!n.ok)throw new Error(n.error.message);return n.data}async function Lt(e){const t=Y(e),n=await z.get(`/api/marketplace/${t}/installed`);if(!n.ok)throw new Error(n.error.message);return n.data}async function Dt(e){const t=Y(e.type),n=await z.post(`/api/marketplace/${t}/manage`,e);if(!n.ok)throw new Error(n.error.message);return n.data}function $t(e){return Ie({queryKey:["marketplace-items",e],queryFn:()=>Nt(e),placeholderData:(t,n)=>{var l;const a=(l=n==null?void 0:n.queryKey)==null?void 0:l[1];return!a||typeof a!="object"||a===null?void 0:("type"in a?a.type:void 0)===e.type?t:void 0},staleTime:15e3})}function _t(e){return Ie({queryKey:["marketplace-installed",e],queryFn:()=>Lt(e),staleTime:1e4})}function Ot(){const e=Ne();return Re({mutationFn:t=>Et(t),onSuccess:(t,n)=>{e.setQueryData(["marketplace-installed",t.type],r=>jt({view:r,request:n,result:t})),e.invalidateQueries({queryKey:["marketplace-installed",t.type],refetchType:"inactive"}),t.type==="plugin"&&e.invalidateQueries({queryKey:["ncp-session-types"]});const a=t.type==="plugin"?c("marketplaceInstallSuccessPlugin"):c("marketplaceInstallSuccessSkill");J.success(t.message||a)},onError:t=>{J.error(t.message||c("marketplaceInstallFailed"))}})}function At(){const e=Ne();return Re({mutationFn:t=>Dt(t),onSuccess:(t,n)=>{e.setQueryData(["marketplace-installed",t.type],r=>It({view:r,request:n,result:t})),e.invalidateQueries({queryKey:["marketplace-installed",t.type],refetchType:"inactive"}),t.type==="plugin"&&e.invalidateQueries({queryKey:["ncp-session-types"]});const a=t.action==="enable"?c("marketplaceEnableSuccess"):t.action==="disable"?c("marketplaceDisableSuccess"):c("marketplaceUninstallSuccess");J.success(t.message||a)},onError:t=>{J.error(t.message||c("marketplaceOperationFailed"))}})}var[X]=lt("Tooltip",[Ee]),Z=Ee(),_e="TooltipProvider",Ut=700,se="tooltip.open",[Ft,ie]=X(_e),Oe=e=>{const{__scopeTooltip:t,delayDuration:n=Ut,skipDelayDuration:a=300,disableHoverableContent:r=!1,children:l}=e,g=i.useRef(!0),f=i.useRef(!1),d=i.useRef(0);return i.useEffect(()=>{const k=d.current;return()=>window.clearTimeout(k)},[]),s.jsx(Ft,{scope:t,isOpenDelayedRef:g,delayDuration:n,onOpen:i.useCallback(()=>{window.clearTimeout(d.current),g.current=!1},[]),onClose:i.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>g.current=!0,a)},[a]),isPointerInTransitRef:f,onPointerInTransitChange:i.useCallback(k=>{f.current=k},[]),disableHoverableContent:r,children:l})};Oe.displayName=_e;var K="Tooltip",[qt,G]=X(K),Ae=e=>{const{__scopeTooltip:t,children:n,open:a,defaultOpen:r,onOpenChange:l,disableHoverableContent:g,delayDuration:f}=e,d=ie(K,e.__scopeTooltip),k=Z(t),[u,b]=i.useState(null),v=et(),h=i.useRef(0),w=g??d.disableHoverableContent,m=f??d.delayDuration,S=i.useRef(!1),[j,P]=tt({prop:a,defaultProp:r??!1,onChange:E=>{E?(d.onOpen(),document.dispatchEvent(new CustomEvent(se))):d.onClose(),l==null||l(E)},caller:K}),L=i.useMemo(()=>j?S.current?"delayed-open":"instant-open":"closed",[j]),C=i.useCallback(()=>{window.clearTimeout(h.current),h.current=0,S.current=!1,P(!0)},[P]),M=i.useCallback(()=>{window.clearTimeout(h.current),h.current=0,P(!1)},[P]),$=i.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{S.current=!0,P(!0),h.current=0},m)},[m,P]);return i.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),s.jsx(nt,{...k,children:s.jsx(qt,{scope:t,contentId:v,open:j,stateAttribute:L,trigger:u,onTriggerChange:b,onTriggerEnter:i.useCallback(()=>{d.isOpenDelayedRef.current?$():C()},[d.isOpenDelayedRef,$,C]),onTriggerLeave:i.useCallback(()=>{w?M():(window.clearTimeout(h.current),h.current=0)},[M,w]),onOpen:C,onClose:M,disableHoverableContent:w,children:n})})};Ae.displayName=K;var re="TooltipTrigger",Ue=i.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=G(re,n),l=ie(re,n),g=Z(n),f=i.useRef(null),d=Me(t,f,r.onTriggerChange),k=i.useRef(!1),u=i.useRef(!1),b=i.useCallback(()=>k.current=!1,[]);return i.useEffect(()=>()=>document.removeEventListener("pointerup",b),[b]),s.jsx(at,{asChild:!0,...g,children:s.jsx(st.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...a,ref:d,onPointerMove:A(e.onPointerMove,v=>{v.pointerType!=="touch"&&!u.current&&!l.isPointerInTransitRef.current&&(r.onTriggerEnter(),u.current=!0)}),onPointerLeave:A(e.onPointerLeave,()=>{r.onTriggerLeave(),u.current=!1}),onPointerDown:A(e.onPointerDown,()=>{r.open&&r.onClose(),k.current=!0,document.addEventListener("pointerup",b,{once:!0})}),onFocus:A(e.onFocus,()=>{k.current||r.onOpen()}),onBlur:A(e.onBlur,r.onClose),onClick:A(e.onClick,r.onClose)})})});Ue.displayName=re;var ce="TooltipPortal",[zt,Ht]=X(ce,{forceMount:void 0}),Fe=e=>{const{__scopeTooltip:t,forceMount:n,children:a,container:r}=e,l=G(ce,t);return s.jsx(zt,{scope:t,forceMount:n,children:s.jsx(Le,{present:n||l.open,children:s.jsx(rt,{asChild:!0,container:r,children:a})})})};Fe.displayName=ce;var q="TooltipContent",qe=i.forwardRef((e,t)=>{const n=Ht(q,e.__scopeTooltip),{forceMount:a=n.forceMount,side:r="top",...l}=e,g=G(q,e.__scopeTooltip);return s.jsx(Le,{present:a||g.open,children:g.disableHoverableContent?s.jsx(ze,{side:r,...l,ref:t}):s.jsx(Bt,{side:r,...l,ref:t})})}),Bt=i.forwardRef((e,t)=>{const n=G(q,e.__scopeTooltip),a=ie(q,e.__scopeTooltip),r=i.useRef(null),l=Me(t,r),[g,f]=i.useState(null),{trigger:d,onClose:k}=n,u=r.current,{onPointerInTransitChange:b}=a,v=i.useCallback(()=>{f(null),b(!1)},[b]),h=i.useCallback((w,m)=>{const S=w.currentTarget,j={x:w.clientX,y:w.clientY},P=Jt(j,S.getBoundingClientRect()),L=Yt(j,P),C=Xt(m.getBoundingClientRect()),M=Wt([...L,...C]);f(M),b(!0)},[b]);return i.useEffect(()=>()=>v(),[v]),i.useEffect(()=>{if(d&&u){const w=S=>h(S,u),m=S=>h(S,d);return d.addEventListener("pointerleave",w),u.addEventListener("pointerleave",m),()=>{d.removeEventListener("pointerleave",w),u.removeEventListener("pointerleave",m)}}},[d,u,h,v]),i.useEffect(()=>{if(g){const w=m=>{const S=m.target,j={x:m.clientX,y:m.clientY},P=(d==null?void 0:d.contains(S))||(u==null?void 0:u.contains(S)),L=!Zt(j,g);P?v():L&&(v(),k())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[d,u,g,k,v]),s.jsx(ze,{...e,ref:l})}),[Kt,Gt]=X(K,{isInside:!1}),Vt=ut("TooltipContent"),ze=i.forwardRef((e,t)=>{const{__scopeTooltip:n,children:a,"aria-label":r,onEscapeKeyDown:l,onPointerDownOutside:g,...f}=e,d=G(q,n),k=Z(n),{onClose:u}=d;return i.useEffect(()=>(document.addEventListener(se,u),()=>document.removeEventListener(se,u)),[u]),i.useEffect(()=>{if(d.trigger){const b=v=>{const h=v.target;h!=null&&h.contains(d.trigger)&&u()};return window.addEventListener("scroll",b,{capture:!0}),()=>window.removeEventListener("scroll",b,{capture:!0})}},[d.trigger,u]),s.jsx(ot,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:g,onFocusOutside:b=>b.preventDefault(),onDismiss:u,children:s.jsxs(it,{"data-state":d.stateAttribute,...k,...f,ref:t,style:{...f.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[s.jsx(Vt,{children:a}),s.jsx(Kt,{scope:n,isInside:!0,children:s.jsx(ct,{id:d.contentId,role:"tooltip",children:r||a})})]})})});qe.displayName=q;var He="TooltipArrow",Qt=i.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=Z(n);return Gt(He,n).isInside?null:s.jsx(dt,{...r,...a,ref:t})});Qt.displayName=He;function Jt(e,t){const n=Math.abs(t.top-e.y),a=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),l=Math.abs(t.left-e.x);switch(Math.min(n,a,r,l)){case l:return"left";case r:return"right";case n:return"top";case a:return"bottom";default:throw new Error("unreachable")}}function Yt(e,t,n=5){const a=[];switch(t){case"top":a.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":a.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":a.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":a.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return a}function Xt(e){const{top:t,right:n,bottom:a,left:r}=e;return[{x:r,y:t},{x:n,y:t},{x:n,y:a},{x:r,y:a}]}function Zt(e,t){const{x:n,y:a}=e;let r=!1;for(let l=0,g=t.length-1;l<t.length;g=l++){const f=t[l],d=t[g],k=f.x,u=f.y,b=d.x,v=d.y;u>a!=v>a&&n<(b-k)*(a-u)/(v-u)+k&&(r=!r)}return r}function Wt(e){const t=e.slice();return t.sort((n,a)=>n.x<a.x?-1:n.x>a.x?1:n.y<a.y?-1:n.y>a.y?1:0),en(t)}function en(e){if(e.length<=1)return e.slice();const t=[];for(let a=0;a<e.length;a++){const r=e[a];for(;t.length>=2;){const l=t[t.length-1],g=t[t.length-2];if((l.x-g.x)*(r.y-g.y)>=(l.y-g.y)*(r.x-g.x))t.pop();else break}t.push(r)}t.pop();const n=[];for(let a=e.length-1;a>=0;a--){const r=e[a];for(;n.length>=2;){const l=n[n.length-1],g=n[n.length-2];if((l.x-g.x)*(r.y-g.y)>=(l.y-g.y)*(r.x-g.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var tn=Oe,nn=Ae,an=Ue,sn=Fe,Be=qe;const rn=tn,ee=nn,te=an,Q=i.forwardRef(({className:e,sideOffset:t=4,...n},a)=>s.jsx(sn,{children:s.jsx(Be,{ref:a,sideOffset:t,className:De("z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Q.displayName=Be.displayName;function ln(e){return s.jsx("div",{className:"mb-4",children:s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsxs("div",{className:"flex-1 min-w-0 relative",children:[s.jsx(pt,{className:"h-4 w-4 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2"}),s.jsx("input",{value:e.searchText,onChange:t=>e.onSearchTextChange(t.target.value),placeholder:e.searchPlaceholder,className:"w-full h-9 border border-gray-200/80 rounded-xl pl-9 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-primary/40"})]}),e.scope==="all"&&s.jsxs(mt,{value:e.sort,onValueChange:t=>e.onSortChange(t),children:[s.jsx(xt,{className:"h-9 w-[150px] shrink-0 rounded-lg",children:s.jsx(ht,{})}),s.jsxs(yt,{children:[s.jsx(Ce,{value:"relevance",children:c("marketplaceSortRelevance")}),s.jsx(Ce,{value:"updated",children:c("marketplaceSortUpdated")})]})]})]})})}function on(e){return s.jsx(s.Fragment,{children:Array.from({length:e.count},(t,n)=>s.jsx("article",{className:"rounded-2xl border border-gray-200/40 bg-white px-5 py-4 shadow-sm",children:s.jsxs("div",{className:"flex items-start gap-3.5 justify-between",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 gap-3",children:[s.jsx(U,{className:"h-10 w-10 shrink-0 rounded-xl"}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-2 pt-0.5",children:[s.jsx(U,{className:"h-4 w-32 max-w-[70%]"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(U,{className:"h-3 w-12"}),s.jsx(U,{className:"h-3 w-24"})]}),s.jsx(U,{className:"h-3 w-full"})]})]}),s.jsx(U,{className:"h-8 w-20 shrink-0 rounded-xl"})]})},`marketplace-skeleton-${n}`))})}function cn(e){return s.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2",children:[s.jsx("button",{className:"h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40",onClick:e.onPrev,disabled:e.page<=1||e.busy,children:c("prev")}),s.jsx("div",{className:"text-sm text-gray-600 min-w-20 text-center",children:e.totalPages===0?"0 / 0":`${e.page} / ${e.totalPages}`}),s.jsx("button",{className:"h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40",onClick:e.onNext,disabled:e.totalPages===0||e.page>=e.totalPages||e.busy,children:c("next")})]})}const Ke=12,un=Ke;function le(e){return(e??"").trim().toLowerCase()}function F(e,t){const n=le(t);return n.length>0?`${e}:${n}`:""}function dn(e){const t=new Map;for(const n of e){const a=[n.install.spec,n.slug,n.id];for(const r of a){const l=F(n.type,r);!l||t.has(l)||t.set(l,n)}}return t}function pn(e){const t=new Map;for(const n of e){const a=[n.spec,n.id,n.label];for(const r of a){const l=F(n.type,r);!l||t.has(l)||t.set(l,n)}}return t}function Pe(e,t){const n=[e.install.spec,e.slug,e.id];for(const a of n){const r=F(e.type,a);if(!r)continue;const l=t.get(r);if(l)return l}}function gn(e,t){const n=t.get(F(e.type,e.spec));if(n)return n;const a=t.get(F(e.type,e.id));return a||t.get(F(e.type,e.label))}function fn(e,t,n,a){const r=le(n);if(!r)return!0;const l=oe(t==null?void 0:t.summaryI18n,t==null?void 0:t.summary,a);return[e.id,e.spec,e.label,t==null?void 0:t.name,t==null?void 0:t.slug,t==null?void 0:t.summary,l,...(t==null?void 0:t.tags)??[]].map(f=>le(f)).filter(Boolean).some(f=>f.includes(r))}function mn(e){const t=["bg-amber-600","bg-orange-500","bg-yellow-600","bg-emerald-600","bg-teal-600","bg-cyan-600","bg-stone-600","bg-rose-500","bg-violet-500"];let n=0;for(let a=0;a<e.length;a++)n=e.charCodeAt(a)+((n<<5)-n);return t[Math.abs(n)%t.length]}function xn({name:e,fallback:t}){const n=e||t,a=n.substring(0,2).toUpperCase(),r=mn(n);return s.jsx("div",{className:De("flex items-center justify-center w-10 h-10 rounded-xl text-white font-semibold text-sm shrink-0",r),children:a})}function I(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function B(e){var f,d,k,u;const t=((f=e.metadataRaw)==null?void 0:f.trim())||"-",n=((d=e.contentRaw)==null?void 0:d.trim())||"-",a=(k=e.summary)==null?void 0:k.trim(),r=(u=e.description)==null?void 0:u.trim(),l=!!r&&r!==a,g=`<!doctype html>
|
|
2
2
|
<html>
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8" />
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{u as ae,f as te,g as R,e as C,r as m,j as a}from"./vendor-CmQZsDAE.js";import{P as he,a as fe}from"./page-layout-
|
|
1
|
+
import{u as ae,f as te,g as R,e as C,r as m,j as a}from"./vendor-CmQZsDAE.js";import{P as he,a as fe}from"./page-layout-DEq5N_8L.js";import{T as ye}from"./tabs-custom-Bke5J9ny.js";import{aj as v,t as n,p as be,n as ke,I as P,S as je,e as ve,f as we,g as Me,h as X,c as Ne,ak as se,al as ne,am as re,an as le,ao as ce,ap as Se,B as Y}from"./index-DvA7S11O.js";import{S as Ce}from"./switch-PvjTvlcs.js";import{S}from"./skeleton-zjQZMWu9.js";import{u as Ie}from"./useConfirmDialog-8tzzp_oW.js";import{b as De,p as Te,a as Pe}from"./marketplace-localization-Dk31LJJJ.js";async function Re(e){var d,o;const t=new URLSearchParams;(d=e.q)!=null&&d.trim()&&t.set("q",e.q.trim()),(o=e.tag)!=null&&o.trim()&&t.set("tag",e.tag.trim()),e.sort&&t.set("sort",e.sort),typeof e.page=="number"&&Number.isFinite(e.page)&&t.set("page",String(Math.max(1,Math.trunc(e.page)))),typeof e.pageSize=="number"&&Number.isFinite(e.pageSize)&&t.set("pageSize",String(Math.max(1,Math.trunc(e.pageSize))));const c=t.toString(),i=await v.get(c?`/api/marketplace/mcp/items?${c}`:"/api/marketplace/mcp/items");if(!i.ok)throw new Error(i.error.message);return i.data}async function qe(){const e=await v.get("/api/marketplace/mcp/installed");if(!e.ok)throw new Error(e.error.message);return e.data}async function Ee(e){const t=await v.get(`/api/marketplace/mcp/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function Fe(e){const t=await v.post("/api/marketplace/mcp/install",{type:"mcp",...e});if(!t.ok)throw new Error(t.error.message);return t.data}async function $e(e){const t=await v.post("/api/marketplace/mcp/manage",{type:"mcp",...e});if(!t.ok)throw new Error(t.error.message);return t.data}async function Le(e){const t=await v.post("/api/marketplace/mcp/doctor",{name:e});if(!t.ok)throw new Error(t.error.message);return t.data}function ze(e){return ae({queryKey:["marketplace-mcp-items",e],queryFn:()=>Re(e),staleTime:15e3})}function Ae(){return ae({queryKey:["marketplace-mcp-installed"],queryFn:()=>qe(),staleTime:1e4})}function Oe(){const e=te();return R({mutationFn:Fe,onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-mcp-installed"]}),e.invalidateQueries({queryKey:["marketplace-mcp-items"]}),e.invalidateQueries({queryKey:["marketplace-mcp-doctor"]}),C.success(t.message||n("marketplaceInstallSuccessMcp"))},onError:t=>{C.error(t.message||n("marketplaceInstallFailed"))}})}function Qe(){const e=te();return R({mutationFn:$e,onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-mcp-installed"]}),e.invalidateQueries({queryKey:["marketplace-mcp-items"]}),e.invalidateQueries({queryKey:["marketplace-mcp-doctor"]}),C.success(t.message||n("marketplaceMcpManageSuccess"))},onError:t=>{C.error(t.message||n("marketplaceOperationFailed"))}})}const Ke=12;function oe(e){return(e??"").trim().toLowerCase()}function Ue(e){const t=new Map;for(const c of e){const i=[c.catalogSlug,c.spec,c.id,c.label];for(const d of i){const o=oe(d);!o||t.has(o)||t.set(o,c)}}return t}function Be(e,t){const c=[e.slug,e.install.spec,e.id,e.name];for(const i of c){const d=oe(i);if(!d)continue;const o=t.get(d);if(o)return o}}function T(e,t,c,i,d){const o=k=>k.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),y=`<!doctype html>
|
|
2
2
|
<html>
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8" />
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,j as e,ac as W,v as z,F as q,a3 as G,ad as K,ae as Y}from"./vendor-CmQZsDAE.js";import{I as A,c as L,u as $,a as J,b as Q,d as X,t as m,C as U,S as Z,e as H,f as ee,g as se,h as te,D as ae,B as re}from"./index-
|
|
1
|
+
import{r as n,j as e,ac as W,v as z,F as q,a3 as G,ad as K,ae as Y}from"./vendor-CmQZsDAE.js";import{I as A,c as L,u as $,a as J,b as Q,d as X,t as m,C as U,S as Z,e as H,f as ee,g as se,h as te,D as ae,B as re}from"./index-DvA7S11O.js";import{L as R}from"./label-DzwitL78.js";import{S as u}from"./skeleton-zjQZMWu9.js";import{h as _}from"./config-hints-CApS3K_7.js";import{b as le,f as oe,t as F,c as ne}from"./provider-models-BOeNnjk9.js";import{P as ce,a as ie}from"./page-layout-DEq5N_8L.js";function de(c){const r=new Set;for(const p of c){const x=p.trim();x.length>0&&r.add(x)}return[...r]}function me({id:c,value:r,onChange:p,options:x,disabled:i=!1,placeholder:T,className:P,inputClassName:v,emptyText:j,createText:k,maxItems:N=Number.POSITIVE_INFINITY,onEnter:b}){const[o,l]=n.useState(!1);n.useEffect(()=>{i&&o&&l(!1)},[i,o]);const h=n.useMemo(()=>de(x),[x]),d=r.trim().toLowerCase(),a=n.useMemo(()=>{const s=h.map((f,w)=>({option:f,index:w}));d.length>0&&s.sort((f,w)=>{const C=f.option.toLowerCase(),S=w.option.toLowerCase(),D=C===d?0:C.startsWith(d)?1:C.includes(d)?2:3,I=S===d?0:S.startsWith(d)?1:S.includes(d)?2:3;return D!==I?D-I:f.index-w.index});const g=s.map(f=>f.option);return Number.isFinite(N)?g.slice(0,Math.max(1,N)):g},[h,d,N]),M=r.trim().length>0&&h.some(s=>s===r.trim());return e.jsxs("div",{className:L("relative",P),onBlur:()=>{setTimeout(()=>l(!1),120)},children:[e.jsx(A,{id:c,value:r,disabled:i,onFocus:()=>{i||l(!0)},onChange:s=>{p(s.target.value),!o&&!i&&l(!0)},onKeyDown:s=>{s.key==="Enter"&&(b&&(s.preventDefault(),b()),l(!1))},placeholder:T,className:L("pr-10",v)}),e.jsx("button",{type:"button",onMouseDown:s=>s.preventDefault(),onClick:()=>l(s=>!s),disabled:i,className:L("absolute inset-y-0 right-0 inline-flex w-10 items-center justify-center",i?"cursor-not-allowed text-gray-300":"text-gray-400 hover:text-gray-600"),"aria-label":"toggle model options",children:e.jsx(W,{className:"h-4 w-4"})}),o&&!i&&e.jsx("div",{className:"absolute z-20 mt-1 w-full overflow-hidden rounded-xl border border-gray-200 bg-white shadow-lg",children:e.jsxs("div",{className:"max-h-60 overflow-y-auto py-1",children:[!M&&r.trim().length>0&&e.jsxs("button",{type:"button",onMouseDown:s=>s.preventDefault(),onClick:()=>{p(r.trim()),l(!1)},className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50",children:[e.jsx(z,{className:"h-4 w-4 text-transparent"}),e.jsx("span",{className:"truncate text-gray-700",children:k?k.replace("{value}",r.trim()):r.trim()})]}),a.map(s=>e.jsxs("button",{type:"button",onMouseDown:g=>g.preventDefault(),onClick:()=>{p(s),l(!1)},className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50",children:[e.jsx(z,{className:L("h-4 w-4",s===r.trim()?"text-primary":"text-transparent")}),e.jsx("span",{className:"truncate text-gray-700",children:s})]},s)),a.length===0&&r.trim().length===0&&e.jsx("div",{className:"px-3 py-2 text-sm text-gray-500",children:j??"No models available"})]})})]})}function Ne(){const{data:c,isLoading:r}=$(),{data:p}=J(),{data:x}=Q(),i=X(),[T,P]=n.useState(""),[v,j]=n.useState(""),[k,N]=n.useState(""),b=x==null?void 0:x.uiHints,o=_("agents.defaults.model",b),l=_("agents.defaults.workspace",b),h=n.useMemo(()=>le({meta:p,config:c,onlyConfigured:!0}),[c,p]),d=n.useMemo(()=>new Map(h.map(t=>[t.name,t])),[h]),a=d.get(T),M=(a==null?void 0:a.name)??"",s=n.useMemo(()=>(a==null?void 0:a.aliases)??[],[a]),g=n.useMemo(()=>(a==null?void 0:a.models)??[],[a]);n.useEffect(()=>{var E,B;if(!((E=c==null?void 0:c.agents)!=null&&E.defaults))return;const t=(c.agents.defaults.model||"").trim(),y=oe(t,h)??"",V=((B=d.get(y))==null?void 0:B.aliases)??[];P(y),j(y?F(t,V):""),N(c.agents.defaults.workspace||"")},[c,h,d]);const f=n.useMemo(()=>{const t=new Set;for(const O of g){const y=O.trim();y&&t.add(y)}return[...t]},[g]),w=n.useMemo(()=>{if(!a)return"";const t=F(v,s);return t?ne(a.prefix,t):""},[v,a,s]),C=m("modelIdentifierHelp")||(o==null?void 0:o.help)||"",S=t=>{P(t),j("")},D=t=>{if(!a){j("");return}j(F(t,s))},I=t=>{t.preventDefault(),i.mutate({model:w})};return r?e.jsxs("div",{className:"max-w-2xl space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{className:"h-8 w-32"}),e.jsx(u,{className:"h-4 w-48"})]}),e.jsxs(U,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx(u,{className:"h-12 w-12 rounded-xl"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{className:"h-5 w-24"}),e.jsx(u,{className:"h-3 w-32"})]})]}),e.jsx(u,{className:"h-4 w-20 mb-2"}),e.jsx(u,{className:"h-10 w-full rounded-xl"})]}),e.jsxs(U,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsx(u,{className:"h-5 w-24 mb-2"}),e.jsx(u,{className:"h-10 w-full rounded-xl"})]})]}):e.jsxs(ce,{children:[e.jsx(ie,{title:m("modelPageTitle"),description:m("modelPageDescription")}),e.jsxs("form",{onSubmit:I,className:"space-y-8",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"p-8 rounded-2xl bg-white border border-gray-200 shadow-card",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-8",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white",children:e.jsx(q,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:m("defaultModel")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"model",className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(o==null?void 0:o.label)??"Model Name"}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx("div",{className:"sm:w-[38%] sm:min-w-[170px]",children:e.jsxs(Z,{value:M,onValueChange:S,children:[e.jsx(H,{className:"h-10 w-full rounded-xl",children:e.jsx(ee,{placeholder:m("providersSelectPlaceholder")})}),e.jsx(se,{children:h.map(t=>e.jsx(te,{value:t.name,children:t.displayName},t.name))})]})}),e.jsx("span",{className:"hidden h-10 items-center justify-center leading-none text-lg font-semibold text-gray-300 sm:inline-flex",children:"/"}),e.jsx(me,{id:"model",value:v,onChange:D,options:f,disabled:!M,placeholder:(o==null?void 0:o.placeholder)??"gpt-5.1",className:"sm:flex-1",inputClassName:"h-10 rounded-xl",emptyText:m("modelPickerNoOptions"),createText:m("modelPickerUseCustom")},M)]}),e.jsx("p",{className:"text-xs text-gray-400",children:C}),e.jsx("p",{className:"text-xs text-gray-500",children:m("modelInputCustomHint")}),e.jsxs("a",{href:`${ae}/guide/model-selection`,className:"inline-flex items-center gap-1.5 text-xs text-primary hover:text-primary-hover transition-colors",children:[e.jsx(G,{className:"h-3.5 w-3.5"}),m("channelsGuideTitle")]})]})]}),e.jsxs("div",{className:"p-8 rounded-2xl bg-white border border-gray-200 shadow-card",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-8",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white",children:e.jsx(K,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:m("workspace")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"workspace",className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(l==null?void 0:l.label)??"Default Path"}),e.jsx(A,{id:"workspace",value:k,onChange:t=>N(t.target.value),placeholder:(l==null?void 0:l.placeholder)??"/path/to/workspace",className:"rounded-xl"})]})]})]}),e.jsx("div",{className:"flex justify-end pt-4",children:e.jsx(re,{type:"submit",disabled:i.isPending,size:"lg",children:i.isPending?e.jsx(Y,{className:"h-5 w-5 animate-spin"}):m("saveChanges")})})]})]})}export{Ne as ModelConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as p,j as e,aF as St,aG as Tt,az as et,at as ke,aH as tt,i as kt,X as Xe,f as Lt,e as W,aI as It,G as Dt,K as Et}from"./vendor-CmQZsDAE.js";import{c as ue,I as Z,B as O,t as s,S as Le,e as Ie,f as De,g as Ee,h as fe,u as st,a as nt,b as rt,U as _t,V as $t,W as Bt,X as Kt,Y as zt,Z as Ft,_ as Ot,$ as Ht}from"./index-DvA7S11O.js";import{L as F}from"./label-DzwitL78.js";import{h as le}from"./config-hints-CApS3K_7.js";import{c as Wt,b as Rt,C as qt,a as Ut}from"./config-layout-BHnOoweL.js";import{S as Gt}from"./switch-PvjTvlcs.js";import{a as Vt,b as Qt,c as Xt}from"./popover-CY54V8F6.js";import{S as Se}from"./status-dot-CU_P0tvO.js";import{T as Yt}from"./tabs-custom-Bke5J9ny.js";import{L as Zt}from"./LogoBadge-BKq1GKWP.js";import{P as Jt,a as es}from"./page-layout-DEq5N_8L.js";function ts({isSet:t,className:n,value:r,onChange:i,placeholder:l,...h}){const[d,c]=p.useState(!1),[g,v]=p.useState(!1),w=typeof r=="string"&&r.length>0,P=t&&!w&&!g;return e.jsxs("div",{className:"relative",children:[P?e.jsx("div",{onClick:()=>v(!0),className:ue("flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-500 cursor-text items-center pr-12",n),children:"••••••••••••"}):e.jsx(Z,{type:d?"text":"password",className:ue("pr-12",n),value:r,onChange:i,onBlur:()=>{w||v(!1)},placeholder:l,autoFocus:g,...h}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:(t||w)&&e.jsx(O,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>c(!d),children:d?e.jsx(St,{className:"h-4 w-4"}):e.jsx(Tt,{className:"h-4 w-4"})})})]})}function ss({value:t,onChange:n,className:r}){const i=t?Object.entries(t):[],l=(c,g,v)=>{const w=[...i];w[c]=[g,v],n(Object.fromEntries(w))},h=()=>{n({...t,"":""})},d=c=>{const g=i.filter((v,w)=>w!==c);n(Object.fromEntries(g))};return e.jsxs("div",{className:ue("space-y-2",r),children:[i.map(([c,g],v)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Z,{type:"text",value:c,onChange:w=>l(v,w.target.value,g),placeholder:s("headerName"),className:"flex-1"}),e.jsx(Z,{type:"text",value:g,onChange:w=>l(v,c,w.target.value),placeholder:s("headerValue"),className:"flex-1"}),e.jsx(O,{type:"button",variant:"ghost",size:"icon",onClick:()=>d(v),children:e.jsx(et,{className:"h-4 w-4 text-red-500"})})]},v)),e.jsxs(O,{type:"button",variant:"outline",size:"sm",onClick:h,children:[e.jsx(ke,{className:"h-4 w-4 mr-2"}),s("add")]})]})}function at(t){const{value:n,onChange:r,options:i}=t;return e.jsx("div",{className:"flex flex-wrap gap-2",children:i.map(l=>{const h=l.value===n;return e.jsx("button",{type:"button",onClick:()=>r(l.value),"aria-pressed":h,className:`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${h?"border-primary bg-primary text-white shadow-sm":"border-gray-200 bg-white text-gray-700 hover:border-primary/40 hover:text-primary"}`,children:l.label},l.value)})})}function ns(t){const{showAdvanced:n,onShowAdvancedChange:r,supportsWireApi:i,wireApiLabel:l,wireApi:h,onWireApiChange:d,shouldUseWireApiPills:c,wireApiSelectOptions:g,extraHeadersLabel:v,extraHeaders:w,onExtraHeadersChange:P}=t;return e.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[e.jsxs("button",{type:"button",onClick:()=>r(!n),className:"flex w-full items-center justify-between text-sm text-gray-600 transition-colors hover:text-gray-900",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(tt,{className:"h-3.5 w-3.5"}),s("providerAdvancedSettings")]}),e.jsx(kt,{className:`h-4 w-4 transition-transform ${n?"rotate-180":""}`})]}),n?e.jsxs("div",{className:"mt-4 space-y-5",children:[i?e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{htmlFor:"wireApi",className:"text-sm font-medium text-gray-900",children:l}),c?e.jsx(at,{value:h,onChange:C=>d(C),options:g}):e.jsxs(Le,{value:h,onValueChange:C=>d(C),children:[e.jsx(Ie,{className:"rounded-xl",children:e.jsx(De,{})}),e.jsx(Ee,{children:g.map(C=>e.jsx(fe,{value:C.value,children:C.label},C.value))})]})]}):null,e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{className:"text-sm font-medium text-gray-900",children:v}),e.jsx(ss,{value:w,onChange:P}),e.jsx("p",{className:"text-xs text-gray-500",children:s("providerExtraHeadersHelpShort")})]})]}):null]})}function rs(t){const{providerAuth:n,providerAuthNote:r,providerAuthMethodOptions:i,providerAuthMethodsCount:l,selectedAuthMethodHint:h,shouldUseAuthMethodPills:d,resolvedAuthMethodId:c,onAuthMethodChange:g,onStartProviderAuth:v,onImportProviderAuthFromCli:w,startPending:P,importPending:C,authSessionId:b,authStatusMessage:N}=t;return(n==null?void 0:n.kind)!=="device_code"?null:e.jsxs("div",{className:"space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3",children:[e.jsx(F,{className:"text-sm font-medium text-gray-900",children:n.displayName||s("providerAuthSectionTitle")}),r?e.jsx("p",{className:"text-xs text-gray-600",children:r}):null,l>1?e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{className:"text-xs font-medium text-gray-700",children:s("providerAuthMethodLabel")}),d?e.jsx(at,{value:c,onChange:g,options:i}):e.jsxs(Le,{value:c,onValueChange:g,children:[e.jsx(Ie,{className:"h-8 rounded-lg bg-white",children:e.jsx(De,{placeholder:s("providerAuthMethodPlaceholder")})}),e.jsx(Ee,{children:i.map(A=>e.jsx(fe,{value:A.value,children:A.label},A.value))})]}),h?e.jsx("p",{className:"text-xs text-gray-500",children:h}):null]}):null,e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(O,{type:"button",variant:"outline",size:"sm",onClick:v,disabled:P||!!b,children:P?s("providerAuthStarting"):b?s("providerAuthAuthorizing"):s("providerAuthAuthorizeInBrowser")}),n.supportsCliImport?e.jsx(O,{type:"button",variant:"outline",size:"sm",onClick:w,disabled:C,children:C?s("providerAuthImporting"):s("providerAuthImportFromCli")}):null,b?e.jsxs("span",{className:"text-xs text-gray-500",children:[s("providerAuthSessionLabel"),": ",b.slice(0,8),"…"]}):null]}),N?e.jsx("p",{className:"text-xs text-gray-600",children:N}):null]})}function as(t){return e.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-gray-200 bg-gray-50 px-4 py-3",children:[e.jsx(F,{className:"text-sm font-medium text-gray-900",children:s("enabled")}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-gray-500",children:t.enabled?s("enabled"):s("disabled")}),e.jsx(Gt,{checked:t.enabled,onCheckedChange:t.onChange})]})]})}const is={enabled:!0,displayName:"",apiKeySet:!1,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelThinking:{}},Te=["off","minimal","low","medium","high","adaptive","xhigh"],os=new Set(Te);function ce(t){if(!t)return null;const n=Object.entries(t).map(([r,i])=>[r.trim(),i]).filter(([r])=>r.length>0);return n.length===0?null:Object.fromEntries(n)}function Ye(t,n){const r=ce(t),i=ce(n);if(r===null&&i===null)return!0;if(!r||!i)return!1;const l=Object.entries(r).sort(([d],[c])=>d.localeCompare(c)),h=Object.entries(i).sort(([d],[c])=>d.localeCompare(c));return l.length!==h.length?!1:l.every(([d,c],g)=>d===h[g][0]&&c===h[g][1])}function Me(t){if(!t||t.length===0)return[];const n=new Set;for(const r of t){const i=r.trim();i&&n.add(i)}return[...n]}function ls(t,n){const r=t.trim();if(!r||!n.trim())return r;const i=`${n.trim()}/`;return r.startsWith(i)?r.slice(i.length):r}function de(t,n){let r=t.trim();if(!r)return"";for(const i of n){const l=i.trim();l&&(r=ls(r,l))}return r.trim()}function ge(t,n){return t.length!==n.length?!1:t.every((r,i)=>r===n[i])}function ds(t,n){const r=[...t];for(const i of n)r.includes(i)||r.push(i);return r}function cs(t,n){return n.length===0?t:n.every(i=>!t.includes(i))?ds(t,n):n}function us(t,n){return ge(t,n)?[]:t}function hs(t,n,r){n!==r&&(t.enabled=n)}function _e(t){if(typeof t!="string")return null;const n=t.trim().toLowerCase();return n&&os.has(n)?n:null}function it(t){if(!Array.isArray(t))return[];const n=[];for(const r of t){const i=_e(r);!i||n.includes(i)||n.push(i)}return n}function ms(t,n){if(!t)return{};const r={};for(const[i,l]of Object.entries(t)){const h=de(i,n);if(!h)continue;const d=it(l==null?void 0:l.supported);if(d.length===0)continue;const c=_e(l==null?void 0:l.default);r[h]=c&&d.includes(c)?{supported:d,default:c}:{supported:d}}return r}function Pe(t,n){const r=new Set(n.map(l=>l.trim()).filter(Boolean)),i={};for(const[l,h]of Object.entries(t)){if(!r.has(l))continue;const d=it(h.supported);if(d.length===0)continue;const c=_e(h.default);i[l]=c&&d.includes(c)?{supported:d,default:c}:{supported:d}}return i}function Ze(t,n){const r=Object.keys(t).sort(),i=Object.keys(n).sort();if(r.length!==i.length)return!1;for(let l=0;l<r.length;l+=1){const h=r[l];if(h!==i[l])return!1;const d=t[h],c=n[h];if(!d||!c)return!1;const g=[...d.supported].sort(),v=[...c.supported].sort();if(!ge(g,v)||(d.default??null)!==(c.default??null))return!1}return!0}function xs(t){return t==="off"?s("chatThinkingLevelOff"):t==="minimal"?s("chatThinkingLevelMinimal"):t==="low"?s("chatThinkingLevelLow"):t==="medium"?s("chatThinkingLevelMedium"):t==="high"?s("chatThinkingLevelHigh"):t==="adaptive"?s("chatThinkingLevelAdaptive"):s("chatThinkingLevelXhigh")}function ps(t){var g,v,w,P,C;const{providerName:n,methods:r,defaultMethodId:i,language:l}=t;if(r.length===0)return"";const h=new Map;for(const b of r){const N=b.id.trim();N&&h.set(N.toLowerCase(),N)}const d=(...b)=>{for(const N of b){const A=h.get(N.toLowerCase());if(A)return A}},c=i==null?void 0:i.trim();if(n==="minimax-portal"){if(l==="zh")return d("cn","china-mainland")??d(c??"")??((g=r[0])==null?void 0:g.id)??"";if(l==="en")return d("global","intl","international")??d(c??"")??((v=r[0])==null?void 0:v.id)??""}if(c){const b=d(c);if(b)return b}return l==="zh"?d("cn")??((w=r[0])==null?void 0:w.id)??"":l==="en"?d("global")??((P=r[0])==null?void 0:P.id)??"":((C=r[0])==null?void 0:C.id)??""}function Je(t){return t.required&&t.hasDefault&&t.optionCount>1&&t.optionCount<=3}function fs(t){const{models:n,modelThinking:r,modelDraft:i,showModelInput:l,onModelDraftChange:h,onShowModelInputChange:d,onAddModel:c,onRemoveModel:g,onToggleModelThinkingLevel:v,onSetModelThinkingDefault:w,thinkingLevels:P,formatThinkingLevelLabel:C}=t;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(F,{className:"text-sm font-medium text-gray-900",children:s("providerModelsTitle")}),l?null:e.jsxs("button",{type:"button",onClick:()=>d(!0),className:"flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80",children:[e.jsx(ke,{className:"h-3 w-3"}),s("providerAddModel")]})]}),l?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{value:i,onChange:b=>h(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),c()),b.key==="Escape"&&(d(!1),h(""))},placeholder:s("providerModelInputPlaceholder"),className:"flex-1 rounded-xl",autoFocus:!0}),e.jsx(O,{type:"button",size:"sm",onClick:c,disabled:i.trim().length===0,children:s("add")}),e.jsx(O,{type:"button",size:"sm",variant:"ghost",onClick:()=>{d(!1),h("")},children:e.jsx(Xe,{className:"h-4 w-4"})})]}):null,n.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center",children:[e.jsx("p",{className:"text-sm text-gray-500",children:s("providerModelsEmptyShort")}),l?null:e.jsx("button",{type:"button",onClick:()=>d(!0),className:"mt-2 text-sm font-medium text-primary hover:text-primary/80",children:s("providerAddFirstModel")})]}):e.jsx("div",{className:"flex flex-wrap gap-2",children:n.map(b=>{const N=r[b],A=(N==null?void 0:N.supported)??[],K=(N==null?void 0:N.default)??null;return e.jsxs("div",{className:"group inline-flex max-w-full items-center gap-1 rounded-full border border-gray-200 bg-white px-3 py-1.5",children:[e.jsx("span",{className:"max-w-[140px] truncate text-sm text-gray-800 sm:max-w-[220px]",children:b}),e.jsxs(Vt,{children:[e.jsx(Qt,{asChild:!0,children:e.jsx("button",{type:"button",className:"inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100","aria-label":s("providerModelThinkingTitle"),title:s("providerModelThinkingTitle"),children:e.jsx(tt,{className:"h-3 w-3"})})}),e.jsxs(Xt,{className:"w-80 space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-semibold text-gray-800",children:s("providerModelThinkingTitle")}),e.jsx("p",{className:"text-xs text-gray-500",children:s("providerModelThinkingHint")})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:P.map(S=>{const y=A.includes(S);return e.jsx("button",{type:"button",onClick:()=>v(b,S),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${y?"border-primary bg-primary text-white":"border-gray-200 bg-white text-gray-600 hover:border-primary/40 hover:text-primary"}`,children:C(S)},S)})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(F,{className:"text-xs font-medium text-gray-700",children:s("providerModelThinkingDefault")}),e.jsxs(Le,{value:K??"__none__",onValueChange:S=>w(b,S==="__none__"?null:S),disabled:A.length===0,children:[e.jsx(Ie,{className:"h-8 rounded-lg bg-white text-xs",children:e.jsx(De,{})}),e.jsxs(Ee,{children:[e.jsx(fe,{value:"__none__",children:s("providerModelThinkingDefaultNone")}),A.map(S=>e.jsx(fe,{value:S,children:C(S)},S))]})]}),A.length===0?e.jsx("p",{className:"text-xs text-gray-500",children:s("providerModelThinkingNoSupported")}):null]})]})]}),e.jsx("button",{type:"button",onClick:()=>g(b),className:"inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100","aria-label":s("remove"),children:e.jsx(Xe,{className:"h-3 w-3"})})]},b)})})]})}function gs(t){return t.enabled?e.jsx(Se,{status:t.apiKeySet?"ready":"setup",label:t.apiKeySet?s("statusReady"):s("statusSetup"),className:t.className}):e.jsx(Se,{status:"inactive",label:s("disabled"),className:t.className})}function ys({providerName:t,onProviderDeleted:n}){var We,Re,qe,Ue,Ge,Ve,Qe;const r=Lt(),{data:i}=st(),{data:l}=nt(),{data:h}=rt(),d=_t(),c=$t(),g=Bt(),v=Kt(),w=zt(),P=Ft(),[C,b]=p.useState(""),[N,A]=p.useState(!0),[K,S]=p.useState(""),[y,j]=p.useState(null),[T,k]=p.useState("auto"),[M,G]=p.useState([]),[D,$]=p.useState({}),[ye,V]=p.useState(""),[R,be]=p.useState(""),[ot,lt]=p.useState(!1),[dt,ct]=p.useState(!1),[ut,q]=p.useState(null),[ht,B]=p.useState(""),[$e,je]=p.useState(""),he=p.useRef(null),o=l==null?void 0:l.providers.find(a=>a.name===t),L=(t?i==null?void 0:i.providers[t]:null)??is,me=h==null?void 0:h.uiHints,J=!!(o!=null&&o.isCustom),ee=t?le(`providers.${t}.apiKey`,me):void 0,H=t?le(`providers.${t}.apiBase`,me):void 0,ve=t?le(`providers.${t}.extraHeaders`,me):void 0,we=t?le(`providers.${t}.wireApi`,me):void 0,Be=(o==null?void 0:o.displayName)||t||"",te=(L.displayName||"").trim()||Be,se=L.enabled!==!1,mt=R.trim()||te||t||s("providersSelectPlaceholder"),Ke=(o==null?void 0:o.modelPrefix)||t||"",U=p.useMemo(()=>Me([Ke,t||""]),[Ke,t]),Ce=(o==null?void 0:o.defaultApiBase)||"",re=L.apiBase||Ce,Ne=ce(L.extraHeaders||null),ae=L.wireApi||(o==null?void 0:o.defaultWireApi)||"auto",Ae=p.useMemo(()=>Me(((o==null?void 0:o.defaultModels)??[]).map(a=>de(a,U))),[o==null?void 0:o.defaultModels,U]),ze=p.useMemo(()=>Me((L.models??[]).map(a=>de(a,U))),[L.models,U]),Q=p.useMemo(()=>cs(Ae,ze),[Ae,ze]),ie=p.useMemo(()=>Pe(ms(L.modelThinking,U),Q),[Q,U,L.modelThinking]),X=Ot(),xt=((We=o==null?void 0:o.apiBaseHelp)==null?void 0:We[X])||((Re=o==null?void 0:o.apiBaseHelp)==null?void 0:Re.en)||(H==null?void 0:H.help)||s("providerApiBaseHelp"),f=o==null?void 0:o.auth,E=p.useMemo(()=>(f==null?void 0:f.methods)??[],[f==null?void 0:f.methods]),pt=p.useMemo(()=>E.map(a=>{var u,m;return{value:a.id,label:((u=a.label)==null?void 0:u[X])||((m=a.label)==null?void 0:m.en)||a.id}}),[E,X]),xe=p.useMemo(()=>ps({providerName:t,methods:E,defaultMethodId:f==null?void 0:f.defaultMethodId,language:X}),[t,f==null?void 0:f.defaultMethodId,E,X]),oe=p.useMemo(()=>{var u;if(!E.length)return"";const a=$e.trim();return a&&E.some(m=>m.id===a)?a:xe||((u=E[0])==null?void 0:u.id)||""},[$e,xe,E]),ne=p.useMemo(()=>E.find(a=>a.id===oe),[E,oe]),ft=((qe=ne==null?void 0:ne.hint)==null?void 0:qe[X])||((Ue=ne==null?void 0:ne.hint)==null?void 0:Ue.en)||"",gt=Je({required:(f==null?void 0:f.kind)==="device_code",hasDefault:!!((Ge=f==null?void 0:f.defaultMethodId)!=null&&Ge.trim()),optionCount:E.length}),yt=((Ve=f==null?void 0:f.note)==null?void 0:Ve[X])||((Qe=f==null?void 0:f.note)==null?void 0:Qe.en)||(f==null?void 0:f.displayName)||"",Fe=((o==null?void 0:o.wireApiOptions)||["auto","chat","responses"]).map(a=>({value:a,label:a==="chat"?s("wireApiChat"):a==="responses"?s("wireApiResponses"):s("wireApiAuto")})),bt=Je({required:!!(o!=null&&o.supportsWireApi),hasDefault:typeof(o==null?void 0:o.defaultWireApi)=="string"&&o.defaultWireApi.length>0,optionCount:Fe.length}),_=p.useCallback(()=>{he.current!==null&&(window.clearTimeout(he.current),he.current=null)},[]),Oe=p.useCallback((a,u)=>{_(),he.current=window.setTimeout(()=>{(async()=>{if(t)try{const m=await w.mutateAsync({provider:t,data:{sessionId:a}});if(m.status==="pending"){B(s("providerAuthWaitingBrowser")),Oe(a,m.nextPollMs??u);return}if(m.status==="authorized"){q(null),_(),B(s("providerAuthCompleted")),W.success(s("providerAuthCompleted")),r.invalidateQueries({queryKey:["config"]}),r.invalidateQueries({queryKey:["config-meta"]});return}q(null),_(),B(m.message||`Authorization ${m.status}.`),W.error(m.message||`Authorization ${m.status}.`)}catch(m){q(null),_();const x=m instanceof Error?m.message:String(m);B(x),W.error(`Authorization failed: ${x}`)}})()},Math.max(1e3,u))},[_,w,t,r]);p.useEffect(()=>{if(!t){b(""),A(!0),S(""),j(null),k("auto"),G([]),$({}),V(""),be(""),q(null),B(""),je(""),_();return}b(""),A(se),S(re),j(L.extraHeaders||null),k(ae),G(Q),$(ie),V(""),be(te),q(null),B(""),je(xe),_()},[t,re,se,L.extraHeaders,ae,Q,ie,te,xe,_]),p.useEffect(()=>()=>_(),[_]),p.useEffect(()=>{$(a=>Pe(a,M))},[M]);const He=p.useMemo(()=>{if(!t)return!1;const a=C.trim().length>0,u=K.trim()!==re.trim(),m=!Ye(y,Ne),x=o!=null&&o.supportsWireApi?T!==ae:!1,I=!ge(M,Q),z=!Ze(D,ie),pe=J?R.trim()!==te:!1;return a||N!==se||u||m||x||I||z||pe},[t,J,R,te,C,N,se,K,re,y,Ne,o==null?void 0:o.supportsWireApi,T,ae,M,Q,D,ie]),jt=()=>{const a=de(ye,U);if(a){if(M.includes(a)){V("");return}G(u=>[...u,a]),V("")}},vt=(a,u)=>{$(m=>{const x=m[a],I=(x==null?void 0:x.supported)??[],z=I.includes(u)?I.filter(Y=>Y!==u):Te.filter(Y=>Y===u||I.includes(Y));if(z.length===0){const Y={...m};return delete Y[a],Y}const pe=x!=null&&x.default&&z.includes(x.default)?x.default:void 0;return{...m,[a]:pe?{supported:z,default:pe}:{supported:z}}})},wt=(a,u)=>{$(m=>{const x=m[a];return!x||x.supported.length===0||u&&!x.supported.includes(u)?m:{...m,[a]:u?{supported:x.supported,default:u}:{supported:x.supported}}})},Ct=a=>{if(a.preventDefault(),!t)return;const u={},m=C.trim(),x=K.trim(),I=ce(y),z=R.trim();J&&z!==te&&(u.displayName=z.length>0?z:null),m.length>0&&(u.apiKey=m),hs(u,N,se),x!==re.trim()&&(u.apiBase=x.length>0&&x!==Ce?x:null),Ye(I,Ne)||(u.extraHeaders=I),o!=null&&o.supportsWireApi&&T!==ae&&(u.wireApi=T),ge(M,Q)||(u.models=us(M,Ae)),Ze(D,ie)||(u.modelThinking=Pe(D,M)),d.mutate({provider:t,data:u})},Nt=async()=>{if(!t)return;const a=M.find(x=>x.trim().length>0)??"",u=de(a,U),m={apiBase:K.trim(),extraHeaders:ce(y),model:u||null};C.trim().length>0&&(m.apiKey=C.trim()),o!=null&&o.supportsWireApi&&(m.wireApi=T);try{const x=await g.mutateAsync({provider:t,data:m});if(x.success){W.success(`${s("providerTestConnectionSuccess")} (${x.latencyMs}ms)`);return}const I=[`provider=${x.provider}`,`latency=${x.latencyMs}ms`];x.model&&I.push(`model=${x.model}`),W.error(`${s("providerTestConnectionFailed")}: ${x.message} | ${I.join(" | ")}`)}catch(x){const I=x instanceof Error?x.message:String(x);W.error(`${s("providerTestConnectionFailed")}: ${I}`)}},At=async()=>{if(!(!t||!J||!window.confirm(s("providerDeleteConfirm"))))try{await c.mutateAsync({provider:t}),n==null||n(t)}catch{}},Mt=async()=>{if(!(!t||(f==null?void 0:f.kind)!=="device_code"))try{B("");const a=await v.mutateAsync({provider:t,data:oe?{methodId:oe}:{}});if(!a.sessionId||!a.verificationUri)throw new Error(s("providerAuthStartFailed"));q(a.sessionId),B(`${s("providerAuthOpenPrompt")}${a.userCode}${s("providerAuthOpenPromptSuffix")}`),window.open(a.verificationUri,"_blank","noopener,noreferrer"),Oe(a.sessionId,a.intervalMs)}catch(a){const u=a instanceof Error?a.message:String(a);q(null),_(),B(u),W.error(`${s("providerAuthStartFailed")}: ${u}`)}},Pt=async()=>{if(!(!t||(f==null?void 0:f.kind)!=="device_code"))try{_(),q(null);const a=await P.mutateAsync({provider:t}),u=a.expiresAt?` (expires: ${a.expiresAt})`:"";B(`${s("providerAuthImportStatusPrefix")}${u}`),W.success(s("providerAuthImportSuccess")),r.invalidateQueries({queryKey:["config"]}),r.invalidateQueries({queryKey:["config-meta"]})}catch(a){const u=a instanceof Error?a.message:String(a);B(u),W.error(`${s("providerAuthImportFailed")}: ${u}`)}};return!t||!o?e.jsx("div",{className:Wt,children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:s("providersSelectTitle")}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:s("providersSelectDescription")})]})}):e.jsxs("div",{className:Rt,children:[e.jsx("div",{className:"border-b border-gray-100 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"truncate text-lg font-semibold text-gray-900",children:mt}),e.jsxs("div",{className:"flex items-center gap-3",children:[J&&e.jsx("button",{type:"button",onClick:At,disabled:c.isPending,className:"text-gray-400 hover:text-red-500 transition-colors",title:s("providerDelete"),children:e.jsx(et,{className:"h-4 w-4"})}),e.jsx(gs,{enabled:se,apiKeySet:L.apiKeySet})]})]})}),e.jsxs("form",{onSubmit:Ct,className:"flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5",children:[e.jsx(as,{enabled:N,onChange:A}),J&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{htmlFor:"providerDisplayName",className:"text-sm font-medium text-gray-900",children:s("providerDisplayName")}),e.jsx(Z,{id:"providerDisplayName",type:"text",value:R,onChange:a=>be(a.target.value),placeholder:Be||s("providerDisplayNamePlaceholder"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:s("providerDisplayNameHelpShort")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{htmlFor:"apiKey",className:"text-sm font-medium text-gray-900",children:(ee==null?void 0:ee.label)??s("apiKey")}),e.jsx(ts,{id:"apiKey",value:C,isSet:L.apiKeySet,onChange:a=>b(a.target.value),placeholder:(ee==null?void 0:ee.placeholder)??s("enterApiKey"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:s("leaveBlankToKeepUnchanged")})]}),e.jsx(rs,{providerAuth:f,providerAuthNote:yt,providerAuthMethodOptions:pt,providerAuthMethodsCount:E.length,selectedAuthMethodHint:ft,shouldUseAuthMethodPills:gt,resolvedAuthMethodId:oe,onAuthMethodChange:je,onStartProviderAuth:Mt,onImportProviderAuthFromCli:Pt,startPending:v.isPending,importPending:P.isPending,authSessionId:ut,authStatusMessage:ht}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{htmlFor:"apiBase",className:"text-sm font-medium text-gray-900",children:(H==null?void 0:H.label)??s("apiBase")}),e.jsx(Z,{id:"apiBase",type:"text",value:K,onChange:a=>S(a.target.value),placeholder:Ce||(H==null?void 0:H.placeholder)||"https://api.example.com",className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:xt})]}),e.jsx(fs,{models:M,modelThinking:D,modelDraft:ye,showModelInput:dt,onModelDraftChange:V,onShowModelInputChange:ct,onAddModel:jt,onRemoveModel:a=>{G(u=>u.filter(m=>m!==a)),$(u=>{const m={...u};return delete m[a],m})},onToggleModelThinkingLevel:vt,onSetModelThinkingDefault:wt,thinkingLevels:Te,formatThinkingLevelLabel:xs}),e.jsx(ns,{showAdvanced:ot,onShowAdvancedChange:lt,supportsWireApi:!!o.supportsWireApi,wireApiLabel:(we==null?void 0:we.label)??s("wireApi"),wireApi:T,onWireApiChange:k,shouldUseWireApiPills:bt,wireApiSelectOptions:Fe,extraHeadersLabel:(ve==null?void 0:ve.label)??s("extraHeaders"),extraHeaders:y,onExtraHeadersChange:j})]}),e.jsxs("div",{className:"flex items-center justify-between border-t border-gray-100 px-6 py-4",children:[e.jsxs(O,{type:"button",variant:"outline",size:"sm",onClick:Nt,disabled:g.isPending,children:[e.jsx(It,{className:"mr-1.5 h-4 w-4"}),g.isPending?s("providerTestingConnection"):s("providerTestConnection")]}),e.jsx(O,{type:"submit",disabled:d.isPending||!He,children:d.isPending?s("saving"):He?s("save"):s("unchanged")})]})]})]})}function bs(t){if(!t)return null;try{const n=new URL(t),r=n.pathname&&n.pathname!=="/"?n.pathname:"";return`${n.host}${r}`}catch{return t.replace(/^https?:\/\//,"")}}function Es(){const{data:t}=st(),{data:n}=nt(),{data:r}=rt(),i=Ht(),[l,h]=p.useState("installed"),[d,c]=p.useState(),[g,v]=p.useState(""),w=r==null?void 0:r.uiHints,P=(n==null?void 0:n.providers)??[],C=(t==null?void 0:t.providers)??{},b=P.filter(y=>{const j=C[y.name];return(j==null?void 0:j.enabled)!==!1&&(j==null?void 0:j.apiKeySet)}).length,N=[{id:"installed",label:s("providersTabConfigured"),count:b},{id:"all",label:s("providersTabAll"),count:P.length}],A=p.useMemo(()=>{const y=(n==null?void 0:n.providers)??[],j=(t==null?void 0:t.providers)??{},T=g.trim().toLowerCase();return y.filter(k=>{if(l==="installed"){const M=j[k.name];return!!((M==null?void 0:M.enabled)!==!1&&(M!=null&&M.apiKeySet))}return!0}).filter(k=>{var D,$;return T?((($=(D=j[k.name])==null?void 0:D.displayName)==null?void 0:$.trim())||k.displayName||k.name).toLowerCase().includes(T)||k.name.toLowerCase().includes(T):!0})},[n,t,l,g]);p.useEffect(()=>{if(A.length===0){c(void 0);return}A.some(j=>j.name===d)||c(A[0].name)},[A,d]);const K=d,S=async()=>{try{const y=await i.mutateAsync({data:{}});h("all"),v(""),c(y.name)}catch{}};return!t||!n?e.jsx("div",{className:"p-8",children:s("providersLoading")}):e.jsxs(Jt,{children:[e.jsx(es,{title:s("providersPageTitle"),description:s("providersPageDescription")}),e.jsxs("div",{className:qt,children:[e.jsxs("section",{className:Ut,children:[e.jsxs("div",{className:"border-b border-gray-100 px-4 pt-4 pb-3 space-y-3",children:[e.jsx(Yt,{tabs:N,activeTab:l,onChange:h,className:"mb-0"}),e.jsxs(O,{type:"button",variant:"outline",className:"w-full justify-center",onClick:S,disabled:i.isPending,children:[e.jsx(ke,{className:"mr-2 h-4 w-4"}),i.isPending?s("saving"):s("providerAddCustom")]})]}),e.jsx("div",{className:"border-b border-gray-100 px-4 py-3",children:e.jsxs("div",{className:"relative",children:[e.jsx(Dt,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx(Z,{value:g,onChange:y=>v(y.target.value),placeholder:s("providersFilterPlaceholder"),className:"h-10 rounded-xl pl-9"})]})}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto p-3",children:[A.map(y=>{var R;const j=t.providers[y.name],T=(j==null?void 0:j.enabled)!==!1,k=!!(T&&(j!=null&&j.apiKeySet)),M=K===y.name,G=((R=j==null?void 0:j.displayName)==null?void 0:R.trim())||y.displayName||y.name,D=le(`providers.${y.name}`,w),$=(j==null?void 0:j.apiBase)||y.defaultApiBase||"",V=bs($)||(D==null?void 0:D.help)||s("providersDefaultDescription");return e.jsx("button",{type:"button",onClick:()=>c(y.name),className:ue("w-full rounded-xl border p-2.5 text-left transition-all",M?"border-primary/30 bg-primary-50/40 shadow-sm":"border-gray-200/70 bg-white hover:border-gray-300 hover:bg-gray-50/70"),children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(Zt,{name:y.name,src:y.logo?`/logos/${y.logo}`:null,className:ue("h-10 w-10 rounded-lg border",k?"border-primary/30 bg-white":"border-gray-200/70 bg-white"),imgClassName:"h-5 w-5 object-contain",fallback:e.jsx("span",{className:"text-sm font-semibold uppercase text-gray-500",children:y.name[0]})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:G}),e.jsx("p",{className:"line-clamp-1 text-[11px] text-gray-500",children:V})]})]}),e.jsx(Se,{status:T?k?"ready":"setup":"inactive",label:T?k?s("statusReady"):s("statusSetup"):s("disabled"),className:"min-w-[56px] justify-center"})]})},y.name)}),A.length===0&&e.jsxs("div",{className:"flex h-full min-h-[220px] flex-col items-center justify-center rounded-xl border border-dashed border-gray-200 bg-gray-50/70 py-10 text-center",children:[e.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-white",children:e.jsx(Et,{className:"h-5 w-5 text-gray-300"})}),e.jsx("p",{className:"text-sm font-medium text-gray-700",children:s("providersNoMatch")})]})]})]}),e.jsx(ys,{providerName:K,onProviderDeleted:y=>{y===d&&c(void 0)}})]})]})}export{Es as ProvidersList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as m,j as a,b6 as w,S as L,b7 as R}from"./vendor-CmQZsDAE.js";import{P as E,a as T}from"./page-layout-
|
|
1
|
+
import{r as m,j as a,b6 as w,S as L,b7 as R}from"./vendor-CmQZsDAE.js";import{P as E,a as T}from"./page-layout-DEq5N_8L.js";import{af as H,ag as M,ah as P,t,ai as B,C as S,a3 as j,a4 as h,a5 as N,z as f,s as y,B as o}from"./index-DvA7S11O.js";import{S as d}from"./status-dot-CU_P0tvO.js";function s(n){const r=n.value===void 0||n.value===null||n.value===""?"-":String(n.value);return a.jsxs("div",{className:"flex items-start justify-between gap-4 py-2 text-sm",children:[a.jsx("span",{className:"text-gray-500",children:n.label}),a.jsx("span",{className:n.muted?"text-right text-gray-500":"text-right text-gray-900",children:r})]})}function k(n){var r,e;return n!=null&&n.account.loggedIn?n.settings.enabled?n.service.running?((r=n.runtime)==null?void 0:r.state)==="connected"?{badgeStatus:"ready",badgeLabel:t("statusReady"),title:t("remoteStatusReadyTitle"),description:t("remoteStatusReadyDescription")}:((e=n.runtime)==null?void 0:e.state)==="connecting"?{badgeStatus:"active",badgeLabel:t("connecting"),title:t("remoteStatusConnectingTitle"),description:t("remoteStatusConnectingDescription")}:{badgeStatus:"warning",badgeLabel:t("remoteStateDisconnected"),title:t("remoteStatusIssueTitle"),description:t("remoteStatusIssueDescription")}:{badgeStatus:"warning",badgeLabel:t("remoteServiceStopped"),title:t("remoteStatusNeedsServiceTitle"),description:t("remoteStatusNeedsServiceDescription")}:{badgeStatus:"inactive",badgeLabel:t("statusInactive"),title:t("remoteStatusNeedsEnable"),description:t("remoteStatusNeedsEnableDescription")}:{badgeStatus:"setup",badgeLabel:t("statusSetup"),title:t("remoteStatusNeedsSignIn"),description:t("remoteStatusNeedsSignInDescription")}}function O(n){var r,e;return n!=null&&n.settings.enabled?n.service.running?((e=(r=n.runtime)==null?void 0:r.lastError)==null?void 0:e.trim())||t("remoteStatusIssueDetailGeneric"):t("remoteStatusIssueDetailServiceStopped"):null}function G(){var b,u,x,p,v;const n=H(),r=M(),e=r.data,l=P(I=>I.actionLabel),i=m.useMemo(()=>k(e),[e]),C=m.useMemo(()=>O(e),[e]),c=!!l,g=((u=(b=e==null?void 0:e.runtime)==null?void 0:b.deviceName)==null?void 0:u.trim())||((x=e==null?void 0:e.settings.deviceName)==null?void 0:x.trim())||t("remoteDeviceNameAuto"),D=!!(e!=null&&e.account.loggedIn&&B(e)),A=!!(e!=null&&e.settings.enabled&&(e!=null&&e.account.loggedIn)&&i.badgeStatus==="warning");return m.useEffect(()=>{n.remoteAccessManager.syncStatus(e)},[n,e]),r.isLoading&&!e?a.jsx("div",{className:"p-8 text-gray-400",children:t("remoteLoading")}):a.jsxs(E,{className:"space-y-6",children:[a.jsx(T,{title:t("remotePageTitle"),description:t("remotePageDescription")}),a.jsxs("div",{className:"grid gap-6 xl:grid-cols-[1.2fr_0.8fr]",children:[a.jsxs(S,{children:[a.jsxs(j,{className:"space-y-4",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[a.jsx(h,{children:i.title}),a.jsx(d,{status:i.badgeStatus,label:i.badgeLabel})]}),a.jsx(N,{children:i.description})]}),a.jsxs(f,{className:"space-y-5",children:[a.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-gray-50 px-4 py-3",children:[a.jsx(s,{label:t("remoteSignedInAccount"),value:e==null?void 0:e.account.email}),a.jsx(s,{label:t("remoteDeviceName"),value:g}),a.jsx(s,{label:t("remoteConnectionStatus"),value:i.badgeLabel}),a.jsx(s,{label:t("remoteLastConnectedAt"),value:(p=e==null?void 0:e.runtime)!=null&&p.lastConnectedAt?y(e.runtime.lastConnectedAt):"-",muted:!0})]}),a.jsxs("div",{className:"flex flex-wrap gap-3",children:[e!=null&&e.account.loggedIn?e.settings.enabled?a.jsxs(o,{onClick:()=>void n.remoteAccessManager.repairRemoteAccess(e),disabled:c,children:[a.jsx(w,{className:"mr-2 h-4 w-4"}),l||t("remoteReconnectNow")]}):a.jsx(o,{onClick:()=>void n.remoteAccessManager.enableRemoteAccess(e),disabled:c,children:l||t("remoteEnableNow")}):a.jsx(o,{onClick:()=>void n.remoteAccessManager.enableRemoteAccess(e),disabled:c,children:l||t("remoteSignInAndEnable")}),a.jsxs(o,{variant:"outline",onClick:()=>void n.accountManager.openNextClawWeb(),disabled:c||!D,children:[a.jsx(L,{className:"mr-2 h-4 w-4"}),t("remoteOpenDeviceList")]}),e!=null&&e.settings.enabled?a.jsx(o,{variant:"outline",onClick:()=>void n.remoteAccessManager.disableRemoteAccess(e),disabled:c,children:t("remoteDisable")}):null]}),A?a.jsxs("div",{className:"rounded-2xl border border-amber-200 bg-amber-50 px-4 py-3",children:[a.jsx("p",{className:"text-sm font-medium text-amber-900",children:t("remoteStatusIssueDetailTitle")}),a.jsx("p",{className:"mt-1 text-sm leading-6 text-amber-800",children:C})]}):null,a.jsx("p",{className:"text-xs text-gray-500",children:t("remoteOpenWebHint")})]})]}),a.jsxs(S,{children:[a.jsxs(j,{children:[a.jsxs(h,{className:"flex items-center gap-2",children:[a.jsx(R,{className:"h-4 w-4 text-primary"}),t("remoteDeviceSectionTitle")]}),a.jsx(N,{children:t("remoteDeviceSectionDescription")})]}),a.jsxs(f,{className:"space-y-5",children:[a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsx(d,{status:e!=null&&e.account.loggedIn?"ready":"inactive",label:e!=null&&e.account.loggedIn?t("remoteAccountConnected"):t("remoteAccountNotConnected")}),a.jsx(d,{status:e!=null&&e.settings.enabled?"active":"inactive",label:e!=null&&e.settings.enabled?t("remoteEnabled"):t("remoteStateDisabled")}),a.jsx(d,{status:e!=null&&e.service.running?"active":"inactive",label:e!=null&&e.service.running?t("remoteServiceRunning"):t("remoteServiceStopped")})]}),a.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-gray-50 px-4 py-3",children:[a.jsx(s,{label:t("remoteDeviceName"),value:g}),a.jsx(s,{label:t("remoteConnectionStatus"),value:i.badgeLabel}),a.jsx(s,{label:t("remoteLastConnectedAt"),value:(v=e==null?void 0:e.runtime)!=null&&v.lastConnectedAt?y(e.runtime.lastConnectedAt):"-",muted:!0})]}),a.jsx("div",{className:"rounded-2xl border border-dashed border-gray-200 bg-gray-50 px-4 py-3 text-sm text-gray-600",children:e!=null&&e.account.loggedIn?t("remoteOpenWebHint"):t("remoteStatusNeedsSignInDescription")})]})]})]})]})}export{G as RemoteAccessPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as p,j as e,az as ee,at as ae,b3 as de,e as se}from"./vendor-CmQZsDAE.js";import{u as me,b as he,a2 as ue,t,C as R,a3 as z,a4 as $,a5 as D,z as L,I as i,S as te,e as re,f as ne,g as le,h as S,B as w}from"./index-
|
|
1
|
+
import{r as p,j as e,az as ee,at as ae,b3 as de,e as se}from"./vendor-CmQZsDAE.js";import{u as me,b as he,a2 as ue,t,C as R,a3 as z,a4 as $,a5 as D,z as L,I as i,S as te,e as re,f as ne,g as le,h as S,B as w}from"./index-DvA7S11O.js";import{S as pe}from"./switch-PvjTvlcs.js";import{h as x}from"./config-hints-CApS3K_7.js";import{P as xe,a as ge}from"./page-layout-DEq5N_8L.js";const je=[{value:"main",label:"main"},{value:"per-peer",label:"per-peer"},{value:"per-channel-peer",label:"per-channel-peer"},{value:"per-account-channel-peer",label:"per-account-channel-peer"}];function ve(){return{id:"",default:!1,workspace:"",model:"",engine:"",contextTokens:void 0,maxToolIterations:void 0}}function fe(){return{agentId:"",match:{channel:"",accountId:""}}}function ce(d){const b=d.trim();if(!b)return;const j=Number.parseInt(b,10);return Number.isFinite(j)?j:void 0}function Ce(){const{data:d,isLoading:b}=me(),{data:j}=he(),A=ue(),[_,N]=p.useState([]),[q,E]=p.useState([]),[K,F]=p.useState("per-channel-peer"),[V,U]=p.useState(0),[G,J]=p.useState(2e5),[Q,W]=p.useState("native");p.useEffect(()=>{var a,r,n;d&&(N((d.agents.list??[]).map(s=>({id:s.id??"",default:!!s.default,workspace:s.workspace??"",model:s.model??"",engine:s.engine??"",contextTokens:s.contextTokens,maxToolIterations:s.maxToolIterations}))),E((d.bindings??[]).map(s=>{var c,l,o;return{agentId:s.agentId??"",match:{channel:((c=s.match)==null?void 0:c.channel)??"",accountId:((l=s.match)==null?void 0:l.accountId)??"",peer:(o=s.match)!=null&&o.peer?{kind:s.match.peer.kind,id:s.match.peer.id}:void 0}}})),F(((a=d.session)==null?void 0:a.dmScope)??"per-channel-peer"),U(((n=(r=d.session)==null?void 0:r.agentToAgent)==null?void 0:n.maxPingPongTurns)??0),J(d.agents.defaults.contextTokens??2e5),W(d.agents.defaults.engine??"native"))},[d]);const u=j==null?void 0:j.uiHints,h=x("session.dmScope",u),v=x("session.agentToAgent.maxPingPongTurns",u),f=x("agents.defaults.contextTokens",u),I=x("agents.defaults.engine",u),O=x("agents.list.*.contextTokens",u),B=x("agents.list.*.engine",u),y=x("agents.list",u),k=x("bindings",u),oe=p.useMemo(()=>{const a=new Set(["main"]);return _.forEach(r=>{const n=r.id.trim();n&&a.add(n)}),a},[_]),g=(a,r)=>{N(n=>n.map((s,c)=>c===a?{...s,...r}:s))},T=(a,r)=>{E(n=>n.map((s,c)=>c===a?r:s))},ie=()=>{try{const a=_.map((s,c)=>{var m,C,P;const l=s.id.trim();if(!l)throw new Error(t("agentIdRequiredError").replace("{index}",String(c)));const o={id:l};return s.default&&(o.default=!0),(m=s.workspace)!=null&&m.trim()&&(o.workspace=s.workspace.trim()),(C=s.model)!=null&&C.trim()&&(o.model=s.model.trim()),(P=s.engine)!=null&&P.trim()&&(o.engine=s.engine.trim()),typeof s.contextTokens=="number"&&(o.contextTokens=Math.max(1e3,s.contextTokens)),typeof s.maxToolIterations=="number"&&(o.maxToolIterations=s.maxToolIterations),o}),r=a.map(s=>s.id).filter((s,c,l)=>l.indexOf(s)!==c);if(r.length>0){se.error(`${t("duplicateAgentId")}: ${r[0]}`);return}const n=q.map((s,c)=>{var X,Y,Z,H;const l=s.agentId.trim(),o=s.match.channel.trim(),m=((X=s.match.accountId)==null?void 0:X.trim())??"",C=(Y=s.match.peer)==null?void 0:Y.kind,P=((H=(Z=s.match.peer)==null?void 0:Z.id)==null?void 0:H.trim())??"";if(!l)throw new Error(t("bindingAgentIdRequired").replace("{index}",String(c)));if(!oe.has(l))throw new Error(`${t("bindingAgentIdNotFound").replace("{index}",String(c))}: ${l}`);if(!o)throw new Error(t("bindingChannelRequired").replace("{index}",String(c)));const M={agentId:l,match:{channel:o}};if(m&&(M.match.accountId=m),C){if(!P)throw new Error(t("bindingPeerIdRequired").replace("{index}",String(c)));M.match.peer={kind:C,id:P}}return M});A.mutate({data:{agents:{defaults:{contextTokens:Math.max(1e3,G),engine:Q.trim()||"native"},list:a},bindings:n,session:{dmScope:K,agentToAgent:{maxPingPongTurns:Math.min(5,Math.max(0,V))}}}})}catch(a){const r=a instanceof Error?a.message:String(a);se.error(r)}};return b||!d?e.jsx("div",{className:"p-8 text-gray-400",children:t("runtimeLoading")}):e.jsxs(xe,{className:"space-y-6",children:[e.jsx(ge,{title:t("runtimePageTitle"),description:t("runtimePageDescription")}),e.jsxs(R,{children:[e.jsxs(z,{children:[e.jsx($,{children:(h==null?void 0:h.label)??t("dmScope")}),e.jsx(D,{children:(h==null?void 0:h.help)??t("dmScopeHelp")})]}),e.jsxs(L,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(f==null?void 0:f.label)??t("defaultContextTokens")}),e.jsx(i,{type:"number",min:1e3,step:1e3,value:G,onChange:a=>J(Math.max(1e3,Number.parseInt(a.target.value,10)||1e3))}),e.jsx("p",{className:"text-xs text-gray-500",children:(f==null?void 0:f.help)??t("defaultContextTokensHelp")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(I==null?void 0:I.label)??t("defaultEngine")}),e.jsx(i,{value:Q,onChange:a=>W(a.target.value),placeholder:t("defaultEnginePlaceholder")}),e.jsx("p",{className:"text-xs text-gray-500",children:(I==null?void 0:I.help)??t("defaultEngineHelp")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(h==null?void 0:h.label)??t("dmScope")}),e.jsxs(te,{value:K,onValueChange:a=>F(a),children:[e.jsx(re,{children:e.jsx(ne,{})}),e.jsx(le,{children:je.map(a=>e.jsx(S,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(v==null?void 0:v.label)??t("maxPingPongTurns")}),e.jsx(i,{type:"number",min:0,max:5,value:V,onChange:a=>U(Math.max(0,Number.parseInt(a.target.value,10)||0))}),e.jsx("p",{className:"text-xs text-gray-500",children:(v==null?void 0:v.help)??t("maxPingPongTurnsHelp")})]})]})]}),e.jsxs(R,{children:[e.jsxs(z,{children:[e.jsx($,{children:(y==null?void 0:y.label)??t("agentList")}),e.jsx(D,{children:(y==null?void 0:y.help)??t("agentListHelp")})]}),e.jsxs(L,{className:"space-y-3",children:[_.map((a,r)=>e.jsxs("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(i,{value:a.id,onChange:n=>g(r,{id:n.target.value}),placeholder:t("agentIdPlaceholder")}),e.jsx(i,{value:a.workspace??"",onChange:n=>g(r,{workspace:n.target.value}),placeholder:t("workspaceOverridePlaceholder")}),e.jsx(i,{value:a.model??"",onChange:n=>g(r,{model:n.target.value}),placeholder:t("modelOverridePlaceholder")}),e.jsx(i,{value:a.engine??"",onChange:n=>g(r,{engine:n.target.value}),placeholder:(B==null?void 0:B.label)??t("engineOverridePlaceholder")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsx(i,{type:"number",min:1e3,step:1e3,value:a.contextTokens??"",onChange:n=>g(r,{contextTokens:ce(n.target.value)}),placeholder:(O==null?void 0:O.label)??t("contextTokensPlaceholder")}),e.jsx(i,{type:"number",min:1,value:a.maxToolIterations??"",onChange:n=>g(r,{maxToolIterations:ce(n.target.value)}),placeholder:t("maxToolsPlaceholder")})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[e.jsx(pe,{checked:!!a.default,onCheckedChange:n=>{if(!n){g(r,{default:!1});return}N(s=>s.map((c,l)=>({...c,default:l===r})))}}),e.jsx("span",{children:t("defaultAgent")})]}),e.jsxs(w,{type:"button",variant:"outline",size:"sm",onClick:()=>N(n=>n.filter((s,c)=>c!==r)),children:[e.jsx(ee,{className:"h-4 w-4 mr-1"}),t("remove")]})]})]},`${r}-${a.id}`)),e.jsxs(w,{type:"button",variant:"outline",onClick:()=>N(a=>[...a,ve()]),children:[e.jsx(ae,{className:"h-4 w-4 mr-2"}),t("addAgent")]})]})]}),e.jsxs(R,{children:[e.jsxs(z,{children:[e.jsx($,{children:(k==null?void 0:k.label)??t("bindings")}),e.jsx(D,{children:(k==null?void 0:k.help)??t("bindingsHelp")})]}),e.jsxs(L,{className:"space-y-3",children:[q.map((a,r)=>{var s,c;const n=((s=a.match.peer)==null?void 0:s.kind)??"";return e.jsxs("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[e.jsx(i,{value:a.agentId,onChange:l=>T(r,{...a,agentId:l.target.value}),placeholder:t("targetAgentIdPlaceholder")}),e.jsx(i,{value:a.match.channel,onChange:l=>T(r,{...a,match:{...a.match,channel:l.target.value}}),placeholder:t("channelPlaceholder")}),e.jsx(i,{value:a.match.accountId??"",onChange:l=>T(r,{...a,match:{...a.match,accountId:l.target.value}}),placeholder:t("accountIdOptionalPlaceholder")}),e.jsxs(te,{value:n||"__none__",onValueChange:l=>{var m;const o=l==="__none__"?"":l;if(!o){T(r,{...a,match:{...a.match,peer:void 0}});return}T(r,{...a,match:{...a.match,peer:{kind:o,id:((m=a.match.peer)==null?void 0:m.id)??""}}})},children:[e.jsx(re,{children:e.jsx(ne,{})}),e.jsxs(le,{children:[e.jsx(S,{value:"__none__",children:t("peerKindOptional")}),e.jsx(S,{value:"direct",children:"direct"}),e.jsx(S,{value:"group",children:"group"}),e.jsx(S,{value:"channel",children:"channel"})]})]}),e.jsx(i,{value:((c=a.match.peer)==null?void 0:c.id)??"",onChange:l=>T(r,{...a,match:{...a.match,peer:n?{kind:n,id:l.target.value}:void 0}}),placeholder:t("peerIdPlaceholder")})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(w,{type:"button",variant:"outline",size:"sm",onClick:()=>E(l=>l.filter((o,m)=>m!==r)),children:[e.jsx(ee,{className:"h-4 w-4 mr-1"}),t("remove")]})})]},`${r}-${a.agentId}`)}),e.jsxs(w,{type:"button",variant:"outline",onClick:()=>E(a=>[...a,fe()]),children:[e.jsx(ae,{className:"h-4 w-4 mr-2"}),t("addBinding")]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(w,{type:"button",onClick:ie,disabled:A.isPending,children:[e.jsx(de,{className:"h-4 w-4 mr-2"}),A.isPending?t("saving"):t("saveRuntimeSettings")]})})]})}export{Ce as RuntimeConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as l,j as e,G as X,ah as Z,K as $}from"./vendor-CmQZsDAE.js";import{P as ee,a as se}from"./page-layout-
|
|
1
|
+
import{r as l,j as e,G as X,ah as Z,K as $}from"./vendor-CmQZsDAE.js";import{P as ee,a as se}from"./page-layout-DEq5N_8L.js";import{u as ae,a as re,R as le,t as a,c as k,B as j,S as b,e as y,f as g,g as N,h as m,I as h}from"./index-DvA7S11O.js";import{L as c}from"./label-DzwitL78.js";import{C as te,a as ce,b as ne}from"./config-layout-BHnOoweL.js";const ie=[{value:"noLimit",label:"searchFreshnessNoLimit"},{value:"oneDay",label:"searchFreshnessOneDay"},{value:"oneWeek",label:"searchFreshnessOneWeek"},{value:"oneMonth",label:"searchFreshnessOneMonth"},{value:"oneYear",label:"searchFreshnessOneYear"}];function ue(){var O;const{data:u}=ae(),{data:n}=re(),x=le(),i=(n==null?void 0:n.search)??[],r=u==null?void 0:u.search,[t,f]=l.useState("bocha"),[S,P]=l.useState("bocha"),[d,C]=l.useState(["bocha"]),[w,B]=l.useState("10"),[A,T]=l.useState(""),[D,K]=l.useState("https://api.bocha.cn/v1/web-search"),[L,U]=l.useState(!0),[E,R]=l.useState("noLimit"),[F,V]=l.useState(""),[I,_]=l.useState("https://api.search.brave.com/res/v1/web/search");l.useEffect(()=>{r&&(f(r.provider),P(r.provider),C(r.enabledProviders),B(String(r.defaults.maxResults)),K(r.providers.bocha.baseUrl),U(!!r.providers.bocha.summary),R(r.providers.bocha.freshness??"noLimit"),_(r.providers.brave.baseUrl))},[r]);const v=l.useMemo(()=>i.find(s=>s.name===t),[i,t]),G=r==null?void 0:r.providers[t],p=d.includes(t),H=(r==null?void 0:r.providers.bocha.docsUrl)??((O=n==null?void 0:n.search.find(s=>s.name==="bocha"))==null?void 0:O.docsUrl)??"https://open.bocha.cn",W=p?a("searchProviderDeactivate"):a("searchProviderActivate"),M=(s=d,o=S)=>({provider:o,enabledProviders:s,defaults:{maxResults:Number(w)||10},providers:{bocha:{apiKey:A||void 0,baseUrl:D,summary:L,freshness:E},brave:{apiKey:F||void 0,baseUrl:I}}}),Y=()=>{const s=p?d.filter(o=>o!==t):[...d,t];C(s),x.mutate({data:M(s)})},q=s=>{P(s)},z=s=>{s.preventDefault(),x.mutate({data:M()})};return!r||i.length===0?e.jsx("div",{className:"p-8",children:a("loading")}):e.jsxs(ee,{children:[e.jsx(se,{title:a("searchPageTitle"),description:a("searchPageDescription")}),e.jsxs("div",{className:te,children:[e.jsxs("section",{className:ce,children:[e.jsx("div",{className:"border-b border-gray-100 px-4 py-4",children:e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-gray-500",children:a("searchChannels")})}),e.jsx("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto p-3",children:i.map(s=>{const o=r.providers[s.name],J=d.includes(s.name),Q=t===s.name;return e.jsx("button",{type:"button",onClick:()=>f(s.name),className:k("w-full rounded-xl border p-3 text-left transition-all",Q?"border-primary/30 bg-primary-50/40 shadow-sm":"border-gray-200/70 bg-white hover:border-gray-300 hover:bg-gray-50/70"),children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:s.displayName}),e.jsx("p",{className:"line-clamp-2 text-[11px] text-gray-500",children:s.name==="bocha"?a("searchProviderBochaDescription"):a("searchProviderBraveDescription")})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsx("span",{className:"rounded-full bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600",children:o.apiKeySet?a("searchStatusConfigured"):a("searchStatusNeedsSetup")}),J?e.jsx("span",{className:"rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700",children:a("searchProviderActivated")}):null]})]})},s.name)})})]}),e.jsx("form",{onSubmit:z,className:k(ne,"p-6"),children:!v||!G?e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-gray-500",children:a("searchNoProviderSelected")}):e.jsxs("div",{className:"space-y-6 overflow-y-auto",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white",children:e.jsx(X,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:v.displayName}),e.jsx("p",{className:"text-sm text-gray-500",children:v.description})]})]}),e.jsx(j,{type:"button",variant:p?"secondary":"outline",className:"rounded-xl",onClick:Y,children:W})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchActiveProvider")}),e.jsxs(b,{value:S,onValueChange:q,children:[e.jsx(y,{className:"rounded-xl",children:e.jsx(g,{})}),e.jsx(N,{children:i.map(s=>e.jsx(m,{value:s.name,children:s.displayName},s.name))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchDefaultMaxResults")}),e.jsx(h,{value:w,onChange:s=>B(s.target.value),inputMode:"numeric",className:"rounded-xl"})]})]}),t==="bocha"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("apiKey")}),e.jsx(h,{type:"password",value:A,onChange:s=>T(s.target.value),placeholder:r.providers.bocha.apiKeyMasked||a("enterApiKey"),className:"rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchProviderBaseUrl")}),e.jsx(h,{value:D,onChange:s=>K(s.target.value),className:"rounded-xl"})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchProviderSummary")}),e.jsxs(b,{value:L?"true":"false",onValueChange:s=>U(s==="true"),children:[e.jsx(y,{className:"rounded-xl",children:e.jsx(g,{})}),e.jsxs(N,{children:[e.jsx(m,{value:"true",children:a("enabled")}),e.jsx(m,{value:"false",children:a("disabled")})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchProviderFreshness")}),e.jsxs(b,{value:E,onValueChange:R,children:[e.jsx(y,{className:"rounded-xl",children:e.jsx(g,{})}),e.jsx(N,{children:ie.map(s=>e.jsx(m,{value:s.value,children:a(s.label)},s.value))})]})]})]}),e.jsx("div",{className:"space-y-2",children:e.jsx("a",{href:H,target:"_blank",rel:"noreferrer",children:e.jsxs(j,{type:"button",variant:"outline",className:"rounded-xl",children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),a("searchProviderOpenDocs")]})})})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("apiKey")}),e.jsx(h,{type:"password",value:F,onChange:s=>V(s.target.value),placeholder:r.providers.brave.apiKeyMasked||a("enterApiKey"),className:"rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchProviderBaseUrl")}),e.jsx(h,{value:I,onChange:s=>_(s.target.value),className:"rounded-xl"})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(j,{type:"submit",disabled:x.isPending,children:[e.jsx($,{className:"mr-2 h-4 w-4"}),x.isPending?a("saving"):a("saveChanges")]})})]})})]})]})}export{ue as SearchConfig};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as u,j as e,az as H,at as L,b3 as G,e as J}from"./vendor-CmQZsDAE.js";import{u as K,ae as Q,t as a,C as R,a3 as T,a4 as M,a5 as O,z as A,S as x,e as m,f as p,g as j,h as o,I as h,B as _}from"./index-
|
|
1
|
+
import{r as u,j as e,az as H,at as L,b3 as G,e as J}from"./vendor-CmQZsDAE.js";import{u as K,ae as Q,t as a,C as R,a3 as T,a4 as M,a5 as O,z as A,S as x,e as m,f as p,g as j,h as o,I as h,B as _}from"./index-DvA7S11O.js";import{L as k}from"./label-DzwitL78.js";import{S as W}from"./switch-PvjTvlcs.js";import{P as X,a as Y}from"./page-layout-DEq5N_8L.js";const z=["env","file","exec"];function N(n=""){return{alias:n,source:"env",prefix:"",path:"",command:"",argsText:"",cwd:"",timeoutMs:5e3}}function Z(){return{path:"",source:"env",provider:"",id:""}}function ee(n,l){return l.source==="env"?{...N(n),source:"env",prefix:l.prefix??""}:l.source==="file"?{...N(n),source:"file",path:l.path}:{...N(n),source:"exec",command:l.command,argsText:(l.args??[]).join(`
|
|
2
2
|
`),cwd:l.cwd??"",timeoutMs:l.timeoutMs??5e3}}function se(n){return n.source==="env"?{source:"env",...n.prefix.trim()?{prefix:n.prefix.trim()}:{}}:n.source==="file"?{source:"file",path:n.path.trim(),format:"json"}:{source:"exec",command:n.command.trim(),args:n.argsText.split(`
|
|
3
3
|
`).map(l=>l.trim()).filter(Boolean),...n.cwd.trim()?{cwd:n.cwd.trim()}:{},timeoutMs:Math.max(1,Math.trunc(n.timeoutMs||5e3))}}function ie(){const{data:n,isLoading:l}=K(),P=Q(),[D,y]=u.useState(!0),[I,E]=u.useState(""),[V,S]=u.useState(""),[F,$]=u.useState(""),[C,f]=u.useState([]),[q,v]=u.useState([]);u.useEffect(()=>{const s=n==null?void 0:n.secrets;if(!s){y(!0),E(""),S(""),$(""),f([]),v([]);return}y(!!s.enabled),E(s.defaults.env??""),S(s.defaults.file??""),$(s.defaults.exec??"");const t=Object.entries(s.providers).map(([c,i])=>ee(c,i)),r=Object.entries(s.refs).map(([c,i])=>({path:c,source:i.source,provider:i.provider??"",id:i.id}));f(t),v(r)},[n==null?void 0:n.secrets]);const w=u.useMemo(()=>{const s=C.map(t=>t.alias.trim()).filter(Boolean);return Array.from(new Set(s))},[C]),d=(s,t)=>{f(r=>r.map((c,i)=>i===s?{...c,...t}:c))},b=(s,t)=>{v(r=>r.map((c,i)=>i===s?{...c,...t}:c))},U=()=>{try{const s={};for(const[r,c]of C.entries()){const i=c.alias.trim();if(!i)throw new Error(`${a("providerAlias")} #${r+1} ${a("isRequired")}`);if(s[i])throw new Error(`${a("providerAlias")}: ${i} (${a("duplicate")})`);if(c.source==="file"&&!c.path.trim())throw new Error(`${a("secretFilePath")} #${r+1} ${a("isRequired")}`);if(c.source==="exec"&&!c.command.trim())throw new Error(`${a("secretExecCommand")} #${r+1} ${a("isRequired")}`);s[i]=se(c)}const t={};for(const[r,c]of q.entries()){const i=c.path.trim(),B=c.id.trim();if(!i)throw new Error(`${a("secretConfigPath")} #${r+1} ${a("isRequired")}`);if(!B)throw new Error(`${a("secretId")} #${r+1} ${a("isRequired")}`);const g=c.provider.trim();if(g&&!s[g])throw new Error(`${a("secretProviderAlias")}: ${g} ${a("notFound")}`);t[i]={source:c.source,...g?{provider:g}:{},id:B}}P.mutate({data:{enabled:D,defaults:{env:I.trim()||null,file:V.trim()||null,exec:F.trim()||null},providers:s,refs:t}})}catch(s){const t=s instanceof Error?s.message:String(s);J.error(t)}};return l?e.jsx("div",{className:"p-8 text-gray-400",children:a("loading")}):e.jsxs(X,{className:"space-y-6",children:[e.jsx(Y,{title:a("secretsPageTitle"),description:a("secretsPageDescription")}),e.jsxs(R,{children:[e.jsxs(T,{children:[e.jsx(M,{children:a("secrets")}),e.jsx(O,{children:a("secretsEnabledHelp")})]}),e.jsxs(A,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-gray-200 p-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-800",children:a("enabled")}),e.jsx("p",{className:"text-xs text-gray-500",children:a("secretsEnabledHelp")})]}),e.jsx(W,{checked:D,onCheckedChange:y})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:a("defaultEnvProvider")}),e.jsxs(x,{value:I||"__none__",onValueChange:s=>E(s==="__none__"?"":s),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("noneOption")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(s=>e.jsx(o,{value:s,children:s},s))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:a("defaultFileProvider")}),e.jsxs(x,{value:V||"__none__",onValueChange:s=>S(s==="__none__"?"":s),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("noneOption")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(s=>e.jsx(o,{value:s,children:s},s))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:a("defaultExecProvider")}),e.jsxs(x,{value:F||"__none__",onValueChange:s=>$(s==="__none__"?"":s),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("noneOption")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(s=>e.jsx(o,{value:s,children:s},s))]})]})]})]})]})]}),e.jsxs(R,{children:[e.jsxs(T,{children:[e.jsx(M,{children:a("secretProvidersTitle")}),e.jsx(O,{children:a("secretProvidersDescription")})]}),e.jsxs(A,{className:"space-y-3",children:[C.map((s,t)=>e.jsxs("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsx(h,{value:s.alias,onChange:r=>d(t,{alias:r.target.value}),placeholder:a("providerAlias")}),e.jsxs(x,{value:s.source,onValueChange:r=>d(t,{source:r}),children:[e.jsx(m,{children:e.jsx(p,{})}),e.jsx(j,{children:z.map(r=>e.jsx(o,{value:r,children:r},r))})]}),e.jsxs(_,{type:"button",variant:"outline",onClick:()=>f(r=>r.filter((c,i)=>i!==t)),children:[e.jsx(H,{className:"h-4 w-4 mr-2"}),a("removeProvider")]})]}),s.source==="env"&&e.jsx(h,{value:s.prefix,onChange:r=>d(t,{prefix:r.target.value}),placeholder:a("envPrefix")}),s.source==="file"&&e.jsx(h,{value:s.path,onChange:r=>d(t,{path:r.target.value}),placeholder:a("secretFilePath")}),s.source==="exec"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{value:s.command,onChange:r=>d(t,{command:r.target.value}),placeholder:a("secretExecCommand")}),e.jsx("textarea",{className:"min-h-[84px] w-full rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-mono",value:s.argsText,onChange:r=>d(t,{argsText:r.target.value}),placeholder:a("secretExecArgs")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsx(h,{value:s.cwd,onChange:r=>d(t,{cwd:r.target.value}),placeholder:a("secretExecCwd")}),e.jsx(h,{type:"number",min:1,value:s.timeoutMs,onChange:r=>d(t,{timeoutMs:Number.parseInt(r.target.value,10)||5e3}),placeholder:a("secretExecTimeoutMs")})]})]})]},`provider-${t}`)),e.jsxs(_,{type:"button",variant:"outline",onClick:()=>f(s=>[...s,N()]),children:[e.jsx(L,{className:"h-4 w-4 mr-2"}),a("addSecretProvider")]})]})]}),e.jsxs(R,{children:[e.jsxs(T,{children:[e.jsx(M,{children:a("secretRefsTitle")}),e.jsx(O,{children:a("secretRefsDescription")})]}),e.jsxs(A,{className:"space-y-3",children:[q.map((s,t)=>e.jsx("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(h,{value:s.path,onChange:r=>b(t,{path:r.target.value}),placeholder:a("secretConfigPath")}),e.jsx(h,{value:s.id,onChange:r=>b(t,{id:r.target.value}),placeholder:a("secretId")}),e.jsxs(x,{value:s.source,onValueChange:r=>b(t,{source:r}),children:[e.jsx(m,{children:e.jsx(p,{})}),e.jsx(j,{children:z.map(r=>e.jsx(o,{value:r,children:r},r))})]}),e.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-2",children:[e.jsxs(x,{value:s.provider||"__none__",onValueChange:r=>b(t,{provider:r==="__none__"?"":r}),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("secretProviderAlias")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(r=>e.jsx(o,{value:r,children:r},r))]})]}),e.jsx(_,{type:"button",variant:"outline",onClick:()=>v(r=>r.filter((c,i)=>i!==t)),children:e.jsx(H,{className:"h-4 w-4"})})]})]})},`ref-${t}`)),e.jsxs(_,{type:"button",variant:"outline",onClick:()=>v(s=>[...s,Z()]),children:[e.jsx(L,{className:"h-4 w-4 mr-2"}),a("addSecretRef")]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(_,{type:"button",onClick:U,disabled:P.isPending,children:[e.jsx(G,{className:"h-4 w-4 mr-2"}),P.isPending?a("saving"):a("save")]})})]})}export{ie as SecretsConfig};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r,j as e,aA as I,G as J,b4 as T,b1 as X,a0 as Z,M as Q,b5 as ee,ak as se,al as te}from"./vendor-CmQZsDAE.js";import{u as ae}from"./useConfirmDialog-
|
|
1
|
+
import{r,j as e,aA as I,G as J,b4 as T,b1 as X,a0 as Z,M as Q,b5 as ee,ak as se,al as te}from"./vendor-CmQZsDAE.js";import{u as ae}from"./useConfirmDialog-8tzzp_oW.js";import{j as re,i as ne,l as le,ab as ie,ac as oe,t,B as f,c as i,S as de,e as ce,f as xe,g as me,h as U,I as k,ad as ue,s as he}from"./index-DvA7S11O.js";import{b as ge,a as fe,S as ye,e as be}from"./chat-message-B6VCCEXF.js";import{P as pe,a as je}from"./page-layout-DEq5N_8L.js";const y="__unknown_channel__";function ve(a){return he(a)}function j(a){const l=a.indexOf(":");return l<=0?y:a.slice(0,l).trim()||y}function C(a){return a===y?t("sessionsUnknownChannel"):a}function Ne({session:a,channel:l,runStatus:d,isSelected:x,onSelect:n}){const b=C(l),m=a.label||a.key.split(":").pop()||a.key;return e.jsxs("button",{onClick:n,className:i("w-full text-left p-3.5 rounded-xl transition-all duration-200 outline-none focus:outline-none focus:ring-0 group",x?"bg-brand-50 border border-brand-100/50":"bg-transparent border border-transparent hover:bg-gray-50/80"),children:[e.jsxs("div",{className:"flex items-start justify-between mb-1.5",children:[e.jsx("div",{className:i("font-semibold truncate pr-2 flex-1 text-sm",x?"text-brand-800":"text-gray-900"),children:m}),e.jsx("div",{className:i("text-[10px] font-bold px-2 py-0.5 rounded-full shrink-0 capitalize",x?"bg-white text-brand-600 shadow-[0_1px_2px_rgba(0,0,0,0.02)]":"bg-gray-100 text-gray-500"),children:b})]}),e.jsxs("div",{className:i("flex items-center text-xs justify-between mt-2 font-medium",x?"text-brand-600/80":"text-gray-400"),children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:d?e.jsx(ye,{status:d}):null}),e.jsx(ee,{className:"w-3.5 h-3.5 opacity-70"}),e.jsx("span",{className:"truncate max-w-[100px]",children:ue(a.updatedAt)})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Q,{className:"w-3.5 h-3.5 opacity-70"}),e.jsx("span",{children:a.messageCount})]})]})]})}function we({message:a}){const l=a.role.toLowerCase()==="user",d=be(a.content).trim();return e.jsx("div",{className:i("flex w-full mb-6",l?"justify-end":"justify-start"),children:e.jsxs("div",{className:i("max-w-[85%] rounded-[1.25rem] p-5 flex gap-3 text-sm",l?"bg-primary text-white rounded-tr-sm":"bg-gray-50 text-gray-800 rounded-tl-sm border border-gray-100/50"),children:[e.jsx("div",{className:"shrink-0 pt-0.5",children:l?e.jsx(se,{className:"w-4 h-4 text-primary-100"}):e.jsx(te,{className:"w-4 h-4 text-gray-400"})}),e.jsxs("div",{className:"flex-1 space-y-1 overflow-x-hidden",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4 mb-2",children:[e.jsx("span",{className:i("font-semibold text-xs",l?"text-primary-50":"text-gray-900 capitalize"),children:a.role}),e.jsx("span",{className:i("text-[10px]",l?"text-primary-200":"text-gray-400"),children:ve(a.timestamp)})]}),e.jsx("div",{className:"whitespace-pre-wrap break-words leading-relaxed text-[15px]",children:d||"-"})]})]})})}function De(){var B,E,K,R;const[a,l]=r.useState(""),[d]=r.useState(100),[x]=r.useState(0),[n,b]=r.useState(null),[m,q]=r.useState("all"),[M,v]=r.useState(""),[L,N]=r.useState(""),[w,S]=r.useState(!1),F=r.useMemo(()=>({q:a.trim()||void 0,limit:d,activeMinutes:x}),[a,d,x]),g=re(F),D=ne({states:["queued","running"],limit:200}),u=le(n,200),p=ie(),_=oe(),{confirm:P,ConfirmDialog:O}=ae(),c=r.useMemo(()=>{var s;return((s=g.data)==null?void 0:s.sessions)??[]},[(B=g.data)==null?void 0:B.sessions]),z=r.useMemo(()=>{var s;return ge(((s=D.data)==null?void 0:s.runs)??[])},[(E=D.data)==null?void 0:E.runs]),V=r.useMemo(()=>fe(z),[z]),o=r.useMemo(()=>c.find(s=>s.key===n),[c,n]),$=r.useMemo(()=>{const s=new Set;for(const h of c)s.add(j(h.key));return Array.from(s).sort((h,A)=>h===y?1:A===y?-1:h.localeCompare(A))},[c]),H=r.useMemo(()=>m==="all"?c:c.filter(s=>j(s.key)===m),[c,m]);r.useEffect(()=>{o?(v(o.label||""),N(o.preferredModel||"")):(v(""),N("")),S(!1)},[o]);const G=()=>{n&&(p.mutate({key:n,data:{label:M.trim()||null,preferredModel:L.trim()||null}}),S(!1))},W=async()=>{if(!n)return;await P({title:t("sessionsClearHistory")+"?",variant:"destructive",confirmLabel:t("sessionsClearHistory")})&&p.mutate({key:n,data:{clearHistory:!0}})},Y=async()=>{if(!n)return;await P({title:t("sessionsDeleteConfirm")+"?",variant:"destructive",confirmLabel:t("sessionsDeleteConfirm")})&&_.mutate({key:n},{onSuccess:()=>b(null)})};return e.jsxs(pe,{fullHeight:!0,children:[e.jsx(je,{title:t("sessionsPageTitle"),description:t("sessionsPageDescription")}),e.jsxs("div",{className:"flex-1 flex gap-6 min-h-0 relative",children:[e.jsxs("div",{className:"w-[320px] flex flex-col shrink-0 bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-4 border-b border-gray-100 bg-white z-10 shrink-0 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:[c.length," ",t("sessionsListTitle")]}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100",onClick:()=>g.refetch(),children:e.jsx(I,{className:i("h-3.5 w-3.5",g.isFetching&&"animate-spin")})})]}),e.jsxs(de,{value:m,onValueChange:q,children:[e.jsx(ce,{className:"w-full h-8.5 rounded-lg bg-gray-50/50 hover:bg-gray-100 border-gray-200 focus:ring-0 shadow-none text-xs font-medium text-gray-700",children:e.jsx(xe,{placeholder:t("sessionsAllChannels")})}),e.jsxs(me,{className:"rounded-xl shadow-lg border-gray-100 max-w-[280px]",children:[e.jsx(U,{value:"all",className:"rounded-lg text-xs",children:t("sessionsAllChannels")}),$.map(s=>e.jsx(U,{value:s,className:"rounded-lg text-xs truncate pr-6",children:C(s)},s))]})]}),e.jsxs("div",{className:"relative w-full",children:[e.jsx(J,{className:"h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400"}),e.jsx(k,{value:a,onChange:s=>l(s.target.value),placeholder:t("sessionsSearchPlaceholder"),className:"pl-8 h-8.5 rounded-lg bg-gray-50/50 border-gray-200 focus-visible:bg-white text-xs"})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-1 pb-10 custom-scrollbar relative",children:g.isLoading?e.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:t("sessionsLoading")}):H.length===0?e.jsxs("div",{className:"text-sm text-gray-400 p-4 text-center border-2 border-dashed border-gray-100 rounded-xl mt-4",children:[e.jsx(T,{className:"w-8 h-8 mx-auto mb-2 text-gray-300"}),t("sessionsEmpty")]}):H.map(s=>e.jsx(Ne,{session:s,channel:j(s.key),runStatus:V.get(s.key),isSelected:n===s.key,onSelect:()=>b(s.key)},s.key))})]}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden relative bg-white rounded-2xl shadow-sm border border-gray-200",children:[(p.isPending||_.isPending)&&e.jsx("div",{className:"absolute top-0 left-0 w-full h-1 bg-primary/20 overflow-hidden z-20",children:e.jsx("div",{className:"h-full bg-primary animate-pulse w-1/3 rounded-r-full"})}),n&&o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shrink-0 border-b border-gray-100 bg-white px-8 py-5 z-10 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-[14px] bg-gray-50 border border-gray-100 flex items-center justify-center text-gray-400 shrink-0",children:e.jsx(X,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-1.5",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 tracking-tight",children:o.label||o.key.split(":").pop()||o.key}),e.jsx("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500 uppercase tracking-widest",children:C(j(o.key))})]}),e.jsx("div",{className:"text-xs text-gray-500 font-mono break-all line-clamp-1 opacity-70",title:n,children:n})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>S(!w),className:i("h-8.5 rounded-lg shadow-none border-gray-200 transition-all text-xs font-semibold",w?"bg-gray-100 text-gray-900":"hover:bg-gray-50 hover:text-gray-900"),children:[e.jsx(Z,{className:"w-3.5 h-3.5 mr-1.5"}),t("sessionsMetadata")]}),e.jsx(f,{variant:"outline",size:"sm",onClick:W,className:"h-8.5 rounded-lg shadow-none hover:bg-gray-50 hover:text-gray-900 border-gray-200 text-xs font-semibold text-gray-500",children:t("sessionsClearHistory")}),e.jsx(f,{variant:"outline",size:"sm",onClick:Y,className:"h-8.5 rounded-lg shadow-none hover:bg-red-50 hover:text-red-600 hover:border-red-200 border-gray-200 text-xs font-semibold text-red-500",children:t("delete")})]})]}),w&&e.jsxs("div",{className:"flex items-center gap-3 bg-gray-50/50 p-3 rounded-lg border border-gray-100 animate-slide-in",children:[e.jsx(k,{placeholder:t("sessionsLabelPlaceholder"),value:M,onChange:s=>v(s.target.value),className:"h-8 text-sm bg-white"}),e.jsx(k,{placeholder:t("sessionsModelPlaceholder"),value:L,onChange:s=>N(s.target.value),className:"h-8 text-sm bg-white"}),e.jsx(f,{size:"sm",onClick:G,className:"h-8 px-4 shrink-0 shadow-none",disabled:p.isPending,children:t("sessionsSaveMeta")})]})]}),e.jsxs("div",{className:`flex-1 overflow-y-auto p-6 relative
|
|
2
2
|
[&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:bg-gray-300/80 [&::-webkit-scrollbar-thumb]:rounded-full`,children:[u.isLoading&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-50/50 backdrop-blur-sm z-10",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 animate-pulse",children:[e.jsx(I,{className:"w-6 h-6 text-primary animate-spin"}),e.jsx("span",{className:"text-sm font-medium text-gray-500",children:t("sessionsHistoryLoading")})]})}),u.error&&e.jsx("div",{className:"text-center p-6 bg-red-50 rounded-xl text-red-600 border border-red-100 text-sm",children:u.error.message}),!u.isLoading&&((K=u.data)==null?void 0:K.messages.length)===0&&e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[e.jsx(Q,{className:"w-12 h-12 mb-3 text-gray-300"}),e.jsx("p",{className:"text-sm",children:t("sessionsEmpty")})]}),e.jsx("div",{className:"max-w-3xl mx-auto",children:(((R=u.data)==null?void 0:R.messages)??[]).map((s,h)=>e.jsx(we,{message:s},`${s.timestamp}-${h}`))})]})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-gray-400 p-8 h-full bg-white",children:[e.jsx("div",{className:"w-20 h-20 bg-gray-50 rounded-3xl flex items-center justify-center mb-6 border border-gray-100 shadow-[0_2px_8px_-2px_rgba(0,0,0,0.02)] rotate-3",children:e.jsx(T,{className:"h-8 w-8 text-gray-300 -rotate-3"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900 mb-2",children:t("sessionsNoSelectionTitle")}),e.jsx("p",{className:"text-sm text-center max-w-sm leading-relaxed",children:t("sessionsNoSelectionDescription")})]})]})]}),e.jsx(O,{})]})}export{De as SessionsConfig};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as u,ae as m}from"./vendor-CmQZsDAE.js";import{t as p,c as g}from"./index-
|
|
1
|
+
import{j as u,ae as m}from"./vendor-CmQZsDAE.js";import{t as p,c as g}from"./index-DvA7S11O.js";const l={queued:1,running:2};function o(t){return t==="queued"||t==="running"?t:null}function y(t){const n=Date.parse(t??"");return Number.isFinite(n)?n:0}function d(t,n){const e=o(t.state),r=o(n.state);if(!e||!r)return!1;const s=l[e],i=l[r];return i!==s?i>s:y(n.requestedAt)>=y(t.requestedAt)}function R(t){var e;const n=new Map;for(const r of t){const s=(e=r.sessionKey)==null?void 0:e.trim();if(!s||!o(r.state))continue;const i=n.get(s);(!i||d(i,r))&&n.set(s,r)}return n}function A(t){const n=new Map;for(const[e,r]of t.entries()){const s=o(r.state);s&&n.set(e,s)}return n}function j({status:t,className:n}){const e=t==="running"?p("sessionsRunStatusRunning"):p("sessionsRunStatusQueued");return u.jsxs("span",{className:g("inline-flex h-3.5 w-3.5 items-center justify-center text-gray-400",n),title:e,"aria-label":e,children:[u.jsx(m,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:"sr-only",children:e})]})}const h=["cmd","command","query","q","path","url","to","channel","agentId","sessionKey"];function c(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function f(t,n=2400){return t.length<=n?t:`${t.slice(0,n)}
|
|
2
2
|
…`}function a(t){if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(t==null)return"";try{return f(JSON.stringify(t,null,2))}catch{return String(t)}}function S(t){if(c(t))return t;if(typeof t!="string")return null;const n=t.trim();if(!n.startsWith("{")&&!n.startsWith("["))return null;try{const e=JSON.parse(n);return c(e)?e:null}catch{return null}}function T(t){const n=S(t);if(!n){const r=a(t).trim();return r?f(r,120):void 0}const e=[];for(const r of h){const s=n[r];if(typeof s=="string"&&s.trim()?e.push(`${r}: ${s.trim()}`):(typeof s=="number"||typeof s=="boolean")&&e.push(`${r}: ${String(s)}`),e.length>=2)break}return e.length>0?e.join(" · "):f(a(n),140)}function N(t){if(typeof t=="string")return t;if(Array.isArray(t)){const n=[];for(const e of t){if(typeof e=="string"){n.push(e);continue}if(c(e)){if(typeof e.text=="string"){n.push(e.text);continue}typeof e.content=="string"&&n.push(e.content)}}if(n.length>0)return n.join(`
|
|
3
3
|
`)}return a(t)}export{j as S,A as a,R as b,a as c,N as e,T as s};
|