nextclaw 0.18.0 → 0.18.2

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 (102) hide show
  1. package/dist/cli/{index.js → app/index.js} +11531 -9137
  2. package/package.json +20 -20
  3. package/resources/USAGE.md +30 -3
  4. package/ui-dist/assets/ChannelsList-SQ7Oxotv.js +8 -0
  5. package/ui-dist/assets/DocBrowser-BCO2k6XD.js +1 -0
  6. package/ui-dist/assets/{DocBrowser-6ReNjvzF.js → DocBrowser-rDOjI3ga.js} +1 -1
  7. package/ui-dist/assets/{DocBrowserContext-B6SpA7Qs.js → DocBrowserContext-BUq3Wo8O.js} +1 -1
  8. package/ui-dist/assets/{LogoBadge-ByNLYg65.js → LogoBadge-DP8Ye7wJ.js} +1 -1
  9. package/ui-dist/assets/ModelConfig-C77Ae9ru.js +1 -0
  10. package/ui-dist/assets/ProviderScopedModelInput-CEnK61uo.js +1 -0
  11. package/ui-dist/assets/ProvidersList-BCupBayq.js +1 -0
  12. package/ui-dist/assets/RuntimeConfig-Ad-CAcmy.js +1 -0
  13. package/ui-dist/assets/SearchConfig-BfCz4wJ4.js +1 -0
  14. package/ui-dist/assets/SecretsConfig-DjmBIhyy.js +3 -0
  15. package/ui-dist/assets/{SessionsConfig-ChHQ7M5c.js → SessionsConfig-CvjxU40H.js} +2 -2
  16. package/ui-dist/assets/{book-open-BdcxxoQu.js → book-open-BE8M56IM.js} +1 -1
  17. package/ui-dist/assets/chat-page-JKC6ln-y.js +58 -0
  18. package/ui-dist/assets/chat-session-display-YcRMrAMa.js +1 -0
  19. package/ui-dist/assets/{chunk-JZWAC4HX-DK5HPmIK.js → chunk-JZWAC4HX-erTUn3b8.js} +1 -1
  20. package/ui-dist/assets/client-CszWMVKi.js +7 -0
  21. package/ui-dist/assets/config-split-page-BAGSzUR3.js +1 -0
  22. package/ui-dist/assets/{createLucideIcon-BSeTgkZW.js → createLucideIcon-CCiTGX8L.js} +1 -1
  23. package/ui-dist/assets/desktop-DfkLlkG2.js +1 -0
  24. package/ui-dist/assets/desktop-update-config-BXeGlqHD.js +1 -0
  25. package/ui-dist/assets/dialog-BghZFPch.js +5 -0
  26. package/ui-dist/assets/{dist-6TrrnPCR.js → dist-Dd9cr-kz.js} +1 -1
  27. package/ui-dist/assets/dist-ZwoAXs46.js +9 -0
  28. package/ui-dist/assets/{download-BhDxnyvU.js → download-D7LOizcW.js} +1 -1
  29. package/ui-dist/assets/es2015-CEAreese.js +41 -0
  30. package/ui-dist/assets/{external-link-BgErLCNT.js → external-link-qsnCMhw1.js} +1 -1
  31. package/ui-dist/assets/{hash-Bl7dr_UG.js → hash-0zjWsNl-.js} +1 -1
  32. package/ui-dist/assets/{i18n-eDHeDY0n.js → i18n-DvzXOGQX.js} +1 -1
  33. package/ui-dist/assets/index-DvVTC9FF.css +1 -0
  34. package/ui-dist/assets/index-lr6rQUSd.js +2 -0
  35. package/ui-dist/assets/key-round-BLe9D8ND.js +1 -0
  36. package/ui-dist/assets/loader-circle-wj7kARHv.js +1 -0
  37. package/ui-dist/assets/{logos-x89HbrZ4.js → logos-_v5b2SdG.js} +1 -1
  38. package/ui-dist/assets/marketplace-page-CAAk1Khc.js +1 -0
  39. package/ui-dist/assets/marketplace-page-CfCiq90S.js +49 -0
  40. package/ui-dist/assets/mcp-marketplace-page-D0Pp9Hs-.js +40 -0
  41. package/ui-dist/assets/play-o6NmwGTi.js +1 -0
  42. package/ui-dist/assets/plus-I9pBS4Fl.js +1 -0
  43. package/ui-dist/assets/{refresh-cw-C47QSEwg.js → refresh-cw-MNqgR3LZ.js} +1 -1
  44. package/ui-dist/assets/remote-C9fXm4V5.js +1 -0
  45. package/ui-dist/assets/{save-3S6-H3Xw.js → save-D4bObrmH.js} +1 -1
  46. package/ui-dist/assets/search-DxmL3IWE.js +1 -0
  47. package/ui-dist/assets/security-config-BUm6FFfl.js +1 -0
  48. package/ui-dist/assets/select-BILPf7zs.js +1 -0
  49. package/ui-dist/assets/setting-row-BATDgg4r.js +1 -0
  50. package/ui-dist/assets/skeleton-COKMAnJy.js +1 -0
  51. package/ui-dist/assets/{switch-BsLtHOH-.js → switch-CBOzecWS.js} +1 -1
  52. package/ui-dist/assets/{tabs-custom-D3HYMt6k.js → tabs-custom-Bx3cNhD-.js} +1 -1
  53. package/ui-dist/assets/tag-chip-zUaDE2-H.js +1 -0
  54. package/ui-dist/assets/{trash-2-G48scll7.js → trash-2-CQUgYyRn.js} +1 -1
  55. package/ui-dist/assets/use-infinite-scroll-loader-B5V2Klve.js +1 -0
  56. package/ui-dist/assets/useConfirmDialog-patAnl1g.js +1 -0
  57. package/ui-dist/assets/{useMutation-CBWjE2uj.js → useMutation-__AYv-Pz.js} +1 -1
  58. package/ui-dist/assets/x-BHUGQIUv.js +1 -0
  59. package/ui-dist/index.html +22 -22
  60. package/ui-dist/runtime-icons/claude.ico +0 -0
  61. package/ui-dist/runtime-icons/codex-openai.svg +6 -0
  62. package/ui-dist/runtime-icons/hermes-agent.png +0 -0
  63. package/ui-dist/assets/ChannelsList-Ita2Zm1_.js +0 -8
  64. package/ui-dist/assets/DocBrowser-BNwbPHf4.js +0 -1
  65. package/ui-dist/assets/MarketplacePage-CjX2MWww.js +0 -1
  66. package/ui-dist/assets/MarketplacePage-D0sDlYX4.js +0 -49
  67. package/ui-dist/assets/McpMarketplacePage-BGKJm1sJ.js +0 -40
  68. package/ui-dist/assets/ModelConfig-BzZenCH-.js +0 -1
  69. package/ui-dist/assets/ProviderScopedModelInput-Da7khnBA.js +0 -1
  70. package/ui-dist/assets/ProvidersList-BbVzRxjY.js +0 -1
  71. package/ui-dist/assets/RemoteAccessPage-BaDH_X1Q.js +0 -1
  72. package/ui-dist/assets/RuntimeConfig-F_XKGgLm.js +0 -1
  73. package/ui-dist/assets/SearchConfig-BGkzXQP-.js +0 -1
  74. package/ui-dist/assets/SecretsConfig-D281Rotl.js +0 -3
  75. package/ui-dist/assets/app-query-client-VnFElj4E.js +0 -1
  76. package/ui-dist/assets/chat-page-Doe0yTtB.js +0 -58
  77. package/ui-dist/assets/chat-session-display-cw78aiI_.js +0 -1
  78. package/ui-dist/assets/client-_i4MU2bB.js +0 -7
  79. package/ui-dist/assets/config-DtIQwrHF.js +0 -1
  80. package/ui-dist/assets/config-layout-CHs0mAaR.js +0 -1
  81. package/ui-dist/assets/desktop-update-config-Dpcf4BKG.js +0 -1
  82. package/ui-dist/assets/dist-ccBFUi-o.js +0 -9
  83. package/ui-dist/assets/index-CF9xve0E.js +0 -6
  84. package/ui-dist/assets/index-FgA52VBt.css +0 -1
  85. package/ui-dist/assets/infiniteQueryBehavior-ZDS92Qpp.js +0 -1
  86. package/ui-dist/assets/loader-circle-ACM1s51e.js +0 -1
  87. package/ui-dist/assets/page-layout-vZnghcFy.js +0 -1
  88. package/ui-dist/assets/play-CFUwCA2E.js +0 -1
  89. package/ui-dist/assets/plus-rYsv72JG.js +0 -1
  90. package/ui-dist/assets/popover-Bg1VoTZ6.js +0 -1
  91. package/ui-dist/assets/refresh-ccw-DT98i__E.js +0 -1
  92. package/ui-dist/assets/rotate-cw-JtFzpNn6.js +0 -1
  93. package/ui-dist/assets/search-3kFR_zh9.js +0 -1
  94. package/ui-dist/assets/security-config-BWaiARNk.js +0 -1
  95. package/ui-dist/assets/select-DJ2MUjBB.js +0 -41
  96. package/ui-dist/assets/skeleton-ByQepn0M.js +0 -1
  97. package/ui-dist/assets/status-dot-vbanNPFU.js +0 -1
  98. package/ui-dist/assets/use-infinite-scroll-loader-DkNhD-42.js +0 -1
  99. package/ui-dist/assets/useConfirmDialog-BkvTN-vd.js +0 -1
  100. package/ui-dist/assets/x-ByDbItbq.js +0 -1
  101. /package/dist/cli/{index.d.ts → app/index.d.ts} +0 -0
  102. /package/ui-dist/assets/{config-hints-BhTmc9P1.js → config-hints-DSQQbeOA.js} +0 -0
