@nextclaw/ui 0.12.20-beta.0 → 0.12.20-beta.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 (90) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/assets/api-BcqDx0tm.js +15 -0
  3. package/dist/assets/app-manager-provider-DVYBjif-.js +1 -0
  4. package/dist/assets/{app-navigation.config-BORqHkbN.js → app-navigation.config-BOVDFMnp.js} +1 -1
  5. package/dist/assets/{channels-list-page-sISO_4Yj.js → channels-list-page-CsoI4OJm.js} +2 -2
  6. package/dist/assets/{chat-ChCu7LQD.js → chat-ahMH_i_K.js} +6 -6
  7. package/dist/assets/chat-page-BxlXY-MB.js +1 -0
  8. package/dist/assets/chunk-JZWAC4HX-u4uYphxM.js +3 -0
  9. package/dist/assets/{desktop-update-config-BfJ5iSeY.js → desktop-update-config-CD6-2PfI.js} +1 -1
  10. package/dist/assets/{dialog-B-CXiFPZ.js → dialog-csshWetU.js} +1 -1
  11. package/dist/assets/{dist-DYVfg3q5.js → dist-Bl94Ahwx.js} +1 -1
  12. package/dist/assets/{es2015-BXroVnPi.js → es2015-JCM5-KtW.js} +1 -1
  13. package/dist/assets/index-CM-57d8J.js +2 -0
  14. package/dist/assets/index-D8MKmXtO.css +1 -0
  15. package/dist/assets/marketplace-page-DJGDpTAo.js +1 -0
  16. package/dist/assets/{marketplace-page-C9oZ01rM.js → marketplace-page-DxlxHCFm.js} +2 -2
  17. package/dist/assets/{mcp-marketplace-page-DuEixgSs.js → mcp-marketplace-page-5UjYRWOR.js} +2 -2
  18. package/dist/assets/mcp-marketplace-page-C1XaHZZO.js +1 -0
  19. package/dist/assets/{model-config-mfhqEZBG.js → model-config-PccJ9XyH.js} +1 -1
  20. package/dist/assets/{notice-card-CozHB03G.js → notice-card-CCgk6FvF.js} +1 -1
  21. package/dist/assets/{popover-CPUPma-w.js → popover-YAsxDBhY.js} +1 -1
  22. package/dist/assets/{provider-scoped-model-input-CL9sti2I.js → provider-scoped-model-input-CzpF7cug.js} +1 -1
  23. package/dist/assets/{providers-list-HPmL2akJ.js → providers-list-8qDMER8o.js} +1 -1
  24. package/dist/assets/remote-D4TtLPAp.js +1 -0
  25. package/dist/assets/runtime-config-page-DWJHrV7H.js +1 -0
  26. package/dist/assets/{search-config-Bcnk9VlL.js → search-config-D3a65l3r.js} +1 -1
  27. package/dist/assets/{secrets-config-Dde-5Y1w.js → secrets-config-CoMlR_7i.js} +2 -2
  28. package/dist/assets/{select-BELPuXLW.js → select-DIZrwsKU.js} +1 -1
  29. package/dist/assets/{sessions-config-page-CG49_0Z6.js → sessions-config-page-QjH5tgjr.js} +2 -2
  30. package/dist/assets/{setting-row-D5DtT6Ny.js → setting-row-DiQyrE81.js} +1 -1
  31. package/dist/assets/{tag-chip-D9BWWgYg.js → tag-chip-C3wDBe_-.js} +1 -1
  32. package/dist/assets/theme-provider-W704JWF8.js +1 -0
  33. package/dist/assets/{tooltip-CI0rpNee.js → tooltip-Dq5Xehpk.js} +1 -1
  34. package/dist/assets/use-config-BQJjq1mP.js +1 -0
  35. package/dist/assets/{use-confirm-dialog-hbynwWf2.js → use-confirm-dialog-DBoV5n5P.js} +1 -1
  36. package/dist/assets/{use-infinite-scroll-loader-Cw5qQr3-.js → use-infinite-scroll-loader-JAicqVC5.js} +1 -1
  37. package/dist/assets/{use-viewport-layout-CWHVDC6z.js → use-viewport-layout-BX3XqzJ4.js} +1 -1
  38. package/dist/index.html +17 -17
  39. package/package.json +8 -6
  40. package/src/app/hooks/use-realtime-query-bridge.ts +5 -5
  41. package/src/features/channels/components/config/channel-form.tsx +3 -3
  42. package/src/features/chat/hooks/use-ncp-chat-page-data.ts +7 -6
  43. package/src/features/chat/pages/ncp-chat-page.test.ts +22 -8
  44. package/src/features/chat/utils/chat-session-preference-governance.utils.test.tsx +114 -0
  45. package/src/features/chat/utils/chat-session-preference-governance.utils.ts +30 -36
  46. package/src/shared/components/common/brand-header.test.tsx +7 -2
  47. package/src/shared/components/common/brand-header.tsx +34 -4
  48. package/src/shared/lib/api/index.ts +12 -12
  49. package/src/shared/lib/api/ncp-session.test.ts +17 -18
  50. package/src/shared/lib/api/raw-client.utils.ts +3 -126
  51. package/src/shared/lib/api/services/agents.service.ts +18 -0
  52. package/src/shared/lib/api/services/channel-auth.service.ts +21 -0
  53. package/src/shared/lib/api/{client.ts → services/client.service.ts} +45 -1
  54. package/src/shared/lib/api/services/config.service.ts +171 -0
  55. package/src/shared/lib/api/services/marketplace.service.ts +66 -0
  56. package/src/shared/lib/api/services/mcp-marketplace.service.ts +70 -0
  57. package/src/shared/lib/api/services/ncp-attachments.service.ts +14 -0
  58. package/src/shared/lib/api/services/ncp-session.service.ts +39 -0
  59. package/src/shared/lib/api/services/remote.service.ts +50 -0
  60. package/src/shared/lib/api/services/runtime-control.service.ts +18 -0
  61. package/src/shared/lib/api/services/runtime-update.service.ts +26 -0
  62. package/src/shared/lib/api/services/server-path.service.ts +16 -0
  63. package/src/shared/lib/transport/index.ts +1 -0
  64. package/src/shared/lib/transport/local-transport.service.ts +24 -4
  65. package/src/shared/lib/transport/remote-transport.service.ts +1 -1
  66. package/src/shared/lib/transport/request-raw-api-response.utils.ts +133 -0
  67. package/src/shared/lib/transport/transport.types.ts +8 -2
  68. package/dist/assets/api-C412zuay.js +0 -15
  69. package/dist/assets/app-manager-provider-Cm-KiZZG.js +0 -1
  70. package/dist/assets/chat-page-BCaNZJGT.js +0 -1
  71. package/dist/assets/chunk-JZWAC4HX-DvbcIVPf.js +0 -3
  72. package/dist/assets/index-CUmk8xFK.css +0 -1
  73. package/dist/assets/index-CqPDhosM.js +0 -2
  74. package/dist/assets/marketplace-page-C8uaWkfd.js +0 -1
  75. package/dist/assets/mcp-marketplace-page-rNqr6ZpD.js +0 -1
  76. package/dist/assets/remote-oDlAdgVA.js +0 -1
  77. package/dist/assets/runtime-config-page-BCshTAAE.js +0 -1
  78. package/dist/assets/theme-provider-DeBrTglS.js +0 -1
  79. package/dist/assets/use-config-CrWZ_TSF.js +0 -1
  80. package/src/shared/lib/api/agents.ts +0 -34
  81. package/src/shared/lib/api/channel-auth.ts +0 -35
  82. package/src/shared/lib/api/config.ts +0 -362
  83. package/src/shared/lib/api/marketplace.ts +0 -156
  84. package/src/shared/lib/api/mcp-marketplace.ts +0 -138
  85. package/src/shared/lib/api/ncp-attachments.ts +0 -41
  86. package/src/shared/lib/api/ncp-session.ts +0 -78
  87. package/src/shared/lib/api/remote.ts +0 -86
  88. package/src/shared/lib/api/runtime-control.ts +0 -34
  89. package/src/shared/lib/api/runtime-update.service.ts +0 -50
  90. package/src/shared/lib/api/server-path.ts +0 -46
