@nextclaw/ui 0.11.22 → 0.12.0

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.
Files changed (122) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/assets/{ChannelsList-Zeys_w43.js → ChannelsList-NKNKsf1J.js} +1 -1
  3. package/dist/assets/ChatPage-p23OnnEI.js +43 -0
  4. package/dist/assets/DocBrowser-C8b2uPgL.js +1 -0
  5. package/dist/assets/{DocBrowser-BmtBLFU0.js → DocBrowser-DxdSujSc.js} +1 -1
  6. package/dist/assets/{DocBrowserContext-YIKkPb76.js → DocBrowserContext-CQ-8jMha.js} +1 -1
  7. package/dist/assets/{LogoBadge-F7ZWdxLT.js → LogoBadge-D-KQIN4U.js} +1 -1
  8. package/dist/assets/{MarketplacePage-Cd4faegU.js → MarketplacePage-CRNvxtvx.js} +2 -2
  9. package/dist/assets/MarketplacePage-GGkEXowp.js +1 -0
  10. package/dist/assets/{McpMarketplacePage-C09Ngs7O.js → McpMarketplacePage-Cu7GmCcc.js} +2 -2
  11. package/dist/assets/{ModelConfig-DJgdcgvQ.js → ModelConfig-CEpx9fro.js} +1 -1
  12. package/dist/assets/{ProvidersList-w0rVFIBf.js → ProvidersList-BWbUb7-2.js} +1 -1
  13. package/dist/assets/{RemoteAccessPage-BJ_ckkOV.js → RemoteAccessPage-NsawrZb0.js} +1 -1
  14. package/dist/assets/RuntimeConfig-BJHBsVTd.js +1 -0
  15. package/dist/assets/{SearchConfig-BT13qpR_.js → SearchConfig-BsaX_WYy.js} +1 -1
  16. package/dist/assets/{SecretsConfig-CvqEVn0B.js → SecretsConfig-CgDZOd3w.js} +1 -1
  17. package/dist/assets/{SessionsConfig-DHHcYznk.js → SessionsConfig-Dd-KM7F7.js} +2 -2
  18. package/dist/assets/{book-open-CXoF5nQC.js → book-open-FnK2xCQd.js} +1 -1
  19. package/dist/assets/chat-session-display-BD_AN71I.js +1 -0
  20. package/dist/assets/{chunk-JZWAC4HX-CvRWvTy5.js → chunk-JZWAC4HX-B5l0hr_u.js} +1 -1
  21. package/dist/assets/{config-DJswxxE8.js → config-JKmXfZ3q.js} +1 -1
  22. package/dist/assets/{createLucideIcon-CjGHOWb6.js → createLucideIcon-o1WWhwhd.js} +1 -1
  23. package/dist/assets/{dist-nqTTbVdA.js → dist-C_moWYv7.js} +1 -1
  24. package/dist/assets/{dist-Cl2QB-2y.js → dist-DazA6Wd_.js} +1 -1
  25. package/dist/assets/{external-link-tIO7zING.js → external-link-BKje3SiD.js} +1 -1
  26. package/dist/assets/{hash-JWUyl1pT.js → hash-DfW4DT8O.js} +1 -1
  27. package/dist/assets/i18n-BK1w-oBy.js +1 -0
  28. package/dist/assets/index-BZaB1TqM.js +6 -0
  29. package/dist/assets/index-DaR9igPC.css +1 -0
  30. package/dist/assets/{label-BIpeNu4r.js → label-BzDWmdOe.js} +1 -1
  31. package/dist/assets/loader-circle-DdZPxBUz.js +1 -0
  32. package/dist/assets/{logos-DThdM9lk.js → logos-CTLlde_T.js} +1 -1
  33. package/dist/assets/{page-layout-D3Xo605Z.js → page-layout-BagR3t59.js} +1 -1
  34. package/dist/assets/plus-DP2PSCPO.js +1 -0
  35. package/dist/assets/{popover-BJRUGA_H.js → popover-5DWhNfd4.js} +1 -1
  36. package/dist/assets/{provider-models-bz5y28rq.js → provider-models-DJ29qHuA.js} +1 -1
  37. package/dist/assets/{react-7ZHqQtEV.js → react-C3yu5yge.js} +1 -1
  38. package/dist/assets/{refresh-ccw-CC6-_QuL.js → refresh-ccw-BAJf-h7w.js} +1 -1
  39. package/dist/assets/{save-DJM5RRWW.js → save-aa6z4GJL.js} +1 -1
  40. package/dist/assets/search-pD6ZwQYF.js +1 -0
  41. package/dist/assets/{security-config-T5zpg16O.js → security-config-DRDxrApx.js} +1 -1
  42. package/dist/assets/{select-DSkTc61S.js → select-BHJPiJWt.js} +1 -1
  43. package/dist/assets/skeleton-D6kCk9Y6.js +1 -0
  44. package/dist/assets/{status-dot-LNBlDu3q.js → status-dot-DUwsTIdv.js} +1 -1
  45. package/dist/assets/{switch-Bo-Y46HZ.js → switch-B6nCfcOB.js} +1 -1
  46. package/dist/assets/{tabs-custom-DXv507_2.js → tabs-custom-B57SMElx.js} +1 -1
  47. package/dist/assets/{trash-2-DFZmW6Gg.js → trash-2-CrjYH5ok.js} +1 -1
  48. package/dist/assets/{useConfirmDialog-Bs5Ll17m.js → useConfirmDialog-DsxnXB1B.js} +1 -1
  49. package/dist/assets/{useMutation-DrZrOgVL.js → useMutation-oTTWXgLG.js} +1 -1
  50. package/dist/assets/x-CTIQHUuD.js +1 -0
  51. package/dist/index.html +18 -18
  52. package/package.json +5 -5
  53. package/src/App.tsx +2 -0
  54. package/src/api/agents.ts +26 -0
  55. package/src/api/types.ts +27 -2
  56. package/src/components/agents/AgentsPage.test.tsx +70 -0
  57. package/src/components/agents/AgentsPage.tsx +353 -0
  58. package/src/components/chat/ChatConversationPanel.test.tsx +144 -8
  59. package/src/components/chat/ChatConversationPanel.tsx +136 -77
  60. package/src/components/chat/ChatSidebar.test.tsx +8 -0
  61. package/src/components/chat/ChatSidebar.tsx +11 -0
  62. package/src/components/chat/ChatWelcome.test.tsx +25 -0
  63. package/src/components/chat/ChatWelcome.tsx +47 -1
  64. package/src/components/chat/adapters/chat-message-part.adapter.ts +18 -5
  65. package/src/components/chat/adapters/chat-message-tool-agent-id.test.ts +102 -0
  66. package/src/components/chat/adapters/chat-message-tool-agent-id.ts +47 -0
  67. package/src/components/chat/adapters/chat-message.adapter.test.ts +89 -9
  68. package/src/components/chat/adapters/chat-message.session-request-tool-card.ts +200 -0
  69. package/src/components/chat/chat-child-session-panel.tsx +166 -0
  70. package/src/components/chat/chat-page-runtime.test.ts +1 -0
  71. package/src/components/chat/chat-page-shell.tsx +8 -17
  72. package/src/components/chat/chat-session-display.test.ts +1 -0
  73. package/src/components/chat/chat-session-route.ts +0 -14
  74. package/src/components/chat/chat-sidebar-session-item.tsx +16 -1
  75. package/src/components/chat/containers/chat-input-bar.container.tsx +2 -1
  76. package/src/components/chat/containers/chat-message-list.container.tsx +11 -0
  77. package/src/components/chat/ncp/NcpChatPage.tsx +153 -190
  78. package/src/components/chat/ncp/README.md +3 -0
  79. package/src/components/chat/ncp/ncp-chat-page-data.test.ts +2 -0
  80. package/src/components/chat/ncp/ncp-chat-thread.manager.ts +106 -1
  81. package/src/components/chat/ncp/ncp-session-adapter.test.ts +23 -0
  82. package/src/components/chat/ncp/ncp-session-adapter.ts +32 -0
  83. package/src/components/chat/ncp/page/ncp-chat-derived-state.ts +128 -0
  84. package/src/components/chat/ncp/session-conversation/use-ncp-child-session-tabs-view.ts +52 -0
  85. package/src/components/chat/ncp/session-conversation/use-ncp-session-conversation.test.tsx +101 -0
  86. package/src/components/chat/ncp/session-conversation/use-ncp-session-conversation.ts +72 -0
  87. package/src/components/chat/ncp/use-ncp-session-list-view.ts +10 -1
  88. package/src/components/chat/presenter/chat-presenter-context.tsx +5 -1
  89. package/src/components/chat/stores/chat-thread.store.ts +25 -1
  90. package/src/components/chat/useHydratedNcpAgent.test.tsx +30 -23
  91. package/src/components/common/AgentAvatar.tsx +63 -0
  92. package/src/components/common/agent-identity/agent-identity-avatar.tsx +27 -0
  93. package/src/components/common/agent-identity/index.ts +3 -0
  94. package/src/components/common/agent-identity/use-agent-identity.ts +50 -0
  95. package/src/components/config/RuntimeConfig.tsx +13 -79
  96. package/src/components/config/runtime-config-agent.utils.ts +95 -0
  97. package/src/components/layout/AppLayout.tsx +3 -1
  98. package/src/components/layout/Sidebar.tsx +6 -1
  99. package/src/components/layout/app-layout.test.tsx +30 -0
  100. package/src/components/ui/tabs.tsx +2 -0
  101. package/src/hooks/README.md +3 -0
  102. package/src/hooks/agents/useAgents.ts +44 -0
  103. package/src/lib/i18n.agents.ts +66 -0
  104. package/src/lib/i18n.chat.ts +5 -0
  105. package/src/lib/i18n.ts +4 -4
  106. package/src/lib/ui-document-title.ts +1 -0
  107. package/dist/assets/ChatPage-DWOU_8P6.js +0 -43
  108. package/dist/assets/DocBrowser-B9OaZjmg.js +0 -1
  109. package/dist/assets/MarketplacePage-BfaTTqN6.js +0 -1
  110. package/dist/assets/RuntimeConfig-Cmn2xPQO.js +0 -1
  111. package/dist/assets/chat-session-display-VW6ZMvZP.js +0 -1
  112. package/dist/assets/i18n-CDHMXlRZ.js +0 -1
  113. package/dist/assets/index-BlH4-cBw.css +0 -1
  114. package/dist/assets/index-C6d0xmtm.js +0 -6
  115. package/dist/assets/loader-circle-Cs8XVFTw.js +0 -1
  116. package/dist/assets/plus-PHf8q-Ct.js +0 -1
  117. package/dist/assets/search-C91yH_6y.js +0 -1
  118. package/dist/assets/skeleton-Dzg-HOiN.js +0 -1
  119. package/dist/assets/x-D7Q1yqSF.js +0 -1
  120. package/src/components/chat/adapters/chat-message.subagent-tool-card.ts +0 -154
  121. /package/src/lib/{i18n → i18n-runtime}/i18n-language-owner.ts +0 -0
  122. /package/src/lib/{i18n → i18n-runtime}/i18n.path-picker.ts +0 -0