@@ -1,40 +0,0 @@
1
- import{_ as e,i as t,m as n,p as r,u as i}from"./i18n-eDHeDY0n.js";import{n as a,r as o}from"./dist-ccBFUi-o.js";import{i as s,s as c,t as l}from"./client-_i4MU2bB.js";import{c as u,i as d,l as f,n as p,o as m,r as h,t as g}from"./use-infinite-scroll-loader-DkNhD-42.js";import{t as _}from"./useMutation-CBWjE2uj.js";import{a as ee,i as v,n as te,r as y,t as ne}from"./select-DJ2MUjBB.js";import{i as b}from"./DocBrowserContext-B6SpA7Qs.js";import{at as x,ct as S,i as re,it as C,nt as w,ot as T,rt as E,st as D}from"./index-CF9xve0E.js";import{n as O,t as ie}from"./page-layout-vZnghcFy.js";import{t as ae}from"./useConfirmDialog-BkvTN-vd.js";import{t as oe}from"./tabs-custom-D3HYMt6k.js";import{t as k}from"./skeleton-ByQepn0M.js";import{t as A}from"./switch-BsLtHOH-.js";var j=e(n(),1);async function M(e){let t=new URLSearchParams;e.q?.trim()&&t.set(`q`,e.q.trim()),e.tag?.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))));let n=t.toString(),r=await l.get(n?`/api/marketplace/mcp/items?${n}`:`/api/marketplace/mcp/items`);if(!r.ok)throw Error(r.error.message);return r.data}async function N(){let e=await l.get(`/api/marketplace/mcp/installed`);if(!e.ok)throw Error(e.error.message);return e.data}async function P(e){let t=await l.get(`/api/marketplace/mcp/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw Error(t.error.message);return t.data}async function F(e){let t=await l.post(`/api/marketplace/mcp/install`,{type:`mcp`,...e});if(!t.ok)throw Error(t.error.message);return t.data}async function I(e){let t=await l.post(`/api/marketplace/mcp/manage`,{type:`mcp`,...e});if(!t.ok)throw Error(t.error.message);return t.data}async function L(e){let t=await l.post(`/api/marketplace/mcp/doctor`,{name:e});if(!t.ok)throw Error(t.error.message);return t.data}function R(e){let t=f({queryKey:[`marketplace-mcp-items`,e],initialPageParam:1,queryFn:({pageParam:t})=>M({...e,page:t}),getNextPageParam:e=>e.page<e.totalPages?e.page+1:void 0,staleTime:15e3}),n=(0,j.useMemo)(()=>u(t.data),[t.data]);return{...t,data:n}}function z(){return s({queryKey:[`marketplace-mcp-installed`],queryFn:()=>N(),staleTime:1e4})}function B(){let e=c();return _({mutationFn:F,onSuccess:n=>{e.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}),a.success(n.message||t(`marketplaceInstallSuccessMcp`))},onError:e=>{a.error(e.message||t(`marketplaceInstallFailed`))}})}function V(){let e=c();return _({mutationFn:I,onSuccess:n=>{e.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}),a.success(n.message||t(`marketplaceMcpManageSuccess`))},onError:e=>{a.error(e.message||t(`marketplaceOperationFailed`))}})}var H=r(),U=12;function W(e){return(e??``).trim().toLowerCase()}function G(e){let t=new Map;for(let n of e){let e=[n.catalogSlug,n.spec,n.id,n.label];for(let r of e){let e=W(r);!e||t.has(e)||t.set(e,n)}}return t}function K(e,t){let n=[e.slug,e.install.spec,e.id,e.name];for(let e of n){let n=W(e);if(!n)continue;let r=t.get(n);if(r)return r}}function q(e,t,n,r,i){let a=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),o=`<!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1" />
6
- <title>${a(e)}</title>
7
- <style>
8
- body { margin: 0; background: #f8fafc; color: #0f172a; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
9
- .wrap { max-width: 980px; margin: 0 auto; padding: 28px 20px 40px; }
10
- .hero { border: 1px solid #dbeafe; border-radius: 16px; background: linear-gradient(180deg, #eff6ff, #ffffff); padding: 20px; }
11
- .hero h1 { margin: 0; font-size: 26px; }
12
- .grid { display: grid; grid-template-columns: 280px 1fr; gap: 14px; margin-top: 16px; }
13
- .card { border: 1px solid #e2e8f0; background: #fff; border-radius: 14px; overflow: hidden; }
14
- .card h2 { margin: 0; padding: 12px 14px; font-size: 13px; font-weight: 700; color: #1d4ed8; border-bottom: 1px solid #e2e8f0; background: #f8fafc; }
15
- .body { padding: 12px 14px; }
16
- pre { margin: 0; white-space: pre-wrap; line-height: 1.7; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
17
- a { color: #2563eb; text-decoration: none; }
18
- @media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }
19
- </style>
20
- </head>
21
- <body>
22
- <main class="wrap">
23
- <section class="hero">
24
- <h1>${a(e)}</h1>
25
- ${i?`<p>${a(i)}</p>`:``}
26
- ${r?`<p><a href="${a(r)}" target="_blank" rel="noopener noreferrer">${a(r)}</a></p>`:``}
27
- </section>
28
- <section class="grid">
29
- <article class="card">
30
- <h2>Metadata</h2>
31
- <div class="body"><pre>${a(t)}</pre></div>
32
- </article>
33
- <article class="card">
34
- <h2>Content</h2>
35
- <div class="body"><pre>${a(n)}</pre></div>
36
- </article>
37
- </section>
38
- </main>
39
- </body>
40
- </html>`;return`data:text/html;charset=utf-8,${encodeURIComponent(o)}`}function J(e,n,r){return d(n?.summaryI18n,n?.summary,e)||h(r,e)||t(`marketplaceInstalledLocalSummary`)}function se(e,t){return t?.transport?t.transport.toUpperCase():(e?.install?.transportTypes??[]).map(e=>e.toUpperCase()).join(` / `)||`MCP`}function ce(e){let n=e.item?.install,[r,i]=(0,j.useState)(``),[a,s]=(0,j.useState)(!0),[c,l]=(0,j.useState)({});return(0,j.useEffect)(()=>{i(n?.defaultName??``),s(!0),l(Object.fromEntries((n?.inputs??[]).map(e=>[e.id,e.defaultValue??``])))},[n,e.open]),(0,H.jsx)(E,{open:e.open,onOpenChange:e.onOpenChange,children:(0,H.jsxs)(C,{children:[(0,H.jsxs)(D,{children:[(0,H.jsx)(S,{children:t(`marketplaceMcpInstallDialogTitle`)}),(0,H.jsx)(x,{children:e.item?.name??`-`})]}),(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-gray-800`,children:t(`marketplaceMcpServerName`)}),(0,H.jsx)(w,{value:r,onChange:e=>i(e.target.value),placeholder:n?.defaultName??`mcp-server`})]}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl border border-gray-200 px-3 py-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-gray-900`,children:t(`marketplaceMcpAllAgents`)}),(0,H.jsx)(`div`,{className:`text-xs text-gray-500`,children:t(`marketplaceMcpAllAgentsDescription`)})]}),(0,H.jsx)(A,{checked:a,onCheckedChange:s})]}),(n?.inputs??[]).map(e=>(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-gray-800`,children:e.label}),e.description&&(0,H.jsx)(`div`,{className:`text-xs text-gray-500`,children:e.description}),(0,H.jsx)(w,{type:e.secret?`password`:`text`,value:c[e.id]??``,onChange:t=>l(n=>({...n,[e.id]:t.target.value})),placeholder:e.defaultValue??``})]},e.id))]}),(0,H.jsxs)(T,{children:[(0,H.jsx)(o,{variant:`outline`,onClick:()=>e.onOpenChange(!1),disabled:e.pending,children:t(`cancel`)}),(0,H.jsx)(o,{onClick:()=>void e.onSubmit({name:r,allAgents:a,inputs:c}),disabled:e.pending||!r.trim(),children:e.pending?t(`marketplaceInstalling`):t(`marketplaceInstall`)})]})]})})}function Y(e){return(0,H.jsx)(E,{open:e.open,onOpenChange:e.onOpenChange,children:(0,H.jsxs)(C,{children:[(0,H.jsxs)(D,{children:[(0,H.jsx)(S,{children:t(`marketplaceMcpDoctorTitle`)}),(0,H.jsx)(x,{children:e.targetName??`-`})]}),e.pending&&(0,H.jsx)(`div`,{className:`text-sm text-gray-500`,children:t(`loading`)}),!e.pending&&e.result&&(0,H.jsxs)(`div`,{className:`space-y-3 text-sm text-gray-700`,children:[(0,H.jsxs)(`div`,{children:[t(`marketplaceMcpDoctorAccessible`),`: `,e.result.accessible?t(`statusReady`):t(`marketplaceOperationFailed`)]}),(0,H.jsxs)(`div`,{children:[t(`marketplaceMcpDoctorTransport`),`: `,e.result.transport.toUpperCase()]}),(0,H.jsxs)(`div`,{children:[t(`marketplaceMcpDoctorTools`),`: `,e.result.toolCount]}),e.result.error&&(0,H.jsx)(`div`,{className:`rounded-lg bg-rose-50 px-3 py-2 text-rose-600`,children:e.result.error})]})]})})}function X(){let[e,n]=(0,j.useState)(`catalog`),[r,a]=(0,j.useState)(``),[o,s]=(0,j.useState)(``),[c,l]=(0,j.useState)(`relevance`),[u,d]=(0,j.useState)(null),[f,h]=(0,j.useState)(null),[x,S]=(0,j.useState)(null),{language:C}=re(),T=b(),{confirm:E,ConfirmDialog:D}=ae(),A=(0,j.useMemo)(()=>p(C),[C]);(0,j.useEffect)(()=>{let e=window.setTimeout(()=>{s(r.trim())},250);return()=>window.clearTimeout(e)},[r]);let M=R({q:o||void 0,sort:c,pageSize:U}),N=z(),F=g({disabled:e!==`catalog`||M.isError||!M.hasNextPage||M.isFetchingNextPage,onLoadMore:()=>M.fetchNextPage(),watchValue:`${e}:${o}:${c}:${M.data?.loadedItems??0}:${M.data?.loadedPages??0}`});(0,j.useEffect)(()=>{let e=F.containerRef.current;e&&typeof e.scrollTo==`function`&&e.scrollTo({top:0})},[F.containerRef,o,e,c]);let I=B(),W=V(),X=_({mutationFn:L,onSuccess:(e,t)=>{h(t),S(e)}}),le=(0,j.useMemo)(()=>G(N.data?.records??[]),[N.data?.records]),Z=(0,j.useMemo)(()=>(N.data?.records??[]).filter(e=>{let t=[e.id??``,e.label??``,e.catalogSlug??``,e.description??``,e.descriptionZh??``].join(` `).toLowerCase();return o?t.includes(o.toLowerCase()):!0}),[N.data?.records,o]),ue=async(e,n)=>{let r=e?.name??n?.label??n?.id??`MCP`,i=J(A,e,n);if(!e){let e=q(r,JSON.stringify(n??{},null,2),t(`marketplaceInstalledLocalSummary`),n?.docsUrl,i);T.open(e,{newTab:!0,title:r,kind:`content`});return}try{let t=await P(e.slug),n=q(r,t.metadataRaw||JSON.stringify(e,null,2),t.bodyRaw||t.raw,t.sourceUrl,i);T.open(n,{newTab:!0,title:r,kind:`content`})}catch(e){let t=q(r,JSON.stringify({error:e instanceof Error?e.message:String(e)},null,2),i,void 0,i);T.open(t,{newTab:!0,title:r,kind:`content`})}},de=async e=>{u&&(await I.mutateAsync({spec:u.slug,name:e.name.trim(),allAgents:e.allAgents,inputs:e.inputs}),d(null))},Q=async(e,n)=>{let r=n.id||n.spec;r&&(e===`remove`&&!await E({title:`${t(`marketplaceMcpRemoveTitle`)} ${r}?`,description:t(`marketplaceMcpRemoveDescription`),confirmLabel:t(`marketplaceMcpRemove`),variant:`destructive`})||await W.mutateAsync({action:e,id:r,spec:n.spec}))},$=(e,n)=>{let r=n??(e?K(e,le):void 0),i=e?.name??n?.label??n?.id??`MCP`,a=J(A,e,n),o=se(e,n),s=r?r.enabled===!1?t(`marketplaceDisable`):t(`statusReady`):null;return(0,H.jsx)(`article`,{onClick:()=>void ue(e,n),className:`cursor-pointer rounded-2xl border border-gray-200/70 bg-white p-4 shadow-sm transition hover:border-blue-300 hover:shadow-md`,children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:i}),(0,H.jsx)(`div`,{className:`mt-1 text-xs text-gray-500`,children:o}),(0,H.jsx)(`div`,{className:`mt-2 line-clamp-2 text-sm text-gray-600`,children:a}),(0,H.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(e?.tags??[]).map(e=>(0,H.jsx)(`span`,{className:`rounded-full bg-slate-100 px-2 py-0.5 text-[11px] text-slate-600`,children:e},e)),s&&(0,H.jsx)(`span`,{className:`rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] text-emerald-700`,children:s})]})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2`,children:[!r&&e&&(0,H.jsx)(`button`,{className:`rounded-xl bg-primary px-3 py-1.5 text-xs font-medium text-white`,onClick:t=>{t.stopPropagation(),d(e)},children:t(`marketplaceInstall`)}),r&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{className:`rounded-xl border border-gray-200 px-3 py-1.5 text-xs font-medium text-gray-700`,onClick:e=>{e.stopPropagation(),Q(r.enabled===!1?`enable`:`disable`,r)},children:r.enabled===!1?t(`marketplaceEnable`):t(`marketplaceDisable`)}),(0,H.jsx)(`button`,{className:`rounded-xl border border-blue-200 px-3 py-1.5 text-xs font-medium text-blue-700`,onClick:e=>{e.stopPropagation(),h(r.id??null),S(null),X.mutateAsync(r.id??``)},children:t(`marketplaceMcpDoctor`)}),(0,H.jsx)(`button`,{className:`rounded-xl border border-rose-200 px-3 py-1.5 text-xs font-medium text-rose-600`,onClick:e=>{e.stopPropagation(),Q(`remove`,r)},children:t(`marketplaceMcpRemove`)})]})]})]})},`${e?.id??n?.id??n?.spec}`)};return(0,H.jsxs)(O,{className:`flex h-full min-h-0 flex-col pb-0`,children:[(0,H.jsx)(ie,{title:t(`marketplaceMcpPageTitle`),description:t(`marketplaceMcpPageDescription`)}),(0,H.jsx)(oe,{tabs:[{id:`catalog`,label:t(`marketplaceMcpTabCatalog`)},{id:`installed`,label:t(`marketplaceMcpTabInstalled`),count:N.data?.total??0}],activeTab:e,onChange:e=>n(e),className:`mb-4`}),(0,H.jsxs)(`div`,{className:`mb-4 flex flex-col gap-3 md:flex-row md:items-center md:justify-between`,children:[(0,H.jsx)(w,{value:r,onChange:e=>a(e.target.value),placeholder:t(`marketplaceMcpSearchPlaceholder`),className:`md:max-w-sm`}),(0,H.jsxs)(ne,{value:c,onValueChange:e=>l(e),children:[(0,H.jsx)(v,{className:`h-9 w-[180px] rounded-lg`,children:(0,H.jsx)(ee,{})}),(0,H.jsxs)(te,{children:[(0,H.jsx)(y,{value:`relevance`,children:t(`marketplaceSortRelevance`)}),(0,H.jsx)(y,{value:`updated`,children:t(`marketplaceSortUpdated`)})]})]})]}),(0,H.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,H.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900`,children:t(e===`catalog`?`marketplaceMcpSectionCatalog`:`marketplaceMcpSectionInstalled`)}),(0,H.jsx)(`span`,{className:`text-xs text-gray-500`,children:e===`catalog`?M.data?.total??0:N.data?.total??0})]}),(0,H.jsxs)(`div`,{ref:F.containerRef,className:`min-h-0 flex-1 overflow-y-auto pr-1`,"aria-busy":M.isLoading||M.isFetchingNextPage,children:[(0,H.jsxs)(`div`,{className:i(`grid grid-cols-1 gap-3 lg:grid-cols-2 2xl:grid-cols-3`),children:[e===`catalog`&&M.isLoading&&Array.from({length:6},(e,t)=>(0,H.jsxs)(`div`,{className:`rounded-2xl border border-gray-200/70 bg-white p-4 shadow-sm`,children:[(0,H.jsx)(k,{className:`h-4 w-32`}),(0,H.jsx)(k,{className:`mt-2 h-3 w-20`}),(0,H.jsx)(k,{className:`mt-3 h-3 w-full`}),(0,H.jsx)(k,{className:`mt-2 h-3 w-2/3`})]},t)),e===`catalog`&&!M.isLoading&&(M.data?.items??[]).map(e=>$(e)),e===`installed`&&Z.map(e=>$(void 0,e))]}),e===`catalog`&&M.isError&&(0,H.jsx)(`div`,{className:`rounded-xl border border-rose-200 bg-rose-50 p-4 text-sm text-rose-700`,children:M.error.message}),e===`installed`&&N.isError&&(0,H.jsx)(`div`,{className:`rounded-xl border border-rose-200 bg-rose-50 p-4 text-sm text-rose-700`,children:N.error.message}),e===`catalog`&&!M.isLoading&&(M.data?.items?.length??0)===0&&(0,H.jsx)(`div`,{className:`py-8 text-center text-sm text-gray-500`,children:t(`marketplaceNoMcp`)}),e===`installed`&&Z.length===0&&(0,H.jsx)(`div`,{className:`py-8 text-center text-sm text-gray-500`,children:t(`marketplaceNoInstalledMcp`)}),e===`catalog`&&!M.isError&&(0,H.jsx)(m,{hasMore:!!M.hasNextPage,loading:M.isFetchingNextPage,sentinelRef:F.sentinelRef})]})]}),(0,H.jsx)(ce,{item:u,open:!!u,pending:I.isPending,onOpenChange:e=>!e&&d(null),onSubmit:de}),(0,H.jsx)(Y,{open:!!f,targetName:f,result:x,pending:X.isPending,onOpenChange:e=>!e&&h(null)}),(0,H.jsx)(D,{})]})}export{X as McpMarketplacePage};
@@ -1 +0,0 @@
1
- import{_ as e,i as t,m as n,p as r}from"./i18n-eDHeDY0n.js";import{r as i}from"./dist-ccBFUi-o.js";import{t as a}from"./book-open-BdcxxoQu.js";import{a as o,n as s,t as c}from"./ProviderScopedModelInput-Da7khnBA.js";import{t as l}from"./loader-circle-ACM1s51e.js";import{t as u}from"./DocBrowserContext-B6SpA7Qs.js";import{G as d,O as f,d as p,dt as m,l as h,nt as g,tt as _,u as v}from"./index-CF9xve0E.js";import{n as y,t as b}from"./page-layout-vZnghcFy.js";import{t as x}from"./skeleton-ByQepn0M.js";import{t as S}from"./config-hints-BhTmc9P1.js";var C=e(n(),1),w=r(),T=`provider/model`;function E(){let{data:e,isLoading:n}=h(),{data:r}=v(),{data:E}=p(),D=f(),[O,k]=(0,C.useState)(``),[A,j]=(0,C.useState)(``),M=E?.uiHints,N=S(`agents.defaults.model`,M),P=S(`agents.defaults.workspace`,M),F=(0,C.useMemo)(()=>s({meta:r,config:e,onlyConfigured:!0}),[e,r]);(0,C.useEffect)(()=>{e?.agents?.defaults&&(k((e.agents.defaults.model||``).trim()),j(e.agents.defaults.workspace||``))},[e]);let I=t(`modelIdentifierHelp`)||N?.help||``;return n?(0,w.jsxs)(`div`,{className:`max-w-2xl space-y-6`,children:[(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(x,{className:`h-8 w-32`}),(0,w.jsx)(x,{className:`h-4 w-48`})]}),(0,w.jsxs)(d,{className:`rounded-2xl border-gray-200 p-6`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-4 mb-6`,children:[(0,w.jsx)(x,{className:`h-12 w-12 rounded-xl`}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(x,{className:`h-5 w-24`}),(0,w.jsx)(x,{className:`h-3 w-32`})]})]}),(0,w.jsx)(x,{className:`h-4 w-20 mb-2`}),(0,w.jsx)(x,{className:`h-10 w-full rounded-xl`})]}),(0,w.jsxs)(d,{className:`rounded-2xl border-gray-200 p-6`,children:[(0,w.jsx)(x,{className:`h-5 w-24 mb-2`}),(0,w.jsx)(x,{className:`h-10 w-full rounded-xl`})]})]}):(0,w.jsxs)(y,{children:[(0,w.jsx)(b,{title:t(`modelPageTitle`),description:t(`modelPageDescription`)}),(0,w.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),D.mutate({model:O,workspace:A})},className:`space-y-8`,children:[(0,w.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-8`,children:[(0,w.jsxs)(`div`,{className:`p-8 rounded-2xl bg-white border border-gray-200 shadow-card`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-4 mb-8`,children:[(0,w.jsx)(`div`,{className:`h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white`,children:(0,w.jsx)(m,{className:`h-5 w-5`})}),(0,w.jsx)(`h3`,{className:`text-lg font-bold text-gray-900`,children:t(`defaultModel`)})]}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(_,{htmlFor:`model`,className:`text-xs font-semibold text-gray-500 uppercase tracking-wider`,children:N?.label??`Model Name`}),(0,w.jsx)(c,{id:`model`,value:O,onChange:k,providerCatalog:F,modelPlaceholder:N?.placeholder??T}),(0,w.jsx)(`p`,{className:`text-xs text-gray-400`,children:I}),(0,w.jsxs)(`a`,{href:`${u}/guide/model-selection`,className:`inline-flex items-center gap-1.5 text-xs text-primary hover:text-primary-hover transition-colors`,children:[(0,w.jsx)(a,{className:`h-3.5 w-3.5`}),t(`channelsGuideTitle`)]})]})]}),(0,w.jsxs)(`div`,{className:`p-8 rounded-2xl bg-white border border-gray-200 shadow-card`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-4 mb-8`,children:[(0,w.jsx)(`div`,{className:`h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white`,children:(0,w.jsx)(o,{className:`h-5 w-5`})}),(0,w.jsx)(`h3`,{className:`text-lg font-bold text-gray-900`,children:t(`workspace`)})]}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(_,{htmlFor:`workspace`,className:`text-xs font-semibold text-gray-500 uppercase tracking-wider`,children:P?.label??`Default Path`}),(0,w.jsx)(g,{id:`workspace`,value:A,onChange:e=>j(e.target.value),placeholder:P?.placeholder??`/path/to/workspace`,className:`rounded-xl`})]})]})]}),(0,w.jsx)(`div`,{className:`flex justify-end pt-4`,children:(0,w.jsx)(i,{type:`submit`,disabled:D.isPending,size:`lg`,children:D.isPending?(0,w.jsx)(l,{className:`h-5 w-5 animate-spin`}):t(`saveChanges`)})})]})]})}export{E as ModelConfig};
@@ -1 +0,0 @@
1
- import{_ as e,i as t,m as n,p as r,u as i}from"./i18n-eDHeDY0n.js";import{a,i as o,k as s,n as c,r as l,t as u}from"./select-DJ2MUjBB.js";import{t as d}from"./createLucideIcon-BSeTgkZW.js";import{nt as f}from"./index-CF9xve0E.js";var p=d(`ChevronsUpDown`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),m=d(`Folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),h=e(n(),1),g=r();function _(e){let t=new Set;for(let n of e){let e=n.trim();e.length>0&&t.add(e)}return[...t]}function v({id:e,value:t,onChange:n,options:r,disabled:a=!1,placeholder:o,className:c,inputClassName:l,emptyText:u,createText:d,maxItems:m=1/0,onEnter:v}){let[y,b]=(0,h.useState)(!1);(0,h.useEffect)(()=>{a&&y&&b(!1)},[a,y]);let x=(0,h.useMemo)(()=>_(r),[r]),S=t.trim().toLowerCase(),C=(0,h.useMemo)(()=>{let e=x.map((e,t)=>({option:e,index:t}));S.length>0&&e.sort((e,t)=>{let n=e.option.toLowerCase(),r=t.option.toLowerCase(),i=n===S?0:n.startsWith(S)?1:n.includes(S)?2:3,a=r===S?0:r.startsWith(S)?1:r.includes(S)?2:3;return i===a?e.index-t.index:i-a});let t=e.map(e=>e.option);return Number.isFinite(m)?t.slice(0,Math.max(1,m)):t},[x,S,m]),w=t.trim().length>0&&x.some(e=>e===t.trim());return(0,g.jsxs)(`div`,{className:i(`relative`,c),onBlur:()=>{setTimeout(()=>b(!1),120)},children:[(0,g.jsx)(f,{id:e,value:t,disabled:a,onFocus:()=>{a||b(!0)},onChange:e=>{n(e.target.value),!y&&!a&&b(!0)},onKeyDown:e=>{e.key===`Enter`&&(v&&(e.preventDefault(),v()),b(!1))},placeholder:o,className:i(`pr-10`,l)}),(0,g.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>b(e=>!e),disabled:a,className:i(`absolute inset-y-0 right-0 inline-flex w-10 items-center justify-center`,a?`cursor-not-allowed text-gray-300`:`text-gray-400 hover:text-gray-600`),"aria-label":`toggle model options`,children:(0,g.jsx)(p,{className:`h-4 w-4`})}),y&&!a&&(0,g.jsx)(`div`,{className:`absolute z-20 mt-1 w-full overflow-hidden rounded-xl border border-gray-200 bg-white shadow-lg`,children:(0,g.jsxs)(`div`,{className:`max-h-60 overflow-y-auto py-1`,children:[!w&&t.trim().length>0&&(0,g.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{n(t.trim()),b(!1)},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50`,children:[(0,g.jsx)(s,{className:`h-4 w-4 text-transparent`}),(0,g.jsx)(`span`,{className:`truncate text-gray-700`,children:d?d.replace(`{value}`,t.trim()):t.trim()})]}),C.map(e=>(0,g.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{n(e),b(!1)},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50`,children:[(0,g.jsx)(s,{className:i(`h-4 w-4`,e===t.trim()?`text-primary`:`text-transparent`)}),(0,g.jsx)(`span`,{className:`truncate text-gray-700`,children:e})]},e)),C.length===0&&t.trim().length===0&&(0,g.jsx)(`div`,{className:`px-3 py-2 text-sm text-gray-500`,children:u??`No models available`})]})})]})}var y=new Set([`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`]);function b(e){if(!e||e.length===0)return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function x(e,t){let n=e.trim(),r=t.trim();if(!n||!r)return n;let i=`${r}/`;return n.startsWith(i)?n.slice(i.length):n}function S(e,t){let n=e.trim();if(!n)return``;for(let e of t)n=x(n,e);return n.trim()}function C(e,t){let n=t.trim(),r=e.trim();return n?r?`${r}/${n}`:n:``}function w(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t&&y.has(t)?t:null}function T(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=w(n);!e||t.includes(e)||t.push(e)}return t}function E(e,t){if(!e)return{};let n={};for(let[r,i]of Object.entries(e)){let e=S(r,t);if(!e)continue;let a=T(i?.supported);if(a.length===0)continue;let o=w(i?.default);n[e]=o&&a.includes(o)?{supported:a,default:o}:{supported:a}}return n}function D(e,t,n){let r=S(t,n);return r?e[r]??null:null}function O(e,t){let n=e.trim();if(!n)return null;let r=null;for(let e of t)for(let t of e.aliases){let i=t.trim();i&&(n===i||n.startsWith(`${i}/`))&&(!r||i.length>r.score)&&(r={name:e.name,score:i.length})}if(r)return r.name;for(let e of t){let t=S(n,e.aliases);if(t&&b(e.models??[]).some(e=>e===t))return e.name}return null}function k(e){return e?e.enabled!==!1&&e.apiKeySet===!0:!1}function A(e){let{meta:t,config:n,onlyConfigured:r=!1}=e,i=(t?.providers??[]).map(e=>{let t=n?.providers?.[e.name],r=(e.modelPrefix||e.name||``).trim(),i=b([e.modelPrefix||``,e.name||``]),a=b((e.defaultModels??[]).map(e=>S(e,i))),o=b((t?.models??[]).map(e=>S(e,i))),s=b([...a,...o]),c=E(t?.modelThinking,i),l=t?.displayName?.trim(),u=k(t);return{name:e.name,displayName:l||e.displayName||e.name,prefix:r,aliases:i,models:s,modelThinking:c,configured:u}});return r?i.filter(e=>e.configured&&e.models.length>0):i}var j=`provider/model`;function M(e){let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function N({id:e,value:n,onChange:r,providerCatalog:i,disabled:s=!1,providerPlaceholder:d,modelPlaceholder:p,className:m}){let[_,y]=(0,h.useState)(``),[b,x]=(0,h.useState)(``),w=i.length>0,T=p??j,E=(0,h.useMemo)(()=>new Map(i.map(e=>[e.name,e])),[i]),D=E.get(_),k=(0,h.useMemo)(()=>D?.aliases??[],[D]),A=(0,h.useMemo)(()=>M(D?.models??[]),[D]);return(0,h.useEffect)(()=>{let e=n.trim();if(!w){y(``),x(e);return}if(!e){x(``),y(e=>E.has(e)?e:``);return}let t=O(e,i)??``,r=E.get(t)?.aliases??[];y(t),x(t?S(e,r):e)},[w,i,E,n]),w?(0,g.jsxs)(`div`,{className:m,children:[(0,g.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,g.jsx)(`div`,{className:`sm:w-[38%] sm:min-w-[170px]`,children:(0,g.jsxs)(u,{value:_,onValueChange:e=>{let t=M(E.get(e)?.models??[])[0]??``;if(y(e),x(t),!t){r(``);return}r(C(E.get(e)?.prefix??e,t))},disabled:s,children:[(0,g.jsx)(o,{className:`h-10 w-full rounded-xl`,children:(0,g.jsx)(a,{placeholder:d??t(`providersSelectPlaceholder`)})}),(0,g.jsx)(c,{children:i.map(e=>(0,g.jsx)(l,{value:e.name,children:e.displayName},e.name))})]})}),(0,g.jsx)(`span`,{className:`hidden h-10 items-center justify-center leading-none text-lg font-semibold text-gray-300 sm:inline-flex`,children:`/`}),(0,g.jsx)(v,{id:e,value:b,onChange:e=>{if(!D){let t=e.trim();x(t),r(t);return}let t=S(e,k);x(t),r(t?C(D.prefix,t):``)},options:A,disabled:s||!_,placeholder:T,className:`sm:flex-1`,inputClassName:`h-10 rounded-xl`,emptyText:t(`modelPickerNoOptions`),createText:t(`modelPickerUseCustom`)},_)]}),(0,g.jsx)(`p`,{className:`mt-2 text-xs text-gray-500`,children:t(`modelInputCustomHint`)})]}):(0,g.jsxs)(`div`,{className:m,children:[(0,g.jsxs)(`div`,{className:`rounded-2xl border border-amber-200 bg-amber-50/70 px-4 py-3`,children:[(0,g.jsx)(`p`,{className:`text-sm font-semibold text-amber-950`,children:t(`providersEmptyTitle`)}),(0,g.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-amber-900`,children:t(`providersEmptyDescription`)})]}),(0,g.jsx)(f,{id:e,value:n,disabled:s,onChange:e=>r(e.target.value),placeholder:T,className:`mt-3 h-10 rounded-xl`}),(0,g.jsx)(`p`,{className:`mt-2 text-xs text-gray-500`,children:t(`modelInputCustomHint`)})]})}export{m as a,D as i,A as n,C as r,N as t};
@@ -1 +0,0 @@
1
- import{_ as e,i as t,m as n,o as r,p as i,u as a}from"./i18n-eDHeDY0n.js";import{n as o,r as s}from"./dist-ccBFUi-o.js";import{s as c}from"./client-_i4MU2bB.js";import{O as l,a as u,i as d,n as f,r as p,t as m}from"./select-DJ2MUjBB.js";import{t as h}from"./createLucideIcon-BSeTgkZW.js";import{t as g}from"./plus-rYsv72JG.js";import{t as _}from"./search-3kFR_zh9.js";import{t as v}from"./trash-2-G48scll7.js";import{t as y}from"./x-ByDbItbq.js";import{A as b,S as x,T as ee,_t as te,d as ne,f as re,g as ie,l as ae,nt as S,tt as C,u as oe,v as se,w as ce}from"./index-CF9xve0E.js";import{n as w,r as le,t as T}from"./popover-Bg1VoTZ6.js";import{t as ue}from"./LogoBadge-ByNLYg65.js";import{n as E,t as de}from"./page-layout-vZnghcFy.js";import{t as D}from"./tabs-custom-D3HYMt6k.js";import{t as O}from"./status-dot-vbanNPFU.js";import{t as k}from"./config-hints-BhTmc9P1.js";import{i as A,n as fe,r as j,t as pe}from"./config-layout-CHs0mAaR.js";import{t as me}from"./switch-BsLtHOH-.js";var he=h(`CircleDotDashed`,[[`path`,{d:`M10.1 2.18a9.93 9.93 0 0 1 3.8 0`,key:`1qdqn0`}],[`path`,{d:`M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7`,key:`1bq7p6`}],[`path`,{d:`M21.82 10.1a9.93 9.93 0 0 1 0 3.8`,key:`1rlaqf`}],[`path`,{d:`M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69`,key:`1xk03u`}],[`path`,{d:`M13.9 21.82a9.94 9.94 0 0 1-3.8 0`,key:`l7re25`}],[`path`,{d:`M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7`,key:`1v18p6`}],[`path`,{d:`M2.18 13.9a9.93 9.93 0 0 1 0-3.8`,key:`xdo6bj`}],[`path`,{d:`M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69`,key:`1jjmaz`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),M=h(`EyeOff`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),N=h(`Eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),ge=h(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),P=e(n(),1),F=i();function _e({isSet:e,className:t,value:n,onChange:r,placeholder:i,...o}){let[c,l]=(0,P.useState)(!1),[u,d]=(0,P.useState)(!1),f=typeof n==`string`&&n.length>0;return(0,F.jsxs)(`div`,{className:`relative`,children:[e&&!f&&!u?(0,F.jsx)(`div`,{onClick:()=>d(!0),className:a(`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`,t),children:`••••••••••••`}):(0,F.jsx)(S,{type:c?`text`:`password`,className:a(`pr-12`,t),value:n,onChange:r,onBlur:()=>{f||d(!1)},placeholder:i,autoFocus:u,...o}),(0,F.jsx)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex gap-1`,children:(e||f)&&(0,F.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>l(!c),children:c?(0,F.jsx)(M,{className:`h-4 w-4`}):(0,F.jsx)(N,{className:`h-4 w-4`})})})]})}function ve({value:e,onChange:n,className:r}){let i=e?Object.entries(e):[],o=(e,t,r)=>{let a=[...i];a[e]=[t,r],n(Object.fromEntries(a))},c=()=>{n({...e,"":``})},l=e=>{let t=i.filter((t,n)=>n!==e);n(Object.fromEntries(t))};return(0,F.jsxs)(`div`,{className:a(`space-y-2`,r),children:[i.map(([e,n],r)=>(0,F.jsxs)(`div`,{className:`flex gap-2`,children:[(0,F.jsx)(S,{type:`text`,value:e,onChange:e=>o(r,e.target.value,n),placeholder:t(`headerName`),className:`flex-1`}),(0,F.jsx)(S,{type:`text`,value:n,onChange:t=>o(r,e,t.target.value),placeholder:t(`headerValue`),className:`flex-1`}),(0,F.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>l(r),children:(0,F.jsx)(v,{className:`h-4 w-4 text-red-500`})})]},r)),(0,F.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:c,children:[(0,F.jsx)(g,{className:`h-4 w-4 mr-2`}),t(`add`)]})]})}function ye(e){let{value:t,onChange:n,options:r}=e;return(0,F.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let r=e.value===t;return(0,F.jsx)(`button`,{type:`button`,onClick:()=>n(e.value),"aria-pressed":r,className:`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${r?`border-primary bg-primary text-white shadow-sm`:`border-gray-200 bg-white text-gray-700 hover:border-primary/40 hover:text-primary`}`,children:e.label},e.value)})})}function be(e){let{showAdvanced:n,onShowAdvancedChange:r,supportsWireApi:i,wireApiLabel:a,wireApi:o,onWireApiChange:s,shouldUseWireApiPills:c,wireApiSelectOptions:h,extraHeadersLabel:g,extraHeaders:_,onExtraHeadersChange:v}=e;return(0,F.jsxs)(`div`,{className:`border-t border-gray-100 pt-4`,children:[(0,F.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:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(ge,{className:`h-3.5 w-3.5`}),t(`providerAdvancedSettings`)]}),(0,F.jsx)(l,{className:`h-4 w-4 transition-transform ${n?`rotate-180`:``}`})]}),n?(0,F.jsxs)(`div`,{className:`mt-4 space-y-5`,children:[i?(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(C,{htmlFor:`wireApi`,className:`text-sm font-medium text-gray-900`,children:a}),c?(0,F.jsx)(ye,{value:o,onChange:e=>s(e),options:h}):(0,F.jsxs)(m,{value:o,onValueChange:e=>s(e),children:[(0,F.jsx)(d,{className:`rounded-xl`,children:(0,F.jsx)(u,{})}),(0,F.jsx)(f,{children:h.map(e=>(0,F.jsx)(p,{value:e.value,children:e.label},e.value))})]})]}):null,(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(C,{className:`text-sm font-medium text-gray-900`,children:g}),(0,F.jsx)(ve,{value:_,onChange:v}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerExtraHeadersHelpShort`)})]})]}):null]})}function xe(e){let{providerAuth:n,providerAuthNote:r,providerAuthMethodOptions:i,providerAuthMethodsCount:a,selectedAuthMethodHint:o,shouldUseAuthMethodPills:c,resolvedAuthMethodId:l,onAuthMethodChange:h,onStartProviderAuth:g,onImportProviderAuthFromCli:_,startPending:v,importPending:y,authSessionId:b,authStatusMessage:x}=e;return n?.kind===`device_code`?(0,F.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3`,children:[(0,F.jsx)(C,{className:`text-sm font-medium text-gray-900`,children:n.displayName||t(`providerAuthSectionTitle`)}),r?(0,F.jsx)(`p`,{className:`text-xs text-gray-600`,children:r}):null,a>1?(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(C,{className:`text-xs font-medium text-gray-700`,children:t(`providerAuthMethodLabel`)}),c?(0,F.jsx)(ye,{value:l,onChange:h,options:i}):(0,F.jsxs)(m,{value:l,onValueChange:h,children:[(0,F.jsx)(d,{className:`h-8 rounded-lg bg-white`,children:(0,F.jsx)(u,{placeholder:t(`providerAuthMethodPlaceholder`)})}),(0,F.jsx)(f,{children:i.map(e=>(0,F.jsx)(p,{value:e.value,children:e.label},e.value))})]}),o?(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:o}):null]}):null,(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:g,disabled:v||!!b,children:t(v?`providerAuthStarting`:b?`providerAuthAuthorizing`:`providerAuthAuthorizeInBrowser`)}),n.supportsCliImport?(0,F.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:_,disabled:y,children:t(y?`providerAuthImporting`:`providerAuthImportFromCli`)}):null,b?(0,F.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[t(`providerAuthSessionLabel`),`: `,b.slice(0,8),`…`]}):null]}),x?(0,F.jsx)(`p`,{className:`text-xs text-gray-600`,children:x}):null]}):null}function Se(e){return(0,F.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl border border-gray-200 bg-gray-50 px-4 py-3`,children:[(0,F.jsx)(C,{className:`text-sm font-medium text-gray-900`,children:t(`enabled`)}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`span`,{className:`text-xs text-gray-500`,children:e.enabled?t(`enabled`):t(`disabled`)}),(0,F.jsx)(me,{checked:e.enabled,onCheckedChange:e.onChange})]})]})}var Ce={enabled:!0,displayName:``,apiKeySet:!1,apiKeyMasked:void 0,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelThinking:{}},we=[`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`],Te=new Set(we);function Ee(e){if(!e)return null;let t=Object.entries(e).map(([e,t])=>[e.trim(),t]).filter(([e])=>e.length>0);return t.length===0?null:Object.fromEntries(t)}function De(e,t){let n=Ee(e),r=Ee(t);if(n===null&&r===null)return!0;if(!n||!r)return!1;let i=Object.entries(n).sort(([e],[t])=>e.localeCompare(t)),a=Object.entries(r).sort(([e],[t])=>e.localeCompare(t));return i.length===a.length?i.every(([e,t],n)=>e===a[n][0]&&t===a[n][1]):!1}function Oe(e){if(!e||e.length===0)return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function ke(e,t){let n=e.trim();if(!n||!t.trim())return n;let r=`${t.trim()}/`;return n.startsWith(r)?n.slice(r.length):n}function I(e,t){let n=e.trim();if(!n)return``;for(let e of t){let t=e.trim();t&&(n=ke(n,t))}return n.trim()}function Ae(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function je(e,t){let n=[...e];for(let e of t)n.includes(e)||n.push(e);return n}function Me(e,t){return t.length===0?e:t.every(t=>!e.includes(t))?je(e,t):t}function Ne(e,t){return Ae(e,t)?[]:e}function Pe(e,t,n){t!==n&&(e.enabled=t)}function L(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t&&Te.has(t)?t:null}function Fe(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=L(n);!e||t.includes(e)||t.push(e)}return t}function Ie(e,t){if(!e)return{};let n={};for(let[r,i]of Object.entries(e)){let e=I(r,t);if(!e)continue;let a=Fe(i?.supported);if(a.length===0)continue;let o=L(i?.default);n[e]=o&&a.includes(o)?{supported:a,default:o}:{supported:a}}return n}function Le(e,t){let n=new Set(t.map(e=>e.trim()).filter(Boolean)),r={};for(let[t,i]of Object.entries(e)){if(!n.has(t))continue;let e=Fe(i.supported);if(e.length===0)continue;let a=L(i.default);r[t]=a&&e.includes(a)?{supported:e,default:a}:{supported:e}}return r}function Re(e,t){let n=Object.keys(e).sort(),r=Object.keys(t).sort();if(n.length!==r.length)return!1;for(let i=0;i<n.length;i+=1){let a=n[i];if(a!==r[i])return!1;let o=e[a],s=t[a];if(!o||!s||!Ae([...o.supported].sort(),[...s.supported].sort())||(o.default??null)!==(s.default??null))return!1}return!0}function ze(e){return t(e===`off`?`chatThinkingLevelOff`:e===`minimal`?`chatThinkingLevelMinimal`:e===`low`?`chatThinkingLevelLow`:e===`medium`?`chatThinkingLevelMedium`:e===`high`?`chatThinkingLevelHigh`:e===`adaptive`?`chatThinkingLevelAdaptive`:`chatThinkingLevelXhigh`)}function Be(e){let{providerName:t,methods:n,defaultMethodId:r,language:i}=e;if(n.length===0)return``;let a=new Map;for(let e of n){let t=e.id.trim();t&&a.set(t.toLowerCase(),t)}let o=(...e)=>{for(let t of e){let e=a.get(t.toLowerCase());if(e)return e}},s=r?.trim();if(t===`minimax-portal`){if(i===`zh`)return o(`cn`,`china-mainland`)??o(s??``)??n[0]?.id??``;if(i===`en`)return o(`global`,`intl`,`international`)??o(s??``)??n[0]?.id??``}if(s){let e=o(s);if(e)return e}return i===`zh`?o(`cn`)??n[0]?.id??``:i===`en`?o(`global`)??n[0]?.id??``:n[0]?.id??``}function Ve(e){return e.required&&e.hasDefault&&e.optionCount>1&&e.optionCount<=3}function He(e){let{models:n,modelThinking:r,modelDraft:i,showModelInput:a,onModelDraftChange:o,onShowModelInputChange:c,onAddModel:l,onRemoveModel:h,onToggleModelThinkingLevel:_,onSetModelThinkingDefault:v,thinkingLevels:b,formatThinkingLevelLabel:x}=e;return(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsx)(C,{className:`text-sm font-medium text-gray-900`,children:t(`providerModelsTitle`)}),a?null:(0,F.jsxs)(`button`,{type:`button`,onClick:()=>c(!0),className:`flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80`,children:[(0,F.jsx)(g,{className:`h-3 w-3`}),t(`providerAddModel`)]})]}),a?(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(S,{value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l()),e.key===`Escape`&&(c(!1),o(``))},placeholder:t(`providerModelInputPlaceholder`),className:`flex-1 rounded-xl`,autoFocus:!0}),(0,F.jsx)(s,{type:`button`,size:`sm`,onClick:l,disabled:i.trim().length===0,children:t(`add`)}),(0,F.jsx)(s,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{c(!1),o(``)},children:(0,F.jsx)(y,{className:`h-4 w-4`})})]}):null,n.length===0?(0,F.jsxs)(`div`,{className:`rounded-xl border border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center`,children:[(0,F.jsx)(`p`,{className:`text-sm text-gray-500`,children:t(`providerModelsEmptyShort`)}),a?null:(0,F.jsx)(`button`,{type:`button`,onClick:()=>c(!0),className:`mt-2 text-sm font-medium text-primary hover:text-primary/80`,children:t(`providerAddFirstModel`)})]}):(0,F.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:n.map(e=>{let n=r[e],i=n?.supported??[],a=n?.default??null;return(0,F.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:[(0,F.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-gray-800 sm:max-w-[220px]`,children:e}),(0,F.jsxs)(T,{children:[(0,F.jsx)(le,{asChild:!0,children:(0,F.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":t(`providerModelThinkingTitle`),title:t(`providerModelThinkingTitle`),children:(0,F.jsx)(ge,{className:`h-3 w-3`})})}),(0,F.jsxs)(w,{className:`w-80 space-y-3`,children:[(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsx)(`p`,{className:`text-xs font-semibold text-gray-800`,children:t(`providerModelThinkingTitle`)}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerModelThinkingHint`)})]}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:b.map(t=>(0,F.jsx)(`button`,{type:`button`,onClick:()=>_(e,t),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${i.includes(t)?`border-primary bg-primary text-white`:`border-gray-200 bg-white text-gray-600 hover:border-primary/40 hover:text-primary`}`,children:x(t)},t))}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(C,{className:`text-xs font-medium text-gray-700`,children:t(`providerModelThinkingDefault`)}),(0,F.jsxs)(m,{value:a??`__none__`,onValueChange:t=>v(e,t===`__none__`?null:t),disabled:i.length===0,children:[(0,F.jsx)(d,{className:`h-8 rounded-lg bg-white text-xs`,children:(0,F.jsx)(u,{})}),(0,F.jsxs)(f,{children:[(0,F.jsx)(p,{value:`__none__`,children:t(`providerModelThinkingDefaultNone`)}),i.map(e=>(0,F.jsx)(p,{value:e,children:x(e)},e))]})]}),i.length===0?(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerModelThinkingNoSupported`)}):null]})]})]}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>h(e),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":t(`remove`),children:(0,F.jsx)(y,{className:`h-3 w-3`})})]},e)})})]})}function Ue(e){return e.enabled?(0,F.jsx)(O,{status:e.apiKeySet?`ready`:`setup`,label:e.apiKeySet?t(`statusReady`):t(`statusSetup`),className:e.className}):(0,F.jsx)(O,{status:`inactive`,label:t(`disabled`),className:e.className})}function R({providerName:e,onProviderDeleted:n}){let i=c(),{data:a}=ae(),{data:l}=oe(),{data:u}=ne(),d=b(),f=ie(),p=ee(),m=ce(),h=x(),g=se(),[_,y]=(0,P.useState)(``),[te,re]=(0,P.useState)(!0),[w,le]=(0,P.useState)(``),[T,ue]=(0,P.useState)(null),[E,de]=(0,P.useState)(`auto`),[D,O]=(0,P.useState)([]),[A,j]=(0,P.useState)({}),[me,M]=(0,P.useState)(``),[N,ge]=(0,P.useState)(``),[ve,ye]=(0,P.useState)(!1),[Te,ke]=(0,P.useState)(!1),[je,L]=(0,P.useState)(null),[Fe,R]=(0,P.useState)(``),[We,Ge]=(0,P.useState)(``),z=(0,P.useRef)(null),B=l?.providers.find(t=>t.name===e),V=(e?a?.providers[e]:null)??Ce,Ke=u?.uiHints,H=!!B?.isCustom,qe=e?k(`providers.${e}.apiKey`,Ke):void 0,Je=e?k(`providers.${e}.apiBase`,Ke):void 0,Ye=e?k(`providers.${e}.extraHeaders`,Ke):void 0,Xe=e?k(`providers.${e}.wireApi`,Ke):void 0,Ze=B?.displayName||e||``,U=(V.displayName||``).trim()||Ze,W=V.enabled!==!1,Qe=N.trim()||U||e||t(`providersSelectPlaceholder`),$e=B?.modelPrefix||e||``,G=(0,P.useMemo)(()=>Oe([$e,e||``]),[$e,e]),et=B?.defaultApiBase||``,K=V.apiBase||et,tt=Ee(V.extraHeaders||null),q=V.wireApi||B?.defaultWireApi||`auto`,nt=(0,P.useMemo)(()=>Oe((B?.defaultModels??[]).map(e=>I(e,G))),[B?.defaultModels,G]),rt=(0,P.useMemo)(()=>Oe((V.models??[]).map(e=>I(e,G))),[V.models,G]),J=(0,P.useMemo)(()=>Me(nt,rt),[nt,rt]),it=(0,P.useMemo)(()=>Le(Ie(V.modelThinking,G),J),[J,G,V.modelThinking]),Y=r(),at=B?.apiBaseHelp?.[Y]||B?.apiBaseHelp?.en||Je?.help||t(`providerApiBaseHelp`),X=B?.auth,Z=(0,P.useMemo)(()=>X?.methods??[],[X?.methods]),Q=!!B?.supportsWireApi||H,ot=(0,P.useMemo)(()=>Z.map(e=>({value:e.id,label:e.label?.[Y]||e.label?.en||e.id})),[Z,Y]),st=(0,P.useMemo)(()=>Be({providerName:e,methods:Z,defaultMethodId:X?.defaultMethodId,language:Y}),[e,X?.defaultMethodId,Z,Y]),ct=(0,P.useMemo)(()=>{if(!Z.length)return``;let e=We.trim();return e&&Z.some(t=>t.id===e)?e:st||Z[0]?.id||``},[We,st,Z]),lt=(0,P.useMemo)(()=>Z.find(e=>e.id===ct),[Z,ct]),ut=Ve({required:X?.kind===`device_code`,hasDefault:!!X?.defaultMethodId?.trim(),optionCount:Z.length}),dt=(B?.wireApiOptions||[`auto`,`chat`,`responses`]).map(e=>({value:e,label:t(e===`chat`?`wireApiChat`:e===`responses`?`wireApiResponses`:`wireApiAuto`)})),ft=Ve({required:Q,hasDefault:typeof B?.defaultWireApi==`string`&&B.defaultWireApi.length>0,optionCount:dt.length}),$=(0,P.useCallback)(()=>{z.current!==null&&(window.clearTimeout(z.current),z.current=null)},[]),pt=(0,P.useCallback)((n,r)=>{$(),z.current=window.setTimeout(()=>{(async()=>{if(e)try{let a=await h.mutateAsync({provider:e,data:{sessionId:n}});if(a.status===`pending`){R(t(`providerAuthWaitingBrowser`)),pt(n,a.nextPollMs??r);return}if(a.status===`authorized`){L(null),$(),R(t(`providerAuthCompleted`)),o.success(t(`providerAuthCompleted`)),i.invalidateQueries({queryKey:[`config`]}),i.invalidateQueries({queryKey:[`config-meta`]});return}L(null),$(),R(a.message||`Authorization ${a.status}.`),o.error(a.message||`Authorization ${a.status}.`)}catch(e){L(null),$();let t=e instanceof Error?e.message:String(e);R(t),o.error(`Authorization failed: ${t}`)}})()},Math.max(1e3,r))},[$,h,e,i]);(0,P.useEffect)(()=>{if(!e){y(``),re(!0),le(``),ue(null),de(`auto`),O([]),j({}),M(``),ge(``),L(null),R(``),Ge(``),$();return}y(``),re(W),le(K),ue(V.extraHeaders||null),de(q),O(J),j(it),M(``),ge(U),L(null),R(``),Ge(st),$()},[e,K,W,V.extraHeaders,q,J,it,U,st,$]),(0,P.useEffect)(()=>()=>$(),[$]),(0,P.useEffect)(()=>{j(e=>Le(e,D))},[D]);let mt=(0,P.useMemo)(()=>{if(!e)return!1;let t=_.trim().length>0,n=w.trim()!==K.trim(),r=!De(T,tt),i=Q?E!==q:!1,a=!Ae(D,J),o=!Re(A,it),s=H?N.trim()!==U:!1;return t||te!==W||n||r||i||a||o||s},[e,H,N,U,_,te,W,w,K,T,tt,Q,E,q,D,J,A,it]);return!e||!B?(0,F.jsx)(`div`,{className:fe,children:(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-gray-900`,children:t(`providersSelectTitle`)}),(0,F.jsx)(`p`,{className:`mt-2 text-sm text-gray-500`,children:t(`providersSelectDescription`)})]})}):(0,F.jsxs)(`div`,{className:pe,children:[(0,F.jsx)(`div`,{className:`border-b border-gray-100 px-6 py-4`,children:(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`truncate text-lg font-semibold text-gray-900`,children:Qe}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[H&&(0,F.jsx)(`button`,{type:`button`,onClick:async()=>{if(!(!e||!H)&&window.confirm(t(`providerDeleteConfirm`)))try{await f.mutateAsync({provider:e}),n?.(e)}catch{}},disabled:f.isPending,className:`text-gray-400 hover:text-red-500 transition-colors`,title:t(`providerDelete`),children:(0,F.jsx)(v,{className:`h-4 w-4`})}),(0,F.jsx)(Ue,{enabled:W,apiKeySet:V.apiKeySet})]})]})}),(0,F.jsxs)(`form`,{onSubmit:t=>{if(t.preventDefault(),!e)return;let n={},r=_.trim(),i=w.trim(),a=Ee(T),o=N.trim();H&&o!==U&&(n.displayName=o.length>0?o:null),r.length>0&&(n.apiKey=r),Pe(n,te,W),i!==K.trim()&&(n.apiBase=i.length>0&&i!==et?i:null),De(a,tt)||(n.extraHeaders=a),Q&&E!==q&&(n.wireApi=E),Ae(D,J)||(n.models=Ne(D,nt)),Re(A,it)||(n.modelThinking=Le(A,D)),d.mutate({provider:e,data:n})},className:`flex min-h-0 flex-1 flex-col`,children:[(0,F.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5`,children:[(0,F.jsx)(Se,{enabled:te,onChange:re}),H&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(C,{htmlFor:`providerDisplayName`,className:`text-sm font-medium text-gray-900`,children:t(`providerDisplayName`)}),(0,F.jsx)(S,{id:`providerDisplayName`,type:`text`,value:N,onChange:e=>ge(e.target.value),placeholder:Ze||t(`providerDisplayNamePlaceholder`),className:`rounded-xl`}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerDisplayNameHelpShort`)})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(C,{htmlFor:`apiKey`,className:`text-sm font-medium text-gray-900`,children:qe?.label??t(`apiKey`)}),(0,F.jsx)(_e,{id:`apiKey`,value:_,isSet:V.apiKeySet,onChange:e=>y(e.target.value),placeholder:qe?.placeholder??t(`enterApiKey`),className:`rounded-xl`}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`leaveBlankToKeepUnchanged`)})]}),(0,F.jsx)(xe,{providerAuth:X,providerAuthNote:X?.note?.[Y]||X?.note?.en||X?.displayName||``,providerAuthMethodOptions:ot,providerAuthMethodsCount:Z.length,selectedAuthMethodHint:lt?.hint?.[Y]||lt?.hint?.en||``,shouldUseAuthMethodPills:ut,resolvedAuthMethodId:ct,onAuthMethodChange:Ge,onStartProviderAuth:async()=>{if(!(!e||X?.kind!==`device_code`))try{R(``);let n=await m.mutateAsync({provider:e,data:ct?{methodId:ct}:{}});if(!n.sessionId||!n.verificationUri)throw Error(t(`providerAuthStartFailed`));L(n.sessionId),R(`${t(`providerAuthOpenPrompt`)}${n.userCode}${t(`providerAuthOpenPromptSuffix`)}`),window.open(n.verificationUri,`_blank`,`noopener,noreferrer`),pt(n.sessionId,n.intervalMs)}catch(e){let n=e instanceof Error?e.message:String(e);L(null),$(),R(n),o.error(`${t(`providerAuthStartFailed`)}: ${n}`)}},onImportProviderAuthFromCli:async()=>{if(!(!e||X?.kind!==`device_code`))try{$(),L(null);let n=await g.mutateAsync({provider:e}),r=n.expiresAt?` (expires: ${n.expiresAt})`:``;R(`${t(`providerAuthImportStatusPrefix`)}${r}`),o.success(t(`providerAuthImportSuccess`)),i.invalidateQueries({queryKey:[`config`]}),i.invalidateQueries({queryKey:[`config-meta`]})}catch(e){let n=e instanceof Error?e.message:String(e);R(n),o.error(`${t(`providerAuthImportFailed`)}: ${n}`)}},startPending:m.isPending,importPending:g.isPending,authSessionId:je,authStatusMessage:Fe}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(C,{htmlFor:`apiBase`,className:`text-sm font-medium text-gray-900`,children:Je?.label??t(`apiBase`)}),(0,F.jsx)(S,{id:`apiBase`,type:`text`,value:w,onChange:e=>le(e.target.value),placeholder:et||Je?.placeholder||`https://api.example.com`,className:`rounded-xl`}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:at})]}),(0,F.jsx)(He,{models:D,modelThinking:A,modelDraft:me,showModelInput:Te,onModelDraftChange:M,onShowModelInputChange:ke,onAddModel:()=>{let e=I(me,G);if(e){if(D.includes(e)){M(``);return}O(t=>[...t,e]),M(``)}},onRemoveModel:e=>{O(t=>t.filter(t=>t!==e)),j(t=>{let n={...t};return delete n[e],n})},onToggleModelThinkingLevel:(e,t)=>{j(n=>{let r=n[e],i=r?.supported??[],a=i.includes(t)?i.filter(e=>e!==t):we.filter(e=>e===t||i.includes(e));if(a.length===0){let t={...n};return delete t[e],t}let o=r?.default&&a.includes(r.default)?r.default:void 0;return{...n,[e]:o?{supported:a,default:o}:{supported:a}}})},onSetModelThinkingDefault:(e,t)=>{j(n=>{let r=n[e];return!r||r.supported.length===0||t&&!r.supported.includes(t)?n:{...n,[e]:t?{supported:r.supported,default:t}:{supported:r.supported}}})},thinkingLevels:we,formatThinkingLevelLabel:ze}),(0,F.jsx)(be,{showAdvanced:ve,onShowAdvancedChange:ye,supportsWireApi:Q,wireApiLabel:Xe?.label??t(`wireApi`),wireApi:E,onWireApiChange:de,shouldUseWireApiPills:ft,wireApiSelectOptions:dt,extraHeadersLabel:Ye?.label??t(`extraHeaders`),extraHeaders:T,onExtraHeadersChange:ue})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-100 px-6 py-4`,children:[(0,F.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:async()=>{if(!e)return;let n=I(D.find(e=>e.trim().length>0)??``,G),r={apiBase:w.trim(),extraHeaders:Ee(T),model:n||null};_.trim().length>0&&(r.apiKey=_.trim()),Q&&(r.wireApi=E);try{let n=await p.mutateAsync({provider:e,data:r});if(n.success){o.success(`${t(`providerTestConnectionSuccess`)} (${n.latencyMs}ms)`);return}let i=[`provider=${n.provider}`,`latency=${n.latencyMs}ms`];n.model&&i.push(`model=${n.model}`),o.error(`${t(`providerTestConnectionFailed`)}: ${n.message} | ${i.join(` | `)}`)}catch(e){let n=e instanceof Error?e.message:String(e);o.error(`${t(`providerTestConnectionFailed`)}: ${n}`)}},disabled:p.isPending,children:[(0,F.jsx)(he,{className:`mr-1.5 h-4 w-4`}),p.isPending?t(`providerTestingConnection`):t(`providerTestConnection`)]}),(0,F.jsx)(s,{type:`submit`,disabled:d.isPending||!mt,children:d.isPending?t(`saving`):t(mt?`save`:`unchanged`)})]})]})]})}function We(e){if(!e)return null;try{let t=new URL(e),n=t.pathname&&t.pathname!==`/`?t.pathname:``;return`${t.host}${n}`}catch{return e.replace(/^https?:\/\//,``)}}function Ge(e){return e.map((e,t)=>({provider:e,index:t})).sort((e,t)=>{let n=e.provider.name===`nextclaw`?1:0,r=t.provider.name===`nextclaw`?1:0;return n===r?e.index-t.index:n-r}).map(({provider:e})=>e)}function z(){let{data:e}=ae(),{data:n}=oe(),{data:r}=ne(),i=re(),[o,c]=(0,P.useState)(`installed`),[l,u]=(0,P.useState)(),[d,f]=(0,P.useState)(``),p=r?.uiHints,m=(0,P.useMemo)(()=>Ge(n?.providers??[]),[n?.providers]),h=e?.providers??{},v=m.filter(e=>{let t=h[e.name];return t?.enabled!==!1&&t?.apiKeySet}).length,y=[{id:`installed`,label:t(`providersTabConfigured`),count:v},{id:`all`,label:t(`providersTabAll`),count:m.length}],b=(0,P.useMemo)(()=>{let t=m,n=e?.providers??{},r=d.trim().toLowerCase();return t.filter(e=>{if(o===`installed`){let t=n[e.name];return!!(t?.enabled!==!1&&t?.apiKeySet)}return!0}).filter(e=>r?(n[e.name]?.displayName?.trim()||e.displayName||e.name).toLowerCase().includes(r)||e.name.toLowerCase().includes(r):!0)},[m,e,o,d]);(0,P.useEffect)(()=>{if(b.length===0){u(void 0);return}b.some(e=>e.name===l)||u(b[0].name)},[b,l]);let x=l;return!e||!n?(0,F.jsx)(`div`,{className:`p-8`,children:t(`providersLoading`)}):(0,F.jsxs)(E,{children:[(0,F.jsx)(de,{title:t(`providersPageTitle`),description:t(`providersPageDescription`)}),(0,F.jsxs)(`div`,{className:A,children:[(0,F.jsxs)(`section`,{className:j,children:[(0,F.jsxs)(`div`,{className:`border-b border-gray-100 px-4 pt-4 pb-3 space-y-3`,children:[(0,F.jsx)(D,{tabs:y,activeTab:o,onChange:c,className:`mb-0`}),(0,F.jsxs)(s,{type:`button`,variant:`outline`,className:`w-full justify-center`,onClick:async()=>{try{let e=await i.mutateAsync({data:{}});c(`all`),f(``),u(e.name)}catch{}},disabled:i.isPending,children:[(0,F.jsx)(g,{className:`mr-2 h-4 w-4`}),i.isPending?t(`saving`):t(`providerAddCustom`)]})]}),(0,F.jsx)(`div`,{className:`border-b border-gray-100 px-4 py-3`,children:(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(_,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,F.jsx)(S,{value:d,onChange:e=>f(e.target.value),placeholder:t(`providersFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,F.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-3`,children:[b.map(n=>{let r=e.providers[n.name],i=r?.enabled!==!1,o=!!(i&&r?.apiKeySet),s=x===n.name,c=r?.displayName?.trim()||n.displayName||n.name,l=k(`providers.${n.name}`,p),d=We(r?.apiBase||n.defaultApiBase||``)||l?.help||t(`providersDefaultDescription`);return(0,F.jsx)(`button`,{type:`button`,onClick:()=>u(n.name),className:a(`w-full rounded-xl border p-2.5 text-left transition-all`,s?`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:(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,F.jsx)(ue,{name:n.name,src:n.logo?`/logos/${n.logo}`:null,className:a(`h-10 w-10 rounded-lg border`,o?`border-primary/30 bg-white`:`border-gray-200/70 bg-white`),imgClassName:`h-5 w-5 object-contain`,fallback:(0,F.jsx)(`span`,{className:`text-sm font-semibold uppercase text-gray-500`,children:n.name[0]})}),(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:c}),(0,F.jsx)(`p`,{className:`line-clamp-1 text-[11px] text-gray-500`,children:d})]})]}),(0,F.jsx)(O,{status:i?o?`ready`:`setup`:`inactive`,label:t(i?o?`statusReady`:`statusSetup`:`disabled`),className:`min-w-[56px] justify-center`})]})},n.name)}),b.length===0&&(0,F.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:[(0,F.jsx)(`div`,{className:`mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-white`,children:(0,F.jsx)(te,{className:`h-5 w-5 text-gray-300`})}),(0,F.jsx)(`p`,{className:`text-sm font-medium text-gray-700`,children:t(`providersNoMatch`)})]})]})]}),(0,F.jsx)(R,{providerName:x,onProviderDeleted:e=>{e===l&&u(void 0)}})]})]})}export{z as ProvidersList};
@@ -1 +0,0 @@
1
- import{_ as e,i as t,m as n,n as r,p as i}from"./i18n-eDHeDY0n.js";import{r as a}from"./dist-ccBFUi-o.js";import{t as o}from"./createLucideIcon-BSeTgkZW.js";import{t as s}from"./refresh-ccw-DT98i__E.js";import{$ as c,G as l,J as u,K as d,X as f,Y as p,Z as m,et as h,q as g,ut as _}from"./index-CF9xve0E.js";import{n as v,t as y}from"./page-layout-vZnghcFy.js";import{t as b}from"./status-dot-vbanNPFU.js";var x=o(`Laptop`,[[`path`,{d:`M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16`,key:`tarvll`}]]),S=[/invalid or expired token/i,/missing bearer token/i,/token expired/i,/token is invalid/i,/run "nextclaw login"/i,/browser sign-in again/i];function C(e){return e?.runtime?.lastError?.trim()||``}function w(e){let n=t(`remoteStatusIssueDetailGeneric`),r=C(e);return r?`${n} (${r})`:n}function T(e){if(!e?.settings.enabled)return!1;let t=C(e);return S.some(e=>e.test(t))}function E(e){return T(e)?{hero:{badgeStatus:`warning`,badgeLabel:t(`remoteStateReauthorizationRequired`),title:t(`remoteStatusReauthorizationTitle`),description:t(`remoteStatusReauthorizationDescription`)},primaryAction:{kind:`reauthorize`,label:t(`remoteReauthorizeNow`),showRefreshIcon:!1},issueHint:{title:t(`remoteStatusRecoveryTitle`),body:t(`remoteStatusReauthorizationHint`)},shouldShowIssueHint:!0,requiresReauthorization:!0}:e?.account.loggedIn?e.settings.enabled?e.service.running?e.runtime?.state===`connected`?{hero:{badgeStatus:`ready`,badgeLabel:t(`statusReady`),title:t(`remoteStatusReadyTitle`),description:t(`remoteStatusReadyDescription`)},primaryAction:{kind:`repair`,label:t(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:e.runtime?.state===`connecting`?{hero:{badgeStatus:`active`,badgeLabel:t(`connecting`),title:t(`remoteStatusConnectingTitle`),description:t(`remoteStatusConnectingDescription`)},primaryAction:{kind:`repair`,label:t(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:t(`remoteStateDisconnected`),title:t(`remoteStatusIssueTitle`),description:t(`remoteStatusIssueDescription`)},primaryAction:{kind:`repair`,label:t(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:t(`remoteStatusRecoveryTitle`),body:w(e)},shouldShowIssueHint:!!(e.settings.enabled&&e.account.loggedIn),requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:t(`remoteServiceStopped`),title:t(`remoteStatusNeedsServiceTitle`),description:t(`remoteStatusNeedsServiceDescription`)},primaryAction:{kind:`repair`,label:t(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:t(`remoteStatusRecoveryTitle`),body:t(`remoteStatusIssueDetailServiceStopped`)},shouldShowIssueHint:!0,requiresReauthorization:!1}:{hero:{badgeStatus:`inactive`,badgeLabel:t(`statusInactive`),title:t(`remoteStatusNeedsEnable`),description:t(`remoteStatusNeedsEnableDescription`)},primaryAction:{kind:`enable`,label:t(`remoteEnableNow`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`setup`,badgeLabel:t(`statusSetup`),title:t(`remoteStatusNeedsSignIn`),description:t(`remoteStatusNeedsSignInDescription`)},primaryAction:{kind:`sign-in-enable`,label:t(`remoteSignInAndEnable`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}}var D=e(n(),1),O=i();function k(e){let{label:t,muted:n,value:r}=e;return(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,O.jsx)(`span`,{className:`text-gray-500`,children:t}),(0,O.jsx)(`span`,{className:n?`text-right text-gray-500`:`text-right text-gray-900`,children:r==null||r===``?`-`:String(r)})]})}function A(){let e=f(),n=c(),i=n.data,o=m(e=>e.actionLabel),S=(0,D.useMemo)(()=>E(i),[i]),C=!!o,w=i?.runtime?.deviceName?.trim()||i?.settings.deviceName?.trim()||t(`remoteDeviceNameAuto`),T=!!(i?.account.loggedIn&&h(i)),{hero:A,issueHint:j}=S;return(0,D.useEffect)(()=>{e.remoteAccessManager.syncStatus(i)},[e,i]),n.isLoading&&!i?(0,O.jsx)(`div`,{className:`p-8 text-gray-400`,children:t(`remoteLoading`)}):(0,O.jsxs)(v,{className:`space-y-6`,children:[(0,O.jsx)(y,{title:t(`remotePageTitle`),description:t(`remotePageDescription`)}),(0,O.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-[1.2fr_0.8fr]`,children:[(0,O.jsxs)(l,{children:[(0,O.jsxs)(u,{className:`space-y-4`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,O.jsx)(p,{children:A.title}),(0,O.jsx)(b,{status:A.badgeStatus,label:A.badgeLabel})]}),(0,O.jsx)(g,{children:A.description})]}),(0,O.jsxs)(d,{className:`space-y-5`,children:[(0,O.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-gray-50 px-4 py-3`,children:[(0,O.jsx)(k,{label:t(`remoteSignedInAccount`),value:i?.account.email}),(0,O.jsx)(k,{label:t(`remoteDeviceName`),value:w}),(0,O.jsx)(k,{label:t(`remoteConnectionStatus`),value:A.badgeLabel}),(0,O.jsx)(k,{label:t(`remoteLastConnectedAt`),value:i?.runtime?.lastConnectedAt?r(i.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,O.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[S.primaryAction?(0,O.jsxs)(a,{onClick:()=>{if(S.primaryAction?.kind===`reauthorize`){e.remoteAccessManager.reauthorizeRemoteAccess(i);return}if(S.primaryAction?.kind===`repair`){e.remoteAccessManager.repairRemoteAccess(i);return}e.remoteAccessManager.enableRemoteAccess(i)},disabled:C,children:[S.primaryAction.showRefreshIcon?(0,O.jsx)(s,{className:`mr-2 h-4 w-4`}):null,o||S.primaryAction.label]}):null,(0,O.jsxs)(a,{variant:`outline`,onClick:()=>void e.accountManager.openNextClawWeb(),disabled:C||!T,children:[(0,O.jsx)(_,{className:`mr-2 h-4 w-4`}),t(`remoteOpenDeviceList`)]}),i?.settings.enabled?(0,O.jsx)(a,{variant:`outline`,onClick:()=>void e.remoteAccessManager.disableRemoteAccess(i),disabled:C,children:t(`remoteDisable`)}):null]}),S.shouldShowIssueHint&&j?(0,O.jsxs)(`div`,{className:`rounded-2xl border border-amber-200 bg-amber-50 px-4 py-3`,children:[(0,O.jsx)(`p`,{className:`text-sm font-medium text-amber-900`,children:j.title}),(0,O.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-amber-800`,children:j.body})]}):null,(0,O.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`remoteOpenWebHint`)})]})]}),(0,O.jsxs)(l,{children:[(0,O.jsxs)(u,{children:[(0,O.jsxs)(p,{className:`flex items-center gap-2`,children:[(0,O.jsx)(x,{className:`h-4 w-4 text-primary`}),t(`remoteDeviceSectionTitle`)]}),(0,O.jsx)(g,{children:t(`remoteDeviceSectionDescription`)})]}),(0,O.jsxs)(d,{className:`space-y-5`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,O.jsx)(b,{status:i?.account.loggedIn?`ready`:`inactive`,label:i?.account.loggedIn?t(`remoteAccountConnected`):t(`remoteAccountNotConnected`)}),(0,O.jsx)(b,{status:i?.settings.enabled?`active`:`inactive`,label:i?.settings.enabled?t(`remoteEnabled`):t(`remoteStateDisabled`)}),(0,O.jsx)(b,{status:i?.service.running?`active`:`inactive`,label:i?.service.running?t(`remoteServiceRunning`):t(`remoteServiceStopped`)})]}),(0,O.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-gray-50 px-4 py-3`,children:[(0,O.jsx)(k,{label:t(`remoteDeviceName`),value:w}),(0,O.jsx)(k,{label:t(`remoteConnectionStatus`),value:A.badgeLabel}),(0,O.jsx)(k,{label:t(`remoteLastConnectedAt`),value:i?.runtime?.lastConnectedAt?r(i.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,O.jsx)(`div`,{className:`rounded-2xl border border-dashed border-gray-200 bg-gray-50 px-4 py-3 text-sm text-gray-600`,children:i?.account.loggedIn?t(`remoteOpenWebHint`):t(`remoteStatusNeedsSignInDescription`)})]})]})]})]})}export{A as RemoteAccessPage};
@@ -1 +0,0 @@
1
- import{_ as e,i as t,m as n,p as r}from"./i18n-eDHeDY0n.js";import{n as i,r as a}from"./dist-ccBFUi-o.js";import{i as o,s,t as c}from"./client-_i4MU2bB.js";import{t as l}from"./useMutation-CBWjE2uj.js";import{a as u,i as d,n as f,r as p,t as m}from"./select-DJ2MUjBB.js";import{t as h}from"./createLucideIcon-BSeTgkZW.js";import{t as g}from"./loader-circle-ACM1s51e.js";import{t as _}from"./play-CFUwCA2E.js";import{t as v}from"./plus-rYsv72JG.js";import{t as y}from"./rotate-cw-JtFzpNn6.js";import{t as b}from"./save-3S6-H3Xw.js";import{t as x}from"./trash-2-G48scll7.js";import{G as S,J as C,K as w,Q as T,Y as E,d as D,j as ee,l as te,nt as O,q as k,t as A,tt as j}from"./index-CF9xve0E.js";import{n as ne,t as M}from"./page-layout-vZnghcFy.js";import{t as N}from"./config-hints-BhTmc9P1.js";import{t as P}from"./switch-BsLtHOH-.js";var F=h(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),I=e(n(),1);async function L(){let e=await c.get(`/api/runtime/control`);if(!e.ok)throw Error(e.error.message);return e.data}async function R(){let e=await c.post(`/api/runtime/control/start-service`,{});if(!e.ok)throw Error(e.error.message);return e.data}async function z(){let e=await c.post(`/api/runtime/control/restart-service`,{});if(!e.ok)throw Error(e.error.message);return e.data}async function B(){let e=await c.post(`/api/runtime/control/stop-service`,{});if(!e.ok)throw Error(e.error.message);return e.data}var V=new class{constructor(){this.getControl=async()=>this.decorateForCurrentEnvironment(await L()),this.controlService=async e=>{let t=this.getDesktopBridge();if(e===`restart-service`&&t&&typeof t.restartService==`function`){let e=await t.restartService();return{accepted:e.accepted,action:`restart-service`,lifecycle:e.lifecycle,message:e.message}}return e===`start-service`?await R():e===`stop-service`?await B():await z()},this.restartApp=async()=>{let e=this.getDesktopBridge();if(!e||typeof e.restartApp!=`function`)throw Error(t(`runtimeRestartAppUnavailable`));let n=await e.restartApp();return{accepted:n.accepted,action:`restart-app`,lifecycle:n.lifecycle,message:n.message}},this.waitForRecovery=async(e={})=>{let n=e.timeoutMs??25e3,r=e.pollIntervalMs??1500,i=Date.now()+n,a=null;for(;Date.now()<i;)try{return await this.getControl()}catch(e){a=e,await this.sleep(r)}throw a instanceof Error?a:Error(t(`runtimeRecoveryTimedOut`))},this.decorateForCurrentEnvironment=e=>{let n=this.getDesktopBridge();return!n||typeof n.restartApp!=`function`?e:{...e,environment:`desktop-embedded`,serviceState:`running`,canStartService:{available:!1,requiresConfirmation:!1,impact:`none`},canStopService:{available:!1,requiresConfirmation:!0,impact:`brief-ui-disconnect`},canRestartApp:{available:!0,requiresConfirmation:!0,impact:`full-app-relaunch`},ownerLabel:t(`runtimeControlEnvironmentDesktop`),managementHint:t(`runtimeControlDesktopServiceHint`)}},this.getDesktopBridge=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.sleep=async e=>{await new Promise(t=>{window.setTimeout(t,e)})}}};function H(){return o({queryKey:[`runtime-control`],queryFn:async()=>await V.getControl(),staleTime:5e3,refetchOnWindowFocus:!0})}function U(){let e=s();return l({mutationFn:async e=>await V.controlService(e),onSuccess:async()=>{await e.invalidateQueries({queryKey:[`runtime-control`]})}})}var W=r();function G(e){return t(e===`healthy`?`runtimeControlHealthy`:e===`starting-service`?`runtimeControlStartingService`:e===`restarting-service`?`runtimeControlRestartingService`:e===`stopping-service`?`runtimeControlStoppingService`:e===`restarting-app`?`runtimeControlRestartingApp`:e===`recovering`?`runtimeControlRecovering`:e===`failed`?`runtimeControlFailed`:`runtimeControlUnavailable`)}function K(e){return t(e===`running`?`runtimeControlServiceRunning`:e===`stopped`?`runtimeControlServiceStopped`:e===`starting`?`runtimeControlServiceStarting`:e===`stopping`?`runtimeControlServiceStopping`:e===`restarting`?`runtimeControlServiceRestarting`:`runtimeControlServiceUnknown`)}function q(e){return e.environment===`desktop-embedded`?t(`runtimeControlEnvironmentDesktop`):e.environment===`managed-local-service`?t(`runtimeControlEnvironmentManagedService`):e.environment===`self-hosted-web`?t(`runtimeControlEnvironmentSelfHosted`):t(`runtimeControlEnvironmentSharedWeb`)}function J(e){return e?[{action:`start-service`,capability:e.canStartService,label:t(`runtimeControlStartService`),icon:`play`},{action:`restart-service`,capability:e.canRestartService,label:t(`runtimeControlRestartService`),icon:`rotate`},{action:`stop-service`,capability:e.canStopService,label:t(`runtimeControlStopService`),icon:`square`,variant:`destructive`},{action:`restart-app`,capability:e.canRestartApp,label:t(`runtimeControlRestartApp`),icon:`rotate`,variant:`secondary`}].filter(e=>e.capability.available||!!e.capability.reasonIfUnavailable):[]}function Y(e){return t(e===`start-service`?`runtimeControlStartingServiceHelp`:e===`restart-service`?`runtimeControlRestartingServiceHelp`:e===`stop-service`?`runtimeControlStoppingServiceHelp`:`runtimeControlRestartingAppHelp`)}function X(e){let{busy:t,icon:n}=e;return t?(0,W.jsx)(g,{className:`mr-2 h-4 w-4 animate-spin`}):n===`play`?(0,W.jsx)(_,{className:`mr-2 h-4 w-4`}):n===`square`?(0,W.jsx)(F,{className:`mr-2 h-4 w-4`}):(0,W.jsx)(y,{className:`mr-2 h-4 w-4`})}function re(){let e=s(),n=H(),r=U(),[o,c]=(0,I.useState)(null),[l,u]=(0,I.useState)(null),[d,f]=(0,I.useState)(null),[p,m]=(0,I.useState)(null),h=n.data,g=o??h?.lifecycle??`healthy`,_=l??h?.serviceState??`unknown`,v=d??h?.message??t(`runtimeControlDescription`),y=r.isPending||p!==null||g===`recovering`,b=J(h),x=()=>{c(null),u(null),f(null),m(null)},T=async n=>{let a=n===`start-service`?h?.canStartService:n===`stop-service`?h?.canStopService:h?.canRestartService;if(!a?.available){i.error(a?.reasonIfUnavailable??t(`runtimeControlLoadFailed`));return}if(!(n===`stop-service`&&a.requiresConfirmation&&!window.confirm(t(`runtimeControlStopServiceConfirm`)))){m(n),c(n===`start-service`?`starting-service`:n===`stop-service`?`stopping-service`:`restarting-service`),u(n===`start-service`?`starting`:n===`stop-service`?`stopping`:`restarting`),f(Y(n));try{let a=await r.mutateAsync(n);if(i.success(a.message),n===`stop-service`)return;c(`recovering`),f(t(`runtimeControlRecoveringHelp`));let o=await V.waitForRecovery();e.setQueryData([`runtime-control`],o),await e.invalidateQueries({queryKey:[`runtime-control`]}),x(),i.success(t(`runtimeControlRecovered`))}catch(e){let r=e instanceof Error?e.message:t(`runtimeControlActionFailed`);c(`failed`),u(n===`stop-service`?`running`:`unknown`),f(r),m(null),i.error(`${t(`runtimeControlActionFailed`)}: ${r}`)}}},D=async()=>{if(!h?.canRestartApp.available){i.error(h?.canRestartApp.reasonIfUnavailable??t(`runtimeRestartAppUnavailable`));return}if(window.confirm(t(`runtimeControlRestartAppConfirm`))){m(`restart-app`),c(`restarting-app`),f(t(`runtimeControlRestartingAppHelp`));try{let e=await V.restartApp();i.success(e.message)}catch(e){let n=e instanceof Error?e.message:t(`runtimeControlActionFailed`);c(`failed`),f(n),m(null),i.error(`${t(`runtimeControlActionFailed`)}: ${n}`)}}};return(0,W.jsxs)(S,{children:[(0,W.jsxs)(C,{children:[(0,W.jsx)(E,{children:t(`runtimeControlTitle`)}),(0,W.jsx)(k,{children:t(`runtimeControlDescription`)})]}),(0,W.jsxs)(w,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{className:`rounded-xl border border-gray-200 bg-gray-50 p-4 space-y-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-center md:justify-between`,children:[(0,W.jsx)(`div`,{className:`text-sm font-medium text-gray-900`,children:K(_)}),(0,W.jsx)(`div`,{className:`text-xs text-gray-500`,children:h?q(h):t(`runtimeControlLoading`)})]}),(0,W.jsx)(`p`,{className:`text-sm text-gray-600`,children:v}),(0,W.jsx)(`div`,{className:`text-xs text-gray-500`,children:G(g)}),h?.managementHint?(0,W.jsx)(`p`,{className:`text-xs text-gray-500`,children:h.managementHint}):null,n.isError&&!y?(0,W.jsx)(`p`,{className:`text-sm text-amber-700`,children:n.error instanceof Error?n.error.message:t(`runtimeControlLoadFailed`)}):null]}),(0,W.jsx)(`div`,{className:`flex flex-col gap-3 md:flex-row md:flex-wrap`,children:b.map(e=>{let t=p===e.action,n=!e.capability.available||y;return(0,W.jsxs)(a,{type:`button`,variant:e.variant??`default`,onClick:()=>{if(e.action===`restart-app`){D();return}T(e.action)},disabled:n,children:[(0,W.jsx)(X,{icon:e.icon,busy:t}),e.label]},e.action)})}),b.filter(e=>!e.capability.available&&e.capability.reasonIfUnavailable).map(e=>(0,W.jsx)(`p`,{className:`text-xs text-gray-500`,children:e.capability.reasonIfUnavailable},`${e.action}-reason`))]})]})}var Z=T(()=>({supported:!1,initialized:!1,busyAction:null,snapshot:null})),Q=new class{constructor(){this.start=async()=>{let e=this.getDesktopApi();if(!e){this.markUnsupported();return}Z.setState({supported:!0,initialized:!1,busyAction:`loading`});try{let t=await e.getPresenceState();Z.setState({supported:!0,initialized:!0,busyAction:null,snapshot:t})}catch(e){Z.setState({supported:!0,initialized:!0,busyAction:null}),i.error(`${t(`runtimePresenceLoadFailed`)}: ${this.getErrorMessage(e)}`)}},this.markUnsupported=()=>{Z.setState({supported:!1,initialized:!0,busyAction:null,snapshot:null})},this.updatePreferences=async e=>{let n=this.getDesktopApi();if(!n)throw Error(t(`runtimePresenceLaunchAtLoginUnavailable`));Z.setState({busyAction:`saving-preferences`});try{let r=await n.updatePresencePreferences(e);return Z.setState({supported:!0,initialized:!0,snapshot:r}),i.success(t(`runtimePresenceSaved`)),r}catch(e){throw i.error(`${t(`runtimePresenceSaveFailed`)}: ${this.getErrorMessage(e)}`),e}finally{Z.setState({busyAction:null})}},this.getDesktopApi=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.getErrorMessage=e=>e instanceof Error?e.message:t(`error`)}};function $(e){let{description:t,title:n}=e;return(0,W.jsxs)(`div`,{className:`rounded-xl border border-gray-200 bg-gray-50 p-4`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-gray-900`,children:n}),(0,W.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-gray-600`,children:t})]})}function ie(){let e=H().data?.environment,n=Z(e=>e.supported),r=Z(e=>e.initialized),i=Z(e=>e.busyAction),a=Z(e=>e.snapshot);return(0,I.useEffect)(()=>{if(e===`desktop-embedded`){Q.start();return}Q.markUnsupported()},[e]),e===`desktop-embedded`?(0,W.jsxs)(S,{children:[(0,W.jsxs)(C,{children:[(0,W.jsx)(E,{children:t(`runtimePresenceTitle`)}),(0,W.jsx)(k,{children:t(`runtimePresenceDescription`)})]}),(0,W.jsxs)(w,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{className:`rounded-xl border border-gray-200 bg-gray-50 p-4`,children:[(0,W.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.08em] text-gray-500`,children:t(`runtimePresenceBehaviorLabel`)}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-medium text-gray-900`,children:a?.closeToBackground?t(`runtimePresenceBehaviorBackground`):t(`runtimePresenceBehaviorQuit`)})]}),!r||n&&!a?(0,W.jsx)(`p`,{className:`text-sm text-gray-500`,children:t(`runtimePresenceLoading`)}):null,a?(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4 rounded-xl border border-gray-200 p-4`,children:[(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(j,{htmlFor:`runtime-presence-close-background`,children:t(`runtimePresenceCloseToBackground`)}),(0,W.jsx)(`p`,{className:`text-sm text-gray-500`,children:t(`runtimePresenceCloseToBackgroundHelp`)})]}),(0,W.jsx)(P,{id:`runtime-presence-close-background`,"aria-label":t(`runtimePresenceCloseToBackground`),checked:a.closeToBackground,disabled:i===`saving-preferences`,onCheckedChange:e=>{Q.updatePreferences({closeToBackground:e})}})]}),(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4 rounded-xl border border-gray-200 p-4`,children:[(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(j,{htmlFor:`runtime-presence-launch-login`,children:t(`runtimePresenceLaunchAtLogin`)}),(0,W.jsx)(`p`,{className:`text-sm text-gray-500`,children:a.supportsLaunchAtLogin?t(`runtimePresenceLaunchAtLoginHelp`):a.launchAtLoginReason??t(`runtimePresenceLaunchAtLoginUnavailable`)})]}),(0,W.jsx)(P,{id:`runtime-presence-launch-login`,"aria-label":t(`runtimePresenceLaunchAtLogin`),checked:a.launchAtLogin,disabled:!a.supportsLaunchAtLogin||i===`saving-preferences`,onCheckedChange:e=>{Q.updatePreferences({launchAtLogin:e})}})]})]}):null]})]}):e===`managed-local-service`?(0,W.jsxs)(S,{children:[(0,W.jsxs)(C,{children:[(0,W.jsx)(E,{children:t(`runtimePresenceTitle`)}),(0,W.jsx)(k,{children:t(`runtimePresenceDescription`)})]}),(0,W.jsx)(w,{children:(0,W.jsx)($,{title:t(`runtimePresenceManagedLocalTitle`),description:t(`runtimePresenceManagedLocalDescription`)})})]}):e===`self-hosted-web`?(0,W.jsxs)(S,{children:[(0,W.jsxs)(C,{children:[(0,W.jsx)(E,{children:t(`runtimePresenceTitle`)}),(0,W.jsx)(k,{children:t(`runtimePresenceDescription`)})]}),(0,W.jsx)(w,{children:(0,W.jsx)($,{title:t(`runtimePresenceSelfHostedTitle`),description:t(`runtimePresenceSelfHostedDescription`)})})]}):e===`shared-web`?(0,W.jsxs)(S,{children:[(0,W.jsxs)(C,{children:[(0,W.jsx)(E,{children:t(`runtimePresenceTitle`)}),(0,W.jsx)(k,{children:t(`runtimePresenceDescription`)})]}),(0,W.jsx)(w,{children:(0,W.jsx)($,{title:t(`runtimePresenceSharedTitle`),description:t(`runtimePresenceSharedDescription`)})})]}):(0,W.jsxs)(S,{children:[(0,W.jsxs)(C,{children:[(0,W.jsx)(E,{children:t(`runtimePresenceTitle`)}),(0,W.jsx)(k,{children:t(`runtimePresenceDescription`)})]}),(0,W.jsx)(w,{children:(0,W.jsx)(`p`,{className:`text-sm text-gray-500`,children:t(`runtimePresenceLoading`)})})]})}function ae(){return{id:``,default:!1,workspace:``,model:``,runtime:``,contextTokens:void 0,maxToolIterations:void 0}}function oe(){return{agentId:``,match:{channel:``,accountId:``}}}function se(e){return{id:e.id??``,default:!!e.default,displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,workspace:e.workspace??``,model:e.model??``,runtime:e.runtime??e.engine??``,contextTokens:e.contextTokens,maxToolIterations:e.maxToolIterations}}function ce(e){return{agentId:e.agentId??``,match:{channel:e.match?.channel??``,accountId:e.match?.accountId??``,peer:e.match?.peer?{kind:e.match.peer.kind,id:e.match.peer.id}:void 0}}}function le(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);return Number.isFinite(n)?n:void 0}function ue(e){let t={id:e.id.trim()};e.default&&(t.default=!0),e.displayName?.trim()&&(t.displayName=e.displayName.trim()),e.description?.trim()&&(t.description=e.description.trim()),e.avatar?.trim()&&(t.avatar=e.avatar.trim()),e.workspace?.trim()&&(t.workspace=e.workspace.trim()),e.model?.trim()&&(t.model=e.model.trim());let n=e.runtime?.trim()??e.engine?.trim();return n&&(t.engine=n),typeof e.contextTokens==`number`&&(t.contextTokens=Math.max(1e3,e.contextTokens)),typeof e.maxToolIterations==`number`&&(t.maxToolIterations=e.maxToolIterations),t}var de=[{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`}],fe={wireDialect:`acp`,processScope:`per-session`,command:``,args:[`acp`],env:{},cwd:``,startupTimeoutMs:8e3,probeTimeoutMs:3e3,requestTimeoutMs:12e4};function pe(){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(M,{title:t(`runtimePageTitle`),description:t(`runtimePageDescription`)}),(0,W.jsx)(re,{}),(0,W.jsx)(ie,{}),(0,W.jsx)(A,{})]})}function me(){let{data:e,isLoading:n}=te(),{data:r}=D(),o=ee(),[s,c]=(0,I.useState)([]),[l,h]=(0,I.useState)([]),[g,_]=(0,I.useState)([]),[y,T]=(0,I.useState)(`per-channel-peer`),[A,j]=(0,I.useState)(2e5),[M,F]=(0,I.useState)(`native`);(0,I.useEffect)(()=>{e&&(c((e.agents.list??[]).map(se)),h((e.bindings??[]).map(ce)),_(Object.entries(e.agents.runtimes?.entries??{}).map(([e,t])=>({id:e,enabled:t.enabled!==!1,label:t.label??``,type:t.type,config:t.config??{},configText:JSON.stringify(t.config??{},null,2)}))),T(e.session?.dmScope??`per-channel-peer`),j(e.agents.defaults.contextTokens??2e5),F(e.agents.defaults.engine??`native`))},[e]);let L=r?.uiHints,R=N(`session.dmScope`,L),z=N(`agents.defaults.contextTokens`,L),B=N(`agents.defaults.engine`,L),V=N(`agents.list.*.contextTokens`,L),H=N(`agents.list.*.engine`,L),U=N(`agents.list`,L),G=N(`bindings`,L),K=N(`agents.runtimes.entries`,L),q=(0,I.useMemo)(()=>{let e=new Set([`main`]);return s.forEach(t=>{let n=t.id.trim();n&&e.add(n)}),e},[s]),J=(e,t)=>{c(n=>n.map((n,r)=>r===e?{...n,...t}:n))},Y=(e,t)=>{h(n=>n.map((n,r)=>r===e?t:n))},X=(e,t)=>{_(n=>n.map((n,r)=>r===e?{...n,...t}:n))},re=e=>{_(t=>t.filter((t,n)=>n!==e))};return n||!e?(0,W.jsx)(`div`,{className:`p-8 text-gray-400`,children:t(`runtimeLoading`)}):(0,W.jsxs)(ne,{className:`space-y-6`,children:[(0,W.jsx)(pe,{}),(0,W.jsxs)(S,{children:[(0,W.jsxs)(C,{children:[(0,W.jsx)(E,{children:R?.label??t(`dmScope`)}),(0,W.jsx)(k,{children:R?.help??t(`dmScopeHelp`)})]}),(0,W.jsxs)(w,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:z?.label??t(`defaultContextTokens`)}),(0,W.jsx)(O,{type:`number`,min:1e3,step:1e3,value:A,onChange:e=>j(Math.max(1e3,Number.parseInt(e.target.value,10)||1e3))}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500`,children:z?.help??t(`defaultContextTokensHelp`)})]}),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:B?.label??t(`defaultEngine`)}),(0,W.jsx)(O,{value:M,onChange:e=>F(e.target.value),placeholder:t(`defaultEnginePlaceholder`)}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500`,children:B?.help??t(`defaultEngineHelp`)})]}),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:R?.label??t(`dmScope`)}),(0,W.jsxs)(m,{value:y,onValueChange:e=>T(e),children:[(0,W.jsx)(d,{children:(0,W.jsx)(u,{})}),(0,W.jsx)(f,{children:de.map(e=>(0,W.jsx)(p,{value:e.value,children:e.label},e.value))})]})]})]})]}),(0,W.jsxs)(S,{children:[(0,W.jsxs)(C,{children:[(0,W.jsx)(E,{children:K?.label??`Runtime Entries`}),(0,W.jsx)(k,{children:K?.help??`统一管理可见的 runtime entry 与其配置。`})]}),(0,W.jsxs)(w,{className:`space-y-3`,children:[g.map((e,n)=>(0,W.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,W.jsx)(O,{value:e.id,onChange:e=>X(n,{id:e.target.value}),placeholder:`entry id,例如 hermes`}),(0,W.jsx)(O,{value:e.label??``,onChange:e=>X(n,{label:e.target.value}),placeholder:`展示名称,例如 Hermes`}),(0,W.jsx)(O,{value:e.type,onChange:e=>X(n,{type:e.target.value}),placeholder:`runtime type,例如 narp-stdio`}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-gray-200 px-3 py-2`,children:[(0,W.jsx)(`span`,{className:`text-sm text-gray-700`,children:`Enabled`}),(0,W.jsx)(P,{checked:e.enabled!==!1,onCheckedChange:e=>X(n,{enabled:e})})]})]}),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:`Config JSON`}),(0,W.jsx)(`textarea`,{className:`min-h-32 w-full rounded-md border border-gray-200 px-3 py-2 text-sm font-mono`,value:e.configText,onChange:e=>X(n,{configText:e.target.value}),spellCheck:!1})]}),(0,W.jsx)(`div`,{className:`flex justify-end`,children:(0,W.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>re(n),children:[(0,W.jsx)(x,{className:`mr-2 h-4 w-4`}),t(`deleteButton`)]})})]},`${n}-${e.id||`runtime-entry`}`)),(0,W.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>{_(e=>[...e,{id:``,enabled:!0,label:``,type:`narp-stdio`,config:fe,configText:JSON.stringify(fe,null,2)}])},children:[(0,W.jsx)(v,{className:`mr-2 h-4 w-4`}),`Add Runtime Entry`]})]})]}),(0,W.jsxs)(S,{children:[(0,W.jsxs)(C,{children:[(0,W.jsx)(E,{children:U?.label??t(`agentList`)}),(0,W.jsx)(k,{children:U?.help??t(`agentListHelp`)})]}),(0,W.jsxs)(w,{className:`space-y-3`,children:[s.map((e,n)=>(0,W.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,W.jsx)(O,{value:e.id,onChange:e=>J(n,{id:e.target.value}),placeholder:t(`agentIdPlaceholder`)}),(0,W.jsx)(O,{value:e.workspace??``,onChange:e=>J(n,{workspace:e.target.value}),placeholder:t(`workspaceOverridePlaceholder`)}),(0,W.jsx)(O,{value:e.model??``,onChange:e=>J(n,{model:e.target.value}),placeholder:t(`modelOverridePlaceholder`)}),(0,W.jsx)(O,{value:e.runtime??e.engine??``,onChange:e=>J(n,{runtime:e.target.value}),placeholder:H?.label??t(`engineOverridePlaceholder`)}),(0,W.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2`,children:[(0,W.jsx)(O,{type:`number`,min:1e3,step:1e3,value:e.contextTokens??``,onChange:e=>J(n,{contextTokens:le(e.target.value)}),placeholder:V?.label??t(`contextTokensPlaceholder`)}),(0,W.jsx)(O,{type:`number`,min:1,value:e.maxToolIterations??``,onChange:e=>J(n,{maxToolIterations:le(e.target.value)}),placeholder:t(`maxToolsPlaceholder`)})]})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600`,children:[(0,W.jsx)(P,{checked:!!e.default,onCheckedChange:e=>{if(!e){J(n,{default:!1});return}c(e=>e.map((e,t)=>({...e,default:t===n})))}}),(0,W.jsx)(`span`,{children:t(`defaultAgent`)})]}),(0,W.jsxs)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>c(e=>e.filter((e,t)=>t!==n)),children:[(0,W.jsx)(x,{className:`h-4 w-4 mr-1`}),t(`remove`)]})]})]},`${n}-${e.id}`)),(0,W.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>c(e=>[...e,ae()]),children:[(0,W.jsx)(v,{className:`h-4 w-4 mr-2`}),t(`addAgent`)]})]})]}),(0,W.jsxs)(S,{children:[(0,W.jsxs)(C,{children:[(0,W.jsx)(E,{children:G?.label??t(`bindings`)}),(0,W.jsx)(k,{children:G?.help??t(`bindingsHelp`)})]}),(0,W.jsxs)(w,{className:`space-y-3`,children:[l.map((e,n)=>{let r=e.match.peer?.kind??``;return(0,W.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:[(0,W.jsx)(O,{value:e.agentId,onChange:t=>Y(n,{...e,agentId:t.target.value}),placeholder:t(`targetAgentIdPlaceholder`)}),(0,W.jsx)(O,{value:e.match.channel,onChange:t=>Y(n,{...e,match:{...e.match,channel:t.target.value}}),placeholder:t(`channelPlaceholder`)}),(0,W.jsx)(O,{value:e.match.accountId??``,onChange:t=>Y(n,{...e,match:{...e.match,accountId:t.target.value}}),placeholder:t(`accountIdOptionalPlaceholder`)}),(0,W.jsxs)(m,{value:r||`__none__`,onValueChange:t=>{let r=t===`__none__`?``:t;if(!r){Y(n,{...e,match:{...e.match,peer:void 0}});return}Y(n,{...e,match:{...e.match,peer:{kind:r,id:e.match.peer?.id??``}}})},children:[(0,W.jsx)(d,{children:(0,W.jsx)(u,{})}),(0,W.jsxs)(f,{children:[(0,W.jsx)(p,{value:`__none__`,children:t(`peerKindOptional`)}),(0,W.jsx)(p,{value:`direct`,children:`direct`}),(0,W.jsx)(p,{value:`group`,children:`group`}),(0,W.jsx)(p,{value:`channel`,children:`channel`})]})]}),(0,W.jsx)(O,{value:e.match.peer?.id??``,onChange:t=>Y(n,{...e,match:{...e.match,peer:r?{kind:r,id:t.target.value}:void 0}}),placeholder:t(`peerIdPlaceholder`)})]}),(0,W.jsx)(`div`,{className:`flex justify-end`,children:(0,W.jsxs)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>h(e=>e.filter((e,t)=>t!==n)),children:[(0,W.jsx)(x,{className:`h-4 w-4 mr-1`}),t(`remove`)]})})]},`${n}-${e.agentId}`)}),(0,W.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>h(e=>[...e,oe()]),children:[(0,W.jsx)(v,{className:`h-4 w-4 mr-2`}),t(`addBinding`)]})]})]}),(0,W.jsx)(`div`,{className:`flex justify-end`,children:(0,W.jsxs)(a,{type:`button`,onClick:()=>{try{let e=s.map((e,n)=>{if(!e.id.trim())throw Error(t(`agentIdRequiredError`).replace(`{index}`,String(n)));return ue(e)}),n=e.map(e=>e.id).filter((e,t,n)=>n.indexOf(e)!==t);if(n.length>0){i.error(`${t(`duplicateAgentId`)}: ${n[0]}`);return}let r=l.map((e,n)=>{let r=e.agentId.trim(),i=e.match.channel.trim(),a=e.match.accountId?.trim()??``,o=e.match.peer?.kind,s=e.match.peer?.id?.trim()??``;if(!r)throw Error(t(`bindingAgentIdRequired`).replace(`{index}`,String(n)));if(!q.has(r))throw Error(`${t(`bindingAgentIdNotFound`).replace(`{index}`,String(n))}: ${r}`);if(!i)throw Error(t(`bindingChannelRequired`).replace(`{index}`,String(n)));let c={agentId:r,match:{channel:i}};if(a&&(c.match.accountId=a),o){if(!s)throw Error(t(`bindingPeerIdRequired`).replace(`{index}`,String(n)));c.match.peer={kind:o,id:s}}return c}),a=g.reduce((e,t,n)=>{let r=t.id.trim(),i=t.type.trim();if(!r)throw Error(`Runtime entry id is required at index ${n}.`);if(!i)throw Error(`Runtime entry type is required for "${r}".`);if(e[r])throw Error(`Duplicate runtime entry id: ${r}`);let a=t.configText.trim()?JSON.parse(t.configText):{};if(a&&(typeof a!=`object`||Array.isArray(a)))throw Error(`Runtime entry config for "${r}" must be a JSON object.`);return e[r]={enabled:t.enabled!==!1,...t.label?.trim()?{label:t.label.trim()}:{},type:i,config:a??{}},e},{});o.mutate({data:{agents:{defaults:{contextTokens:Math.max(1e3,A),engine:M.trim()||`native`},list:e,runtimes:{entries:a}},bindings:r,session:{dmScope:y}}})}catch(e){let t=e instanceof Error?e.message:String(e);i.error(t)}},disabled:o.isPending,children:[(0,W.jsx)(b,{className:`h-4 w-4 mr-2`}),o.isPending?t(`saving`):t(`saveRuntimeSettings`)]})})]})}export{me as RuntimeConfig};
@@ -1 +0,0 @@
1
- import{_ as e,i as t,m as n,p as r,u as i}from"./i18n-eDHeDY0n.js";import{r as a}from"./dist-ccBFUi-o.js";import{a as o,i as s,n as c,r as l,t as u}from"./select-DJ2MUjBB.js";import{t as d}from"./external-link-BgErLCNT.js";import{t as f}from"./search-3kFR_zh9.js";import{M as p,_t as m,l as h,nt as g,tt as _,u as v}from"./index-CF9xve0E.js";import{n as y,t as ee}from"./page-layout-vZnghcFy.js";import{i as te,r as ne,t as re}from"./config-layout-CHs0mAaR.js";var b=e(n(),1),x=r(),S=[{value:`noLimit`,label:`searchFreshnessNoLimit`},{value:`oneDay`,label:`searchFreshnessOneDay`},{value:`oneWeek`,label:`searchFreshnessOneWeek`},{value:`oneMonth`,label:`searchFreshnessOneMonth`},{value:`oneYear`,label:`searchFreshnessOneYear`}],C=[{value:`basic`,label:`searchDepthBasic`},{value:`advanced`,label:`searchDepthAdvanced`}],ie={bocha:`searchProviderBochaDescription`,tavily:`searchProviderTavilyDescription`,brave:`searchProviderBraveDescription`};function ae({apiKey:e,apiKeyMasked:n,baseUrl:r,summary:i,freshness:f,docsUrl:p,onApiKeyChange:m,onBaseUrlChange:h,onSummaryChange:v,onFreshnessChange:y}){return(0,x.jsxs)(`div`,{className:`space-y-4`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`apiKey`)}),(0,x.jsx)(g,{type:`password`,value:e,onChange:e=>m(e.target.value),placeholder:n||t(`enterApiKey`),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`searchProviderBaseUrl`)}),(0,x.jsx)(g,{value:r,onChange:e=>h(e.target.value),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`searchProviderSummary`)}),(0,x.jsxs)(u,{value:i?`true`:`false`,onValueChange:e=>v(e===`true`),children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsxs)(c,{children:[(0,x.jsx)(l,{value:`true`,children:t(`enabled`)}),(0,x.jsx)(l,{value:`false`,children:t(`disabled`)})]})]})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`searchProviderFreshness`)}),(0,x.jsxs)(u,{value:f,onValueChange:y,children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsx)(c,{children:S.map(e=>(0,x.jsx)(l,{value:e.value,children:t(e.label)},e.value))})]})]})]}),(0,x.jsx)(`div`,{className:`space-y-2`,children:(0,x.jsx)(`a`,{href:p??`https://open.bocha.cn`,target:`_blank`,rel:`noreferrer`,children:(0,x.jsxs)(a,{type:`button`,variant:`outline`,className:`rounded-xl`,children:[(0,x.jsx)(d,{className:`mr-2 h-4 w-4`}),t(`searchProviderOpenDocs`)]})})})]})}function w({apiKey:e,apiKeyMasked:n,baseUrl:r,searchDepth:i,includeAnswer:f,docsUrl:p,onApiKeyChange:m,onBaseUrlChange:h,onSearchDepthChange:v,onIncludeAnswerChange:y}){return(0,x.jsxs)(`div`,{className:`space-y-4`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`apiKey`)}),(0,x.jsx)(g,{type:`password`,value:e,onChange:e=>m(e.target.value),placeholder:n||t(`enterApiKey`),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`searchProviderBaseUrl`)}),(0,x.jsx)(g,{value:r,onChange:e=>h(e.target.value),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`searchProviderSearchDepth`)}),(0,x.jsxs)(u,{value:i,onValueChange:e=>v(e),children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsx)(c,{children:C.map(e=>(0,x.jsx)(l,{value:e.value,children:t(e.label)},e.value))})]})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`searchProviderIncludeAnswer`)}),(0,x.jsxs)(u,{value:f?`true`:`false`,onValueChange:e=>y(e===`true`),children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsxs)(c,{children:[(0,x.jsx)(l,{value:`true`,children:t(`enabled`)}),(0,x.jsx)(l,{value:`false`,children:t(`disabled`)})]})]})]})]}),p?(0,x.jsx)(`div`,{className:`space-y-2`,children:(0,x.jsx)(`a`,{href:p,target:`_blank`,rel:`noreferrer`,children:(0,x.jsxs)(a,{type:`button`,variant:`outline`,className:`rounded-xl`,children:[(0,x.jsx)(d,{className:`mr-2 h-4 w-4`}),t(`searchProviderOpenDocs`)]})})}):null]})}function oe({apiKey:e,apiKeyMasked:n,baseUrl:r,onApiKeyChange:i,onBaseUrlChange:a}){return(0,x.jsxs)(`div`,{className:`space-y-4`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`apiKey`)}),(0,x.jsx)(g,{type:`password`,value:e,onChange:e=>i(e.target.value),placeholder:n||t(`enterApiKey`),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`searchProviderBaseUrl`)}),(0,x.jsx)(g,{value:r,onChange:e=>a(e.target.value),className:`rounded-xl`})]})]})}function T(){let{data:e}=h(),{data:n}=v(),r=p(),d=(0,b.useMemo)(()=>n?.search??[],[n]),S=e?.search,[C,T]=(0,b.useState)(`bocha`),[E,D]=(0,b.useState)(`bocha`),[O,k]=(0,b.useState)([`bocha`]),[A,j]=(0,b.useState)(`10`),[M,se]=(0,b.useState)(``),[N,P]=(0,b.useState)(`https://api.bocha.cn/v1/web-search`),[F,I]=(0,b.useState)(!0),[L,R]=(0,b.useState)(`noLimit`),[z,ce]=(0,b.useState)(``),[B,V]=(0,b.useState)(`https://api.tavily.com/search`),[H,U]=(0,b.useState)(`basic`),[W,G]=(0,b.useState)(!1),[K,le]=(0,b.useState)(``),[q,J]=(0,b.useState)(`https://api.search.brave.com/res/v1/web/search`);(0,b.useEffect)(()=>{S&&(T(S.provider),D(S.provider),k(S.enabledProviders),j(String(S.defaults.maxResults)),P(S.providers.bocha.baseUrl),I(!!S.providers.bocha.summary),R(S.providers.bocha.freshness??`noLimit`),V(S.providers.tavily.baseUrl),U(S.providers.tavily.searchDepth??`basic`),G(!!S.providers.tavily.includeAnswer),J(S.providers.brave.baseUrl))},[S]);let Y=(0,b.useMemo)(()=>d.find(e=>e.name===C),[d,C]),X=S?.providers[C],Z=O.includes(C),Q=X?.docsUrl??Y?.docsUrl,ue=t(Z?`searchProviderDeactivate`:`searchProviderActivate`),$=(e=O,t=E)=>({provider:t,enabledProviders:e,defaults:{maxResults:Number(A)||10},providers:{bocha:{apiKey:M||void 0,baseUrl:N,summary:F,freshness:L},tavily:{apiKey:z||void 0,baseUrl:B,searchDepth:H,includeAnswer:W},brave:{apiKey:K||void 0,baseUrl:q}}});return!S||d.length===0?(0,x.jsx)(`div`,{className:`p-8`,children:t(`loading`)}):(0,x.jsxs)(y,{children:[(0,x.jsx)(ee,{title:t(`searchPageTitle`),description:t(`searchPageDescription`)}),(0,x.jsxs)(`div`,{className:te,children:[(0,x.jsxs)(`section`,{className:ne,children:[(0,x.jsx)(`div`,{className:`border-b border-gray-100 px-4 py-4`,children:(0,x.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-gray-500`,children:t(`searchChannels`)})}),(0,x.jsx)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-3`,children:d.map(e=>{let n=S.providers[e.name],r=O.includes(e.name);return(0,x.jsx)(`button`,{type:`button`,onClick:()=>T(e.name),className:i(`w-full rounded-xl border p-3 text-left transition-all`,C===e.name?`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:(0,x.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.displayName}),(0,x.jsx)(`p`,{className:`line-clamp-2 text-[11px] text-gray-500`,children:t(ie[e.name])})]}),(0,x.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[(0,x.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600`,children:n.apiKeySet?t(`searchStatusConfigured`):t(`searchStatusNeedsSetup`)}),r?(0,x.jsx)(`span`,{className:`rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700`,children:t(`searchProviderActivated`)}):null]})]})},e.name)})})]}),(0,x.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),r.mutate({data:$()})},className:i(re,`p-6`),children:!Y||!X?(0,x.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:t(`searchNoProviderSelected`)}):(0,x.jsxs)(`div`,{className:`space-y-6 overflow-y-auto`,children:[(0,x.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white`,children:(0,x.jsx)(f,{className:`h-5 w-5`})}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900`,children:Y.displayName}),(0,x.jsx)(`p`,{className:`text-sm text-gray-500`,children:Y.description})]})]}),(0,x.jsx)(a,{type:`button`,variant:Z?`secondary`:`outline`,className:`rounded-xl`,onClick:()=>{let e=Z?O.filter(e=>e!==C):[...O,C];k(e),r.mutate({data:$(e)})},children:ue})]}),(0,x.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`searchActiveProvider`)}),(0,x.jsxs)(u,{value:E,onValueChange:e=>{D(e)},children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsx)(c,{children:d.map(e=>(0,x.jsx)(l,{value:e.name,children:e.displayName},e.name))})]})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`searchDefaultMaxResults`)}),(0,x.jsx)(g,{value:A,onChange:e=>j(e.target.value),inputMode:`numeric`,className:`rounded-xl`})]})]}),C===`bocha`?(0,x.jsx)(ae,{apiKey:M,apiKeyMasked:S.providers.bocha.apiKeyMasked,baseUrl:N,summary:F,freshness:L,docsUrl:Q,onApiKeyChange:se,onBaseUrlChange:P,onSummaryChange:I,onFreshnessChange:R}):C===`tavily`?(0,x.jsx)(w,{apiKey:z,apiKeyMasked:S.providers.tavily.apiKeyMasked,baseUrl:B,searchDepth:H,includeAnswer:W,docsUrl:Q,onApiKeyChange:ce,onBaseUrlChange:V,onSearchDepthChange:U,onIncludeAnswerChange:G}):(0,x.jsx)(oe,{apiKey:K,apiKeyMasked:S.providers.brave.apiKeyMasked,baseUrl:q,onApiKeyChange:le,onBaseUrlChange:J}),(0,x.jsx)(`div`,{className:`flex justify-end`,children:(0,x.jsxs)(a,{type:`submit`,disabled:r.isPending,children:[(0,x.jsx)(m,{className:`mr-2 h-4 w-4`}),r.isPending?t(`saving`):t(`saveChanges`)]})})]})})]})]})}export{T as SearchConfig};
@@ -1,3 +0,0 @@
1
- import{_ as e,i as t,m as n,p as r}from"./i18n-eDHeDY0n.js";import{n as i,r as a}from"./dist-ccBFUi-o.js";import{a as o,i as s,n as c,r as l,t as u}from"./select-DJ2MUjBB.js";import{t as d}from"./plus-rYsv72JG.js";import{t as f}from"./save-3S6-H3Xw.js";import{t as p}from"./trash-2-G48scll7.js";import{G as m,J as h,K as g,N as _,Y as v,l as y,nt as b,q as x,tt as S}from"./index-CF9xve0E.js";import{n as C,t as w}from"./page-layout-vZnghcFy.js";import{t as T}from"./switch-BsLtHOH-.js";var E=e(n(),1),D=r(),O=[`env`,`file`,`exec`];function k(e=``){return{alias:e,source:`env`,prefix:``,path:``,command:``,argsText:``,cwd:``,timeoutMs:5e3}}function A(){return{path:``,source:`env`,provider:``,id:``}}function j(e,t){return t.source===`env`?{...k(e),source:`env`,prefix:t.prefix??``}:t.source===`file`?{...k(e),source:`file`,path:t.path}:{...k(e),source:`exec`,command:t.command,argsText:(t.args??[]).join(`
2
- `),cwd:t.cwd??``,timeoutMs:t.timeoutMs??5e3}}function M(e){return e.source===`env`?{source:`env`,...e.prefix.trim()?{prefix:e.prefix.trim()}:{}}:e.source===`file`?{source:`file`,path:e.path.trim(),format:`json`}:{source:`exec`,command:e.command.trim(),args:e.argsText.split(`
3
- `).map(e=>e.trim()).filter(Boolean),...e.cwd.trim()?{cwd:e.cwd.trim()}:{},timeoutMs:Math.max(1,Math.trunc(e.timeoutMs||5e3))}}function N(){let{data:e,isLoading:n}=y(),r=_(),[N,P]=(0,E.useState)(!0),[F,I]=(0,E.useState)(``),[L,R]=(0,E.useState)(``),[z,B]=(0,E.useState)(``),[V,H]=(0,E.useState)([]),[U,W]=(0,E.useState)([]);(0,E.useEffect)(()=>{let t=e?.secrets;if(!t){P(!0),I(``),R(``),B(``),H([]),W([]);return}P(!!t.enabled),I(t.defaults.env??``),R(t.defaults.file??``),B(t.defaults.exec??``);let n=Object.entries(t.providers).map(([e,t])=>j(e,t)),r=Object.entries(t.refs).map(([e,t])=>({path:e,source:t.source,provider:t.provider??``,id:t.id}));H(n),W(r)},[e?.secrets]);let G=(0,E.useMemo)(()=>{let e=V.map(e=>e.alias.trim()).filter(Boolean);return Array.from(new Set(e))},[V]),K=(e,t)=>{H(n=>n.map((n,r)=>r===e?{...n,...t}:n))},q=(e,t)=>{W(n=>n.map((n,r)=>r===e?{...n,...t}:n))};return n?(0,D.jsx)(`div`,{className:`p-8 text-gray-400`,children:t(`loading`)}):(0,D.jsxs)(C,{className:`space-y-6`,children:[(0,D.jsx)(w,{title:t(`secretsPageTitle`),description:t(`secretsPageDescription`)}),(0,D.jsxs)(m,{children:[(0,D.jsxs)(h,{children:[(0,D.jsx)(v,{children:t(`secrets`)}),(0,D.jsx)(x,{children:t(`secretsEnabledHelp`)})]}),(0,D.jsxs)(g,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl border border-gray-200 p-3`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`p`,{className:`text-sm font-medium text-gray-800`,children:t(`enabled`)}),(0,D.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`secretsEnabledHelp`)})]}),(0,D.jsx)(T,{checked:N,onCheckedChange:P})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(S,{children:t(`defaultEnvProvider`)}),(0,D.jsxs)(u,{value:F||`__none__`,onValueChange:e=>I(e===`__none__`?``:e),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`noneOption`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]})]}),(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(S,{children:t(`defaultFileProvider`)}),(0,D.jsxs)(u,{value:L||`__none__`,onValueChange:e=>R(e===`__none__`?``:e),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`noneOption`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]})]}),(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(S,{children:t(`defaultExecProvider`)}),(0,D.jsxs)(u,{value:z||`__none__`,onValueChange:e=>B(e===`__none__`?``:e),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`noneOption`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]})]})]})]})]}),(0,D.jsxs)(m,{children:[(0,D.jsxs)(h,{children:[(0,D.jsx)(v,{children:t(`secretProvidersTitle`)}),(0,D.jsx)(x,{children:t(`secretProvidersDescription`)})]}),(0,D.jsxs)(g,{className:`space-y-3`,children:[V.map((e,n)=>(0,D.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,D.jsx)(b,{value:e.alias,onChange:e=>K(n,{alias:e.target.value}),placeholder:t(`providerAlias`)}),(0,D.jsxs)(u,{value:e.source,onValueChange:e=>K(n,{source:e}),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{})}),(0,D.jsx)(c,{children:O.map(e=>(0,D.jsx)(l,{value:e,children:e},e))})]}),(0,D.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>H(e=>e.filter((e,t)=>t!==n)),children:[(0,D.jsx)(p,{className:`h-4 w-4 mr-2`}),t(`removeProvider`)]})]}),e.source===`env`&&(0,D.jsx)(b,{value:e.prefix,onChange:e=>K(n,{prefix:e.target.value}),placeholder:t(`envPrefix`)}),e.source===`file`&&(0,D.jsx)(b,{value:e.path,onChange:e=>K(n,{path:e.target.value}),placeholder:t(`secretFilePath`)}),e.source===`exec`&&(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(b,{value:e.command,onChange:e=>K(n,{command:e.target.value}),placeholder:t(`secretExecCommand`)}),(0,D.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:e.argsText,onChange:e=>K(n,{argsText:e.target.value}),placeholder:t(`secretExecArgs`)}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2`,children:[(0,D.jsx)(b,{value:e.cwd,onChange:e=>K(n,{cwd:e.target.value}),placeholder:t(`secretExecCwd`)}),(0,D.jsx)(b,{type:`number`,min:1,value:e.timeoutMs,onChange:e=>K(n,{timeoutMs:Number.parseInt(e.target.value,10)||5e3}),placeholder:t(`secretExecTimeoutMs`)})]})]})]},`provider-${n}`)),(0,D.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>H(e=>[...e,k()]),children:[(0,D.jsx)(d,{className:`h-4 w-4 mr-2`}),t(`addSecretProvider`)]})]})]}),(0,D.jsxs)(m,{children:[(0,D.jsxs)(h,{children:[(0,D.jsx)(v,{children:t(`secretRefsTitle`)}),(0,D.jsx)(x,{children:t(`secretRefsDescription`)})]}),(0,D.jsxs)(g,{className:`space-y-3`,children:[U.map((e,n)=>(0,D.jsx)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,D.jsx)(b,{value:e.path,onChange:e=>q(n,{path:e.target.value}),placeholder:t(`secretConfigPath`)}),(0,D.jsx)(b,{value:e.id,onChange:e=>q(n,{id:e.target.value}),placeholder:t(`secretId`)}),(0,D.jsxs)(u,{value:e.source,onValueChange:e=>q(n,{source:e}),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{})}),(0,D.jsx)(c,{children:O.map(e=>(0,D.jsx)(l,{value:e,children:e},e))})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-2`,children:[(0,D.jsxs)(u,{value:e.provider||`__none__`,onValueChange:e=>q(n,{provider:e===`__none__`?``:e}),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`secretProviderAlias`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]}),(0,D.jsx)(a,{type:`button`,variant:`outline`,onClick:()=>W(e=>e.filter((e,t)=>t!==n)),children:(0,D.jsx)(p,{className:`h-4 w-4`})})]})]})},`ref-${n}`)),(0,D.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>W(e=>[...e,A()]),children:[(0,D.jsx)(d,{className:`h-4 w-4 mr-2`}),t(`addSecretRef`)]})]})]}),(0,D.jsx)(`div`,{className:`flex justify-end`,children:(0,D.jsxs)(a,{type:`button`,onClick:()=>{try{let e={};for(let[n,r]of V.entries()){let i=r.alias.trim();if(!i)throw Error(`${t(`providerAlias`)} #${n+1} ${t(`isRequired`)}`);if(e[i])throw Error(`${t(`providerAlias`)}: ${i} (${t(`duplicate`)})`);if(r.source===`file`&&!r.path.trim())throw Error(`${t(`secretFilePath`)} #${n+1} ${t(`isRequired`)}`);if(r.source===`exec`&&!r.command.trim())throw Error(`${t(`secretExecCommand`)} #${n+1} ${t(`isRequired`)}`);e[i]=M(r)}let n={};for(let[r,i]of U.entries()){let a=i.path.trim(),o=i.id.trim();if(!a)throw Error(`${t(`secretConfigPath`)} #${r+1} ${t(`isRequired`)}`);if(!o)throw Error(`${t(`secretId`)} #${r+1} ${t(`isRequired`)}`);let s=i.provider.trim();if(s&&!e[s])throw Error(`${t(`secretProviderAlias`)}: ${s} ${t(`notFound`)}`);n[a]={source:i.source,...s?{provider:s}:{},id:o}}r.mutate({data:{enabled:N,defaults:{env:F.trim()||null,file:L.trim()||null,exec:z.trim()||null},providers:e,refs:n}})}catch(e){let t=e instanceof Error?e.message:String(e);i.error(t)}},disabled:r.isPending,children:[(0,D.jsx)(f,{className:`h-4 w-4 mr-2`}),r.isPending?t(`saving`):t(`save`)]})})]})}export{N as SecretsConfig};
@@ -1 +0,0 @@
1
- import{A as e,C as t,E as n,S as r,T as i,b as a,c as o,d as s,f as c,k as l,m as u,p as d,w as f,x as p,y as m}from"./client-_i4MU2bB.js";import{r as h}from"./infiniteQueryBehavior-ZDS92Qpp.js";var g=class extends e{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new o({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=_(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=_(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=_(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=_(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){d.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>r(t,e))}findAll(e={}){return this.getAll().filter(t=>r(e,t))}notify(e){d.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return d.batch(()=>Promise.all(e.map(e=>e.continue().catch(f))))}};function _(e){return e.options.scope?.id}var v=class extends e{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??p(r,t),a=this.get(i);return a||(a=new s({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){d.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let n={exact:!0,...e};return this.getAll().find(e=>t(n,e))}findAll(e={}){let n=this.getAll();return Object.keys(e).length>0?n.filter(n=>t(e,n)):n}notify(e){d.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){d.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){d.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},y=new class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new v,this.#t=e.mutationCache||new g,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=u.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=c.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=this.#e.build(this,t),i=r.state.data;return i===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(n(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(i))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=m(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return d.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;d.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return d.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=d.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(f).catch(f)}invalidateQueries(e,t={}){return d.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=d.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(f)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(f)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let r=this.#e.build(this,t);return r.isStaleByTime(n(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(f).catch(f)}fetchInfiniteQuery(e){return e.behavior=h(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(f).catch(f)}ensureInfiniteQueryData(e){return e.behavior=h(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return c.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(a(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{i(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(a(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{i(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=p(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===l&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}}({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!0}}});export{y as t};