@@ -1 +0,0 @@
1
- import{_ as e,i as t,m as n,p as r,u as i}from"./i18n-C5Mibli1.js";import{Ct as a,Dt as o,Et as s,It as c,Mt as l,St as u,Tt as d,_t as ee,ht as f,mt as p,wt as te,xt as m}from"./api-C412zuay.js";import{r as h}from"./chunk-JZWAC4HX-DvbcIVPf.js";import{t as g}from"./createLucideIcon-BZkY6emz.js";import{i as _,n as v,t as y}from"./select-BELPuXLW.js";import{n as b,t as ne}from"./refresh-cw-BxojR62w.js";import{t as re}from"./x-DpTzXQcX.js";import{t as ie}from"./use-config-CrWZ_TSF.js";import{n as ae,r as oe,t as se}from"./popover-CPUPma-w.js";var ce=g(`AlarmClock`,[[`circle`,{cx:`12`,cy:`13`,r:`8`,key:`3y4lt7`}],[`path`,{d:`M12 9v4l2 2`,key:`1c63tq`}],[`path`,{d:`M5 3 2 6`,key:`18tl5t`}],[`path`,{d:`m22 6-3-3`,key:`1opdir`}],[`path`,{d:`M6.38 18.7 4 21`,key:`17xu3x`}],[`path`,{d:`M17.64 18.67 20 21`,key:`kv2oe2`}]]),le=g(`Bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),ue=g(`BrainCircuit`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M9 13a4.5 4.5 0 0 0 3-4`,key:`10igwf`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M12 13h4`,key:`1ku699`}],[`path`,{d:`M12 18h6a2 2 0 0 1 2 2v1`,key:`105ag5`}],[`path`,{d:`M12 8h8`,key:`1lhi5i`}],[`path`,{d:`M16 8V5a2 2 0 0 1 2-2`,key:`u6izg6`}],[`circle`,{cx:`16`,cy:`13`,r:`.5`,key:`ry7gng`}],[`circle`,{cx:`18`,cy:`3`,r:`.5`,key:`1aiba7`}],[`circle`,{cx:`20`,cy:`21`,r:`.5`,key:`yhc1fs`}],[`circle`,{cx:`20`,cy:`8`,r:`.5`,key:`1e43v0`}]]),de=g(`Languages`,[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),fe=g(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),pe=g(`Palette`,[[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`path`,{d:`M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z`,key:`12rzf8`}]]),me=g(`Smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),he=g(`Wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`,key:`cbrjhi`}]]),x=`nextclaw.ui.theme`,ge=[{value:`warm`,labelKey:`themeWarm`},{value:`cool`,labelKey:`themeCool`}],S=`warm`,C=!1,w=new Set;function T(e){return e===`warm`||e===`cool`}function E(e){typeof document>`u`||document.documentElement.setAttribute(`data-theme`,e)}function D(){if(typeof window>`u`)return`warm`;try{let e=window.localStorage.getItem(x);if(T(e))return e}catch{}return`warm`}function O(){return C||=(S=D(),E(S),!0),S}function k(){return C?S:O()}function A(e){if(O(),e!==S){if(S=e,E(S),typeof window<`u`)try{window.localStorage.setItem(x,S)}catch{}w.forEach(e=>e(S))}}function j(e){return w.add(e),()=>{w.delete(e)}}var M=r(),N={healthy:`bg-emerald-500 shadow-[0_0_0_3px_rgba(16,185,129,0.14)]`,attention:`bg-amber-400 shadow-[0_0_0_3px_rgba(251,191,36,0.16)]`,inactive:`bg-gray-300 shadow-[0_0_0_3px_rgba(156,163,175,0.12)]`};function P(){let e=ee(),n=e.actionLabel===t(`runtimeStatusRestartAction`),r=async()=>{if(n)try{let e=await m.runRuntimeControlAction(`restart-service`);c.success(e.message)}catch(e){let n=e instanceof Error?e.message:t(`runtimeControlActionFailed`);c.error(`${t(`runtimeControlActionFailed`)}: ${n}`)}};return(0,M.jsxs)(se,{children:[(0,M.jsx)(oe,{asChild:!0,children:(0,M.jsx)(`button`,{type:`button`,className:`inline-flex items-center justify-center rounded-full p-0.5 transition-transform hover:scale-105`,"aria-label":e.title,title:e.title,"data-testid":`runtime-status-entry`,children:(0,M.jsx)(`span`,{className:i(`h-2.5 w-2.5 rounded-full`,N[e.tone])})})}),(0,M.jsxs)(ae,{align:`start`,sideOffset:10,className:`w-[290px] space-y-3 rounded-2xl border border-gray-200 bg-white p-4`,children:[(0,M.jsxs)(`div`,{className:`space-y-1`,children:[(0,M.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:e.title}),(0,M.jsx)(`p`,{className:`text-xs leading-5 text-gray-600`,children:e.description})]}),e.reasonLines.length>0?(0,M.jsx)(`div`,{className:`space-y-2`,children:e.reasonLines.map(e=>(0,M.jsx)(`div`,{className:`rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-5 text-amber-900`,children:e},e))}):null,e.actionLabel?(0,M.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-100 pt-1`,children:[(0,M.jsx)(`span`,{className:`text-[11px] text-gray-500`,children:t(`runtimeStatusActionHint`)}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>void r(),disabled:e.isBusy,className:`text-sm font-semibold text-sky-600 transition-colors hover:text-sky-700 disabled:text-gray-400`,children:e.isBusy?t(`runtimeStatusRestartingAction`):e.actionLabel})]}):null]})]})}function F({className:e,suffix:t}){let{data:n}=ie(),r=n?.name??`NextClaw`,i=n?.productVersion?.trim(),a=t??(0,M.jsx)(P,{});return(0,M.jsxs)(`div`,{className:e??`flex items-center gap-2.5`,children:[(0,M.jsx)(`div`,{className:`h-7 w-7 rounded-lg overflow-hidden flex items-center justify-center`,children:(0,M.jsx)(`img`,{src:`/logo.svg`,alt:r,className:`h-full w-full object-contain`})}),(0,M.jsxs)(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[(0,M.jsx)(`span`,{className:`truncate text-[15px] font-semibold tracking-[-0.01em] text-gray-800`,children:r}),i?(0,M.jsxs)(`span`,{className:`text-[13px] font-medium text-gray-500`,children:[`v`,i]}):null,(0,M.jsx)(I,{}),a?(0,M.jsx)(`span`,{className:`inline-flex items-center shrink-0`,children:a}):null]})]})}function I(){let{supported:e,busyAction:n,snapshot:r}=f();return!e||!r?null:r.status===`downloading`||r.status===`blocked`||r.status===`failed`?(0,M.jsx)(L,{snapshot:r}):r.status===`downloaded`?(0,M.jsx)(`button`,{type:`button`,className:i(`inline-flex h-5 shrink-0 items-center rounded-full px-2 text-[11px] font-semibold leading-none ring-1 transition-colors`,R(r.status)),disabled:n===`applying`,onClick:()=>void p.applyDownloadedUpdate(),children:t(n===`applying`?`desktopUpdatesInlineApplying`:`desktopUpdatesInlineReady`)}):r.status===`update-available`?(0,M.jsx)(`button`,{type:`button`,className:i(`inline-flex h-5 shrink-0 items-center rounded-full px-2 text-[11px] font-semibold leading-none ring-1 transition-colors`,R(r.status)),disabled:n===`downloading`,onClick:()=>void p.downloadUpdate(),children:t(n===`downloading`?`desktopUpdatesInlineDownloading`:`desktopUpdatesInlineDownload`)}):null}function L({snapshot:e}){let n=_e(e);return n?(0,M.jsx)(`span`,{className:i(`inline-flex h-5 shrink-0 items-center rounded-full px-2 text-[11px] font-semibold leading-none ring-1 transition-colors`,R(e.status)),title:t(`updates`),children:n}):null}function _e(e){if(e.status===`downloading`){let n=e.progress?.percent;return n==null?t(`desktopUpdatesInlineDownloading`):t(`desktopUpdatesInlineDownloadingPercent`).replace(`{percent}`,String(n))}return e.status===`downloaded`?t(`desktopUpdatesInlineReady`):e.status===`update-available`?t(`desktopUpdatesInlineDownload`):e.status===`blocked`||e.status===`failed`?t(`desktopUpdatesInlineAttention`):null}function R(e){return e===`downloaded`?`bg-emerald-50 text-emerald-700 ring-emerald-100 hover:bg-emerald-100 disabled:opacity-70`:e===`blocked`||e===`failed`?`bg-red-50 text-red-700 ring-red-100`:`bg-amber-50 text-amber-700 ring-amber-100 hover:bg-amber-100 disabled:opacity-70`}var ve={default:{row:`gap-3 px-3 py-2.5 text-[14px]`,icon:`h-[17px] w-[17px]`,value:`text-xs`,gap:`gap-3`},compact:{row:`gap-2.5 px-3 py-2 text-[13px]`,icon:`h-4 w-4`,value:`text-[11px]`,gap:`gap-2.5`}};function z(e){return ve[e]}function ye({to:e,label:t,icon:n,density:r=`default`,className:a}){let o=z(r);return(0,M.jsx)(h,{to:e,className:({isActive:e})=>i(`group flex w-full items-center rounded-xl font-medium transition-colors duration-base`,o.row,e?`bg-gray-200 text-gray-900 shadow-sm`:`text-gray-600 hover:bg-gray-200/60 hover:text-gray-900`,a),children:({isActive:e})=>(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(n,{className:i(o.icon,`transition-colors`,e?`text-gray-900`:`text-gray-500 group-hover:text-gray-800`)}),(0,M.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:t})]})})}function be({label:e,icon:t,onClick:n,density:r=`default`,className:a,labelClassName:o,trailing:s,trailingClassName:c,testId:l,trailingTestId:u}){let d=z(r);return(0,M.jsxs)(`button`,{type:`button`,onClick:n,className:i(`flex w-full items-center rounded-xl font-medium text-gray-600 transition-all duration-base hover:bg-gray-200/60 hover:text-gray-800`,d.row,a),"data-testid":l,children:[(0,M.jsx)(t,{className:i(d.icon,`shrink-0 text-gray-400`)}),(0,M.jsx)(`span`,{className:i(`min-w-0 flex-1 text-left`,o),children:e}),s?(0,M.jsx)(`span`,{className:i(`shrink-0 text-gray-500`,d.value,c),"data-testid":u,children:s}):null]})}function xe({label:e,icon:t,value:n,valueLabel:r,onValueChange:a,density:o=`default`,children:s}){let c=z(o);return(0,M.jsxs)(y,{value:n,onValueChange:a,children:[(0,M.jsxs)(_,{className:i(`h-auto w-full rounded-xl border-0 bg-transparent font-medium text-gray-600 shadow-none hover:bg-gray-200/60 focus:ring-0`,c.row),children:[(0,M.jsxs)(`div`,{className:i(`flex min-w-0 items-center`,c.gap),children:[(0,M.jsx)(t,{className:i(c.icon,`text-gray-400`)}),(0,M.jsx)(`span`,{className:`text-left`,children:e})]}),(0,M.jsx)(`span`,{className:i(`ml-auto text-gray-500`,c.value),children:r})]}),(0,M.jsx)(v,{children:s})]})}var B=`nextclaw-pwa-install-banner-dismissed`,V=`nextclaw-pwa-install-banner-dismissed-until`;function H(){let e=W();return e?e.getItem(`nextclaw-pwa-install-banner-dismissed`)===`1`?!0:Ce(e):!1}function Se(){let e=W();e?.setItem(B,`1`),e?.removeItem(V)}function U(){let e=W();e?.removeItem(B),e?.removeItem(V)}function W(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function Ce(e){let t=e.getItem(V);if(!t)return!1;let n=Number.parseInt(t,10);return e.removeItem(V),!Number.isFinite(n)||n<=Date.now()?!1:(e.setItem(B,`1`),!0)}function G(){return{initialized:!1,installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`,dismissedInstallPrompt:H(),updateAvailable:!1,registrationFailed:!1}}var K=u(()=>G()),q=`nextclaw-pwa-dev-sw-reset`,J=new class{constructor(){this.started=!1,this.registration=null,this.reloadWhenControllerChanges=!1,this.start=async()=>{if(!(this.started||typeof window>`u`)&&(this.started=!0,!(!(`serviceWorker`in navigator)||!this.isEligibleInstallContext()))){if(this.isDevelopmentServer()){await this.cleanupDevelopmentRegistrations();return}try{let e=await navigator.serviceWorker.register(`/sw.js`);this.registration=e,this.bindRegistration(e),navigator.serviceWorker.addEventListener(`controllerchange`,this.handleControllerChange),await this.syncUpdateAvailability()}catch{K.setState({registrationFailed:!0})}}},this.syncUpdateAvailability=async()=>{if(typeof window>`u`||!(`serviceWorker`in navigator)||typeof navigator.serviceWorker.getRegistration!=`function`){K.setState({updateAvailable:!1});return}let e=this.registration??await navigator.serviceWorker.getRegistration(`/sw.js`)??null;K.setState({updateAvailable:this.shouldSurfaceUpdate(e)})},this.applyUpdate=async()=>{let e=this.registration??await navigator.serviceWorker.getRegistration(`/sw.js`)??null;if(!e){window.location.reload();return}e.waiting||await e.update();let t=e.waiting;if(!t){window.location.reload();return}this.reloadWhenControllerChanges=!0,t.postMessage({type:`SKIP_WAIT`})},this.stop=()=>{!this.started||typeof window>`u`||!(`serviceWorker`in navigator)||(navigator.serviceWorker.removeEventListener(`controllerchange`,this.handleControllerChange),this.started=!1,this.registration=null,this.reloadWhenControllerChanges=!1)},this.bindRegistration=e=>{e.addEventListener(`updatefound`,()=>{let t=e.installing;t&&t.addEventListener(`statechange`,()=>{t.state===`installed`&&this.syncUpdateAvailability()})})},this.handleControllerChange=()=>{this.reloadWhenControllerChanges&&(this.reloadWhenControllerChanges=!1,window.location.reload())},this.isEligibleInstallContext=()=>window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>!1,this.shouldSurfaceUpdate=e=>!e?.waiting||!navigator.serviceWorker.controller?!1:K.getState().installability===`installed`,this.cleanupDevelopmentRegistrations=async()=>{if(typeof navigator.serviceWorker.getRegistrations!=`function`)return;let e=(await navigator.serviceWorker.getRegistrations()).filter(e=>[e.active?.scriptURL,e.installing?.scriptURL,e.waiting?.scriptURL].filter(e=>!!e).some(e=>e.endsWith(`/sw.js`)));if(e.length===0){this.clearDevResetMarker();return}if(await Promise.all(e.map(async e=>await e.unregister())),await this.clearNextClawCaches(),navigator.serviceWorker.controller&&!this.hasDevResetMarker()){this.setDevResetMarker(),window.location.reload();return}this.clearDevResetMarker()},this.clearNextClawCaches=async()=>{if(typeof window>`u`||!(`caches`in window)||typeof caches.keys!=`function`)return;let e=await caches.keys();await Promise.all(e.filter(e=>e.startsWith(`nextclaw-ui-`)).map(async e=>await caches.delete(e)))},this.hasDevResetMarker=()=>{try{return window.sessionStorage.getItem(q)===`1`}catch{return!1}},this.setDevResetMarker=()=>{try{window.sessionStorage.setItem(q,`1`)}catch{}},this.clearDevResetMarker=()=>{try{window.sessionStorage.removeItem(q)}catch{}}}},Y=new class{constructor(){this.started=!1,this.deferredPrompt=null,this.displayModeMediaQuery=null,this.start=()=>{this.started||typeof window>`u`||(this.started=!0,window.addEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.addEventListener(`appinstalled`,this.handleAppInstalled),typeof window.matchMedia==`function`&&(this.displayModeMediaQuery=window.matchMedia(`(display-mode: standalone)`),this.bindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged)),this.refreshState())},this.stop=()=>{!this.started||typeof window>`u`||(window.removeEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.removeEventListener(`appinstalled`,this.handleAppInstalled),this.displayModeMediaQuery&&=(this.unbindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged),null),this.deferredPrompt=null,this.started=!1)},this.resetForTests=()=>{this.stop(),K.setState(G())},this.refreshState=()=>{let e=this.resolveInstallability();K.setState(t=>({...t,initialized:!0,installability:e.installability,installMethod:e.installMethod,blockedReason:e.blockedReason,dismissedInstallPrompt:H()})),J.syncUpdateAvailability()},this.dismissInstallPrompt=()=>{Se(),K.setState({dismissedInstallPrompt:!0})},this.promptInstall=async()=>{let e=this.resolveInstallability();if(e.installability!==`available`)return`unavailable`;if(e.installMethod===`manual`||!this.deferredPrompt)return`manual`;this.deferredPrompt.prompt();let n=await this.deferredPrompt.userChoice;return this.deferredPrompt=null,n.outcome===`accepted`?(U(),this.refreshState(),c.success(t(`pwaInstallAccepted`)),`accepted`):(this.dismissInstallPrompt(),this.refreshState(),`dismissed`)},this.handleBeforeInstallPrompt=e=>{e.preventDefault(),this.deferredPrompt=e,this.refreshState()},this.handleAppInstalled=()=>{this.deferredPrompt=null,U(),K.setState({dismissedInstallPrompt:!0}),c.success(t(`pwaInstalledToast`)),this.refreshState()},this.handleDisplayModeChanged=()=>{this.refreshState()},this.resolveInstallability=()=>this.isDevelopmentServer()?{installability:`unsupported`,installMethod:`none`,blockedReason:`dev-server`}:this.hasDesktopHost()?{installability:`suppressed`,installMethod:`none`,blockedReason:`desktop-host`}:this.isStandalone()?{installability:`installed`,installMethod:`none`,blockedReason:null}:this.hasInstallSurfaceSupport()?this.isEligibleInstallContext()?{installability:`available`,installMethod:this.deferredPrompt?`prompt`:`manual`,blockedReason:null}:{installability:`unsupported`,installMethod:`none`,blockedReason:`insecure-context`}:{installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`},this.hasDesktopHost=()=>typeof window<`u`&&!!window.nextclawDesktop,this.hasInstallSurfaceSupport=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&`serviceWorker`in navigator,this.isEligibleInstallContext=()=>typeof window>`u`?!1:window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>typeof window<`u`&&!1,this.isStandalone=()=>{if(typeof window>`u`)return!1;let e=window.navigator;return typeof window.matchMedia==`function`&&window.matchMedia(`(display-mode: standalone)`).matches||e.standalone===!0},this.bindDisplayModeListener=(e,t)=>{if(`addEventListener`in e){e.addEventListener(`change`,t);return}e.addListener?.(t)},this.unbindDisplayModeListener=(e,t)=>{if(`removeEventListener`in e){e.removeEventListener(`change`,t);return}e.removeListener?.(t)}}};function we(){let e=K(e=>e.installability);return(0,M.jsx)(`span`,{className:i(`inline-flex items-center rounded-full border px-3 py-1 text-xs font-medium`,e===`installed`?`bg-emerald-50 text-emerald-700 border-emerald-200`:e===`available`?`bg-amber-50 text-amber-700 border-amber-200`:`bg-gray-100 text-gray-600 border-gray-200`),children:Te(e)})}function Te(e){return t(e===`available`?`pwaInstallStatusAvailable`:e===`installed`?`pwaInstallStatusInstalled`:e===`suppressed`?`pwaInstallStatusDesktopHost`:`pwaInstallStatusUnavailable`)}function Ee(e,n,r){return t(e===`installed`?`pwaInstallCardInstalled`:e===`suppressed`?`pwaInstallCardSuppressed`:e===`available`&&n===`prompt`?`pwaInstallCardPrompt`:e===`available`?`pwaInstallCardManual`:r===`insecure-context`?`pwaInstallCardInsecureContext`:r===`dev-server`?`pwaInstallCardDevServer`:`pwaInstallCardUnsupported`)}function De(){let e=K(e=>e.installability),n=K(e=>e.installMethod),r=K(e=>e.blockedReason);return(0,M.jsxs)(a,{children:[(0,M.jsxs)(s,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(o,{children:t(`pwaInstallTitle`)}),(0,M.jsx)(d,{children:t(`pwaInstallDescription`)})]}),(0,M.jsx)(we,{})]}),(0,M.jsxs)(te,{className:`space-y-4`,children:[(0,M.jsx)(`div`,{className:`rounded-2xl border border-gray-200 bg-gray-50/90 p-4`,children:(0,M.jsx)(`p`,{className:`text-sm leading-6 text-gray-700`,children:Ee(e,n,r)})}),e===`available`&&n===`prompt`?(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,M.jsxs)(l,{type:`button`,className:`gap-2`,onClick:()=>{Y.promptInstall()},children:[(0,M.jsx)(b,{className:`h-4 w-4`}),t(`pwaInstallAction`)]}),(0,M.jsx)(`p`,{className:`text-sm text-gray-500`,children:t(`pwaInstallPromptHint`)})]}):null,e===`available`&&n===`manual`?(0,M.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl border border-dashed border-gray-300 bg-white p-4`,children:[(0,M.jsx)(me,{className:`mt-0.5 h-4 w-4 text-gray-500`}),(0,M.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:t(`pwaInstallManualHint`)})]}):null]})]})}function Oe(){let e=K(e=>e.installability),n=K(e=>e.installMethod),r=K(e=>e.dismissedInstallPrompt);return e!==`available`||n!==`prompt`||r?null:(0,M.jsxs)(`div`,{className:`fixed bottom-5 right-5 z-50 w-[min(420px,calc(100vw-2rem))] rounded-[26px] border border-gray-200 bg-white/95 p-5 shadow-2xl backdrop-blur-xl`,children:[(0,M.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,M.jsxs)(`div`,{className:`space-y-1`,children:[(0,M.jsx)(`p`,{className:`text-sm font-semibold text-gray-900`,children:t(`pwaInstallBannerTitle`)}),(0,M.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:t(`pwaInstallBannerDescription`)})]}),(0,M.jsx)(`button`,{type:`button`,"aria-label":t(`pwaInstallDismiss`),className:`rounded-full p-1 text-gray-400 transition hover:bg-gray-100 hover:text-gray-600`,onClick:()=>{Y.dismissInstallPrompt()},children:(0,M.jsx)(re,{className:`h-4 w-4`})})]}),(0,M.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,M.jsxs)(l,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{Y.promptInstall()},children:[(0,M.jsx)(b,{className:`h-4 w-4`}),t(`pwaInstallAction`)]}),(0,M.jsx)(l,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{Y.dismissInstallPrompt()},children:t(`pwaInstallDismiss`)})]})]})}function ke(){let e=K(e=>e.updateAvailable),n=K(e=>e.installability);return!e||n!==`installed`?null:(0,M.jsxs)(`div`,{className:`fixed top-5 right-5 z-50 w-[min(420px,calc(100vw-2rem))] rounded-[26px] border border-gray-200 bg-white/95 p-5 shadow-2xl backdrop-blur-xl`,children:[(0,M.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,M.jsxs)(`div`,{className:`space-y-1`,children:[(0,M.jsx)(`p`,{className:`text-sm font-semibold text-gray-900`,children:t(`pwaUpdateBannerTitle`)}),(0,M.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:t(`pwaUpdateBannerDescription`)})]})}),(0,M.jsx)(`div`,{className:`mt-4`,children:(0,M.jsxs)(l,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{J.applyUpdate()},children:[(0,M.jsx)(ne,{className:`h-4 w-4`}),t(`pwaUpdateAction`)]})})]})}var X=!1;function Z(){X||typeof window>`u`||(X=!0,Y.start(),J.start())}var Ae={warm:`#F9F8F5`,cool:`#F8FAFB`},je=new class{constructor(){this.syncTheme=e=>{if(typeof document>`u`)return;let t=Ae[e];this.updateThemeMeta(t),this.updateSurfaceBackgrounds(t),document.documentElement.style.colorScheme=`light`},this.syncCurrentTheme=()=>{if(typeof document>`u`)return;let e=document.documentElement.getAttribute(`data-theme`)===`cool`?`cool`:`warm`;this.syncTheme(e)},this.updateThemeMeta=e=>{let t=document.querySelector(`meta[name="theme-color"]`);t instanceof HTMLMetaElement&&(t.content=e)},this.updateSurfaceBackgrounds=e=>{document.documentElement.style.backgroundColor=e,document.body.style.backgroundColor=e;let t=document.getElementById(`root`);t&&(t.style.backgroundColor=e)}}},Q=e(n(),1),$=(0,Q.createContext)(null);function Me({children:e}){let[t,n]=(0,Q.useState)(()=>O());(0,Q.useEffect)(()=>{je.syncTheme(t)},[t]),(0,Q.useEffect)(()=>j(e=>{n(e)}),[]);let r=(0,Q.useCallback)(e=>{A(e),n(k())},[]),i=(0,Q.useMemo)(()=>({theme:t,setTheme:r}),[t,r]);return(0,M.jsx)($.Provider,{value:i,children:e})}function Ne(){let e=(0,Q.useContext)($);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}export{le as _,De as a,ye as c,ge as d,he as f,ue as g,de as h,Oe as i,xe as l,fe as m,Ne as n,ke as o,pe as p,Z as r,be as s,Me as t,F as u,ce as v};
@@ -1 +0,0 @@
1
- import{i as e}from"./i18n-C5Mibli1.js";import{$ as t,B as n,F as r,G as i,I as a,It as o,J as s,K as c,L as l,Lt as u,N as d,P as f,Q as p,R as m,Rt as h,U as g,V as _,Vt as v,W as y,X as b,Y as x,Z as S,_ as C,et as w,g as T,h as E,m as D,p as O,q as k,v as A,y as j,z as M}from"./api-C412zuay.js";function ee(){return h({queryKey:[`config`],queryFn:m,staleTime:3e4,refetchOnWindowFocus:!0})}function N(){return h({queryKey:[`app-meta`],queryFn:l,staleTime:1/0})}function P(){return h({queryKey:[`config-meta`],queryFn:M,staleTime:1/0})}function F(){return h({queryKey:[`config-schema`],queryFn:n,staleTime:1/0})}function I(){let t=v();return u({mutationFn:b,onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),o.success(e(`configSaved`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function L(){let n=v();return u({mutationFn:({data:e})=>t(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`config`]}),n.invalidateQueries({queryKey:[`config-meta`]}),o.success(e(`configSavedApplied`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function R(){let t=v();return u({mutationFn:({provider:e,data:t})=>S(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),t.invalidateQueries({queryKey:[`config-meta`]}),o.success(e(`configSaved`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function z(){let t=v();return u({mutationFn:({data:e})=>d(e??{}),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),t.invalidateQueries({queryKey:[`config-meta`]}),o.success(e(`configSaved`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function B(){let t=v();return u({mutationFn:({provider:e})=>r(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),t.invalidateQueries({queryKey:[`config-meta`]}),o.success(e(`configSaved`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function V(){return u({mutationFn:({provider:e,data:t})=>s(e,t)})}function H(){return u({mutationFn:({provider:e,data:t})=>k(e,t)})}function U(){return u({mutationFn:({provider:e,data:t})=>y(e,t)})}function W(){return u({mutationFn:({provider:e})=>g(e)})}function G(){let t=v();return u({mutationFn:({channel:e,data:t})=>x(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),t.invalidateQueries({queryKey:[`config-meta`]}),o.success(e(`configSavedApplying`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function K(){let t=v();return u({mutationFn:({data:e})=>p(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),o.success(e(`configSavedApplied`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function q(){let t=v();return u({mutationFn:({data:e})=>w(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),o.success(e(`configSavedApplied`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function J(){return u({mutationFn:({actionId:e,data:t})=>a(e,t),onError:t=>{o.error(e(`error`)+`: `+t.message)}})}function Y(e){return h({queryKey:[`ncp-sessions`,e?.limit??null],queryFn:()=>A(e),staleTime:5e3,retry:!1})}function X(e,t=200){return h({queryKey:[`ncp-session-messages`,e,t],queryFn:()=>T(e,t),enabled:!!e,staleTime:5e3,retry:!1})}function Z(e){return h({queryKey:[`ncp-session-skills`,e.sessionId,e.projectRoot??null],queryFn:()=>C(e.sessionId,{...Object.prototype.hasOwnProperty.call(e,`projectRoot`)?{projectRoot:e.projectRoot??null}:{}}),enabled:!!e.sessionId,staleTime:5e3,retry:!1})}function Q(){let t=v();return u({mutationFn:({sessionId:e})=>E(e),onSuccess:(n,r)=>{O(t,r.sessionId),t.removeQueries({queryKey:[`ncp-session-messages`,r.sessionId]}),o.success(e(`configSavedApplied`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function $(){let t=v();return u({mutationFn:({sessionId:e,data:t})=>j(e,t),onSuccess:n=>{D(t,n),t.invalidateQueries({queryKey:[`ncp-session-skills`,n.sessionId]}),o.success(e(`configSavedApplied`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function te(e={all:!0}){return h({queryKey:[`cron`,e],queryFn:()=>_(e),staleTime:1e4})}function ne(){let t=v();return u({mutationFn:({id:e})=>f(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`cron`]}),o.success(e(`configSavedApplied`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function re(){let t=v();return u({mutationFn:({id:e,enabled:t})=>c(e,{enabled:t}),onSuccess:()=>{t.invalidateQueries({queryKey:[`cron`]}),o.success(e(`configSavedApplied`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function ie(){let t=v();return u({mutationFn:({id:e,force:t})=>i(e,{force:t}),onSuccess:()=>{t.invalidateQueries({queryKey:[`cron`]}),o.success(e(`configSavedApplied`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}export{R as C,q as E,$ as S,L as T,H as _,z as a,G as b,Q as c,W as d,X as f,ie as g,U as h,F as i,B as l,Y as m,ee as n,te as o,Z as p,P as r,ne as s,N as t,J as u,V as v,K as w,I as x,re as y};
@@ -1,34 +0,0 @@
1
- import { api } from "./client";
2
- import type { AgentCreateRequest, AgentDeleteResult, AgentProfileView, AgentUpdateRequest } from "./types";
3
-
4
- export async function fetchAgents(): Promise<{ agents: AgentProfileView[] }> {
5
- const response = await api.get<{ agents: AgentProfileView[] }>("/api/agents");
6
- if (!response.ok) {
7
- throw new Error(response.error.message);
8
- }
9
- return response.data;
10
- }
11
-
12
- export async function createAgent(data: AgentCreateRequest): Promise<AgentProfileView> {
13
- const response = await api.post<AgentProfileView>("/api/agents", data);
14
- if (!response.ok) {
15
- throw new Error(response.error.message);
16
- }
17
- return response.data;
18
- }
19
-
20
- export async function updateAgent(agentId: string, data: AgentUpdateRequest): Promise<AgentProfileView> {
21
- const response = await api.put<AgentProfileView>(`/api/agents/${encodeURIComponent(agentId)}`, data);
22
- if (!response.ok) {
23
- throw new Error(response.error.message);
24
- }
25
- return response.data;
26
- }
27
-
28
- export async function deleteAgent(agentId: string): Promise<AgentDeleteResult> {
29
- const response = await api.delete<AgentDeleteResult>(`/api/agents/${encodeURIComponent(agentId)}`);
30
- if (!response.ok) {
31
- throw new Error(response.error.message);
32
- }
33
- return response.data;
34
- }
@@ -1,35 +0,0 @@
1
- import { api } from './client';
2
- import type {
3
- ChannelAuthPollRequest,
4
- ChannelAuthPollResult,
5
- ChannelAuthStartRequest,
6
- ChannelAuthStartResult
7
- } from './channel-auth.types';
8
-
9
- export async function startChannelAuth(
10
- channel: string,
11
- data: ChannelAuthStartRequest = {}
12
- ): Promise<ChannelAuthStartResult> {
13
- const response = await api.post<ChannelAuthStartResult>(
14
- `/api/config/channels/${channel}/auth/start`,
15
- data
16
- );
17
- if (!response.ok) {
18
- throw new Error(response.error.message);
19
- }
20
- return response.data;
21
- }
22
-
23
- export async function pollChannelAuth(
24
- channel: string,
25
- data: ChannelAuthPollRequest
26
- ): Promise<ChannelAuthPollResult> {
27
- const response = await api.post<ChannelAuthPollResult>(
28
- `/api/config/channels/${channel}/auth/poll`,
29
- data
30
- );
31
- if (!response.ok) {
32
- throw new Error(response.error.message);
33
- }
34
- return response.data;
35
- }
@@ -1,362 +0,0 @@
1
- import { api } from './client';
2
- import type {
3
- AuthEnabledUpdateRequest,
4
- AuthLoginRequest,
5
- AuthPasswordUpdateRequest,
6
- AuthSetupRequest,
7
- AuthStatusView,
8
- AppMetaView,
9
- BootstrapStatusView,
10
- ConfigView,
11
- ConfigMetaView,
12
- ConfigSchemaResponse,
13
- ProviderConfigView,
14
- ChannelConfigUpdate,
15
- ProviderConfigUpdate,
16
- ProviderConnectionTestRequest,
17
- ProviderConnectionTestResult,
18
- ProviderAuthStartRequest,
19
- ProviderAuthStartResult,
20
- ProviderAuthPollRequest,
21
- ProviderAuthPollResult,
22
- ProviderAuthImportResult,
23
- SearchConfigUpdate,
24
- SearchConfigView,
25
- ProviderCreateRequest,
26
- ProviderCreateResult,
27
- ProviderDeleteResult,
28
- RuntimeConfigUpdate,
29
- SecretsConfigUpdate,
30
- SecretsView,
31
- ConfigActionExecuteRequest,
32
- ConfigActionExecuteResult,
33
- ChatSessionTypesView,
34
- CronListView,
35
- CronEnableRequest,
36
- CronRunRequest,
37
- CronActionResult
38
- } from './types';
39
-
40
- // GET /api/auth/status
41
- export async function fetchAuthStatus(options: { timeoutMs?: number } = {}): Promise<AuthStatusView> {
42
- const response = await api.get<AuthStatusView>('/api/auth/status', { timeoutMs: options.timeoutMs ?? 5_000 });
43
- if (!response.ok) {
44
- throw new Error(response.error.message);
45
- }
46
- return response.data;
47
- }
48
-
49
- // POST /api/auth/setup
50
- export async function setupAuth(data: AuthSetupRequest): Promise<AuthStatusView> {
51
- const response = await api.post<AuthStatusView>('/api/auth/setup', data);
52
- if (!response.ok) {
53
- throw new Error(response.error.message);
54
- }
55
- return response.data;
56
- }
57
-
58
- // POST /api/auth/login
59
- export async function loginAuth(data: AuthLoginRequest): Promise<AuthStatusView> {
60
- const response = await api.post<AuthStatusView>('/api/auth/login', data);
61
- if (!response.ok) {
62
- throw new Error(response.error.message);
63
- }
64
- return response.data;
65
- }
66
-
67
- // POST /api/auth/logout
68
- export async function logoutAuth(): Promise<{ success: boolean }> {
69
- const response = await api.post<{ success: boolean }>('/api/auth/logout', {});
70
- if (!response.ok) {
71
- throw new Error(response.error.message);
72
- }
73
- return response.data;
74
- }
75
-
76
- // PUT /api/auth/password
77
- export async function updateAuthPassword(data: AuthPasswordUpdateRequest): Promise<AuthStatusView> {
78
- const response = await api.put<AuthStatusView>('/api/auth/password', data);
79
- if (!response.ok) {
80
- throw new Error(response.error.message);
81
- }
82
- return response.data;
83
- }
84
-
85
- // PUT /api/auth/enabled
86
- export async function updateAuthEnabled(data: AuthEnabledUpdateRequest): Promise<AuthStatusView> {
87
- const response = await api.put<AuthStatusView>('/api/auth/enabled', data);
88
- if (!response.ok) {
89
- throw new Error(response.error.message);
90
- }
91
- return response.data;
92
- }
93
-
94
- // GET /api/app/meta
95
- export async function fetchAppMeta(): Promise<AppMetaView> {
96
- const response = await api.get<AppMetaView>('/api/app/meta');
97
- if (!response.ok) {
98
- throw new Error(response.error.message);
99
- }
100
- return response.data;
101
- }
102
-
103
- // GET /api/runtime/bootstrap-status
104
- export async function fetchBootstrapStatus(): Promise<BootstrapStatusView> {
105
- const response = await api.get<BootstrapStatusView>('/api/runtime/bootstrap-status');
106
- if (!response.ok) {
107
- throw new Error(response.error.message);
108
- }
109
- return response.data;
110
- }
111
-
112
- // GET /api/config
113
- export async function fetchConfig(): Promise<ConfigView> {
114
- const response = await api.get<ConfigView>('/api/config');
115
- if (!response.ok) {
116
- throw new Error(response.error.message);
117
- }
118
- return response.data;
119
- }
120
-
121
- // GET /api/config/meta
122
- export async function fetchConfigMeta(): Promise<ConfigMetaView> {
123
- const response = await api.get<ConfigMetaView>('/api/config/meta');
124
- if (!response.ok) {
125
- throw new Error(response.error.message);
126
- }
127
- return response.data;
128
- }
129
-
130
- // GET /api/config/schema
131
- export async function fetchConfigSchema(): Promise<ConfigSchemaResponse> {
132
- const response = await api.get<ConfigSchemaResponse>('/api/config/schema');
133
- if (!response.ok) {
134
- throw new Error(response.error.message);
135
- }
136
- return response.data;
137
- }
138
-
139
- // PUT /api/config/model
140
- export async function updateModel(data: { model: string; workspace?: string }): Promise<{ model: string; workspace?: string }> {
141
- const response = await api.put<{ model: string; workspace?: string }>('/api/config/model', data);
142
- if (!response.ok) {
143
- throw new Error(response.error.message);
144
- }
145
- return response.data;
146
- }
147
-
148
- // PUT /api/config/search
149
- export async function updateSearch(
150
- data: SearchConfigUpdate
151
- ): Promise<SearchConfigView> {
152
- const response = await api.put<SearchConfigView>('/api/config/search', data);
153
- if (!response.ok) {
154
- throw new Error(response.error.message);
155
- }
156
- return response.data;
157
- }
158
-
159
- // PUT /api/config/providers/:provider
160
- export async function updateProvider(
161
- provider: string,
162
- data: ProviderConfigUpdate
163
- ): Promise<ProviderConfigView> {
164
- const response = await api.put<ProviderConfigView>(
165
- `/api/config/providers/${provider}`,
166
- data
167
- );
168
- if (!response.ok) {
169
- throw new Error(response.error.message);
170
- }
171
- return response.data;
172
- }
173
-
174
- // POST /api/config/providers
175
- export async function createProvider(
176
- data: ProviderCreateRequest = {}
177
- ): Promise<ProviderCreateResult> {
178
- const response = await api.post<ProviderCreateResult>(
179
- '/api/config/providers',
180
- data
181
- );
182
- if (!response.ok) {
183
- throw new Error(response.error.message);
184
- }
185
- return response.data;
186
- }
187
-
188
- // DELETE /api/config/providers/:provider
189
- export async function deleteProvider(provider: string): Promise<ProviderDeleteResult> {
190
- const response = await api.delete<ProviderDeleteResult>(
191
- `/api/config/providers/${provider}`
192
- );
193
- if (!response.ok) {
194
- throw new Error(response.error.message);
195
- }
196
- return response.data;
197
- }
198
-
199
- // POST /api/config/providers/:provider/test
200
- export async function testProviderConnection(
201
- provider: string,
202
- data: ProviderConnectionTestRequest
203
- ): Promise<ProviderConnectionTestResult> {
204
- const response = await api.post<ProviderConnectionTestResult>(
205
- `/api/config/providers/${provider}/test`,
206
- data
207
- );
208
- if (!response.ok) {
209
- throw new Error(response.error.message);
210
- }
211
- return response.data;
212
- }
213
-
214
- // POST /api/config/providers/:provider/auth/start
215
- export async function startProviderAuth(
216
- provider: string,
217
- data: ProviderAuthStartRequest = {}
218
- ): Promise<ProviderAuthStartResult> {
219
- const response = await api.post<ProviderAuthStartResult>(
220
- `/api/config/providers/${provider}/auth/start`,
221
- data
222
- );
223
- if (!response.ok) {
224
- throw new Error(response.error.message);
225
- }
226
- return response.data;
227
- }
228
-
229
- // POST /api/config/providers/:provider/auth/poll
230
- export async function pollProviderAuth(
231
- provider: string,
232
- data: ProviderAuthPollRequest
233
- ): Promise<ProviderAuthPollResult> {
234
- const response = await api.post<ProviderAuthPollResult>(
235
- `/api/config/providers/${provider}/auth/poll`,
236
- data
237
- );
238
- if (!response.ok) {
239
- throw new Error(response.error.message);
240
- }
241
- return response.data;
242
- }
243
-
244
- // POST /api/config/providers/:provider/auth/import-cli
245
- export async function importProviderAuthFromCli(provider: string): Promise<ProviderAuthImportResult> {
246
- const response = await api.post<ProviderAuthImportResult>(
247
- `/api/config/providers/${provider}/auth/import-cli`,
248
- {}
249
- );
250
- if (!response.ok) {
251
- throw new Error(response.error.message);
252
- }
253
- return response.data;
254
- }
255
-
256
- // PUT /api/config/channels/:channel
257
- export async function updateChannel(
258
- channel: string,
259
- data: ChannelConfigUpdate
260
- ): Promise<Record<string, unknown>> {
261
- const response = await api.put<Record<string, unknown>>(
262
- `/api/config/channels/${channel}`,
263
- data
264
- );
265
- if (!response.ok) {
266
- throw new Error(response.error.message);
267
- }
268
- return response.data;
269
- }
270
-
271
- // PUT /api/config/runtime
272
- export async function updateRuntime(
273
- data: RuntimeConfigUpdate
274
- ): Promise<Pick<ConfigView, 'agents' | 'bindings' | 'session'>> {
275
- const response = await api.put<Pick<ConfigView, 'agents' | 'bindings' | 'session'>>(
276
- '/api/config/runtime',
277
- data
278
- );
279
- if (!response.ok) {
280
- throw new Error(response.error.message);
281
- }
282
- return response.data;
283
- }
284
-
285
- // PUT /api/config/secrets
286
- export async function updateSecrets(
287
- data: SecretsConfigUpdate
288
- ): Promise<SecretsView> {
289
- const response = await api.put<SecretsView>(
290
- '/api/config/secrets',
291
- data
292
- );
293
- if (!response.ok) {
294
- throw new Error(response.error.message);
295
- }
296
- return response.data;
297
- }
298
-
299
- // POST /api/config/actions/:id/execute
300
- export async function executeConfigAction(
301
- actionId: string,
302
- data: ConfigActionExecuteRequest
303
- ): Promise<ConfigActionExecuteResult> {
304
- const response = await api.post<ConfigActionExecuteResult>(
305
- `/api/config/actions/${actionId}/execute`,
306
- data
307
- );
308
- if (!response.ok) {
309
- throw new Error(response.error.message);
310
- }
311
- return response.data;
312
- }
313
-
314
- // GET /api/ncp/session-types
315
- export async function fetchNcpChatSessionTypes(): Promise<ChatSessionTypesView> {
316
- const response = await api.get<ChatSessionTypesView>('/api/ncp/session-types');
317
- if (!response.ok) {
318
- throw new Error(response.error.message);
319
- }
320
- return response.data;
321
- }
322
-
323
- // GET /api/cron
324
- export async function fetchCronJobs(params?: { all?: boolean }): Promise<CronListView> {
325
- const query = new URLSearchParams();
326
- if (params?.all) {
327
- query.set('all', '1');
328
- }
329
- const suffix = query.toString();
330
- const response = await api.get<CronListView>(suffix ? '/api/cron?' + suffix : '/api/cron');
331
- if (!response.ok) {
332
- throw new Error(response.error.message);
333
- }
334
- return response.data;
335
- }
336
-
337
- // DELETE /api/cron/:id
338
- export async function deleteCronJob(id: string): Promise<{ deleted: boolean }> {
339
- const response = await api.delete<{ deleted: boolean }>(`/api/cron/${encodeURIComponent(id)}`);
340
- if (!response.ok) {
341
- throw new Error(response.error.message);
342
- }
343
- return response.data;
344
- }
345
-
346
- // PUT /api/cron/:id/enable
347
- export async function setCronJobEnabled(id: string, data: CronEnableRequest): Promise<CronActionResult> {
348
- const response = await api.put<CronActionResult>(`/api/cron/${encodeURIComponent(id)}/enable`, data);
349
- if (!response.ok) {
350
- throw new Error(response.error.message);
351
- }
352
- return response.data;
353
- }
354
-
355
- // POST /api/cron/:id/run
356
- export async function runCronJob(id: string, data: CronRunRequest): Promise<CronActionResult> {
357
- const response = await api.post<CronActionResult>(`/api/cron/${encodeURIComponent(id)}/run`, data);
358
- if (!response.ok) {
359
- throw new Error(response.error.message);
360
- }
361
- return response.data;
362
- }
@@ -1,156 +0,0 @@
1
- import { api } from './client';
2
- import type {
3
- MarketplaceInstallRequest,
4
- MarketplaceInstallResult,
5
- MarketplaceManageRequest,
6
- MarketplaceManageResult,
7
- MarketplaceInstalledView,
8
- MarketplacePluginContentView,
9
- MarketplaceItemType,
10
- MarketplaceSkillContentView,
11
- MarketplaceItemView,
12
- MarketplaceListView,
13
- MarketplaceRecommendationView,
14
- MarketplaceSort
15
- } from './types';
16
-
17
- export type MarketplaceListParams = {
18
- type: MarketplaceItemType;
19
- q?: string;
20
- tag?: string;
21
- sort?: MarketplaceSort;
22
- page?: number;
23
- pageSize?: number;
24
- };
25
-
26
- function toMarketplaceTypeSegment(type: MarketplaceItemType): 'plugins' | 'skills' | 'mcp' {
27
- if (type === 'plugin') {
28
- return 'plugins';
29
- }
30
- if (type === 'skill') {
31
- return 'skills';
32
- }
33
- return 'mcp';
34
- }
35
-
36
- export async function fetchMarketplaceItems(params: MarketplaceListParams): Promise<MarketplaceListView> {
37
- const query = new URLSearchParams();
38
- const segment = toMarketplaceTypeSegment(params.type);
39
-
40
- if (params.q?.trim()) {
41
- query.set('q', params.q.trim());
42
- }
43
- if (params.tag?.trim()) {
44
- query.set('tag', params.tag.trim());
45
- }
46
- if (params.sort) {
47
- query.set('sort', params.sort);
48
- }
49
- if (typeof params.page === 'number' && Number.isFinite(params.page)) {
50
- query.set('page', String(Math.max(1, Math.trunc(params.page))));
51
- }
52
- if (typeof params.pageSize === 'number' && Number.isFinite(params.pageSize)) {
53
- query.set('pageSize', String(Math.max(1, Math.trunc(params.pageSize))));
54
- }
55
-
56
- const suffix = query.toString();
57
- const response = await api.get<MarketplaceListView>(
58
- suffix ? `/api/marketplace/${segment}/items?${suffix}` : `/api/marketplace/${segment}/items`
59
- );
60
- if (!response.ok) {
61
- throw new Error(response.error.message);
62
- }
63
-
64
- return response.data;
65
- }
66
-
67
- export async function fetchMarketplaceItem(slug: string, type: MarketplaceItemType): Promise<MarketplaceItemView> {
68
- const segment = toMarketplaceTypeSegment(type);
69
- const response = await api.get<MarketplaceItemView>(
70
- `/api/marketplace/${segment}/items/${encodeURIComponent(slug)}`
71
- );
72
- if (!response.ok) {
73
- throw new Error(response.error.message);
74
- }
75
-
76
- return response.data;
77
- }
78
-
79
- export async function fetchMarketplaceSkillContent(slug: string): Promise<MarketplaceSkillContentView> {
80
- const response = await api.get<MarketplaceSkillContentView>(
81
- `/api/marketplace/skills/items/${encodeURIComponent(slug)}/content`
82
- );
83
- if (!response.ok) {
84
- throw new Error(response.error.message);
85
- }
86
-
87
- return response.data;
88
- }
89
-
90
- export async function fetchMarketplacePluginContent(slug: string): Promise<MarketplacePluginContentView> {
91
- const response = await api.get<MarketplacePluginContentView>(
92
- `/api/marketplace/plugins/items/${encodeURIComponent(slug)}/content`
93
- );
94
- if (!response.ok) {
95
- throw new Error(response.error.message);
96
- }
97
-
98
- return response.data;
99
- }
100
-
101
- export async function fetchMarketplaceRecommendations(
102
- type: MarketplaceItemType,
103
- params: {
104
- scene?: string;
105
- limit?: number;
106
- } = {}
107
- ): Promise<MarketplaceRecommendationView> {
108
- const query = new URLSearchParams();
109
- const segment = toMarketplaceTypeSegment(type);
110
- if (params.scene?.trim()) {
111
- query.set('scene', params.scene.trim());
112
- }
113
- if (typeof params.limit === 'number' && Number.isFinite(params.limit)) {
114
- query.set('limit', String(Math.max(1, Math.trunc(params.limit))));
115
- }
116
-
117
- const suffix = query.toString();
118
- const response = await api.get<MarketplaceRecommendationView>(
119
- suffix
120
- ? `/api/marketplace/${segment}/recommendations?${suffix}`
121
- : `/api/marketplace/${segment}/recommendations`
122
- );
123
- if (!response.ok) {
124
- throw new Error(response.error.message);
125
- }
126
-
127
- return response.data;
128
- }
129
-
130
- export async function installMarketplaceItem(request: MarketplaceInstallRequest): Promise<MarketplaceInstallResult> {
131
- const segment = toMarketplaceTypeSegment(request.type);
132
- const response = await api.post<MarketplaceInstallResult>(`/api/marketplace/${segment}/install`, request);
133
- if (!response.ok) {
134
- throw new Error(response.error.message);
135
- }
136
-
137
- return response.data;
138
- }
139
-
140
- export async function fetchMarketplaceInstalled(type: MarketplaceItemType): Promise<MarketplaceInstalledView> {
141
- const segment = toMarketplaceTypeSegment(type);
142
- const response = await api.get<MarketplaceInstalledView>(`/api/marketplace/${segment}/installed`);
143
- if (!response.ok) {
144
- throw new Error(response.error.message);
145
- }
146
- return response.data;
147
- }
148
-
149
- export async function manageMarketplaceItem(request: MarketplaceManageRequest): Promise<MarketplaceManageResult> {
150
- const segment = toMarketplaceTypeSegment(request.type);
151
- const response = await api.post<MarketplaceManageResult>(`/api/marketplace/${segment}/manage`, request);
152
- if (!response.ok) {
153
- throw new Error(response.error.message);
154
- }
155
- return response.data;
156
- }