@@ -1,6 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DocBrowser-B9OaZjmg.js","assets/DocBrowser-BmtBLFU0.js","assets/i18n-CDHMXlRZ.js","assets/createLucideIcon-CjGHOWb6.js","assets/book-open-CXoF5nQC.js","assets/external-link-tIO7zING.js","assets/plus-PHf8q-Ct.js","assets/search-C91yH_6y.js","assets/x-D7Q1yqSF.js","assets/DocBrowserContext-YIKkPb76.js","assets/ModelConfig-DJgdcgvQ.js","assets/select-DSkTc61S.js","assets/dist-Cl2QB-2y.js","assets/provider-models-bz5y28rq.js","assets/loader-circle-Cs8XVFTw.js","assets/page-layout-D3Xo605Z.js","assets/label-BIpeNu4r.js","assets/skeleton-Dzg-HOiN.js","assets/config-hints-WtpHP_DW.js","assets/ChatPage-DWOU_8P6.js","assets/chunk-JZWAC4HX-CvRWvTy5.js","assets/popover-BJRUGA_H.js","assets/dist-nqTTbVdA.js","assets/MarketplacePage-Cd4faegU.js","assets/useMutation-DrZrOgVL.js","assets/marketplace-localization-CxSTG9wr.js","assets/useConfirmDialog-Bs5Ll17m.js","assets/tabs-custom-DXv507_2.js","assets/react-7ZHqQtEV.js","assets/chat-session-display-VW6ZMvZP.js","assets/logos-DThdM9lk.js","assets/refresh-ccw-CC6-_QuL.js","assets/trash-2-DFZmW6Gg.js","assets/config-DJswxxE8.js","assets/LogoBadge-F7ZWdxLT.js","assets/SearchConfig-BT13qpR_.js","assets/config-layout-LQ10ozRC.js","assets/ProvidersList-w0rVFIBf.js","assets/status-dot-LNBlDu3q.js","assets/switch-Bo-Y46HZ.js","assets/ChannelsList-Zeys_w43.js","assets/hash-JWUyl1pT.js","assets/RuntimeConfig-Cmn2xPQO.js","assets/save-DJM5RRWW.js","assets/security-config-T5zpg16O.js","assets/SessionsConfig-DHHcYznk.js","assets/SecretsConfig-CvqEVn0B.js","assets/RemoteAccessPage-BJ_ckkOV.js","assets/MarketplacePage-BfaTTqN6.js","assets/McpMarketplacePage-C09Ngs7O.js"])))=>i.map(i=>d[i]);
2
- import{_ as e,a as t,c as n,h as r,i,l as a,m as o,n as s,o as c,p as l,s as u,u as d}from"./i18n-CDHMXlRZ.js";import{N as ee,c as f,i as te,l as ne,n as p,o as m,r as h,t as re,u as g}from"./dist-Cl2QB-2y.js";import{a as _,i as v,l as y,n as ie,o as ae,r as b,t as oe}from"./chunk-JZWAC4HX-CvRWvTy5.js";import{n as x,t as se}from"./react-7ZHqQtEV.js";import{t as S}from"./useMutation-DrZrOgVL.js";import{A as ce,B as C,F as le,G as w,H as ue,I as T,L as de,M as fe,N as pe,P as me,U as he,W as E,i as ge,j as _e,n as ve,r as ye,t as be,z as xe}from"./select-DSkTc61S.js";import{t as Se}from"./dist-nqTTbVdA.js";import{t as D}from"./createLucideIcon-CjGHOWb6.js";import{n as Ce}from"./DocBrowser-BmtBLFU0.js";import{t as we}from"./book-open-CXoF5nQC.js";import{t as Te}from"./search-C91yH_6y.js";import{t as Ee}from"./x-D7Q1yqSF.js";import{C as De,D as Oe,E as ke,O as Ae,S as je,T as Me,_ as Ne,a as Pe,b as Fe,c as Ie,f as Le,g as Re,h as ze,i as Be,l as Ve,m as He,n as Ue,o as We,p as Ge,r as Ke,s as qe,t as Je,u as Ye,v as Xe,w as Ze,x as Qe,y as $e}from"./config-DJswxxE8.js";import{i as O,n as et,r as tt}from"./DocBrowserContext-YIKkPb76.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var nt=r((e=>{var t=ee();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot}))(),k=e(o(),1),A=l(),j=`Dialog`,[rt,it]=he(j),[at,M]=rt(j),ot=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=k.useRef(null),c=k.useRef(null),[l,u]=xe({prop:r,defaultProp:i??!1,onChange:a,caller:j});return(0,A.jsx)(at,{scope:t,triggerRef:s,contentRef:c,contentId:C(),titleId:C(),descriptionId:C(),open:l,onOpenChange:u,onOpenToggle:k.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})};ot.displayName=j;var st=`DialogTrigger`,ct=k.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=M(st,n),a=E(t,i.triggerRef);return(0,A.jsx)(T.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":L(i.open),...r,ref:a,onClick:w(e.onClick,i.onOpenToggle)})});ct.displayName=st;var N=`DialogPortal`,[lt,ut]=rt(N,{forceMount:void 0}),dt=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=M(N,t);return(0,A.jsx)(lt,{scope:t,forceMount:n,children:k.Children.map(r,e=>(0,A.jsx)(Se,{present:n||a.open,children:(0,A.jsx)(pe,{asChild:!0,container:i,children:e})}))})};dt.displayName=N;var P=`DialogOverlay`,ft=k.forwardRef((e,t)=>{let n=ut(P,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=M(P,e.__scopeDialog);return a.modal?(0,A.jsx)(Se,{present:r||a.open,children:(0,A.jsx)(mt,{...i,ref:t})}):null});ft.displayName=P;var pt=de(`DialogOverlay.RemoveScroll`),mt=k.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=M(P,n);return(0,A.jsx)(_e,{as:pt,allowPinchZoom:!0,shards:[i.contentRef],children:(0,A.jsx)(T.div,{"data-state":L(i.open),...r,ref:t,style:{pointerEvents:`auto`,...r.style}})})}),F=`DialogContent`,ht=k.forwardRef((e,t)=>{let n=ut(F,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=M(F,e.__scopeDialog);return(0,A.jsx)(Se,{present:r||a.open,children:a.modal?(0,A.jsx)(gt,{...i,ref:t}):(0,A.jsx)(_t,{...i,ref:t})})});ht.displayName=F;var gt=k.forwardRef((e,t)=>{let n=M(F,e.__scopeDialog),r=k.useRef(null),i=E(t,n.contentRef,r);return k.useEffect(()=>{let e=r.current;if(e)return ce(e)},[]),(0,A.jsx)(vt,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:w(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:w(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:w(e.onFocusOutside,e=>e.preventDefault())})}),_t=k.forwardRef((e,t)=>{let n=M(F,e.__scopeDialog),r=k.useRef(!1),i=k.useRef(!1);return(0,A.jsx)(vt,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),vt=k.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=M(F,n),c=k.useRef(null),l=E(t,c);return fe(),(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(me,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,A.jsx)(le,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":L(s.open),...o,ref:l,onDismiss:()=>s.onOpenChange(!1)})}),(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(Dt,{titleId:s.titleId}),(0,A.jsx)(kt,{contentRef:c,descriptionId:s.descriptionId})]})]})}),I=`DialogTitle`,yt=k.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=M(I,n);return(0,A.jsx)(T.h2,{id:i.titleId,...r,ref:t})});yt.displayName=I;var bt=`DialogDescription`,xt=k.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=M(bt,n);return(0,A.jsx)(T.p,{id:i.descriptionId,...r,ref:t})});xt.displayName=bt;var St=`DialogClose`,Ct=k.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=M(St,n);return(0,A.jsx)(T.button,{type:`button`,...r,ref:t,onClick:w(e.onClick,()=>i.onOpenChange(!1))})});Ct.displayName=St;function L(e){return e?`open`:`closed`}var wt=`DialogTitleWarning`,[Tt,Et]=ue(wt,{contentName:F,titleName:I,docsSlug:`dialog`}),Dt=({titleId:e})=>{let t=Et(wt),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
3
-
4
- If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
5
-
6
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return k.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Ot=`DialogDescriptionWarning`,kt=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Et(Ot).contentName}}.`;return k.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},At=ot,jt=dt,Mt=ft,Nt=ht,Pt=yt,Ft=xt,It=Ct,Lt=D(`AlarmClock`,[[`circle`,{cx:`12`,cy:`13`,r:`8`,key:`3y4lt7`}],[`path`,{d:`M12 9v4l2 2`,key:`1c63tq`}],[`path`,{d:`M5 3 2 6`,key:`18tl5t`}],[`path`,{d:`m22 6-3-3`,key:`1opdir`}],[`path`,{d:`M6.38 18.7 4 21`,key:`17xu3x`}],[`path`,{d:`M17.64 18.67 20 21`,key:`kv2oe2`}]]),Rt=D(`BrainCircuit`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M9 13a4.5 4.5 0 0 0 3-4`,key:`10igwf`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M12 13h4`,key:`1ku699`}],[`path`,{d:`M12 18h6a2 2 0 0 1 2 2v1`,key:`105ag5`}],[`path`,{d:`M12 8h8`,key:`1lhi5i`}],[`path`,{d:`M16 8V5a2 2 0 0 1 2-2`,key:`u6izg6`}],[`circle`,{cx:`16`,cy:`13`,r:`.5`,key:`ry7gng`}],[`circle`,{cx:`18`,cy:`3`,r:`.5`,key:`1aiba7`}],[`circle`,{cx:`20`,cy:`21`,r:`.5`,key:`yhc1fs`}],[`circle`,{cx:`20`,cy:`8`,r:`.5`,key:`1e43v0`}]]),zt=D(`Cpu`,[[`rect`,{width:`16`,height:`16`,x:`4`,y:`4`,rx:`2`,key:`14l7u7`}],[`rect`,{width:`6`,height:`6`,x:`9`,y:`9`,rx:`1`,key:`5aljv4`}],[`path`,{d:`M15 2v2`,key:`13l42r`}],[`path`,{d:`M15 20v2`,key:`15mkzm`}],[`path`,{d:`M2 15h2`,key:`1gxd5l`}],[`path`,{d:`M2 9h2`,key:`1bbxkp`}],[`path`,{d:`M20 15h2`,key:`19e6y8`}],[`path`,{d:`M20 9h2`,key:`19tzq7`}],[`path`,{d:`M9 2v2`,key:`165o2o`}],[`path`,{d:`M9 20v2`,key:`i2bqo8`}]]),Bt=D(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),Vt=D(`History`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),R=D(`KeyRound`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Ht=D(`Languages`,[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),Ut=D(`LogOut`,[[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}],[`polyline`,{points:`16 17 21 12 16 7`,key:`1gabdz`}],[`line`,{x1:`21`,x2:`9`,y1:`12`,y2:`12`,key:`1uyos4`}]]),Wt=D(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),Gt=D(`MessageSquare`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}]]),Kt=D(`Palette`,[[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`path`,{d:`M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z`,key:`12rzf8`}]]),qt=D(`Plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M9 8V2`,key:`14iosj`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z`,key:`osxo6l`}]]),Jt=D(`Settings`,[[`path`,{d:`M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z`,key:`1qme2f`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Yt=D(`Shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),Xt=D(`Sparkles`,[[`path`,{d:`M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z`,key:`4pj2yx`}],[`path`,{d:`M20 3v4`,key:`1olli1`}],[`path`,{d:`M22 5h-4`,key:`1gvqau`}],[`path`,{d:`M4 17v2`,key:`vumght`}],[`path`,{d:`M5 18H3`,key:`zchphs`}]]),Zt=D(`SquareArrowOutUpRight`,[[`path`,{d:`M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6`,key:`y09zxi`}],[`path`,{d:`m21 3-9 9`,key:`mpx6sq`}],[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}]]),Qt=D(`Wifi`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M2 8.82a15 15 0 0 1 20 0`,key:`dnpr2z`}],[`path`,{d:`M5 12.859a10 10 0 0 1 14 0`,key:`1x1e6c`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}]]),$t=D(`Wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`,key:`cbrjhi`}]]),en=At,tn=jt,nn=k.forwardRef(({className:e,...t},n)=>(0,A.jsx)(Mt,{ref:n,className:d(`fixed inset-0 z-50 bg-black/40 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t}));nn.displayName=Mt.displayName;var rn=k.forwardRef(({className:e,children:t,...n},r)=>(0,A.jsxs)(tn,{children:[(0,A.jsx)(nn,{}),(0,A.jsxs)(Nt,{ref:r,className:d(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-gray-200/50 bg-white p-6 shadow-xl duration-base data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-2xl`,e),...n,children:[t,(0,A.jsxs)(It,{className:`absolute right-4 top-4 rounded-lg p-1 opacity-70 ring-offset-white transition-all duration-fast hover:opacity-100 hover:bg-gray-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 disabled:pointer-events-none`,children:[(0,A.jsx)(Ee,{className:`h-4 w-4 text-gray-500`}),(0,A.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));rn.displayName=Nt.displayName;var an=({className:e,...t})=>(0,A.jsx)(`div`,{className:d(`flex flex-col space-y-2 text-center sm:text-left`,e),...t});an.displayName=`DialogHeader`;var on=({className:e,...t})=>(0,A.jsx)(`div`,{className:d(`flex flex-col-reverse sm:flex-row sm:justify-end sm:gap-3`,e),...t});on.displayName=`DialogFooter`;var sn=k.forwardRef(({className:e,...t},n)=>(0,A.jsx)(Pt,{ref:n,className:d(`text-lg font-semibold leading-tight tracking-tight text-gray-900`,e),...t}));sn.displayName=Pt.displayName;var cn=k.forwardRef(({className:e,...t},n)=>(0,A.jsx)(Ft,{ref:n,className:d(`text-sm text-gray-500 leading-relaxed`,e),...t}));cn.displayName=Ft.displayName;async function ln(){let e=await h.get(`/api/remote/status`);if(!e.ok)throw Error(e.error.message);return e.data}async function un(){let e=await h.get(`/api/remote/doctor`);if(!e.ok)throw Error(e.error.message);return e.data}async function dn(e){let t=await h.post(`/api/remote/auth/start`,e);if(!t.ok)throw Error(t.error.message);return t.data}async function fn(e){let t=await h.post(`/api/remote/auth/poll`,e);if(!t.ok)throw Error(t.error.message);return t.data}async function pn(){let e=await h.post(`/api/remote/logout`,{});if(!e.ok)throw Error(e.error.message);return e.data}async function mn(e){let t=await h.put(`/api/remote/settings`,e);if(!t.ok)throw Error(t.error.message);return t.data}async function z(e){let t=await h.post(`/api/remote/service/${e}`,{});if(!t.ok)throw Error(t.error.message);return t.data}var hn=[`remote-status`],gn=`https://platform.nextclaw.io`,_n=`https://nextclaw-platform-console.pages.dev`,B=async()=>await x.fetchQuery({queryKey:hn,queryFn:ln,staleTime:5e3}),V=async()=>(await x.invalidateQueries({queryKey:hn}),await B()),vn=(e,t)=>t?.trim()||e?.settings.platformApiBase?.trim()||e?.account.apiBase?.trim()||void 0;function H(e){let t=e?.trim();if(!t)return;let n;try{n=new URL(t)}catch{return}if(n.hostname===`platform.nextclaw.io`||n.hostname===`nextclaw-platform-console.pages.dev`)return n.origin;if(n.hostname===`ai-gateway-api.nextclaw.io`)return gn;if(n.hostname.includes(`nextclaw-provider-gateway-api`)&&n.hostname.endsWith(`.workers.dev`))return _n}var yn=e=>H(e?.account.apiBase)||H(e?.settings.platformApiBase)||H(e?.platformBase)||H(e?.account.platformBase)||void 0;function U(){return f({queryKey:hn,queryFn:ln,staleTime:5e3,refetchOnWindowFocus:!0})}var W=se(e=>({panelOpen:!1,authSessionId:null,authVerificationUri:null,authExpiresAt:null,authStatusMessage:``,authPollIntervalMs:1500,pendingAction:null,openPanel:()=>e({panelOpen:!0}),closePanel:()=>e({panelOpen:!1}),setPendingAction:t=>e({pendingAction:t}),clearPendingAction:()=>e({pendingAction:null}),beginBrowserAuth:({sessionId:t,verificationUri:n,expiresAt:r,intervalMs:i,statusMessage:a})=>e({panelOpen:!0,authSessionId:t,authVerificationUri:n,authExpiresAt:r,authPollIntervalMs:i,authStatusMessage:a}),updateBrowserAuth:({statusMessage:t,intervalMs:n})=>e(e=>({authStatusMessage:t??e.authStatusMessage,authPollIntervalMs:n??e.authPollIntervalMs})),clearBrowserAuth:()=>e({authSessionId:null,authVerificationUri:null,authExpiresAt:null,authStatusMessage:``,authPollIntervalMs:1500}),setAuthStatusMessage:t=>e({authStatusMessage:t})})),bn=class{constructor(){this.authPollTimerId=null,this.afterSignedIn=null,this.bindSignedInContinuation=e=>{this.afterSignedIn=e},this.openAccountPanel=()=>{W.getState().openPanel()},this.closeAccountPanel=()=>{W.getState().closePanel()},this.syncRemoteStatus=e=>{e?.account.loggedIn&&(this.clearPollTimer(),W.getState().clearBrowserAuth())},this.ensureSignedIn=async e=>{let t=await B();return t.account.loggedIn?!0:(e?.pendingAction&&W.getState().setPendingAction(e.pendingAction),this.openAccountPanel(),await this.startBrowserSignIn({apiBase:e?.apiBase,status:t}),!1)},this.startBrowserSignIn=async e=>{try{let t=e?.status??await B();e?.pendingAction&&W.getState().setPendingAction(e.pendingAction);let n=await dn({apiBase:vn(t,e?.apiBase)});W.getState().beginBrowserAuth({sessionId:n.sessionId,verificationUri:n.verificationUri,expiresAt:n.expiresAt,intervalMs:n.intervalMs,statusMessage:i(`remoteBrowserAuthWaiting`)}),window.open(n.verificationUri,`_blank`,`noopener,noreferrer`)||W.getState().setAuthStatusMessage(i(`remoteBrowserAuthPopupBlocked`)),this.scheduleBrowserAuthPoll()}catch(e){let t=e instanceof Error?e.message:i(`remoteBrowserAuthStartFailed`);p.error(`${i(`remoteBrowserAuthStartFailed`)}: ${t}`)}},this.resumeBrowserSignIn=()=>{let e=W.getState().authVerificationUri;e&&window.open(e,`_blank`,`noopener,noreferrer`)},this.logout=async()=>{try{await pn(),W.getState().clearPendingAction(),W.getState().clearBrowserAuth(),await V(),p.success(i(`remoteLogoutSuccess`))}catch(e){let t=e instanceof Error?e.message:i(`remoteLogoutFailed`);p.error(`${i(`remoteLogoutFailed`)}: ${t}`)}},this.openNextClawWeb=async()=>{let e=yn(await B());if(!e){p.error(i(`remoteOpenWebUnavailable`));return}window.open(e,`_blank`,`noopener,noreferrer`)},this.scheduleBrowserAuthPoll=()=>{this.clearPollTimer();let{authSessionId:e,authPollIntervalMs:t}=W.getState();e&&(this.authPollTimerId=window.setTimeout(async()=>{await this.pollBrowserSignIn()},t))},this.pollBrowserSignIn=async()=>{let e=W.getState();if(e.authSessionId)try{let t=await B(),n=await fn({sessionId:e.authSessionId,apiBase:vn(t)});if(n.status===`pending`){W.getState().updateBrowserAuth({statusMessage:i(`remoteBrowserAuthWaiting`),intervalMs:n.nextPollMs??1500}),this.scheduleBrowserAuthPoll();return}if(n.status===`expired`){this.clearPollTimer(),W.getState().clearBrowserAuth(),p.error(n.message||i(`remoteBrowserAuthExpired`));return}W.getState().setAuthStatusMessage(i(`remoteBrowserAuthCompleted`));let r=await V(),{pendingAction:a}=W.getState();this.clearPollTimer(),W.getState().clearBrowserAuth(),p.success(i(`remoteLoginSuccess`)),a&&this.afterSignedIn&&await this.afterSignedIn(a,r),W.getState().clearPendingAction()}catch(e){this.clearPollTimer(),W.getState().clearBrowserAuth();let t=e instanceof Error?e.message:i(`remoteBrowserAuthPollFailed`);p.error(`${i(`remoteBrowserAuthPollFailed`)}: ${t}`)}},this.clearPollTimer=()=>{this.authPollTimerId!==null&&(window.clearTimeout(this.authPollTimerId),this.authPollTimerId=null)},this.getBrowserAuthSummary=()=>{let e=W.getState();return{sessionId:e.authSessionId,expiresAt:e.authExpiresAt?s(e.authExpiresAt):`-`}}}},G=se(e=>({enabled:!1,deviceName:``,platformApiBase:``,advancedOpen:!1,draftTouched:!1,actionLabel:null,doctor:null,setEnabled:t=>e({enabled:t,draftTouched:!0}),setDeviceName:t=>e({deviceName:t,draftTouched:!0}),setPlatformApiBase:t=>e({platformApiBase:t,draftTouched:!0}),setAdvancedOpen:t=>e({advancedOpen:t}),hydrateDraft:({enabled:t,deviceName:n,platformApiBase:r})=>e({enabled:t,deviceName:n,platformApiBase:r,draftTouched:!1}),beginAction:t=>e({actionLabel:t}),finishAction:()=>e({actionLabel:null}),setDoctor:t=>e({doctor:t})})),xn=class{constructor(){this.accountManager=null,this.bindAccountManager=e=>{this.accountManager=e},this.syncStatus=e=>{if(!e)return;let t=G.getState();t.draftTouched||t.actionLabel||this.hydrateDraftFromStatus(e)},this.setEnabled=e=>{G.getState().setEnabled(e)},this.setDeviceName=e=>{G.getState().setDeviceName(e)},this.setPlatformApiBase=e=>{G.getState().setPlatformApiBase(e)},this.setAdvancedOpen=e=>{G.getState().setAdvancedOpen(e)},this.enableRemoteAccess=async e=>{let t=e??await V(),n=G.getState();if(!t.account.loggedIn){await this.accountManager?.ensureSignedIn({pendingAction:{type:`enable-remote`},apiBase:n.platformApiBase});return}await this.applyEnabledState(!0,t)},this.disableRemoteAccess=async e=>{let t=e??await V();await this.applyEnabledState(!1,t)},this.repairRemoteAccess=async e=>{let t=e??await V();if(!t.account.loggedIn){await this.accountManager?.ensureSignedIn({pendingAction:{type:`enable-remote`}});return}let n=t.service.running?`restart`:`start`;await this.runManagedAction({actionLabel:i(n===`restart`?`remoteActionRestarting`:`remoteActionStarting`),job:async()=>{await z(n);let e=await V();this.hydrateDraftFromStatus(e)},successMessage:i(`remoteServiceRecovered`)})},this.reauthorizeRemoteAccess=async e=>{let t=e??await V();await this.accountManager?.startBrowserSignIn({status:t,apiBase:G.getState().platformApiBase,pendingAction:{type:`repair-remote`}})},this.saveAdvancedSettings=async e=>{let t=e??await V(),n=G.getState();await this.runManagedAction({actionLabel:i(`remoteActionSavingAdvanced`),job:async()=>{await mn({enabled:n.enabled,deviceName:n.deviceName.trim(),platformApiBase:n.platformApiBase.trim()});let e=await V();this.hydrateDraftFromStatus(e)},successMessage:t.settings.enabled===n.enabled?i(`remoteSettingsSaved`):i(`remoteAdvancedSaved`)})},this.runDoctor=async()=>{await this.runManagedAction({actionLabel:i(`remoteDoctorRunning`),job:async()=>{let e=await un();G.getState().setDoctor(e)},successMessage:i(`remoteDoctorCompleted`)})},this.startService=async()=>{await this.runServiceAction(`start`,i(`remoteActionStarting`))},this.restartService=async()=>{await this.runServiceAction(`restart`,i(`remoteActionRestarting`))},this.stopService=async()=>{await this.runServiceAction(`stop`,i(`remoteActionStopping`))},this.resumePendingActionAfterSignIn=async(e,t)=>{if(e){if(e.type===`enable-remote`){await this.applyEnabledState(!0,t);return}e.type===`repair-remote`&&await this.repairRemoteAccess(t)}},this.applyEnabledState=async(e,t)=>{let n=G.getState();await this.runManagedAction({actionLabel:i(e?`remoteActionEnabling`:`remoteActionDisabling`),job:async()=>{await mn({enabled:e,deviceName:n.deviceName.trim(),platformApiBase:n.platformApiBase.trim()});let r=await V();this.hydrateDraftFromStatus(r),e?await z(r.service.running?`restart`:`start`):t.service.running&&await z(`restart`);let i=await V();this.hydrateDraftFromStatus(i)},successMessage:i(e?`remoteEnabledReady`:`remoteDisabledDone`)})},this.runServiceAction=async(e,t)=>{await this.runManagedAction({actionLabel:t,job:async()=>{let t=await z(e),n=await V();this.hydrateDraftFromStatus(n),p.success(t.message)}})},this.hydrateDraftFromStatus=e=>{G.getState().hydrateDraft({enabled:e.settings.enabled,deviceName:e.settings.deviceName,platformApiBase:e.settings.platformApiBase})},this.runManagedAction=async e=>{G.getState().beginAction(e.actionLabel);try{await e.job(),e.successMessage&&p.success(e.successMessage)}catch(e){let t=e instanceof Error?e.message:i(`error`);throw p.error(t),e}finally{G.getState().finishAction()}}}},K=new class{constructor(){this.accountManager=new bn,this.remoteAccessManager=new xn}};K.accountManager.bindSignedInContinuation(K.remoteAccessManager.resumePendingActionAfterSignIn),K.remoteAccessManager.bindAccountManager(K.accountManager);var Sn=(0,k.createContext)(null);function Cn({children:e}){return(0,A.jsx)(Sn.Provider,{value:K,children:e})}function q(){let e=(0,k.useContext)(Sn);if(!e)throw Error(`useAppPresenter must be used inside AppPresenterProvider`);return e}function J(e){return(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,A.jsx)(`span`,{className:`text-gray-500`,children:e.label}),(0,A.jsx)(`span`,{className:`text-right text-gray-900`,children:e.value?.trim()||`-`})]})}function wn(){let e=q(),t=U(),n=W(e=>e.panelOpen),r=W(e=>e.authSessionId),a=W(e=>e.authVerificationUri),o=W(e=>e.authExpiresAt),c=W(e=>e.authStatusMessage),l=t.data;return(0,k.useEffect)(()=>{e.accountManager.syncRemoteStatus(l)},[e,l]),(0,A.jsx)(en,{open:n,onOpenChange:t=>t?e.accountManager.openAccountPanel():e.accountManager.closeAccountPanel(),children:(0,A.jsxs)(rn,{className:`max-w-xl`,children:[(0,A.jsxs)(an,{children:[(0,A.jsxs)(sn,{className:`flex items-center gap-2`,children:[(0,A.jsx)(R,{className:`h-5 w-5 text-primary`}),i(`accountPanelTitle`)]}),(0,A.jsx)(cn,{children:i(`accountPanelDescription`)})]}),l?.account.loggedIn?(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{className:`rounded-2xl border border-emerald-200 bg-emerald-50 px-4 py-3`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium text-emerald-800`,children:i(`accountPanelSignedInTitle`)}),(0,A.jsx)(`p`,{className:`mt-1 text-sm text-emerald-700`,children:i(`accountPanelSignedInDescription`)})]}),(0,A.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-gray-50 px-4 py-3`,children:[(0,A.jsx)(J,{label:i(`remoteAccountEmail`),value:l.account.email}),(0,A.jsx)(J,{label:i(`remoteAccountRole`),value:l.account.role})]}),(0,A.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,A.jsxs)(m,{onClick:()=>void e.accountManager.openNextClawWeb(),children:[(0,A.jsx)(Zt,{className:`mr-2 h-4 w-4`}),i(`remoteOpenDeviceList`)]}),(0,A.jsxs)(m,{variant:`outline`,onClick:()=>void e.accountManager.logout(),children:[(0,A.jsx)(Ut,{className:`mr-2 h-4 w-4`}),i(`remoteLogout`)]})]})]}):(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-gray-50 px-4 py-3`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium text-gray-900`,children:i(`accountPanelSignedOutTitle`)}),(0,A.jsx)(`p`,{className:`mt-1 text-sm text-gray-600`,children:i(`accountPanelSignedOutDescription`)}),r?(0,A.jsxs)(`div`,{className:`mt-3 border-t border-white/80 pt-3`,children:[(0,A.jsx)(J,{label:i(`remoteBrowserAuthSession`),value:r}),(0,A.jsx)(J,{label:i(`remoteBrowserAuthExpiresAt`),value:o?s(o):`-`})]}):null]}),c?(0,A.jsx)(`p`,{className:`text-sm text-gray-600`,children:c}):null,(0,A.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,A.jsx)(m,{onClick:()=>void e.accountManager.startBrowserSignIn(),children:i(r?`remoteBrowserAuthActionRetry`:`remoteBrowserAuthAction`)}),a?(0,A.jsx)(m,{variant:`outline`,onClick:()=>e.accountManager.resumeBrowserSignIn(),children:i(`remoteBrowserAuthResume`)}):null]})]})]})})}var Tn=k.forwardRef(({className:e,hover:t=!0,...n},r)=>(0,A.jsx)(`div`,{ref:r,className:d(`rounded-2xl border border-gray-200/50 bg-white text-card-foreground shadow-card transition-all duration-base`,t&&`hover:shadow-card-hover hover:border-gray-200`,e),...n}));Tn.displayName=`Card`;var En=k.forwardRef(({className:e,...t},n)=>(0,A.jsx)(`div`,{ref:n,className:d(`flex flex-col space-y-1.5 p-6`,e),...t}));En.displayName=`CardHeader`;var Dn=k.forwardRef(({className:e,...t},n)=>(0,A.jsx)(`h3`,{ref:n,className:d(`text-[15px] font-semibold leading-tight tracking-tight text-gray-900`,e),...t}));Dn.displayName=`CardTitle`;var On=k.forwardRef(({className:e,...t},n)=>(0,A.jsx)(`p`,{ref:n,className:d(`text-[13px] text-gray-400 leading-relaxed`,e),...t}));On.displayName=`CardDescription`;var kn=k.forwardRef(({className:e,...t},n)=>(0,A.jsx)(`div`,{ref:n,className:d(`p-6 pt-0`,e),...t}));kn.displayName=`CardContent`;var An=k.forwardRef(({className:e,...t},n)=>(0,A.jsx)(`div`,{ref:n,className:d(`flex items-center justify-between p-6 pt-0`,e),...t}));An.displayName=`CardFooter`;var Y=k.forwardRef(({className:e,type:t,...n},r)=>(0,A.jsx)(`input`,{type:t,className:d(`flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-900 file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-gray-300 placeholder:font-normal focus:outline-none focus:ring-1 focus:ring-primary/40 focus:border-primary/40 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));Y.displayName=`Input`;var jn=40,Mn=400;function Nn(e){if(!(e instanceof Error))return!1;let t=e.message.trim().toLowerCase();return t?t.includes(`failed to fetch`)||t.includes(`networkerror`)||t.includes(`network request failed`)||t.includes(`load failed`)||t.includes(`request timed out`)||t.includes(`timed out waiting for remote request response`)||t.includes(`remote transport connection closed`):!1}function Pn(e,t){return e>=jn?!1:Nn(t)}function Fn(){let[e,t]=(0,k.useState)(!1),n=f({queryKey:[`auth-status`],queryFn:()=>We({timeoutMs:e?5e3:Mn}),staleTime:5e3,retry:Pn,retryDelay:250,refetchOnWindowFocus:!0});return(0,k.useEffect)(()=>{n.isSuccess&&!e&&t(!0)},[e,n.isSuccess]),n}function X(e){return Promise.all([e.invalidateQueries({queryKey:[`auth-status`]}),e.invalidateQueries({queryKey:[`app-meta`]}),e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),e.invalidateQueries({queryKey:[`config-schema`]}),e.invalidateQueries({queryKey:[`sessions`]}),e.invalidateQueries({queryKey:[`session-history`]}),e.invalidateQueries({queryKey:[`chat-runs`]}),e.invalidateQueries({queryKey:[`cron-jobs`]})])}function In(){let e=g();return S({mutationFn:Xe,onSuccess:async()=>{await X(e),p.success(i(`authSetupSuccess`))},onError:e=>{p.error(`${i(`authActionFailed`)}: ${e.message}`)}})}function Ln(){let e=g();return S({mutationFn:Ge,onSuccess:async()=>{await X(e),p.success(i(`authLoginSuccess`))},onError:e=>{p.error(`${i(`authActionFailed`)}: ${e.message}`)}})}function Rn(){let e=g();return S({mutationFn:He,onSuccess:async()=>{await X(e),p.success(i(`authLogoutSuccess`))},onError:e=>{p.error(`${i(`authActionFailed`)}: ${e.message}`)}})}function zn(){let e=g();return S({mutationFn:je,onSuccess:async()=>{await X(e),p.success(i(`authPasswordUpdated`))},onError:e=>{p.error(`${i(`authActionFailed`)}: ${e.message}`)}})}function Bn(){let e=g();return S({mutationFn:Qe,onSuccess:async(t,n)=>{await X(e),p.success(n.enabled?i(`authEnabledSuccess`):i(`authDisabledSuccess`))},onError:e=>{p.error(`${i(`authActionFailed`)}: ${e.message}`)}})}function Vn({username:e}){let t=Ln(),[n,r]=(0,k.useState)(e??``),[a,o]=(0,k.useState)(``),s=n.trim().length>0&&a.length>0&&!t.isPending;return(0,A.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-secondary px-6 py-10`,children:(0,A.jsxs)(Tn,{hover:!1,className:`w-full max-w-md shadow-card-hover`,children:[(0,A.jsxs)(En,{children:[(0,A.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.24em] text-gray-500`,children:i(`authBrand`)}),(0,A.jsx)(Dn,{className:`text-2xl`,children:i(`authLoginTitle`)}),(0,A.jsx)(On,{children:i(`authLoginDescription`)})]}),(0,A.jsx)(kn,{children:(0,A.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e?.preventDefault(),s&&t.mutate({username:n.trim(),password:a})},children:[(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:i(`authUsername`)}),(0,A.jsx)(Y,{value:n,onChange:e=>r(e.target.value),placeholder:i(`authUsernamePlaceholder`),autoFocus:!0})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:i(`authPassword`)}),(0,A.jsx)(Y,{type:`password`,value:a,onChange:e=>o(e.target.value),placeholder:i(`authPasswordPlaceholder`)})]}),(0,A.jsx)(m,{type:`submit`,className:`w-full`,disabled:!s,children:t.isPending?i(`authLoggingIn`):i(`authLoginAction`)})]})})]})})}var Hn=`nextclaw.ui.theme`,Un=[{value:`warm`,labelKey:`themeWarm`},{value:`cool`,labelKey:`themeCool`}],Z=`warm`,Wn=!1,Gn=new Set;function Kn(e){return e===`warm`||e===`cool`}function qn(e){typeof document>`u`||document.documentElement.setAttribute(`data-theme`,e)}function Jn(){if(typeof window>`u`)return`warm`;try{let e=window.localStorage.getItem(Hn);if(Kn(e))return e}catch{}return`warm`}function Yn(){return Wn||=(Z=Jn(),qn(Z),!0),Z}function Xn(){return Wn?Z:Yn()}function Zn(e){if(Yn(),e!==Z){if(Z=e,qn(Z),typeof window<`u`)try{window.localStorage.setItem(Hn,Z)}catch{}Gn.forEach(e=>e(Z))}}function Qn(e){return Gn.add(e),()=>{Gn.delete(e)}}function $n(){let e=O();(0,k.useEffect)(()=>{let t=t=>{let n=t.target.closest(`a[href]`);if(!n)return;let r=n.getAttribute(`href`)||``;tt(r)&&(n.hasAttribute(`data-doc-external`)||t.ctrlKey||t.metaKey||t.shiftKey||(t.preventDefault(),t.stopPropagation(),e.open(r)))};return document.addEventListener(`click`,t,!0),()=>document.removeEventListener(`click`,t,!0)},[e])}function er(e){return[...e].sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt))}function tr(e,t){let n=t.updatedAt.localeCompare(e.updatedAt);return n>0?!0:n<0?!1:e.status===t.status?!0:t.status===`idle`}function nr(e,t){if(!e)return e;let n=e.sessions.findIndex(e=>e.sessionId===t.sessionId),r=er(n>=0?e.sessions.map((e,r)=>r===n&&tr(e,t)?t:e):[...e.sessions,t]);return{...e,sessions:r,total:r.length}}function rr(e,t){if(!e)return e;let n=t.trim();if(!n)return e;let r=e.sessions.filter(e=>e.sessionId!==n);return r.length===e.sessions.length?e:{...e,sessions:r,total:r.length}}function ir(e,t){e?.setQueriesData({queryKey:[`ncp-sessions`]},e=>nr(e,t))}function ar(e,t){if(!e)return e;let n=t.sessionKey.trim();if(!n)return e;let r=!1,i=e.sessions.map(e=>e.sessionId!==n||e.status===t.status?e:(r=!0,{...e,status:t.status}));return r?{...e,sessions:i}:e}function or(e,t){e?.setQueriesData({queryKey:[`ncp-sessions`]},e=>ar(e,t))}function sr(e,t){e?.setQueriesData({queryKey:[`ncp-sessions`]},e=>rr(e,t))}function cr(e,t){if(t.type===`session.run-status`){or(e,t.payload);return}if(t.type===`session.summary.upsert`){ir(e,t.payload.summary);return}sr(e,t.payload.sessionKey)}async function lr(e){let t=new URLSearchParams;typeof e?.limit==`number`&&Number.isFinite(e.limit)&&t.set(`limit`,String(Math.max(1,Math.trunc(e.limit))));let n=t.toString(),r=await h.get(n?`/api/ncp/sessions?${n}`:`/api/ncp/sessions`);if(!r.ok)throw Error(r.error.message);return r.data}async function ur(e,t=200){let n=await h.get(`/api/ncp/sessions/${encodeURIComponent(e)}/messages?limit=${Math.max(1,Math.trunc(t))}`);if(!n.ok)throw Error(n.error.message);return n.data}async function dr(e,t){let n=new URLSearchParams,r=t?.projectRoot?.trim();r&&n.set(`projectRoot`,r);let i=n.toString(),a=await h.get(i?`/api/ncp/sessions/${encodeURIComponent(e)}/skills?${i}`:`/api/ncp/sessions/${encodeURIComponent(e)}/skills`);if(!a.ok)throw Error(a.error.message);return a.data}async function fr(e,t){let n=await h.put(`/api/ncp/sessions/${encodeURIComponent(e)}`,t);if(!n.ok)throw Error(n.error.message);return n.data}async function pr(e){let t=await h.delete(`/api/ncp/sessions/${encodeURIComponent(e)}`);if(!t.ok)throw Error(t.error.message);return t.data}function mr(){return f({queryKey:[`config`],queryFn:qe,staleTime:3e4,refetchOnWindowFocus:!0})}function hr(){return f({queryKey:[`app-meta`],queryFn:Pe,staleTime:1/0})}function gr(){return f({queryKey:[`config-meta`],queryFn:Ie,staleTime:1/0})}function _r(){return f({queryKey:[`config-schema`],queryFn:Ve,staleTime:1/0})}function vr(){let e=g();return S({mutationFn:Ze,onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),p.success(i(`configSaved`))},onError:e=>{p.error(i(`configSaveFailed`)+`: `+e.message)}})}function yr(){let e=g();return S({mutationFn:({data:e})=>Oe(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),p.success(i(`configSavedApplied`))},onError:e=>{p.error(i(`configSaveFailed`)+`: `+e.message)}})}function br(){let e=g();return S({mutationFn:({provider:e,data:t})=>Me(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),p.success(i(`configSaved`))},onError:e=>{p.error(i(`configSaveFailed`)+`: `+e.message)}})}function xr(){let e=g();return S({mutationFn:({data:e})=>Je(e??{}),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),p.success(i(`configSaved`))},onError:e=>{p.error(i(`configSaveFailed`)+`: `+e.message)}})}function Sr(){let e=g();return S({mutationFn:({provider:e})=>Ke(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),p.success(i(`configSaved`))},onError:e=>{p.error(i(`configSaveFailed`)+`: `+e.message)}})}function Cr(){return S({mutationFn:({provider:e,data:t})=>Fe(e,t)})}function wr(){return S({mutationFn:({provider:e,data:t})=>$e(e,t)})}function Tr(){return S({mutationFn:({provider:e,data:t})=>ze(e,t)})}function Er(){return S({mutationFn:({provider:e})=>Le(e)})}function Dr(){let e=g();return S({mutationFn:({channel:e,data:t})=>De(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),p.success(i(`configSavedApplied`))},onError:e=>{p.error(i(`configSaveFailed`)+`: `+e.message)}})}function Or(){let e=g();return S({mutationFn:({data:e})=>ke(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),p.success(i(`configSavedApplied`))},onError:e=>{p.error(i(`configSaveFailed`)+`: `+e.message)}})}function kr(){let e=g();return S({mutationFn:({data:e})=>Ae(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),p.success(i(`configSavedApplied`))},onError:e=>{p.error(i(`configSaveFailed`)+`: `+e.message)}})}function Ar(){return S({mutationFn:({actionId:e,data:t})=>Be(e,t),onError:e=>{p.error(i(`error`)+`: `+e.message)}})}function jr(e){return f({queryKey:[`ncp-sessions`,e?.limit??null],queryFn:()=>lr(e),staleTime:5e3,retry:!1})}function Mr(e,t=200){return f({queryKey:[`ncp-session-messages`,e,t],queryFn:()=>ur(e,t),enabled:!!e,staleTime:5e3,retry:!1})}function Nr(e){return f({queryKey:[`ncp-session-skills`,e.sessionId,e.projectRoot??null],queryFn:()=>dr(e.sessionId,{...Object.prototype.hasOwnProperty.call(e,`projectRoot`)?{projectRoot:e.projectRoot??null}:{}}),enabled:!!e.sessionId,staleTime:5e3,retry:!1})}function Pr(){let e=g();return S({mutationFn:({sessionId:e})=>pr(e),onSuccess:(t,n)=>{sr(e,n.sessionId),e.removeQueries({queryKey:[`ncp-session-messages`,n.sessionId]}),p.success(i(`configSavedApplied`))},onError:e=>{p.error(i(`configSaveFailed`)+`: `+e.message)}})}function Fr(){let e=g();return S({mutationFn:({sessionId:e,data:t})=>fr(e,t),onSuccess:t=>{ir(e,t),e.invalidateQueries({queryKey:[`ncp-session-skills`,t.sessionId]}),p.success(i(`configSavedApplied`))},onError:e=>{p.error(i(`configSaveFailed`)+`: `+e.message)}})}function Ir(e={all:!0}){return f({queryKey:[`cron`,e],queryFn:()=>Ye(e),staleTime:1e4})}function Lr(){let e=g();return S({mutationFn:({id:e})=>Ue(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),p.success(i(`configSavedApplied`))},onError:e=>{p.error(i(`configSaveFailed`)+`: `+e.message)}})}function Rr(){let e=g();return S({mutationFn:({id:e,enabled:t})=>Ne(e,{enabled:t}),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),p.success(i(`configSavedApplied`))},onError:e=>{p.error(i(`configSaveFailed`)+`: `+e.message)}})}function zr(){let e=g();return S({mutationFn:({id:e,force:t})=>Re(e,{force:t}),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),p.success(i(`configSavedApplied`))},onError:e=>{p.error(i(`configSaveFailed`)+`: `+e.message)}})}function Br({className:e,suffix:t}){let{data:n}=hr(),r=n?.name??`NextClaw`,i=n?.productVersion?.trim();return(0,A.jsxs)(`div`,{className:e??`flex items-center gap-2.5`,children:[(0,A.jsx)(`div`,{className:`h-7 w-7 rounded-lg overflow-hidden flex items-center justify-center`,children:(0,A.jsx)(`img`,{src:`/logo.svg`,alt:r,className:`h-full w-full object-contain`})}),(0,A.jsxs)(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[(0,A.jsx)(`span`,{className:`truncate text-[15px] font-semibold tracking-[-0.01em] text-gray-800`,children:r}),i?(0,A.jsxs)(`span`,{className:`text-[13px] font-medium text-gray-500`,children:[`v`,i]}):null,t?(0,A.jsx)(`span`,{className:`inline-flex items-center shrink-0`,children:t}):null]})]})}var Vr={default:{row:`gap-3 px-3 py-2.5 text-[14px]`,icon:`h-[17px] w-[17px]`,value:`text-xs`,gap:`gap-3`},compact:{row:`gap-2.5 px-3 py-2 text-[13px]`,icon:`h-4 w-4`,value:`text-[11px]`,gap:`gap-2.5`}};function Q(e){return Vr[e]}function Hr({to:e,label:t,icon:n,density:r=`default`,className:i}){let a=Q(r);return(0,A.jsx)(ie,{to:e,className:({isActive:e})=>d(`group flex w-full items-center rounded-xl font-medium transition-colors duration-base`,a.row,e?`bg-gray-200 text-gray-900 shadow-sm`:`text-gray-600 hover:bg-gray-200/60 hover:text-gray-900`,i),children:({isActive:e})=>(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(n,{className:d(a.icon,`transition-colors`,e?`text-gray-900`:`text-gray-500 group-hover:text-gray-800`)}),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:t})]})})}function Ur({label:e,icon:t,onClick:n,density:r=`default`,className:i,labelClassName:a,trailing:o,trailingClassName:s,testId:c,trailingTestId:l}){let u=Q(r);return(0,A.jsxs)(`button`,{type:`button`,onClick:n,className:d(`flex w-full items-center rounded-xl font-medium text-gray-600 transition-all duration-base hover:bg-gray-200/60 hover:text-gray-800`,u.row,i),"data-testid":c,children:[(0,A.jsx)(t,{className:d(u.icon,`shrink-0 text-gray-400`)}),(0,A.jsx)(`span`,{className:d(`min-w-0 flex-1 text-left`,a),children:e}),o?(0,A.jsx)(`span`,{className:d(`shrink-0 text-gray-500`,u.value,s),"data-testid":l,children:o}):null]})}function Wr({label:e,icon:t,value:n,valueLabel:r,onValueChange:i,density:a=`default`,children:o}){let s=Q(a);return(0,A.jsxs)(be,{value:n,onValueChange:i,children:[(0,A.jsxs)(ge,{className:d(`h-auto w-full rounded-xl border-0 bg-transparent font-medium text-gray-600 shadow-none hover:bg-gray-200/60 focus:ring-0`,s.row),children:[(0,A.jsxs)(`div`,{className:d(`flex min-w-0 items-center`,s.gap),children:[(0,A.jsx)(t,{className:d(s.icon,`text-gray-400`)}),(0,A.jsx)(`span`,{className:`text-left`,children:e})]}),(0,A.jsx)(`span`,{className:d(`ml-auto text-gray-500`,s.value),children:r})]}),(0,A.jsx)(ve,{children:o})]})}var Gr=(0,k.createContext)(null);function Kr({children:e}){let[t,r]=(0,k.useState)(()=>u());(0,k.useEffect)(()=>a(e=>{r(e)}),[]);let i=(0,k.useCallback)(e=>{n(e),r(c())},[]),o=(0,k.useCallback)(()=>{i(t===`en`?`zh`:`en`)},[t,i]),s=(0,k.useMemo)(()=>({language:t,setLanguage:i,toggleLanguage:o}),[t,i,o]);return(0,A.jsx)(Gr.Provider,{value:s,children:e})}function qr(){let e=(0,k.useContext)(Gr);if(!e)throw Error(`useI18n must be used within I18nProvider`);return{...e,t:i}}var Jr=(0,k.createContext)(null);function Yr({children:e}){let[t,n]=(0,k.useState)(()=>Yn());(0,k.useEffect)(()=>Qn(e=>{n(e)}),[]);let r=(0,k.useCallback)(e=>{Zn(e),n(Xn())},[]),i=(0,k.useMemo)(()=>({theme:t,setTheme:r}),[t,r]);return(0,A.jsx)(Jr.Provider,{value:i,children:e})}function Xr(){let e=(0,k.useContext)(Jr);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}function Zr({mode:e}){let n=q(),r=O(),a=U(),{language:o,setLanguage:s}=qr(),{theme:c,setTheme:l}=Xr(),u=e===`settings`,ee=t.find(e=>e.value===o)?.label??o,f=i(Un.find(e=>e.value===c)?.labelKey??`themeWarm`),te=a.data?.account.email?.trim(),ne=!!a.data?.account.loggedIn,p=e=>{o!==e&&(s(e),window.location.reload())},m=e=>{c!==e&&l(e)},h=[{target:`/chat`,label:i(`chat`),icon:Wt},{target:`/chat/cron`,label:i(`cron`),icon:Lt},{target:`/chat/skills`,label:i(`marketplaceFilterSkills`),icon:Rt}],re=[{target:`/model`,label:i(`model`),icon:zt},{target:`/providers`,label:i(`providers`),icon:Xt},{target:`/search`,label:i(`searchChannels`),icon:Te},{target:`/channels`,label:i(`channels`),icon:Gt},{target:`/runtime`,label:i(`runtime`),icon:Bt},{target:`/remote`,label:i(`remote`),icon:Qt},{target:`/security`,label:i(`security`),icon:Yt},{target:`/sessions`,label:i(`sessions`),icon:Vt},{target:`/secrets`,label:i(`secrets`),icon:R},{target:`/marketplace/plugins`,label:i(`marketplaceFilterPlugins`),icon:qt},{target:`/marketplace/mcp`,label:i(`marketplaceFilterMcp`),icon:$t}],g=u?re:h,_=u?`compact`:`default`;return(0,A.jsxs)(`aside`,{className:`w-[240px] shrink-0 flex h-full min-h-0 flex-col overflow-hidden bg-secondary px-4 py-6`,children:[u?(0,A.jsx)(`div`,{className:`shrink-0 px-2 pb-3`,children:(0,A.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-1`,"data-testid":`settings-sidebar-header`,children:[(0,A.jsxs)(ie,{to:`/chat`,className:`group inline-flex min-w-0 items-center gap-1.5 rounded-lg px-1 py-1 text-[12px] font-medium text-gray-500 transition-colors hover:bg-gray-200/60 hover:text-gray-900`,children:[(0,A.jsx)(Ce,{className:`h-3.5 w-3.5 shrink-0 text-gray-400 group-hover:text-gray-700`}),(0,A.jsx)(`span`,{className:`truncate`,children:i(`backToMain`)})]}),(0,A.jsx)(`span`,{className:`h-4 w-px shrink-0 bg-[#dddfe6]`,"aria-hidden":`true`}),(0,A.jsx)(`h1`,{className:`truncate text-[15px] font-semibold tracking-[-0.01em] text-gray-800`,children:i(`settings`)})]})}):(0,A.jsx)(`div`,{className:`shrink-0 px-2 pb-8`,children:(0,A.jsx)(Br,{className:`flex items-center gap-2.5 cursor-pointer`})}),(0,A.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,A.jsx)(`nav`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto pr-1`,children:(0,A.jsx)(`ul`,{className:d(u?`space-y-0.5 pb-3`:`space-y-1 pb-4`),children:g.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsx)(Hr,{to:e.target,label:e.label,icon:e.icon,density:_})},e.target))})}),(0,A.jsxs)(`div`,{className:d(`shrink-0 border-t border-[#dde0ea] bg-secondary`,u?`mt-2 pt-3`:`mt-3 pt-3`),children:[u?(0,A.jsx)(Ur,{onClick:()=>n.accountManager.openAccountPanel(),icon:R,label:i(`remoteAccountEntryManage`),density:`compact`,className:`mb-1.5`,trailing:ne?te||i(`remoteAccountEntryConnected`):i(`remoteAccountEntryDisconnected`),trailingClassName:`max-w-[92px] truncate text-right`,testId:`settings-sidebar-account-entry`,trailingTestId:`settings-sidebar-account-status`}):null,e===`main`&&(0,A.jsx)(`div`,{className:`mb-2`,children:(0,A.jsx)(Hr,{to:`/settings`,label:i(`settings`),icon:Jt})}),(0,A.jsx)(`div`,{className:`mb-2`,children:(0,A.jsx)(Wr,{value:c,onValueChange:e=>m(e),icon:Kt,label:i(`theme`),valueLabel:f,density:_,children:Un.map(e=>(0,A.jsx)(ye,{value:e.value,className:`text-xs`,children:i(e.labelKey)},e.value))})}),(0,A.jsx)(`div`,{className:`mb-2`,children:(0,A.jsx)(Wr,{value:o,onValueChange:e=>p(e),icon:Ht,label:i(`language`),valueLabel:ee,density:_,children:t.map(e=>(0,A.jsx)(ye,{value:e.value,className:`text-xs`,children:e.label},e.value))})}),(0,A.jsx)(Ur,{onClick:()=>r.open(void 0,{kind:`docs`,newTab:!0,title:`Docs`}),icon:we,label:i(`docBrowserHelp`),density:_})]})]})]})}var Qr=`NextClaw`,$r=[{prefix:`/marketplace/mcp`,key:`marketplaceMcpPageTitle`},{prefix:`/marketplace/plugins`,key:`marketplacePluginsPageTitle`},{prefix:`/marketplace/skills`,key:`marketplaceSkillsPageTitle`},{prefix:`/marketplace`,key:`marketplace`},{prefix:`/skills`,key:`marketplaceSkillsPageTitle`},{prefix:`/cron`,key:`cronPageTitle`},{prefix:`/chat`,key:`chat`},{prefix:`/model`,key:`modelPageTitle`},{prefix:`/search`,key:`searchPageTitle`},{prefix:`/providers`,key:`providersPageTitle`},{prefix:`/channels`,key:`channelsPageTitle`},{prefix:`/runtime`,key:`runtimePageTitle`},{prefix:`/remote`,key:`remotePageTitle`},{prefix:`/security`,key:`authSecurityTitle`},{prefix:`/sessions`,key:`sessionsPageTitle`},{prefix:`/secrets`,key:`secretsPageTitle`}];function ei(e,t){return e===t||e.startsWith(`${t}/`)}function ti(e){let t=e.toLowerCase();for(let{prefix:e,key:n}of $r)if(ei(t,e))return i(n);return i(`settings`)}function ni(e){return`${Qr} - ${ti(e)}`}var ri=(0,k.lazy)(async()=>({default:(await y(async()=>{let{DocBrowser:e}=await import(`./DocBrowser-B9OaZjmg.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))).DocBrowser}));function ii(e){let t=e.toLowerCase();return t===`/chat`||t.startsWith(`/chat/`)||t===`/skills`||t.startsWith(`/skills/`)||t===`/cron`||t.startsWith(`/cron/`)}function ai(e){let t=e.toLowerCase();return t===`/channels`||t.startsWith(`/channels/`)}function oi({children:e}){let{isOpen:t,mode:n}=O();$n();let{pathname:r}=ae(),{language:i}=qr(),a=ii(r),o=ai(r);return(0,k.useEffect)(()=>{document.title=ni(r)},[r,i]),(0,A.jsxs)(`div`,{className:`h-screen flex bg-background font-sans text-foreground`,children:[!a&&(0,A.jsx)(Zr,{mode:`settings`}),(0,A.jsxs)(`div`,{className:`flex-1 flex min-w-0 overflow-hidden relative`,children:[(0,A.jsx)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,children:a?(0,A.jsx)(`div`,{className:`flex-1 h-full overflow-hidden`,children:e}):(0,A.jsx)(`main`,{className:d(`flex-1 custom-scrollbar p-8`,o?`overflow-auto xl:overflow-hidden`:`overflow-auto`),children:(0,A.jsx)(`div`,{className:d(`max-w-6xl mx-auto animate-fade-in h-full`,o&&`min-h-0 xl:overflow-hidden`),children:e})})}),t&&n===`docked`&&(0,A.jsx)(k.Suspense,{fallback:null,children:(0,A.jsx)(ri,{})})]}),t&&n===`floating`&&(0,A.jsx)(k.Suspense,{fallback:null,children:(0,A.jsx)(ri,{})})]})}function si({children:e}){return(0,A.jsx)(et,{children:(0,A.jsx)(oi,{children:e})})}var ci=se(e=>({connectionStatus:`disconnected`,setConnectionStatus:t=>e({connectionStatus:t}),channelModal:{open:!1},openChannelModal:t=>e({channelModal:{open:!0,channel:t}}),closeChannelModal:()=>e({channelModal:{open:!1}})}));function li(e){let t=e.trim().toLowerCase();return t?!(t.startsWith(`plugins`)||t.startsWith(`skills`)):!0}function ui(e,t){t.startsWith(`plugins`)&&(e?.invalidateQueries({queryKey:[`ncp-session-types`]}),e?.invalidateQueries({queryKey:[`marketplace-installed`,`plugin`]}),e?.invalidateQueries({queryKey:[`marketplace-items`]})),t.startsWith(`mcp`)&&(e?.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}))}function di(e,t){e&&li(t)&&e.invalidateQueries({queryKey:[`config`]}),ui(e,t)}function fi(e,t,n,r){if(r.type===`connection.open`){t(`connected`),n.current&&(n.current=!1,e?.invalidateQueries({queryKey:[`ncp-sessions`]}));return}if(r.type===`connection.close`||r.type===`connection.error`){t(`disconnected`),n.current=!0;return}if(r.type===`config.updated`){di(e,typeof r.payload?.path==`string`?r.payload.path:``);return}if(r.type===`session.run-status`||r.type===`session.summary.upsert`||r.type===`session.summary.delete`){cr(e,r);return}r.type===`error`&&console.error(`Realtime transport error:`,r.payload.message)}function pi(e){let{setConnectionStatus:t}=ci(),n=(0,k.useRef)(!1);(0,k.useEffect)(()=>(t(`connecting`),te.subscribe(r=>fi(e,t,n,r))),[e,t])}var mi=(0,k.lazy)(async()=>({default:(await y(async()=>{let{ModelConfig:e}=await import(`./ModelConfig-DJgdcgvQ.js`);return{ModelConfig:e}},__vite__mapDeps([10,2,11,12,3,4,13,14,9,15,16,17,18]))).ModelConfig})),hi=(0,k.lazy)(async()=>({default:(await y(async()=>{let{ChatPage:e}=await import(`./ChatPage-DWOU_8P6.js`);return{ChatPage:e}},__vite__mapDeps([19,2,20,11,12,3,21,22,23,24,9,15,25,26,17,27,28,4,29,14,5,13,30,6,31,7,32,8,33,34,16]))).ChatPage})),gi=(0,k.lazy)(async()=>({default:(await y(async()=>{let{SearchConfig:e}=await import(`./SearchConfig-BT13qpR_.js`);return{SearchConfig:e}},__vite__mapDeps([35,2,11,12,3,5,7,36,15,16]))).SearchConfig})),_i=(0,k.lazy)(async()=>({default:(await y(async()=>{let{ProvidersList:e}=await import(`./ProvidersList-w0rVFIBf.js`);return{ProvidersList:e}},__vite__mapDeps([37,2,11,12,3,21,22,6,7,32,8,34,36,15,16,38,39,27,18]))).ProvidersList})),vi=(0,k.lazy)(async()=>({default:(await y(async()=>{let{ChannelsList:e}=await import(`./ChannelsList-Zeys_w43.js`);return{ChannelsList:e}},__vite__mapDeps([40,2,11,12,3,24,4,5,30,41,14,7,8,34,36,15,16,38,39,27,18]))).ChannelsList})),yi=(0,k.lazy)(async()=>({default:(await y(async()=>{let{RuntimeConfig:e}=await import(`./RuntimeConfig-Cmn2xPQO.js`);return{RuntimeConfig:e}},__vite__mapDeps([42,2,11,12,3,6,43,32,15,39,18]))).RuntimeConfig})),bi=(0,k.lazy)(async()=>({default:(await y(async()=>{let{SecurityConfig:e}=await import(`./security-config-T5zpg16O.js`);return{SecurityConfig:e}},__vite__mapDeps([44,2,12,15,16,39]))).SecurityConfig})),xi=(0,k.lazy)(async()=>({default:(await y(async()=>{let{SessionsConfig:e}=await import(`./SessionsConfig-DHHcYznk.js`);return{SessionsConfig:e}},__vite__mapDeps([45,2,11,12,3,29,14,41,7,15,26]))).SessionsConfig})),Si=(0,k.lazy)(async()=>({default:(await y(async()=>{let{SecretsConfig:e}=await import(`./SecretsConfig-CvqEVn0B.js`);return{SecretsConfig:e}},__vite__mapDeps([46,2,11,12,3,6,43,32,15,16,39]))).SecretsConfig})),Ci=(0,k.lazy)(async()=>({default:(await y(async()=>{let{RemoteAccessPage:e}=await import(`./RemoteAccessPage-BJ_ckkOV.js`);return{RemoteAccessPage:e}},__vite__mapDeps([47,2,12,3,31,15,38]))).RemoteAccessPage})),wi=(0,k.lazy)(async()=>({default:(await y(async()=>{let{MarketplacePage:e}=await import(`./MarketplacePage-BfaTTqN6.js`);return{MarketplacePage:e}},__vite__mapDeps([48,23,2,20,11,12,3,22,24,9,15,25,26,17,27]))).MarketplacePage})),Ti=(0,k.lazy)(async()=>({default:(await y(async()=>{let{McpMarketplacePage:e}=await import(`./McpMarketplacePage-C09Ngs7O.js`);return{McpMarketplacePage:e}},__vite__mapDeps([49,2,11,12,3,24,9,15,25,26,17,39,27]))).McpMarketplacePage}));function Ei(){return(0,A.jsx)(`div`,{className:`h-full w-full animate-pulse rounded-2xl border border-border/40 bg-card/40`})}function $({children:e}){return(0,A.jsx)(k.Suspense,{fallback:(0,A.jsx)(Ei,{}),children:e})}function Di(){return pi(x),(0,A.jsxs)(Cn,{children:[(0,A.jsx)(si,{children:(0,A.jsx)(`div`,{className:`w-full h-full`,children:(0,A.jsxs)(_,{children:[(0,A.jsx)(v,{path:`/chat/skills`,element:(0,A.jsx)(b,{to:`/skills`,replace:!0})}),(0,A.jsx)(v,{path:`/chat/cron`,element:(0,A.jsx)(b,{to:`/cron`,replace:!0})}),(0,A.jsx)(v,{path:`/chat/:sessionId?`,element:(0,A.jsx)($,{children:(0,A.jsx)(hi,{view:`chat`})})}),(0,A.jsx)(v,{path:`/skills`,element:(0,A.jsx)($,{children:(0,A.jsx)(hi,{view:`skills`})})}),(0,A.jsx)(v,{path:`/cron`,element:(0,A.jsx)($,{children:(0,A.jsx)(hi,{view:`cron`})})}),(0,A.jsx)(v,{path:`/model`,element:(0,A.jsx)($,{children:(0,A.jsx)(mi,{})})}),(0,A.jsx)(v,{path:`/search`,element:(0,A.jsx)($,{children:(0,A.jsx)(gi,{})})}),(0,A.jsx)(v,{path:`/providers`,element:(0,A.jsx)($,{children:(0,A.jsx)(_i,{})})}),(0,A.jsx)(v,{path:`/channels`,element:(0,A.jsx)($,{children:(0,A.jsx)(vi,{})})}),(0,A.jsx)(v,{path:`/runtime`,element:(0,A.jsx)($,{children:(0,A.jsx)(yi,{})})}),(0,A.jsx)(v,{path:`/remote`,element:(0,A.jsx)($,{children:(0,A.jsx)(Ci,{})})}),(0,A.jsx)(v,{path:`/security`,element:(0,A.jsx)($,{children:(0,A.jsx)(bi,{})})}),(0,A.jsx)(v,{path:`/sessions`,element:(0,A.jsx)($,{children:(0,A.jsx)(xi,{})})}),(0,A.jsx)(v,{path:`/secrets`,element:(0,A.jsx)($,{children:(0,A.jsx)(Si,{})})}),(0,A.jsx)(v,{path:`/settings`,element:(0,A.jsx)(b,{to:`/model`,replace:!0})}),(0,A.jsx)(v,{path:`/marketplace/skills`,element:(0,A.jsx)(b,{to:`/skills`,replace:!0})}),(0,A.jsx)(v,{path:`/marketplace`,element:(0,A.jsx)(b,{to:`/marketplace/plugins`,replace:!0})}),(0,A.jsx)(v,{path:`/marketplace/mcp`,element:(0,A.jsx)($,{children:(0,A.jsx)(Ti,{})})}),(0,A.jsx)(v,{path:`/marketplace/:type`,element:(0,A.jsx)($,{children:(0,A.jsx)(wi,{})})}),(0,A.jsx)(v,{path:`/`,element:(0,A.jsx)(b,{to:`/chat`,replace:!0})}),(0,A.jsx)(v,{path:`*`,element:(0,A.jsx)(b,{to:`/chat`,replace:!0})})]})})}),(0,A.jsx)(wn,{})]})}function Oi(){let e=Fn(),t=e.isError&&Nn(e.error);return e.isLoading&&!e.isError||t||e.isError?(0,A.jsx)(Di,{}):e.data?.enabled&&!e.data.authenticated?(0,A.jsx)(Vn,{username:e.data.username}):(0,A.jsx)(Di,{})}function ki(){return(0,A.jsxs)(ne,{client:x,children:[(0,A.jsx)(Oi,{}),(0,A.jsx)(re,{position:`top-right`,richColors:!0})]})}(0,nt.createRoot)(document.getElementById(`root`)).render((0,A.jsx)(k.StrictMode,{children:(0,A.jsx)(Yr,{children:(0,A.jsx)(Kr,{children:(0,A.jsx)(oe,{children:(0,A.jsx)(ki,{})})})})}));export{yn as $,Or as A,Rn as B,wr as C,vr as D,Dr as E,fr as F,Tn as G,Bn as H,sr as I,En as J,kn as K,ir as L,kr as M,pr as N,Fr as O,ur as P,U as Q,Un as R,zr as S,Rr as T,zn as U,In as V,Y as W,q as X,Dn as Y,G as Z,Er as _,Hr as a,sn as at,jr as b,mr as c,Xt as ct,xr as d,Gt as dt,en as et,Ir as f,Wt as ft,Ar as g,Lt as gt,Sr as h,Rt as ht,Ur as i,an as it,yr as j,br as k,gr as l,Jt as lt,Pr as m,R as mt,Xr as n,cn as nt,Wr as o,$t as ot,Lr as p,Ht as pt,On as q,qr as r,on as rt,Br as s,Zt as st,ci as t,rn as tt,_r as u,Kt as ut,Mr as v,Cr as w,Tr as x,Nr as y,Fn as z};
@@ -1 +0,0 @@
1
- import{t as e}from"./createLucideIcon-CjGHOWb6.js";var t=e(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]);export{t};
@@ -1 +0,0 @@
1
- import{t as e}from"./createLucideIcon-CjGHOWb6.js";var t=e(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]);export{t};
@@ -1 +0,0 @@
1
- import{t as e}from"./createLucideIcon-CjGHOWb6.js";var t=e(`Search`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]);export{t};
@@ -1 +0,0 @@
1
- import{p as e,u as t}from"./i18n-CDHMXlRZ.js";var n=e();function r({className:e,...r}){return(0,n.jsx)(`div`,{className:t(`animate-pulse rounded-md bg-slate-200`,e),...r})}export{r as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./createLucideIcon-CjGHOWb6.js";var t=e(`X`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);export{t};
@@ -1,154 +0,0 @@
1
- import {
2
- stringifyUnknown,
3
- summarizeToolArgs,
4
- type ToolCard,
5
- } from "@/lib/chat-message";
6
- import type { ChatToolPartViewModel } from "@nextclaw/agent-chat-ui";
7
-
8
- type ToolCardViewSource = ToolCard & {
9
- statusTone: ChatToolPartViewModel["statusTone"];
10
- statusLabel: string;
11
- };
12
-
13
- type SpawnToolInvocation = {
14
- toolName: string;
15
- toolCallId?: string;
16
- args?: unknown;
17
- result?: unknown;
18
- };
19
-
20
- type SubagentToolCardTexts = {
21
- toolStatusRunningLabel: string;
22
- toolStatusCompletedLabel: string;
23
- toolStatusFailedLabel: string;
24
- };
25
-
26
- type SubagentRunResult = {
27
- runId?: string;
28
- label?: string;
29
- task?: string;
30
- status?: string;
31
- result?: unknown;
32
- message?: string;
33
- };
34
-
35
- function isRecord(value: unknown): value is Record<string, unknown> {
36
- return typeof value === "object" && value !== null;
37
- }
38
-
39
- function readOptionalString(value: unknown): string | null {
40
- if (typeof value !== "string") {
41
- return null;
42
- }
43
- const trimmed = value.trim();
44
- return trimmed.length > 0 ? trimmed : null;
45
- }
46
-
47
- function readSubagentRunResult(value: unknown): SubagentRunResult | null {
48
- if (!isRecord(value)) {
49
- return null;
50
- }
51
- if (value.kind === "nextclaw.subagent_run") {
52
- return value;
53
- }
54
- if (typeof value.runId === "string" && typeof value.status === "string") {
55
- return value;
56
- }
57
- return null;
58
- }
59
-
60
- function buildSubagentDetail(subagentRun: SubagentRunResult, fallbackArgs: unknown): string | undefined {
61
- const detailParts = [
62
- readOptionalString(subagentRun.label)
63
- ? `label: ${subagentRun.label?.trim()}`
64
- : null,
65
- readOptionalString(subagentRun.runId)
66
- ? `run: ${subagentRun.runId?.trim()}`
67
- : null,
68
- readOptionalString(subagentRun.task)
69
- ? `task: ${subagentRun.task?.trim()}`
70
- : null,
71
- ].filter((value): value is string => Boolean(value));
72
-
73
- return detailParts.join(" · ") || summarizeToolArgs(fallbackArgs);
74
- }
75
-
76
- function buildSubagentOutput(subagentRun: SubagentRunResult): string | undefined {
77
- const runId = readOptionalString(subagentRun.runId);
78
- const label = readOptionalString(subagentRun.label);
79
- const task = readOptionalString(subagentRun.task);
80
- const status = readOptionalString(subagentRun.status)?.toLowerCase();
81
- const resultText =
82
- typeof subagentRun.result !== "undefined"
83
- ? stringifyUnknown(subagentRun.result).trim()
84
- : "";
85
- const messageText = readOptionalString(subagentRun.message);
86
-
87
- const sections = [
88
- runId ? `Run ID: ${runId}` : null,
89
- label ? `Label: ${label}` : null,
90
- task ? `Task:\n${task}` : null,
91
- resultText
92
- ? `${status === "failed" ? "Error" : "Result"}:\n${resultText}`
93
- : messageText
94
- ? `Status:\n${messageText}`
95
- : null,
96
- ].filter((value): value is string => Boolean(value));
97
-
98
- return sections.length > 0 ? sections.join("\n\n") : undefined;
99
- }
100
-
101
- export function buildSubagentToolCard(params: {
102
- invocation: SpawnToolInvocation;
103
- texts: SubagentToolCardTexts;
104
- }): ToolCardViewSource | null {
105
- if (params.invocation.toolName !== "spawn") {
106
- return null;
107
- }
108
-
109
- const subagentRun = readSubagentRunResult(params.invocation.result);
110
- if (!subagentRun) {
111
- return null;
112
- }
113
-
114
- const normalizedStatus = readOptionalString(subagentRun.status)?.toLowerCase();
115
- const detail = buildSubagentDetail(subagentRun, params.invocation.args);
116
- const output = buildSubagentOutput(subagentRun);
117
-
118
- if (normalizedStatus === "failed") {
119
- return {
120
- kind: "result",
121
- name: params.invocation.toolName,
122
- detail,
123
- text: output,
124
- callId: params.invocation.toolCallId || undefined,
125
- hasResult: Boolean(output),
126
- statusTone: "error",
127
- statusLabel: params.texts.toolStatusFailedLabel,
128
- };
129
- }
130
-
131
- if (normalizedStatus === "completed") {
132
- return {
133
- kind: "result",
134
- name: params.invocation.toolName,
135
- detail,
136
- text: output,
137
- callId: params.invocation.toolCallId || undefined,
138
- hasResult: Boolean(output),
139
- statusTone: "success",
140
- statusLabel: params.texts.toolStatusCompletedLabel,
141
- };
142
- }
143
-
144
- return {
145
- kind: "result",
146
- name: params.invocation.toolName,
147
- detail,
148
- text: output,
149
- callId: params.invocation.toolCallId || undefined,
150
- hasResult: Boolean(output),
151
- statusTone: "running",
152
- statusLabel: params.texts.toolStatusRunningLabel,
153
- };
154
- }