@vellumai/web 0.11.1-dev.202608032034.aebd2da → 0.11.1-dev.202608032226.351a4e2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{access-C1I5oond.js → access-yGcxATuu.js} +1 -1
- package/dist/assets/{account-page-e83ZZGt_.js → account-page-CKW2SSp9.js} +1 -1
- package/dist/assets/{acp-run-detail-panel-BP6MJVSE.js → acp-run-detail-panel-BCjFtA_f.js} +1 -1
- package/dist/assets/{activity-steps-panel-Dx07LouI.js → activity-steps-panel-Cz33jeyV.js} +1 -1
- package/dist/assets/{add-credits-modal-BaVh9z2u.js → add-credits-modal-B_MFASQE.js} +1 -1
- package/dist/assets/{ai-page-DX4POmeH.js → ai-page-ClE_nCMR.js} +1 -1
- package/dist/assets/{api-BtgSRGvM.js → api-C0nyw19F.js} +1 -1
- package/dist/assets/{assistant-status-panel-BHDN8PNU.js → assistant-status-panel-DeVTQvDz.js} +1 -1
- package/dist/assets/auth-store-D55YOXDj.js +2 -0
- package/dist/assets/{avatar-random-CqEafXlj.js → avatar-random-484pJyF3.js} +1 -1
- package/dist/assets/{background-task-actions-qqLh6rZn.js → background-task-actions-DwqH9oM6.js} +1 -1
- package/dist/assets/{background-task-detail-panel-DayPRasX.js → background-task-detail-panel-BeUtlnT5.js} +1 -1
- package/dist/assets/{billing-page-CFkU6BaX.js → billing-page-DzjIHoDX.js} +1 -1
- package/dist/assets/{build-state-B8Rq7nj1.js → build-state-qwijhEiY.js} +1 -1
- package/dist/assets/{channels-page-route-BTEfE4t7.js → channels-page-route-D4DLyfWJ.js} +1 -1
- package/dist/assets/{chat-markdown-message-COWyU40r.js → chat-markdown-message-CKi-NHzb.js} +1 -1
- package/dist/assets/{checkout-page-CYLWMWPt.js → checkout-page-kQVpLpf-.js} +1 -1
- package/dist/assets/{command-palette-window-page-C2HXDbfT.js → command-palette-window-page-DhSWYXbd.js} +1 -1
- package/dist/assets/{conversation-queries-Bd0Kbom7.js → conversation-queries-B31vm-Y1.js} +1 -1
- package/dist/assets/{credentials-page-DKSR_Zam.js → credentials-page-Cd9pgN5h.js} +1 -1
- package/dist/assets/debug-page-gflEI_1_.js +4 -0
- package/dist/assets/{developer-page-DrMRgzkc.js → developer-page-BJr5yx1q.js} +1 -1
- package/dist/assets/{emails-page-Cdc-tPPa.js → emails-page-D54SJ9Qn.js} +1 -1
- package/dist/assets/{first-run-scope-0nXVxenk.js → first-run-scope-BqaKW0iq.js} +1 -1
- package/dist/assets/{funnel-events-ZI_dMO-E.js → funnel-events-BhLPs4C-.js} +1 -1
- package/dist/assets/{general-page-CqU0mukt.js → general-page-DMmGkDTG.js} +1 -1
- package/dist/assets/{hatching-screen-5Ns-LED6.js → hatching-screen-CiBLq47u.js} +1 -1
- package/dist/assets/home-page-route-DVUNu3Ap.js +1 -0
- package/dist/assets/{hosting-screen-CoI_0LLl.js → hosting-screen-BooqGYaC.js} +1 -1
- package/dist/assets/{identity-page-route-cGL9xM0w.js → identity-page-route-XzcTS26G.js} +1 -1
- package/dist/assets/{index-Blkf3bPi.js → index-BfyUfISv.js} +1 -1
- package/dist/assets/{ingest-BsJxxXyc.js → ingest-cbIUCyYd.js} +1 -1
- package/dist/assets/{inspect-page-z3aYx0qD.js → inspect-page-Cnw7GS7E.js} +1 -1
- package/dist/assets/{integrations-page-DOXZuQr6.js → integrations-page-0cfyvYmp.js} +1 -1
- package/dist/assets/{local-runtime-upgrade-CZ4WOe4f.js → local-runtime-upgrade-omsL-NDw.js} +1 -1
- package/dist/assets/{login-flow-Dtp-3tNV.js → login-flow-DnBrnY_F.js} +1 -1
- package/dist/assets/{login-page-DDBFbAzk.js → login-page-Cehskc-T.js} +1 -1
- package/dist/assets/{logout-page-z3XOk2wX.js → logout-page-BR4VqeQ5.js} +1 -1
- package/dist/assets/{logs-layout-pcP2Ef6M.js → logs-layout-zl-EjgzZ.js} +1 -1
- package/dist/assets/{memory-page-route-DKgiS6HJ.js → memory-page-route-CNkRqdAT.js} +1 -1
- package/dist/assets/{memory-router-playground-page-DrUP3MCp.js → memory-router-playground-page-DYi59gfo.js} +1 -1
- package/dist/assets/{notifications-page-F6miCJy6.js → notifications-page-APw4Crk-.js} +1 -1
- package/dist/assets/{open-workspace-file-C05Tcrol.js → open-workspace-file-DYQnenip.js} +2 -2
- package/dist/assets/{personality-page-F2kfjY46.js → personality-page-DhANpmbS.js} +1 -1
- package/dist/assets/{plans-page-BzzAj_zc.js → plans-page-rcodAUMC.js} +1 -1
- package/dist/assets/{platform-login-notice-W6sDytqC.js → platform-login-notice-D3MegklO.js} +1 -1
- package/dist/assets/{platform-loopback-page-e78IsQAa.js → platform-loopback-page-C6FzXoWP.js} +1 -1
- package/dist/assets/{privacy-page-KgkmGZnk.js → privacy-page-CfrjCpeD.js} +1 -1
- package/dist/assets/{privacy-screen-DrOm_twh.js → privacy-screen-CeHf0PDN.js} +1 -1
- package/dist/assets/{provider-callback-page-D_BfdwXM.js → provider-callback-page-Dg3HfDxW.js} +1 -1
- package/dist/assets/{provider-signup-page-fnuIn644.js → provider-signup-page-CpLDQery.js} +1 -1
- package/dist/assets/{react-query.gen-BVTEjHsw.js → react-query.gen-BGUTzcTG.js} +1 -1
- package/dist/assets/{research-onboarding-route-CxJ2rZd3.js → research-onboarding-route-DVSAMyqq.js} +1 -1
- package/dist/assets/{retire-confirm-dialog-Dvr5YkiM.js → retire-confirm-dialog-DHhjDO0L.js} +1 -1
- package/dist/assets/{review-terms-screen-BKXTyNfJ.js → review-terms-screen-faC2X3qN.js} +1 -1
- package/dist/assets/{risk-DowO3Nts.js → risk-BuFJ18u_.js} +1 -1
- package/dist/assets/{routes-BA96rRl2.js → routes-CgzDcsx-.js} +5 -5
- package/dist/assets/{runtime-upgrade-banner-xb6RIZD3.js → runtime-upgrade-banner-Cbbxoksm.js} +1 -1
- package/dist/assets/{schedules-page-D8RM5kA8.js → schedules-page-DPX0uLzP.js} +1 -1
- package/dist/assets/{sdk.gen-DVW3wpbx.js → sdk.gen-DwcktL4E.js} +1 -1
- package/dist/assets/{select-assistant-screen-CybWc17g.js → select-assistant-screen-D4cryjd8.js} +1 -1
- package/dist/assets/{settings-layout-Brq3xFKP.js → settings-layout-P118CCPr.js} +1 -1
- package/dist/assets/{settings-navigation-SBGsJnnx.js → settings-navigation-BE7_pkHk.js} +1 -1
- package/dist/assets/{share-feedback-modal-C3UWQjP0.js → share-feedback-modal-CjeHBN-v.js} +1 -1
- package/dist/assets/{sidebar-tree-BzMiVAfn.js → sidebar-tree-BvzA_BiU.js} +1 -1
- package/dist/assets/{signup-page-0i-u2BC6.js → signup-page-CXdcmTsL.js} +1 -1
- package/dist/assets/{site-favicon-E6OyQgue.js → site-favicon-DQHtqmLO.js} +1 -1
- package/dist/assets/{skill-detail-page-BllApnzv.js → skill-detail-page-kBFir--k.js} +1 -1
- package/dist/assets/{subagent-detail-panel-LGjnuFoZ.js → subagent-detail-panel-7lkLfaL6.js} +1 -1
- package/dist/assets/{system-events-page-BPDpf3uE.js → system-events-page-BouGQKlX.js} +1 -1
- package/dist/assets/{tool-detail-panel-DYV838ez.js → tool-detail-panel-DzQts863.js} +1 -1
- package/dist/assets/{transcript-message-body-shared-C8IYfmO9.js → transcript-message-body-shared-BhvjN5HF.js} +1 -1
- package/dist/assets/{upgrade-cancel-page-DhTF9dJB.js → upgrade-cancel-page-BsarXnAm.js} +1 -1
- package/dist/assets/{upgrade-success-page-qO1uYGMN.js → upgrade-success-page-NS1EWjo2.js} +1 -1
- package/dist/assets/{use-assistant-capability-q3Hh4XrX.js → use-assistant-capability-CVGwRhaR.js} +1 -1
- package/dist/assets/{use-assistant-identity-details-Ca7AVxgW.js → use-assistant-identity-details-DwU_hccl.js} +1 -1
- package/dist/assets/{use-checkout-dismiss-refresh-zcJMFA3R.js → use-checkout-dismiss-refresh-DqjPrcE0.js} +1 -1
- package/dist/assets/{use-command-palette-sections-BSC2Wkt_.js → use-command-palette-sections-DF0iyH53.js} +1 -1
- package/dist/assets/{use-ios-app-nudge-CFV2lx5J.js → use-ios-app-nudge-rHuzm_cD.js} +1 -1
- package/dist/assets/{use-is-org-ready-B4ouZE2v.js → use-is-org-ready-_bcxY9zb.js} +1 -1
- package/dist/assets/{use-onboarding-login-HdAfPFX8.js → use-onboarding-login-DmZA-Mb2.js} +1 -1
- package/dist/assets/{use-platform-assistant-id-CIOuueCO.js → use-platform-assistant-id-DhMrx-n9.js} +1 -1
- package/dist/assets/{use-platform-gate-DEPyUO3c.js → use-platform-gate-Oc-w11de.js} +1 -1
- package/dist/assets/{use-return-to-short-circuit-BuTYXevi.js → use-return-to-short-circuit-2pD4HsK8.js} +1 -1
- package/dist/assets/{use-sticky-profiles-DKVJgOVG.js → use-sticky-profiles-B63YDPxX.js} +1 -1
- package/dist/assets/{use-subagent-card-data-BYZzHmRL.js → use-subagent-card-data-ByOqIUh5.js} +1 -1
- package/dist/assets/{voice-list-eMYmbFH9.js → voice-list-wJgVqrRh.js} +1 -1
- package/dist/assets/{voice-page-CADyxYSv.js → voice-page-_rmgVE3p.js} +1 -1
- package/dist/assets/{welcome-screen-BdAhfgTc.js → welcome-screen-Cq_y2fgM.js} +1 -1
- package/dist/index.html +33 -33
- package/package.json +1 -1
- package/dist/assets/auth-store-QpgWmI2t.js +0 -2
- package/dist/assets/debug-page-KfqBnSCL.js +0 -4
- package/dist/assets/home-page-route-Dzq2b7PG.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{i as t,l as n}from"./local-settings-Bx7FsNo5.js";import{t as r}from"./capture-error-FWzaVb8P.js";import{t as i}from"./react-BFJW0bSv.js";import{t as a}from"./button-Dy5001j6.js";import{m as o,u as s}from"./chunk-5KNZJZUH-Bsoom5--.js";import{N as c,O as l,S as u,T as d,c as f,n as p}from"./QueryClientProvider-CMu7CkQU.js";import{a as m,c as h,d as g,i as _,l as v,o as y,r as b,s as x,t as S,u as C}from"./useQuery-Bz-fbQ-m.js";import{t as w}from"./jsx-runtime-D3ZM-ToX.js";import{t as T}from"./card-DRIctGVs.js";import{t as E}from"./createLucideIcon-CAM1RhH8.js";import{t as D}from"./check-sC49_hjU.js";import{t as O}from"./chevron-down-B5A-0g8A.js";import{t as k}from"./chevron-right-HU6H84S0.js";import{t as A}from"./circle-alert-DVCpoZrc.js";import{t as j}from"./circle-check-CjGnAahM.js";import{t as M}from"./circle-x-17dBxF06.js";import{n as N,o as P,t as F}from"./list-row-BYrmPIC4.js";import{t as I}from"./external-link-CAce-RVu.js";import{t as L}from"./key-round-CSc3w5ka.js";import{t as R}from"./loader-circle-BzJ2kz3F.js";import{t as z}from"./log-in-Bhye1kwc.js";import{t as ee}from"./log-out-BLE632qu.js";import{t as B}from"./pencil-CLJIvYKH.js";import{t as V}from"./plus-JG7kWjHA.js";import{n as te,t as H}from"./integration-icon-tiuVoy54.js";import{t as ne}from"./refresh-cw-Ci7hSykC.js";import{t as re}from"./search-DA3TmTuR.js";import{t as ie}from"./sparkles-DC8kqYjt.js";import{t as U}from"./trash-2-De6X8YiM.js";import{t as ae}from"./x-DuBvjmAE.js";import{t as oe}from"./notice-DCp7WO3L.js";import{t as W}from"./popover-BFL-uOLh.js";import{t as G}from"./input-C-GkeWCw.js";import{t as se}from"./toggle-D776PTw-.js";import{t as K}from"./modal-DwsThLGg.js";import{n as q,t as ce}from"./panel-item-DGs4s9r-.js";import{n as J}from"./toast-DR7D7Uma.js";import{t as Y}from"./confirm-dialog-DZX6LhLy.js";import{r as le}from"./api-errors-SZKDzMLE.js";import{J as ue}from"./auth-store-QpgWmI2t.js";import{Kr as X}from"./sdk.gen-BySz4QYj.js";import{r as de}from"./api-BtgSRGvM.js";import{m as fe}from"./native-biometric-K90ZnTI1.js";import{d as pe}from"./routes-Dwx_Ibh9.js";import{i as me,t as he}from"./use-platform-gate-DEPyUO3c.js";import{$ as ge,an as _e,et as ve,in as ye,it as be,nn as xe,nt as Se,rn as Ce,rt as we,tt as Te}from"./react-query.gen-Cnk5tcFs.js";import{n as Ee,r as De}from"./browser-BaaiMPkj.js";import{n as Oe}from"./conversation-navigation-CYonSeT9.js";import{n as ke}from"./use-is-mobile-Cx2xnNUx.js";import{Dt as Ae,Ot as je,S as Me,b as Z,x as Ne}from"./react-query.gen-BVTEjHsw.js";import{t as Pe}from"./assistant-feature-flag-store-Ci_346FY.js";import{a as Fe,i as Ie,n as Le,r as Re}from"./oauth-connection-utils-BHC1Orld.js";import{a as ze,i as Be,n as Ve,t as He}from"./oauth-popup-Ql5xgtlO.js";import{t as Ue}from"./copy-to-clipboard-DaTa8Tbi.js";import{t as We}from"./platform-login-notice-W6sDytqC.js";import{t as Ge}from"./use-active-assistant-id-AtGy8p_R.js";import{t as Ke}from"./use-platform-assistant-id-CIOuueCO.js";function qe(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Je(e,t,n){let r=e.slice(0);return r[t]=n,r}var Ye=class extends c{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,f.batch(()=>{let e=this.#i,t=this.#f(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!l(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(qe(e,n).forEach(e=>{e.destroy()}),qe(n,e).forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})),this.#m()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#f(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=d(this.#a,t(e))),this.#a}return e}#f(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new g(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#p(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Je(this.#t,n,t),this.#m())}#m(){if(this.hasListeners()){let e=this.#a,t=this.#u(this.#t,this.#l);e!==this.#d(t,this.#r?.combine)&&f.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},Q=e(i(),1);function Xe({queries:e,...t},n){let r=p(n),i=C(),a=v(),o=Q.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{b(e),y(e,a,r.getQueryCache().get(e.queryHash))}),h(a);let[s]=Q.useState(()=>new Ye(r,o,t)),[c,l,d]=s.getOptimisticResult(o,t.combine),S=!i&&t.subscribed!==!1;Q.useSyncExternalStore(Q.useCallback(e=>S?s.subscribe(f.batchCalls(e)):u,[s,S]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),Q.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let w=c.some((e,t)=>m(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&m(n,e)?_(n,new g(r,n),a):[]}):[];if(w.length>0)throw Promise.all(w);let T=c.find((e,t)=>{let n=o[t];return n&&x({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(T?.error)throw T.error;return l(d())}var Ze=E(`cable`,[[`path`,{d:`M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z`,key:`trhst0`}],[`path`,{d:`M17 21v-2`,key:`ds4u3f`}],[`path`,{d:`M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10`,key:`1mo9zo`}],[`path`,{d:`M21 21v-2`,key:`eo0ou`}],[`path`,{d:`M3 5V3`,key:`1k5hjh`}],[`path`,{d:`M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z`,key:`1dd30t`}],[`path`,{d:`M7 5V3`,key:`1t1388`}]]),Qe=E(`calendar-plus`,[[`path`,{d:`M16 19h6`,key:`xwg31i`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M19 16v6`,key:`tddt3s`}],[`path`,{d:`M21 12.598V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8.5`,key:`1glfrc`}],[`path`,{d:`M3 10h18`,key:`8toen8`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}]]);function $e({assistantId:e,providerKey:t,displayName:n,managedAvailable:r,connectionsQueryKey:i,allConnections:a}){let o=p(),s=fe(),c=(0,Q.useRef)(null),l=(0,Q.useRef)(null),u=(0,Q.useRef)(null),d=(0,Q.useRef)(null),[f,m]=(0,Q.useState)(!1),h=()=>{l.current=null,m(!1)},g=()=>{c.current&&!c.current.closed&&c.current.close(),c.current=null,u.current&&=(clearInterval(u.current),null),d.current&&=(clearTimeout(d.current),null)},_=(0,Q.useCallback)(e=>{if(e.type!==`vellum:oauth-complete`||!l.current||e.requestId!==l.current.requestId)return;let{oauthStatus:t,oauthCode:r}=e;if(g(),h(),t===`connected`)J.success(`${n} account connected.`),o.invalidateQueries({queryKey:i});else{let e=r?`Error: ${r}`:`Authorization failed`;J.error(`${n} ${e}`)}},[i,n,o]),v=(0,Q.useCallback)(async(e,n)=>{if(!r)return!1;for(let r=0;r<8;r+=1){r>0&&await Ie(750);try{if(o.invalidateQueries({queryKey:i}),Re(await o.fetchQuery({...Z({path:{assistant_id:e}}),staleTime:0}),t,n))return!0}catch{}}return!1},[i,r,t,o]);(0,Q.useEffect)(()=>{let e=e=>{let t=l.current;if(!t)return;let n=He(e,window.location.origin,t.requestId);n&&_(n)},t=e=>{let t=l.current;if(!t)return;let n=Ve(e,t.requestId);n&&(_(n),window.localStorage.removeItem(Be(t.requestId)))};return window.addEventListener(`message`,e),window.addEventListener(`storage`,t),()=>{window.removeEventListener(`message`,e),window.removeEventListener(`storage`,t)}},[_]),Fe((0,Q.useCallback)(e=>{let t=l.current;t&&e.requestId===t.requestId&&_({type:`vellum:oauth-complete`,requestId:e.requestId,oauthStatus:e.oauthStatus,oauthProvider:e.oauthProvider,oauthCode:e.oauthCode})},[_])),(0,Q.useEffect)(()=>De(()=>{let e=l.current;e&&(async()=>{let t=await v(e.platformAssistantId,e.baselineConnectionSignatures);l.current&&(h(),t&&J.success(`${n} account connected.`))})()}),[v,n]),(0,Q.useEffect)(()=>()=>{u.current&&clearInterval(u.current),d.current&&clearTimeout(d.current),c.current&&!c.current.closed&&c.current.close()},[]);let y=je();return{handleConnect:(i=[])=>{if(!r)return;let f=crypto.randomUUID();m(!0);let p=async r=>{let c;try{c=await ue(e)}catch(e){g(),h(),J.error(e instanceof Error?e.message:`Failed to start ${n} authorization.`);return}let u=Le(await o.fetchQuery({...Z({path:{assistant_id:c}}),staleTime:0}).catch(()=>c===e?a??[]:[]),t);l.current={requestId:f,provider:t,platformAssistantId:c,baselineConnectionSignatures:u},y.mutate({path:{assistant_id:c,provider:t},body:{requested_scopes:i,redirect_after_connect:`${pe.account.oauth.popupComplete}?requestId=${f}${s?`&native=1`:``}`}},{onSuccess(e){if(s){Ee(e.connect_url);return}r&&!r.closed?r.location.href=e.connect_url:l.current&&(g(),h(),J.error(`${n} connection failed: popup closed.`))},onError(e){g(),h();let t=le(e,void 0,`Failed to start ${n} authorization.`);J.error(t)}})};if(s){p(null);return}let b=window.open(``,`_blank`,`width=500,height=600`);if(b===null){h(),J.error(`Popup blocked. Please enable popups and try again.`);return}c.current=b,u.current=setInterval(()=>{c.current&&c.current.closed&&l.current&&!d.current&&(d.current=setTimeout(async()=>{d.current=null;let e=l.current;if(!e)return;let t=window.localStorage.getItem(Be(e.requestId));if(t){let n=ze(t);if(n&&n.requestId===e.requestId){_(n),window.localStorage.removeItem(Be(e.requestId));return}}let r=await v(e.platformAssistantId,e.baselineConnectionSignatures);if(l.current){if(r){g(),h(),J.success(`${n} account connected.`);return}g(),h(),J.error(`${n} connection failed: authorization popup closed.`)}},1e3))},100),p(b)},oauthInProgress:f,startOAuthPending:y.isPending}}var $=w();function et({displayName:e,providerKey:t,logoUrl:n,connections:r,connectionsLoading:i,startPending:o,oauthInProgress:s,disconnectingId:c,onConnect:l,onDisconnect:u,connectPresets:d=[]}){let f=o||s;return i?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,$.jsx)(R,{className:`h-5 w-5 animate-spin text-[var(--content-disabled)]`})}):r.length===0?o||s?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-10`,children:[(0,$.jsx)(H,{providerKey:t,displayName:e,logoUrl:n,size:48}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,$.jsx)(R,{className:`h-3.5 w-3.5 animate-spin`}),`Waiting for authorization...`]})]}):(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-10`,children:[(0,$.jsx)(H,{providerKey:t,displayName:e,logoUrl:n,size:48}),(0,$.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:`Connect Account to continue`}),(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,$.jsx)(a,{variant:`primary`,size:`compact`,leftIcon:(0,$.jsx)(V,{}),onClick:()=>l(),disabled:f,children:`Connect Account`}),d.map(e=>(0,$.jsx)(a,{variant:`outlined`,size:`compact`,leftIcon:(0,$.jsx)(Qe,{}),onClick:()=>l(e.scopes),disabled:f,children:e.label},e.id))]})]}):(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)]`,children:[(0,$.jsx)(`ul`,{className:`divide-y divide-[var(--border-base)]`,children:r.map(r=>{let i=c===r.id;return(0,$.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3`,children:[(0,$.jsx)(H,{providerKey:t,displayName:e,logoUrl:n,size:20}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body-medium-default text-[var(--content-default)]`,children:r.account_label??`${e} Account`}),(0,$.jsx)(a,{variant:`dangerOutline`,size:`compact`,iconOnly:i?(0,$.jsx)(R,{className:`animate-spin`}):(0,$.jsx)(U,{}),onClick:()=>u(r),disabled:i,"aria-label":`Disconnect ${r.account_label??`${e} account`}`})]},r.id)})}),(0,$.jsx)(`div`,{className:`border-t border-[var(--border-base)] px-4 py-3 dark:border-[var(--border-base)]`,children:f?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,$.jsx)(R,{className:`h-3.5 w-3.5 animate-spin`}),`Waiting for authorization...`]}):(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(a,{variant:`primary`,size:`compact`,leftIcon:(0,$.jsx)(I,{}),onClick:()=>l(),disabled:f,children:`Connect account`}),d.map(e=>(0,$.jsx)(a,{variant:`outlined`,size:`compact`,leftIcon:(0,$.jsx)(Qe,{}),onClick:()=>l(e.scopes),disabled:f,children:e.label},e.id))]})})]})}function tt(e){return e.length>16?`${e.slice(0,12)}…${e.slice(-4)}`:e.length>8?`${e.slice(0,8)}…`:e}function nt(e){try{return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}catch{return``}}function rt({assistantId:e,providerKey:t,displayName:n,logoUrl:r}){let i=p(),o=S({...Te({path:{assistant_id:e},query:{provider_key:t}}),select:e=>e.apps}),s=S({...we({path:{assistant_id:e,providerKey:t}}),select:e=>e.oauth_callback_url}),c=o.data??[],l=s.data??null,u=Xe({queries:c.map(t=>({...ge({path:{assistant_id:e,appId:t.id}}),select:e=>e.connections}))}),d={};c.forEach((e,t)=>{d[e.id]=u[t]?.data??[]});let f=Se({path:{assistant_id:e},query:{provider_key:t}}),m=ye({onSuccess:()=>{i.invalidateQueries({queryKey:f}),x(``),w(``),y(!1),J.success(`${n} OAuth app added.`)},onError:e=>{J.error(e.message||`Failed to create OAuth app`)}}),h=Ce({onSuccess:()=>{i.invalidateQueries({queryKey:f}),J.success(`OAuth app deleted.`)},onError:e=>{J.error(e.message||`Failed to delete OAuth app`)}}),g=xe({onSuccess:e=>{`auth_url`in e&&(window.location.href=e.auth_url)},onError:e=>{J.error(e.message||`Failed to start OAuth flow`)}}),_=_e(),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(``),[E,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(null),N=m.isPending,F=h.isPending?h.variables?.path?.id??null:null,L=g.isPending?g.variables?.path?.appId??null:null,z=_.isPending?_.variables?.path?.id??null:null,ee=()=>{let n=b.trim(),r=C.trim();!n||!r||m.mutate({path:{assistant_id:e},body:{provider_key:t,client_id:n,client_secret:r}})},B=()=>{let t=k;A(null),t&&h.mutate({path:{assistant_id:e,id:t.id}})},te=t=>{g.mutate({path:{assistant_id:e,appId:t.id},body:{callback_transport:`gateway`,scopes:[]}})};return o.isLoading?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,$.jsx)(R,{className:`h-5 w-5 animate-spin text-[var(--content-disabled)]`})}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[c.length===0||v?(0,$.jsx)(T.Root,{children:(0,$.jsxs)(T.Body,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:c.length===0?`Add your own ${n} OAuth app`:`Add another ${n} OAuth app`}),(0,$.jsx)(`p`,{className:`text-body-small-default leading-relaxed text-[var(--content-tertiary)]`,children:`Credentials are stored encrypted on the assistant and are never sent to Vellum.`})]}),l?(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Redirect URL`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(G,{type:`text`,value:l,readOnly:!0,fullWidth:!0}),(0,$.jsx)(a,{type:`button`,variant:`outlined`,size:`compact`,onClick:()=>{Ue(l,{successMessage:`Copied to clipboard!`,errorMessage:`Couldn't copy the redirect URL.`,onCopied:()=>{O(!0),setTimeout(()=>O(!1),2e3)}})},"aria-label":E?`Copied`:`Copy redirect URL`,iconOnly:E?(0,$.jsx)(D,{"aria-hidden":!0}):(0,$.jsx)(P,{"aria-hidden":!0})})]}),(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Add this URL to your OAuth app's redirect settings.`})]}):null,(0,$.jsx)(G,{label:`Client ID`,type:`text`,value:b,onChange:e=>x(e.target.value),placeholder:`Enter your client ID`,fullWidth:!0}),(0,$.jsx)(G,{label:`Client Secret`,type:`password`,value:C,onChange:e=>w(e.target.value),placeholder:`Enter your client secret`,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 pt-1`,children:[c.length>0?(0,$.jsx)(a,{type:`button`,variant:`outlined`,size:`compact`,onClick:()=>{y(!1),x(``),w(``)},disabled:N,children:`Cancel`}):null,(0,$.jsx)(a,{type:`button`,size:`compact`,onClick:ee,disabled:N||!b.trim()||!C.trim(),leftIcon:N?(0,$.jsx)(R,{className:`animate-spin`,"aria-hidden":!0}):(0,$.jsx)(V,{"aria-hidden":!0}),children:`Add App`})]})]})}):null,c.map(e=>{let i=d[e.id]??[],o=F===e.id,s=L===e.id;return(0,$.jsx)(T.Root,{children:(0,$.jsxs)(T.Body,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,$.jsx)(`p`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:tt(e.client_id)}),(0,$.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[`Added `,nt(e.created_at)]})]}),(0,$.jsx)(a,{type:`button`,variant:`dangerOutline`,size:`compact`,onClick:()=>A(e),disabled:o,"aria-label":`Delete OAuth app ${tt(e.client_id)}`,iconOnly:o?(0,$.jsx)(R,{className:`animate-spin`,"aria-hidden":!0}):(0,$.jsx)(U,{"aria-hidden":!0})})]}),i.length>0?(0,$.jsx)(`ul`,{className:`divide-y divide-[var(--border-base)] overflow-hidden rounded-md border border-[var(--border-base)] dark:divide-[var(--border-base)] dark:border-[var(--border-base)]`,children:i.map(i=>{let o=z===i.id;return(0,$.jsxs)(`li`,{className:`flex items-center gap-3 px-3 py-2`,children:[(0,$.jsx)(H,{providerKey:t,displayName:n,logoUrl:r,size:18}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body-medium-lighter text-[var(--content-default)]`,children:i.account_info??`${n} Account`}),(0,$.jsx)(a,{type:`button`,variant:`dangerOutline`,size:`compact`,onClick:()=>M({appId:e.id,connection:i}),disabled:o,"aria-label":`Disconnect ${i.account_info??`${n} account`}`,iconOnly:o?(0,$.jsx)(R,{className:`animate-spin`,"aria-hidden":!0}):(0,$.jsx)(U,{"aria-hidden":!0})})]},i.id)})}):null,(0,$.jsx)(a,{type:`button`,size:`compact`,onClick:()=>te(e),disabled:s,className:`w-full`,leftIcon:s?(0,$.jsx)(R,{className:`animate-spin`,"aria-hidden":!0}):(0,$.jsx)(I,{"aria-hidden":!0}),children:s?`Waiting for authorization...`:`Connect account`})]})},e.id)}),c.length>0&&!v?(0,$.jsx)(a,{type:`button`,variant:`outlined`,size:`compact`,onClick:()=>y(!0),className:`w-full border-dashed`,leftIcon:(0,$.jsx)(V,{"aria-hidden":!0}),children:`Add Another App`}):null,(0,$.jsx)(Y,{open:k!==null,title:`Delete OAuth app`,message:k?`Delete OAuth app '${tt(k.client_id)}'? This will disconnect all linked accounts.`:``,confirmLabel:`Delete`,destructive:!0,onConfirm:B,onCancel:()=>A(null)}),(0,$.jsx)(Y,{open:j!==null,title:`Disconnect ${n}?`,message:j?`Disconnect ${j.connection.account_info??`${n} Account`}? You can reconnect later.`:``,confirmLabel:`Disconnect`,destructive:!0,onConfirm:()=>{let t=j;M(null),t&&_.mutate({path:{assistant_id:e,id:t.connection.id}},{onSuccess:()=>{let r=ve({path:{assistant_id:e,appId:t.appId}});i.invalidateQueries({queryKey:r}),i.invalidateQueries({queryKey:f}),J.success(`${n} account disconnected.`)},onError:e=>{J.error(e.message||`Failed to disconnect account`)}})},onCancel:()=>M(null)})]})}var it={};function at(e){return it[e]??[]}function ot({assistantId:e,platformAssistantId:t,providerKey:n,displayName:r,description:i,logoUrl:o,platformGate:s,onClose:c}){let l=p(),u=s===`full`,d=!he(),[f,m]=(0,Q.useState)(s===`gated`&&d?`your-own`:`managed`);(0,Q.useEffect)(()=>{!d&&f===`your-own`&&m(`managed`)},[d,f]);let[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(null),y=Ne({path:{assistant_id:t}}),{data:b,isLoading:x}=S({...Z({path:{assistant_id:t}}),enabled:u}),C=(b??[]).filter(e=>e.provider===n&&e.connected),{handleConnect:w,oauthInProgress:T,startOAuthPending:E}=$e({assistantId:e,providerKey:n,displayName:r,managedAvailable:u,connectionsQueryKey:y,allConnections:b}),D={path:{assistant_id:t}},O=Ae({onSuccess(e,t){J.success(`${r} account disconnected.`);let n=t.path.connection_id;Me(l,D,e=>e?.filter(e=>e.id!==n)),l.invalidateQueries({queryKey:y}),g(null)},onError(e){let t=le(e,void 0,`Failed to disconnect ${r} account.`);J.error(t),g(null)}});(0,Q.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!e.defaultPrevented&&(e.preventDefault(),c())};document.addEventListener(`keydown`,e);let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,e),document.body.style.overflow=t}},[c]);let k=e=>{v(e)},A=()=>{let e=_;v(null),e&&(g(e.id),O.mutate({path:{assistant_id:t,connection_id:e.id}}))},j=i?`Configure ${r} OAuth for ${i}`:`Configure ${r} OAuth`;return(0,$.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,children:[(0,$.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`integration-modal-title`,className:`flex w-full max-w-[520px] flex-col overflow-hidden rounded-xl bg-white shadow-xl dark:bg-[var(--surface-lift)]`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-[var(--border-base)] px-5 py-4 dark:border-[var(--border-base)]`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(H,{providerKey:n,displayName:r,logoUrl:o,size:32}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`h2`,{id:`integration-modal-title`,className:`text-title-small text-[var(--content-default)]`,children:[r,` OAuth`]}),(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:j})]})]}),(0,$.jsx)(a,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(ae,{}),"aria-label":`Close`,onClick:c})]}),(0,$.jsxs)(`div`,{className:`space-y-4 px-5 py-4`,children:[s!==`gated`&&d&&(0,$.jsxs)(`div`,{role:`tablist`,"aria-label":`OAuth mode`,className:`flex w-full rounded-md border border-[var(--border-base)] bg-[var(--surface-base)] p-0.5 dark:border-[var(--border-base)] dark:bg-[var(--surface-base)]/40`,children:[(0,$.jsx)(st,{active:f===`managed`,onClick:()=>m(`managed`),children:`Managed`}),(0,$.jsx)(st,{active:f===`your-own`,onClick:()=>m(`your-own`),children:`Your Own`})]}),f===`managed`&&s!==`gated`?s===`disabled`?(0,$.jsx)(We,{children:`Log in to the Vellum platform to manage OAuth connections.`}):(0,$.jsx)(et,{displayName:r,providerKey:n,logoUrl:o,connections:C,connectionsLoading:x,startPending:E,oauthInProgress:T,disconnectingId:O.isPending?h:null,onConnect:w,onDisconnect:k,connectPresets:at(n)}):d?(0,$.jsx)(rt,{assistantId:e,providerKey:n,displayName:r,logoUrl:o}):null]}),(0,$.jsx)(`div`,{className:`flex justify-end border-t border-[var(--border-base)] px-5 py-3 dark:border-[var(--border-base)]`,children:(0,$.jsx)(a,{variant:`outlined`,size:`compact`,onClick:c,children:`Confirm`})})]}),(0,$.jsx)(Y,{open:_!==null,title:`Disconnect ${r}?`,message:_?`Disconnect ${_.account_label??`${r} Account`}? You can reconnect later.`:``,confirmLabel:`Disconnect`,destructive:!0,onConfirm:A,onCancel:()=>v(null)})]})}function st({active:e,onClick:t,children:n}){return(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e,onClick:t,className:`flex-1 cursor-pointer rounded-[5px] px-3 py-1.5 text-body-medium-default transition-colors ${e?`bg-white text-[var(--content-default)] shadow-sm dark:bg-[var(--surface-lift)] dark:text-[var(--content-default)]`:`text-[var(--content-secondary)] hover:text-[var(--content-default)] dark:text-[var(--content-disabled)] dark:hover:text-[var(--content-default)]`}`,children:n})}function ct({platformAssistantId:e,providerKey:t,displayName:n,description:r,logoUrl:i,connection:o,platformGate:s,onConfigure:c}){let l=p(),u=!!o?.connected,[d,f]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(!1),g=ke(),_=Ne({path:{assistant_id:e}}),v={path:{assistant_id:e}},y=Ae({onSuccess(e,t){J.success(`${n} account disconnected.`);let r=t.path.connection_id;Me(l,v,e=>e?.filter(e=>e.id!==r)),l.invalidateQueries({queryKey:_})},onError(e){let t=le(e,void 0,`Failed to disconnect ${n} account.`);J.error(t)}}),b=()=>{o?.id&&h(!0)};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T.Root,{children:(0,$.jsxs)(T.Body,{padding:`sm`,className:`flex items-center gap-4 px-4`,children:[(0,$.jsx)(H,{providerKey:t,displayName:n,logoUrl:i,size:32}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`truncate text-title-small text-[var(--content-default)]`,children:n}),r&&(0,$.jsx)(`p`,{className:`truncate text-body-medium-lighter text-[var(--content-tertiary)]`,children:r})]}),u&&s===`full`?(0,$.jsx)(`div`,{className:`shrink-0`,children:(0,$.jsx)(lt,{displayName:n,open:d,onOpenChange:f,onEditConnections:()=>{f(!1),c()},onDisable:()=>{f(!1),b()},disablePending:y.isPending,isMobile:g})}):(0,$.jsx)(a,{variant:`primary`,onClick:c,className:`shrink-0`,children:`Enable`})]})}),(0,$.jsx)(Y,{open:m,title:`Disconnect ${n}?`,message:`Disconnect your ${n} account? You can reconnect it later.`,confirmLabel:`Disconnect`,destructive:!0,onConfirm:()=>{h(!1),o?.id&&y.mutate({path:{assistant_id:e,connection_id:o.id}})},onCancel:()=>h(!1)})]})}function lt({displayName:e,open:t,onOpenChange:n,onEditConnections:r,onDisable:i,disablePending:o,isMobile:s}){return s?(0,$.jsxs)(q.Root,{open:t,onOpenChange:n,children:[(0,$.jsx)(q.Trigger,{asChild:!0,children:(0,$.jsx)(a,{variant:`outlined`,rightIcon:(0,$.jsx)(O,{}),"aria-haspopup":`menu`,"aria-expanded":t,children:`Configure`})}),(0,$.jsxs)(q.Content,{children:[(0,$.jsx)(q.Header,{children:(0,$.jsx)(q.Title,{children:e})}),(0,$.jsxs)(q.Body,{children:[(0,$.jsx)(ce,{icon:B,label:`Edit connections`,onSelect:r}),(0,$.jsx)(ce,{icon:o?R:M,label:`Disable`,onSelect:()=>{o||i()}})]})]})]}):(0,$.jsxs)(W.Root,{open:t,onOpenChange:n,children:[(0,$.jsx)(W.Trigger,{asChild:!0,children:(0,$.jsx)(a,{variant:`outlined`,rightIcon:(0,$.jsx)(O,{}),"aria-haspopup":`menu`,"aria-expanded":t,children:`Configure`})}),(0,$.jsxs)(W.Content,{align:`end`,sideOffset:4,role:`menu`,className:`w-56 overflow-hidden p-0`,children:[(0,$.jsx)(a,{type:`button`,role:`menuitem`,variant:`ghost`,onClick:r,className:`w-full justify-start rounded-none`,leftIcon:(0,$.jsx)(B,{"aria-hidden":!0}),children:`Edit connections`}),(0,$.jsx)(a,{type:`button`,role:`menuitem`,variant:`dangerGhost`,onClick:i,disabled:o,className:`w-full justify-start rounded-none`,leftIcon:o?(0,$.jsx)(R,{className:`animate-spin`,"aria-hidden":!0}):(0,$.jsx)(M,{"aria-hidden":!0}),children:`Disable`})]})]})}var ut=[{value:`none`,label:`None`},{value:`oauth`,label:`OAuth`},{value:`bearer`,label:`Bearer Token`},{value:`api-key`,label:`API Key`}],dt=[{value:`sse`,label:`SSE`},{value:`streamable-http`,label:`Streamable HTTP`},{value:`stdio`,label:`Stdio (command)`}];function ft({open:e,onClose:t,onAdd:n,isPending:r}){let[i,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(`sse`),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(`none`),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(`X-API-Key`),[x,S]=(0,Q.useState)(``),C=(0,Q.useCallback)(()=>{o(``),c(`sse`),u(``),f(``),m(``),g(`none`),v(``),b(`X-API-Key`),S(``)},[]),w=(0,Q.useCallback)(()=>{r||(C(),t())},[r,C,t]),T=(0,Q.useCallback)(()=>{let e=i.trim();if(!e)return;let t={name:e,transportType:s};if(s===`stdio`){let e=d.trim();if(!e)return;t.command=e;let n=p.trim();n&&(t.args=n.split(/\s+/))}else{let e=l.trim();if(!e)return;t.url=e,h===`bearer`&&_.trim()?t.headers={Authorization:`Bearer ${_.trim()}`}:h===`api-key`&&y.trim()&&x.trim()?t.headers={[y.trim()]:x.trim()}:h===`oauth`&&(t.autoAuth=!0)}n(t)},[i,s,l,d,p,h,_,y,x,n]),E=s===`stdio`,D=i.trim()&&(E?d.trim():l.trim());return(0,$.jsx)(K.Root,{open:e,onOpenChange:e=>{e||w()},children:(0,$.jsxs)(K.Content,{size:`md`,children:[(0,$.jsxs)(K.Header,{children:[(0,$.jsx)(K.Title,{icon:Ze,children:`Add MCP Server`}),(0,$.jsx)(K.Description,{children:`Connect to a Model Context Protocol server to extend available tools.`})]}),(0,$.jsx)(K.Body,{children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-name`,children:`Server name`}),(0,$.jsx)(G,{id:`mcp-name`,type:`text`,value:i,onChange:e=>o(e.target.value),placeholder:`my-server`,fullWidth:!0,autoFocus:!0})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-transport`,children:`Transport`}),(0,$.jsx)(`select`,{id:`mcp-transport`,value:s,onChange:e=>c(e.target.value),className:`w-full rounded-md border border-[var(--border-element)] bg-[var(--surface-lift)] px-3 py-1.5 text-body-medium-default text-[var(--content-default)] outline-none focus:ring-2 focus:ring-[var(--ring)]`,children:dt.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),E?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-command`,children:`Command`}),(0,$.jsx)(G,{id:`mcp-command`,type:`text`,value:d,onChange:e=>f(e.target.value),placeholder:`npx -y @modelcontextprotocol/server-example`,fullWidth:!0})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-args`,children:`Arguments (space-separated)`}),(0,$.jsx)(G,{id:`mcp-args`,type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:`--port 3000`,fullWidth:!0})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-url`,children:`Server URL`}),(0,$.jsx)(G,{id:`mcp-url`,type:`url`,value:l,onChange:e=>u(e.target.value),placeholder:`https://example.com/mcp`,fullWidth:!0})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-auth`,children:`Authentication`}),(0,$.jsx)(`select`,{id:`mcp-auth`,value:h,onChange:e=>g(e.target.value),className:`w-full rounded-md border border-[var(--border-element)] bg-[var(--surface-lift)] px-3 py-1.5 text-body-medium-default text-[var(--content-default)] outline-none focus:ring-2 focus:ring-[var(--ring)]`,children:ut.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),h===`oauth`?(0,$.jsx)(`p`,{className:`rounded-md border border-[var(--border-element)] bg-[var(--surface-base)] px-3 py-2 text-body-small-default text-[var(--content-tertiary)]`,children:`OAuth credentials will be configured through a browser-based authorization flow after the server is added.`}):null,h===`bearer`?(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-bearer`,children:`Bearer token`}),(0,$.jsx)(G,{id:`mcp-bearer`,type:`password`,value:_,onChange:e=>v(e.target.value),placeholder:`tok_...`,fullWidth:!0})]}):null,h===`api-key`?(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-apikey-header`,children:`Header name`}),(0,$.jsx)(G,{id:`mcp-apikey-header`,type:`text`,value:y,onChange:e=>b(e.target.value),placeholder:`X-API-Key`,fullWidth:!0})]}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-apikey-value`,children:`API key`}),(0,$.jsx)(G,{id:`mcp-apikey-value`,type:`password`,value:x,onChange:e=>S(e.target.value),placeholder:`sk_...`,fullWidth:!0})]})]}):null]})]})}),(0,$.jsxs)(K.Footer,{children:[(0,$.jsx)(a,{variant:`ghost`,onClick:w,disabled:r,children:`Cancel`}),(0,$.jsx)(a,{variant:`primary`,onClick:T,disabled:!D||r,children:r?`Adding...`:`Add Server`})]})]})})}async function pt(e){let{data:t,response:n}=await X.get({url:`/v1/assistants/{assistant_id}/internal/mcp/list`,path:{assistant_id:e}});if(!n?.ok)throw Error(`Failed to fetch MCP servers: ${n?.status}`);return t}async function mt(e){let{data:t,response:n}=await X.get({url:`/v1/assistants/{assistant_id}/internal/mcp/tools-summary`,path:{assistant_id:e}});if(!n?.ok)throw Error(`Failed to fetch MCP tools summary: ${n?.status}`);return t}async function ht(e,t){let{response:n}=await X.post({url:`/v1/assistants/{assistant_id}/internal/mcp/update`,path:{assistant_id:e},body:t});if(!n?.ok)throw Error(`Failed to update MCP server: ${n?.status}`)}async function gt(e,t){let{response:n}=await X.post({url:`/v1/assistants/{assistant_id}/internal/mcp/add`,path:{assistant_id:e},body:t});if(!n?.ok)throw Error(`Failed to add MCP server: ${n?.status}`)}async function _t(e,t){let{response:n}=await X.post({url:`/v1/assistants/{assistant_id}/internal/mcp/remove`,path:{assistant_id:e},body:{name:t}});if(!n?.ok)throw Error(`Failed to remove MCP server: ${n?.status}`)}async function vt(e,t){let{data:n,response:r}=await X.post({url:`/v1/assistants/{assistant_id}/internal/mcp/auth/start`,path:{assistant_id:e},body:{serverId:t}});if(!r?.ok)throw Error(`Failed to start MCP auth: ${r?.status}`);return n}async function yt(e,t){let{data:n,response:r}=await X.get({url:`/v1/assistants/{assistant_id}/internal/mcp/auth/status/${encodeURIComponent(t)}`,path:{assistant_id:e}});if(!r?.ok)throw Error(`Failed to poll MCP auth status: ${r?.status}`);return n}async function bt(e,t){let{response:n}=await X.post({url:`/v1/assistants/{assistant_id}/internal/mcp/auth/revoke`,path:{assistant_id:e},body:{serverId:t}});if(!n?.ok)throw Error(`Failed to revoke OAuth for ${t}: ${n?.status}`)}async function xt(e){let{response:t}=await X.post({url:`/v1/assistants/{assistant_id}/internal/mcp/reload`,path:{assistant_id:e},body:{}});if(!t?.ok)throw Error(`Failed to reload MCP servers: ${t?.status}`)}var St={connected:{icon:j,label:`Connected`,className:`text-[var(--system-positive-strong)]`},"needs-auth":{icon:L,label:`Needs Auth`,className:`text-[var(--system-warning-strong)]`},disabled:{icon:te,label:`Disabled`,className:`text-[var(--content-tertiary)]`}},Ct={icon:A,label:`Error`,className:`text-[var(--system-negative-strong)]`};function wt({server:e,toolsSummary:t,onToggleEnabled:n,onRemove:r,onConfigure:i,onAuthenticate:o,onRevokeOAuth:s,isUpdating:c,isAuthenticating:l,isRevoking:u}){let[d,f]=(0,Q.useState)(!1),p=St[e.status]??Ct,m=p.icon,h=(0,Q.useCallback)(t=>n(e.id,t),[n,e.id]),g=(0,Q.useCallback)(()=>r(e.id),[r,e.id]),_=(0,Q.useCallback)(()=>i(e.id),[i,e.id]),v=(0,Q.useCallback)(()=>o(e.id),[o,e.id]),y=(0,Q.useCallback)(()=>s(e.id),[s,e.id]),b=(0,Q.useCallback)(()=>f(e=>!e),[]);return(0,$.jsx)(T.Root,{children:(0,$.jsxs)(T.Body,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:e.id}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-label-medium-default ${p.className}`,children:[(0,$.jsx)(m,{className:`h-3.5 w-3.5`}),p.label]}),e.hasOAuth?(0,$.jsx)(`span`,{className:`rounded-full bg-[var(--surface-lift)] px-2 py-0.5 text-label-small-default text-[var(--content-secondary)]`,children:`OAuth`}):null]}),(0,$.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)(`span`,{children:e.transport.type}),t?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,$.jsxs)(`span`,{children:[t.toolCount,` `,t.toolCount===1?`tool`:`tools`]}),(0,$.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,$.jsxs)(`span`,{children:[`~`,t.estimatedTokens.toLocaleString(),` tokens`]})]}):null]})]})}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[c||l?(0,$.jsx)(R,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}):null,e.status===`needs-auth`&&e.transport.type!==`stdio`&&!e.hasOAuth?(0,$.jsx)(a,{variant:`ghost`,size:`compact`,leftIcon:(0,$.jsx)(z,{}),onClick:v,disabled:l,children:l?`Authenticating...`:`Authenticate`}):null,e.hasOAuth?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(a,{variant:`ghost`,size:`compact`,leftIcon:(0,$.jsx)(ne,{}),onClick:v,disabled:l,tooltip:`Re-authenticate OAuth`,children:`Re-auth`}),(0,$.jsx)(a,{variant:`dangerGhost`,size:`compact`,leftIcon:(0,$.jsx)(ee,{}),onClick:y,disabled:u,tooltip:`Revoke OAuth credentials`,children:u?`Revoking...`:`Revoke`})]}):null,(0,$.jsx)(se,{checked:e.enabled,onChange:h,disabled:c,"aria-label":`${e.enabled?`Disable`:`Enable`} ${e.id}`}),(0,$.jsx)(a,{variant:`ghost`,size:`compact`,onClick:_,tooltip:`Configure`,children:`Configure`}),(0,$.jsx)(a,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,$.jsx)(U,{}),onClick:g,tooltip:`Remove server`,"aria-label":`Remove ${e.id}`})]})]}),t&&t.tools.length>0?(0,$.jsxs)(`div`,{className:`mt-3 border-t border-[var(--border-base)] pt-2`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:b,className:`flex w-full cursor-pointer items-center gap-1 text-body-small-default text-[var(--content-secondary)] hover:text-[var(--content-default)]`,children:[d?(0,$.jsx)(O,{className:`h-3.5 w-3.5`}):(0,$.jsx)(k,{className:`h-3.5 w-3.5`}),t.toolCount,` registered`,` `,t.toolCount===1?`tool`:`tools`]}),d?(0,$.jsx)(`div`,{className:`mt-2 max-h-60 overflow-y-auto`,children:t.tools.map(e=>(0,$.jsx)(F,{title:e.name,subtitle:e.description||void 0,trailing:(0,$.jsxs)(`span`,{className:`whitespace-nowrap text-body-small-default text-[var(--content-secondary)]`,children:[`~`,e.estimatedTokens.toLocaleString(),` tok`]})},e.name))}):null]}):null]})})}var Tt=[{value:`none`,label:`None`},{value:`bearer`,label:`Bearer Token`},{value:`api-key`,label:`API Key`}],Et=[`low`,`medium`,`high`];function Dt({server:e,toolsSummary:t,onClose:n,onSave:r,isPending:i}){let[o,s]=(0,Q.useState)(`medium`),[c,l]=(0,Q.useState)(`none`),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(`X-API-Key`),[m,h]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{e&&(s(e.defaultRiskLevel),l(e.authType),d(``),p(e.authHeaderName??`X-API-Key`),h(``))},[e]);let g=(0,Q.useCallback)(()=>{if(!e)return;let t=c!==e.authType,n=c===`bearer`&&u.trim()!==``,i=c===`api-key`&&f.trim()!==``&&m.trim()!==``,a=t||n||i,s;s=a?c===`none`?null:c===`bearer`&&u.trim()?{Authorization:`Bearer ${u.trim()}`}:c===`api-key`&&f.trim()&&m.trim()?{[f.trim()]:m.trim()}:void 0:void 0,r(e.id,{name:e.id,defaultRiskLevel:o,...s===void 0?{}:{headers:s}})},[e,o,c,u,f,m,r]),_=(0,Q.useCallback)(()=>{i||n()},[i,n]);return e?(0,$.jsx)(K.Root,{open:!!e,onOpenChange:e=>{e||_()},children:(0,$.jsxs)(K.Content,{size:`lg`,children:[(0,$.jsxs)(K.Header,{children:[(0,$.jsx)(K.Title,{icon:Ze,children:e.id}),(0,$.jsxs)(K.Description,{children:[e.transport.type,` transport · `,e.status]})]}),(0,$.jsx)(K.Body,{children:(0,$.jsxs)(`div`,{className:`space-y-5`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-risk`,children:`Default risk level`}),(0,$.jsx)(`select`,{id:`mcp-risk`,value:o,onChange:e=>s(e.target.value),className:`w-full rounded-md border border-[var(--border-element)] bg-[var(--surface-lift)] px-3 py-1.5 text-body-medium-default text-[var(--content-default)] outline-none focus:ring-2 focus:ring-[var(--ring)]`,children:Et.map(e=>(0,$.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),e.transport.type===`stdio`?null:(0,$.jsxs)($.Fragment,{children:[e.hasOAuth?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-[var(--border-element)] bg-[var(--surface-base)] px-3 py-2`,children:[(0,$.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Authentication`}),(0,$.jsx)(`span`,{className:`rounded-full bg-[var(--surface-lift)] px-2 py-0.5 text-label-small-default text-[var(--content-default)]`,children:`OAuth`}),(0,$.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`— managed via OAuth flow`})]}):null,e.hasOAuth?null:(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-detail-auth`,children:`Authentication`}),(0,$.jsx)(`select`,{id:`mcp-detail-auth`,value:c,onChange:e=>l(e.target.value),className:`w-full rounded-md border border-[var(--border-element)] bg-[var(--surface-lift)] px-3 py-1.5 text-body-medium-default text-[var(--content-default)] outline-none focus:ring-2 focus:ring-[var(--ring)]`,children:Tt.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),c===`bearer`&&!e.hasOAuth?(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-detail-bearer`,children:`Bearer token`}),(0,$.jsx)(G,{id:`mcp-detail-bearer`,type:`password`,value:u,onChange:e=>d(e.target.value),placeholder:e.hasStaticAuth&&e.authType===`bearer`?`•••••••• (leave blank to keep current)`:`tok_...`,fullWidth:!0})]}):null,c===`api-key`&&!e.hasOAuth?(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-detail-apikey-header`,children:`Header name`}),(0,$.jsx)(G,{id:`mcp-detail-apikey-header`,type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:`X-API-Key`,fullWidth:!0})]}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-detail-apikey-value`,children:`API key`}),(0,$.jsx)(G,{id:`mcp-detail-apikey-value`,type:`password`,value:m,onChange:e=>h(e.target.value),placeholder:e.hasStaticAuth&&e.authType===`api-key`?`•••••••• (leave blank to keep current)`:`sk_...`,fullWidth:!0})]})]}):null]}),t&&t.tools.length>0?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`h3`,{className:`text-body-medium-default text-[var(--content-default)]`,children:[`Registered tools (`,t.toolCount,`)`]}),(0,$.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[`Total estimated token overhead: ~`,t.estimatedTokens.toLocaleString(),` tokens`]}),(0,$.jsx)(`div`,{className:`max-h-64 overflow-y-auto rounded-lg border border-[var(--border-base)]`,children:(0,$.jsxs)(`table`,{className:`w-full text-body-small-default`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{className:`border-b border-[var(--border-base)] bg-[var(--surface-base)]`,children:[(0,$.jsx)(`th`,{className:`px-3 py-2 text-left font-medium text-[var(--content-secondary)]`,children:`Tool`}),(0,$.jsx)(`th`,{className:`px-3 py-2 text-left font-medium text-[var(--content-secondary)]`,children:`Description`}),(0,$.jsx)(`th`,{className:`px-3 py-2 text-right font-medium text-[var(--content-secondary)]`,children:`Tokens`})]})}),(0,$.jsx)(`tbody`,{children:t.tools.map(e=>(0,$.jsxs)(`tr`,{className:`border-b border-[var(--border-base)] last:border-b-0`,children:[(0,$.jsx)(`td`,{className:`px-3 py-2 font-medium text-[var(--content-default)]`,children:e.name}),(0,$.jsx)(`td`,{className:`max-w-xs truncate px-3 py-2 text-[var(--content-tertiary)]`,children:e.description||`—`}),(0,$.jsxs)(`td`,{className:`px-3 py-2 text-right text-[var(--content-tertiary)]`,children:[`~`,e.estimatedTokens.toLocaleString()]})]},e.name))})]})})]}):null]})}),(0,$.jsxs)(K.Footer,{children:[(0,$.jsx)(a,{variant:`ghost`,onClick:_,disabled:i,children:`Cancel`}),(0,$.jsx)(a,{variant:`primary`,onClick:g,disabled:i,children:i?`Saving...`:`Save`})]})]})}):null}var Ot=`mcp-servers`,kt=`mcp-tools-summary`,At=`Help me set up an MCP server to extend you with external tools.`;function jt(){let e=Ge(),t=p(),n=s(),r=Pe.use.mcpAddServer(),i=Pe.use.hasHydrated(),[o,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(new Set),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(null),{data:k,isLoading:A,isError:j}=S({queryKey:[Ot,e],queryFn:()=>pt(e)}),{data:M}=S({queryKey:[kt,e],queryFn:()=>mt(e)}),N=(0,Q.useCallback)(()=>{t.invalidateQueries({queryKey:[Ot,e]}),t.invalidateQueries({queryKey:[kt,e]})},[t,e]),P=(0,Q.useMemo)(()=>{let e=new Map;if(M)for(let t of M.servers)e.set(t.serverId,t);return e},[M]),F=(0,Q.useMemo)(()=>!l||!k?null:k.servers.find(e=>e.id===l)??null,[l,k]),I=(0,Q.useCallback)(async(t,n)=>{h(e=>new Set(e).add(t));try{await ht(e,{name:t,enabled:n}),N()}catch{J.error(`Failed to ${n?`enable`:`disable`} ${t}`)}finally{h(e=>{let n=new Set(e);return n.delete(t),n})}},[e,N]),L=(0,Q.useCallback)(async()=>{if(d){y(!0);try{await _t(e,d),N(),J.success(`Removed ${d}`),f(null)}catch{J.error(`Failed to remove ${d}`)}finally{y(!1)}}},[d,e,N]),z=(0,Q.useCallback)(async t=>{E(t);let n;try{n=await vt(e,t)}catch{J.error(`Failed to start authentication for ${t}`),E(null);return}try{if(n.already_authenticated){J.success(`${t} is already authenticated`),N();return}window.open(n.auth_url,`_blank`,`noopener,noreferrer`);for(let n=0;n<60;n++){await new Promise(e=>setTimeout(e,3e3));let n=await yt(e,t);if(n.status===`complete`){J.success(`${t} authenticated successfully`),N();return}if(n.status===`error`){J.error(n.error??`Authentication failed for ${t}`);return}}J.error(`Authentication timed out for ${t}`)}catch{J.error(`Authentication polling failed for ${t}`)}finally{E(null),N()}},[e,N]),ee=(0,Q.useCallback)(async t=>{O(t);try{await bt(e,t),N(),J.success(`OAuth credentials revoked for ${t}`)}catch{J.error(`Failed to revoke OAuth for ${t}`)}finally{O(null)}},[e,N]),B=(0,Q.useCallback)(async t=>{let n=t.autoAuth?window.open(`about:blank`,`_blank`,`noopener`):null;_(!0);try{await gt(e,t),N(),J.success(`Added ${t.name}`),c(!1)}catch{J.error(`Failed to add ${t.name}`),n?.close(),_(!1);return}if(_(!1),t.autoAuth){E(t.name);try{let r=await vt(e,t.name);if(r.already_authenticated){n?.close(),J.success(`${t.name} is already authenticated`),N();return}n?n.location.href=r.auth_url:window.open(r.auth_url,`_blank`,`noopener,noreferrer`);for(let n=0;n<60;n++){await new Promise(e=>setTimeout(e,3e3));let n=await yt(e,t.name);if(n.status===`complete`){J.success(`${t.name} authenticated successfully`),N();return}if(n.status===`error`){J.error(n.error??`Authentication failed for ${t.name}`);return}}J.error(`Authentication timed out for ${t.name}`)}catch{n?.close(),J.error(`Failed to start authentication for ${t.name}`)}finally{E(null),N()}}},[e,N]),te=(0,Q.useCallback)(async(t,n)=>{x(!0);try{await ht(e,n),N(),J.success(`Updated ${t}`),u(null)}catch{J.error(`Failed to update ${t}`)}finally{x(!1)}},[e,N]),H=(0,Q.useCallback)(async()=>{w(!0);try{await xt(e),N(),J.success(`MCP servers reloaded`)}catch{J.error(`Failed to reload MCP servers`)}finally{w(!1)}},[e,N]),re=(0,Q.useCallback)(()=>{r?c(!0):Oe(n,{prompt:At})},[r,n]),ie=k?.servers??[];return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-title-small text-[var(--content-default)]`,children:`MCP Servers`}),(0,$.jsx)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:`Manage Model Context Protocol server connections and their registered tools.`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(a,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(ne,{className:C?`animate-spin`:``}),onClick:H,disabled:C,tooltip:`Reload all servers`,"aria-label":`Reload MCP servers`}),r?(0,$.jsx)(a,{variant:`primary`,size:`compact`,leftIcon:(0,$.jsx)(V,{}),onClick:()=>c(!0),children:`Add Server`}):null]})]}),M?(0,$.jsxs)(`div`,{className:`flex gap-4 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsxs)(`span`,{children:[M.totalToolCount,` total`,` `,M.totalToolCount===1?`tool`:`tools`]}),(0,$.jsxs)(`span`,{children:[`~`,M.totalEstimatedTokens.toLocaleString(),` total tokens`]})]}):null,A?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,$.jsx)(R,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{children:`Loading MCP servers...`})]}):j?(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Failed to load MCP servers. Check that an assistant is running.`}):ie.length===0?(0,$.jsxs)(`button`,{type:`button`,onClick:re,disabled:!i,className:`flex w-full flex-col items-center gap-2 rounded-lg border border-dashed border-[var(--border-element)] px-4 py-12 text-center transition-colors hover:border-[var(--border-active)] hover:bg-[var(--surface-hover)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)] disabled:pointer-events-none`,children:[(0,$.jsx)(Ze,{className:`h-6 w-6 text-[var(--content-disabled)]`}),(0,$.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`No MCP Servers`}),(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:r?`Add an MCP server to extend your assistant with external tools.`:`Chat with your assistant to set up an MCP server.`})]}):(0,$.jsx)(`div`,{className:`space-y-2`,children:ie.map(e=>(0,$.jsx)(wt,{server:e,toolsSummary:P.get(e.id),onToggleEnabled:I,onRemove:f,onConfigure:u,onAuthenticate:z,onRevokeOAuth:ee,isUpdating:m.has(e.id),isAuthenticating:T===e.id,isRevoking:D===e.id},e.id))}),r?(0,$.jsx)(ft,{open:o,onClose:()=>c(!1),onAdd:B,isPending:g}):null,(0,$.jsx)(Dt,{server:F,toolsSummary:l?P.get(l):void 0,onClose:()=>u(null),onSave:te,isPending:b}),(0,$.jsx)(Y,{open:!!d,title:`Remove MCP Server`,message:`Are you sure you want to remove "${d}"? This will disconnect all tools provided by this server.`,confirmLabel:`Remove`,destructive:!0,isPending:v,onConfirm:L,onCancel:()=>f(null)})]})}function Mt(){return(0,$.jsx)(jt,{})}var Nt=`vellum:integrations:bannerDismissed`,Pt=[{value:`all`,label:`All`},{value:`enabled`,label:`Enabled`},{value:`not-enabled`,label:`Not Enabled`}];function Ft(e,t){return e?.find(e=>e.provider===t)??null}function It(e){return e===`mcp`?`mcp`:`oauth`}function Lt(){let[e]=o(),i=s(),a=me(),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(!0),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(`all`),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!0),[b,x]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{y(t(Nt,`false`)===`true`)},[]);let C=()=>{y(!0),n(Nt,`true`)};(0,Q.useEffect)(()=>{let e=!0;return(async()=>{try{let t=await de();e&&t.ok&&l(t.data)}catch(e){r(e,{context:`integrations.getAssistant`})}finally{e&&d(!1)}})(),()=>{e=!1}},[]);let{platformAssistantId:w,isLoading:T}=Ke(c?.id,a===`full`),{data:E,isLoading:D,isError:k}=S({...be({path:{assistant_id:c?.id??``}}),select:e=>e.providers,enabled:!!c}),{data:A,isLoading:j}=S({...Z({path:{assistant_id:w??``}}),enabled:!!w&&a===`full`});(0,Q.useEffect)(()=>{let t=e.get(`oauth_status`);if(!t)return;let n=e.get(`oauth_provider`),r=n?n.charAt(0).toUpperCase()+n.slice(1):null;if(t===`connected`)J.success(r?`${r} account connected successfully.`:`Account connected successfully.`);else if(t===`error`){let t=e.get(`oauth_code`)??`unknown`;J.error({denied:`Authorization was denied. Please try again.`,state_invalid:`Authorization state was invalid. Please try again.`,state_expired:`Authorization expired. Please try again.`,exchange_failed:`Failed to complete authorization. Please try again.`,identity_failed:`Failed to verify account identity. Please try again.`}[t]??(r?`Failed to connect ${r}.`:`Failed to connect. Please try again.`))}i(pe.settings.integrations,{replace:!0})},[e,i]);let M=(0,Q.useMemo)(()=>E?.filter(e=>e.supports_managed_mode)??[],[E]),N=(0,Q.useMemo)(()=>{let e=f.trim().toLowerCase(),t=M.filter(t=>{if(t.provider_key===`slack`)return!1;if(!e)return!0;let n=(t.display_name??t.provider_key).toLowerCase(),r=(t.description??``).toLowerCase();return n.includes(e)||r.includes(e)});return m!==`all`&&(t=t.filter(e=>{let t=!!Ft(A,e.provider_key)?.connected;return m===`enabled`?t:!t})),[...t].sort((e,t)=>{let n=!!Ft(A,e.provider_key)?.connected;if(n!==!!Ft(A,t.provider_key)?.connected)return n?-1:1;let r=(e.display_name??e.provider_key).toLowerCase(),i=(t.display_name??t.provider_key).toLowerCase();return r.localeCompare(i)})},[M,A,f,m]),P=u||D||j||T,F=Pt.find(e=>e.value===m)?.label??`All`,I=(()=>{if(f.trim())return`No integrations matched`;switch(m){case`enabled`:return`No Enabled Integrations`;case`not-enabled`:return`All Integrations Are Enabled`;default:return`No Integrations Available`}})(),L=(()=>{if(f.trim())return`No integrations matched "${f.trim()}"`;switch(m){case`enabled`:return`Connect an integration to get started.`;case`not-enabled`:return`All available integrations have been connected.`;default:return`Check your connection and try again.`}})(),z=(0,Q.useMemo)(()=>b?M.find(e=>e.provider_key===b)??null:null,[M,b]);return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[!v&&(0,$.jsxs)(oe,{tone:`info`,icon:(0,$.jsx)(ie,{className:`h-3.5 w-3.5`}),onDismiss:C,children:[(0,$.jsx)(`span`,{className:`text-body-medium-default`,children:`Tip:`}),` You can enable integrations by mentioning them in chat.`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(G,{type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:`Search Integrations`,"aria-label":`Search integrations`,leftIcon:(0,$.jsx)(re,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),fullWidth:!0,wrapperClassName:`flex-1`}),(0,$.jsxs)(W.Root,{open:g,onOpenChange:_,children:[(0,$.jsx)(W.Trigger,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"aria-haspopup":`listbox`,"aria-expanded":g,className:`flex w-36 cursor-pointer items-center justify-between gap-2 rounded-md border border-[var(--border-element)] bg-[var(--surface-lift)] px-3 py-1.5 text-body-medium-lighter text-[var(--content-default)] transition-colors hover:bg-[var(--ghost-hover)]`,children:[(0,$.jsx)(`span`,{children:F}),(0,$.jsx)(O,{className:`h-3.5 w-3.5`})]})}),(0,$.jsx)(W.Content,{align:`end`,sideOffset:4,className:`w-36 overflow-hidden p-0`,children:(0,$.jsx)(`div`,{role:`listbox`,children:Pt.map(e=>{let t=e.value===m;return(0,$.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>{h(e.value),_(!1)},className:`flex w-full cursor-pointer items-center px-3 py-1.5 text-left hover:bg-[var(--ghost-hover)] ${t?`text-body-medium-default text-[var(--content-default)]`:`text-body-medium-lighter text-[var(--content-default)]`}`,children:e.label},e.value)})})})]})]}),(0,$.jsx)(`div`,{children:P?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,$.jsx)(R,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{children:`Loading...`})]}):k?(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Failed to load integrations. Please try again.`}):c?N.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2 rounded-lg border border-dashed border-[var(--border-element)] px-4 py-12 text-center`,children:[(0,$.jsx)(re,{className:`h-6 w-6 text-[var(--content-disabled)]`}),(0,$.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:I}),(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:L})]}):(0,$.jsx)(`div`,{className:`space-y-2`,children:N.map(e=>(0,$.jsx)(ct,{platformAssistantId:w??c.id,providerKey:e.provider_key,displayName:e.display_name??e.provider_key,description:e.description,logoUrl:e.logo_url,connection:Ft(A,e.provider_key),platformGate:a,onConfigure:()=>x(e.provider_key)},e.provider_key))}):(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No assistant found. Hatch an assistant to connect integrations.`})}),z&&c&&(0,$.jsx)(ot,{assistantId:c.id,platformAssistantId:w??c.id,providerKey:z.provider_key,displayName:z.display_name??z.provider_key,description:z.description,logoUrl:z.logo_url,platformGate:a,onClose:()=>x(null)})]})}function Rt(){let[e,t]=o(),n=It(e.get(`tab`));return(0,$.jsx)(`div`,{className:`space-y-6`,children:(0,$.jsxs)(N.Root,{value:n,onValueChange:n=>{let r=It(n),i=new URLSearchParams(e);r===`mcp`?i.set(`tab`,`mcp`):i.delete(`tab`),t(i,{replace:!0})},children:[(0,$.jsxs)(N.List,{children:[(0,$.jsx)(N.Trigger,{value:`oauth`,children:`OAuth`}),(0,$.jsx)(N.Trigger,{value:`mcp`,children:`MCP`})]}),(0,$.jsx)(N.Panel,{value:`oauth`,className:`pt-4`,children:(0,$.jsx)(Q.Suspense,{children:(0,$.jsx)(Lt,{})})}),(0,$.jsx)(N.Panel,{value:`mcp`,className:`pt-4`,children:(0,$.jsx)(Mt,{})})]})})}export{Rt as IntegrationsPage};
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{i as t,l as n}from"./local-settings-Bx7FsNo5.js";import{t as r}from"./capture-error-FWzaVb8P.js";import{t as i}from"./react-BFJW0bSv.js";import{t as a}from"./button-Dy5001j6.js";import{m as o,u as s}from"./chunk-5KNZJZUH-Bsoom5--.js";import{N as c,O as l,S as u,T as d,c as f,n as p}from"./QueryClientProvider-CMu7CkQU.js";import{a as m,c as h,d as g,i as _,l as v,o as y,r as b,s as x,t as S,u as C}from"./useQuery-Bz-fbQ-m.js";import{t as w}from"./jsx-runtime-D3ZM-ToX.js";import{t as T}from"./card-DRIctGVs.js";import{t as E}from"./createLucideIcon-CAM1RhH8.js";import{t as D}from"./check-sC49_hjU.js";import{t as O}from"./chevron-down-B5A-0g8A.js";import{t as k}from"./chevron-right-HU6H84S0.js";import{t as A}from"./circle-alert-DVCpoZrc.js";import{t as j}from"./circle-check-CjGnAahM.js";import{t as M}from"./circle-x-17dBxF06.js";import{n as N,o as P,t as F}from"./list-row-BYrmPIC4.js";import{t as I}from"./external-link-CAce-RVu.js";import{t as L}from"./key-round-CSc3w5ka.js";import{t as R}from"./loader-circle-BzJ2kz3F.js";import{t as z}from"./log-in-Bhye1kwc.js";import{t as ee}from"./log-out-BLE632qu.js";import{t as B}from"./pencil-CLJIvYKH.js";import{t as V}from"./plus-JG7kWjHA.js";import{n as te,t as H}from"./integration-icon-tiuVoy54.js";import{t as ne}from"./refresh-cw-Ci7hSykC.js";import{t as re}from"./search-DA3TmTuR.js";import{t as ie}from"./sparkles-DC8kqYjt.js";import{t as U}from"./trash-2-De6X8YiM.js";import{t as ae}from"./x-DuBvjmAE.js";import{t as oe}from"./notice-DCp7WO3L.js";import{t as W}from"./popover-BFL-uOLh.js";import{t as G}from"./input-C-GkeWCw.js";import{t as se}from"./toggle-D776PTw-.js";import{t as K}from"./modal-DwsThLGg.js";import{n as q,t as ce}from"./panel-item-DGs4s9r-.js";import{n as J}from"./toast-DR7D7Uma.js";import{t as Y}from"./confirm-dialog-DZX6LhLy.js";import{r as le}from"./api-errors-SZKDzMLE.js";import{J as ue}from"./auth-store-D55YOXDj.js";import{Kr as X}from"./sdk.gen-BySz4QYj.js";import{r as de}from"./api-C0nyw19F.js";import{m as fe}from"./native-biometric-K90ZnTI1.js";import{d as pe}from"./routes-Dwx_Ibh9.js";import{i as me,t as he}from"./use-platform-gate-Oc-w11de.js";import{$ as ge,an as _e,et as ve,in as ye,it as be,nn as xe,nt as Se,rn as Ce,rt as we,tt as Te}from"./react-query.gen-Cnk5tcFs.js";import{n as Ee,r as De}from"./browser-BaaiMPkj.js";import{n as Oe}from"./conversation-navigation-CYonSeT9.js";import{n as ke}from"./use-is-mobile-Cx2xnNUx.js";import{Dt as Ae,Ot as je,S as Me,b as Z,x as Ne}from"./react-query.gen-BGUTzcTG.js";import{t as Pe}from"./assistant-feature-flag-store-Ci_346FY.js";import{a as Fe,i as Ie,n as Le,r as Re}from"./oauth-connection-utils-BHC1Orld.js";import{a as ze,i as Be,n as Ve,t as He}from"./oauth-popup-Ql5xgtlO.js";import{t as Ue}from"./copy-to-clipboard-DaTa8Tbi.js";import{t as We}from"./platform-login-notice-D3MegklO.js";import{t as Ge}from"./use-active-assistant-id-AtGy8p_R.js";import{t as Ke}from"./use-platform-assistant-id-DhMrx-n9.js";function qe(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Je(e,t,n){let r=e.slice(0);return r[t]=n,r}var Ye=class extends c{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,f.batch(()=>{let e=this.#i,t=this.#f(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!l(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(qe(e,n).forEach(e=>{e.destroy()}),qe(n,e).forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})),this.#m()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#f(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=d(this.#a,t(e))),this.#a}return e}#f(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new g(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#p(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Je(this.#t,n,t),this.#m())}#m(){if(this.hasListeners()){let e=this.#a,t=this.#u(this.#t,this.#l);e!==this.#d(t,this.#r?.combine)&&f.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},Q=e(i(),1);function Xe({queries:e,...t},n){let r=p(n),i=C(),a=v(),o=Q.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{b(e),y(e,a,r.getQueryCache().get(e.queryHash))}),h(a);let[s]=Q.useState(()=>new Ye(r,o,t)),[c,l,d]=s.getOptimisticResult(o,t.combine),S=!i&&t.subscribed!==!1;Q.useSyncExternalStore(Q.useCallback(e=>S?s.subscribe(f.batchCalls(e)):u,[s,S]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),Q.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let w=c.some((e,t)=>m(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&m(n,e)?_(n,new g(r,n),a):[]}):[];if(w.length>0)throw Promise.all(w);let T=c.find((e,t)=>{let n=o[t];return n&&x({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(T?.error)throw T.error;return l(d())}var Ze=E(`cable`,[[`path`,{d:`M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z`,key:`trhst0`}],[`path`,{d:`M17 21v-2`,key:`ds4u3f`}],[`path`,{d:`M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10`,key:`1mo9zo`}],[`path`,{d:`M21 21v-2`,key:`eo0ou`}],[`path`,{d:`M3 5V3`,key:`1k5hjh`}],[`path`,{d:`M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z`,key:`1dd30t`}],[`path`,{d:`M7 5V3`,key:`1t1388`}]]),Qe=E(`calendar-plus`,[[`path`,{d:`M16 19h6`,key:`xwg31i`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M19 16v6`,key:`tddt3s`}],[`path`,{d:`M21 12.598V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8.5`,key:`1glfrc`}],[`path`,{d:`M3 10h18`,key:`8toen8`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}]]);function $e({assistantId:e,providerKey:t,displayName:n,managedAvailable:r,connectionsQueryKey:i,allConnections:a}){let o=p(),s=fe(),c=(0,Q.useRef)(null),l=(0,Q.useRef)(null),u=(0,Q.useRef)(null),d=(0,Q.useRef)(null),[f,m]=(0,Q.useState)(!1),h=()=>{l.current=null,m(!1)},g=()=>{c.current&&!c.current.closed&&c.current.close(),c.current=null,u.current&&=(clearInterval(u.current),null),d.current&&=(clearTimeout(d.current),null)},_=(0,Q.useCallback)(e=>{if(e.type!==`vellum:oauth-complete`||!l.current||e.requestId!==l.current.requestId)return;let{oauthStatus:t,oauthCode:r}=e;if(g(),h(),t===`connected`)J.success(`${n} account connected.`),o.invalidateQueries({queryKey:i});else{let e=r?`Error: ${r}`:`Authorization failed`;J.error(`${n} ${e}`)}},[i,n,o]),v=(0,Q.useCallback)(async(e,n)=>{if(!r)return!1;for(let r=0;r<8;r+=1){r>0&&await Ie(750);try{if(o.invalidateQueries({queryKey:i}),Re(await o.fetchQuery({...Z({path:{assistant_id:e}}),staleTime:0}),t,n))return!0}catch{}}return!1},[i,r,t,o]);(0,Q.useEffect)(()=>{let e=e=>{let t=l.current;if(!t)return;let n=He(e,window.location.origin,t.requestId);n&&_(n)},t=e=>{let t=l.current;if(!t)return;let n=Ve(e,t.requestId);n&&(_(n),window.localStorage.removeItem(Be(t.requestId)))};return window.addEventListener(`message`,e),window.addEventListener(`storage`,t),()=>{window.removeEventListener(`message`,e),window.removeEventListener(`storage`,t)}},[_]),Fe((0,Q.useCallback)(e=>{let t=l.current;t&&e.requestId===t.requestId&&_({type:`vellum:oauth-complete`,requestId:e.requestId,oauthStatus:e.oauthStatus,oauthProvider:e.oauthProvider,oauthCode:e.oauthCode})},[_])),(0,Q.useEffect)(()=>De(()=>{let e=l.current;e&&(async()=>{let t=await v(e.platformAssistantId,e.baselineConnectionSignatures);l.current&&(h(),t&&J.success(`${n} account connected.`))})()}),[v,n]),(0,Q.useEffect)(()=>()=>{u.current&&clearInterval(u.current),d.current&&clearTimeout(d.current),c.current&&!c.current.closed&&c.current.close()},[]);let y=je();return{handleConnect:(i=[])=>{if(!r)return;let f=crypto.randomUUID();m(!0);let p=async r=>{let c;try{c=await ue(e)}catch(e){g(),h(),J.error(e instanceof Error?e.message:`Failed to start ${n} authorization.`);return}let u=Le(await o.fetchQuery({...Z({path:{assistant_id:c}}),staleTime:0}).catch(()=>c===e?a??[]:[]),t);l.current={requestId:f,provider:t,platformAssistantId:c,baselineConnectionSignatures:u},y.mutate({path:{assistant_id:c,provider:t},body:{requested_scopes:i,redirect_after_connect:`${pe.account.oauth.popupComplete}?requestId=${f}${s?`&native=1`:``}`}},{onSuccess(e){if(s){Ee(e.connect_url);return}r&&!r.closed?r.location.href=e.connect_url:l.current&&(g(),h(),J.error(`${n} connection failed: popup closed.`))},onError(e){g(),h();let t=le(e,void 0,`Failed to start ${n} authorization.`);J.error(t)}})};if(s){p(null);return}let b=window.open(``,`_blank`,`width=500,height=600`);if(b===null){h(),J.error(`Popup blocked. Please enable popups and try again.`);return}c.current=b,u.current=setInterval(()=>{c.current&&c.current.closed&&l.current&&!d.current&&(d.current=setTimeout(async()=>{d.current=null;let e=l.current;if(!e)return;let t=window.localStorage.getItem(Be(e.requestId));if(t){let n=ze(t);if(n&&n.requestId===e.requestId){_(n),window.localStorage.removeItem(Be(e.requestId));return}}let r=await v(e.platformAssistantId,e.baselineConnectionSignatures);if(l.current){if(r){g(),h(),J.success(`${n} account connected.`);return}g(),h(),J.error(`${n} connection failed: authorization popup closed.`)}},1e3))},100),p(b)},oauthInProgress:f,startOAuthPending:y.isPending}}var $=w();function et({displayName:e,providerKey:t,logoUrl:n,connections:r,connectionsLoading:i,startPending:o,oauthInProgress:s,disconnectingId:c,onConnect:l,onDisconnect:u,connectPresets:d=[]}){let f=o||s;return i?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,$.jsx)(R,{className:`h-5 w-5 animate-spin text-[var(--content-disabled)]`})}):r.length===0?o||s?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-10`,children:[(0,$.jsx)(H,{providerKey:t,displayName:e,logoUrl:n,size:48}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,$.jsx)(R,{className:`h-3.5 w-3.5 animate-spin`}),`Waiting for authorization...`]})]}):(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-10`,children:[(0,$.jsx)(H,{providerKey:t,displayName:e,logoUrl:n,size:48}),(0,$.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:`Connect Account to continue`}),(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,$.jsx)(a,{variant:`primary`,size:`compact`,leftIcon:(0,$.jsx)(V,{}),onClick:()=>l(),disabled:f,children:`Connect Account`}),d.map(e=>(0,$.jsx)(a,{variant:`outlined`,size:`compact`,leftIcon:(0,$.jsx)(Qe,{}),onClick:()=>l(e.scopes),disabled:f,children:e.label},e.id))]})]}):(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)]`,children:[(0,$.jsx)(`ul`,{className:`divide-y divide-[var(--border-base)]`,children:r.map(r=>{let i=c===r.id;return(0,$.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3`,children:[(0,$.jsx)(H,{providerKey:t,displayName:e,logoUrl:n,size:20}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body-medium-default text-[var(--content-default)]`,children:r.account_label??`${e} Account`}),(0,$.jsx)(a,{variant:`dangerOutline`,size:`compact`,iconOnly:i?(0,$.jsx)(R,{className:`animate-spin`}):(0,$.jsx)(U,{}),onClick:()=>u(r),disabled:i,"aria-label":`Disconnect ${r.account_label??`${e} account`}`})]},r.id)})}),(0,$.jsx)(`div`,{className:`border-t border-[var(--border-base)] px-4 py-3 dark:border-[var(--border-base)]`,children:f?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,$.jsx)(R,{className:`h-3.5 w-3.5 animate-spin`}),`Waiting for authorization...`]}):(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(a,{variant:`primary`,size:`compact`,leftIcon:(0,$.jsx)(I,{}),onClick:()=>l(),disabled:f,children:`Connect account`}),d.map(e=>(0,$.jsx)(a,{variant:`outlined`,size:`compact`,leftIcon:(0,$.jsx)(Qe,{}),onClick:()=>l(e.scopes),disabled:f,children:e.label},e.id))]})})]})}function tt(e){return e.length>16?`${e.slice(0,12)}…${e.slice(-4)}`:e.length>8?`${e.slice(0,8)}…`:e}function nt(e){try{return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}catch{return``}}function rt({assistantId:e,providerKey:t,displayName:n,logoUrl:r}){let i=p(),o=S({...Te({path:{assistant_id:e},query:{provider_key:t}}),select:e=>e.apps}),s=S({...we({path:{assistant_id:e,providerKey:t}}),select:e=>e.oauth_callback_url}),c=o.data??[],l=s.data??null,u=Xe({queries:c.map(t=>({...ge({path:{assistant_id:e,appId:t.id}}),select:e=>e.connections}))}),d={};c.forEach((e,t)=>{d[e.id]=u[t]?.data??[]});let f=Se({path:{assistant_id:e},query:{provider_key:t}}),m=ye({onSuccess:()=>{i.invalidateQueries({queryKey:f}),x(``),w(``),y(!1),J.success(`${n} OAuth app added.`)},onError:e=>{J.error(e.message||`Failed to create OAuth app`)}}),h=Ce({onSuccess:()=>{i.invalidateQueries({queryKey:f}),J.success(`OAuth app deleted.`)},onError:e=>{J.error(e.message||`Failed to delete OAuth app`)}}),g=xe({onSuccess:e=>{`auth_url`in e&&(window.location.href=e.auth_url)},onError:e=>{J.error(e.message||`Failed to start OAuth flow`)}}),_=_e(),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(``),[E,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(null),N=m.isPending,F=h.isPending?h.variables?.path?.id??null:null,L=g.isPending?g.variables?.path?.appId??null:null,z=_.isPending?_.variables?.path?.id??null:null,ee=()=>{let n=b.trim(),r=C.trim();!n||!r||m.mutate({path:{assistant_id:e},body:{provider_key:t,client_id:n,client_secret:r}})},B=()=>{let t=k;A(null),t&&h.mutate({path:{assistant_id:e,id:t.id}})},te=t=>{g.mutate({path:{assistant_id:e,appId:t.id},body:{callback_transport:`gateway`,scopes:[]}})};return o.isLoading?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,$.jsx)(R,{className:`h-5 w-5 animate-spin text-[var(--content-disabled)]`})}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[c.length===0||v?(0,$.jsx)(T.Root,{children:(0,$.jsxs)(T.Body,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:c.length===0?`Add your own ${n} OAuth app`:`Add another ${n} OAuth app`}),(0,$.jsx)(`p`,{className:`text-body-small-default leading-relaxed text-[var(--content-tertiary)]`,children:`Credentials are stored encrypted on the assistant and are never sent to Vellum.`})]}),l?(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Redirect URL`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(G,{type:`text`,value:l,readOnly:!0,fullWidth:!0}),(0,$.jsx)(a,{type:`button`,variant:`outlined`,size:`compact`,onClick:()=>{Ue(l,{successMessage:`Copied to clipboard!`,errorMessage:`Couldn't copy the redirect URL.`,onCopied:()=>{O(!0),setTimeout(()=>O(!1),2e3)}})},"aria-label":E?`Copied`:`Copy redirect URL`,iconOnly:E?(0,$.jsx)(D,{"aria-hidden":!0}):(0,$.jsx)(P,{"aria-hidden":!0})})]}),(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Add this URL to your OAuth app's redirect settings.`})]}):null,(0,$.jsx)(G,{label:`Client ID`,type:`text`,value:b,onChange:e=>x(e.target.value),placeholder:`Enter your client ID`,fullWidth:!0}),(0,$.jsx)(G,{label:`Client Secret`,type:`password`,value:C,onChange:e=>w(e.target.value),placeholder:`Enter your client secret`,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 pt-1`,children:[c.length>0?(0,$.jsx)(a,{type:`button`,variant:`outlined`,size:`compact`,onClick:()=>{y(!1),x(``),w(``)},disabled:N,children:`Cancel`}):null,(0,$.jsx)(a,{type:`button`,size:`compact`,onClick:ee,disabled:N||!b.trim()||!C.trim(),leftIcon:N?(0,$.jsx)(R,{className:`animate-spin`,"aria-hidden":!0}):(0,$.jsx)(V,{"aria-hidden":!0}),children:`Add App`})]})]})}):null,c.map(e=>{let i=d[e.id]??[],o=F===e.id,s=L===e.id;return(0,$.jsx)(T.Root,{children:(0,$.jsxs)(T.Body,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,$.jsx)(`p`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:tt(e.client_id)}),(0,$.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[`Added `,nt(e.created_at)]})]}),(0,$.jsx)(a,{type:`button`,variant:`dangerOutline`,size:`compact`,onClick:()=>A(e),disabled:o,"aria-label":`Delete OAuth app ${tt(e.client_id)}`,iconOnly:o?(0,$.jsx)(R,{className:`animate-spin`,"aria-hidden":!0}):(0,$.jsx)(U,{"aria-hidden":!0})})]}),i.length>0?(0,$.jsx)(`ul`,{className:`divide-y divide-[var(--border-base)] overflow-hidden rounded-md border border-[var(--border-base)] dark:divide-[var(--border-base)] dark:border-[var(--border-base)]`,children:i.map(i=>{let o=z===i.id;return(0,$.jsxs)(`li`,{className:`flex items-center gap-3 px-3 py-2`,children:[(0,$.jsx)(H,{providerKey:t,displayName:n,logoUrl:r,size:18}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body-medium-lighter text-[var(--content-default)]`,children:i.account_info??`${n} Account`}),(0,$.jsx)(a,{type:`button`,variant:`dangerOutline`,size:`compact`,onClick:()=>M({appId:e.id,connection:i}),disabled:o,"aria-label":`Disconnect ${i.account_info??`${n} account`}`,iconOnly:o?(0,$.jsx)(R,{className:`animate-spin`,"aria-hidden":!0}):(0,$.jsx)(U,{"aria-hidden":!0})})]},i.id)})}):null,(0,$.jsx)(a,{type:`button`,size:`compact`,onClick:()=>te(e),disabled:s,className:`w-full`,leftIcon:s?(0,$.jsx)(R,{className:`animate-spin`,"aria-hidden":!0}):(0,$.jsx)(I,{"aria-hidden":!0}),children:s?`Waiting for authorization...`:`Connect account`})]})},e.id)}),c.length>0&&!v?(0,$.jsx)(a,{type:`button`,variant:`outlined`,size:`compact`,onClick:()=>y(!0),className:`w-full border-dashed`,leftIcon:(0,$.jsx)(V,{"aria-hidden":!0}),children:`Add Another App`}):null,(0,$.jsx)(Y,{open:k!==null,title:`Delete OAuth app`,message:k?`Delete OAuth app '${tt(k.client_id)}'? This will disconnect all linked accounts.`:``,confirmLabel:`Delete`,destructive:!0,onConfirm:B,onCancel:()=>A(null)}),(0,$.jsx)(Y,{open:j!==null,title:`Disconnect ${n}?`,message:j?`Disconnect ${j.connection.account_info??`${n} Account`}? You can reconnect later.`:``,confirmLabel:`Disconnect`,destructive:!0,onConfirm:()=>{let t=j;M(null),t&&_.mutate({path:{assistant_id:e,id:t.connection.id}},{onSuccess:()=>{let r=ve({path:{assistant_id:e,appId:t.appId}});i.invalidateQueries({queryKey:r}),i.invalidateQueries({queryKey:f}),J.success(`${n} account disconnected.`)},onError:e=>{J.error(e.message||`Failed to disconnect account`)}})},onCancel:()=>M(null)})]})}var it={};function at(e){return it[e]??[]}function ot({assistantId:e,platformAssistantId:t,providerKey:n,displayName:r,description:i,logoUrl:o,platformGate:s,onClose:c}){let l=p(),u=s===`full`,d=!he(),[f,m]=(0,Q.useState)(s===`gated`&&d?`your-own`:`managed`);(0,Q.useEffect)(()=>{!d&&f===`your-own`&&m(`managed`)},[d,f]);let[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(null),y=Ne({path:{assistant_id:t}}),{data:b,isLoading:x}=S({...Z({path:{assistant_id:t}}),enabled:u}),C=(b??[]).filter(e=>e.provider===n&&e.connected),{handleConnect:w,oauthInProgress:T,startOAuthPending:E}=$e({assistantId:e,providerKey:n,displayName:r,managedAvailable:u,connectionsQueryKey:y,allConnections:b}),D={path:{assistant_id:t}},O=Ae({onSuccess(e,t){J.success(`${r} account disconnected.`);let n=t.path.connection_id;Me(l,D,e=>e?.filter(e=>e.id!==n)),l.invalidateQueries({queryKey:y}),g(null)},onError(e){let t=le(e,void 0,`Failed to disconnect ${r} account.`);J.error(t),g(null)}});(0,Q.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!e.defaultPrevented&&(e.preventDefault(),c())};document.addEventListener(`keydown`,e);let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,e),document.body.style.overflow=t}},[c]);let k=e=>{v(e)},A=()=>{let e=_;v(null),e&&(g(e.id),O.mutate({path:{assistant_id:t,connection_id:e.id}}))},j=i?`Configure ${r} OAuth for ${i}`:`Configure ${r} OAuth`;return(0,$.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,children:[(0,$.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`integration-modal-title`,className:`flex w-full max-w-[520px] flex-col overflow-hidden rounded-xl bg-white shadow-xl dark:bg-[var(--surface-lift)]`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-[var(--border-base)] px-5 py-4 dark:border-[var(--border-base)]`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(H,{providerKey:n,displayName:r,logoUrl:o,size:32}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`h2`,{id:`integration-modal-title`,className:`text-title-small text-[var(--content-default)]`,children:[r,` OAuth`]}),(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:j})]})]}),(0,$.jsx)(a,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(ae,{}),"aria-label":`Close`,onClick:c})]}),(0,$.jsxs)(`div`,{className:`space-y-4 px-5 py-4`,children:[s!==`gated`&&d&&(0,$.jsxs)(`div`,{role:`tablist`,"aria-label":`OAuth mode`,className:`flex w-full rounded-md border border-[var(--border-base)] bg-[var(--surface-base)] p-0.5 dark:border-[var(--border-base)] dark:bg-[var(--surface-base)]/40`,children:[(0,$.jsx)(st,{active:f===`managed`,onClick:()=>m(`managed`),children:`Managed`}),(0,$.jsx)(st,{active:f===`your-own`,onClick:()=>m(`your-own`),children:`Your Own`})]}),f===`managed`&&s!==`gated`?s===`disabled`?(0,$.jsx)(We,{children:`Log in to the Vellum platform to manage OAuth connections.`}):(0,$.jsx)(et,{displayName:r,providerKey:n,logoUrl:o,connections:C,connectionsLoading:x,startPending:E,oauthInProgress:T,disconnectingId:O.isPending?h:null,onConnect:w,onDisconnect:k,connectPresets:at(n)}):d?(0,$.jsx)(rt,{assistantId:e,providerKey:n,displayName:r,logoUrl:o}):null]}),(0,$.jsx)(`div`,{className:`flex justify-end border-t border-[var(--border-base)] px-5 py-3 dark:border-[var(--border-base)]`,children:(0,$.jsx)(a,{variant:`outlined`,size:`compact`,onClick:c,children:`Confirm`})})]}),(0,$.jsx)(Y,{open:_!==null,title:`Disconnect ${r}?`,message:_?`Disconnect ${_.account_label??`${r} Account`}? You can reconnect later.`:``,confirmLabel:`Disconnect`,destructive:!0,onConfirm:A,onCancel:()=>v(null)})]})}function st({active:e,onClick:t,children:n}){return(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e,onClick:t,className:`flex-1 cursor-pointer rounded-[5px] px-3 py-1.5 text-body-medium-default transition-colors ${e?`bg-white text-[var(--content-default)] shadow-sm dark:bg-[var(--surface-lift)] dark:text-[var(--content-default)]`:`text-[var(--content-secondary)] hover:text-[var(--content-default)] dark:text-[var(--content-disabled)] dark:hover:text-[var(--content-default)]`}`,children:n})}function ct({platformAssistantId:e,providerKey:t,displayName:n,description:r,logoUrl:i,connection:o,platformGate:s,onConfigure:c}){let l=p(),u=!!o?.connected,[d,f]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(!1),g=ke(),_=Ne({path:{assistant_id:e}}),v={path:{assistant_id:e}},y=Ae({onSuccess(e,t){J.success(`${n} account disconnected.`);let r=t.path.connection_id;Me(l,v,e=>e?.filter(e=>e.id!==r)),l.invalidateQueries({queryKey:_})},onError(e){let t=le(e,void 0,`Failed to disconnect ${n} account.`);J.error(t)}}),b=()=>{o?.id&&h(!0)};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T.Root,{children:(0,$.jsxs)(T.Body,{padding:`sm`,className:`flex items-center gap-4 px-4`,children:[(0,$.jsx)(H,{providerKey:t,displayName:n,logoUrl:i,size:32}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`truncate text-title-small text-[var(--content-default)]`,children:n}),r&&(0,$.jsx)(`p`,{className:`truncate text-body-medium-lighter text-[var(--content-tertiary)]`,children:r})]}),u&&s===`full`?(0,$.jsx)(`div`,{className:`shrink-0`,children:(0,$.jsx)(lt,{displayName:n,open:d,onOpenChange:f,onEditConnections:()=>{f(!1),c()},onDisable:()=>{f(!1),b()},disablePending:y.isPending,isMobile:g})}):(0,$.jsx)(a,{variant:`primary`,onClick:c,className:`shrink-0`,children:`Enable`})]})}),(0,$.jsx)(Y,{open:m,title:`Disconnect ${n}?`,message:`Disconnect your ${n} account? You can reconnect it later.`,confirmLabel:`Disconnect`,destructive:!0,onConfirm:()=>{h(!1),o?.id&&y.mutate({path:{assistant_id:e,connection_id:o.id}})},onCancel:()=>h(!1)})]})}function lt({displayName:e,open:t,onOpenChange:n,onEditConnections:r,onDisable:i,disablePending:o,isMobile:s}){return s?(0,$.jsxs)(q.Root,{open:t,onOpenChange:n,children:[(0,$.jsx)(q.Trigger,{asChild:!0,children:(0,$.jsx)(a,{variant:`outlined`,rightIcon:(0,$.jsx)(O,{}),"aria-haspopup":`menu`,"aria-expanded":t,children:`Configure`})}),(0,$.jsxs)(q.Content,{children:[(0,$.jsx)(q.Header,{children:(0,$.jsx)(q.Title,{children:e})}),(0,$.jsxs)(q.Body,{children:[(0,$.jsx)(ce,{icon:B,label:`Edit connections`,onSelect:r}),(0,$.jsx)(ce,{icon:o?R:M,label:`Disable`,onSelect:()=>{o||i()}})]})]})]}):(0,$.jsxs)(W.Root,{open:t,onOpenChange:n,children:[(0,$.jsx)(W.Trigger,{asChild:!0,children:(0,$.jsx)(a,{variant:`outlined`,rightIcon:(0,$.jsx)(O,{}),"aria-haspopup":`menu`,"aria-expanded":t,children:`Configure`})}),(0,$.jsxs)(W.Content,{align:`end`,sideOffset:4,role:`menu`,className:`w-56 overflow-hidden p-0`,children:[(0,$.jsx)(a,{type:`button`,role:`menuitem`,variant:`ghost`,onClick:r,className:`w-full justify-start rounded-none`,leftIcon:(0,$.jsx)(B,{"aria-hidden":!0}),children:`Edit connections`}),(0,$.jsx)(a,{type:`button`,role:`menuitem`,variant:`dangerGhost`,onClick:i,disabled:o,className:`w-full justify-start rounded-none`,leftIcon:o?(0,$.jsx)(R,{className:`animate-spin`,"aria-hidden":!0}):(0,$.jsx)(M,{"aria-hidden":!0}),children:`Disable`})]})]})}var ut=[{value:`none`,label:`None`},{value:`oauth`,label:`OAuth`},{value:`bearer`,label:`Bearer Token`},{value:`api-key`,label:`API Key`}],dt=[{value:`sse`,label:`SSE`},{value:`streamable-http`,label:`Streamable HTTP`},{value:`stdio`,label:`Stdio (command)`}];function ft({open:e,onClose:t,onAdd:n,isPending:r}){let[i,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(`sse`),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(`none`),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(`X-API-Key`),[x,S]=(0,Q.useState)(``),C=(0,Q.useCallback)(()=>{o(``),c(`sse`),u(``),f(``),m(``),g(`none`),v(``),b(`X-API-Key`),S(``)},[]),w=(0,Q.useCallback)(()=>{r||(C(),t())},[r,C,t]),T=(0,Q.useCallback)(()=>{let e=i.trim();if(!e)return;let t={name:e,transportType:s};if(s===`stdio`){let e=d.trim();if(!e)return;t.command=e;let n=p.trim();n&&(t.args=n.split(/\s+/))}else{let e=l.trim();if(!e)return;t.url=e,h===`bearer`&&_.trim()?t.headers={Authorization:`Bearer ${_.trim()}`}:h===`api-key`&&y.trim()&&x.trim()?t.headers={[y.trim()]:x.trim()}:h===`oauth`&&(t.autoAuth=!0)}n(t)},[i,s,l,d,p,h,_,y,x,n]),E=s===`stdio`,D=i.trim()&&(E?d.trim():l.trim());return(0,$.jsx)(K.Root,{open:e,onOpenChange:e=>{e||w()},children:(0,$.jsxs)(K.Content,{size:`md`,children:[(0,$.jsxs)(K.Header,{children:[(0,$.jsx)(K.Title,{icon:Ze,children:`Add MCP Server`}),(0,$.jsx)(K.Description,{children:`Connect to a Model Context Protocol server to extend available tools.`})]}),(0,$.jsx)(K.Body,{children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-name`,children:`Server name`}),(0,$.jsx)(G,{id:`mcp-name`,type:`text`,value:i,onChange:e=>o(e.target.value),placeholder:`my-server`,fullWidth:!0,autoFocus:!0})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-transport`,children:`Transport`}),(0,$.jsx)(`select`,{id:`mcp-transport`,value:s,onChange:e=>c(e.target.value),className:`w-full rounded-md border border-[var(--border-element)] bg-[var(--surface-lift)] px-3 py-1.5 text-body-medium-default text-[var(--content-default)] outline-none focus:ring-2 focus:ring-[var(--ring)]`,children:dt.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),E?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-command`,children:`Command`}),(0,$.jsx)(G,{id:`mcp-command`,type:`text`,value:d,onChange:e=>f(e.target.value),placeholder:`npx -y @modelcontextprotocol/server-example`,fullWidth:!0})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-args`,children:`Arguments (space-separated)`}),(0,$.jsx)(G,{id:`mcp-args`,type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:`--port 3000`,fullWidth:!0})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-url`,children:`Server URL`}),(0,$.jsx)(G,{id:`mcp-url`,type:`url`,value:l,onChange:e=>u(e.target.value),placeholder:`https://example.com/mcp`,fullWidth:!0})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-auth`,children:`Authentication`}),(0,$.jsx)(`select`,{id:`mcp-auth`,value:h,onChange:e=>g(e.target.value),className:`w-full rounded-md border border-[var(--border-element)] bg-[var(--surface-lift)] px-3 py-1.5 text-body-medium-default text-[var(--content-default)] outline-none focus:ring-2 focus:ring-[var(--ring)]`,children:ut.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),h===`oauth`?(0,$.jsx)(`p`,{className:`rounded-md border border-[var(--border-element)] bg-[var(--surface-base)] px-3 py-2 text-body-small-default text-[var(--content-tertiary)]`,children:`OAuth credentials will be configured through a browser-based authorization flow after the server is added.`}):null,h===`bearer`?(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-bearer`,children:`Bearer token`}),(0,$.jsx)(G,{id:`mcp-bearer`,type:`password`,value:_,onChange:e=>v(e.target.value),placeholder:`tok_...`,fullWidth:!0})]}):null,h===`api-key`?(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-apikey-header`,children:`Header name`}),(0,$.jsx)(G,{id:`mcp-apikey-header`,type:`text`,value:y,onChange:e=>b(e.target.value),placeholder:`X-API-Key`,fullWidth:!0})]}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-apikey-value`,children:`API key`}),(0,$.jsx)(G,{id:`mcp-apikey-value`,type:`password`,value:x,onChange:e=>S(e.target.value),placeholder:`sk_...`,fullWidth:!0})]})]}):null]})]})}),(0,$.jsxs)(K.Footer,{children:[(0,$.jsx)(a,{variant:`ghost`,onClick:w,disabled:r,children:`Cancel`}),(0,$.jsx)(a,{variant:`primary`,onClick:T,disabled:!D||r,children:r?`Adding...`:`Add Server`})]})]})})}async function pt(e){let{data:t,response:n}=await X.get({url:`/v1/assistants/{assistant_id}/internal/mcp/list`,path:{assistant_id:e}});if(!n?.ok)throw Error(`Failed to fetch MCP servers: ${n?.status}`);return t}async function mt(e){let{data:t,response:n}=await X.get({url:`/v1/assistants/{assistant_id}/internal/mcp/tools-summary`,path:{assistant_id:e}});if(!n?.ok)throw Error(`Failed to fetch MCP tools summary: ${n?.status}`);return t}async function ht(e,t){let{response:n}=await X.post({url:`/v1/assistants/{assistant_id}/internal/mcp/update`,path:{assistant_id:e},body:t});if(!n?.ok)throw Error(`Failed to update MCP server: ${n?.status}`)}async function gt(e,t){let{response:n}=await X.post({url:`/v1/assistants/{assistant_id}/internal/mcp/add`,path:{assistant_id:e},body:t});if(!n?.ok)throw Error(`Failed to add MCP server: ${n?.status}`)}async function _t(e,t){let{response:n}=await X.post({url:`/v1/assistants/{assistant_id}/internal/mcp/remove`,path:{assistant_id:e},body:{name:t}});if(!n?.ok)throw Error(`Failed to remove MCP server: ${n?.status}`)}async function vt(e,t){let{data:n,response:r}=await X.post({url:`/v1/assistants/{assistant_id}/internal/mcp/auth/start`,path:{assistant_id:e},body:{serverId:t}});if(!r?.ok)throw Error(`Failed to start MCP auth: ${r?.status}`);return n}async function yt(e,t){let{data:n,response:r}=await X.get({url:`/v1/assistants/{assistant_id}/internal/mcp/auth/status/${encodeURIComponent(t)}`,path:{assistant_id:e}});if(!r?.ok)throw Error(`Failed to poll MCP auth status: ${r?.status}`);return n}async function bt(e,t){let{response:n}=await X.post({url:`/v1/assistants/{assistant_id}/internal/mcp/auth/revoke`,path:{assistant_id:e},body:{serverId:t}});if(!n?.ok)throw Error(`Failed to revoke OAuth for ${t}: ${n?.status}`)}async function xt(e){let{response:t}=await X.post({url:`/v1/assistants/{assistant_id}/internal/mcp/reload`,path:{assistant_id:e},body:{}});if(!t?.ok)throw Error(`Failed to reload MCP servers: ${t?.status}`)}var St={connected:{icon:j,label:`Connected`,className:`text-[var(--system-positive-strong)]`},"needs-auth":{icon:L,label:`Needs Auth`,className:`text-[var(--system-warning-strong)]`},disabled:{icon:te,label:`Disabled`,className:`text-[var(--content-tertiary)]`}},Ct={icon:A,label:`Error`,className:`text-[var(--system-negative-strong)]`};function wt({server:e,toolsSummary:t,onToggleEnabled:n,onRemove:r,onConfigure:i,onAuthenticate:o,onRevokeOAuth:s,isUpdating:c,isAuthenticating:l,isRevoking:u}){let[d,f]=(0,Q.useState)(!1),p=St[e.status]??Ct,m=p.icon,h=(0,Q.useCallback)(t=>n(e.id,t),[n,e.id]),g=(0,Q.useCallback)(()=>r(e.id),[r,e.id]),_=(0,Q.useCallback)(()=>i(e.id),[i,e.id]),v=(0,Q.useCallback)(()=>o(e.id),[o,e.id]),y=(0,Q.useCallback)(()=>s(e.id),[s,e.id]),b=(0,Q.useCallback)(()=>f(e=>!e),[]);return(0,$.jsx)(T.Root,{children:(0,$.jsxs)(T.Body,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:e.id}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-label-medium-default ${p.className}`,children:[(0,$.jsx)(m,{className:`h-3.5 w-3.5`}),p.label]}),e.hasOAuth?(0,$.jsx)(`span`,{className:`rounded-full bg-[var(--surface-lift)] px-2 py-0.5 text-label-small-default text-[var(--content-secondary)]`,children:`OAuth`}):null]}),(0,$.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)(`span`,{children:e.transport.type}),t?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,$.jsxs)(`span`,{children:[t.toolCount,` `,t.toolCount===1?`tool`:`tools`]}),(0,$.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,$.jsxs)(`span`,{children:[`~`,t.estimatedTokens.toLocaleString(),` tokens`]})]}):null]})]})}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[c||l?(0,$.jsx)(R,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}):null,e.status===`needs-auth`&&e.transport.type!==`stdio`&&!e.hasOAuth?(0,$.jsx)(a,{variant:`ghost`,size:`compact`,leftIcon:(0,$.jsx)(z,{}),onClick:v,disabled:l,children:l?`Authenticating...`:`Authenticate`}):null,e.hasOAuth?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(a,{variant:`ghost`,size:`compact`,leftIcon:(0,$.jsx)(ne,{}),onClick:v,disabled:l,tooltip:`Re-authenticate OAuth`,children:`Re-auth`}),(0,$.jsx)(a,{variant:`dangerGhost`,size:`compact`,leftIcon:(0,$.jsx)(ee,{}),onClick:y,disabled:u,tooltip:`Revoke OAuth credentials`,children:u?`Revoking...`:`Revoke`})]}):null,(0,$.jsx)(se,{checked:e.enabled,onChange:h,disabled:c,"aria-label":`${e.enabled?`Disable`:`Enable`} ${e.id}`}),(0,$.jsx)(a,{variant:`ghost`,size:`compact`,onClick:_,tooltip:`Configure`,children:`Configure`}),(0,$.jsx)(a,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,$.jsx)(U,{}),onClick:g,tooltip:`Remove server`,"aria-label":`Remove ${e.id}`})]})]}),t&&t.tools.length>0?(0,$.jsxs)(`div`,{className:`mt-3 border-t border-[var(--border-base)] pt-2`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:b,className:`flex w-full cursor-pointer items-center gap-1 text-body-small-default text-[var(--content-secondary)] hover:text-[var(--content-default)]`,children:[d?(0,$.jsx)(O,{className:`h-3.5 w-3.5`}):(0,$.jsx)(k,{className:`h-3.5 w-3.5`}),t.toolCount,` registered`,` `,t.toolCount===1?`tool`:`tools`]}),d?(0,$.jsx)(`div`,{className:`mt-2 max-h-60 overflow-y-auto`,children:t.tools.map(e=>(0,$.jsx)(F,{title:e.name,subtitle:e.description||void 0,trailing:(0,$.jsxs)(`span`,{className:`whitespace-nowrap text-body-small-default text-[var(--content-secondary)]`,children:[`~`,e.estimatedTokens.toLocaleString(),` tok`]})},e.name))}):null]}):null]})})}var Tt=[{value:`none`,label:`None`},{value:`bearer`,label:`Bearer Token`},{value:`api-key`,label:`API Key`}],Et=[`low`,`medium`,`high`];function Dt({server:e,toolsSummary:t,onClose:n,onSave:r,isPending:i}){let[o,s]=(0,Q.useState)(`medium`),[c,l]=(0,Q.useState)(`none`),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(`X-API-Key`),[m,h]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{e&&(s(e.defaultRiskLevel),l(e.authType),d(``),p(e.authHeaderName??`X-API-Key`),h(``))},[e]);let g=(0,Q.useCallback)(()=>{if(!e)return;let t=c!==e.authType,n=c===`bearer`&&u.trim()!==``,i=c===`api-key`&&f.trim()!==``&&m.trim()!==``,a=t||n||i,s;s=a?c===`none`?null:c===`bearer`&&u.trim()?{Authorization:`Bearer ${u.trim()}`}:c===`api-key`&&f.trim()&&m.trim()?{[f.trim()]:m.trim()}:void 0:void 0,r(e.id,{name:e.id,defaultRiskLevel:o,...s===void 0?{}:{headers:s}})},[e,o,c,u,f,m,r]),_=(0,Q.useCallback)(()=>{i||n()},[i,n]);return e?(0,$.jsx)(K.Root,{open:!!e,onOpenChange:e=>{e||_()},children:(0,$.jsxs)(K.Content,{size:`lg`,children:[(0,$.jsxs)(K.Header,{children:[(0,$.jsx)(K.Title,{icon:Ze,children:e.id}),(0,$.jsxs)(K.Description,{children:[e.transport.type,` transport · `,e.status]})]}),(0,$.jsx)(K.Body,{children:(0,$.jsxs)(`div`,{className:`space-y-5`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-risk`,children:`Default risk level`}),(0,$.jsx)(`select`,{id:`mcp-risk`,value:o,onChange:e=>s(e.target.value),className:`w-full rounded-md border border-[var(--border-element)] bg-[var(--surface-lift)] px-3 py-1.5 text-body-medium-default text-[var(--content-default)] outline-none focus:ring-2 focus:ring-[var(--ring)]`,children:Et.map(e=>(0,$.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),e.transport.type===`stdio`?null:(0,$.jsxs)($.Fragment,{children:[e.hasOAuth?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-[var(--border-element)] bg-[var(--surface-base)] px-3 py-2`,children:[(0,$.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Authentication`}),(0,$.jsx)(`span`,{className:`rounded-full bg-[var(--surface-lift)] px-2 py-0.5 text-label-small-default text-[var(--content-default)]`,children:`OAuth`}),(0,$.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`— managed via OAuth flow`})]}):null,e.hasOAuth?null:(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-detail-auth`,children:`Authentication`}),(0,$.jsx)(`select`,{id:`mcp-detail-auth`,value:c,onChange:e=>l(e.target.value),className:`w-full rounded-md border border-[var(--border-element)] bg-[var(--surface-lift)] px-3 py-1.5 text-body-medium-default text-[var(--content-default)] outline-none focus:ring-2 focus:ring-[var(--ring)]`,children:Tt.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),c===`bearer`&&!e.hasOAuth?(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-detail-bearer`,children:`Bearer token`}),(0,$.jsx)(G,{id:`mcp-detail-bearer`,type:`password`,value:u,onChange:e=>d(e.target.value),placeholder:e.hasStaticAuth&&e.authType===`bearer`?`•••••••• (leave blank to keep current)`:`tok_...`,fullWidth:!0})]}):null,c===`api-key`&&!e.hasOAuth?(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-detail-apikey-header`,children:`Header name`}),(0,$.jsx)(G,{id:`mcp-detail-apikey-header`,type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:`X-API-Key`,fullWidth:!0})]}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-detail-apikey-value`,children:`API key`}),(0,$.jsx)(G,{id:`mcp-detail-apikey-value`,type:`password`,value:m,onChange:e=>h(e.target.value),placeholder:e.hasStaticAuth&&e.authType===`api-key`?`•••••••• (leave blank to keep current)`:`sk_...`,fullWidth:!0})]})]}):null]}),t&&t.tools.length>0?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`h3`,{className:`text-body-medium-default text-[var(--content-default)]`,children:[`Registered tools (`,t.toolCount,`)`]}),(0,$.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[`Total estimated token overhead: ~`,t.estimatedTokens.toLocaleString(),` tokens`]}),(0,$.jsx)(`div`,{className:`max-h-64 overflow-y-auto rounded-lg border border-[var(--border-base)]`,children:(0,$.jsxs)(`table`,{className:`w-full text-body-small-default`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{className:`border-b border-[var(--border-base)] bg-[var(--surface-base)]`,children:[(0,$.jsx)(`th`,{className:`px-3 py-2 text-left font-medium text-[var(--content-secondary)]`,children:`Tool`}),(0,$.jsx)(`th`,{className:`px-3 py-2 text-left font-medium text-[var(--content-secondary)]`,children:`Description`}),(0,$.jsx)(`th`,{className:`px-3 py-2 text-right font-medium text-[var(--content-secondary)]`,children:`Tokens`})]})}),(0,$.jsx)(`tbody`,{children:t.tools.map(e=>(0,$.jsxs)(`tr`,{className:`border-b border-[var(--border-base)] last:border-b-0`,children:[(0,$.jsx)(`td`,{className:`px-3 py-2 font-medium text-[var(--content-default)]`,children:e.name}),(0,$.jsx)(`td`,{className:`max-w-xs truncate px-3 py-2 text-[var(--content-tertiary)]`,children:e.description||`—`}),(0,$.jsxs)(`td`,{className:`px-3 py-2 text-right text-[var(--content-tertiary)]`,children:[`~`,e.estimatedTokens.toLocaleString()]})]},e.name))})]})})]}):null]})}),(0,$.jsxs)(K.Footer,{children:[(0,$.jsx)(a,{variant:`ghost`,onClick:_,disabled:i,children:`Cancel`}),(0,$.jsx)(a,{variant:`primary`,onClick:g,disabled:i,children:i?`Saving...`:`Save`})]})]})}):null}var Ot=`mcp-servers`,kt=`mcp-tools-summary`,At=`Help me set up an MCP server to extend you with external tools.`;function jt(){let e=Ge(),t=p(),n=s(),r=Pe.use.mcpAddServer(),i=Pe.use.hasHydrated(),[o,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(new Set),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(null),{data:k,isLoading:A,isError:j}=S({queryKey:[Ot,e],queryFn:()=>pt(e)}),{data:M}=S({queryKey:[kt,e],queryFn:()=>mt(e)}),N=(0,Q.useCallback)(()=>{t.invalidateQueries({queryKey:[Ot,e]}),t.invalidateQueries({queryKey:[kt,e]})},[t,e]),P=(0,Q.useMemo)(()=>{let e=new Map;if(M)for(let t of M.servers)e.set(t.serverId,t);return e},[M]),F=(0,Q.useMemo)(()=>!l||!k?null:k.servers.find(e=>e.id===l)??null,[l,k]),I=(0,Q.useCallback)(async(t,n)=>{h(e=>new Set(e).add(t));try{await ht(e,{name:t,enabled:n}),N()}catch{J.error(`Failed to ${n?`enable`:`disable`} ${t}`)}finally{h(e=>{let n=new Set(e);return n.delete(t),n})}},[e,N]),L=(0,Q.useCallback)(async()=>{if(d){y(!0);try{await _t(e,d),N(),J.success(`Removed ${d}`),f(null)}catch{J.error(`Failed to remove ${d}`)}finally{y(!1)}}},[d,e,N]),z=(0,Q.useCallback)(async t=>{E(t);let n;try{n=await vt(e,t)}catch{J.error(`Failed to start authentication for ${t}`),E(null);return}try{if(n.already_authenticated){J.success(`${t} is already authenticated`),N();return}window.open(n.auth_url,`_blank`,`noopener,noreferrer`);for(let n=0;n<60;n++){await new Promise(e=>setTimeout(e,3e3));let n=await yt(e,t);if(n.status===`complete`){J.success(`${t} authenticated successfully`),N();return}if(n.status===`error`){J.error(n.error??`Authentication failed for ${t}`);return}}J.error(`Authentication timed out for ${t}`)}catch{J.error(`Authentication polling failed for ${t}`)}finally{E(null),N()}},[e,N]),ee=(0,Q.useCallback)(async t=>{O(t);try{await bt(e,t),N(),J.success(`OAuth credentials revoked for ${t}`)}catch{J.error(`Failed to revoke OAuth for ${t}`)}finally{O(null)}},[e,N]),B=(0,Q.useCallback)(async t=>{let n=t.autoAuth?window.open(`about:blank`,`_blank`,`noopener`):null;_(!0);try{await gt(e,t),N(),J.success(`Added ${t.name}`),c(!1)}catch{J.error(`Failed to add ${t.name}`),n?.close(),_(!1);return}if(_(!1),t.autoAuth){E(t.name);try{let r=await vt(e,t.name);if(r.already_authenticated){n?.close(),J.success(`${t.name} is already authenticated`),N();return}n?n.location.href=r.auth_url:window.open(r.auth_url,`_blank`,`noopener,noreferrer`);for(let n=0;n<60;n++){await new Promise(e=>setTimeout(e,3e3));let n=await yt(e,t.name);if(n.status===`complete`){J.success(`${t.name} authenticated successfully`),N();return}if(n.status===`error`){J.error(n.error??`Authentication failed for ${t.name}`);return}}J.error(`Authentication timed out for ${t.name}`)}catch{n?.close(),J.error(`Failed to start authentication for ${t.name}`)}finally{E(null),N()}}},[e,N]),te=(0,Q.useCallback)(async(t,n)=>{x(!0);try{await ht(e,n),N(),J.success(`Updated ${t}`),u(null)}catch{J.error(`Failed to update ${t}`)}finally{x(!1)}},[e,N]),H=(0,Q.useCallback)(async()=>{w(!0);try{await xt(e),N(),J.success(`MCP servers reloaded`)}catch{J.error(`Failed to reload MCP servers`)}finally{w(!1)}},[e,N]),re=(0,Q.useCallback)(()=>{r?c(!0):Oe(n,{prompt:At})},[r,n]),ie=k?.servers??[];return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-title-small text-[var(--content-default)]`,children:`MCP Servers`}),(0,$.jsx)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:`Manage Model Context Protocol server connections and their registered tools.`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(a,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(ne,{className:C?`animate-spin`:``}),onClick:H,disabled:C,tooltip:`Reload all servers`,"aria-label":`Reload MCP servers`}),r?(0,$.jsx)(a,{variant:`primary`,size:`compact`,leftIcon:(0,$.jsx)(V,{}),onClick:()=>c(!0),children:`Add Server`}):null]})]}),M?(0,$.jsxs)(`div`,{className:`flex gap-4 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsxs)(`span`,{children:[M.totalToolCount,` total`,` `,M.totalToolCount===1?`tool`:`tools`]}),(0,$.jsxs)(`span`,{children:[`~`,M.totalEstimatedTokens.toLocaleString(),` total tokens`]})]}):null,A?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,$.jsx)(R,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{children:`Loading MCP servers...`})]}):j?(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Failed to load MCP servers. Check that an assistant is running.`}):ie.length===0?(0,$.jsxs)(`button`,{type:`button`,onClick:re,disabled:!i,className:`flex w-full flex-col items-center gap-2 rounded-lg border border-dashed border-[var(--border-element)] px-4 py-12 text-center transition-colors hover:border-[var(--border-active)] hover:bg-[var(--surface-hover)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)] disabled:pointer-events-none`,children:[(0,$.jsx)(Ze,{className:`h-6 w-6 text-[var(--content-disabled)]`}),(0,$.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`No MCP Servers`}),(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:r?`Add an MCP server to extend your assistant with external tools.`:`Chat with your assistant to set up an MCP server.`})]}):(0,$.jsx)(`div`,{className:`space-y-2`,children:ie.map(e=>(0,$.jsx)(wt,{server:e,toolsSummary:P.get(e.id),onToggleEnabled:I,onRemove:f,onConfigure:u,onAuthenticate:z,onRevokeOAuth:ee,isUpdating:m.has(e.id),isAuthenticating:T===e.id,isRevoking:D===e.id},e.id))}),r?(0,$.jsx)(ft,{open:o,onClose:()=>c(!1),onAdd:B,isPending:g}):null,(0,$.jsx)(Dt,{server:F,toolsSummary:l?P.get(l):void 0,onClose:()=>u(null),onSave:te,isPending:b}),(0,$.jsx)(Y,{open:!!d,title:`Remove MCP Server`,message:`Are you sure you want to remove "${d}"? This will disconnect all tools provided by this server.`,confirmLabel:`Remove`,destructive:!0,isPending:v,onConfirm:L,onCancel:()=>f(null)})]})}function Mt(){return(0,$.jsx)(jt,{})}var Nt=`vellum:integrations:bannerDismissed`,Pt=[{value:`all`,label:`All`},{value:`enabled`,label:`Enabled`},{value:`not-enabled`,label:`Not Enabled`}];function Ft(e,t){return e?.find(e=>e.provider===t)??null}function It(e){return e===`mcp`?`mcp`:`oauth`}function Lt(){let[e]=o(),i=s(),a=me(),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(!0),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(`all`),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!0),[b,x]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{y(t(Nt,`false`)===`true`)},[]);let C=()=>{y(!0),n(Nt,`true`)};(0,Q.useEffect)(()=>{let e=!0;return(async()=>{try{let t=await de();e&&t.ok&&l(t.data)}catch(e){r(e,{context:`integrations.getAssistant`})}finally{e&&d(!1)}})(),()=>{e=!1}},[]);let{platformAssistantId:w,isLoading:T}=Ke(c?.id,a===`full`),{data:E,isLoading:D,isError:k}=S({...be({path:{assistant_id:c?.id??``}}),select:e=>e.providers,enabled:!!c}),{data:A,isLoading:j}=S({...Z({path:{assistant_id:w??``}}),enabled:!!w&&a===`full`});(0,Q.useEffect)(()=>{let t=e.get(`oauth_status`);if(!t)return;let n=e.get(`oauth_provider`),r=n?n.charAt(0).toUpperCase()+n.slice(1):null;if(t===`connected`)J.success(r?`${r} account connected successfully.`:`Account connected successfully.`);else if(t===`error`){let t=e.get(`oauth_code`)??`unknown`;J.error({denied:`Authorization was denied. Please try again.`,state_invalid:`Authorization state was invalid. Please try again.`,state_expired:`Authorization expired. Please try again.`,exchange_failed:`Failed to complete authorization. Please try again.`,identity_failed:`Failed to verify account identity. Please try again.`}[t]??(r?`Failed to connect ${r}.`:`Failed to connect. Please try again.`))}i(pe.settings.integrations,{replace:!0})},[e,i]);let M=(0,Q.useMemo)(()=>E?.filter(e=>e.supports_managed_mode)??[],[E]),N=(0,Q.useMemo)(()=>{let e=f.trim().toLowerCase(),t=M.filter(t=>{if(t.provider_key===`slack`)return!1;if(!e)return!0;let n=(t.display_name??t.provider_key).toLowerCase(),r=(t.description??``).toLowerCase();return n.includes(e)||r.includes(e)});return m!==`all`&&(t=t.filter(e=>{let t=!!Ft(A,e.provider_key)?.connected;return m===`enabled`?t:!t})),[...t].sort((e,t)=>{let n=!!Ft(A,e.provider_key)?.connected;if(n!==!!Ft(A,t.provider_key)?.connected)return n?-1:1;let r=(e.display_name??e.provider_key).toLowerCase(),i=(t.display_name??t.provider_key).toLowerCase();return r.localeCompare(i)})},[M,A,f,m]),P=u||D||j||T,F=Pt.find(e=>e.value===m)?.label??`All`,I=(()=>{if(f.trim())return`No integrations matched`;switch(m){case`enabled`:return`No Enabled Integrations`;case`not-enabled`:return`All Integrations Are Enabled`;default:return`No Integrations Available`}})(),L=(()=>{if(f.trim())return`No integrations matched "${f.trim()}"`;switch(m){case`enabled`:return`Connect an integration to get started.`;case`not-enabled`:return`All available integrations have been connected.`;default:return`Check your connection and try again.`}})(),z=(0,Q.useMemo)(()=>b?M.find(e=>e.provider_key===b)??null:null,[M,b]);return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[!v&&(0,$.jsxs)(oe,{tone:`info`,icon:(0,$.jsx)(ie,{className:`h-3.5 w-3.5`}),onDismiss:C,children:[(0,$.jsx)(`span`,{className:`text-body-medium-default`,children:`Tip:`}),` You can enable integrations by mentioning them in chat.`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(G,{type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:`Search Integrations`,"aria-label":`Search integrations`,leftIcon:(0,$.jsx)(re,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),fullWidth:!0,wrapperClassName:`flex-1`}),(0,$.jsxs)(W.Root,{open:g,onOpenChange:_,children:[(0,$.jsx)(W.Trigger,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"aria-haspopup":`listbox`,"aria-expanded":g,className:`flex w-36 cursor-pointer items-center justify-between gap-2 rounded-md border border-[var(--border-element)] bg-[var(--surface-lift)] px-3 py-1.5 text-body-medium-lighter text-[var(--content-default)] transition-colors hover:bg-[var(--ghost-hover)]`,children:[(0,$.jsx)(`span`,{children:F}),(0,$.jsx)(O,{className:`h-3.5 w-3.5`})]})}),(0,$.jsx)(W.Content,{align:`end`,sideOffset:4,className:`w-36 overflow-hidden p-0`,children:(0,$.jsx)(`div`,{role:`listbox`,children:Pt.map(e=>{let t=e.value===m;return(0,$.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>{h(e.value),_(!1)},className:`flex w-full cursor-pointer items-center px-3 py-1.5 text-left hover:bg-[var(--ghost-hover)] ${t?`text-body-medium-default text-[var(--content-default)]`:`text-body-medium-lighter text-[var(--content-default)]`}`,children:e.label},e.value)})})})]})]}),(0,$.jsx)(`div`,{children:P?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,$.jsx)(R,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{children:`Loading...`})]}):k?(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Failed to load integrations. Please try again.`}):c?N.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2 rounded-lg border border-dashed border-[var(--border-element)] px-4 py-12 text-center`,children:[(0,$.jsx)(re,{className:`h-6 w-6 text-[var(--content-disabled)]`}),(0,$.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:I}),(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:L})]}):(0,$.jsx)(`div`,{className:`space-y-2`,children:N.map(e=>(0,$.jsx)(ct,{platformAssistantId:w??c.id,providerKey:e.provider_key,displayName:e.display_name??e.provider_key,description:e.description,logoUrl:e.logo_url,connection:Ft(A,e.provider_key),platformGate:a,onConfigure:()=>x(e.provider_key)},e.provider_key))}):(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No assistant found. Hatch an assistant to connect integrations.`})}),z&&c&&(0,$.jsx)(ot,{assistantId:c.id,platformAssistantId:w??c.id,providerKey:z.provider_key,displayName:z.display_name??z.provider_key,description:z.description,logoUrl:z.logo_url,platformGate:a,onClose:()=>x(null)})]})}function Rt(){let[e,t]=o(),n=It(e.get(`tab`));return(0,$.jsx)(`div`,{className:`space-y-6`,children:(0,$.jsxs)(N.Root,{value:n,onValueChange:n=>{let r=It(n),i=new URLSearchParams(e);r===`mcp`?i.set(`tab`,`mcp`):i.delete(`tab`),t(i,{replace:!0})},children:[(0,$.jsxs)(N.List,{children:[(0,$.jsx)(N.Trigger,{value:`oauth`,children:`OAuth`}),(0,$.jsx)(N.Trigger,{value:`mcp`,children:`MCP`})]}),(0,$.jsx)(N.Panel,{value:`oauth`,className:`pt-4`,children:(0,$.jsx)(Q.Suspense,{children:(0,$.jsx)(Lt,{})})}),(0,$.jsx)(N.Panel,{value:`mcp`,className:`pt-4`,children:(0,$.jsx)(Mt,{})})]})})}export{Rt as IntegrationsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,l as t}from"./local-settings-Bx7FsNo5.js";import{t as n}from"./useMutation-CXGTrp4W.js";import{I as r,g as i,ot as a}from"./local-mode-Bds87_d7.js";import{c as o,l as s}from"./utils-CLGxXkUG.js";import{n as c,rt as l}from"./auth-store-
|
|
1
|
+
import{i as e,l as t}from"./local-settings-Bx7FsNo5.js";import{t as n}from"./useMutation-CXGTrp4W.js";import{I as r,g as i,ot as a}from"./local-mode-Bds87_d7.js";import{c as o,l as s}from"./utils-CLGxXkUG.js";import{n as c,rt as l}from"./auth-store-D55YOXDj.js";function u({assistantId:e,targetVersion:t}){let o=n({mutationFn:async()=>{if(!e)throw Error(`No local assistant is active.`);l.setLocalAssistantUpgradeInProgress(e,!0);try{let n=await r(e,{...t?{version:t}:{latest:!0}});if(!n.ok)throw Error(n.error??`Failed to trigger update.`);return n}finally{l.setLocalAssistantUpgradeInProgress(e,!1)}}});return{...o,upgrade:async()=>{if(!e)throw Error(`No local assistant is active.`);let t=await o.mutateAsync();return await i(),a(),await c.getState().connectLocalAssistant(e),t}}}var d=1200*1e3,f=`vellum:runtimeUpgradeDismissed`,p=`vellum:localRuntimeUpgradeDismissed`;function m(e){return(e?s(e):null)?.pre?.split(`.`)[0]===`local`}function h(e){let t=e?.filter(e=>!m(e.version))??[];return t.find(e=>e.is_stable!==!1)??t[0]}function g(e,t){if(!e||!t)return!1;let n=s(t),r=s(e);return!n||!r?t!==e:o(n,r)>0}function _(e,t){return t&&e===`preview`?`preview`:`stable`}function v(e,t,n){return`${e}:${t}:${n}`}function y(t,n){return e(v(f,t,n),``)===`true`||e(v(p,t,n),``)===`true`}function b(e,n){t(v(f,e,n),`true`)}export{g as a,_ as i,b as n,y as o,h as r,u as s,d as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e}from"./routes-Dwx_Ibh9.js";import{a as t,n,r}from"./navigation-resolver-CBlxbQ74.js";import{t as i}from"./build-state-
|
|
1
|
+
import{d as e}from"./routes-Dwx_Ibh9.js";import{a as t,n,r}from"./navigation-resolver-CBlxbQ74.js";import{t as i}from"./build-state-qwijhEiY.js";var a=`workos`,o=e.account.providerCallback,s=`authIntent`;function c(e,t={}){let n=new URLSearchParams;e&&n.set(`returnTo`,e),t.authIntent&&n.set(s,t.authIntent);let r=n.toString();return r?`${o}?${r}`:o}function l(e){return e.get(s)===`signup`?`signup`:`login`}function u(e){return e.startsWith(`http`)||e.startsWith(`/accounts/`)||e.startsWith(`/v1/`)||e.startsWith(`/_allauth/`)||e.startsWith(`/import`)}var d=[e.checkout,e.plans,`${e.settings.root}/billing`,e.account.root];function f(e){if(u(e))return!0;let t=e.split(/[?#]/)[0]??e;return d.some(e=>t===e||t.startsWith(`${e}/`))||r(e)!==null?!0:n(e)}function p(e,t){return m({returnTo:e,fallback:t,authIntent:`login`})}function m({returnTo:e,fallback:n,authIntent:r}){let a=t(i(),{kind:`post-auth`,authIntent:r,returnTo:e,fallback:n}),o=a.action===`redirect`?a.to:n;return{destination:o,requiresFullPageNavigation:u(o)}}export{u as a,p as c,l as i,a as n,f as o,c as r,m as s,o as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-Dy5001j6.js";import{l as r,t as i}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as a}from"./jsx-runtime-D3ZM-ToX.js";import{t as o}from"./cn-CJf7MmLX.js";import"./src-BAS7a2RG.js";import{E as s,f as c,m as l,p as u}from"./native-biometric-K90ZnTI1.js";import{d}from"./routes-Dwx_Ibh9.js";import{n as f,r as p}from"./login-flow-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-Dy5001j6.js";import{l as r,t as i}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as a}from"./jsx-runtime-D3ZM-ToX.js";import{t as o}from"./cn-CJf7MmLX.js";import"./src-BAS7a2RG.js";import{E as s,f as c,m as l,p as u}from"./native-biometric-K90ZnTI1.js";import{d}from"./routes-Dwx_Ibh9.js";import{n as f,r as p}from"./login-flow-DnBrnY_F.js";import{t as m}from"./public-asset-CD3ouSWU.js";import{n as h,t as g}from"./use-return-to-short-circuit-2pD4HsK8.js";var _=e(t(),1),v=a();function y({children:e}){return(0,v.jsxs)(`div`,{className:`fixed inset-0 z-50 flex flex-col items-center justify-center bg-[var(--surface-base)] text-[var(--content-default)]`,children:[(0,v.jsx)(`img`,{src:m(`/vellum-logo.svg`),alt:`Vellum`,width:220,height:66,className:`block dark:hidden`}),(0,v.jsx)(`img`,{src:m(`/vellum-logo-white.svg`),alt:`Vellum`,width:220,height:66,className:`hidden dark:block`}),e,(0,v.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute left-1/2 w-full max-w-[900px] -translate-x-1/2`,style:{bottom:0},children:(0,v.jsx)(`img`,{src:m(`/login-background-characters.svg`),alt:``,width:880,height:182,className:`h-auto w-full`})})]})}function b(){return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`div`,{className:`pointer-events-none absolute top-[120px] left-1/2 z-0 -translate-x-1/2`,children:(0,v.jsx)(`img`,{src:m(`/vellum-logo-white.svg`),alt:`Vellum`,width:92,height:28})}),(0,v.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute right-0 bottom-0 left-1/2 z-0 w-full max-w-[1100px] -translate-x-1/2`,children:(0,v.jsx)(`img`,{src:m(`/login-background-characters.svg`),alt:``,width:880,height:182,className:`h-auto w-full`})})]})}var x=`flex w-full max-w-[448px] flex-col gap-6 rounded-lg border border-[var(--border-disabled)] bg-[var(--surface-lift)] p-6`;function S({children:e}){return(0,v.jsx)(`div`,{className:x,children:e})}function C({children:e}){return(0,v.jsx)(`h1`,{className:`text-title-large text-center text-[var(--content-emphasised)]`,children:e})}function w({children:e,className:t}){return(0,v.jsx)(`p`,{className:o(`text-body-small-default text-center text-[var(--system-negative-strong)]`,t),children:e})}function T({children:e}){return(0,v.jsx)(`div`,{className:`dark`,children:(0,v.jsxs)(`div`,{className:`relative min-h-screen overflow-x-hidden bg-[var(--surface-base)] text-[var(--content-default)]`,children:[(0,v.jsx)(b,{}),(0,v.jsx)(`div`,{className:`relative z-10 flex min-h-screen flex-col items-center justify-center px-4`,children:e})]})})}var E={signup_closed:`Sign-ups are currently closed. Visit vellum.ai/community to request access.`};function D({returnTo:e}){let[t,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(!1),o=async()=>{r(null),a(!0);try{await u({returnTo:e??null})}catch(e){let t=e&&typeof e==`object`&&`code`in e?e.code:void 0;if(t===`USER_CANCELLED`){a(!1);return}if(t===`AUTH_ERROR`){let t=e&&typeof e==`object`&&`data`in e&&e.data&&typeof e.data==`object`&&`authError`in e.data&&typeof e.data.authError==`string`?e.data.authError:void 0;r((t&&E[t])??`Something went wrong. Please try again.`)}else console.error(`[native-auth] auth flow failed:`,e),r(`Something went wrong. Please try again.`);a(!1)}};return(0,v.jsx)(y,{children:(0,v.jsxs)(`div`,{className:`z-10 mt-8 flex w-full max-w-[320px] flex-col items-center gap-3`,children:[t&&(0,v.jsx)(w,{className:`max-w-[280px]`,children:t}),(0,v.jsx)(n,{type:`button`,variant:`primary`,fullWidth:!0,onClick:()=>{o()},disabled:i,className:`max-w-[300px]`,children:`Sign in`})]})})}function O({returnTo:e}){let[t,a]=(0,_.useState)(null),[o,l]=(0,_.useState)(!1),u=p(e),{search:m}=r(),h=s(e?`${d.account.signup}?returnTo=${encodeURIComponent(e)}`:d.account.signup,m),g=async()=>{a(null),l(!0);try{await c(f,u,{returnTo:e})}catch(e){console.error(`[web-login] auth flow failed:`,e),a(`Something went wrong. Please try again.`),l(!1)}};return(0,v.jsx)(T,{children:(0,v.jsxs)(S,{children:[(0,v.jsx)(C,{children:`Sign in to Vellum`}),t&&(0,v.jsx)(w,{children:t}),(0,v.jsx)(`div`,{className:`flex flex-col items-center gap-3`,children:(0,v.jsx)(n,{type:`button`,variant:`primary`,fullWidth:!0,onClick:()=>void g(),disabled:o,className:`max-w-[300px]`,children:`Continue`})}),(0,v.jsxs)(`p`,{className:`text-body-small-default flex justify-center gap-1`,children:[(0,v.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Don't have an account?`}),(0,v.jsx)(i,{to:h,className:`font-medium text-[var(--content-emphasised)] hover:underline`,children:`Sign up`})]})]})})}function k(){let e=l(),t=g();return t.kind===`wait`?e?(0,v.jsx)(y,{}):(0,v.jsx)(T,{children:(0,v.jsx)(h,{})}):t.kind===`redirect`?t.node:e?(0,v.jsx)(D,{returnTo:t.returnTo}):(0,v.jsx)(O,{returnTo:t.returnTo})}export{k as LoginPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{m as n}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as r}from"./jsx-runtime-D3ZM-ToX.js";import{n as i}from"./auth-store-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{m as n}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as r}from"./jsx-runtime-D3ZM-ToX.js";import{n as i}from"./auth-store-D55YOXDj.js";import{w as a}from"./native-biometric-K90ZnTI1.js";import{d as o}from"./routes-Dwx_Ibh9.js";import{t as s}from"./hard-navigate-V2EFapkk.js";import{r as c,t as l}from"./account-shell-BxZ339N3.js";var u=e(t(),1),d=r();function f(){let[e]=n(),t=i.use.logout(),r=(0,u.useRef)(!1);return(0,u.useEffect)(()=>{if(r.current)return;r.current=!0;let n=a(e.get(`returnTo`),o.account.login),i=n.startsWith(`http`)||n===o.account.login?n:`${o.account.login}?returnTo=${encodeURIComponent(n)}`,c=!1;return t().then(()=>{c||s(i)},()=>{c||s(i)}),()=>{c=!0}},[t,e]),(0,d.jsx)(l,{children:(0,d.jsx)(c,{title:`Signing out...`})})}export{f as LogoutPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{l as n,r}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as i}from"./jsx-runtime-D3ZM-ToX.js";import{t as a}from"./createLucideIcon-CAM1RhH8.js";import{t as o}from"./mail-DABv3_Ue.js";import{d as s}from"./routes-Dwx_Ibh9.js";import{i as c}from"./use-platform-gate-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{l as n,r}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as i}from"./jsx-runtime-D3ZM-ToX.js";import{t as a}from"./createLucideIcon-CAM1RhH8.js";import{t as o}from"./mail-DABv3_Ue.js";import{d as s}from"./routes-Dwx_Ibh9.js";import{i as c}from"./use-platform-gate-Oc-w11de.js";import{n as l,t as u}from"./sidebar-tree-BvzA_BiU.js";var d=a(`monitor-cog`,[[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`m14.305 7.53.923-.382`,key:`1mlnsw`}],[`path`,{d:`m15.228 4.852-.923-.383`,key:`82mpwg`}],[`path`,{d:`m16.852 3.228-.383-.924`,key:`ln4sir`}],[`path`,{d:`m16.852 8.772-.383.923`,key:`1dejw0`}],[`path`,{d:`m19.148 3.228.383-.924`,key:`192kgf`}],[`path`,{d:`m19.53 9.696-.382-.924`,key:`fiavlr`}],[`path`,{d:`m20.772 4.852.924-.383`,key:`1j8mgp`}],[`path`,{d:`m20.772 7.148.924.383`,key:`zix9be`}],[`path`,{d:`M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7`,key:`1tnzv8`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}]]),f=e(t(),1),p=[{id:`emails`,label:`Emails`,href:s.logs.emails,icon:o},{id:`system-events`,label:`System Events`,href:s.logs.systemEvents,icon:d}],m=i();function h(){let e=c({platformHostedOnly:!0}),t=c(),{pathname:i}=n(),a=(0,f.useMemo)(()=>p.filter(n=>!(n.id===`system-events`&&e===`gated`||n.id===`emails`&&t===`gated`)),[e,t]),o=(0,f.useMemo)(()=>{let e=p.find(e=>i===e.href||i.startsWith(e.href+`/`));return e?e.label:i===s.logs.root?p[0]?.label??`Logs & Usage`:`Logs & Usage`},[i]);return(0,m.jsx)(l,{backHref:s.assistant,sidebar:(0,m.jsx)(u,{items:a,indexPath:s.logs.root}),title:o,menuRoute:s.logs.root,children:(0,m.jsx)(r,{})})}export{h as LogsLayout};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-Dy5001j6.js";import{u as r}from"./chunk-5KNZJZUH-Bsoom5--.js";import{n as i}from"./QueryClientProvider-CMu7CkQU.js";import{t as a}from"./useQuery-Bz-fbQ-m.js";import{t as o}from"./jsx-runtime-D3ZM-ToX.js";import{t as s}from"./queryOptions-CMSBCFOf.js";import{t as c}from"./typography-DEI9Ra9z.js";import{t as l}from"./chevron-down-B5A-0g8A.js";import{t as u}from"./chevron-left-CytMddTB.js";import{t as d}from"./chevron-up-2Qqarz0p.js";import{t as f}from"./loader-circle-BzJ2kz3F.js";import{n as p,t as m}from"./minimize-2-BR0ed4mI.js";import{t as h}from"./message-circle-gk_DFUIg.js";import{t as g}from"./plus-JG7kWjHA.js";import{t as _}from"./refresh-cw-Ci7hSykC.js";import{t as v}from"./rotate-ccw-Da_2DvhY.js";import{t as y}from"./search-DA3TmTuR.js";import{t as b}from"./settings-DyEBEqeQ.js";import{t as x}from"./sparkles-DC8kqYjt.js";import{t as S}from"./x-DuBvjmAE.js";import{i as ee,n as C,r as te,t as w}from"./invalidate-memory-queries-BPL6t0Cu.js";import{M as ne}from"./src-BAS7a2RG.js";import{n as T}from"./input-C-GkeWCw.js";import{t as E}from"./modal-DwsThLGg.js";import{n as re}from"./toast-DR7D7Uma.js";import{t as D}from"./file-markdown-DBLxtb0M.js";import{n as O,r as ie,t as ae}from"./api-errors-SZKDzMLE.js";import{ln as oe,yn as k}from"./sdk.gen-BySz4QYj.js";import{d as A}from"./routes-Dwx_Ibh9.js";import{t as j}from"./consent-D2XV8e0u.js";import{n as M}from"./conversation-navigation-CYonSeT9.js";import{n as N}from"./get-memory-stats-CthVfpul.js";import{t as P}from"./assistant-feature-flag-store-Ci_346FY.js";import{t as F}from"./ingest-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-Dy5001j6.js";import{u as r}from"./chunk-5KNZJZUH-Bsoom5--.js";import{n as i}from"./QueryClientProvider-CMu7CkQU.js";import{t as a}from"./useQuery-Bz-fbQ-m.js";import{t as o}from"./jsx-runtime-D3ZM-ToX.js";import{t as s}from"./queryOptions-CMSBCFOf.js";import{t as c}from"./typography-DEI9Ra9z.js";import{t as l}from"./chevron-down-B5A-0g8A.js";import{t as u}from"./chevron-left-CytMddTB.js";import{t as d}from"./chevron-up-2Qqarz0p.js";import{t as f}from"./loader-circle-BzJ2kz3F.js";import{n as p,t as m}from"./minimize-2-BR0ed4mI.js";import{t as h}from"./message-circle-gk_DFUIg.js";import{t as g}from"./plus-JG7kWjHA.js";import{t as _}from"./refresh-cw-Ci7hSykC.js";import{t as v}from"./rotate-ccw-Da_2DvhY.js";import{t as y}from"./search-DA3TmTuR.js";import{t as b}from"./settings-DyEBEqeQ.js";import{t as x}from"./sparkles-DC8kqYjt.js";import{t as S}from"./x-DuBvjmAE.js";import{i as ee,n as C,r as te,t as w}from"./invalidate-memory-queries-BPL6t0Cu.js";import{M as ne}from"./src-BAS7a2RG.js";import{n as T}from"./input-C-GkeWCw.js";import{t as E}from"./modal-DwsThLGg.js";import{n as re}from"./toast-DR7D7Uma.js";import{t as D}from"./file-markdown-DBLxtb0M.js";import{n as O,r as ie,t as ae}from"./api-errors-SZKDzMLE.js";import{ln as oe,yn as k}from"./sdk.gen-BySz4QYj.js";import{d as A}from"./routes-Dwx_Ibh9.js";import{t as j}from"./consent-D2XV8e0u.js";import{n as M}from"./conversation-navigation-CYonSeT9.js";import{n as N}from"./get-memory-stats-CthVfpul.js";import{t as P}from"./assistant-feature-flag-store-Ci_346FY.js";import{t as F}from"./ingest-cbIUCyYd.js";import{t as I}from"./use-assistant-capability-CVGwRhaR.js";import{t as se}from"./use-active-assistant-id-AtGy8p_R.js";var L=e(t(),1),R={x:600,y:450},z=`memory_tab_v1`,B=crypto.randomUUID();function V(e){typeof window>`u`||j()&&F([{type:`onboarding`,daemon_event_id:crypto.randomUUID(),recorded_at:Date.now(),screen:`memory`,session_id:B,step_name:e,funnel_version:z}])}var H=Math.PI*(3-Math.sqrt(5)),U=7,W=2.4,G=34,ce=10;function le(e){return Math.min(G,U+W*Math.sqrt(e))}function ue(e){return e===`concept`||e===`skill`||e===`capability`||e===`pending`?e:`other`}function K(e){return e===`link`||e===`learned`?e:`other`}function de(e,t={}){let n=t.center??R,r=e.nodes,i=r.length;if(i===0)return{nodes:[],edges:[]};let a=new Map;r.forEach((e,t)=>a.set(e.id,t));let o=e.edges.filter(e=>e.source!==e.target&&a.has(e.source)&&a.has(e.target)),s=Array(i).fill(0),c=[];for(let e of o){let t=a.get(e.source),n=a.get(e.target);s[t]++,s[n]++,c.push([t,n])}let l=r.map((e,t)=>le(s[t])),u=70+26*Math.sqrt(i),d=r.map((e,t)=>{let r=(t+.5)/i,a=Math.acos(1-2*r),o=t*H,s=u*Math.cbrt(r),c=Math.sin(a);return{x:n.x+s*c*Math.cos(o),y:n.y+s*c*Math.sin(o),z:s*Math.cos(a),vx:0,vy:0,vz:0}}),f=t.iterations??Math.max(90,Math.min(340,Math.round(46e3/i))),p=.011,m=.82,h=.5,g=1,_=1-.001**(1/f);for(let e=0;e<f;e++){for(let e=0;e<i;e++){let t=d[e];for(let n=e+1;n<i;n++){let r=d[n],i=t.x-r.x,a=t.y-r.y,o=t.z-r.z,s=i*i+a*a+o*o;s<.01&&(i=(e-n)*.1+.1,a=.1,o=.05,s=i*i+a*a+o*o);let c=Math.sqrt(s),l=6400/s,u=i/c*l,f=a/c*l,p=o/c*l;t.vx+=u,t.vy+=f,t.vz+=p,r.vx-=u,r.vy-=f,r.vz-=p}}for(let[e,t]of c){let n=d[e],r=d[t],i=r.x-n.x,a=r.y-n.y,o=r.z-n.z,s=Math.sqrt(i*i+a*a+o*o)||.01,c=.05*(s-140),l=i/s*c,u=a/s*c,f=o/s*c;n.vx+=l,n.vy+=u,n.vz+=f,r.vx-=l,r.vy-=u,r.vz-=f}for(let e=0;e<i;e++){let t=d[e];t.vx+=(n.x-t.x)*p,t.vy+=(n.y-t.y)*p,t.vz+=(0-t.z)*p,t.x+=t.vx*g*h,t.y+=t.vy*g*h,t.z+=t.vz*g*h,t.vx*=m,t.vy*=m,t.vz*=m}g*=1-_}for(let e=0;e<10;e++){let e=!1;for(let t=0;t<i;t++){let n=d[t];for(let r=t+1;r<i;r++){let i=d[r],a=i.x-n.x,o=i.y-n.y,s=i.z-n.z,c=Math.sqrt(a*a+o*o+s*s),u=l[t]+l[r]+ce;if(c>=u)continue;c<.01&&(a=(r-t)*.1+.1,o=.1,s=.05,c=Math.sqrt(a*a+o*o+s*s));let f=(u-c)/2,p=a/c*f,m=o/c*f,h=s/c*f;n.x-=p,n.y-=m,n.z-=h,i.x+=p,i.y+=m,i.z+=h,e=!0}}if(!e)break}return{nodes:r.map((e,t)=>{let n={id:e.id,x:d[t].x,y:d[t].y,z:d[t].z,radius:l[t],label:e.label,kind:ue(e.kind),degree:s[t]};return e.summary&&(n.summary=e.summary),e.updatedAtMs!==void 0&&(n.updatedAtMs=e.updatedAtMs),n}),edges:o.map((e,t)=>{let n={id:`${e.source}__${e.target}__${t}`,fromId:e.source,toId:e.target,kind:K(e.kind),directed:e.directed??!1};return e.description&&(n.description=e.description),n})}}var q=o();function fe({title:e,detail:t,action:n}){return(0,q.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,q.jsx)(`p`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:e}),t?(0,q.jsx)(`p`,{className:`max-w-sm text-body-small-default`,style:{color:`var(--content-tertiary)`},children:t}):null,n?(0,q.jsx)(`div`,{className:`mt-2`,children:n}):null]})}var pe=`Failed to load this concept.`;function me(e,t){return s({queryKey:[`memory-graph-node`,e,t],enabled:!!(e&&t),queryFn:async()=>{let{data:n,error:r,response:i}=await k({path:{assistant_id:e},query:{id:t??``},throwOnError:!1});if(O(i,r,pe),!i.ok)throw new ae(i.status,ie(r,i,pe));return n??{found:!1}}})}var he={concept:`#467CC8`,skill:`#DB4B77`,capability:`#0E9B8B`,pending:`#F1B21E`,other:`#8D99A5`},ge=[`#467CC8`,`#E86B40`,`#7A5AF5`,`#22B8CF`,`#3DB85E`,`#E9C91A`,`#E83F5B`,`#6ECF87`,`#F39B74`,`#F5C94E`],J={concept:`Concept`,skill:`Skill`,capability:`Capability`,pending:`Pending`,other:`Other`},_e=`#F1B21E`;function ve(e){if(e.length<=4)return e.map((e,t)=>({node:e,index:t}));let t=e.slice(-3).map((t,n)=>({node:t,index:e.length-3+n}));return[{node:e[0],index:0},`ellipsis`,...t]}function ye(e){return e?new Date(e).toLocaleDateString(`en-GB`,{day:`numeric`,month:`short`,year:`numeric`}):null}var Y=600;function X(e){let t=e.slice(0,Y),n=t.lastIndexOf(`
|
|
2
2
|
`);return n>Y/2?e.slice(0,n):t}function be({content:e}){let[t,r]=(0,L.useState)(!1);return e.length<=Y?(0,q.jsx)(D,{content:e}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(D,{content:t?e:X(e)}),(0,q.jsx)(n,{variant:`ghost`,size:`compact`,className:`-ml-2 mt-1`,onClick:()=>r(e=>!e),rightIcon:t?(0,q.jsx)(d,{size:16,"aria-hidden":!0}):(0,q.jsx)(l,{size:16,"aria-hidden":!0}),children:t?`Show less`:`Read full note`})]})}function xe({assistantId:e,node:t,trail:r,neighbors:i,onTravel:o,onCrumb:s,onClose:c,onOpenThread:l}){let d=a(me(e,t.id)),f=d.data,p=ye(t.updatedAtMs),m=f?.title??t.label,g=ve(r);return(0,L.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!e.defaultPrevented&&(e.preventDefault(),c())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[c]),(0,q.jsxs)(`div`,{"data-graph-panel":!0,className:`absolute inset-0 z-20 flex justify-end`,onPointerDown:e=>e.stopPropagation(),onPointerMove:e=>e.stopPropagation(),onPointerUp:e=>e.stopPropagation(),children:[(0,q.jsx)(`div`,{className:`absolute inset-0`,style:{backgroundColor:`color-mix(in srgb, var(--surface-base) 16%, transparent)`},onClick:c}),(0,q.jsxs)(`aside`,{className:`relative flex h-full min-h-0 w-full max-w-md flex-col overflow-hidden`,style:{backgroundColor:`var(--surface-lift)`,borderLeft:`1px solid var(--border-base)`},children:[r.length>1?(0,q.jsxs)(`nav`,{"aria-label":`Concept trail`,className:`flex shrink-0 items-center gap-1 overflow-hidden border-b px-5 py-2 text-body-small-default`,style:{borderColor:`var(--border-base)`,color:`var(--content-tertiary)`},children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>s(r.length-2),"aria-label":`Back`,className:`-ml-1 mr-0.5 flex shrink-0 items-center rounded p-0.5 hover:bg-[color-mix(in_srgb,var(--content-tertiary)_14%,transparent)]`,style:{color:`var(--content-tertiary)`},children:(0,q.jsx)(u,{size:16,"aria-hidden":!0})}),g.map((e,t)=>(0,q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[t>0?(0,q.jsx)(`span`,{"aria-hidden":!0,children:`›`}):null,e===`ellipsis`?(0,q.jsx)(`span`,{"aria-hidden":!0,children:`…`}):e.index===r.length-1?(0,q.jsx)(`span`,{"aria-current":`page`,className:`max-w-[9rem] truncate`,style:{color:`var(--content-default)`},children:e.node.label}):(0,q.jsx)(`button`,{type:`button`,onClick:()=>s(e.index),className:`max-w-[8rem] truncate rounded hover:underline`,style:{color:`var(--content-tertiary)`},children:e.node.label})]},e===`ellipsis`?`ellipsis`:e.index))]}):null,(0,q.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-3 border-b px-5 py-4`,style:{borderColor:`var(--border-base)`},children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h2`,{className:`truncate text-title-small`,style:{color:`var(--content-default)`},title:f?.title??t.label,children:f?.title??t.label}),p?(0,q.jsxs)(`p`,{className:`mt-0.5 text-body-small-default`,style:{color:`var(--content-tertiary)`},children:[`Updated `,p]}):null]}),(0,q.jsx)(n,{variant:`ghost`,iconOnly:(0,q.jsx)(S,{"aria-hidden":!0}),onClick:c,"aria-label":`Close`,tintColor:`var(--content-tertiary)`})]}),(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,style:{touchAction:`pan-y`},children:[d.isLoading?(0,q.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,q.jsx)(`div`,{className:`h-5 w-5 animate-spin rounded-full border-2`,style:{borderColor:`var(--border-base)`,borderTopColor:`var(--content-tertiary)`}})}):d.isError?(0,q.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Couldn't load this concept. Try again in a moment.`}):f?.found&&f.content?.trim()?(0,q.jsx)(be,{content:f.content},t.id):(0,q.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`This concept doesn't have written content yet — it exists as a link in the graph, but its page is empty.`}),i.length>0?(0,q.jsxs)(`section`,{className:`mt-6 border-t pt-4`,style:{borderColor:`var(--border-base)`},children:[(0,q.jsxs)(`div`,{className:`mb-2 flex items-baseline justify-between gap-2`,children:[(0,q.jsx)(`h3`,{className:`text-body-small-default uppercase tracking-wide`,style:{color:`var(--content-tertiary)`},children:`Wired to`}),(0,q.jsxs)(`span`,{className:`text-body-small-default tabular-nums`,style:{color:`var(--content-tertiary)`},children:[i.length,` connection`,i.length===1?``:`s`]})]}),(0,q.jsx)(`ul`,{className:`flex list-none flex-col gap-0.5`,children:i.map(e=>(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,onClick:()=>o({id:e.id,label:e.label}),className:`flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-body-medium-default hover:bg-[color-mix(in_srgb,var(--content-tertiary)_12%,transparent)]`,style:{color:`var(--content-default)`},children:[(0,q.jsx)(`span`,{"aria-hidden":!0,className:`h-1.5 w-1.5 shrink-0 rounded-full`,style:{backgroundColor:e.kind===`learned`?_e:`var(--content-tertiary)`}}),(0,q.jsx)(`span`,{className:`truncate`,children:e.label})]})},e.id))})]}):null]}),l?(0,q.jsxs)(`footer`,{className:`flex shrink-0 gap-2 border-t px-5 py-3`,style:{borderColor:`var(--border-base)`},children:[(0,q.jsx)(n,{variant:`outlined`,size:`regular`,className:`flex-1`,leftIcon:(0,q.jsx)(h,{size:16,"aria-hidden":!0}),onClick:()=>l(`Tell me what you remember about "${m}" and how it connects to the rest of what you know.`),children:`Ask about this`}),(0,q.jsx)(n,{variant:`primary`,size:`regular`,className:`flex-1`,leftIcon:(0,q.jsx)(x,{size:16,"aria-hidden":!0}),onClick:()=>l(`I want to refine what you remember about "${m}". Ask me what's off and we'll correct it together.`),children:`Refine`})]}):null]})]})}function Se({onDismiss:e}){return(0,q.jsxs)(`div`,{"data-graph-control":!0,className:`pointer-events-auto absolute left-1/2 top-4 z-10 flex w-[min(30rem,calc(100%-6rem))] -translate-x-1/2 items-start gap-3 rounded-xl px-4 py-3`,style:{backgroundColor:`var(--surface-lift)`,border:`1px solid var(--border-base)`,boxShadow:`0 4px 12px rgba(0, 0, 0, 0.25)`},children:[(0,q.jsx)(`span`,{className:`mt-0.5 shrink-0`,style:{color:`var(--primary-base)`},"aria-hidden":!0,children:(0,q.jsx)(x,{size:18})}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`p`,{className:`text-body-medium-emphasised`,style:{color:`var(--content-default)`},children:`This is your assistant's mind`}),(0,q.jsx)(`p`,{className:`mt-0.5 text-body-small-default`,style:{color:`var(--content-tertiary)`},children:`Every idea it learns — and the links it draws between them — shows up here. The map grows and rearranges itself as you talk, so the more you share, the richer it gets.`})]}),(0,q.jsx)(n,{variant:`ghost`,iconOnly:(0,q.jsx)(S,{"aria-hidden":!0}),onClick:e,"aria-label":`Dismiss`,tintColor:`var(--content-tertiary)`})]})}var Ce=8;function we({nodeKinds:e,coloredByTheme:t,themes:n,hasLinks:r,hasLearned:i,onToggleLink:a,onToggleLearned:o,linkActive:s,learnedActive:c}){return(0,q.jsxs)(`div`,{"data-graph-control":!0,className:`pointer-events-none absolute bottom-4 left-4 flex flex-col gap-1.5 rounded-lg px-3 py-2`,style:{backgroundColor:`color-mix(in srgb, var(--surface-base) 78%, transparent)`,border:`1px solid var(--border-base)`},children:[e.map(e=>(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`inline-block h-2.5 w-2.5 rounded-full`,style:{backgroundColor:he[e]}}),(0,q.jsx)(`span`,{className:`text-[11px]`,style:{color:`var(--content-tertiary)`},children:J[e]})]},e)),t&&(n&&n.length>0?(0,q.jsxs)(q.Fragment,{children:[n.slice(0,Ce).map((e,t)=>(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`inline-block h-2.5 w-2.5 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),(0,q.jsx)(`span`,{className:`max-w-[9rem] truncate text-[11px]`,style:{color:`var(--content-tertiary)`},title:e.concepts?.join(` · `)??e.name,children:e.name})]},t)),n.length>Ce&&(0,q.jsxs)(`span`,{className:`text-[11px]`,style:{color:`var(--content-tertiary)`},children:[`+`,n.length-Ce,` more`]})]}):(0,q.jsx)(`span`,{className:`text-[11px]`,style:{color:`var(--content-tertiary)`},children:`Colored by theme`})),(e.length>0||t)&&(r||i)&&(0,q.jsx)(`div`,{className:`mt-0.5 border-t pt-1.5`,style:{borderColor:`var(--border-base)`}}),r&&(0,q.jsx)(Te,{swatchStyle:{borderTop:`2px solid var(--content-tertiary)`},label:`Link`,onToggle:a,active:s}),i&&(0,q.jsx)(Te,{swatchStyle:{borderTop:`2px dashed #F1B21E`},label:`Learned`,onToggle:o,active:c})]})}function Te({swatchStyle:e,label:t,onToggle:n,active:r}){let i=(0,q.jsx)(`span`,{className:`inline-block h-0 w-4`,style:e}),a=(0,q.jsx)(`span`,{className:`text-[11px]`,style:{color:`var(--content-tertiary)`},children:t});return n?(0,q.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":r,className:`pointer-events-auto flex cursor-pointer items-center gap-2 border-0 bg-transparent p-0 transition-opacity`,style:{opacity:r===!1?.4:1},children:[i,a]}):(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i,a]})}var Ee=8;function De(e,t){let n=e.length;if(n===0)return new Map;let r=new Map;e.forEach((e,t)=>r.set(e.id,t));let i=e.map(()=>[]);for(let e of t){let t=r.get(e.fromId),n=r.get(e.toId);t===void 0||n===void 0||t===n||(i[t].push(n),i[n].push(t))}let a=e.map((e,t)=>t);for(let e=0;e<Ee;e++)for(let e=0;e<n;e++){let t=i[e];if(t.length===0)continue;let n=new Map;for(let e of t)n.set(a[e],(n.get(a[e])??0)+1);let r=a[e],o=-1;for(let[e,t]of n)(t>o||t===o&&e<r)&&(r=e,o=t);a[e]=r}let o=new Map,s=new Map;return e.forEach((e,t)=>{let n=a[t],r=o.get(n);r===void 0&&(r=o.size,o.set(n,r)),s.set(e.id,r)}),s}var Z=`Migrate my memory from v2 to v3. That's most likely your "Memory v3 Migration" skill, but work out what my corpus actually needs and follow whichever skill you use exactly.
|
|
3
3
|
|
|
4
4
|
Run it in the background and tell me when it's done, or if something blocks.`,Q=`Migrate my memory from v1 to v3. That's most likely two hops, your "Memory v2 Migration" skill and then your "Memory v3 Migration" skill, but work out what my assistant actually needs and follow whichever skills you use exactly.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./useQuery-Bz-fbQ-m.js";import{t as r}from"./useMutation-CXGTrp4W.js";import{t as i}from"./jsx-runtime-D3ZM-ToX.js";import{t as a}from"./card-DRIctGVs.js";import"./src-BAS7a2RG.js";import{s as o}from"./auth-store-QpgWmI2t.js";import{mn as s}from"./sdk.gen-BySz4QYj.js";import{t as c}from"./client-feature-flag-store-DhF7SK2q.js";import{X as l,Y as u,h as d}from"./react-query.gen-Cnk5tcFs.js";import{t as f}from"./access-C1I5oond.js";import{t as p}from"./use-active-assistant-id-AtGy8p_R.js";var m=e(t(),1),h=class extends Error{status;constructor(e,t){super(t),this.name=`SimulateMemoryRouterError`,this.status=e}};async function g(e,t,n){let{data:r,response:i}=await s({path:{assistant_id:e},body:t,signal:n,throwOnError:!1}),a=i?await i.clone().text().catch(()=>``):``;if(!i||!i.ok)throw new h(i?.status??0,a||i?.statusText||`Failed to simulate memory router`);if(!r)throw new h(i.status,`Empty response from memory router simulator endpoint`);return{response:r,rawRequest:JSON.stringify(t,null,2),rawResponse:_(a)}}function _(e){if(e.length===0)return e;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function v(e){return r({mutationFn:async t=>{if(!e)throw new h(0,`Missing assistantId`);return g(e,t)}})}function y(e){return n({...d({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4})}function b(e){return n({...l({path:{assistant_id:e}}),enabled:!!e,staleTime:1440*60*1e3})}function x(e){return n({...u({path:{assistant_id:e}}),enabled:!!e,staleTime:1/0})}var S=i();function C(){let e=f(),t=o(),n=c.use.memoryRouterPlayground();return t?(0,S.jsx)($,{children:`Loading…`}):!e||!n?(0,S.jsx)($,{children:`Memory router playground is not available.`}):(0,S.jsx)(T,{})}var w={tier1:``,tier2:``,batch:``,profile:``,customPrompt:``};function T(){let e=p(),t=v(e),n=v(e),r=y(e),i=b(e),a=x(e),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)([{assistantMessage:``,userMessage:``}]),[u,d]=(0,m.useState)(!1);(0,m.useEffect)(()=>{if(u)return;let e=a.data?.nowText;typeof e==`string`&&o===``&&s(e)},[a.data?.nowText,o,u]);let[f,h]=(0,m.useState)(w),[g,_]=(0,m.useState)(w),[C,T]=(0,m.useState)(null),[D,k]=(0,m.useState)(null),j=c[c.length-1].userMessage,M=e=>{let r=e===`A`?f:g,i=e===`A`?T:k,a=e===`A`?t:n;i(null);let s;try{s=E(r)}catch(e){i(e instanceof Error?e.message:`Invalid override input`);return}let l=r.profile.trim().length>0?r.profile:void 0,u=r.customPrompt.trim().length>0?r.customPrompt:void 0,d=c.map((e,t)=>t===c.length-1?{...e,userMessage:e.userMessage.trim()}:e);a.mutate({recentTurnPairs:d,nowText:o,...s?{configOverrides:s}:{},...l===void 0?{}:{profileOverride:l},...u===void 0?{}:{routerPromptOverride:u}})},N=()=>{M(`A`),M(`B`)},P=j.trim().length>0,I=P&&!t.isPending,L=P&&!n.isPending;return(0,S.jsx)(`div`,{className:`flex h-full min-h-0 flex-col overflow-y-auto`,children:(0,S.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[1280px] flex-col gap-6 p-6`,children:[(0,S.jsx)(ee,{}),(0,S.jsx)(O,{nowText:o,onNowTextChange:e=>{d(!0),s(e)},onReloadNowText:()=>{let e=a.data?.nowText;typeof e==`string`&&(s(e),d(!1))},nowTextLoading:a.isLoading,pairs:c,onPairsChange:l}),(0,S.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[(0,S.jsx)(A,{paneId:`A`,overrides:f,onChange:h,onRun:()=>M(`A`),canRun:I,isRunning:t.isPending,profiles:r.data?.profiles??[],activeProfile:r.data?.activeProfile??null,defaultPromptTemplate:i.data?.template??``}),(0,S.jsx)(A,{paneId:`B`,overrides:g,onChange:_,onRun:()=>M(`B`),canRun:L,isRunning:n.isPending,profiles:r.data?.profiles??[],activeProfile:r.data?.activeProfile??null,defaultPromptTemplate:i.data?.template??``})]}),(0,S.jsx)(`div`,{className:`flex justify-end`,children:(0,S.jsx)(te,{onClick:N,disabled:!P||t.isPending||n.isPending,isRunning:t.isPending||n.isPending})}),(0,S.jsx)(ne,{visible:t.data!==void 0&&n.data!==void 0}),(0,S.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[(0,S.jsx)(F,{paneId:`A`,userMessage:j,mutation:t,otherResult:n.data?.response,validation:C}),(0,S.jsx)(F,{paneId:`B`,userMessage:j,mutation:n,otherResult:t.data?.response,validation:D})]})]})})}function E(e){let t={...D(`tier1_size`,e.tier1),...D(`tier2_size`,e.tier2),...D(`batch_size`,e.batch)};return Object.keys(t).length===0?void 0:t}function D(e,t){let n=t.trim();if(n===``)return{};if(n===`null`)return{[e]:null};let r=Number(n);if(!Number.isInteger(r)||r<1)throw Error(`${e} must be a positive integer or 'null' (got "${n}")`);return{[e]:r}}function ee(){return(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`h1`,{className:`text-body-large-default`,style:{color:`var(--content-default)`},children:`Memory Router Playground`}),(0,S.jsxs)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-secondary)`},children:[`Dry-run the v4 router with custom tier/batch overrides. Read-only — no rows are written to `,(0,S.jsx)(`code`,{children:`memory_v2_injection_events`}),` or`,` `,(0,S.jsx)(`code`,{children:`memory_v2_activation_logs`}),`, and no activation state is mutated. Leave an override blank to inherit the live config value; enter`,` `,(0,S.jsx)(`code`,{children:`null`}),` to explicitly disable a tier.`]})]})}function O({nowText:e,onNowTextChange:t,onReloadNowText:n,nowTextLoading:r,pairs:i,onPairsChange:o}){let s=(e,t)=>{o(i.map((n,r)=>r===e?{...n,...t}:n))},c=()=>{o([{assistantMessage:``,userMessage:``},...i])},l=e=>{e!==i.length-1&&o(i.filter((t,n)=>n!==e))};return(0,S.jsx)(a,{children:(0,S.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,S.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:`Conversational context (shared by both panes)`}),(0,S.jsx)(k,{id:`memory-router-playground-now`,label:`<now> block`,value:e,onChange:t,rows:6,monospace:!0,placeholder:r?`Loading current NOW.md…`:`Pre-filled with the live NOW.md. Edit to test alternate states.`,trailing:(0,S.jsx)(`button`,{type:`button`,onClick:n,disabled:r,className:`rounded px-2 py-1 text-label-default`,style:{background:`var(--surface-overlay)`,color:`var(--content-secondary)`,border:`none`,cursor:r?`not-allowed`:`pointer`},children:`Reload live NOW.md`})}),(0,S.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,S.jsx)(`span`,{className:`text-label-default`,style:{color:`var(--content-secondary)`},children:`Recent (assistant, user) pairs · oldest first`}),(0,S.jsx)(`button`,{type:`button`,onClick:c,className:`rounded px-2 py-1 text-label-default`,style:{background:`var(--surface-overlay)`,color:`var(--content-secondary)`,border:`none`,cursor:`pointer`},children:`+ Add older pair`})]}),i.map((e,t)=>{let n=t===i.length-1;return(0,S.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border p-3`,style:{borderColor:`var(--border-base)`,background:`var(--surface-base)`},children:[(0,S.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,S.jsxs)(`span`,{className:`text-label-default`,style:{color:`var(--content-secondary)`},children:[`Pair `,t+1,` of `,i.length,n?` · most recent`:``]}),!n&&(0,S.jsx)(`button`,{type:`button`,onClick:()=>l(t),className:`rounded px-2 py-1 text-label-default`,style:{background:`transparent`,color:`var(--system-negative-strong)`,border:`none`,cursor:`pointer`},children:`Remove`})]}),(0,S.jsx)(k,{id:`memory-router-playground-pair-${t}-assistant`,label:`[assistant]: reply`,value:e.assistantMessage,onChange:e=>s(t,{assistantMessage:e}),rows:3,placeholder:t===0&&i.length===1?`Leave blank for a first-turn scenario.`:`Assistant's reply that came before the user message below.`}),(0,S.jsx)(k,{id:`memory-router-playground-pair-${t}-user`,label:n?`Just-arrived [user]: message`:`[user]: message`,value:e.userMessage,onChange:e=>s(t,{userMessage:e}),rows:3,placeholder:n?`e.g. what should we ship next`:`User's message.`,required:n})]},t)})]})})}function k({id:e,label:t,value:n,onChange:r,rows:i,placeholder:a,monospace:o,trailing:s,required:c}){return(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`label`,{htmlFor:e,className:`text-label-default`,style:{color:`var(--content-secondary)`},children:[t,c?` *`:``]}),s]}),(0,S.jsx)(`textarea`,{id:e,value:n,onChange:e=>r(e.target.value),rows:i,placeholder:a,className:`rounded-md border px-3 py-2 text-body-medium-default`,style:{borderColor:`var(--border-base)`,background:`var(--surface-base)`,color:`var(--content-default)`,resize:`vertical`,...o?{fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`}:{}}})]})}function A({paneId:e,overrides:t,onChange:n,onRun:r,canRun:i,isRunning:o,profiles:s,activeProfile:c,defaultPromptTemplate:l}){return(0,S.jsx)(a,{children:(0,S.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,S.jsxs)(`div`,{className:`text-body-medium-default`,style:{color:q(e)},children:[`Config `,e]}),(0,S.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3`,children:[(0,S.jsx)(N,{paneId:e,label:`tier1_size`,value:t.tier1,onChange:e=>n({...t,tier1:e})}),(0,S.jsx)(N,{paneId:e,label:`tier2_size`,value:t.tier2,onChange:e=>n({...t,tier2:e})}),(0,S.jsx)(N,{paneId:e,label:`batch_size`,value:t.batch,onChange:e=>n({...t,batch:e})})]}),(0,S.jsx)(M,{paneId:e,value:t.profile,onChange:e=>n({...t,profile:e}),profiles:s,activeProfile:c}),(0,S.jsx)(j,{paneId:e,value:t.customPrompt,onChange:e=>n({...t,customPrompt:e}),defaultTemplate:l}),(0,S.jsx)(`div`,{className:`flex justify-end`,children:(0,S.jsx)(`button`,{type:`button`,onClick:r,disabled:!i,className:`rounded-md px-4 py-2 text-body-medium-default transition-colors`,style:{background:i?`var(--system-positive-strong)`:`var(--surface-overlay)`,color:i?`var(--content-on-positive)`:`var(--content-disabled)`,border:`none`,cursor:i?`pointer`:`not-allowed`},children:o?`Running…`:`Run ${e}`})})]})})}function j({paneId:e,value:t,onChange:n,defaultTemplate:r}){let[i,a]=(0,m.useState)(!1),o=`memory-router-playground-${e}-prompt`,s=t.trim().length>0;return(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`text-label-default`,style:{color:`var(--content-secondary)`,background:`transparent`,border:`none`,padding:0,cursor:`pointer`,textAlign:`left`},children:[i?`▾`:`▸`,` System prompt`,` `,(0,S.jsxs)(`span`,{style:{color:`var(--content-tertiary)`},children:[`(`,s?`custom`:`bundled`,`)`]})]}),i&&(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>n(r),disabled:r.length===0,className:`rounded px-2 py-1 text-label-default`,style:{background:`var(--surface-overlay)`,color:`var(--content-secondary)`,border:`none`,cursor:r.length===0?`not-allowed`:`pointer`},children:`Load default`}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>n(``),disabled:!s,className:`rounded px-2 py-1 text-label-default`,style:{background:`var(--surface-overlay)`,color:`var(--content-secondary)`,border:`none`,cursor:s?`pointer`:`not-allowed`},children:`Reset`})]})]}),i&&(0,S.jsx)(`textarea`,{id:o,value:t,onChange:e=>n(e.target.value),rows:12,placeholder:`Custom router system prompt. Available placeholders:
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./useQuery-Bz-fbQ-m.js";import{t as r}from"./useMutation-CXGTrp4W.js";import{t as i}from"./jsx-runtime-D3ZM-ToX.js";import{t as a}from"./card-DRIctGVs.js";import"./src-BAS7a2RG.js";import{s as o}from"./auth-store-D55YOXDj.js";import{mn as s}from"./sdk.gen-BySz4QYj.js";import{t as c}from"./client-feature-flag-store-DhF7SK2q.js";import{X as l,Y as u,h as d}from"./react-query.gen-Cnk5tcFs.js";import{t as f}from"./access-yGcxATuu.js";import{t as p}from"./use-active-assistant-id-AtGy8p_R.js";var m=e(t(),1),h=class extends Error{status;constructor(e,t){super(t),this.name=`SimulateMemoryRouterError`,this.status=e}};async function g(e,t,n){let{data:r,response:i}=await s({path:{assistant_id:e},body:t,signal:n,throwOnError:!1}),a=i?await i.clone().text().catch(()=>``):``;if(!i||!i.ok)throw new h(i?.status??0,a||i?.statusText||`Failed to simulate memory router`);if(!r)throw new h(i.status,`Empty response from memory router simulator endpoint`);return{response:r,rawRequest:JSON.stringify(t,null,2),rawResponse:_(a)}}function _(e){if(e.length===0)return e;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function v(e){return r({mutationFn:async t=>{if(!e)throw new h(0,`Missing assistantId`);return g(e,t)}})}function y(e){return n({...d({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4})}function b(e){return n({...l({path:{assistant_id:e}}),enabled:!!e,staleTime:1440*60*1e3})}function x(e){return n({...u({path:{assistant_id:e}}),enabled:!!e,staleTime:1/0})}var S=i();function C(){let e=f(),t=o(),n=c.use.memoryRouterPlayground();return t?(0,S.jsx)($,{children:`Loading…`}):!e||!n?(0,S.jsx)($,{children:`Memory router playground is not available.`}):(0,S.jsx)(T,{})}var w={tier1:``,tier2:``,batch:``,profile:``,customPrompt:``};function T(){let e=p(),t=v(e),n=v(e),r=y(e),i=b(e),a=x(e),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)([{assistantMessage:``,userMessage:``}]),[u,d]=(0,m.useState)(!1);(0,m.useEffect)(()=>{if(u)return;let e=a.data?.nowText;typeof e==`string`&&o===``&&s(e)},[a.data?.nowText,o,u]);let[f,h]=(0,m.useState)(w),[g,_]=(0,m.useState)(w),[C,T]=(0,m.useState)(null),[D,k]=(0,m.useState)(null),j=c[c.length-1].userMessage,M=e=>{let r=e===`A`?f:g,i=e===`A`?T:k,a=e===`A`?t:n;i(null);let s;try{s=E(r)}catch(e){i(e instanceof Error?e.message:`Invalid override input`);return}let l=r.profile.trim().length>0?r.profile:void 0,u=r.customPrompt.trim().length>0?r.customPrompt:void 0,d=c.map((e,t)=>t===c.length-1?{...e,userMessage:e.userMessage.trim()}:e);a.mutate({recentTurnPairs:d,nowText:o,...s?{configOverrides:s}:{},...l===void 0?{}:{profileOverride:l},...u===void 0?{}:{routerPromptOverride:u}})},N=()=>{M(`A`),M(`B`)},P=j.trim().length>0,I=P&&!t.isPending,L=P&&!n.isPending;return(0,S.jsx)(`div`,{className:`flex h-full min-h-0 flex-col overflow-y-auto`,children:(0,S.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[1280px] flex-col gap-6 p-6`,children:[(0,S.jsx)(ee,{}),(0,S.jsx)(O,{nowText:o,onNowTextChange:e=>{d(!0),s(e)},onReloadNowText:()=>{let e=a.data?.nowText;typeof e==`string`&&(s(e),d(!1))},nowTextLoading:a.isLoading,pairs:c,onPairsChange:l}),(0,S.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[(0,S.jsx)(A,{paneId:`A`,overrides:f,onChange:h,onRun:()=>M(`A`),canRun:I,isRunning:t.isPending,profiles:r.data?.profiles??[],activeProfile:r.data?.activeProfile??null,defaultPromptTemplate:i.data?.template??``}),(0,S.jsx)(A,{paneId:`B`,overrides:g,onChange:_,onRun:()=>M(`B`),canRun:L,isRunning:n.isPending,profiles:r.data?.profiles??[],activeProfile:r.data?.activeProfile??null,defaultPromptTemplate:i.data?.template??``})]}),(0,S.jsx)(`div`,{className:`flex justify-end`,children:(0,S.jsx)(te,{onClick:N,disabled:!P||t.isPending||n.isPending,isRunning:t.isPending||n.isPending})}),(0,S.jsx)(ne,{visible:t.data!==void 0&&n.data!==void 0}),(0,S.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[(0,S.jsx)(F,{paneId:`A`,userMessage:j,mutation:t,otherResult:n.data?.response,validation:C}),(0,S.jsx)(F,{paneId:`B`,userMessage:j,mutation:n,otherResult:t.data?.response,validation:D})]})]})})}function E(e){let t={...D(`tier1_size`,e.tier1),...D(`tier2_size`,e.tier2),...D(`batch_size`,e.batch)};return Object.keys(t).length===0?void 0:t}function D(e,t){let n=t.trim();if(n===``)return{};if(n===`null`)return{[e]:null};let r=Number(n);if(!Number.isInteger(r)||r<1)throw Error(`${e} must be a positive integer or 'null' (got "${n}")`);return{[e]:r}}function ee(){return(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`h1`,{className:`text-body-large-default`,style:{color:`var(--content-default)`},children:`Memory Router Playground`}),(0,S.jsxs)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-secondary)`},children:[`Dry-run the v4 router with custom tier/batch overrides. Read-only — no rows are written to `,(0,S.jsx)(`code`,{children:`memory_v2_injection_events`}),` or`,` `,(0,S.jsx)(`code`,{children:`memory_v2_activation_logs`}),`, and no activation state is mutated. Leave an override blank to inherit the live config value; enter`,` `,(0,S.jsx)(`code`,{children:`null`}),` to explicitly disable a tier.`]})]})}function O({nowText:e,onNowTextChange:t,onReloadNowText:n,nowTextLoading:r,pairs:i,onPairsChange:o}){let s=(e,t)=>{o(i.map((n,r)=>r===e?{...n,...t}:n))},c=()=>{o([{assistantMessage:``,userMessage:``},...i])},l=e=>{e!==i.length-1&&o(i.filter((t,n)=>n!==e))};return(0,S.jsx)(a,{children:(0,S.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,S.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:`Conversational context (shared by both panes)`}),(0,S.jsx)(k,{id:`memory-router-playground-now`,label:`<now> block`,value:e,onChange:t,rows:6,monospace:!0,placeholder:r?`Loading current NOW.md…`:`Pre-filled with the live NOW.md. Edit to test alternate states.`,trailing:(0,S.jsx)(`button`,{type:`button`,onClick:n,disabled:r,className:`rounded px-2 py-1 text-label-default`,style:{background:`var(--surface-overlay)`,color:`var(--content-secondary)`,border:`none`,cursor:r?`not-allowed`:`pointer`},children:`Reload live NOW.md`})}),(0,S.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,S.jsx)(`span`,{className:`text-label-default`,style:{color:`var(--content-secondary)`},children:`Recent (assistant, user) pairs · oldest first`}),(0,S.jsx)(`button`,{type:`button`,onClick:c,className:`rounded px-2 py-1 text-label-default`,style:{background:`var(--surface-overlay)`,color:`var(--content-secondary)`,border:`none`,cursor:`pointer`},children:`+ Add older pair`})]}),i.map((e,t)=>{let n=t===i.length-1;return(0,S.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border p-3`,style:{borderColor:`var(--border-base)`,background:`var(--surface-base)`},children:[(0,S.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,S.jsxs)(`span`,{className:`text-label-default`,style:{color:`var(--content-secondary)`},children:[`Pair `,t+1,` of `,i.length,n?` · most recent`:``]}),!n&&(0,S.jsx)(`button`,{type:`button`,onClick:()=>l(t),className:`rounded px-2 py-1 text-label-default`,style:{background:`transparent`,color:`var(--system-negative-strong)`,border:`none`,cursor:`pointer`},children:`Remove`})]}),(0,S.jsx)(k,{id:`memory-router-playground-pair-${t}-assistant`,label:`[assistant]: reply`,value:e.assistantMessage,onChange:e=>s(t,{assistantMessage:e}),rows:3,placeholder:t===0&&i.length===1?`Leave blank for a first-turn scenario.`:`Assistant's reply that came before the user message below.`}),(0,S.jsx)(k,{id:`memory-router-playground-pair-${t}-user`,label:n?`Just-arrived [user]: message`:`[user]: message`,value:e.userMessage,onChange:e=>s(t,{userMessage:e}),rows:3,placeholder:n?`e.g. what should we ship next`:`User's message.`,required:n})]},t)})]})})}function k({id:e,label:t,value:n,onChange:r,rows:i,placeholder:a,monospace:o,trailing:s,required:c}){return(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`label`,{htmlFor:e,className:`text-label-default`,style:{color:`var(--content-secondary)`},children:[t,c?` *`:``]}),s]}),(0,S.jsx)(`textarea`,{id:e,value:n,onChange:e=>r(e.target.value),rows:i,placeholder:a,className:`rounded-md border px-3 py-2 text-body-medium-default`,style:{borderColor:`var(--border-base)`,background:`var(--surface-base)`,color:`var(--content-default)`,resize:`vertical`,...o?{fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`}:{}}})]})}function A({paneId:e,overrides:t,onChange:n,onRun:r,canRun:i,isRunning:o,profiles:s,activeProfile:c,defaultPromptTemplate:l}){return(0,S.jsx)(a,{children:(0,S.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,S.jsxs)(`div`,{className:`text-body-medium-default`,style:{color:q(e)},children:[`Config `,e]}),(0,S.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3`,children:[(0,S.jsx)(N,{paneId:e,label:`tier1_size`,value:t.tier1,onChange:e=>n({...t,tier1:e})}),(0,S.jsx)(N,{paneId:e,label:`tier2_size`,value:t.tier2,onChange:e=>n({...t,tier2:e})}),(0,S.jsx)(N,{paneId:e,label:`batch_size`,value:t.batch,onChange:e=>n({...t,batch:e})})]}),(0,S.jsx)(M,{paneId:e,value:t.profile,onChange:e=>n({...t,profile:e}),profiles:s,activeProfile:c}),(0,S.jsx)(j,{paneId:e,value:t.customPrompt,onChange:e=>n({...t,customPrompt:e}),defaultTemplate:l}),(0,S.jsx)(`div`,{className:`flex justify-end`,children:(0,S.jsx)(`button`,{type:`button`,onClick:r,disabled:!i,className:`rounded-md px-4 py-2 text-body-medium-default transition-colors`,style:{background:i?`var(--system-positive-strong)`:`var(--surface-overlay)`,color:i?`var(--content-on-positive)`:`var(--content-disabled)`,border:`none`,cursor:i?`pointer`:`not-allowed`},children:o?`Running…`:`Run ${e}`})})]})})}function j({paneId:e,value:t,onChange:n,defaultTemplate:r}){let[i,a]=(0,m.useState)(!1),o=`memory-router-playground-${e}-prompt`,s=t.trim().length>0;return(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`text-label-default`,style:{color:`var(--content-secondary)`,background:`transparent`,border:`none`,padding:0,cursor:`pointer`,textAlign:`left`},children:[i?`▾`:`▸`,` System prompt`,` `,(0,S.jsxs)(`span`,{style:{color:`var(--content-tertiary)`},children:[`(`,s?`custom`:`bundled`,`)`]})]}),i&&(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>n(r),disabled:r.length===0,className:`rounded px-2 py-1 text-label-default`,style:{background:`var(--surface-overlay)`,color:`var(--content-secondary)`,border:`none`,cursor:r.length===0?`not-allowed`:`pointer`},children:`Load default`}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>n(``),disabled:!s,className:`rounded px-2 py-1 text-label-default`,style:{background:`var(--surface-overlay)`,color:`var(--content-secondary)`,border:`none`,cursor:s?`pointer`:`not-allowed`},children:`Reset`})]})]}),i&&(0,S.jsx)(`textarea`,{id:o,value:t,onChange:e=>n(e.target.value),rows:12,placeholder:`Custom router system prompt. Available placeholders:
|
|
2
2
|
{{ASSISTANT_NAME}}, {{USER_NAME}}, {{PAGE_INDEX}}
|
|
3
3
|
Leave blank to use the bundled template. "Load default" seeds the textarea with the bundled body for editing.`,className:`rounded-md border px-3 py-2 text-body-small-default`,style:{borderColor:`var(--border-base)`,background:`var(--surface-base)`,color:`var(--content-default)`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,resize:`vertical`,minHeight:`120px`}})]})}function M({paneId:e,value:t,onChange:n,profiles:r,activeProfile:i}){let a=`memory-router-playground-${e}-profile`,o=i!==null&&i.length>0?`inherit active (${i})`:`inherit active`;return(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`label`,{htmlFor:a,className:`text-label-default`,style:{color:`var(--content-secondary)`},children:`llm.profiles override`}),(0,S.jsxs)(`select`,{id:a,value:t,onChange:e=>n(e.target.value),className:`rounded-md border px-3 py-2 text-body-medium-default`,style:{borderColor:`var(--border-base)`,background:`var(--surface-base)`,color:`var(--content-default)`},children:[(0,S.jsx)(`option`,{value:``,children:o}),r.map(e=>(0,S.jsx)(`option`,{value:e,children:e},e))]})]})}function N({paneId:e,label:t,value:n,onChange:r}){let i=`memory-router-playground-${e}-${t}`;return(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`label`,{htmlFor:i,className:`text-label-default`,style:{color:`var(--content-secondary)`},children:t}),(0,S.jsx)(`input`,{id:i,value:n,onChange:e=>r(e.target.value),placeholder:`inherit`,className:`rounded-md border px-3 py-2 text-body-medium-default`,style:{borderColor:`var(--border-base)`,background:`var(--surface-base)`,color:`var(--content-default)`}})]})}function te({onClick:e,disabled:t,isRunning:n}){return(0,S.jsx)(`button`,{type:`button`,onClick:e,disabled:t,className:`rounded-md px-4 py-2 text-body-medium-default transition-colors`,style:{background:t?`var(--surface-overlay)`:`var(--primary-base)`,color:t?`var(--content-disabled)`:`var(--content-on-primary)`,border:`none`,cursor:t?`not-allowed`:`pointer`},children:n?`Running…`:`Run both`})}function ne({visible:e}){return e?(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 rounded-md px-4 py-2 text-label-default`,style:{background:`var(--surface-overlay)`,color:`var(--content-secondary)`},children:[(0,S.jsx)(P,{marker:`●`,markerColor:`var(--content-default)`,label:`in both`}),(0,S.jsx)(P,{marker:`◆`,markerColor:q(`A`),label:`A only`}),(0,S.jsx)(P,{marker:`◇`,markerColor:q(`B`),label:`B only`})]}):null}function P({marker:e,markerColor:t,label:n}){return(0,S.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,S.jsx)(`span`,{style:{color:t},children:e}),(0,S.jsx)(`span`,{children:n})]})}function F({paneId:e,userMessage:t,mutation:n,otherResult:r,validation:i}){let a=n.data;return(0,S.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,S.jsx)(R,{paneId:e}),i!==null&&(0,S.jsx)(Q,{message:i}),n.isError&&(0,S.jsx)(Q,{message:n.error instanceof Error?n.error.message:`Failed to run simulation`}),a!==void 0&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(z,{paneId:e,userMessage:t,result:a.response,otherResult:r}),(0,S.jsx)(I,{paneId:e,rawRequest:a.rawRequest,rawResponse:a.rawResponse})]})]})}function I({paneId:e,rawRequest:t,rawResponse:n}){let[r,i]=(0,m.useState)(!1);return(0,S.jsx)(a,{children:(0,S.jsxs)(`div`,{className:`flex flex-col gap-2 p-4`,children:[(0,S.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`text-label-default`,style:{color:`var(--content-secondary)`,background:`transparent`,border:`none`,padding:0,cursor:`pointer`,textAlign:`left`},children:[r?`▾`:`▸`,` Raw API exchange`]}),r&&(0,S.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,S.jsx)(L,{label:`Request (Pane ${e})`,body:t}),(0,S.jsx)(L,{label:`Response (Pane ${e})`,body:n})]})]})})}function L({label:e,body:t}){return(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`span`,{className:`text-label-default`,style:{color:`var(--content-secondary)`},children:e}),(0,S.jsx)(`pre`,{className:`overflow-auto rounded-md border px-3 py-2 text-body-small-default`,style:{borderColor:`var(--border-base)`,background:`var(--surface-base)`,color:`var(--content-default)`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,maxHeight:`320px`,whiteSpace:`pre`},children:t.length===0?`(empty)`:t})]})}function R({paneId:e}){return(0,S.jsxs)(`div`,{className:`text-body-medium-default`,style:{color:q(e)},children:[`Pane `,e]})}function z({paneId:e,userMessage:t,result:n,otherResult:r}){let i=(0,m.useMemo)(()=>B(n,r),[n,r]),a=(0,m.useMemo)(()=>W(n),[n]);return(0,S.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,S.jsx)(H,{result:n,userMessage:t,otherResult:r,counts:(0,m.useMemo)(()=>V(i),[i])}),(0,S.jsx)(U,{result:n}),n.failureReason!==null&&(0,S.jsx)(Q,{message:`Router failure: ${n.failureReason}`}),a.length===0?(0,S.jsx)(X,{}):a.map(t=>(0,S.jsx)(Y,{paneId:e,source:t.source,slugs:t.slugs,scores:n.scores,diff:i},t.source))]})}function B(e,t){let n=new Map;if(t===void 0){for(let t of e.selectedSlugs)n.set(t,`both`);return n}let r=new Set(t.selectedSlugs);for(let t of e.selectedSlugs)n.set(t,r.has(t)?`both`:`only-here`);return n}function V(e){let t=0,n=0;for(let r of e.values())r===`both`?t++:n++;return{total:e.size,shared:t,unique:n}}function H({result:e,userMessage:t,otherResult:n,counts:r}){let i=[{label:`User message`,value:t},{label:`Total candidate pages`,value:e.totalCandidatePages.toLocaleString()},{label:`Selected`,value:`${e.selectedSlugs.length} (live max_page_ids: ${e.effectiveConfig.max_page_ids})`}];return n!==void 0&&i.push({label:`Diff`,value:`${r.shared} shared · ${r.unique} unique to this pane`}),(0,S.jsx)(a,{children:(0,S.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,S.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:`Summary`}),(0,S.jsx)(Z,{rows:i})]})})}function U({result:e}){let t=[`tier1_size`,`tier2_size`,`batch_size`,`max_page_ids`].map(t=>{let n=e.effectiveConfig[t],r=e.overrides[t];return{label:t,value:`${n===null?`null`:String(n)}${r===void 0?``:` (override)`}`}});return t.push({label:`llm.profiles override`,value:e.profileOverride===null?`inherit active`:`${e.profileOverride} (override)`}),t.push({label:`system prompt`,value:e.routerPromptOverridden?`custom`:`bundled`}),(0,S.jsx)(a,{children:(0,S.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,S.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:`Effective config`}),(0,S.jsx)(Z,{rows:t})]})})}function W(e){let t=new Map;for(let n of e.selectedSlugs){let r=e.sourceBySlug[n];if(r===void 0)continue;let i=t.get(r)??[];i.push(n),t.set(r,i)}return[...t.keys()].sort((e,t)=>G(e)-G(t)).map(e=>({source:e,slugs:t.get(e)}))}function G(e){return e===`tier1`?0:e===`tier2`?1:e.startsWith(`tier3:`)?2+Number(e.slice(6)):2**53-1}function K(e){return e===`tier1`?`tier 1`:e===`tier2`?`tier 2`:e.startsWith(`tier3:`)?`tier 3 · b${e.slice(6)}`:e}function q(e){return e===`A`?`var(--system-mid-strong)`:`var(--primary-base)`}function J(e,t){return t===`both`?{color:`var(--content-default)`,marker:`●`}:{color:q(e),marker:e===`A`?`◆`:`◇`}}function Y({paneId:e,source:t,slugs:n,scores:r,diff:i}){return(0,S.jsx)(a,{children:(0,S.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,S.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:K(t)}),(0,S.jsxs)(`span`,{className:`text-label-default`,style:{color:`var(--content-secondary)`},children:[n.length,` `,n.length===1?`page`:`pages`]})]}),(0,S.jsx)(`ul`,{className:`flex flex-col gap-1`,children:n.map(n=>{let{color:a,marker:o}=J(e,i.get(n)??`only-here`);return(0,S.jsxs)(`li`,{className:`flex items-baseline justify-between gap-3`,children:[(0,S.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,S.jsx)(`span`,{style:{color:a},children:o}),(0,S.jsx)(`code`,{className:`text-body-medium-default`,style:{color:a},children:n})]}),t===`tier2`&&(0,S.jsxs)(`span`,{className:`tabular-nums text-label-default`,style:{color:`var(--content-secondary)`},children:[`EMA `,(r[n]??0).toFixed(3)]})]},n)})})]})})}function X(){return(0,S.jsx)(a,{children:(0,S.jsxs)(`div`,{className:`flex flex-col gap-2 p-4`,children:[(0,S.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:`No pages selected`}),(0,S.jsx)(`span`,{className:`text-label-default`,style:{color:`var(--content-secondary)`},children:`The router returned an empty selection. Try a more specific query, or relax the override values.`})]})})}function Z({rows:e}){return(0,S.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.map(({label:e,value:t})=>(0,S.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,S.jsx)(`span`,{className:`shrink-0 text-label-default`,style:{color:`var(--content-secondary)`},children:e}),(0,S.jsx)(`span`,{className:`text-right text-body-medium-lighter`,style:{color:`var(--content-default)`},children:t})]},e))})}function Q({message:e}){return(0,S.jsx)(`div`,{className:`rounded-md px-4 py-3 text-body-medium-default`,style:{background:`var(--surface-overlay)`,color:`var(--system-negative-strong)`},children:e})}function $({children:e}){return(0,S.jsx)(`div`,{className:`flex h-full w-full items-center justify-center p-8 text-label-default`,style:{color:`var(--content-tertiary)`},children:e})}export{C as MemoryRouterPlaygroundPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{n}from"./chunk-5KNZJZUH-Bsoom5--.js";import{n as r}from"./QueryClientProvider-CMu7CkQU.js";import{t as i}from"./useQuery-Bz-fbQ-m.js";import{t as a}from"./useMutation-CXGTrp4W.js";import{t as o}from"./jsx-runtime-D3ZM-ToX.js";import{t as s}from"./createLucideIcon-CAM1RhH8.js";import{t as c}from"./bell-Ct4a9v6Y.js";import{t as l}from"./check-sC49_hjU.js";import{t as u}from"./menu-CKZtG-s_.js";import{t as d}from"./loader-circle-BzJ2kz3F.js";import{t as f}from"./moon-DSdti3GO.js";import{t as p}from"./triangle-alert--e3n47gm.js";import{t as m}from"./notice-DCp7WO3L.js";import{t as h}from"./popover-BFL-uOLh.js";import{t as g}from"./input-C-GkeWCw.js";import{n as _,t as v}from"./panel-item-DGs4s9r-.js";import{n as y}from"./toast-DR7D7Uma.js";import{d as b}from"./routes-Dwx_Ibh9.js";import{i as x,r as S,t as C}from"./use-platform-gate-DEPyUO3c.js";import{n as w}from"./use-is-mobile-Cx2xnNUx.js";import{Ct as T,St as E,_t as D,bt as O,vt as k,xt as A,yt as j}from"./react-query.gen-BVTEjHsw.js";import{t as M}from"./platform-login-notice-W6sDytqC.js";import{r as N}from"./format-date-CKGQir4m.js";import{t as P}from"./mutation-error-CXV1BKlB.js";var F=s(`bell-off`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),I=s(`check-check`,[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]),L=e(t(),1);function R(e){e.invalidateQueries({queryKey:j()}),e.invalidateQueries({queryKey:T()})}function z(e){return e.snoozed_until?new Date(e.snoozed_until)>new Date:!1}var B=[{label:`1 hour`,hours:1},{label:`4 hours`,hours:4},{label:`24 hours`,hours:24},{label:`1 week`,hours:168}],V=o();function H({notificationId:e,currentlySnoozed:t,children:n}){let i=r(),o=a(E()),s=w(),[c,l]=(0,L.useState)(!1),d=()=>R(i),f=t=>{let n=new Date(new Date().getTime()+t*60*60*1e3).toISOString();o.mutate({path:{id:e},body:{snoozed_until:n}},{onSuccess:d,onError:P(`Failed to snooze notification`)})},p=()=>{o.mutate({path:{id:e},body:{snoozed_until:null}},{onSuccess:d,onError:P(`Failed to clear snooze`)})};return s?(0,V.jsxs)(_.Root,{open:c,onOpenChange:l,children:[(0,V.jsx)(_.Trigger,{asChild:!0,children:n}),(0,V.jsxs)(_.Content,{children:[(0,V.jsx)(_.Header,{children:(0,V.jsx)(_.Title,{children:`Snooze until…`})}),(0,V.jsxs)(_.Body,{children:[B.map(({label:e,hours:t})=>(0,V.jsx)(v,{label:e,onSelect:()=>{o.isPending||(l(!1),f(t))}},e)),t&&(0,V.jsx)(v,{label:`Clear snooze`,onSelect:()=>{o.isPending||(l(!1),p())}})]})]})]}):(0,V.jsxs)(u.Root,{open:c,onOpenChange:l,children:[(0,V.jsx)(u.Trigger,{children:n}),(0,V.jsxs)(u.Content,{align:`start`,className:`min-w-[12rem]`,children:[(0,V.jsx)(u.Label,{children:`Snooze until…`}),B.map(({label:e,hours:t})=>(0,V.jsx)(u.Item,{disabled:o.isPending,onSelect:()=>f(t),children:e},e)),t&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(u.Separator,{}),(0,V.jsx)(u.Item,{disabled:o.isPending,onSelect:()=>p(),children:`Clear snooze`})]})]})]})}function U({existingRules:e,onClose:t,onPauseCreated:n,onPauseDeleted:i,hideTitle:o=!1}){let s=r(),c=a(O()),l=a(A()),[u,f]=(0,L.useState)(``),p=()=>R(s),m=()=>{let e=new Date(new Date().getTime()+365*24*60*60*1e3).toISOString();c.mutate({body:{notification_type:`alert`,dedupe_key_prefix:``,reason:u.trim()||`User requested pause`,expires_at:e}},{onSuccess:e=>{n(e),p(),t()},onError:P(`Failed to pause alerts`)})},h=e=>{l.mutate({path:{rule_id:e}},{onSuccess:()=>{i(e),p(),t()},onError:P(`Failed to resume alerts`)})},_=c.isPending||l.isPending;return(0,V.jsxs)(`div`,{children:[!o&&(0,V.jsx)(`p`,{className:`mb-2 text-body-medium-default text-[var(--content-default)]`,children:`Pause alerts`}),e.length>0?(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`p`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Active pause rules:`}),e.map(e=>(0,V.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-[var(--border-base)] bg-[var(--surface-base)] px-2 py-2`,children:[(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`p`,{className:`truncate text-body-small-default text-[var(--content-default)]`,children:e.reason||`All alerts paused`}),e.expires_at&&(0,V.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:[`Expires `,N(e.expires_at)]})]}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>h(e.id),disabled:_,className:`ml-2 shrink-0 cursor-pointer rounded px-2 py-1 text-body-small-default text-[var(--system-negative-strong)] transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50`,children:`Resume`})]},e.id))]}):(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`p`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Temporarily mute all alert notifications.`}),(0,V.jsx)(g,{type:`text`,value:u,onChange:e=>f(e.target.value),placeholder:`Reason (optional)`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>m(),disabled:_,className:`w-full cursor-pointer rounded-md bg-[var(--primary-base)] px-3 py-1.5 text-body-medium-default text-[var(--content-inset)] transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50`,children:c.isPending?(0,V.jsxs)(`span`,{className:`flex items-center justify-center gap-2`,children:[(0,V.jsx)(d,{className:`h-3 w-3 animate-spin`}),`Pausing…`]}):`Pause all alerts`})]})]})}function W({notification:e,onAck:t,isAcking:n}){let r=e.notification_type===`alert`,i=z(e),a=!e.is_read;return(0,V.jsxs)(`div`,{className:`relative rounded-lg border border-[var(--border-base)] p-4`,style:{background:e.is_resolved?`var(--surface-base)`:`var(--surface-lift)`,opacity:e.is_resolved?.75:1},children:[(0,V.jsx)(`div`,{className:`flex items-start gap-3`,children:(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a&&!e.is_resolved&&(0,V.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 shrink-0 rounded-full bg-[var(--primary-base)]`}),r&&(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[color-mix(in_oklab,var(--system-negative-strong)_14%,transparent)] px-2 py-0.5 text-body-small-default text-[var(--system-negative-strong)]`,children:[(0,V.jsx)(p,{className:`h-3 w-3`}),`Alert`]}),i&&(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--surface-base)] px-2 py-0.5 text-body-small-default text-[var(--content-secondary)]`,children:[(0,V.jsx)(f,{className:`h-3 w-3`}),`Snoozed`]}),e.is_resolved&&(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[color-mix(in_oklab,var(--system-positive-strong)_14%,transparent)] px-2 py-0.5 text-body-small-default text-[var(--system-positive-strong)]`,children:[(0,V.jsx)(l,{className:`h-3 w-3`}),`Resolved`]})]}),(0,V.jsx)(`h3`,{className:`text-body-medium-default leading-tight`,style:{color:e.is_resolved?`var(--content-secondary)`:`var(--content-default)`},children:e.title}),e.body&&(0,V.jsx)(`p`,{className:`text-body-small-default leading-relaxed text-[var(--content-secondary)]`,children:e.body})]})}),(0,V.jsxs)(`div`,{className:`mt-3 flex items-center gap-3 text-body-small-default text-[var(--content-secondary)]`,children:[(0,V.jsxs)(`span`,{children:[`Last seen `,N(e.last_seen_at)]}),e.occurrence_count>1&&(0,V.jsxs)(`span`,{children:[`· `,e.occurrence_count,`× occurrences`]})]}),!e.is_resolved&&(0,V.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t border-[var(--border-base)] pt-3`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:()=>t(e.id,a),disabled:n,className:`flex cursor-pointer items-center gap-1.5 rounded-md px-3 py-1.5 text-body-small-default transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50`,style:{background:a?`var(--primary-base)`:`var(--surface-base)`,color:a?`var(--content-inset)`:`var(--content-secondary)`},children:[n?(0,V.jsx)(d,{className:`h-3 w-3 animate-spin`}):(0,V.jsx)(l,{className:`h-3 w-3`}),a?`Mark as read`:`Mark as unread`]}),(0,V.jsx)(H,{notificationId:e.id,currentlySnoozed:i,children:(0,V.jsxs)(`button`,{type:`button`,className:`flex cursor-pointer items-center gap-1.5 rounded-md border border-[var(--border-base)] bg-[var(--surface-base)] px-3 py-1.5 text-body-small-default text-[var(--content-secondary)] transition-opacity hover:opacity-80`,children:[(0,V.jsx)(f,{className:`h-3 w-3`}),i?`Change snooze`:`Snooze`]})})]})]})}function G(){let e=x({platformHostedOnly:!0}),t=C(),o=S(),s=r(),l=w(),[u,f]=(0,L.useState)(`open`),[p,g]=(0,L.useState)(!1),[v,T]=(0,L.useState)([]),{data:E,isLoading:O,isError:A,refetch:j}=i({...k({query:{status:u}}),enabled:e===`full`&&t}),N=e===`full`&&o||(t?O:!1);(0,L.useEffect)(()=>{!t&&p&&g(!1)},[t,p]);let P=t?A:!1,z=t?E?.results??[]:[],B=z.filter(e=>!e.is_read&&!e.is_resolved),H=a(D()),[G,K]=(0,L.useState)(new Set),[q,J]=(0,L.useState)(!1),Y=(0,L.useCallback)(()=>R(s),[s]),X=async(e,t)=>{K(t=>new Set(t).add(e));try{await H.mutateAsync({path:{id:e},body:{acknowledged:t}}),Y()}catch(e){y.error(e instanceof Error?e.message:`Failed to update notification`)}finally{K(t=>{let n=new Set(t);return n.delete(e),n})}},Z=async()=>{if(!(B.length===0||q)){J(!0);try{await Promise.allSettled(B.map(e=>H.mutateAsync({path:{id:e.id},body:{acknowledged:!0}})))}finally{Y(),J(!1)}}},Q=(0,V.jsxs)(`button`,{type:`button`,className:`flex cursor-pointer items-center gap-1.5 rounded-md border border-[var(--border-base)] bg-[var(--surface-base)] px-3 py-1.5 text-body-small-default text-[var(--content-secondary)] transition-opacity hover:opacity-80`,title:`Pause alerts`,children:[(0,V.jsx)(F,{className:`h-3.5 w-3.5`}),`Pause alerts`]}),$=(0,V.jsx)(U,{existingRules:v,onClose:()=>g(!1),onPauseCreated:e=>T(t=>[...t,e]),onPauseDeleted:e=>T(t=>t.filter(t=>t.id!==e))});return e===`gated`?(0,V.jsx)(n,{replace:!0,to:b.settings.general}):e===`disabled`?(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(c,{className:`h-5 w-5 text-[var(--content-secondary)]`}),(0,V.jsxs)(`div`,{className:`flex-1`,children:[(0,V.jsx)(`h2`,{className:`text-title-medium text-[var(--content-default)]`,children:`Notifications`}),(0,V.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:`Platform alerts and status notifications`})]})]}),(0,V.jsx)(M,{children:`Log in to the Vellum platform to view notifications.`})]}):(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(c,{className:`h-5 w-5 text-[var(--content-secondary)]`}),(0,V.jsxs)(`div`,{className:`flex-1`,children:[(0,V.jsx)(`h2`,{className:`text-title-medium text-[var(--content-default)]`,children:`Notifications`}),(0,V.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:`Platform alerts and status notifications`})]}),t&&(l?(0,V.jsxs)(_.Root,{open:p,onOpenChange:g,children:[(0,V.jsx)(_.Trigger,{asChild:!0,children:Q}),(0,V.jsxs)(_.Content,{children:[(0,V.jsx)(_.Header,{children:(0,V.jsx)(_.Title,{children:`Pause alerts`})}),(0,V.jsx)(_.Body,{children:(0,V.jsx)(U,{existingRules:v,onClose:()=>g(!1),onPauseCreated:e=>T(t=>[...t,e]),onPauseDeleted:e=>T(t=>t.filter(t=>t.id!==e)),hideTitle:!0})})]})]}):(0,V.jsxs)(h.Root,{open:p,onOpenChange:g,children:[(0,V.jsx)(h.Trigger,{asChild:!0,children:Q}),(0,V.jsx)(h.Content,{align:`end`,className:`w-72`,children:$})]}))]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`div`,{className:`flex gap-1 rounded-md border border-[var(--border-base)] bg-[var(--surface-base)] p-1`,children:[`open`,`resolved`].map(e=>{let t=u===e;return(0,V.jsx)(`button`,{type:`button`,onClick:()=>f(e),className:`cursor-pointer rounded px-3 py-1 text-body-small-default capitalize transition-colors`,style:{background:t?`var(--surface-lift)`:`transparent`,color:t?`var(--content-default)`:`var(--content-secondary)`,boxShadow:t?`0 1px 2px rgba(0,0,0,0.08)`:void 0},children:e},e)})}),u===`open`&&B.length>1&&(0,V.jsxs)(`button`,{type:`button`,onClick:()=>void Z(),disabled:q,className:`ml-auto flex cursor-pointer items-center gap-1.5 rounded-md border border-[var(--border-base)] bg-transparent px-3 py-1.5 text-body-small-default text-[var(--content-secondary)] transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50`,children:[q?(0,V.jsx)(d,{className:`h-3 w-3 animate-spin`}):(0,V.jsx)(I,{className:`h-3 w-3`}),`Mark all as read (`,B.length,`)`]})]}),N?(0,V.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,V.jsx)(d,{className:`h-4 w-4 animate-spin`}),`Loading notifications…`]}):P?(0,V.jsxs)(m,{tone:`error`,children:[`Failed to load notifications.`,` `,(0,V.jsx)(`button`,{type:`button`,onClick:()=>void j(),className:`cursor-pointer underline hover:no-underline`,children:`Retry`})]}):z.length===0?(0,V.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 py-12 text-center`,children:[(0,V.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--surface-base)]`,children:(0,V.jsx)(c,{className:`h-5 w-5 text-[var(--content-secondary)]`})}),(0,V.jsxs)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:[`No `,u,` notifications`]}),(0,V.jsx)(`p`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:u===`open`?`You're all caught up!`:`Nothing to show here.`})]}):(0,V.jsx)(`div`,{className:`space-y-3`,children:z.map(e=>(0,V.jsx)(W,{notification:e,onAck:(e,t)=>void X(e,t),isAcking:G.has(e.id)},e.id))})]})}export{G as NotificationsPage};
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{n}from"./chunk-5KNZJZUH-Bsoom5--.js";import{n as r}from"./QueryClientProvider-CMu7CkQU.js";import{t as i}from"./useQuery-Bz-fbQ-m.js";import{t as a}from"./useMutation-CXGTrp4W.js";import{t as o}from"./jsx-runtime-D3ZM-ToX.js";import{t as s}from"./createLucideIcon-CAM1RhH8.js";import{t as c}from"./bell-Ct4a9v6Y.js";import{t as l}from"./check-sC49_hjU.js";import{t as u}from"./menu-CKZtG-s_.js";import{t as d}from"./loader-circle-BzJ2kz3F.js";import{t as f}from"./moon-DSdti3GO.js";import{t as p}from"./triangle-alert--e3n47gm.js";import{t as m}from"./notice-DCp7WO3L.js";import{t as h}from"./popover-BFL-uOLh.js";import{t as g}from"./input-C-GkeWCw.js";import{n as _,t as v}from"./panel-item-DGs4s9r-.js";import{n as y}from"./toast-DR7D7Uma.js";import{d as b}from"./routes-Dwx_Ibh9.js";import{i as x,r as S,t as C}from"./use-platform-gate-Oc-w11de.js";import{n as w}from"./use-is-mobile-Cx2xnNUx.js";import{Ct as T,St as E,_t as D,bt as O,vt as k,xt as A,yt as j}from"./react-query.gen-BGUTzcTG.js";import{t as M}from"./platform-login-notice-D3MegklO.js";import{r as N}from"./format-date-CKGQir4m.js";import{t as P}from"./mutation-error-CXV1BKlB.js";var F=s(`bell-off`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),I=s(`check-check`,[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]),L=e(t(),1);function R(e){e.invalidateQueries({queryKey:j()}),e.invalidateQueries({queryKey:T()})}function z(e){return e.snoozed_until?new Date(e.snoozed_until)>new Date:!1}var B=[{label:`1 hour`,hours:1},{label:`4 hours`,hours:4},{label:`24 hours`,hours:24},{label:`1 week`,hours:168}],V=o();function H({notificationId:e,currentlySnoozed:t,children:n}){let i=r(),o=a(E()),s=w(),[c,l]=(0,L.useState)(!1),d=()=>R(i),f=t=>{let n=new Date(new Date().getTime()+t*60*60*1e3).toISOString();o.mutate({path:{id:e},body:{snoozed_until:n}},{onSuccess:d,onError:P(`Failed to snooze notification`)})},p=()=>{o.mutate({path:{id:e},body:{snoozed_until:null}},{onSuccess:d,onError:P(`Failed to clear snooze`)})};return s?(0,V.jsxs)(_.Root,{open:c,onOpenChange:l,children:[(0,V.jsx)(_.Trigger,{asChild:!0,children:n}),(0,V.jsxs)(_.Content,{children:[(0,V.jsx)(_.Header,{children:(0,V.jsx)(_.Title,{children:`Snooze until…`})}),(0,V.jsxs)(_.Body,{children:[B.map(({label:e,hours:t})=>(0,V.jsx)(v,{label:e,onSelect:()=>{o.isPending||(l(!1),f(t))}},e)),t&&(0,V.jsx)(v,{label:`Clear snooze`,onSelect:()=>{o.isPending||(l(!1),p())}})]})]})]}):(0,V.jsxs)(u.Root,{open:c,onOpenChange:l,children:[(0,V.jsx)(u.Trigger,{children:n}),(0,V.jsxs)(u.Content,{align:`start`,className:`min-w-[12rem]`,children:[(0,V.jsx)(u.Label,{children:`Snooze until…`}),B.map(({label:e,hours:t})=>(0,V.jsx)(u.Item,{disabled:o.isPending,onSelect:()=>f(t),children:e},e)),t&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(u.Separator,{}),(0,V.jsx)(u.Item,{disabled:o.isPending,onSelect:()=>p(),children:`Clear snooze`})]})]})]})}function U({existingRules:e,onClose:t,onPauseCreated:n,onPauseDeleted:i,hideTitle:o=!1}){let s=r(),c=a(O()),l=a(A()),[u,f]=(0,L.useState)(``),p=()=>R(s),m=()=>{let e=new Date(new Date().getTime()+365*24*60*60*1e3).toISOString();c.mutate({body:{notification_type:`alert`,dedupe_key_prefix:``,reason:u.trim()||`User requested pause`,expires_at:e}},{onSuccess:e=>{n(e),p(),t()},onError:P(`Failed to pause alerts`)})},h=e=>{l.mutate({path:{rule_id:e}},{onSuccess:()=>{i(e),p(),t()},onError:P(`Failed to resume alerts`)})},_=c.isPending||l.isPending;return(0,V.jsxs)(`div`,{children:[!o&&(0,V.jsx)(`p`,{className:`mb-2 text-body-medium-default text-[var(--content-default)]`,children:`Pause alerts`}),e.length>0?(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`p`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Active pause rules:`}),e.map(e=>(0,V.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-[var(--border-base)] bg-[var(--surface-base)] px-2 py-2`,children:[(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`p`,{className:`truncate text-body-small-default text-[var(--content-default)]`,children:e.reason||`All alerts paused`}),e.expires_at&&(0,V.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:[`Expires `,N(e.expires_at)]})]}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>h(e.id),disabled:_,className:`ml-2 shrink-0 cursor-pointer rounded px-2 py-1 text-body-small-default text-[var(--system-negative-strong)] transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50`,children:`Resume`})]},e.id))]}):(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`p`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Temporarily mute all alert notifications.`}),(0,V.jsx)(g,{type:`text`,value:u,onChange:e=>f(e.target.value),placeholder:`Reason (optional)`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>m(),disabled:_,className:`w-full cursor-pointer rounded-md bg-[var(--primary-base)] px-3 py-1.5 text-body-medium-default text-[var(--content-inset)] transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50`,children:c.isPending?(0,V.jsxs)(`span`,{className:`flex items-center justify-center gap-2`,children:[(0,V.jsx)(d,{className:`h-3 w-3 animate-spin`}),`Pausing…`]}):`Pause all alerts`})]})]})}function W({notification:e,onAck:t,isAcking:n}){let r=e.notification_type===`alert`,i=z(e),a=!e.is_read;return(0,V.jsxs)(`div`,{className:`relative rounded-lg border border-[var(--border-base)] p-4`,style:{background:e.is_resolved?`var(--surface-base)`:`var(--surface-lift)`,opacity:e.is_resolved?.75:1},children:[(0,V.jsx)(`div`,{className:`flex items-start gap-3`,children:(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a&&!e.is_resolved&&(0,V.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 shrink-0 rounded-full bg-[var(--primary-base)]`}),r&&(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[color-mix(in_oklab,var(--system-negative-strong)_14%,transparent)] px-2 py-0.5 text-body-small-default text-[var(--system-negative-strong)]`,children:[(0,V.jsx)(p,{className:`h-3 w-3`}),`Alert`]}),i&&(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--surface-base)] px-2 py-0.5 text-body-small-default text-[var(--content-secondary)]`,children:[(0,V.jsx)(f,{className:`h-3 w-3`}),`Snoozed`]}),e.is_resolved&&(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[color-mix(in_oklab,var(--system-positive-strong)_14%,transparent)] px-2 py-0.5 text-body-small-default text-[var(--system-positive-strong)]`,children:[(0,V.jsx)(l,{className:`h-3 w-3`}),`Resolved`]})]}),(0,V.jsx)(`h3`,{className:`text-body-medium-default leading-tight`,style:{color:e.is_resolved?`var(--content-secondary)`:`var(--content-default)`},children:e.title}),e.body&&(0,V.jsx)(`p`,{className:`text-body-small-default leading-relaxed text-[var(--content-secondary)]`,children:e.body})]})}),(0,V.jsxs)(`div`,{className:`mt-3 flex items-center gap-3 text-body-small-default text-[var(--content-secondary)]`,children:[(0,V.jsxs)(`span`,{children:[`Last seen `,N(e.last_seen_at)]}),e.occurrence_count>1&&(0,V.jsxs)(`span`,{children:[`· `,e.occurrence_count,`× occurrences`]})]}),!e.is_resolved&&(0,V.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t border-[var(--border-base)] pt-3`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:()=>t(e.id,a),disabled:n,className:`flex cursor-pointer items-center gap-1.5 rounded-md px-3 py-1.5 text-body-small-default transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50`,style:{background:a?`var(--primary-base)`:`var(--surface-base)`,color:a?`var(--content-inset)`:`var(--content-secondary)`},children:[n?(0,V.jsx)(d,{className:`h-3 w-3 animate-spin`}):(0,V.jsx)(l,{className:`h-3 w-3`}),a?`Mark as read`:`Mark as unread`]}),(0,V.jsx)(H,{notificationId:e.id,currentlySnoozed:i,children:(0,V.jsxs)(`button`,{type:`button`,className:`flex cursor-pointer items-center gap-1.5 rounded-md border border-[var(--border-base)] bg-[var(--surface-base)] px-3 py-1.5 text-body-small-default text-[var(--content-secondary)] transition-opacity hover:opacity-80`,children:[(0,V.jsx)(f,{className:`h-3 w-3`}),i?`Change snooze`:`Snooze`]})})]})]})}function G(){let e=x({platformHostedOnly:!0}),t=C(),o=S(),s=r(),l=w(),[u,f]=(0,L.useState)(`open`),[p,g]=(0,L.useState)(!1),[v,T]=(0,L.useState)([]),{data:E,isLoading:O,isError:A,refetch:j}=i({...k({query:{status:u}}),enabled:e===`full`&&t}),N=e===`full`&&o||(t?O:!1);(0,L.useEffect)(()=>{!t&&p&&g(!1)},[t,p]);let P=t?A:!1,z=t?E?.results??[]:[],B=z.filter(e=>!e.is_read&&!e.is_resolved),H=a(D()),[G,K]=(0,L.useState)(new Set),[q,J]=(0,L.useState)(!1),Y=(0,L.useCallback)(()=>R(s),[s]),X=async(e,t)=>{K(t=>new Set(t).add(e));try{await H.mutateAsync({path:{id:e},body:{acknowledged:t}}),Y()}catch(e){y.error(e instanceof Error?e.message:`Failed to update notification`)}finally{K(t=>{let n=new Set(t);return n.delete(e),n})}},Z=async()=>{if(!(B.length===0||q)){J(!0);try{await Promise.allSettled(B.map(e=>H.mutateAsync({path:{id:e.id},body:{acknowledged:!0}})))}finally{Y(),J(!1)}}},Q=(0,V.jsxs)(`button`,{type:`button`,className:`flex cursor-pointer items-center gap-1.5 rounded-md border border-[var(--border-base)] bg-[var(--surface-base)] px-3 py-1.5 text-body-small-default text-[var(--content-secondary)] transition-opacity hover:opacity-80`,title:`Pause alerts`,children:[(0,V.jsx)(F,{className:`h-3.5 w-3.5`}),`Pause alerts`]}),$=(0,V.jsx)(U,{existingRules:v,onClose:()=>g(!1),onPauseCreated:e=>T(t=>[...t,e]),onPauseDeleted:e=>T(t=>t.filter(t=>t.id!==e))});return e===`gated`?(0,V.jsx)(n,{replace:!0,to:b.settings.general}):e===`disabled`?(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(c,{className:`h-5 w-5 text-[var(--content-secondary)]`}),(0,V.jsxs)(`div`,{className:`flex-1`,children:[(0,V.jsx)(`h2`,{className:`text-title-medium text-[var(--content-default)]`,children:`Notifications`}),(0,V.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:`Platform alerts and status notifications`})]})]}),(0,V.jsx)(M,{children:`Log in to the Vellum platform to view notifications.`})]}):(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(c,{className:`h-5 w-5 text-[var(--content-secondary)]`}),(0,V.jsxs)(`div`,{className:`flex-1`,children:[(0,V.jsx)(`h2`,{className:`text-title-medium text-[var(--content-default)]`,children:`Notifications`}),(0,V.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:`Platform alerts and status notifications`})]}),t&&(l?(0,V.jsxs)(_.Root,{open:p,onOpenChange:g,children:[(0,V.jsx)(_.Trigger,{asChild:!0,children:Q}),(0,V.jsxs)(_.Content,{children:[(0,V.jsx)(_.Header,{children:(0,V.jsx)(_.Title,{children:`Pause alerts`})}),(0,V.jsx)(_.Body,{children:(0,V.jsx)(U,{existingRules:v,onClose:()=>g(!1),onPauseCreated:e=>T(t=>[...t,e]),onPauseDeleted:e=>T(t=>t.filter(t=>t.id!==e)),hideTitle:!0})})]})]}):(0,V.jsxs)(h.Root,{open:p,onOpenChange:g,children:[(0,V.jsx)(h.Trigger,{asChild:!0,children:Q}),(0,V.jsx)(h.Content,{align:`end`,className:`w-72`,children:$})]}))]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`div`,{className:`flex gap-1 rounded-md border border-[var(--border-base)] bg-[var(--surface-base)] p-1`,children:[`open`,`resolved`].map(e=>{let t=u===e;return(0,V.jsx)(`button`,{type:`button`,onClick:()=>f(e),className:`cursor-pointer rounded px-3 py-1 text-body-small-default capitalize transition-colors`,style:{background:t?`var(--surface-lift)`:`transparent`,color:t?`var(--content-default)`:`var(--content-secondary)`,boxShadow:t?`0 1px 2px rgba(0,0,0,0.08)`:void 0},children:e},e)})}),u===`open`&&B.length>1&&(0,V.jsxs)(`button`,{type:`button`,onClick:()=>void Z(),disabled:q,className:`ml-auto flex cursor-pointer items-center gap-1.5 rounded-md border border-[var(--border-base)] bg-transparent px-3 py-1.5 text-body-small-default text-[var(--content-secondary)] transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50`,children:[q?(0,V.jsx)(d,{className:`h-3 w-3 animate-spin`}):(0,V.jsx)(I,{className:`h-3 w-3`}),`Mark all as read (`,B.length,`)`]})]}),N?(0,V.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,V.jsx)(d,{className:`h-4 w-4 animate-spin`}),`Loading notifications…`]}):P?(0,V.jsxs)(m,{tone:`error`,children:[`Failed to load notifications.`,` `,(0,V.jsx)(`button`,{type:`button`,onClick:()=>void j(),className:`cursor-pointer underline hover:no-underline`,children:`Retry`})]}):z.length===0?(0,V.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 py-12 text-center`,children:[(0,V.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--surface-base)]`,children:(0,V.jsx)(c,{className:`h-5 w-5 text-[var(--content-secondary)]`})}),(0,V.jsxs)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:[`No `,u,` notifications`]}),(0,V.jsx)(`p`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:u===`open`?`You're all caught up!`:`Nothing to show here.`})]}):(0,V.jsx)(`div`,{className:`space-y-3`,children:z.map(e=>(0,V.jsx)(W,{notification:e,onAck:(e,t)=>void X(e,t),isAcking:G.has(e.id)},e.id))})]})}export{G as NotificationsPage};
|