@vellumai/web 0.10.11-dev.202607231048.3e678da → 0.10.11-dev.202607231240.e03ec0b
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/{account-page-CaVPw_ZY.js → account-page-4OPGIzD3.js} +1 -1
- package/dist/assets/{acp-run-detail-panel-WGU3w40T.js → acp-run-detail-panel-DpA07WFv.js} +1 -1
- package/dist/assets/{activity-steps-panel-o4iDlbug.js → activity-steps-panel-Eiuv4mEX.js} +1 -1
- package/dist/assets/{ai-page-DWWBCvFh.js → ai-page-Ilh8oEBA.js} +1 -1
- package/dist/assets/{api-key-screen-Djm6rB0F.js → api-key-screen-C4-neX_1.js} +1 -1
- package/dist/assets/{assistant-feature-flag-store-kjj-A-rI.js → assistant-feature-flag-store-BV_nEYvU.js} +1 -1
- package/dist/assets/{assistant-status-panel-BwLJwtUy.js → assistant-status-panel-BTxCCenj.js} +1 -1
- package/dist/assets/{background-task-detail-panel-CHMWbjSP.js → background-task-detail-panel-C0ShhKn8.js} +1 -1
- package/dist/assets/{billing-page-BS4Ii96C.js → billing-page-J_cHaFA6.js} +1 -1
- package/dist/assets/{bookmarks-page-B7Nk1BsT.js → bookmarks-page-DyHvBhzu.js} +1 -1
- package/dist/assets/{channels-page-route-CmhwUukG.js → channels-page-route-CU-NT-sp.js} +1 -1
- package/dist/assets/{client-feature-flag-store-CXA4D_4L.js → client-feature-flag-store-ebKDvCeO.js} +1 -1
- package/dist/assets/{command-palette-Do7hDLIZ.js → command-palette-BNsQkO0X.js} +1 -1
- package/dist/assets/{command-palette-window-page-CIIzFGkL.js → command-palette-window-page-BsWQwXLR.js} +1 -1
- package/dist/assets/{community-page-uq3th5f7.js → community-page-BVnxLfgR.js} +1 -1
- package/dist/assets/{contacts-page-route-BzU6AkNP.js → contacts-page-route-F-zr1zVR.js} +1 -1
- package/dist/assets/{credentials-page-BQ8l0lnH.js → credentials-page-C9cmfrBo.js} +1 -1
- package/dist/assets/{debug-page-DyC5kiKX.js → debug-page-DwzL-9GZ.js} +1 -1
- package/dist/assets/{deploy-dialogs-BQlUas2l.js → deploy-dialogs-D6o8RDRh.js} +1 -1
- package/dist/assets/{developer-page-DRvBOgmA.js → developer-page-CIBxe5bO.js} +1 -1
- package/dist/assets/{dictation-overlay-page-fZ6fAe29.js → dictation-overlay-page-BZQ1IiWW.js} +1 -1
- package/dist/assets/{document-viewer-page-Doxv5lPI.js → document-viewer-page-8cZSV3s1.js} +1 -1
- package/dist/assets/{emails-page-DxLG3W-x.js → emails-page-DZUaMVqR.js} +1 -1
- package/dist/assets/feature-flag-catalog-Bkr5vS-F.js +1 -0
- package/dist/assets/{general-page-mkiD21xw.js → general-page-DcPJAAiz.js} +1 -1
- package/dist/assets/{hatching-screen-29zSzCw0.js → hatching-screen-oBes6VQG.js} +1 -1
- package/dist/assets/{home-page-route-CA3__3Jv.js → home-page-route-BFOTKfyB.js} +1 -1
- package/dist/assets/{hosting-screen-BH-ZgzFd.js → hosting-screen-BlHWMQ5l.js} +1 -1
- package/dist/assets/{identity-page-route-DhYn3-uP.js → identity-page-route-Da3XAZFT.js} +1 -1
- package/dist/assets/{index-DNzT2JAI.js → index-DA-27U7J.js} +16 -16
- package/dist/assets/{inspect-page-BpQAAdyf.js → inspect-page-D4RBNe7y.js} +1 -1
- package/dist/assets/{integrations-page-h8bA-2cW.js → integrations-page-CtorNovo.js} +1 -1
- package/dist/assets/{intelligence-layout-2rspCRxw.js → intelligence-layout-C5caw6j5.js} +1 -1
- package/dist/assets/{library-detail-page-DkSotDJF.js → library-detail-page-BYC0dQ9v.js} +1 -1
- package/dist/assets/{library-page-DKGJ2LN8.js → library-page-BXyq_gmm.js} +1 -1
- package/dist/assets/{logout-page-DBDJq6Wv.js → logout-page-D_X1y-aM.js} +1 -1
- package/dist/assets/{logs-layout-CS4wdncb.js → logs-layout-D-XkuO-J.js} +1 -1
- package/dist/assets/{memory-page-route-CPfpdLTf.js → memory-page-route-DyJRk3Ol.js} +1 -1
- package/dist/assets/{memory-router-playground-page-B28UzCex.js → memory-router-playground-page-Bwqn_yOk.js} +1 -1
- package/dist/assets/{mobile-sidebar-drawer-DA_KHGz5.js → mobile-sidebar-drawer-vBwxPgat.js} +1 -1
- package/dist/assets/{notifications-page-CUcwb2rE.js → notifications-page-D4Why7e5.js} +1 -1
- package/dist/assets/{oauth-complete-page-BaPz-Z4e.js → oauth-complete-page-8lBwq15D.js} +1 -1
- package/dist/assets/{oauth-popup-complete-page-x4xxUtH4.js → oauth-popup-complete-page-B3v-dJhq.js} +1 -1
- package/dist/assets/{pairing-page-DYpNQE8J.js → pairing-page-B5chxtcv.js} +1 -1
- package/dist/assets/{personality-page-Dk1KQq9C.js → personality-page-BJulFBDf.js} +1 -1
- package/dist/assets/{plans-page-CwZksLLG.js → plans-page-BXtSJKgK.js} +1 -1
- package/dist/assets/{plugin-detail-page-DLCBJ4TA.js → plugin-detail-page-9HIVa5Vm.js} +1 -1
- package/dist/assets/{privacy-page-D05m0wxB.js → privacy-page-C9rqm2o3.js} +1 -1
- package/dist/assets/{privacy-screen-Dk6h9Mu0.js → privacy-screen-KR-ZQCyT.js} +1 -1
- package/dist/assets/{provider-callback-page-pF9JWwYO.js → provider-callback-page-CCreci4A.js} +1 -1
- package/dist/assets/{quick-input-page-BrhZESQE.js → quick-input-page-DuL3u9Zx.js} +1 -1
- package/dist/assets/{research-mock-page-C1lnqOde.js → research-mock-page-D6WX-cSW.js} +1 -1
- package/dist/assets/{research-onboarding-route-BpbUArd8.js → research-onboarding-route-B5No6fJE.js} +1 -1
- package/dist/assets/{review-terms-screen-C27zsRXU.js → review-terms-screen-BydxdOY-.js} +1 -1
- package/dist/assets/{schedules-page-tbwftKR6.js → schedules-page-DHC4G3MB.js} +1 -1
- package/dist/assets/{select-assistant-screen-Dj3Ujuer.js → select-assistant-screen-D8tbxVLQ.js} +1 -1
- package/dist/assets/{settings-layout-Dy1w18rE.js → settings-layout-rKajYl2h.js} +1 -1
- package/dist/assets/{share-feedback-modal-DOsLZ_d3.js → share-feedback-modal-CdzAko5b.js} +1 -1
- package/dist/assets/{sidebar-tree-B3YVYp4t.js → sidebar-tree-FO-frXVZ.js} +1 -1
- package/dist/assets/{signup-page-DvQ21R-o.js → signup-page-CgumoZWg.js} +1 -1
- package/dist/assets/{skill-detail-page-RXTQ6AhD.js → skill-detail-page-BSBVJgLg.js} +1 -1
- package/dist/assets/{skill-detail-panel-Cn127GSw.js → skill-detail-panel-BgWGaTm5.js} +1 -1
- package/dist/assets/{sounds-page-CynJ60rk.js → sounds-page-DMXMPZE6.js} +1 -1
- package/dist/assets/{start-screen-DyQf430P.js → start-screen-d-gvSaGT.js} +1 -1
- package/dist/assets/{subagent-detail-panel-1QGgAHDN.js → subagent-detail-panel-BXTIqhMk.js} +1 -1
- package/dist/assets/{superpowers-page-DhaoawyT.js → superpowers-page-C6A1Vq8D.js} +1 -1
- package/dist/assets/{system-events-page-BHqaBWg3.js → system-events-page-BSoTGIUe.js} +1 -1
- package/dist/assets/{theme-stage-page-CwPl2xCt.js → theme-stage-page-BhHJYDBU.js} +1 -1
- package/dist/assets/{tiptap-document-editor-CUts_LLj.js → tiptap-document-editor-Z5gChK2b.js} +1 -1
- package/dist/assets/{tool-detail-panel-CJeJzNGJ.js → tool-detail-panel-3ertbTbW.js} +1 -1
- package/dist/assets/{upgrade-cancel-page-BdQDGdqF.js → upgrade-cancel-page-CyhuTbkj.js} +1 -1
- package/dist/assets/{upgrade-success-page-Wadj1X5l.js → upgrade-success-page-BHfLu0ex.js} +1 -1
- package/dist/assets/{use-assistant-identity-details-B956VZBl.js → use-assistant-identity-details-BvTE3c_d.js} +1 -1
- package/dist/assets/{use-checkout-dismiss-refresh-B3tC9K0S.js → use-checkout-dismiss-refresh-B3XiCNx4.js} +1 -1
- package/dist/assets/{use-edge-swipe-back-DymF-HMi.js → use-edge-swipe-back-24qRhD5r.js} +1 -1
- package/dist/assets/{use-invite-link-dialog-DVk1QIJe.js → use-invite-link-dialog-t9tfAo4w.js} +1 -1
- package/dist/assets/{use-skill-actions-Bf-J1toG.js → use-skill-actions-BuaWaFN2.js} +1 -1
- package/dist/assets/{use-skill-detail-files-DPunvq6L.js → use-skill-detail-files-Sd7BIZjr.js} +1 -1
- package/dist/assets/{voice-page-sp9rajnZ.js → voice-page-DW1aQd2C.js} +1 -1
- package/dist/assets/{weather-forecast-display-DjRIDek3.js → weather-forecast-display-KE1aZQ9y.js} +1 -1
- package/dist/assets/{welcome-screen-B_XcInRq.js → welcome-screen-DXo7RlC9.js} +1 -1
- package/dist/assets/{workflow-detail-panel-DTsegHVj.js → workflow-detail-panel-Dmp1BJGa.js} +1 -1
- package/dist/assets/{workspace-page-Ch3527IW.js → workspace-page-CpRX-Yir.js} +1 -1
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/dist/assets/feature-flag-catalog-DiGeRi3c.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import{a as i,n as a,s as o}from"./auth-store-De2L1iVx.js";import{f as s}from"./native-biometric-CEVNJbma.js";import{u as c}from"./routes-DN3K5OaW.js";import{n as l,t as u}from"./login-flow-D3EZFl_S.js";import{pi as d}from"./index-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import{a as i,n as a,s as o}from"./auth-store-De2L1iVx.js";import{f as s}from"./native-biometric-CEVNJbma.js";import{u as c}from"./routes-DN3K5OaW.js";import{n as l,t as u}from"./login-flow-D3EZFl_S.js";import{pi as d}from"./index-DA-27U7J.js";import{r as f,t as p}from"./account-shell-CRIf1eWb.js";var m=e(t(),1),h=r();function g(){let e=i(),t=o(),r=a.use.user(),g=a.use.logout(),[_,v]=(0,m.useState)(null),[y,b]=(0,m.useState)(!1),x=async()=>{v(null),b(!0);try{await s(l,u)}catch(e){console.error(`[account] auth flow failed:`,e),v(`Something went wrong. Please try again.`),b(!1)}};return t?(0,h.jsx)(p,{children:(0,h.jsx)(f,{title:`Loading...`})}):e?(0,h.jsxs)(p,{children:[(0,h.jsx)(f,{title:`Welcome${r?.username?`, ${r.username}`:``}!`,subtitle:`You are signed in.`}),(0,h.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,h.jsx)(n,{to:c.assistant,className:`inline-flex w-full items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-[var(--content-inset)] no-underline transition-colors hover:bg-[var(--primary-hover)]`,children:`Go to your assistant`}),(0,h.jsx)(`button`,{type:`button`,onClick:async()=>{await g(),d(c.account.login)},className:`cursor-pointer bg-transparent text-sm font-normal text-[var(--content-secondary)] transition-colors hover:text-[var(--content-default)]`,children:`Sign out`})]})]}):(0,h.jsxs)(p,{children:[(0,h.jsx)(f,{title:`Welcome to Vellum`,subtitle:`Sign in to get started.`}),_&&(0,h.jsx)(`p`,{className:`text-center text-sm text-[var(--system-negative-strong)]`,children:_}),(0,h.jsx)(`div`,{className:`flex flex-col items-center gap-4`,children:(0,h.jsx)(`button`,{type:`button`,onClick:()=>void x(),disabled:y,className:`inline-flex w-full cursor-pointer items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-[var(--content-inset)] transition-colors hover:bg-[var(--primary-hover)] disabled:opacity-50`,children:`Sign in`})})]})}export{g as AccountPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-EqyiBCqE.js";import{t as n}from"./react-DJZBPgpf.js";import{t as r}from"./button-BxZ6HzpA.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{t as a}from"./typography-B_Zom8Gj.js";import{t as o}from"./createLucideIcon-IRfcSUxS.js";import{t as s}from"./arrow-left-8m8Hdw7f.js";import{t as c}from"./brain-BDL_F8de.js";import{t as l}from"./chevron-down-qD-re7AW.js";import{r as u}from"./panel-item-BdWXckRy.js";import{t as d}from"./circle-check-D3NSGpeC.js";import{w as f}from"./menu-B-5JB1WS.js";import{t as p}from"./code-Czx7d7SK.js";import{t as m}from"./file-text-CxRYK_Ja.js";import{t as h}from"./globe-DWcyIkcn.js";import{t as g}from"./repeat-D_3ouUDK.js";import{t as _}from"./square-BaqnLb-n.js";import{t as v}from"./triangle-alert-BAgktlRD.js";import{t as y}from"./x-x6asKwaA.js";import"./src-ChvLuWxs.js";import{t as b}from"./tag-D4RWxz2r.js";import{t as x}from"./chat-markdown-message-Dc8j-__5.js";import{t as S}from"./three-dot-indicator-B7ma4dAk.js";import{At as C,Mt as w,Sa as ee,_o as te,_t as ne,gt as re,jt as ie,kt as T,ma as E,pa as ae,uo as oe,vt as D,xa as se,za as ce}from"./index-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-EqyiBCqE.js";import{t as n}from"./react-DJZBPgpf.js";import{t as r}from"./button-BxZ6HzpA.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{t as a}from"./typography-B_Zom8Gj.js";import{t as o}from"./createLucideIcon-IRfcSUxS.js";import{t as s}from"./arrow-left-8m8Hdw7f.js";import{t as c}from"./brain-BDL_F8de.js";import{t as l}from"./chevron-down-qD-re7AW.js";import{r as u}from"./panel-item-BdWXckRy.js";import{t as d}from"./circle-check-D3NSGpeC.js";import{w as f}from"./menu-B-5JB1WS.js";import{t as p}from"./code-Czx7d7SK.js";import{t as m}from"./file-text-CxRYK_Ja.js";import{t as h}from"./globe-DWcyIkcn.js";import{t as g}from"./repeat-D_3ouUDK.js";import{t as _}from"./square-BaqnLb-n.js";import{t as v}from"./triangle-alert-BAgktlRD.js";import{t as y}from"./x-x6asKwaA.js";import"./src-ChvLuWxs.js";import{t as b}from"./tag-D4RWxz2r.js";import{t as x}from"./chat-markdown-message-Dc8j-__5.js";import{t as S}from"./three-dot-indicator-B7ma4dAk.js";import{At as C,Mt as w,Sa as ee,_o as te,_t as ne,gt as re,jt as ie,kt as T,ma as E,pa as ae,uo as oe,vt as D,xa as se,za as ce}from"./index-DA-27U7J.js";import{t as le}from"./status-badge-pill-DQHLgr0r.js";var ue=o(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),de=o(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),O=e(n(),1),k=``;function A(e,t){switch(e){case`complete`:case`completed`:return`completed`;case`failed`:case`error`:return`error`;case void 0:return t;default:return`running`}}function fe(e){return(e.messageId?.startsWith(`local-marker-`)??!1)||(e.content?.startsWith(`↻ Steering: `)??!1)}function j(e){let t=e??``;return t.startsWith(`↻ Steering: `)?t.slice(T.length):t}function M(e){let t=e[e.length-1];t&&(t.kind===`agent`||t.kind===`thinking`)&&!t.isComplete&&(e[e.length-1]={...t,isComplete:!0})}function N(e,t){if(t.updateType===`agent_message_chunk`&&fe(t)){M(e),e.push({kind:`user`,id:t.messageId??`steer-${e.length}`,content:j(t.content)});return}switch(t.updateType){case`user_message_chunk`:{let n=t.messageId??k,r=j(t.content),i=e[e.length-1];i&&i.kind===`user`&&i.id===n?e[e.length-1]={...i,content:i.content+r}:(M(e),e.push({kind:`user`,id:n,content:r}));let a=e[e.length-1].content;for(let t=0;t<e.length-1;t++){let n=e[t];if(n.kind===`user`&&n.id.startsWith(`local-marker-`)&&n.content===a){e.splice(t,1);break}}return}case`agent_message_chunk`:{let n=t.messageId??k,r=e[e.length-1];if(r&&r.kind===`agent`&&r.messageId===n){e[e.length-1]={...r,content:r.content+(t.content??``)};return}if(n!==k&&r&&r.kind===`agent`&&r.messageId===k&&!r.isComplete&&r.content===(t.content??``)){e[e.length-1]={...r,messageId:n};return}M(e),e.push({kind:`agent`,messageId:n,content:t.content??``,isComplete:!1});return}case`agent_thought_chunk`:{let n=t.messageId??k,r=e[e.length-1];if(r&&r.kind===`thinking`&&r.messageId===n){e[e.length-1]={...r,content:r.content+(t.content??``)};return}M(e),e.push({kind:`thinking`,messageId:n,content:t.content??``,isComplete:!1});return}case`tool_call`:{let n=t.toolCallId;if(n===void 0)return;M(e),e.push({kind:`tool`,toolCallId:n,title:t.toolTitle??``,toolKind:t.toolKind,status:A(t.toolStatus,`running`),content:t.content,locations:P(t),rawInput:t.rawInput,rawOutput:t.rawOutput});return}case`tool_call_update`:{let n=t.toolCallId;if(n===void 0)return;let r=e.findIndex(e=>e.kind===`tool`&&e.toolCallId===n);if(r===-1)return;let i=e[r],a=P(t);e[r]={...i,title:t.toolTitle??i.title,toolKind:t.toolKind??i.toolKind,status:A(t.toolStatus,i.status),content:t.content??i.content,locations:a??i.locations,rawInput:t.rawInput===void 0?i.rawInput:t.rawInput,rawOutput:t.rawOutput===void 0?i.rawOutput:t.rawOutput};return}case`plan`:{let n=pe(t.content);if(n===null)return;let r=e.findIndex(e=>e.kind===`plan`),i={kind:`plan`,entries:n};r===-1?(M(e),e.push(i)):e[r]=i;return}}}function P(e){let t=e.locations;if(!Array.isArray(t))return;let n=[];for(let e of t){let t=e??{};typeof t.path==`string`&&n.push(typeof t.line==`number`?{path:t.path,line:t.line}:{path:t.path})}return n}function pe(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}let n=Array.isArray(t)?t:Array.isArray(t?.entries)?t.entries:null;return n===null?null:n.map(e=>{let t=e??{},n=t.content??t.label??``;return{label:typeof n==`string`?n:String(n),checked:t.checked===!0||t.status===`completed`}})}function me(e){let t=[];for(let n of e)N(t,n);return t}function F(e,t){if(e===t)return{kind:`identity`};if(e===null)return{kind:`first`};if(t.length<e.length)return{kind:`fallback`};for(let n=0;n<e.length;n++)if(e[n]!==t[n])return n===e.length-1&&t.length===e.length?{kind:`mutate-last`}:{kind:`fallback`};return t.length===e.length?{kind:`identity`}:{kind:`append`,from:e.length}}function I(){let e=null,t=[];function n(n){return t=me(n),e=n,t}function r(r){let i=F(e,r);switch(i.kind){case`identity`:return t;case`first`:return n(r);case`append`:{let n=t.slice();for(let e=i.from;e<r.length;e++)N(n,r[e]);return e=r,t=n,t}case`mutate-last`:case`fallback`:return n(r)}}return{project:r}}function L(e){let t=(0,O.useRef)(null);return t.current??=I(),t.current.project(e)}function R(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{let t=e.trimStart();return t.startsWith(`{`)||t.startsWith(`[`)?[]:[{type:`content`,text:e}]}let n=Array.isArray(t)?t:[t],r=[];for(let e of n){let t=z(e);t&&r.push(t)}return r}function z(e){if(typeof e!=`object`||!e)return null;let t=e;switch(t.type){case`content`:return{type:`content`,text:he(t.content)};case`diff`:return typeof t.path!=`string`||typeof t.newText!=`string`?null:{type:`diff`,path:t.path,newText:t.newText,...typeof t.oldText==`string`?{oldText:t.oldText}:{}};case`terminal`:{let e=ge(t);return e===void 0?{type:`terminal`}:{type:`terminal`,text:e}}default:return null}}function he(e){if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t=e.text;if(typeof t==`string`)return t}return``}function ge(e){if(typeof e.text==`string`)return e.text;if(typeof e.output==`string`)return e.output;if(typeof e.content==`string`)return e.content;if(typeof e.content==`object`&&e.content!==null){let t=e.content.text;if(typeof t==`string`)return t}}function B(e){if(typeof e!=`object`||!e)return;let t=e.command;return typeof t==`string`?t:void 0}function V(e){return R(e).filter(e=>e.type===`content`||e.type===`terminal`).map(e=>`text`in e?e.text??``:``).filter(e=>e.length>0).join(`
|
|
2
2
|
`)}function H(e){if(e!=null){if(typeof e==`string`)return e;if(typeof e==`object`)try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)}}function U(e,t){let n=new Map;for(let t of e)t.type===`diff`&&n.set(t.path,{path:t.path,newText:t.newText,...t.oldText===void 0?{}:{oldText:t.oldText}});for(let e of t??[])n.has(e.path)||n.set(e.path,{path:e.path});return Array.from(n.values())}var W=i();function _e({content:e,isComplete:t}){return(0,W.jsxs)(`div`,{"data-testid":`acp-chat-agent-message`,className:`flex w-full flex-col items-start text-chat text-[var(--content-default)]`,children:[(0,W.jsx)(x,{content:e}),!t&&(0,W.jsx)(S,{className:`mt-1`,"data-testid":`acp-chat-agent-streaming`})]})}function ve({entries:e}){return e.length===0?null:(0,W.jsxs)(`div`,{"data-testid":`acp-chat-plan-block`,className:`w-full rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] p-3`,children:[(0,W.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 text-[var(--content-tertiary)]`,children:[(0,W.jsx)(ce,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),(0,W.jsx)(a,{variant:`body-small-emphasised`,className:`text-inherit`,children:`Plan`})]}),(0,W.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:e.map((e,t)=>(0,W.jsxs)(`li`,{"data-testid":`acp-chat-plan-entry`,"data-checked":e.checked,className:`flex items-start gap-2`,children:[e.checked?(0,W.jsx)(d,{"aria-hidden":!0,className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}):(0,W.jsx)(f,{"aria-hidden":!0,className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-disabled)]`}),(0,W.jsx)(`span`,{className:e.checked?`text-body-small-default text-[var(--content-tertiary)] line-through`:`text-body-small-default text-[var(--content-default)]`,children:e.label})]},t))})]})}function ye(e){switch(e){case`max_tokens`:case`max_turn_requests`:return`Stopped: limit reached`;case`refusal`:return`Refused`;case`cancelled`:return`Cancelled`;default:return`Completed`}}function be(e){return new Date(e).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function G({completedAt:e}){return e===void 0?null:(0,W.jsxs)(`span`,{"data-testid":`acp-chat-terminal-time`,children:[`at `,be(e)]})}function xe({status:e,stopReason:t,error:n,completedAt:r}){if(w(e))return null;if(e===`failed`)return(0,W.jsxs)(`div`,{"data-testid":`acp-chat-terminal-block`,"data-terminal-kind":`failed`,className:`flex items-start gap-2 rounded-lg bg-[var(--system-negative-weak)] px-3 py-2 text-body-small-default text-[var(--system-negative-strong)]`,children:[(0,W.jsx)(`span`,{"aria-hidden":!0,"data-testid":`acp-chat-terminal-failed-icon`,className:`flex h-[12px] w-4 shrink-0 items-center justify-center`,children:(0,W.jsx)(v,{className:`h-4 w-4`})}),(0,W.jsx)(`span`,{children:n??`Run failed`})]});if(e===`cancelled`)return(0,W.jsxs)(`div`,{"data-testid":`acp-chat-terminal-block`,"data-terminal-kind":`cancelled`,className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,W.jsx)(oe,{"aria-hidden":!0,className:`h-4 w-4 shrink-0`}),(0,W.jsx)(`span`,{children:`Cancelled`}),(0,W.jsx)(G,{completedAt:r})]});let i=ye(t);return(0,W.jsxs)(`div`,{"data-testid":`acp-chat-terminal-block`,"data-terminal-kind":`completed`,className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,W.jsx)(d,{"aria-hidden":!0,className:`h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}),(0,W.jsx)(`span`,{children:i}),(0,W.jsx)(G,{completedAt:r})]})}function Se({showDot:e,isLast:t,children:n}){return(0,W.jsxs)(`div`,{className:`relative flex items-start gap-2${t?``:` pb-4`}`,children:[!t&&(0,W.jsx)(`div`,{"aria-hidden":!0,className:`absolute bottom-0 left-[6.5px] w-px bg-[var(--border-element)] ${e?`top-[16px]`:`top-0`}`}),e?(0,W.jsx)(`span`,{"aria-hidden":!0,"data-testid":`acp-chat-timeline-dot`,className:`flex h-[14px] w-[14px] shrink-0 items-center justify-center`,children:(0,W.jsx)(`span`,{className:`h-[5px] w-[5px] rounded-full bg-[var(--content-disabled)]`})}):(0,W.jsx)(`span`,{"aria-hidden":!0,className:`h-[14px] w-[14px] shrink-0`}),(0,W.jsx)(`div`,{className:`min-w-0 flex-1`,children:n})]})}function Ce({content:e,isComplete:t}){let[n,r]=(0,O.useState)(null),i=n??!t,a=e.trim().length>0,o=t?`Thought process`:`Thinking`,s=t?(0,W.jsx)(c,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}):(0,W.jsx)(S,{dotSize:5,className:`shrink-0`,"data-testid":`acp-chat-thinking-streaming`});return a?(0,W.jsxs)(`div`,{"data-testid":`acp-chat-thinking-block`,className:`w-full`,children:[(0,W.jsxs)(`button`,{type:`button`,"aria-expanded":i,onClick:()=>r(!i),"data-testid":`acp-chat-thinking-toggle`,className:`flex w-full items-center gap-1.5 text-body-small-default text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-secondary)]`,children:[i?(0,W.jsx)(l,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}):(0,W.jsx)(u,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),s,(0,W.jsx)(`span`,{children:o})]}),i&&(0,W.jsx)(`div`,{"data-testid":`acp-chat-thinking-body`,className:`mt-1.5 border-l-2 border-[var(--border-base)] pl-3 text-body-small-default text-[var(--content-tertiary)]`,children:(0,W.jsx)(x,{content:e})})]}):(0,W.jsx)(`div`,{"data-testid":`acp-chat-thinking-block`,className:`w-full`,children:(0,W.jsxs)(`div`,{className:`flex w-full items-center gap-1.5 text-body-small-default text-[var(--content-tertiary)]`,children:[s,(0,W.jsx)(`span`,{children:o})]})})}var we={running:`neutral`,completed:`positive`,error:`negative`,ended:`neutral`},Te={running:`Running`,completed:`Completed`,error:`Failed`,ended:`Ended`},Ee={read:`Read file`,edit:`Edit file`,delete:`Delete file`,move:`Move file`,search:`Search`,execute:`Run command`,think:`Thinking`,fetch:`Fetch`,switch_mode:`Switch mode`},De=`Tool call`,Oe={read:m,edit:ue,delete:ae,move:de,search:ee,execute:E,think:c,fetch:h,switch_mode:g},ke=new Set([`read`,`edit`,`delete`,`move`]);function Ae({toolKind:e}){return(0,W.jsx)(e&&Oe[e]||p,{"aria-hidden":!0,className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)]`})}function K({label:e,value:t,testId:n}){return(0,W.jsxs)(`div`,{"data-testid":n,children:[(0,W.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-tertiary)]`,children:e}),(0,W.jsx)(`pre`,{className:`max-h-60 overflow-auto rounded-md border border-[var(--border-element)] bg-[var(--surface-base)] p-2.5 font-mono text-body-small-default text-[var(--content-secondary)]`,children:t})]})}function je({block:e,isTerminal:t=!1,onOpenDiff:n,onOpenOutput:r}){let[i,o]=(0,O.useState)(!1),s=(0,O.useMemo)(()=>R(e.content),[e.content]),c=(0,O.useMemo)(()=>V(e.content),[e.content]),d=(0,O.useMemo)(()=>c.split(`
|
|
3
3
|
`).map(e=>e.trim()).find(e=>e.length>0&&!e.startsWith("```"))||`View output`,[c]),f=(0,O.useMemo)(()=>U(s,e.locations),[s,e.locations]),p=t&&e.status===`running`?`ended`:e.status,h=p===`running`,g=e.toolKind&&Ee[e.toolKind]||De,_=B(e.rawInput)??e.title,v=_&&_!==g&&(!ke.has(e.toolKind??``)||f.length===0)?_:null,y=H(e.rawInput),x=H(e.rawOutput),C=y!==void 0||x!==void 0;return(0,W.jsxs)(`div`,{"data-testid":`acp-chat-tool-card`,"data-status":e.status,className:`w-full rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Ae,{toolKind:e.toolKind}),(0,W.jsx)(a,{variant:`body-small-emphasised`,className:`min-w-0 flex-1 truncate text-[var(--content-default)]`,title:e.title,children:g}),(0,W.jsx)(b,{tone:we[p],"data-testid":`acp-chat-tool-status`,children:Te[p]}),h&&(0,W.jsx)(S,{className:`shrink-0`,"data-testid":`acp-chat-tool-running`})]}),v&&(0,W.jsx)(`div`,{"data-testid":`acp-chat-tool-detail`,className:`mt-1.5 font-mono text-body-small-default whitespace-pre-wrap break-words text-[var(--content-secondary)]`,children:v}),f.length>0&&(0,W.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:f.map(t=>{let r=t.oldText!==void 0||t.newText!==void 0,i=`flex max-w-full items-center gap-1.5 rounded-md border border-[var(--border-base)] bg-[var(--surface-base)] px-2 py-1 text-body-small-default text-[var(--content-secondary)]`;return r?(0,W.jsxs)(`button`,{type:`button`,"data-testid":`acp-chat-tool-file-chip`,onClick:()=>n(e.toolCallId,t),title:t.path,className:`${i} cursor-pointer transition-colors hover:bg-[var(--surface-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--border-focus)]`,children:[(0,W.jsx)(m,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`truncate font-mono`,children:t.path})]},t.path):(0,W.jsxs)(`span`,{"data-testid":`acp-chat-tool-file-ref`,title:t.path,className:i,children:[(0,W.jsx)(m,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`truncate font-mono`,children:t.path})]},t.path)})}),c.length>0&&(0,W.jsxs)(`button`,{type:`button`,"data-testid":`acp-chat-tool-output-open`,onClick:()=>r?.(e.toolCallId),className:`mt-2 flex w-full items-center gap-2 rounded-md border border-[var(--border-element)] bg-[var(--surface-base)] px-2.5 py-2 text-left transition-colors hover:bg-[var(--surface-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--border-focus)]`,children:[(0,W.jsx)(E,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0 text-[var(--content-tertiary)]`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-body-small-default text-[var(--content-secondary)]`,children:d}),(0,W.jsx)(u,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0 text-[var(--content-tertiary)]`})]}),C&&(0,W.jsxs)(`div`,{className:`mt-2`,"data-testid":`acp-chat-tool-raw`,children:[(0,W.jsxs)(`button`,{type:`button`,"data-testid":`acp-chat-tool-raw-toggle`,"aria-expanded":i,onClick:()=>o(e=>!e),className:`flex items-center gap-1 text-body-small-default text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-default)]`,children:[i?(0,W.jsx)(l,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}):(0,W.jsx)(u,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),(0,W.jsx)(`span`,{children:i?`Hide raw input/output`:`Show raw input/output`})]}),i&&(0,W.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-2`,children:[y!==void 0&&(0,W.jsx)(K,{label:`Raw input`,value:y,testId:`acp-chat-tool-raw-input`}),x!==void 0&&(0,W.jsx)(K,{label:`Raw output`,value:x,testId:`acp-chat-tool-raw-output`})]})]})]})}function Me({content:e}){return(0,W.jsx)(`div`,{"data-testid":`acp-chat-user-turn`,className:`flex w-full justify-end`,children:(0,W.jsx)(`div`,{className:`max-w-[80%] rounded-lg bg-[var(--surface-lift)] px-4 py-3 whitespace-pre-wrap text-chat text-[var(--content-default)]`,children:e})})}function Ne(e,t){let n=e=>new Intl.NumberFormat(void 0,{style:`currency`,currency:t}).format(e);return e>0&&e<.01?`<${n(.01)}`:n(e)}var q=new Intl.NumberFormat(`en-US`);function J({label:e,value:t}){return(0,W.jsxs)(`div`,{className:`flex items-baseline gap-1`,"data-usage-stat":e.toLowerCase(),children:[(0,W.jsx)(a,{variant:`label-small-default`,className:`text-[var(--content-tertiary)]`,children:e}),(0,W.jsx)(a,{variant:`body-small-default`,className:`text-[var(--content-secondary)] tabular-nums`,children:t})]})}function Pe({entry:e}){let{inputTokens:t,outputTokens:n,costAmount:r,costCurrency:i}=e;if(t===void 0&&n===void 0)return null;let a=t??0,o=n??0,s=r!=null&&i!=null;return(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,"data-testid":`acp-usage-meter`,children:[(0,W.jsx)(J,{label:`Input`,value:q.format(a)}),(0,W.jsx)(J,{label:`Output`,value:q.format(o)}),s&&(0,W.jsx)(J,{label:`Cost`,value:Ne(r,i)})]})}function Fe({content:e}){return(0,W.jsx)(`div`,{"data-testid":`acp-chat-command-output`,className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] p-3 [&_pre]:!max-h-none`,children:(0,W.jsx)(x,{content:V(e),hardLineBreaks:!0})})}var Y=2e3;function X(e){if(e===``)return[];let t=e.split(`
|
|
4
4
|
`);return e.endsWith(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-BxZ6HzpA.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import{t as i}from"./typography-B_Zom8Gj.js";import{E as a,S as o,c as s,l as c,x as l}from"./risk-DVMoHqLD.js";import{t as u}from"./chevron-left-BMF1xNfR.js";import"./src-ChvLuWxs.js";import{t as d}from"./chat-markdown-message-Dc8j-__5.js";import{C as f,a as p,i as m,n as h,r as g,s as _,y as v}from"./site-favicon-D3w8K4_d.js";import{At as y,E as b,G as x,J as S,K as C,U as w,W as T,X as E,Y as D,q as O,vi as k,zt as A}from"./index-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-BxZ6HzpA.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import{t as i}from"./typography-B_Zom8Gj.js";import{E as a,S as o,c as s,l as c,x as l}from"./risk-DVMoHqLD.js";import{t as u}from"./chevron-left-BMF1xNfR.js";import"./src-ChvLuWxs.js";import{t as d}from"./chat-markdown-message-Dc8j-__5.js";import{C as f,a as p,i as m,n as h,r as g,s as _,y as v}from"./site-favicon-D3w8K4_d.js";import{At as y,E as b,G as x,J as S,K as C,U as w,W as T,X as E,Y as D,q as O,vi as k,zt as A}from"./index-DA-27U7J.js";import{ToolDetailBody as j,t as M}from"./tool-detail-panel-3ertbTbW.js";var N=e(t(),1);function P(e,t,n){let r=T(t,n.workflow),i=e=>{let t=C(e,n.workflow.byToolUseId);if(t!==null&&r.has(t))return!0;let i=w(e,n.acpByToolUseId);if(i!==null&&n.acpById[i]!==void 0)return!0;let a=x(e);return a!==void 0&&n.backgroundTaskById[a]!==void 0},a=t.filter(e=>!i(e));if(a.length===t.length)return{items:e,toolCalls:t};let o=new Set(a.map(e=>e.id));return{items:e.filter(e=>e.kind!==`toolCall`||o.has(e.toolCall.id)),toolCalls:a}}function F(e,t){let n=o(),r=k.use.byId(),i=k.use.byToolUseId(),l=k.use.notFoundRunIds(),u=k.use.hydrationFailedRunIds(),d=y.use.byId(),f=y.use.byToolUseId(),p=A.use.byId();return(0,N.useMemo)(()=>{if(!e||t==null)return null;let o=n.find(t=>a(t).includes(e));if(!o)return null;let m=c(o.contentBlocks??[],{splitInlineThinking:o.role!==`user`})[t];if(!m||m.type!==`activity`)return null;let{cardItems:h,toolCalls:g}=s(m.items);return P(h,g,{workflow:{byId:r,byToolUseId:i,notFoundRunIds:l,hydrationFailedRunIds:u},acpById:d,acpByToolUseId:f,backgroundTaskById:p})},[n,e,t,r,i,l,u,d,f,p])}var I=r(),L=60;function R({payload:e,onClose:t}){let[r,a]=(0,N.useState)(null),o=F(e.messageId,e.groupIndex),s=o?.items??e.items,c=o?.toolCalls??e.toolCalls,l=E(s),d=S(l.steps),p=D(l.state,l.steps),m=p===`loading`,h=O(p,l.totalDurationLabel??``,d.failed),g=m&&l.currentStepTitle||h,v=new Map(c.map(e=>[e.id,e])),y=r?r.kind===`thinking`?`Thinking`:r.activity||r.title:``;return(0,I.jsx)(b,{titleNode:r?(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 py-0.5`,children:[(0,I.jsx)(n,{variant:`ghost`,iconOnly:(0,I.jsx)(u,{}),"aria-label":`Back to all steps`,tooltip:`All steps`,onClick:()=>a(null),className:`-ml-2.5 shrink-0`}),(0,I.jsx)(i,{variant:`title-medium`,className:`min-w-0 shrink truncate leading-snug text-[var(--content-default)]`,children:y})]}):(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 py-0.5`,children:[(0,I.jsx)(i,{variant:`title-medium`,className:`min-w-0 shrink truncate leading-snug text-[var(--content-default)]`,children:m?(0,I.jsx)(f,{children:g}):g}),l.stepCount?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{"aria-hidden":!0,className:`size-[3px] shrink-0 rounded-full bg-[var(--content-tertiary)]`}),(0,I.jsx)(i,{variant:`title-medium`,className:`shrink-0 whitespace-nowrap leading-snug text-[var(--content-secondary)]`,children:l.stepCount})]}):null]}),closeLabel:`Close steps`,onClose:t,children:r?(0,I.jsx)(B,{detail:r}):(0,I.jsx)(_,{steps:l.steps,timeline:!0,renderStep:t=>(0,I.jsx)(z,{step:t,activeDetail:r,onOpenDetail:a,lookupToolCall:e=>v.get(e),messageId:e.messageId,groupIndex:e.groupIndex})})})}function z({step:e,activeDetail:t,onOpenDetail:n,lookupToolCall:r,messageId:i,groupIndex:a}){if(e.kind===`thinking`){let t=i!=null&&e.thinkingItemIndex!=null?{messageId:i,thinkingGroupIndex:a,thinkingItemIndex:e.thinkingItemIndex}:{};return(0,I.jsx)(m,{iconName:`brain`,label:l(e.text,L),ariaLabel:`View thinking`,active:!1,onClick:()=>n({kind:`thinking`,toolCallId:``,toolName:``,title:`Thinking`,activity:``,input:{},status:`completed`,thinkingText:e.text,...t})})}if(e.kind===`web_search`)return(0,I.jsx)(g,{step:e});if(e.kind===`web_search_error`)return(0,I.jsx)(h,{step:e});if(e.kind!==`tool`)return(0,I.jsx)(p,{step:e});let o=r(e.toolCallId);return(0,I.jsx)(m,{iconName:e.iconName,label:e.activity||e.info||e.title,active:t?.toolCallId===e.toolCallId,onClick:()=>{o&&n(v(o))}})}function B({detail:e}){let t=M(e.kind===`thinking`?e.messageId:void 0,e.thinkingGroupIndex,e.thinkingItemIndex);return(0,I.jsx)(`div`,{className:`flex flex-col gap-4`,children:e.kind===`thinking`?(0,I.jsx)(d,{content:t??e.thinkingText??``,hardLineBreaks:!0}):(0,I.jsx)(j,{detail:e})})}export{R as ActivityStepsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{a as t,c as n,i as r}from"./local-settings-C-dW2vkq.js";import{r as i,t as a}from"./capture-error-EqyiBCqE.js";import{t as o}from"./react-DJZBPgpf.js";import{t as s}from"./button-BxZ6HzpA.js";import{m as c,u as l}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as u}from"./QueryClientProvider-DKhXIxGb.js";import{t as d}from"./useQuery-B45lW1Kk.js";import{t as f}from"./useMutation-Lj4VunQV.js";import{t as p}from"./jsx-runtime-CVSDxk6A.js";import{t as m}from"./cn-eDwV5N77.js";import{t as h}from"./typography-B_Zom8Gj.js";import{t as g}from"./createLucideIcon-IRfcSUxS.js";import{t as _}from"./check-DFNrQERi.js";import{t as v}from"./chevron-down-qD-re7AW.js";import{n as y,t as b}from"./circle-check-D3NSGpeC.js";import{t as x}from"./clock-DO_4QDAG.js";import{t as S}from"./crown-BJwJq0zQ.js";import{t as C}from"./external-link-CfkE0LZW.js";import{t as w}from"./info-BuIjW2mw.js";import{t as T}from"./loader-circle-CWO25Tky.js";import{t as E}from"./triangle-alert-BAgktlRD.js";import{t as D}from"./notice-Bd1rN4YY.js";import{j as O}from"./src-ChvLuWxs.js";import{t as k}from"./tag-D4RWxz2r.js";import{t as A}from"./popover-Cnk1lojt.js";import{t as j}from"./input-CGhuhT4R.js";import{t as M}from"./toggle-CvdrA_Wf.js";import{t as N}from"./modal-uxv7vVf7.js";import{n as P}from"./toast-CJSlHuX8.js";import{t as F}from"./confirm-dialog-BX77s7Gd.js";import{t as I}from"./dropdown-Dftxb_kj.js";import{Ut as L,Wt as R,ar as z,ft as ee,j as B,lt as te,wn as V}from"./sdk.gen-CPsr6ePr.js";import{Bt as H,Ft as ne,H as U,V as W,_t as G,c as K,d as q,f as J,l as Y,m as re,p as ie,u as X}from"./react-query.gen-BmvBFzUQ.js";import{t as ae}from"./assistant-identity-store-D_L4IJs-.js";import{i as oe,r as se,t as ce}from"./utils-CuIE4SGk.js";import{r as le}from"./api-errors-DNWYjUzX.js";import{u as ue}from"./routes-DN3K5OaW.js";import{t as de}from"./use-is-org-ready-DX9EbciC.js";import{c as fe,ct as pe,d as me,f as he,g as ge,h as _e,l as ve,m as ye,o as be,p as xe,s as Se,u as Ce,v as we,y as Te}from"./react-query.gen-BfXcRy9K.js";import{$i as Ee,$t as De,Ai as Oe,Ar as ke,B as Ae,Bi as je,Br as Me,Di as Ne,Dr as Pe,Ei as Fe,Fi as Ie,Fr as Le,Gi as Re,Gr as ze,H as Be,Hi as Ve,Hr as He,Ii as Ue,Ir as We,Ji as Ge,Ki as Ke,Lr as qe,Mi as Je,Mr as Ye,Ni as Xe,Nr as Ze,Oi as Qe,Or as $e,Pi as et,Pr as tt,Qi as nt,Qt as rt,R as it,Rr as at,Sa as ot,Ti as st,Ui as ct,Ur as lt,V as ut,Vi as dt,Wi as ft,Wr as pt,Xi as mt,Xt as ht,Yi as gt,Zi as _t,Zt as vt,ea as yt,ji as bt,jr as xt,ki as St,kr as Ct,na as wt,pa as Tt,qi as Et,ra as Dt,ta as Ot,wi as kt,z as At,zi as jt,zr as Mt}from"./index-DNzT2JAI.js";import{t as Nt}from"./use-active-assistant-id-COiCJBSe.js";import{t as Pt}from"./detail-card-BO9_00mj.js";import{t as Ft}from"./environment-store-PamE9l4Q.js";var It=g(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),Z=e(o(),1),Q=p();function Lt({mode:e,onChange:t}){return(0,Q.jsx)(`div`,{className:`max-w-[280px]`,children:(0,Q.jsx)(O,{ariaLabel:`Service mode`,value:e,onChange:t,items:[{value:`managed`,label:`Managed`},{value:`your-own`,label:`Your Own`}]})})}function Rt({id:e,title:t,subtitle:n,mode:r,onModeChange:i,children:a}){return(0,Q.jsxs)(Pt,{id:e,title:t,subtitle:n,accessory:(0,Q.jsx)(Lt,{mode:r,onChange:i}),children:[(0,Q.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:a})]})}function zt({id:e,title:t,subtitle:n,children:r}){return(0,Q.jsxs)(Pt,{id:e,title:t,subtitle:n,children:[(0,Q.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:r})]})}function Bt(){return(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] px-4 py-2.5`,children:[(0,Q.jsx)(w,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,Q.jsxs)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:[`Managed services are metered and deducted from your Vellum account balance.`,` `,(0,Q.jsxs)(`a`,{href:`https://www.vellum.ai/docs/pricing`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--primary-base)] hover:underline`,children:[`View pricing`,(0,Q.jsx)(C,{className:`h-3.5 w-3.5`})]})]})]})}function Vt({status:e,message:t,isLoading:n}){return n?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2.5 py-0.5 text-body-small-default text-[var(--content-quiet)]`,children:[(0,Q.jsx)(T,{className:`h-3 w-3 animate-spin`}),`Checking domain…`]}):e?e===`verified`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-positive-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-positive-strong)]`,title:`DNS records have been verified. Your domain is ready to send and receive email.`,children:[(0,Q.jsx)(_,{className:`h-3 w-3`}),`Domain verified`]}):e===`pending`||e===`not_started`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-mid-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-mid-strong)]`,title:`DNS records have been provisioned. Waiting for the email provider to verify them — this usually takes a few minutes.`,children:[(0,Q.jsx)(x,{className:`h-3 w-3`}),`Verifying domain…`]}):(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-negative-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-negative-strong)]`,title:`Domain verification failed. DNS records may not have propagated correctly. You could try releasing and re-registering the domain.`,children:[(0,Q.jsx)(y,{className:`h-3 w-3`}),`Verification failed`]}):(0,Q.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2.5 py-0.5 text-body-small-default text-[var(--content-quiet)]`,title:`Unable to retrieve domain verification status.`,children:`Unknown status`})}function $({onClick:e,disabled:t}){return(0,Q.jsx)(s,{onClick:e,disabled:t,children:`Save`})}function Ht({onClick:e,filled:t=!1}){return(0,Q.jsx)(s,{variant:t?`danger`:`dangerGhost`,onClick:e,children:`Reset`})}function Ut({guide:e}){return(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(w,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{children:e.description}),(0,Q.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[e.linkLabel,(0,Q.jsx)(C,{className:`h-3 w-3`})]})]})]})}var Wt=`__custom__`;function Gt(e){return e?!!(e.profile||e.provider||e.model):!1}function Kt(e,t){let n=Gt(e);return n===Gt(t)?n?(e?.profile??null)===(t?.profile??null)&&(e?.provider??null)===(t?.provider??null)&&(e?.model??null)===(t?.model??null):!0:!1}function qt({id:e,displayName:t,description:n,defaultProfileLabel:r,draft:i,profileOptions:a,onDraftChange:o,onToggle:s}){let c=Gt(i),l=!i||!c?``:i.provider||i.model?Wt:i.profile??``,u=l===Wt,d=Je(),f=d[0]??Ee[0],p=d.find(e=>e===i?.provider)??f,m=Dt(p).map(e=>({value:e.id,label:e.displayName})),h=!!i?.provider&&!i?.model;function g(t){t===`__custom__`?o(e,{profile:null,provider:f,model:wt(f)??``}):t===``?o(e,null):o(e,{profile:t,provider:null,model:null})}function _(t){let n=wt(t)??``;o(e,{...i??{},profile:null,provider:t,model:n})}function v(t){o(e,{...i??{},model:t})}return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:t}),n&&(0,Q.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[n,r&&(0,Q.jsxs)(`span`,{className:`ml-1.5 text-body-small-default text-[var(--content-tertiary)] opacity-60`,children:[`· Default: `,r]})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[c&&(0,Q.jsx)(I,{value:l,onChange:g,options:a,className:`w-44`,menuMinWidth:280,menuAlign:`end`}),(0,Q.jsx)(M,{checked:c,onChange:t=>s(e,t),"aria-label":`Override ${t}`})]})]}),c&&u&&(0,Q.jsxs)(`div`,{className:`mt-3 space-y-2 border-t border-[var(--border-base)] pt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex-1`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(I,{value:p??``,onChange:_,options:d.map(e=>({value:e,label:Ot[e]??e}))})]}),(0,Q.jsxs)(`div`,{className:`flex-1`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Model`}),(0,Q.jsx)(I,{value:i?.model??``,onChange:v,options:m})]})]}),h&&(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:`Pick a model`})]})]})}function Jt({isOpen:e,onClose:t,assistantId:n}){let r=(0,Z.useRef)(!1);return(0,Q.jsx)(N.Root,{open:e,onOpenChange:e=>{!e&&!r.current&&t()},children:e?(0,Q.jsx)(Yt,{assistantId:n,onClose:t,onSavingChange:e=>{r.current=e}}):null})}function Yt({assistantId:e,onClose:t,onSavingChange:n}){let r=u(),{data:i}=d({...K({path:{assistant_id:e}}),staleTime:3e4}),o=(0,Z.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),c=(0,Z.useMemo)(()=>i?.llm?.profileOrder??[],[i?.llm?.profileOrder]),l=(0,Z.useMemo)(()=>i?.llm?.callSites??{},[i?.llm?.callSites]),f=(0,Z.useMemo)(()=>dt(o,c),[o,c]),p=Je(),m=H({onSuccess:t=>{X(r,{path:{assistant_id:e}},t)}}),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)({}),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),{data:E,isLoading:D,isError:O,refetch:k}=d({...q({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4,refetchOnWindowFocus:!1}),A=(0,Z.useMemo)(()=>(E?.callSites??[]).filter(e=>e.id!==`mainAgent`),[E]),M=!D&&!O&&!!E&&!!i,L=(0,Z.useMemo)(()=>A.map(e=>e.id),[A]),R=(0,Z.useMemo)(()=>{if(!M)return{};let e={};for(let t of L)if(t in y)e[t]=y[t];else{let n=l[t];e[t]=n?{...n}:{}}return e},[M,L,l,y]),z=(0,Z.useMemo)(()=>new Set(L),[L]),ee=(0,Z.useMemo)(()=>Object.entries(l).some(([e,t])=>z.has(e)&&(t?.profile!=null||t?.provider!=null||t?.model!=null)),[l,z]),B=(0,Z.useMemo)(()=>{if(!M)return!1;for(let e of Object.keys(R))if(!Kt(R[e],l[e]))return!0;return!1},[M,R,l]),te=(0,Z.useMemo)(()=>Object.values(R).some(e=>Gt(e)&&!!e?.provider&&!e?.model),[R]),V=(0,Z.useMemo)(()=>ut(f,[]).map(e=>({value:e.name,label:At(e)})),[f]),ne=(0,Z.useCallback)(()=>{if(!_)return;let e={};for(let t of L)e[t]={profile:_};b(e)},[_,L]),U=(0,Z.useCallback)(e=>[...ut(f,[e]).map(e=>({value:e.name,label:At(e)})),{value:Wt,label:`Custom`}],[f]),W=(0,Z.useMemo)(()=>{if(!h.trim())return A;let e=h.toLowerCase();return A.filter(t=>(t.displayName??``).toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)||(t.domain??``).toLowerCase().includes(e))},[A,h]),G=(0,Z.useMemo)(()=>{if(!E)return[];let e=E.domains.map(e=>e.id),t=new Map(E.domains.map(e=>[e.id,e])),n=[];for(let r of e){let e=W.filter(e=>e.domain===r);e.length>0&&n.push({domain:t.get(r),sites:e})}let r=new Set(e),i=W.filter(e=>!r.has(e.domain));return i.length>0&&n.push({domain:{id:`other`,displayName:`Other`},sites:i}),n},[E,W]),J=(0,Z.useCallback)((e,t)=>{b(n=>({...n,[e]:t}))},[]),Y=(0,Z.useCallback)((e,t)=>{if(!t){b(t=>({...t,[e]:null}));return}let n=Ae(f,A.find(t=>t.id===e)?.defaultProfile);if(n)b(t=>({...t,[e]:{profile:n}}));else{let t=p[0]??Ee[0],n=wt(t)??``;b(r=>({...r,[e]:{provider:t,model:n}}))}},[A,f,p]),re=(0,Z.useCallback)(async()=>{S(!0),n?.(!0);try{let n={};for(let e of Object.keys(R)){let t=R[e]??null;n[e]=Gt(t)?{profile:t?.profile??null,provider:t?.provider??null,model:t?.model??null}:null}await m.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:n}}}),t(),P.success(`Overrides saved.`)}catch(e){P.error(`Failed to save overrides. Please try again.`),a(e,{context:`call_site_overrides_save`})}finally{S(!1),n?.(!1)}},[R,t,m,n,e]),ie=(0,Z.useCallback)(async()=>{S(!0),n?.(!0);try{let n={};for(let e of Object.keys(R))n[e]=null;await m.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:n}}}),t(),P.success(`Overrides reset.`)}catch(e){P.error(`Failed to reset overrides. Please try again.`),a(e,{context:`call_site_overrides_reset`})}finally{S(!1),n?.(!1)}},[R,t,m,n,e]);return(0,Q.jsxs)(N.Content,{size:`lg`,hideCloseButton:!0,children:[(0,Q.jsxs)(N.Header,{children:[(0,Q.jsx)(N.Title,{children:`Action Overrides`}),(0,Q.jsx)(N.Description,{children:`Customize which model profile specific actions should use. Uses your default profile if no override is set.`})]}),(0,Q.jsxs)(N.Body,{children:[(0,Q.jsx)(`div`,{className:`mb-4`,children:(0,Q.jsx)(j,{type:`search`,value:h,onChange:e=>g(e.target.value),placeholder:`Search actions…`,leftIcon:(0,Q.jsx)(ot,{className:`h-4 w-4`}),fullWidth:!0})}),V.length>0&&(0,Q.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] p-3`,children:[(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 text-body-medium-default text-[var(--content-default)]`,children:`Use one profile for all actions`}),(0,Q.jsx)(I,{value:_,onChange:v,options:V,placeholder:`Choose profile…`,className:`w-44`,menuMinWidth:280,menuAlign:`end`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:ne,disabled:!_||!M||x,children:`Apply to all`})]}),D&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,Q.jsx)(T,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}),O&&(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-12 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Couldn't load actions`}),(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Make sure your assistant is running`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>void k(),children:`Retry`})]}),!D&&!O&&E&&(0,Q.jsx)(`div`,{className:`space-y-4`,children:G.length===0?(0,Q.jsx)(`p`,{className:`py-8 text-center text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No actions match your search.`}):G.map(({domain:e,sites:t})=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-body-small-default font-semibold uppercase tracking-wider text-[var(--content-tertiary)]`,children:e.displayName}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>{let t=(()=>{let t=R[e.id]??null;return!t||!Gt(t)?``:t.provider||t.model?`__custom__`:t.profile??``})(),n=e.defaultProfile?f.find(t=>t.name===e.defaultProfile)?.label??e.defaultProfile:null;return(0,Q.jsx)(qt,{id:e.id,displayName:e.displayName,description:e.description,defaultProfileLabel:n,draft:R[e.id]??null,profileOptions:U(t===``||t===`__custom__`?null:t),onDraftChange:J,onToggle:Y},e.id)})})]},e.id))})]}),(0,Q.jsxs)(N.Footer,{children:[ee&&(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>w(!0),disabled:x||!M,tintColor:`var(--system-negative-strong)`,className:`mr-auto`,children:`Reset to Defaults`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:t,disabled:x,children:`Cancel`}),(0,Q.jsx)(s,{variant:`primary`,size:`compact`,onClick:()=>void re(),disabled:!B||te||x,children:x?(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin`}):`Save`})]}),(0,Q.jsx)(F,{open:C,title:`Reset to Defaults`,message:`Every task override will be reset and will follow your active profile. This cannot be undone.`,confirmLabel:`Reset to Defaults`,destructive:!0,onConfirm:()=>{w(!1),ie()},onCancel:()=>w(!1)})]})}function Xt({blocked:e,availableReplacements:t,replacement:n,onReplacementChange:r,error:i,saving:a,onClose:o,onConfirm:c}){let l=``;if(e){let t=e.label||e.name;l=e.isActive&&e.callSiteIds.length>0?`"${t}" is the active profile and is used by ${e.callSiteIds.length} call site(s). Pick a replacement profile.`:e.isActive?`"${t}" is the active profile. Pick a different active profile before deleting, or select a replacement below.`:`"${t}" is used by ${e.callSiteIds.length} call site(s). Select a replacement profile to reassign them before deleting.`}return(0,Q.jsx)(N.Root,{open:e!==null,onOpenChange:e=>{e||o()},children:(0,Q.jsxs)(N.Content,{size:`sm`,children:[(0,Q.jsx)(N.Header,{children:(0,Q.jsx)(N.Title,{children:`Can't Delete Profile`})}),(0,Q.jsxs)(N.Body,{className:`space-y-4`,children:[(0,Q.jsx)(h,{variant:`body-medium-default`,as:`p`,children:l}),e&&e.callSiteIds.length>0&&(0,Q.jsx)(`ul`,{className:`space-y-1 pl-1`,children:e.callSiteIds.map(e=>(0,Q.jsxs)(`li`,{className:`text-body-small-default text-(--content-secondary)`,children:[`• `,(0,Q.jsx)(`code`,{children:e})]},e))}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Replacement profile`}),(0,Q.jsx)(I,{"aria-label":`Replacement profile`,value:n,onChange:r,options:[{value:``,label:`Select a replacement…`},...t.map(e=>({value:e.name,label:e.label??e.name}))]})]}),i&&(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:i})]}),(0,Q.jsxs)(N.Footer,{children:[(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,onClick:o,children:`Cancel`}),(0,Q.jsx)(s,{variant:`primary`,size:`compact`,disabled:!n||a,onClick:c,children:a?`Saving…`:`Reassign and Delete`})]})]})})}function Zt(e,t){if(e){let n=Dt(e).find(e=>e.id===t);if(n)return n.displayName}let n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t}function Qt(e,t){let n=[];e.description&&n.push(e.description);let r=e.provider_connection===`vellum`&&t?`vellum`:e.provider,i=[];if(e.model&&i.push(Zt(r,e.model)),r){let e=Ot[r]??r;i.push(`hosted by ${e}`)}return i.length>0&&n.push(i.join(` `)),n.join(` – `)}function $t({profile:e,vellumIsManaged:t,isDragging:n,dropTarget:r,isDeleting:i,deleteError:a,isToggling:o,onDragStart:c,onDragEnd:l,onDragOver:u,onDragLeave:d,onDrop:f,onEditClick:p,onDeleteClick:m,onStatusToggle:g}){let _=e.source===`managed`,v=e.invariant===!0,y=e.status!==`disabled`;return(0,Q.jsxs)(`div`,{className:`relative`,children:[r?.name===e.name&&!r.after&&(0,Q.jsx)(`div`,{className:`mx-0 h-0.5 rounded-full bg-[var(--border-active)]`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg pr-2 py-2${n?` opacity-50`:``}`,draggable:!_,onDragStart:c,onDragEnd:l,onDragOver:u,onDragLeave:d,onDrop:f,children:[(0,Q.jsx)(It,{className:`h-4 w-4 shrink-0 ${_?`invisible`:`cursor-grab text-[var(--content-tertiary)]`}`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1${y?``:` opacity-55`}`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(h,{variant:`body-medium-default`,as:`span`,className:`text-(--content-default)`,children:e.label??e.name}),_&&(0,Q.jsx)(k,{tone:`positive`,title:`Managed by Platform — this profile cannot be disabled, deleted, or renamed.`,children:`Platform`})]}),e.description||e.model||e.provider?(0,Q.jsx)(h,{variant:`body-medium-lighter`,as:`p`,className:`mt-0.5 text-(--content-tertiary)`,children:Qt(e,t)}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(!v||!y)&&(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center`,title:y?`Active — toggle to hide from pickers`:`Disabled — toggle to show in pickers`,children:(0,Q.jsx)(M,{checked:y,onChange:e=>g(e),disabled:o,"aria-label":`${y?`Disable`:`Enable`} ${e.label??e.name}`})}),(0,Q.jsxs)(`div`,{className:`flex w-[92px] items-center justify-end gap-2`,children:[(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,onClick:p,children:_||v?`View`:`Edit`}),(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,iconOnly:(0,Q.jsx)(Tt,{}),"aria-label":`Delete ${e.label??e.name}`,disabled:_||v||i,title:_||v?`Managed profiles cannot be deleted`:void 0,onClick:m,tintColor:`var(--system-negative-strong)`})]})]})]}),r?.name===e.name&&r.after&&(0,Q.jsx)(`div`,{className:`mx-0 h-0.5 rounded-full bg-[var(--border-active)]`}),a?(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`px-2 pb-1 text-(--system-negative-strong)`,children:a}):null]})}function en({isOpen:e,assistantId:t,onClose:n}){let r=u(),{data:i}=d({...K({path:{assistant_id:t}}),staleTime:3e4}),o=(0,Z.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),s=(0,Z.useMemo)(()=>i?.llm?.profileOrder??[],[i?.llm?.profileOrder]),c=i?.llm?.activeProfile??null,l=i?.llm?.callSites??{},f=(0,Z.useMemo)(()=>dt(o,s),[o,s]),p=H({onSuccess:e=>{X(r,{path:{assistant_id:t}},e)}}),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(null),{data:v}=d({...W({path:{assistant_id:t}}),enabled:e}),y=v?.connections,b=y?.some(e=>e.name===`vellum`&&e.provider===`vellum`)??!1,x=Object.keys(o);async function S(e,n,r){let i=r?.mode??`replace`,c=!(e in o);if(i===`merge`&&!c){await p.mutateAsync({path:{assistant_id:t},body:{llm:{profiles:{[e]:n}}}}),h(!1),_(null);return}let l={profiles:{[e]:n}};if(c&&(l.profileOrder=s.includes(e)?s:[...s,e]),c)await p.mutateAsync({path:{assistant_id:t},body:{llm:l}});else{let n=o[e];await p.mutateAsync({path:{assistant_id:t},body:{llm:{profiles:{[e]:null}}}});try{await p.mutateAsync({path:{assistant_id:t},body:{llm:l}})}catch(r){throw a(r,{context:`settings-ai-profile-edit-recreate`}),n!=null&&await p.mutateAsync({path:{assistant_id:t},body:{llm:{profiles:{[e]:n}}}}).catch(()=>{}),r}}c&&P.success(`Profile "${n.label??e}" created`),h(!1),_(null)}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(N.Root,{open:e,onOpenChange:e=>{e||n()},children:e?(0,Q.jsx)(tn,{assistantId:t,vellumIsManaged:b,profiles:o,profileOrder:s,orderedProfiles:f,activeProfile:c,callSiteOverrides:l,onClose:n,onEditClick:e=>{_(e),h(!0)},onNewClick:()=>{_(null),h(!0)}}):null}),(0,Q.jsx)(kt,{isOpen:m,mode:g?g.source===`managed`||g.invariant===!0?`view`:`edit`:`create`,profileName:g?.name,initialValues:g??void 0,existingNames:x,connections:y,assistantId:t,onSave:S,onCancel:()=>{h(!1),_(null)}})]})}function tn({assistantId:e,vellumIsManaged:t,profiles:n,profileOrder:r,orderedProfiles:i,activeProfile:o,callSiteOverrides:c,onClose:l,onEditClick:d,onNewClick:f}){let p=u(),m=H({onSuccess:t=>{X(p,{path:{assistant_id:e}},t)}}),[g,_]=(0,Z.useState)({}),[v,y]=(0,Z.useState)({}),[b,x]=(0,Z.useState)(new Set),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(null),[E,D]=(0,Z.useState)(null),[O,k]=(0,Z.useState)(null),A=(0,Z.useRef)(null),j=(0,Z.useRef)(null),[M,P]=(0,Z.useState)(null),[F,I]=(0,Z.useState)(null),[L,R]=(0,Z.useState)(``),[z,ee]=(0,Z.useState)(!1),B=(0,Z.useMemo)(()=>i,[i]);async function te(t,r){if(b.has(t.name))return!1;x(e=>new Set(e).add(t.name)),C(null);let i=r?`active`:`disabled`;if(!n[t.name])return x(e=>{let n=new Set(e);return n.delete(t.name),n}),!1;try{return await m.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[t.name]:{status:i}}}}}),!0}catch(e){return a(e,{context:`settings-ai-profile-toggle`}),C(`Couldn't update "${t.label??t.name}". Please try again.`),!1}finally{x(e=>{let n=new Set(e);return n.delete(t.name),n})}}async function V(t){y(e=>({...e,[t]:!0})),_(e=>{let n={...e};return delete n[t],n});try{let n=r.filter(e=>e!==t);await m.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[t]:null},profileOrder:n}}})}catch(e){a(e,{context:`settings-ai-profile-delete`}),_(e=>({...e,[t]:`Failed to delete profile. Please try again.`}))}finally{y(e=>{let n={...e};return delete n[t],n})}}function ne(e){let t=B.find(t=>t.name===e)?.label??e,n=e===o,r=Object.entries(c).filter(([t,n])=>t!==`mainAgent`&&n?.profile===e).map(([e])=>e);if(n||r.length>0){P({name:e,label:t,isActive:n,callSiteIds:r}),R(``),I(null);return}V(e)}async function U(){if(!M||!L)return;ee(!0),I(null);let t={};if(M.isActive&&(t.activeProfile=L),M.callSiteIds.length>0){let e={};for(let t of M.callSiteIds)e[t]={profile:L};t.callSites=e}if(Object.keys(t).length>0)try{await m.mutateAsync({path:{assistant_id:e},body:{llm:t}})}catch(e){a(e,{context:`settings-ai-profile-reassign-delete`}),I(`Failed to reassign references. Please try again.`),ee(!1);return}let n=M.name;P(null),ee(!1),V(n)}async function W(t,n){if(t===n.name)return;k(null);let i=r.filter(e=>e!==t),o=i.indexOf(n.name);if(o===-1)return;n.after&&(o+=1);let s=[...i.slice(0,o),t,...i.slice(o)];try{await m.mutateAsync({path:{assistant_id:e},body:{llm:{profileOrder:s}}})}catch(e){a(e,{context:`settings-ai-profile-reorder`}),k(`Failed to reorder profiles. Please try again.`)}}let G=B.filter(e=>e.name!==M?.name&&e.source!==`managed`),K=G.length>0?G:B.filter(e=>e.name!==M?.name);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(N.Content,{size:`md`,children:[(0,Q.jsxs)(N.Header,{children:[(0,Q.jsx)(N.Title,{children:`Model Profiles`}),(0,Q.jsx)(N.Description,{children:`Bundle a provider and model into a named profile. Assign profiles to specific actions or swap between them when chatting.`})]}),(0,Q.jsxs)(N.Body,{children:[B.length===0?(0,Q.jsx)(h,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`No profiles yet. Create one to get started.`}):(0,Q.jsx)(`div`,{className:`space-y-1`,children:B.map(e=>(0,Q.jsx)($t,{profile:e,vellumIsManaged:t,isDragging:w===e.name,dropTarget:E,isDeleting:v[e.name]??!1,deleteError:g[e.name],isToggling:b.has(e.name),onDragStart:t=>{A.current=e.name,T(e.name),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)},onDragEnd:()=>{A.current=null,j.current=null,T(null),D(null)},onDragOver:t=>{t.preventDefault();let n=t.currentTarget.getBoundingClientRect(),r=t.clientY>n.top+n.height/2,i={name:e.name,after:r};j.current=i,D(i)},onDragLeave:t=>{t.currentTarget.contains(t.relatedTarget)||(j.current=null,D(t=>t?.name===e.name?null:t))},onDrop:e=>{e.preventDefault();let t=A.current,n=j.current;A.current=null,j.current=null,T(null),D(null),t&&n&&W(t,n)},onEditClick:()=>d(e),onDeleteClick:()=>ne(e.name),onStatusToggle:t=>void te(e,t)},e.name))}),O&&(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`mt-2 text-(--system-negative-strong)`,children:O}),S&&(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`mt-2 text-(--system-negative-strong)`,children:S})]}),(0,Q.jsxs)(N.Footer,{className:`justify-between`,children:[(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:f,children:`+ New Profile`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:l,children:`Done`})]})]}),(0,Q.jsx)(Xt,{blocked:M,availableReplacements:K,replacement:L,onReplacementChange:R,error:F,saving:z,onClose:()=>{P(null),I(null)},onConfirm:()=>void U()})]})}var nn=`0.10.8`;function rn(){return se(nn)}function an({mode:e,connection:t,assistantId:n,existingNames:r,onSave:i,onCancel:a}){let[o,c]=(0,Z.useState)(t?.label??``),l=t?.name??``,d=t?.provider??`anthropic`,f=t?.auth.type??`api_key`,[p,m]=(0,Z.useState)(()=>t?.auth.type===`api_key`?t.auth.credential:t?``:`credential/anthropic/api_key`),[g,_]=(0,Z.useState)(t?.baseUrl??``),[v,y]=(0,Z.useState)(()=>t?.models?t.models.map(e=>e.id).join(`, `):``),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(null),w=d===`openai-compatible`,[T,E]=(0,Z.useState)(``),[D,O]=(0,Z.useState)(!1),k=u(),A=(0,Z.useMemo)(()=>et(p),[p]),M=f===`api_key`&&A!==null,{hasStoredCredential:P,isLoading:F}=bt({assistantId:n,credentialKind:`credential`,credentialName:A?`${A.service}:${A.field}`:``,enabled:M}),{credentials:I}=Fe({assistantId:n,enabled:f===`api_key`});(0,Z.useEffect)(()=>{let e=t?.provider??`anthropic`;c(t?.label??``),t?.auth.type===`api_key`?m(t.auth.credential):m(t?``:`credential/${e}/api_key`),C(null),_(t?.baseUrl??``),y(t?.models?t.models.map(e=>e.id).join(`, `):``),E(``),O(!1)},[t]);let L=l.trim().length>0;async function ee(){if(L){x(!0),C(null);try{let e;if(f===`api_key`){let t=p.trim()||`credential/${d}/api_key`,r=T.trim();if(r){O(!0);try{let e=et(t);await z({path:{assistant_id:n},body:e?{type:`credential`,name:`${e.service}:${e.field}`,value:r}:{type:`api_key`,name:d,value:r},throwOnError:!0});let i=Oe(n,`credential`,e?`${e.service}:${e.field}`:``);k.setQueryData(i,!0),k.invalidateQueries({queryKey:G({path:{assistant_id:n}})})}catch{C(`Failed to save API key. Please try again.`);return}finally{O(!1)}}e={type:`api_key`,credential:t}}else if(t)e=t.auth;else{C(`Nothing to edit. Close and try again.`);return}let r=o.trim()||null,a={auth:e,label:r,...w&&{base_url:g.trim()||null,models:v.trim()?v.split(`,`).map(e=>({id:e.trim()})).filter(e=>e.id):null}},{data:s,error:c,response:u}=await R({path:{assistant_id:n,name:t?.name??l.trim()},body:a});if(!u?.ok){C(Ue(u?.status,c)??Xe(u?.status));return}if(!s){C(`Server returned an empty response. Please try again.`);return}i(s)}catch{C(`Failed to save provider. Please try again.`)}finally{x(!1)}}}let B=I.filter(e=>e.service===d),te=e!==`create`&&t?.auth.type===`api_key`,V=B.length>0||te,H=Ne(`Enter your API key`,P);return e===`create`?(0,Q.jsx)(st,{variant:`modal`,assistantId:n,existingNames:r,defaultProviderType:d,onCreated:i,onCancel:a}):(0,Q.jsxs)(N.Content,{size:`md`,children:[(0,Q.jsxs)(N.Header,{children:[(0,Q.jsx)(N.Title,{children:`Edit Provider`}),(0,Q.jsx)(N.Description,{children:t?`Editing ${Ie(t)}.`:`Edit provider settings.`})]}),(0,Q.jsxs)(N.Body,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:[`Display Name`,` `,(0,Q.jsx)(`span`,{className:`text-[var(--content-disabled)]`,children:`(optional)`})]}),(0,Q.jsx)(j,{value:o,onChange:e=>c(e.target.value),placeholder:`e.g. My Anthropic Key`,fullWidth:!0})]}),w&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Base URL`}),(0,Q.jsx)(j,{value:g,onChange:e=>_(e.target.value),placeholder:`https://api.example.com/v1`,fullWidth:!0})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Models`}),(0,Q.jsx)(j,{value:v,onChange:e=>y(e.target.value),placeholder:`model-1, model-2`,fullWidth:!0}),(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:`Comma-separated model identifiers exposed by your endpoint.`})]})]}),f===`api_key`&&(0,Q.jsx)(Qe,{apiKeyValue:T,onApiKeyChange:E,credential:p,onCredentialChange:m,isLoadingCredential:F,apiKeyPlaceholder:H,provider:d,providerCredentials:B,showAdvancedSection:V,onError:C}),f===`oauth_subscription`&&(0,Q.jsx)(St,{assistantId:n,onConnected:i}),S&&(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:S})]}),(0,Q.jsxs)(N.Footer,{children:[(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,onClick:a,children:`Cancel`}),(0,Q.jsx)(s,{variant:`primary`,size:`compact`,disabled:!L||b||D,onClick:()=>void ee(),children:b?`Saving…`:`Save`})]})]})}var on={anthropic:!0,openai:!0,gemini:!0,fireworks:!0,openrouter:!0,vellum:!0};function sn(e){return e in on}function cn({isOpen:e,assistantId:t,onClose:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(null),s=u(),{data:c,isLoading:l,isError:f}=d({...W({path:{assistant_id:t}}),enabled:e}),p=rn(),{data:m}=d({...J({path:{assistant_id:t}}),enabled:e&&p}),h=(0,Z.useMemo)(()=>{let e=c?.connections??[];return[...e.filter(e=>e.provider===yt),...e.filter(e=>e.provider!==yt)]},[c]);function g(){s.invalidateQueries({queryKey:ie({path:{assistant_id:t}})}),s.invalidateQueries({queryKey:Y({path:{assistant_id:t}})})}function _(e){s.invalidateQueries({queryKey:U({path:{assistant_id:t}})}),i(!1),o(null)}let v=h.map(e=>e.name),y=()=>{i(!1),o(null)};return(0,Q.jsx)(N.Root,{open:e,onOpenChange:e=>{e||(r?y():n())},children:e?r?(0,Q.jsx)(an,{mode:a?`edit`:`create`,connection:a??void 0,assistantId:t,existingNames:v,onSave:_,onCancel:y}):(0,Q.jsx)(ln,{connections:h,loading:l,isError:f,assistantId:t,supportsDefaultProvider:p,defaultConnectionName:p?m?.resolvedConnectionName??null:null,onDefaultChanged:g,onClose:n,onEditClick:e=>{o(e),i(!0)},onNewClick:()=>{o(null),i(!0)},onConnectionDeleted:()=>{s.invalidateQueries({queryKey:U({path:{assistant_id:t}})})}}):null})}function ln({connections:e,loading:t,isError:n,assistantId:r,supportsDefaultProvider:i,defaultConnectionName:o,onDefaultChanged:c,onClose:l,onEditClick:u,onNewClick:d,onConnectionDeleted:p}){let[m,g]=(0,Z.useState)({}),[_,v]=(0,Z.useState)({}),y=f({...re(),onMutate:e=>{let t=e.body?.connectionName;t&&g(e=>{let n={...e};return delete n[t],n})},onSuccess:c,onError:(e,t)=>{a(e,{context:`settings-ai-set-default-provider`});let n=t.body?.connectionName;n&&g(e=>({...e,[n]:`Failed to set default provider. Please try again.`}))}});function b(e){sn(e.provider)&&y.mutate({path:{assistant_id:r},body:{provider:e.provider,connectionName:e.name}})}async function x(e){v(t=>({...t,[e]:!0})),g(t=>{let n={...t};return delete n[e],n});try{let{response:t}=await L({path:{assistant_id:r,name:e}});t?.ok||t?.status===404?p(e):t?.status===409?g(t=>({...t,[e]:`This provider is in use by a profile or as the default provider. Update those settings before deleting it.`})):g(t=>({...t,[e]:`Failed to delete provider. Please try again.`}))}catch{g(t=>({...t,[e]:`Failed to delete provider. Please try again.`}))}finally{v(t=>{let n={...t};return delete n[e],n})}}return(0,Q.jsxs)(N.Content,{size:`md`,children:[(0,Q.jsxs)(N.Header,{children:[(0,Q.jsx)(N.Title,{children:`Providers`}),(0,Q.jsx)(N.Description,{children:`Manage the model providers your assistant can use.`})]}),(0,Q.jsx)(N.Body,{children:t?(0,Q.jsx)(`div`,{className:`space-y-2 py-2`,children:[1,2,3].map(e=>(0,Q.jsx)(`div`,{className:`h-10 animate-pulse rounded-lg bg-[var(--surface-active)]`},e))}):n?(0,Q.jsx)(h,{variant:`body-medium-default`,as:`p`,className:`py-4 text-center text-(--system-negative-strong)`,children:`Failed to load providers. Please try again.`}):e.length===0?(0,Q.jsx)(h,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`No providers yet. Add one to get started.`}):(0,Q.jsx)(`div`,{className:`space-y-1`,children:e.map(e=>{let t=_[e.name]??!1,n=m[e.name],r=e.isManaged??!1,a=e.name===o,c=sn(e.provider),l=y.isPending&&y.variables?.body?.connectionName===e.name;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg px-2 py-2`,children:[(0,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(h,{variant:`body-medium-default`,as:`span`,className:`text-(--content-default)`,children:Ie(e)}),r&&(0,Q.jsx)(k,{tone:`positive`,title:`Managed by Platform — you can rename this provider, but not edit it.`,children:`Platform`}),a&&(0,Q.jsx)(k,{tone:`info`,title:`Built-in profiles (Balanced, Quality, Speed) use this provider.`,children:`Default`})]})}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[i&&!a&&(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,disabled:!c||l,title:c?`Use this provider for the built-in profiles.`:`Built-in profiles can't run on this provider.`,onClick:()=>b(e),children:`Set as default`}),!r&&(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,onClick:()=>u(e),children:`Edit`}),(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,iconOnly:(0,Q.jsx)(Tt,{}),"aria-label":`Delete ${Ie(e)}`,disabled:r||a||t,title:r?`The Vellum provider cannot be removed`:a?`This is your default provider. Set another provider as default first.`:void 0,onClick:()=>void x(e.name),tintColor:`var(--system-negative-strong)`})]})]}),n?(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`px-2 pb-1 text-(--system-negative-strong)`,children:n}):null]},e.name)})})}),(0,Q.jsxs)(N.Footer,{className:`justify-between`,children:[(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:d,children:`+ Add Provider`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:l,children:`Done`})]})]})}function un(e){let[t,n]=(0,Z.useState)(void 0);return(0,Z.useEffect)(()=>{t!==void 0&&e===t.value&&n(void 0)},[e,t]),[t===void 0?e:t.value,(0,Z.useCallback)(e=>n(e===void 0?void 0:{value:e}),[])]}function dn(){let e=Nt(),t=u(),{data:n}=d({...K({path:{assistant_id:e}}),staleTime:3e4}),r=rn(),{data:i,refetch:o}=d({...J({path:{assistant_id:e}}),enabled:r}),c=i?.availability,l=n?.llm?.activeProfile??null,f=n?.llm?.advisorProfile??null,p=n?.llm?.callSites??{},{profiles:m,profileOrder:g}=it(n?.llm,e),_=(0,Z.useMemo)(()=>dt(m,g),[m,g]),v=H({onSuccess:n=>{X(t,{path:{assistant_id:e}},n)}}),[y,b]=un(l),[x,S]=un(f),[C,w]=(0,Z.useState)(!1),[E,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(!1),j=(0,Z.useMemo)(()=>ut(_,[y]),[_,y]),M=(0,Z.useMemo)(()=>ut(_,[x]),[_,x]),N=Object.entries(p).filter(([e,t])=>e!==`mainAgent`&&(t?.profile!=null||t?.provider!=null||t?.model!=null)).length,F=N===1?`1 Override`:N>0?`${N} Overrides`:`Overrides`,L=y!==l,R=x!==f,z=(0,Z.useCallback)(async()=>{try{let t={};L&&(t.activeProfile=y),R&&(t.advisorProfile=x),await v.mutateAsync({path:{assistant_id:e},body:{llm:t}}),P.success(`Saved.`)}catch(e){P.error(`Failed to save. Please try again.`),a(e,{context:`settings-ai-language-model-save`})}},[L,R,y,x,v,e]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(zt,{title:`Language Model`,subtitle:`Configure the LLMs that power your assistant`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[c&&c.status!==`ok`&&(0,Q.jsx)(D,{tone:c.status===`unknown`?`warning`:`error`,children:c.message??`Your default provider is not available.`}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Default Profile`}),(0,Q.jsx)(I,{value:y??``,onChange:e=>{b(e===``?null:e)},placeholder:`Select a default profile…`,options:j.map(e=>({value:e.name,label:At(e)}))}),j.length===0?(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`mt-1 text-(--content-tertiary)`,children:`No profiles yet. Click Profiles below to create one.`}):null]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Advisor Profile`}),(0,Q.jsx)(I,{value:x??``,onChange:e=>{S(e===``?null:e)},placeholder:`Select an advisor profile…`,options:M.map(e=>({value:e.name,label:At(e)}))}),(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`mt-1 text-(--content-tertiary)`,children:`Which model your assistant consults for a second opinion`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>A(!0),children:`Providers`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>w(!0),children:`Profiles`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>O(!0),children:F})]}),(L||R)&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:z,disabled:v.isPending}),v.isPending&&(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`})]})]})}),e&&(0,Q.jsx)(en,{isOpen:C,assistantId:e,onClose:()=>w(!1)}),e&&(0,Q.jsx)(Jt,{isOpen:E,onClose:()=>O(!1),assistantId:e}),e&&(0,Q.jsx)(cn,{isOpen:k,assistantId:e,onClose:()=>{A(!1),r&&o()}})]})}function fn(){let e=Nt();return(0,Z.useCallback)(async(t,n)=>{try{let{data:r}=await z({path:{assistant_id:e},body:{value:n,type:`api_key`,name:t},throwOnError:!0});je(r)}catch(e){throw e instanceof Error&&e.message===`No assistant found`?P.error(`Assistant not ready. Please try again.`):P.error(`Failed to save ${t} API key. Please try again.`),a(e,{context:`provision_provider_key`}),e}},[e])}var pn=`0.10.12`;function mn(){return ce(pn)}function hn(){let e=Nt(),i=u(),o=de(),{data:s}=d({...K({path:{assistant_id:e}}),enabled:o,staleTime:3e4}),c=H({onSuccess:t=>{X(i,{path:{assistant_id:e}},t)}}),l=fn(),f=(0,Z.useMemo)(()=>{if(!s)return r(qe,`inference-provider-native`);let e=s.services?.[`web-search`];return(e?.mode===`managed`&&e?.provider!==`inference-provider-native`?`vellum`:e?.provider)||r(`vellum:ai:webSearchProvider`,`inference-provider-native`)},[s]),[p,m]=(0,Z.useState)(!1),[h,g]=un(f),[_,v]=(0,Z.useState)(``),y=Re.has(h),{hasStoredCredential:b}=bt({assistantId:e,credentialKind:`api_key`,credentialName:h,enabled:y}),x=_.trim().length>0,S=p||y&&!b&&!x||h===f&&!x,C=Ne(Ge[h]??`Enter your API key`,b),w=(0,Z.useCallback)(async()=>{m(!0);let t=_.trim(),r=ct(h),o=y&&t.length>0;try{o&&await l(h,t),await oe();let n=h===`vellum`?mn()?{provider:`vellum`,mode:`managed`}:{mode:`managed`}:{provider:h,mode:`your-own`};await c.mutateAsync({path:{assistant_id:e},body:{services:{"web-search":n}}}).catch(e=>{throw P.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e})}catch{m(!1);return}m(!1);try{if(n(qe,h),o){r&&n(r,t);let a=Oe(e,`api_key`,h);i.setQueryData(a,!0),i.invalidateQueries({queryKey:a}),v(``)}P.success(`Web search settings saved.`)}catch(e){a(e,{context:`settings-ai-web-search-persist-local`}),P.error(`Saved, but local preferences could not be written.`)}},[y,c,l,i,e,_,h]),E=(0,Z.useCallback)(()=>{let e=ct(h);e&&t(e),v(``),g(`inference-provider-native`),n(qe,`inference-provider-native`)},[h,g]);return(0,Q.jsx)(zt,{title:`Web Search`,subtitle:`Configure how your assistant should search the web`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(I,{"aria-label":`Web search provider`,value:h,onChange:g,options:Et.map(e=>({value:e,label:Ke[e]??e}))})]}),h===`vellum`&&(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Search runs through your Vellum account.`}),y&&(0,Q.jsx)(j,{label:`API Key`,type:`password`,value:_,onChange:e=>v(e.target.value),placeholder:C,fullWidth:!0}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:w,disabled:S}),p&&(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),y&&(0,Q.jsx)(Ht,{onClick:E,filled:!0})]})]})})}var gn=`default`;function _n(){let e=Nt(),i=u(),{data:o}=d({...K({path:{assistant_id:e}}),staleTime:3e4}),s=H({onSuccess:t=>{X(i,{path:{assistant_id:e}},t)}}),c=fn(),l=(0,Z.useMemo)(()=>o?o.services?.[`web-fetch`]?.provider||r(`vellum:ai:webFetchProvider`,gn):r(We,gn),[o]),[f,p]=(0,Z.useState)(!1),[m,h]=un(l),[g,_]=(0,Z.useState)(``),v=gt.has(m),{hasStoredCredential:y}=bt({assistantId:e,credentialKind:`api_key`,credentialName:m,enabled:v}),b=g.trim().length>0,x=f||v&&!y&&!b||m===l&&!b,S=Ne(nt[m]??`Enter your API key`,y),C=(0,Z.useCallback)(async()=>{p(!0);let t=g.trim(),r=v&&t.length>0;try{r&&await c(m,t),await s.mutateAsync({path:{assistant_id:e},body:{services:{"web-fetch":{provider:m}}}}).catch(e=>{throw P.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e})}catch{p(!1);return}p(!1);try{if(n(We,m),r){let r=Ve(m);r&&n(r,t);let a=Oe(e,`api_key`,m);i.setQueryData(a,!0),i.invalidateQueries({queryKey:a}),_(``)}P.success(`Web fetch settings saved.`)}catch(e){a(e,{context:`settings-ai-web-fetch-persist-local`}),P.error(`Saved, but local preferences could not be written.`)}},[v,s,c,i,e,g,m]),w=(0,Z.useCallback)(()=>{let e=Ve(m);e&&t(e),_(``),h(gn),n(We,gn)},[m,h]);return(0,Q.jsx)(zt,{id:`web-fetch`,title:`Web Fetch`,subtitle:`Configure how your assistant reads individual web pages`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(I,{value:m,onChange:h,options:_t.map(e=>({value:e,label:mt[e]??e}))})]}),v&&(0,Q.jsx)(j,{label:`API Key`,type:`password`,value:g,onChange:e=>_(e.target.value),placeholder:S,fullWidth:!0}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:C,disabled:x}),f&&(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),v&&(0,Q.jsx)(Ht,{onClick:w,filled:!0})]})]})})}function vn({subdomain:e,onSubdomainChange:t,domainSuffix:n,subdomainPlaceholder:r=`my-assistant`,disabled:i,autoFocus:a,prefix:o,error:s,locked:c,lockedMessage:l}){return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex h-9 w-full items-center rounded-md border bg-[var(--field-bg)] text-body-medium-lighter transition-[border-color] duration-150 ${s?`border-[var(--system-negative-strong)]`:`border-[var(--field-border)] focus-within:border-[var(--border-active)]`}`,children:[o,(0,Q.jsx)(`input`,{value:e,onChange:e=>t(e.target.value.toLowerCase().trim()),disabled:i||c,readOnly:c,autoFocus:a,placeholder:r,"aria-label":`Subdomain`,"aria-invalid":!!s,className:`h-full min-w-0 flex-1 bg-transparent ${o?`pl-1.5`:`pl-3`} pr-1 text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none disabled:cursor-not-allowed disabled:opacity-60`}),(0,Q.jsxs)(`span`,{className:`shrink-0 pr-3 font-mono text-[var(--content-secondary)]`,children:[`.`,n]})]}),s&&(0,Q.jsx)(`p`,{className:`mt-1.5 text-body-small-default text-[var(--system-negative-strong)]`,children:s}),c&&l&&(0,Q.jsx)(`p`,{className:`mt-1.5 text-body-small-default text-[var(--content-tertiary)]`,children:l})]})}function yn({assistantId:e,assistantHandle:t,emailRootDomain:n}){let r=u(),i=l(),[o,p]=c(),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(null),[E,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{g||!t||m||(h(t),_(!0))},[t,g,m]);let N=d({...pe(),enabled:!0}),I=N.data,L=I?.entitlements,R=L?.managed_email===!0,z=!!L&&!R,ee=!I&&N.isError&&!N.isFetching,B=d({...fe({path:{assistant_id:e}}),enabled:!z}),te=d({...xe({path:{assistant_id:e}}),enabled:!z}),V=B.data?.results?.[0],H=te.data?.results?.[0],ne=V?`${V.subdomain}.${n}`:null,U=d({..._e({path:{assistant_id:e,id:H?.id??``}}),enabled:!!H?.id,refetchOnWindowFocus:!1}),W=d({...Ce({path:{assistant_id:e,id:V?.id??``}}),enabled:!!V?.id,refetchInterval:e=>{let t=e.state.data?.status;return t===`verified`||t===`failed`?!1:1e4},refetchOnWindowFocus:!0});(0,Z.useEffect)(()=>{o.get(`release`)!==`1`||!V||H||(A(!0),p(e=>{let t=new URLSearchParams(e);return t.delete(`release`),t},{replace:!0}))},[H,V,o,p]);let G=f(be()),K=f(Se()),q=f(me()),J=f(he()),Y=(0,Z.useCallback)(()=>{let t={assistant_id:e};r.invalidateQueries({queryKey:ve({path:t})}),r.invalidateQueries({queryKey:ye({path:t})}),H?.id&&r.invalidateQueries({queryKey:ge({path:{...t,id:H.id}})}),r.invalidateQueries({queryKey:Te()})},[H?.id,e,r]),re=(0,Z.useCallback)(async()=>{let t=m.trim().toLowerCase();if(!t){y(`Enter a subdomain.`);return}O(!1);try{await G.mutateAsync({path:{assistant_id:e},body:{subdomain:t}}),h(``),y(null),Y(),P.success(`Domain ${t}.${n} registered.`)}catch(e){y(le(e,void 0,`Failed to register domain.`))}},[e,n,Y,G,m]),ie=(0,Z.useCallback)(async()=>{let t=b.trim().toLowerCase();if(!t){w(`Enter an email username.`);return}try{await q.mutateAsync({path:{assistant_id:e},body:{username:t}}),x(``),w(null),Y(),P.success(`Email address created.`)}catch(e){w(le(e,void 0,`Failed to create email address.`))}},[e,Y,q,b]),X=(0,Z.useCallback)(async()=>{if(H?.id){M(!1);try{await J.mutateAsync({path:{assistant_id:e,id:H.id}}),Y(),P.success(`Email address removed.`)}catch(e){a(e,{context:`email_address_delete`}),P.error(`Failed to remove email address.`)}}},[H?.id,e,J,Y]),ae=(0,Z.useCallback)(async()=>{if(!V?.id)return;if(H){P.error(`Remove the email address first.`);return}A(!1);let t=V.subdomain;try{await K.mutateAsync({path:{assistant_id:e,id:V.id}}),h(t),Y(),P.success(`Domain released.`)}catch(e){a(e,{context:`email_domain_release`}),P.error(`Failed to release domain.`)}},[H,e,K,V?.id,V?.subdomain,Y]);if(N.isLoading)return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin`}),`Checking subscription…`]});if(z)return(0,Q.jsxs)(D,{tone:`info`,icon:(0,Q.jsx)(S,{className:`h-4 w-4`,"aria-hidden":!0}),title:`Get a dedicated email address for your assistant`,actions:(0,Q.jsx)(s,{size:`compact`,onClick:()=>i(`${ue.settings.usage}?tab=billing&adjust_plan`),children:`Upgrade to Pro`}),children:[`Pro plans include a managed`,` `,`<your-subdomain>.${n}`,` inbox — no provider setup required. Or switch to `,(0,Q.jsx)(`strong`,{children:`Your Own`}),` to bring an existing provider.`]});let oe=ee?(0,Q.jsx)(D,{tone:`warning`,title:`Couldn't verify subscription status`,actions:(0,Q.jsx)(s,{size:`compact`,variant:`outlined`,onClick:()=>N.refetch(),children:`Retry`}),children:`We couldn't reach the billing service. The form below assumes managed email is enabled for your org — if it isn't, registering a domain will fail.`}):null;return V?H?(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[oe,(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Address`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:H.address}),(0,Q.jsx)(Vt,{status:W.data?.status,message:W.data?.message,isLoading:W.isLoading}),(0,Q.jsx)(s,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,Q.jsx)(Tt,{}),onClick:()=>M(!0),disabled:J.isPending,"aria-label":`Remove email address`})]}),(0,Q.jsx)(F,{open:j,title:`Remove Email Address`,message:(0,Q.jsxs)(Q.Fragment,{children:[`Are you sure you want to remove `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:H.address}),`? Your assistant will no longer be able to send or receive email at this address.`]}),confirmLabel:`Remove`,destructive:!0,onConfirm:X,onCancel:()=>M(!1)})]}),U.data?.usage&&(0,Q.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[U.data.usage.sent_today,` /`,` `,U.data.usage.daily_limit,` sent today ·`,` `,U.data.usage.received_today,` received`]})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[oe,(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Domain`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:[V.subdomain,`.`,n]}),(0,Q.jsx)(Vt,{status:W.data?.status,message:W.data?.message,isLoading:W.isLoading}),(0,Q.jsx)(s,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,Q.jsx)(Tt,{}),onClick:()=>A(!0),disabled:K.isPending,"aria-label":`Release domain`})]}),(0,Q.jsx)(F,{open:k,title:`Release Domain`,message:(0,Q.jsxs)(Q.Fragment,{children:[`Are you sure you want to release `,(0,Q.jsxs)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:[V.subdomain,`.`,n]}),`? The subdomain will become available for others to claim.`]}),confirmLabel:`Release`,destructive:!0,onConfirm:ae,onCancel:()=>A(!1)})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Email address`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex h-9 min-w-0 flex-1 items-center rounded-md border bg-[var(--field-bg)] text-body-medium-lighter transition-[border-color] duration-150 ${C?`border-[var(--system-negative-strong)]`:`border-[var(--field-border)] focus-within:border-[var(--border-active)]`}`,children:[(0,Q.jsx)(`input`,{value:b,onChange:e=>{x(e.target.value.toLowerCase()),C&&w(null)},placeholder:`hi`,"aria-label":`Email username`,"aria-invalid":!!C,className:`h-full min-w-0 flex-1 bg-transparent pl-3 pr-1 text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none`}),(0,Q.jsxs)(`span`,{className:`shrink-0 pr-3 font-mono text-[var(--content-secondary)]`,children:[`@`,ne]})]}),(0,Q.jsx)(s,{onClick:ie,disabled:q.isPending||!b.trim(),children:q.isPending?`Creating…`:`Create`})]}),C&&(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:C})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[oe,(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Subdomain`}),(0,Q.jsx)(vn,{subdomain:m,onSubdomainChange:e=>{h(e),v&&y(null)},domainSuffix:n,subdomainPlaceholder:`my-assistant`,error:v}),(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Each assistant gets its own subdomain. Lowercase letters, numbers, and hyphens only.`}),(0,Q.jsx)(s,{onClick:()=>O(!0),disabled:G.isPending||!m.trim(),children:G.isPending?`Registering…`:`Register`}),(0,Q.jsx)(F,{open:E,title:`Set Subdomain`,message:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:m.trim().toLowerCase()||`subdomain`}),` will also become your assistant's public handle. You won't be able to change it once set.`]}),confirmLabel:`Confirm`,onConfirm:re,onCancel:()=>O(!1)})]})}function bn(){let e=Nt(),t=de(),{data:o}=d({...we(),enabled:t}),s=o?.results?.[0]?.handle,c=Ft.use.emailRootDomain(),l=jt(),[u,f]=(0,Z.useState)(()=>l===`gated`?`your-own`:ft(r($e,`managed`),`managed`)),[p,m]=(0,Z.useState)(()=>{let e=r(Pe,`resend`);return e===`mailgun`||e===`resend`?e:`resend`}),h=d({queryKey:[`byoEmailCredential`,e,p],queryFn:async()=>{let{data:t}=await te({path:{assistant_id:e},body:{service:p,field:`api_key`},throwOnError:!0});return t},enabled:u===`your-own`||l===`gated`,staleTime:6e4,retry:i,meta:{errorContext:`byo_email_credential_check`}});(0,Z.useEffect)(()=>{h.error&&a(h.error,{context:`byo_email_credential_check`,bestEffort:!0})},[h.error]);let g=h.data?.hasSecret===!0,_=(0,Z.useCallback)(e=>{f(e),n($e,e)},[]),v=(0,Z.useCallback)(()=>{n(Pe,p),P.success(`Email settings saved.`)},[p]),y=(0,Z.useMemo)(()=>Mt.find(e=>e.id===p)??Mt[0],[p]),x=(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(w,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{children:[`Configure `,y.displayName,` via the assistant CLI: ask the assistant to run the`,` `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:y.setupSkill}),` `,`skill. It walks you through storing the API key, detecting the domain, and (optionally) wiring up an inbound webhook.`]}),(0,Q.jsxs)(`a`,{href:y.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Open `,y.displayName,(0,Q.jsx)(C,{className:`h-3 w-3`})]})]})]}),S=(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(I,{value:p,onChange:e=>{(e===`mailgun`||e===`resend`)&&m(e)},options:Mt.map(e=>({value:e.id,label:e.displayName}))})]}),g?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-[var(--system-positive-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-default)]`,children:[(0,Q.jsx)(b,{className:`h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`span`,{children:[y.displayName,` API key configured. To reconfigure, run the`,` `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:y.setupSkill}),` `,`skill.`]})]}),(0,Q.jsxs)(`a`,{href:y.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-body-small-default text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Open `,y.displayName,(0,Q.jsx)(C,{className:`h-3 w-3`})]})]}):x,(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsx)($,{onClick:v,disabled:!1})})]});return l===`gated`?(0,Q.jsx)(zt,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,children:S}):(0,Q.jsx)(Rt,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,mode:u,onModeChange:_,children:u===`managed`?(0,Q.jsx)(`div`,{className:`space-y-4`,children:l===`disabled`?(0,Q.jsx)(Be,{children:`Log in to the Vellum platform to manage email settings.`}):(0,Q.jsx)(yn,{assistantId:e,assistantHandle:s,emailRootDomain:c})}):S})}function xn(){let e=Nt(),t=u(),{data:i}=d({...K({path:{assistant_id:e}}),staleTime:3e4}),o=H({onSuccess:n=>{X(t,{path:{assistant_id:e}},n)}}),s=fn(),[c,l]=un((0,Z.useMemo)(()=>ft(i?i.services?.[`image-generation`]?.mode??r(`vellum:ai:imageGenMode`,`your-own`):r(Ct,`your-own`),`your-own`),[i])),[f,p]=(0,Z.useState)(()=>r(ke,`gemini-3.1-flash-image-preview`)),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(!1),v=(0,Z.useCallback)(async()=>{_(!0);let r=m.trim(),i=c===`your-own`&&r.length>0;try{i&&await s(pt(f),r),await o.mutateAsync({path:{assistant_id:e},body:{services:{"image-generation":{mode:c}}}}).catch(e=>{throw P.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e});try{await V({path:{assistant_id:e},body:{modelId:f},throwOnError:!0})}catch(e){throw P.error(`Failed to update image generation model. Please try again.`),a(e,{context:`set_image_gen_model`}),e}finally{t.invalidateQueries({queryKey:Y({path:{assistant_id:e}})})}}catch{_(!1);return}_(!1);try{n(Ct,c),n(ke,f),i&&h(``),P.success(`Image generation settings saved.`)}catch(e){a(e,{context:`settings-ai-image-gen-persist-local`}),P.error(`Saved, but local preferences could not be written.`)}},[m,c,f,e,o,s,t]),y=(0,Z.useCallback)(()=>{h(``),p(`gemini-3.1-flash-image-preview`),n(ke,`gemini-3.1-flash-image-preview`)},[]);return(0,Q.jsx)(Rt,{title:`Image Generation`,subtitle:`Configure which model your assistant uses to generate images`,mode:c,onModeChange:e=>l(e),children:c===`managed`?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Active Model`}),(0,Q.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,Q.jsx)(I,{className:`flex-1`,value:f,onChange:p,options:at.map(e=>({value:e,label:Me[e]??e}))}),(0,Q.jsx)($,{onClick:v,disabled:g}),g&&(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(j,{label:`API Key`,type:`password`,value:m,onChange:e=>h(e.target.value),placeholder:pt(f)===`openai`?`Enter your OpenAI API key`:`Enter your Gemini API key`,fullWidth:!0}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Active Model`}),(0,Q.jsx)(I,{value:f,onChange:p,options:at.map(e=>({value:e,label:Me[e]??e}))})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:v,disabled:g}),g&&(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),(0,Q.jsx)(Ht,{onClick:y})]})]})})}async function Sn(e){let{provider:t,apiKey:n,voiceId:r,text:i}=e;if(n.trim().length===0)return{kind:`error`,message:`Save an API key for this provider first.`};try{return t===`elevenlabs`?await Cn(n,r,i):t===`deepgram`?await wn(n,i):t===`fish-audio`?{kind:`unsupported`,message:`Fish Audio TTS is only supported in the desktop app today. Use ElevenLabs or Deepgram to test from the browser.`}:t===`xai`?{kind:`unsupported`,message:`xAI TTS is only supported in the desktop app today. Use ElevenLabs or Deepgram to test from the browser.`}:{kind:`unsupported`,message:`TTS testing for "${t}" is not supported from the browser yet.`}}catch(e){return{kind:`error`,message:e instanceof Error?e.message:`Failed to reach the TTS provider.`}}}async function Cn(e,t,n){let r=t.trim();if(r.length===0)return{kind:`error`,message:`Enter and save a Voice ID before testing ElevenLabs.`};let i=await fetch(`https://api.elevenlabs.io/v1/text-to-speech/${encodeURIComponent(r)}?output_format=mp3_44100_128`,{method:`POST`,headers:{"xi-api-key":e,"Content-Type":`application/json`,Accept:`audio/mpeg`},body:JSON.stringify({text:n,model_id:`eleven_turbo_v2_5`})});return i.ok?{kind:`audio`,blob:await i.blob()}:{kind:`error`,message:await Tn(i,`ElevenLabs rejected the request.`)}}async function wn(e,t){let n=await fetch(`https://api.deepgram.com/v1/speak?model=aura-2-thalia-en`,{method:`POST`,headers:{Authorization:`Token ${e}`,"Content-Type":`application/json`,Accept:`audio/mpeg`},body:JSON.stringify({text:t})});return n.ok?{kind:`audio`,blob:await n.blob()}:{kind:`error`,message:await Tn(n,`Deepgram rejected the request.`)}}async function Tn(e,t){try{let n=await e.text();if(n.length===0)return`${t} (HTTP ${e.status})`;try{let e=JSON.parse(n);if(e&&typeof e==`object`&&`detail`in e&&typeof e.detail==`string`)return e.detail;if(e&&typeof e==`object`&&`message`in e&&typeof e.message==`string`)return e.message}catch{}return n.slice(0,200)}catch{return`${t} (HTTP ${e.status})`}}function En({assistantId:e,value:t,onChange:n,className:r}){let[i,a]=(0,Z.useState)(!1),{voices:o}=rt(e);if(o.length===0)return null;let s=o.find(e=>e.model===t)??o[0];return(0,Q.jsxs)(A.Root,{open:i,onOpenChange:a,children:[(0,Q.jsx)(A.Trigger,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Voice`,className:m(`flex h-9 w-full items-center gap-2 rounded-md border border-[var(--field-border)] bg-[var(--field-bg)] px-3 text-left text-body-medium-lighter text-[var(--content-default)] transition-colors focus:outline-none data-[state=open]:border-[var(--border-active)]`,r),children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:s?vt(s.description):`Select a voice`}),(0,Q.jsx)(v,{className:`h-3.5 w-3.5 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0})]})}),(0,Q.jsx)(A.Content,{side:`bottom`,align:`start`,className:`w-[var(--radix-popover-trigger-width)] p-1`,children:(0,Q.jsx)(ht,{assistantId:e,value:t,onChange:n,onSelect:()=>a(!1),showSource:!0})})]})}var Dn={elevenlabs:`voiceId`,"fish-audio":`referenceId`,xai:`voiceId`};function On({assistantId:e,hideSaveButton:t=!1,hideCredentialsGuide:i=!1,onSaveStateChange:a}={}){let o=Nt(),c=e??o,l=ae.use.name()??`your assistant`,f=de(),p=u(),{data:m}=d({...ne({path:{assistant_id:c}}),enabled:f,staleTime:1/0}),h=(0,Z.useMemo)(()=>{let e=m?.providers;if(!e)return lt;if(e.some(e=>e.id===`vellum`))return e;let t=lt.find(e=>e.id===`vellum`);return t?[t,...e]:e},[m]),{data:g}=d({...K({path:{assistant_id:c}}),enabled:f,staleTime:3e4}),_=g?.services?.tts,v=_?.mode===`managed`?`vellum`:_?.provider,y=`elevenlabs`,b=(0,Z.useMemo)(()=>v??r(`vellum:voice:ttsProvider`,y),[v,y]),x=!!v,[S,C]=un(b),[w,T]=(0,Z.useState)(``),[E,D]=(0,Z.useState)(``),[O,k]=(0,Z.useState)(``),[A,M]=(0,Z.useState)(!1),[N,F]=(0,Z.useState)(!1),[L,R]=(0,Z.useState)(!1),{voices:z,defaultModel:te,fetched:V}=De(c,{enabled:S===`vellum`}),H=_?.providers?.vellum?.model??te??``,[U,W]=un(H),G=z.find(e=>e.model===U)??z[0],q=(0,Z.useMemo)(()=>h.find(e=>e.id===S)??h[0],[S,h]),J=S===`vellum`&&q.supportsVoiceSelection&&U!==H,re=(0,Z.useCallback)(e=>{let t=r(Ze+e,``),n=r(Le+e,``);M(t.length>0),D(n),k(n),T(``)},[]);(0,Z.useEffect)(()=>{re(S)},[S,re]);let ie=(0,Z.useMemo)(()=>{let e=S!==b,t=w.trim().length>0,n=E.trim()!==O;return e||t||n||J},[S,b,w,E,O,J]),X=(0,Z.useCallback)(async()=>{let e=w.trim(),t=E.trim(),i=q.id;n(tt,i),e.length>0&&n(Ze+i,e),n(Le+i,t);let a=e.length>0?e:r(Ze+i,``),o=Dn[i];R(!0);try{if(a.length>0){let{response:e}=await ee({path:{assistant_id:c},body:{service:i,field:`api_key`,value:a,label:`${q.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}let e={...S!==b||!x?{provider:i,mode:i===`vellum`?`managed`:`your-own`}:{},...o?{providers:{[i]:{[o]:t}}}:{},...J?{providers:{vellum:{model:U}}}:{}};if(Object.keys(e).length>0){let{response:t}=await B({path:{assistant_id:c},body:{services:{tts:e}},throwOnError:!1});if(!t?.ok)throw Error(`Failed to save configuration (HTTP ${t?.status??`?`})`)}return M(a.length>0),k(t),T(``),p.invalidateQueries({queryKey:Y({path:{assistant_id:c}})}),P.success(`Text-to-speech settings saved`),!0}catch(e){return P.error(e instanceof Error?e.message:`Failed to save text-to-speech settings`),!1}finally{R(!1)}},[c,S,U,J,w,E,q,b,x,p]);(0,Z.useEffect)(()=>{a?.({hasChanges:ie,saving:L,save:X})},[a,ie,L,X]);let oe=(0,Z.useCallback)(()=>{n(Ze+S,``),M(!1),T(``)},[S]),se=(0,Z.useCallback)(async()=>{F(!0);try{let e=r(Ze+S,``),t=w.trim(),n=t.length>0?t:e;if(n.length===0){P.error(`Save an API key for this provider before testing.`);return}let i=r(Le+S,``),a=E.trim(),o=await Sn({provider:S,apiKey:n,voiceId:a.length>0?a:i,text:`Hey! It's ${l}. How does this sound?`});if(o.kind!==`audio`){P.error(o.message);return}let s=URL.createObjectURL(o.blob);try{let e=new Audio(s);await e.play(),await new Promise(t=>{e.onended=()=>t(),e.onerror=()=>t()})}finally{URL.revokeObjectURL(s)}}finally{F(!1)}},[l,w,S,E]),ce=A?`•••••••• (Enter a new key to replace)`:q.apiKeyPlaceholder,le=S===`vellum`,ue=le&&q.supportsVoiceSelection;return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(I,{value:S,onChange:C,options:h.map(e=>({value:e.id,label:e.displayName})),"aria-label":`TTS provider`})]}),!le&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,Q.jsx)(j,{type:`password`,value:w,onChange:e=>T(e.target.value),placeholder:ce,fullWidth:!0})]}),ue&&G&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Voice`}),(0,Q.jsx)(En,{assistantId:c,value:U,onChange:W})]}),ue&&V&&!G&&(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`No managed voices are currently available.`}),q.supportsVoiceSelection&&!le&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Voice ID`}),(0,Q.jsx)(j,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:`Enter a voice ID`,fullWidth:!0})]}),!i&&!le&&(0,Q.jsx)(Ut,{guide:q.credentialsGuide}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!le&&(0,Q.jsx)(s,{variant:`outlined`,onClick:se,disabled:N,children:N?`Testing…`:`Test`}),(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[!t&&(0,Q.jsx)($,{onClick:X,disabled:!ie||L}),A&&!le&&(0,Q.jsx)(Ht,{onClick:oe})]})]})]})}function kn(){return(0,Q.jsx)(zt,{title:`Text-to-Speech`,subtitle:`Configure how your assistant speaks`,children:(0,Q.jsx)(On,{})})}var An={vellum:{provider:`vellum`},deepgram:{provider:`deepgram`,credentialService:`deepgram`},openai:{provider:`openai-whisper`,credentialService:`openai`}},jn={vellum:`vellum`,deepgram:`deepgram`,"openai-whisper":`openai`},Mn=`deepgram`;function Nn({assistantId:e,hideSaveButton:t=!1,hideCredentialsGuide:i=!1,onSaveStateChange:a}={}){let o=Nt(),s=e??o,c=de(),l=u(),[f]=(0,Z.useState)(()=>He.filter(e=>!e.requiresNativeDictation||ze())),p=Mn,{data:m}=d({...K({path:{assistant_id:s}}),enabled:c,staleTime:3e4}),h=m?.services?.stt,g=h?.mode===`managed`?`vellum`:h?.provider,_=(0,Z.useMemo)(()=>{let e=g?jn[g]:void 0;if(e&&f.some(t=>t.id===e))return e;let t=r(Ye,p);return f.some(e=>e.id===t)?t:p},[g,f,p]),v=!!g,[y,b]=un(_),[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(!1),[T,D]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{let e=r(Ye,p);e===`macos-native`&&!f.some(t=>t.id===e)&&n(Ye,p)},[f,p]);let O=(0,Z.useMemo)(()=>f.find(e=>e.id===y)??f[0],[f,y]),k=O.apiKeyPlaceholder!==void 0;(0,Z.useEffect)(()=>{w(r(xt+y,``).length>0),S(``)},[y]);let A=(0,Z.useMemo)(()=>{let e=y!==_,t=x.trim().length>0;return e||t},[y,_,x]),M=(0,Z.useCallback)(async()=>{let e=x.trim();n(Ye,y),e.length>0&&n(xt+y,e);let t=An[y];D(!0);try{if(t?.credentialService){let n=e.length>0?e:r(xt+y,``);if(n.length>0){let{response:e}=await ee({path:{assistant_id:s},body:{service:t.credentialService,field:`api_key`,value:n,label:`${O.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}}if(t&&(y!==_||!v)||g===`vellum`&&y!==`vellum`){let e=t?.provider??Mn,{response:n}=await B({path:{assistant_id:s},body:{services:{stt:{provider:e,mode:e===`vellum`?`managed`:`your-own`}}},throwOnError:!1});if(!n?.ok)throw Error(`Failed to save configuration (HTTP ${n?.status??`?`})`)}return e.length>0&&w(!0),S(``),l.invalidateQueries({queryKey:Y({path:{assistant_id:s}})}),P.success(`Speech-to-text settings saved`),!0}catch(e){return P.error(e instanceof Error?e.message:`Failed to save speech-to-text settings`),!1}finally{D(!1)}},[s,y,x,O,_,v,g,l]);(0,Z.useEffect)(()=>{a?.({hasChanges:A,saving:T,save:M})},[a,A,T,M]);let N=(0,Z.useCallback)(()=>{n(xt+y,``),w(!1),S(``)},[y]),F=C?`•••••••• (Enter a new key to replace)`:O.apiKeyPlaceholder;return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(I,{value:y,onChange:b,options:f.map(e=>({value:e.id,label:e.displayName})),"aria-label":`STT provider`})]}),k&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,Q.jsx)(j,{type:`password`,value:x,onChange:e=>S(e.target.value),placeholder:F,fullWidth:!0})]}),O.setupWarning&&(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(E,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-mid-strong)]`}),(0,Q.jsx)(`span`,{children:O.setupWarning})]}),!i&&O.credentialsGuide&&(0,Q.jsx)(Ut,{guide:O.credentialsGuide}),y===`vellum`&&(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Transcription runs through your Vellum account.`}),(!t||C)&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[!t&&(0,Q.jsx)($,{onClick:M,disabled:!A||T}),C&&(0,Q.jsx)(Ht,{onClick:N})]})]})}function Pn(){return(0,Q.jsx)(zt,{title:`Speech-to-Text`,subtitle:`Configure how your assistant transcribes speech`,children:(0,Q.jsx)(Nn,{})})}function Fn(){return(0,Z.useEffect)(()=>{let e=window.location.hash.slice(1);e&&requestAnimationFrame(()=>{document.getElementById(e)?.scrollIntoView({block:`start`})})},[]),(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.jsx)(Bt,{}),(0,Q.jsx)(dn,{}),(0,Q.jsx)(hn,{}),(0,Q.jsx)(_n,{}),(0,Q.jsx)(bn,{}),(0,Q.jsx)(xn,{}),(0,Q.jsx)(kn,{}),(0,Q.jsx)(Pn,{})]})}export{Fn as AiPage};
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{a as t,c as n,i as r}from"./local-settings-C-dW2vkq.js";import{r as i,t as a}from"./capture-error-EqyiBCqE.js";import{t as o}from"./react-DJZBPgpf.js";import{t as s}from"./button-BxZ6HzpA.js";import{m as c,u as l}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as u}from"./QueryClientProvider-DKhXIxGb.js";import{t as d}from"./useQuery-B45lW1Kk.js";import{t as f}from"./useMutation-Lj4VunQV.js";import{t as p}from"./jsx-runtime-CVSDxk6A.js";import{t as m}from"./cn-eDwV5N77.js";import{t as h}from"./typography-B_Zom8Gj.js";import{t as g}from"./createLucideIcon-IRfcSUxS.js";import{t as _}from"./check-DFNrQERi.js";import{t as v}from"./chevron-down-qD-re7AW.js";import{n as y,t as b}from"./circle-check-D3NSGpeC.js";import{t as x}from"./clock-DO_4QDAG.js";import{t as S}from"./crown-BJwJq0zQ.js";import{t as C}from"./external-link-CfkE0LZW.js";import{t as w}from"./info-BuIjW2mw.js";import{t as T}from"./loader-circle-CWO25Tky.js";import{t as E}from"./triangle-alert-BAgktlRD.js";import{t as D}from"./notice-Bd1rN4YY.js";import{j as O}from"./src-ChvLuWxs.js";import{t as k}from"./tag-D4RWxz2r.js";import{t as A}from"./popover-Cnk1lojt.js";import{t as j}from"./input-CGhuhT4R.js";import{t as M}from"./toggle-CvdrA_Wf.js";import{t as N}from"./modal-uxv7vVf7.js";import{n as P}from"./toast-CJSlHuX8.js";import{t as F}from"./confirm-dialog-BX77s7Gd.js";import{t as I}from"./dropdown-Dftxb_kj.js";import{Ut as L,Wt as R,ar as z,ft as ee,j as B,lt as te,wn as V}from"./sdk.gen-CPsr6ePr.js";import{Bt as H,Ft as ne,H as U,V as W,_t as G,c as K,d as q,f as J,l as Y,m as re,p as ie,u as X}from"./react-query.gen-BmvBFzUQ.js";import{t as ae}from"./assistant-identity-store-D_L4IJs-.js";import{i as oe,r as se,t as ce}from"./utils-CuIE4SGk.js";import{r as le}from"./api-errors-DNWYjUzX.js";import{u as ue}from"./routes-DN3K5OaW.js";import{t as de}from"./use-is-org-ready-DX9EbciC.js";import{c as fe,ct as pe,d as me,f as he,g as ge,h as _e,l as ve,m as ye,o as be,p as xe,s as Se,u as Ce,v as we,y as Te}from"./react-query.gen-BfXcRy9K.js";import{$i as Ee,$t as De,Ai as Oe,Ar as ke,B as Ae,Bi as je,Br as Me,Di as Ne,Dr as Pe,Ei as Fe,Fi as Ie,Fr as Le,Gi as Re,Gr as ze,H as Be,Hi as Ve,Hr as He,Ii as Ue,Ir as We,Ji as Ge,Ki as Ke,Lr as qe,Mi as Je,Mr as Ye,Ni as Xe,Nr as Ze,Oi as Qe,Or as $e,Pi as et,Pr as tt,Qi as nt,Qt as rt,R as it,Rr as at,Sa as ot,Ti as st,Ui as ct,Ur as lt,V as ut,Vi as dt,Wi as ft,Wr as pt,Xi as mt,Xt as ht,Yi as gt,Zi as _t,Zt as vt,ea as yt,ji as bt,jr as xt,ki as St,kr as Ct,na as wt,pa as Tt,qi as Et,ra as Dt,ta as Ot,wi as kt,z as At,zi as jt,zr as Mt}from"./index-DA-27U7J.js";import{t as Nt}from"./use-active-assistant-id-COiCJBSe.js";import{t as Pt}from"./detail-card-BO9_00mj.js";import{t as Ft}from"./environment-store-PamE9l4Q.js";var It=g(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),Z=e(o(),1),Q=p();function Lt({mode:e,onChange:t}){return(0,Q.jsx)(`div`,{className:`max-w-[280px]`,children:(0,Q.jsx)(O,{ariaLabel:`Service mode`,value:e,onChange:t,items:[{value:`managed`,label:`Managed`},{value:`your-own`,label:`Your Own`}]})})}function Rt({id:e,title:t,subtitle:n,mode:r,onModeChange:i,children:a}){return(0,Q.jsxs)(Pt,{id:e,title:t,subtitle:n,accessory:(0,Q.jsx)(Lt,{mode:r,onChange:i}),children:[(0,Q.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:a})]})}function zt({id:e,title:t,subtitle:n,children:r}){return(0,Q.jsxs)(Pt,{id:e,title:t,subtitle:n,children:[(0,Q.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:r})]})}function Bt(){return(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] px-4 py-2.5`,children:[(0,Q.jsx)(w,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,Q.jsxs)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:[`Managed services are metered and deducted from your Vellum account balance.`,` `,(0,Q.jsxs)(`a`,{href:`https://www.vellum.ai/docs/pricing`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--primary-base)] hover:underline`,children:[`View pricing`,(0,Q.jsx)(C,{className:`h-3.5 w-3.5`})]})]})]})}function Vt({status:e,message:t,isLoading:n}){return n?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2.5 py-0.5 text-body-small-default text-[var(--content-quiet)]`,children:[(0,Q.jsx)(T,{className:`h-3 w-3 animate-spin`}),`Checking domain…`]}):e?e===`verified`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-positive-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-positive-strong)]`,title:`DNS records have been verified. Your domain is ready to send and receive email.`,children:[(0,Q.jsx)(_,{className:`h-3 w-3`}),`Domain verified`]}):e===`pending`||e===`not_started`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-mid-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-mid-strong)]`,title:`DNS records have been provisioned. Waiting for the email provider to verify them — this usually takes a few minutes.`,children:[(0,Q.jsx)(x,{className:`h-3 w-3`}),`Verifying domain…`]}):(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-negative-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-negative-strong)]`,title:`Domain verification failed. DNS records may not have propagated correctly. You could try releasing and re-registering the domain.`,children:[(0,Q.jsx)(y,{className:`h-3 w-3`}),`Verification failed`]}):(0,Q.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2.5 py-0.5 text-body-small-default text-[var(--content-quiet)]`,title:`Unable to retrieve domain verification status.`,children:`Unknown status`})}function $({onClick:e,disabled:t}){return(0,Q.jsx)(s,{onClick:e,disabled:t,children:`Save`})}function Ht({onClick:e,filled:t=!1}){return(0,Q.jsx)(s,{variant:t?`danger`:`dangerGhost`,onClick:e,children:`Reset`})}function Ut({guide:e}){return(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(w,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{children:e.description}),(0,Q.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[e.linkLabel,(0,Q.jsx)(C,{className:`h-3 w-3`})]})]})]})}var Wt=`__custom__`;function Gt(e){return e?!!(e.profile||e.provider||e.model):!1}function Kt(e,t){let n=Gt(e);return n===Gt(t)?n?(e?.profile??null)===(t?.profile??null)&&(e?.provider??null)===(t?.provider??null)&&(e?.model??null)===(t?.model??null):!0:!1}function qt({id:e,displayName:t,description:n,defaultProfileLabel:r,draft:i,profileOptions:a,onDraftChange:o,onToggle:s}){let c=Gt(i),l=!i||!c?``:i.provider||i.model?Wt:i.profile??``,u=l===Wt,d=Je(),f=d[0]??Ee[0],p=d.find(e=>e===i?.provider)??f,m=Dt(p).map(e=>({value:e.id,label:e.displayName})),h=!!i?.provider&&!i?.model;function g(t){t===`__custom__`?o(e,{profile:null,provider:f,model:wt(f)??``}):t===``?o(e,null):o(e,{profile:t,provider:null,model:null})}function _(t){let n=wt(t)??``;o(e,{...i??{},profile:null,provider:t,model:n})}function v(t){o(e,{...i??{},model:t})}return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:t}),n&&(0,Q.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[n,r&&(0,Q.jsxs)(`span`,{className:`ml-1.5 text-body-small-default text-[var(--content-tertiary)] opacity-60`,children:[`· Default: `,r]})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[c&&(0,Q.jsx)(I,{value:l,onChange:g,options:a,className:`w-44`,menuMinWidth:280,menuAlign:`end`}),(0,Q.jsx)(M,{checked:c,onChange:t=>s(e,t),"aria-label":`Override ${t}`})]})]}),c&&u&&(0,Q.jsxs)(`div`,{className:`mt-3 space-y-2 border-t border-[var(--border-base)] pt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex-1`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(I,{value:p??``,onChange:_,options:d.map(e=>({value:e,label:Ot[e]??e}))})]}),(0,Q.jsxs)(`div`,{className:`flex-1`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Model`}),(0,Q.jsx)(I,{value:i?.model??``,onChange:v,options:m})]})]}),h&&(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:`Pick a model`})]})]})}function Jt({isOpen:e,onClose:t,assistantId:n}){let r=(0,Z.useRef)(!1);return(0,Q.jsx)(N.Root,{open:e,onOpenChange:e=>{!e&&!r.current&&t()},children:e?(0,Q.jsx)(Yt,{assistantId:n,onClose:t,onSavingChange:e=>{r.current=e}}):null})}function Yt({assistantId:e,onClose:t,onSavingChange:n}){let r=u(),{data:i}=d({...K({path:{assistant_id:e}}),staleTime:3e4}),o=(0,Z.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),c=(0,Z.useMemo)(()=>i?.llm?.profileOrder??[],[i?.llm?.profileOrder]),l=(0,Z.useMemo)(()=>i?.llm?.callSites??{},[i?.llm?.callSites]),f=(0,Z.useMemo)(()=>dt(o,c),[o,c]),p=Je(),m=H({onSuccess:t=>{X(r,{path:{assistant_id:e}},t)}}),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)({}),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),{data:E,isLoading:D,isError:O,refetch:k}=d({...q({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4,refetchOnWindowFocus:!1}),A=(0,Z.useMemo)(()=>(E?.callSites??[]).filter(e=>e.id!==`mainAgent`),[E]),M=!D&&!O&&!!E&&!!i,L=(0,Z.useMemo)(()=>A.map(e=>e.id),[A]),R=(0,Z.useMemo)(()=>{if(!M)return{};let e={};for(let t of L)if(t in y)e[t]=y[t];else{let n=l[t];e[t]=n?{...n}:{}}return e},[M,L,l,y]),z=(0,Z.useMemo)(()=>new Set(L),[L]),ee=(0,Z.useMemo)(()=>Object.entries(l).some(([e,t])=>z.has(e)&&(t?.profile!=null||t?.provider!=null||t?.model!=null)),[l,z]),B=(0,Z.useMemo)(()=>{if(!M)return!1;for(let e of Object.keys(R))if(!Kt(R[e],l[e]))return!0;return!1},[M,R,l]),te=(0,Z.useMemo)(()=>Object.values(R).some(e=>Gt(e)&&!!e?.provider&&!e?.model),[R]),V=(0,Z.useMemo)(()=>ut(f,[]).map(e=>({value:e.name,label:At(e)})),[f]),ne=(0,Z.useCallback)(()=>{if(!_)return;let e={};for(let t of L)e[t]={profile:_};b(e)},[_,L]),U=(0,Z.useCallback)(e=>[...ut(f,[e]).map(e=>({value:e.name,label:At(e)})),{value:Wt,label:`Custom`}],[f]),W=(0,Z.useMemo)(()=>{if(!h.trim())return A;let e=h.toLowerCase();return A.filter(t=>(t.displayName??``).toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)||(t.domain??``).toLowerCase().includes(e))},[A,h]),G=(0,Z.useMemo)(()=>{if(!E)return[];let e=E.domains.map(e=>e.id),t=new Map(E.domains.map(e=>[e.id,e])),n=[];for(let r of e){let e=W.filter(e=>e.domain===r);e.length>0&&n.push({domain:t.get(r),sites:e})}let r=new Set(e),i=W.filter(e=>!r.has(e.domain));return i.length>0&&n.push({domain:{id:`other`,displayName:`Other`},sites:i}),n},[E,W]),J=(0,Z.useCallback)((e,t)=>{b(n=>({...n,[e]:t}))},[]),Y=(0,Z.useCallback)((e,t)=>{if(!t){b(t=>({...t,[e]:null}));return}let n=Ae(f,A.find(t=>t.id===e)?.defaultProfile);if(n)b(t=>({...t,[e]:{profile:n}}));else{let t=p[0]??Ee[0],n=wt(t)??``;b(r=>({...r,[e]:{provider:t,model:n}}))}},[A,f,p]),re=(0,Z.useCallback)(async()=>{S(!0),n?.(!0);try{let n={};for(let e of Object.keys(R)){let t=R[e]??null;n[e]=Gt(t)?{profile:t?.profile??null,provider:t?.provider??null,model:t?.model??null}:null}await m.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:n}}}),t(),P.success(`Overrides saved.`)}catch(e){P.error(`Failed to save overrides. Please try again.`),a(e,{context:`call_site_overrides_save`})}finally{S(!1),n?.(!1)}},[R,t,m,n,e]),ie=(0,Z.useCallback)(async()=>{S(!0),n?.(!0);try{let n={};for(let e of Object.keys(R))n[e]=null;await m.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:n}}}),t(),P.success(`Overrides reset.`)}catch(e){P.error(`Failed to reset overrides. Please try again.`),a(e,{context:`call_site_overrides_reset`})}finally{S(!1),n?.(!1)}},[R,t,m,n,e]);return(0,Q.jsxs)(N.Content,{size:`lg`,hideCloseButton:!0,children:[(0,Q.jsxs)(N.Header,{children:[(0,Q.jsx)(N.Title,{children:`Action Overrides`}),(0,Q.jsx)(N.Description,{children:`Customize which model profile specific actions should use. Uses your default profile if no override is set.`})]}),(0,Q.jsxs)(N.Body,{children:[(0,Q.jsx)(`div`,{className:`mb-4`,children:(0,Q.jsx)(j,{type:`search`,value:h,onChange:e=>g(e.target.value),placeholder:`Search actions…`,leftIcon:(0,Q.jsx)(ot,{className:`h-4 w-4`}),fullWidth:!0})}),V.length>0&&(0,Q.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] p-3`,children:[(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 text-body-medium-default text-[var(--content-default)]`,children:`Use one profile for all actions`}),(0,Q.jsx)(I,{value:_,onChange:v,options:V,placeholder:`Choose profile…`,className:`w-44`,menuMinWidth:280,menuAlign:`end`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:ne,disabled:!_||!M||x,children:`Apply to all`})]}),D&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,Q.jsx)(T,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}),O&&(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-12 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Couldn't load actions`}),(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Make sure your assistant is running`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>void k(),children:`Retry`})]}),!D&&!O&&E&&(0,Q.jsx)(`div`,{className:`space-y-4`,children:G.length===0?(0,Q.jsx)(`p`,{className:`py-8 text-center text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No actions match your search.`}):G.map(({domain:e,sites:t})=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-body-small-default font-semibold uppercase tracking-wider text-[var(--content-tertiary)]`,children:e.displayName}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>{let t=(()=>{let t=R[e.id]??null;return!t||!Gt(t)?``:t.provider||t.model?`__custom__`:t.profile??``})(),n=e.defaultProfile?f.find(t=>t.name===e.defaultProfile)?.label??e.defaultProfile:null;return(0,Q.jsx)(qt,{id:e.id,displayName:e.displayName,description:e.description,defaultProfileLabel:n,draft:R[e.id]??null,profileOptions:U(t===``||t===`__custom__`?null:t),onDraftChange:J,onToggle:Y},e.id)})})]},e.id))})]}),(0,Q.jsxs)(N.Footer,{children:[ee&&(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>w(!0),disabled:x||!M,tintColor:`var(--system-negative-strong)`,className:`mr-auto`,children:`Reset to Defaults`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:t,disabled:x,children:`Cancel`}),(0,Q.jsx)(s,{variant:`primary`,size:`compact`,onClick:()=>void re(),disabled:!B||te||x,children:x?(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin`}):`Save`})]}),(0,Q.jsx)(F,{open:C,title:`Reset to Defaults`,message:`Every task override will be reset and will follow your active profile. This cannot be undone.`,confirmLabel:`Reset to Defaults`,destructive:!0,onConfirm:()=>{w(!1),ie()},onCancel:()=>w(!1)})]})}function Xt({blocked:e,availableReplacements:t,replacement:n,onReplacementChange:r,error:i,saving:a,onClose:o,onConfirm:c}){let l=``;if(e){let t=e.label||e.name;l=e.isActive&&e.callSiteIds.length>0?`"${t}" is the active profile and is used by ${e.callSiteIds.length} call site(s). Pick a replacement profile.`:e.isActive?`"${t}" is the active profile. Pick a different active profile before deleting, or select a replacement below.`:`"${t}" is used by ${e.callSiteIds.length} call site(s). Select a replacement profile to reassign them before deleting.`}return(0,Q.jsx)(N.Root,{open:e!==null,onOpenChange:e=>{e||o()},children:(0,Q.jsxs)(N.Content,{size:`sm`,children:[(0,Q.jsx)(N.Header,{children:(0,Q.jsx)(N.Title,{children:`Can't Delete Profile`})}),(0,Q.jsxs)(N.Body,{className:`space-y-4`,children:[(0,Q.jsx)(h,{variant:`body-medium-default`,as:`p`,children:l}),e&&e.callSiteIds.length>0&&(0,Q.jsx)(`ul`,{className:`space-y-1 pl-1`,children:e.callSiteIds.map(e=>(0,Q.jsxs)(`li`,{className:`text-body-small-default text-(--content-secondary)`,children:[`• `,(0,Q.jsx)(`code`,{children:e})]},e))}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Replacement profile`}),(0,Q.jsx)(I,{"aria-label":`Replacement profile`,value:n,onChange:r,options:[{value:``,label:`Select a replacement…`},...t.map(e=>({value:e.name,label:e.label??e.name}))]})]}),i&&(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:i})]}),(0,Q.jsxs)(N.Footer,{children:[(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,onClick:o,children:`Cancel`}),(0,Q.jsx)(s,{variant:`primary`,size:`compact`,disabled:!n||a,onClick:c,children:a?`Saving…`:`Reassign and Delete`})]})]})})}function Zt(e,t){if(e){let n=Dt(e).find(e=>e.id===t);if(n)return n.displayName}let n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t}function Qt(e,t){let n=[];e.description&&n.push(e.description);let r=e.provider_connection===`vellum`&&t?`vellum`:e.provider,i=[];if(e.model&&i.push(Zt(r,e.model)),r){let e=Ot[r]??r;i.push(`hosted by ${e}`)}return i.length>0&&n.push(i.join(` `)),n.join(` – `)}function $t({profile:e,vellumIsManaged:t,isDragging:n,dropTarget:r,isDeleting:i,deleteError:a,isToggling:o,onDragStart:c,onDragEnd:l,onDragOver:u,onDragLeave:d,onDrop:f,onEditClick:p,onDeleteClick:m,onStatusToggle:g}){let _=e.source===`managed`,v=e.invariant===!0,y=e.status!==`disabled`;return(0,Q.jsxs)(`div`,{className:`relative`,children:[r?.name===e.name&&!r.after&&(0,Q.jsx)(`div`,{className:`mx-0 h-0.5 rounded-full bg-[var(--border-active)]`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg pr-2 py-2${n?` opacity-50`:``}`,draggable:!_,onDragStart:c,onDragEnd:l,onDragOver:u,onDragLeave:d,onDrop:f,children:[(0,Q.jsx)(It,{className:`h-4 w-4 shrink-0 ${_?`invisible`:`cursor-grab text-[var(--content-tertiary)]`}`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1${y?``:` opacity-55`}`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(h,{variant:`body-medium-default`,as:`span`,className:`text-(--content-default)`,children:e.label??e.name}),_&&(0,Q.jsx)(k,{tone:`positive`,title:`Managed by Platform — this profile cannot be disabled, deleted, or renamed.`,children:`Platform`})]}),e.description||e.model||e.provider?(0,Q.jsx)(h,{variant:`body-medium-lighter`,as:`p`,className:`mt-0.5 text-(--content-tertiary)`,children:Qt(e,t)}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(!v||!y)&&(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center`,title:y?`Active — toggle to hide from pickers`:`Disabled — toggle to show in pickers`,children:(0,Q.jsx)(M,{checked:y,onChange:e=>g(e),disabled:o,"aria-label":`${y?`Disable`:`Enable`} ${e.label??e.name}`})}),(0,Q.jsxs)(`div`,{className:`flex w-[92px] items-center justify-end gap-2`,children:[(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,onClick:p,children:_||v?`View`:`Edit`}),(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,iconOnly:(0,Q.jsx)(Tt,{}),"aria-label":`Delete ${e.label??e.name}`,disabled:_||v||i,title:_||v?`Managed profiles cannot be deleted`:void 0,onClick:m,tintColor:`var(--system-negative-strong)`})]})]})]}),r?.name===e.name&&r.after&&(0,Q.jsx)(`div`,{className:`mx-0 h-0.5 rounded-full bg-[var(--border-active)]`}),a?(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`px-2 pb-1 text-(--system-negative-strong)`,children:a}):null]})}function en({isOpen:e,assistantId:t,onClose:n}){let r=u(),{data:i}=d({...K({path:{assistant_id:t}}),staleTime:3e4}),o=(0,Z.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),s=(0,Z.useMemo)(()=>i?.llm?.profileOrder??[],[i?.llm?.profileOrder]),c=i?.llm?.activeProfile??null,l=i?.llm?.callSites??{},f=(0,Z.useMemo)(()=>dt(o,s),[o,s]),p=H({onSuccess:e=>{X(r,{path:{assistant_id:t}},e)}}),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(null),{data:v}=d({...W({path:{assistant_id:t}}),enabled:e}),y=v?.connections,b=y?.some(e=>e.name===`vellum`&&e.provider===`vellum`)??!1,x=Object.keys(o);async function S(e,n,r){let i=r?.mode??`replace`,c=!(e in o);if(i===`merge`&&!c){await p.mutateAsync({path:{assistant_id:t},body:{llm:{profiles:{[e]:n}}}}),h(!1),_(null);return}let l={profiles:{[e]:n}};if(c&&(l.profileOrder=s.includes(e)?s:[...s,e]),c)await p.mutateAsync({path:{assistant_id:t},body:{llm:l}});else{let n=o[e];await p.mutateAsync({path:{assistant_id:t},body:{llm:{profiles:{[e]:null}}}});try{await p.mutateAsync({path:{assistant_id:t},body:{llm:l}})}catch(r){throw a(r,{context:`settings-ai-profile-edit-recreate`}),n!=null&&await p.mutateAsync({path:{assistant_id:t},body:{llm:{profiles:{[e]:n}}}}).catch(()=>{}),r}}c&&P.success(`Profile "${n.label??e}" created`),h(!1),_(null)}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(N.Root,{open:e,onOpenChange:e=>{e||n()},children:e?(0,Q.jsx)(tn,{assistantId:t,vellumIsManaged:b,profiles:o,profileOrder:s,orderedProfiles:f,activeProfile:c,callSiteOverrides:l,onClose:n,onEditClick:e=>{_(e),h(!0)},onNewClick:()=>{_(null),h(!0)}}):null}),(0,Q.jsx)(kt,{isOpen:m,mode:g?g.source===`managed`||g.invariant===!0?`view`:`edit`:`create`,profileName:g?.name,initialValues:g??void 0,existingNames:x,connections:y,assistantId:t,onSave:S,onCancel:()=>{h(!1),_(null)}})]})}function tn({assistantId:e,vellumIsManaged:t,profiles:n,profileOrder:r,orderedProfiles:i,activeProfile:o,callSiteOverrides:c,onClose:l,onEditClick:d,onNewClick:f}){let p=u(),m=H({onSuccess:t=>{X(p,{path:{assistant_id:e}},t)}}),[g,_]=(0,Z.useState)({}),[v,y]=(0,Z.useState)({}),[b,x]=(0,Z.useState)(new Set),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(null),[E,D]=(0,Z.useState)(null),[O,k]=(0,Z.useState)(null),A=(0,Z.useRef)(null),j=(0,Z.useRef)(null),[M,P]=(0,Z.useState)(null),[F,I]=(0,Z.useState)(null),[L,R]=(0,Z.useState)(``),[z,ee]=(0,Z.useState)(!1),B=(0,Z.useMemo)(()=>i,[i]);async function te(t,r){if(b.has(t.name))return!1;x(e=>new Set(e).add(t.name)),C(null);let i=r?`active`:`disabled`;if(!n[t.name])return x(e=>{let n=new Set(e);return n.delete(t.name),n}),!1;try{return await m.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[t.name]:{status:i}}}}}),!0}catch(e){return a(e,{context:`settings-ai-profile-toggle`}),C(`Couldn't update "${t.label??t.name}". Please try again.`),!1}finally{x(e=>{let n=new Set(e);return n.delete(t.name),n})}}async function V(t){y(e=>({...e,[t]:!0})),_(e=>{let n={...e};return delete n[t],n});try{let n=r.filter(e=>e!==t);await m.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[t]:null},profileOrder:n}}})}catch(e){a(e,{context:`settings-ai-profile-delete`}),_(e=>({...e,[t]:`Failed to delete profile. Please try again.`}))}finally{y(e=>{let n={...e};return delete n[t],n})}}function ne(e){let t=B.find(t=>t.name===e)?.label??e,n=e===o,r=Object.entries(c).filter(([t,n])=>t!==`mainAgent`&&n?.profile===e).map(([e])=>e);if(n||r.length>0){P({name:e,label:t,isActive:n,callSiteIds:r}),R(``),I(null);return}V(e)}async function U(){if(!M||!L)return;ee(!0),I(null);let t={};if(M.isActive&&(t.activeProfile=L),M.callSiteIds.length>0){let e={};for(let t of M.callSiteIds)e[t]={profile:L};t.callSites=e}if(Object.keys(t).length>0)try{await m.mutateAsync({path:{assistant_id:e},body:{llm:t}})}catch(e){a(e,{context:`settings-ai-profile-reassign-delete`}),I(`Failed to reassign references. Please try again.`),ee(!1);return}let n=M.name;P(null),ee(!1),V(n)}async function W(t,n){if(t===n.name)return;k(null);let i=r.filter(e=>e!==t),o=i.indexOf(n.name);if(o===-1)return;n.after&&(o+=1);let s=[...i.slice(0,o),t,...i.slice(o)];try{await m.mutateAsync({path:{assistant_id:e},body:{llm:{profileOrder:s}}})}catch(e){a(e,{context:`settings-ai-profile-reorder`}),k(`Failed to reorder profiles. Please try again.`)}}let G=B.filter(e=>e.name!==M?.name&&e.source!==`managed`),K=G.length>0?G:B.filter(e=>e.name!==M?.name);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(N.Content,{size:`md`,children:[(0,Q.jsxs)(N.Header,{children:[(0,Q.jsx)(N.Title,{children:`Model Profiles`}),(0,Q.jsx)(N.Description,{children:`Bundle a provider and model into a named profile. Assign profiles to specific actions or swap between them when chatting.`})]}),(0,Q.jsxs)(N.Body,{children:[B.length===0?(0,Q.jsx)(h,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`No profiles yet. Create one to get started.`}):(0,Q.jsx)(`div`,{className:`space-y-1`,children:B.map(e=>(0,Q.jsx)($t,{profile:e,vellumIsManaged:t,isDragging:w===e.name,dropTarget:E,isDeleting:v[e.name]??!1,deleteError:g[e.name],isToggling:b.has(e.name),onDragStart:t=>{A.current=e.name,T(e.name),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)},onDragEnd:()=>{A.current=null,j.current=null,T(null),D(null)},onDragOver:t=>{t.preventDefault();let n=t.currentTarget.getBoundingClientRect(),r=t.clientY>n.top+n.height/2,i={name:e.name,after:r};j.current=i,D(i)},onDragLeave:t=>{t.currentTarget.contains(t.relatedTarget)||(j.current=null,D(t=>t?.name===e.name?null:t))},onDrop:e=>{e.preventDefault();let t=A.current,n=j.current;A.current=null,j.current=null,T(null),D(null),t&&n&&W(t,n)},onEditClick:()=>d(e),onDeleteClick:()=>ne(e.name),onStatusToggle:t=>void te(e,t)},e.name))}),O&&(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`mt-2 text-(--system-negative-strong)`,children:O}),S&&(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`mt-2 text-(--system-negative-strong)`,children:S})]}),(0,Q.jsxs)(N.Footer,{className:`justify-between`,children:[(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:f,children:`+ New Profile`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:l,children:`Done`})]})]}),(0,Q.jsx)(Xt,{blocked:M,availableReplacements:K,replacement:L,onReplacementChange:R,error:F,saving:z,onClose:()=>{P(null),I(null)},onConfirm:()=>void U()})]})}var nn=`0.10.8`;function rn(){return se(nn)}function an({mode:e,connection:t,assistantId:n,existingNames:r,onSave:i,onCancel:a}){let[o,c]=(0,Z.useState)(t?.label??``),l=t?.name??``,d=t?.provider??`anthropic`,f=t?.auth.type??`api_key`,[p,m]=(0,Z.useState)(()=>t?.auth.type===`api_key`?t.auth.credential:t?``:`credential/anthropic/api_key`),[g,_]=(0,Z.useState)(t?.baseUrl??``),[v,y]=(0,Z.useState)(()=>t?.models?t.models.map(e=>e.id).join(`, `):``),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(null),w=d===`openai-compatible`,[T,E]=(0,Z.useState)(``),[D,O]=(0,Z.useState)(!1),k=u(),A=(0,Z.useMemo)(()=>et(p),[p]),M=f===`api_key`&&A!==null,{hasStoredCredential:P,isLoading:F}=bt({assistantId:n,credentialKind:`credential`,credentialName:A?`${A.service}:${A.field}`:``,enabled:M}),{credentials:I}=Fe({assistantId:n,enabled:f===`api_key`});(0,Z.useEffect)(()=>{let e=t?.provider??`anthropic`;c(t?.label??``),t?.auth.type===`api_key`?m(t.auth.credential):m(t?``:`credential/${e}/api_key`),C(null),_(t?.baseUrl??``),y(t?.models?t.models.map(e=>e.id).join(`, `):``),E(``),O(!1)},[t]);let L=l.trim().length>0;async function ee(){if(L){x(!0),C(null);try{let e;if(f===`api_key`){let t=p.trim()||`credential/${d}/api_key`,r=T.trim();if(r){O(!0);try{let e=et(t);await z({path:{assistant_id:n},body:e?{type:`credential`,name:`${e.service}:${e.field}`,value:r}:{type:`api_key`,name:d,value:r},throwOnError:!0});let i=Oe(n,`credential`,e?`${e.service}:${e.field}`:``);k.setQueryData(i,!0),k.invalidateQueries({queryKey:G({path:{assistant_id:n}})})}catch{C(`Failed to save API key. Please try again.`);return}finally{O(!1)}}e={type:`api_key`,credential:t}}else if(t)e=t.auth;else{C(`Nothing to edit. Close and try again.`);return}let r=o.trim()||null,a={auth:e,label:r,...w&&{base_url:g.trim()||null,models:v.trim()?v.split(`,`).map(e=>({id:e.trim()})).filter(e=>e.id):null}},{data:s,error:c,response:u}=await R({path:{assistant_id:n,name:t?.name??l.trim()},body:a});if(!u?.ok){C(Ue(u?.status,c)??Xe(u?.status));return}if(!s){C(`Server returned an empty response. Please try again.`);return}i(s)}catch{C(`Failed to save provider. Please try again.`)}finally{x(!1)}}}let B=I.filter(e=>e.service===d),te=e!==`create`&&t?.auth.type===`api_key`,V=B.length>0||te,H=Ne(`Enter your API key`,P);return e===`create`?(0,Q.jsx)(st,{variant:`modal`,assistantId:n,existingNames:r,defaultProviderType:d,onCreated:i,onCancel:a}):(0,Q.jsxs)(N.Content,{size:`md`,children:[(0,Q.jsxs)(N.Header,{children:[(0,Q.jsx)(N.Title,{children:`Edit Provider`}),(0,Q.jsx)(N.Description,{children:t?`Editing ${Ie(t)}.`:`Edit provider settings.`})]}),(0,Q.jsxs)(N.Body,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:[`Display Name`,` `,(0,Q.jsx)(`span`,{className:`text-[var(--content-disabled)]`,children:`(optional)`})]}),(0,Q.jsx)(j,{value:o,onChange:e=>c(e.target.value),placeholder:`e.g. My Anthropic Key`,fullWidth:!0})]}),w&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Base URL`}),(0,Q.jsx)(j,{value:g,onChange:e=>_(e.target.value),placeholder:`https://api.example.com/v1`,fullWidth:!0})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Models`}),(0,Q.jsx)(j,{value:v,onChange:e=>y(e.target.value),placeholder:`model-1, model-2`,fullWidth:!0}),(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:`Comma-separated model identifiers exposed by your endpoint.`})]})]}),f===`api_key`&&(0,Q.jsx)(Qe,{apiKeyValue:T,onApiKeyChange:E,credential:p,onCredentialChange:m,isLoadingCredential:F,apiKeyPlaceholder:H,provider:d,providerCredentials:B,showAdvancedSection:V,onError:C}),f===`oauth_subscription`&&(0,Q.jsx)(St,{assistantId:n,onConnected:i}),S&&(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:S})]}),(0,Q.jsxs)(N.Footer,{children:[(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,onClick:a,children:`Cancel`}),(0,Q.jsx)(s,{variant:`primary`,size:`compact`,disabled:!L||b||D,onClick:()=>void ee(),children:b?`Saving…`:`Save`})]})]})}var on={anthropic:!0,openai:!0,gemini:!0,fireworks:!0,openrouter:!0,vellum:!0};function sn(e){return e in on}function cn({isOpen:e,assistantId:t,onClose:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(null),s=u(),{data:c,isLoading:l,isError:f}=d({...W({path:{assistant_id:t}}),enabled:e}),p=rn(),{data:m}=d({...J({path:{assistant_id:t}}),enabled:e&&p}),h=(0,Z.useMemo)(()=>{let e=c?.connections??[];return[...e.filter(e=>e.provider===yt),...e.filter(e=>e.provider!==yt)]},[c]);function g(){s.invalidateQueries({queryKey:ie({path:{assistant_id:t}})}),s.invalidateQueries({queryKey:Y({path:{assistant_id:t}})})}function _(e){s.invalidateQueries({queryKey:U({path:{assistant_id:t}})}),i(!1),o(null)}let v=h.map(e=>e.name),y=()=>{i(!1),o(null)};return(0,Q.jsx)(N.Root,{open:e,onOpenChange:e=>{e||(r?y():n())},children:e?r?(0,Q.jsx)(an,{mode:a?`edit`:`create`,connection:a??void 0,assistantId:t,existingNames:v,onSave:_,onCancel:y}):(0,Q.jsx)(ln,{connections:h,loading:l,isError:f,assistantId:t,supportsDefaultProvider:p,defaultConnectionName:p?m?.resolvedConnectionName??null:null,onDefaultChanged:g,onClose:n,onEditClick:e=>{o(e),i(!0)},onNewClick:()=>{o(null),i(!0)},onConnectionDeleted:()=>{s.invalidateQueries({queryKey:U({path:{assistant_id:t}})})}}):null})}function ln({connections:e,loading:t,isError:n,assistantId:r,supportsDefaultProvider:i,defaultConnectionName:o,onDefaultChanged:c,onClose:l,onEditClick:u,onNewClick:d,onConnectionDeleted:p}){let[m,g]=(0,Z.useState)({}),[_,v]=(0,Z.useState)({}),y=f({...re(),onMutate:e=>{let t=e.body?.connectionName;t&&g(e=>{let n={...e};return delete n[t],n})},onSuccess:c,onError:(e,t)=>{a(e,{context:`settings-ai-set-default-provider`});let n=t.body?.connectionName;n&&g(e=>({...e,[n]:`Failed to set default provider. Please try again.`}))}});function b(e){sn(e.provider)&&y.mutate({path:{assistant_id:r},body:{provider:e.provider,connectionName:e.name}})}async function x(e){v(t=>({...t,[e]:!0})),g(t=>{let n={...t};return delete n[e],n});try{let{response:t}=await L({path:{assistant_id:r,name:e}});t?.ok||t?.status===404?p(e):t?.status===409?g(t=>({...t,[e]:`This provider is in use by a profile or as the default provider. Update those settings before deleting it.`})):g(t=>({...t,[e]:`Failed to delete provider. Please try again.`}))}catch{g(t=>({...t,[e]:`Failed to delete provider. Please try again.`}))}finally{v(t=>{let n={...t};return delete n[e],n})}}return(0,Q.jsxs)(N.Content,{size:`md`,children:[(0,Q.jsxs)(N.Header,{children:[(0,Q.jsx)(N.Title,{children:`Providers`}),(0,Q.jsx)(N.Description,{children:`Manage the model providers your assistant can use.`})]}),(0,Q.jsx)(N.Body,{children:t?(0,Q.jsx)(`div`,{className:`space-y-2 py-2`,children:[1,2,3].map(e=>(0,Q.jsx)(`div`,{className:`h-10 animate-pulse rounded-lg bg-[var(--surface-active)]`},e))}):n?(0,Q.jsx)(h,{variant:`body-medium-default`,as:`p`,className:`py-4 text-center text-(--system-negative-strong)`,children:`Failed to load providers. Please try again.`}):e.length===0?(0,Q.jsx)(h,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`No providers yet. Add one to get started.`}):(0,Q.jsx)(`div`,{className:`space-y-1`,children:e.map(e=>{let t=_[e.name]??!1,n=m[e.name],r=e.isManaged??!1,a=e.name===o,c=sn(e.provider),l=y.isPending&&y.variables?.body?.connectionName===e.name;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg px-2 py-2`,children:[(0,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(h,{variant:`body-medium-default`,as:`span`,className:`text-(--content-default)`,children:Ie(e)}),r&&(0,Q.jsx)(k,{tone:`positive`,title:`Managed by Platform — you can rename this provider, but not edit it.`,children:`Platform`}),a&&(0,Q.jsx)(k,{tone:`info`,title:`Built-in profiles (Balanced, Quality, Speed) use this provider.`,children:`Default`})]})}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[i&&!a&&(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,disabled:!c||l,title:c?`Use this provider for the built-in profiles.`:`Built-in profiles can't run on this provider.`,onClick:()=>b(e),children:`Set as default`}),!r&&(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,onClick:()=>u(e),children:`Edit`}),(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,iconOnly:(0,Q.jsx)(Tt,{}),"aria-label":`Delete ${Ie(e)}`,disabled:r||a||t,title:r?`The Vellum provider cannot be removed`:a?`This is your default provider. Set another provider as default first.`:void 0,onClick:()=>void x(e.name),tintColor:`var(--system-negative-strong)`})]})]}),n?(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`px-2 pb-1 text-(--system-negative-strong)`,children:n}):null]},e.name)})})}),(0,Q.jsxs)(N.Footer,{className:`justify-between`,children:[(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:d,children:`+ Add Provider`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:l,children:`Done`})]})]})}function un(e){let[t,n]=(0,Z.useState)(void 0);return(0,Z.useEffect)(()=>{t!==void 0&&e===t.value&&n(void 0)},[e,t]),[t===void 0?e:t.value,(0,Z.useCallback)(e=>n(e===void 0?void 0:{value:e}),[])]}function dn(){let e=Nt(),t=u(),{data:n}=d({...K({path:{assistant_id:e}}),staleTime:3e4}),r=rn(),{data:i,refetch:o}=d({...J({path:{assistant_id:e}}),enabled:r}),c=i?.availability,l=n?.llm?.activeProfile??null,f=n?.llm?.advisorProfile??null,p=n?.llm?.callSites??{},{profiles:m,profileOrder:g}=it(n?.llm,e),_=(0,Z.useMemo)(()=>dt(m,g),[m,g]),v=H({onSuccess:n=>{X(t,{path:{assistant_id:e}},n)}}),[y,b]=un(l),[x,S]=un(f),[C,w]=(0,Z.useState)(!1),[E,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(!1),j=(0,Z.useMemo)(()=>ut(_,[y]),[_,y]),M=(0,Z.useMemo)(()=>ut(_,[x]),[_,x]),N=Object.entries(p).filter(([e,t])=>e!==`mainAgent`&&(t?.profile!=null||t?.provider!=null||t?.model!=null)).length,F=N===1?`1 Override`:N>0?`${N} Overrides`:`Overrides`,L=y!==l,R=x!==f,z=(0,Z.useCallback)(async()=>{try{let t={};L&&(t.activeProfile=y),R&&(t.advisorProfile=x),await v.mutateAsync({path:{assistant_id:e},body:{llm:t}}),P.success(`Saved.`)}catch(e){P.error(`Failed to save. Please try again.`),a(e,{context:`settings-ai-language-model-save`})}},[L,R,y,x,v,e]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(zt,{title:`Language Model`,subtitle:`Configure the LLMs that power your assistant`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[c&&c.status!==`ok`&&(0,Q.jsx)(D,{tone:c.status===`unknown`?`warning`:`error`,children:c.message??`Your default provider is not available.`}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Default Profile`}),(0,Q.jsx)(I,{value:y??``,onChange:e=>{b(e===``?null:e)},placeholder:`Select a default profile…`,options:j.map(e=>({value:e.name,label:At(e)}))}),j.length===0?(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`mt-1 text-(--content-tertiary)`,children:`No profiles yet. Click Profiles below to create one.`}):null]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Advisor Profile`}),(0,Q.jsx)(I,{value:x??``,onChange:e=>{S(e===``?null:e)},placeholder:`Select an advisor profile…`,options:M.map(e=>({value:e.name,label:At(e)}))}),(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`mt-1 text-(--content-tertiary)`,children:`Which model your assistant consults for a second opinion`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>A(!0),children:`Providers`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>w(!0),children:`Profiles`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>O(!0),children:F})]}),(L||R)&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:z,disabled:v.isPending}),v.isPending&&(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`})]})]})}),e&&(0,Q.jsx)(en,{isOpen:C,assistantId:e,onClose:()=>w(!1)}),e&&(0,Q.jsx)(Jt,{isOpen:E,onClose:()=>O(!1),assistantId:e}),e&&(0,Q.jsx)(cn,{isOpen:k,assistantId:e,onClose:()=>{A(!1),r&&o()}})]})}function fn(){let e=Nt();return(0,Z.useCallback)(async(t,n)=>{try{let{data:r}=await z({path:{assistant_id:e},body:{value:n,type:`api_key`,name:t},throwOnError:!0});je(r)}catch(e){throw e instanceof Error&&e.message===`No assistant found`?P.error(`Assistant not ready. Please try again.`):P.error(`Failed to save ${t} API key. Please try again.`),a(e,{context:`provision_provider_key`}),e}},[e])}var pn=`0.10.12`;function mn(){return ce(pn)}function hn(){let e=Nt(),i=u(),o=de(),{data:s}=d({...K({path:{assistant_id:e}}),enabled:o,staleTime:3e4}),c=H({onSuccess:t=>{X(i,{path:{assistant_id:e}},t)}}),l=fn(),f=(0,Z.useMemo)(()=>{if(!s)return r(qe,`inference-provider-native`);let e=s.services?.[`web-search`];return(e?.mode===`managed`&&e?.provider!==`inference-provider-native`?`vellum`:e?.provider)||r(`vellum:ai:webSearchProvider`,`inference-provider-native`)},[s]),[p,m]=(0,Z.useState)(!1),[h,g]=un(f),[_,v]=(0,Z.useState)(``),y=Re.has(h),{hasStoredCredential:b}=bt({assistantId:e,credentialKind:`api_key`,credentialName:h,enabled:y}),x=_.trim().length>0,S=p||y&&!b&&!x||h===f&&!x,C=Ne(Ge[h]??`Enter your API key`,b),w=(0,Z.useCallback)(async()=>{m(!0);let t=_.trim(),r=ct(h),o=y&&t.length>0;try{o&&await l(h,t),await oe();let n=h===`vellum`?mn()?{provider:`vellum`,mode:`managed`}:{mode:`managed`}:{provider:h,mode:`your-own`};await c.mutateAsync({path:{assistant_id:e},body:{services:{"web-search":n}}}).catch(e=>{throw P.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e})}catch{m(!1);return}m(!1);try{if(n(qe,h),o){r&&n(r,t);let a=Oe(e,`api_key`,h);i.setQueryData(a,!0),i.invalidateQueries({queryKey:a}),v(``)}P.success(`Web search settings saved.`)}catch(e){a(e,{context:`settings-ai-web-search-persist-local`}),P.error(`Saved, but local preferences could not be written.`)}},[y,c,l,i,e,_,h]),E=(0,Z.useCallback)(()=>{let e=ct(h);e&&t(e),v(``),g(`inference-provider-native`),n(qe,`inference-provider-native`)},[h,g]);return(0,Q.jsx)(zt,{title:`Web Search`,subtitle:`Configure how your assistant should search the web`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(I,{"aria-label":`Web search provider`,value:h,onChange:g,options:Et.map(e=>({value:e,label:Ke[e]??e}))})]}),h===`vellum`&&(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Search runs through your Vellum account.`}),y&&(0,Q.jsx)(j,{label:`API Key`,type:`password`,value:_,onChange:e=>v(e.target.value),placeholder:C,fullWidth:!0}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:w,disabled:S}),p&&(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),y&&(0,Q.jsx)(Ht,{onClick:E,filled:!0})]})]})})}var gn=`default`;function _n(){let e=Nt(),i=u(),{data:o}=d({...K({path:{assistant_id:e}}),staleTime:3e4}),s=H({onSuccess:t=>{X(i,{path:{assistant_id:e}},t)}}),c=fn(),l=(0,Z.useMemo)(()=>o?o.services?.[`web-fetch`]?.provider||r(`vellum:ai:webFetchProvider`,gn):r(We,gn),[o]),[f,p]=(0,Z.useState)(!1),[m,h]=un(l),[g,_]=(0,Z.useState)(``),v=gt.has(m),{hasStoredCredential:y}=bt({assistantId:e,credentialKind:`api_key`,credentialName:m,enabled:v}),b=g.trim().length>0,x=f||v&&!y&&!b||m===l&&!b,S=Ne(nt[m]??`Enter your API key`,y),C=(0,Z.useCallback)(async()=>{p(!0);let t=g.trim(),r=v&&t.length>0;try{r&&await c(m,t),await s.mutateAsync({path:{assistant_id:e},body:{services:{"web-fetch":{provider:m}}}}).catch(e=>{throw P.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e})}catch{p(!1);return}p(!1);try{if(n(We,m),r){let r=Ve(m);r&&n(r,t);let a=Oe(e,`api_key`,m);i.setQueryData(a,!0),i.invalidateQueries({queryKey:a}),_(``)}P.success(`Web fetch settings saved.`)}catch(e){a(e,{context:`settings-ai-web-fetch-persist-local`}),P.error(`Saved, but local preferences could not be written.`)}},[v,s,c,i,e,g,m]),w=(0,Z.useCallback)(()=>{let e=Ve(m);e&&t(e),_(``),h(gn),n(We,gn)},[m,h]);return(0,Q.jsx)(zt,{id:`web-fetch`,title:`Web Fetch`,subtitle:`Configure how your assistant reads individual web pages`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(I,{value:m,onChange:h,options:_t.map(e=>({value:e,label:mt[e]??e}))})]}),v&&(0,Q.jsx)(j,{label:`API Key`,type:`password`,value:g,onChange:e=>_(e.target.value),placeholder:S,fullWidth:!0}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:C,disabled:x}),f&&(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),v&&(0,Q.jsx)(Ht,{onClick:w,filled:!0})]})]})})}function vn({subdomain:e,onSubdomainChange:t,domainSuffix:n,subdomainPlaceholder:r=`my-assistant`,disabled:i,autoFocus:a,prefix:o,error:s,locked:c,lockedMessage:l}){return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex h-9 w-full items-center rounded-md border bg-[var(--field-bg)] text-body-medium-lighter transition-[border-color] duration-150 ${s?`border-[var(--system-negative-strong)]`:`border-[var(--field-border)] focus-within:border-[var(--border-active)]`}`,children:[o,(0,Q.jsx)(`input`,{value:e,onChange:e=>t(e.target.value.toLowerCase().trim()),disabled:i||c,readOnly:c,autoFocus:a,placeholder:r,"aria-label":`Subdomain`,"aria-invalid":!!s,className:`h-full min-w-0 flex-1 bg-transparent ${o?`pl-1.5`:`pl-3`} pr-1 text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none disabled:cursor-not-allowed disabled:opacity-60`}),(0,Q.jsxs)(`span`,{className:`shrink-0 pr-3 font-mono text-[var(--content-secondary)]`,children:[`.`,n]})]}),s&&(0,Q.jsx)(`p`,{className:`mt-1.5 text-body-small-default text-[var(--system-negative-strong)]`,children:s}),c&&l&&(0,Q.jsx)(`p`,{className:`mt-1.5 text-body-small-default text-[var(--content-tertiary)]`,children:l})]})}function yn({assistantId:e,assistantHandle:t,emailRootDomain:n}){let r=u(),i=l(),[o,p]=c(),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(null),[E,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{g||!t||m||(h(t),_(!0))},[t,g,m]);let N=d({...pe(),enabled:!0}),I=N.data,L=I?.entitlements,R=L?.managed_email===!0,z=!!L&&!R,ee=!I&&N.isError&&!N.isFetching,B=d({...fe({path:{assistant_id:e}}),enabled:!z}),te=d({...xe({path:{assistant_id:e}}),enabled:!z}),V=B.data?.results?.[0],H=te.data?.results?.[0],ne=V?`${V.subdomain}.${n}`:null,U=d({..._e({path:{assistant_id:e,id:H?.id??``}}),enabled:!!H?.id,refetchOnWindowFocus:!1}),W=d({...Ce({path:{assistant_id:e,id:V?.id??``}}),enabled:!!V?.id,refetchInterval:e=>{let t=e.state.data?.status;return t===`verified`||t===`failed`?!1:1e4},refetchOnWindowFocus:!0});(0,Z.useEffect)(()=>{o.get(`release`)!==`1`||!V||H||(A(!0),p(e=>{let t=new URLSearchParams(e);return t.delete(`release`),t},{replace:!0}))},[H,V,o,p]);let G=f(be()),K=f(Se()),q=f(me()),J=f(he()),Y=(0,Z.useCallback)(()=>{let t={assistant_id:e};r.invalidateQueries({queryKey:ve({path:t})}),r.invalidateQueries({queryKey:ye({path:t})}),H?.id&&r.invalidateQueries({queryKey:ge({path:{...t,id:H.id}})}),r.invalidateQueries({queryKey:Te()})},[H?.id,e,r]),re=(0,Z.useCallback)(async()=>{let t=m.trim().toLowerCase();if(!t){y(`Enter a subdomain.`);return}O(!1);try{await G.mutateAsync({path:{assistant_id:e},body:{subdomain:t}}),h(``),y(null),Y(),P.success(`Domain ${t}.${n} registered.`)}catch(e){y(le(e,void 0,`Failed to register domain.`))}},[e,n,Y,G,m]),ie=(0,Z.useCallback)(async()=>{let t=b.trim().toLowerCase();if(!t){w(`Enter an email username.`);return}try{await q.mutateAsync({path:{assistant_id:e},body:{username:t}}),x(``),w(null),Y(),P.success(`Email address created.`)}catch(e){w(le(e,void 0,`Failed to create email address.`))}},[e,Y,q,b]),X=(0,Z.useCallback)(async()=>{if(H?.id){M(!1);try{await J.mutateAsync({path:{assistant_id:e,id:H.id}}),Y(),P.success(`Email address removed.`)}catch(e){a(e,{context:`email_address_delete`}),P.error(`Failed to remove email address.`)}}},[H?.id,e,J,Y]),ae=(0,Z.useCallback)(async()=>{if(!V?.id)return;if(H){P.error(`Remove the email address first.`);return}A(!1);let t=V.subdomain;try{await K.mutateAsync({path:{assistant_id:e,id:V.id}}),h(t),Y(),P.success(`Domain released.`)}catch(e){a(e,{context:`email_domain_release`}),P.error(`Failed to release domain.`)}},[H,e,K,V?.id,V?.subdomain,Y]);if(N.isLoading)return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin`}),`Checking subscription…`]});if(z)return(0,Q.jsxs)(D,{tone:`info`,icon:(0,Q.jsx)(S,{className:`h-4 w-4`,"aria-hidden":!0}),title:`Get a dedicated email address for your assistant`,actions:(0,Q.jsx)(s,{size:`compact`,onClick:()=>i(`${ue.settings.usage}?tab=billing&adjust_plan`),children:`Upgrade to Pro`}),children:[`Pro plans include a managed`,` `,`<your-subdomain>.${n}`,` inbox — no provider setup required. Or switch to `,(0,Q.jsx)(`strong`,{children:`Your Own`}),` to bring an existing provider.`]});let oe=ee?(0,Q.jsx)(D,{tone:`warning`,title:`Couldn't verify subscription status`,actions:(0,Q.jsx)(s,{size:`compact`,variant:`outlined`,onClick:()=>N.refetch(),children:`Retry`}),children:`We couldn't reach the billing service. The form below assumes managed email is enabled for your org — if it isn't, registering a domain will fail.`}):null;return V?H?(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[oe,(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Address`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:H.address}),(0,Q.jsx)(Vt,{status:W.data?.status,message:W.data?.message,isLoading:W.isLoading}),(0,Q.jsx)(s,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,Q.jsx)(Tt,{}),onClick:()=>M(!0),disabled:J.isPending,"aria-label":`Remove email address`})]}),(0,Q.jsx)(F,{open:j,title:`Remove Email Address`,message:(0,Q.jsxs)(Q.Fragment,{children:[`Are you sure you want to remove `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:H.address}),`? Your assistant will no longer be able to send or receive email at this address.`]}),confirmLabel:`Remove`,destructive:!0,onConfirm:X,onCancel:()=>M(!1)})]}),U.data?.usage&&(0,Q.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[U.data.usage.sent_today,` /`,` `,U.data.usage.daily_limit,` sent today ·`,` `,U.data.usage.received_today,` received`]})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[oe,(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Domain`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:[V.subdomain,`.`,n]}),(0,Q.jsx)(Vt,{status:W.data?.status,message:W.data?.message,isLoading:W.isLoading}),(0,Q.jsx)(s,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,Q.jsx)(Tt,{}),onClick:()=>A(!0),disabled:K.isPending,"aria-label":`Release domain`})]}),(0,Q.jsx)(F,{open:k,title:`Release Domain`,message:(0,Q.jsxs)(Q.Fragment,{children:[`Are you sure you want to release `,(0,Q.jsxs)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:[V.subdomain,`.`,n]}),`? The subdomain will become available for others to claim.`]}),confirmLabel:`Release`,destructive:!0,onConfirm:ae,onCancel:()=>A(!1)})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Email address`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex h-9 min-w-0 flex-1 items-center rounded-md border bg-[var(--field-bg)] text-body-medium-lighter transition-[border-color] duration-150 ${C?`border-[var(--system-negative-strong)]`:`border-[var(--field-border)] focus-within:border-[var(--border-active)]`}`,children:[(0,Q.jsx)(`input`,{value:b,onChange:e=>{x(e.target.value.toLowerCase()),C&&w(null)},placeholder:`hi`,"aria-label":`Email username`,"aria-invalid":!!C,className:`h-full min-w-0 flex-1 bg-transparent pl-3 pr-1 text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none`}),(0,Q.jsxs)(`span`,{className:`shrink-0 pr-3 font-mono text-[var(--content-secondary)]`,children:[`@`,ne]})]}),(0,Q.jsx)(s,{onClick:ie,disabled:q.isPending||!b.trim(),children:q.isPending?`Creating…`:`Create`})]}),C&&(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:C})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[oe,(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Subdomain`}),(0,Q.jsx)(vn,{subdomain:m,onSubdomainChange:e=>{h(e),v&&y(null)},domainSuffix:n,subdomainPlaceholder:`my-assistant`,error:v}),(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Each assistant gets its own subdomain. Lowercase letters, numbers, and hyphens only.`}),(0,Q.jsx)(s,{onClick:()=>O(!0),disabled:G.isPending||!m.trim(),children:G.isPending?`Registering…`:`Register`}),(0,Q.jsx)(F,{open:E,title:`Set Subdomain`,message:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:m.trim().toLowerCase()||`subdomain`}),` will also become your assistant's public handle. You won't be able to change it once set.`]}),confirmLabel:`Confirm`,onConfirm:re,onCancel:()=>O(!1)})]})}function bn(){let e=Nt(),t=de(),{data:o}=d({...we(),enabled:t}),s=o?.results?.[0]?.handle,c=Ft.use.emailRootDomain(),l=jt(),[u,f]=(0,Z.useState)(()=>l===`gated`?`your-own`:ft(r($e,`managed`),`managed`)),[p,m]=(0,Z.useState)(()=>{let e=r(Pe,`resend`);return e===`mailgun`||e===`resend`?e:`resend`}),h=d({queryKey:[`byoEmailCredential`,e,p],queryFn:async()=>{let{data:t}=await te({path:{assistant_id:e},body:{service:p,field:`api_key`},throwOnError:!0});return t},enabled:u===`your-own`||l===`gated`,staleTime:6e4,retry:i,meta:{errorContext:`byo_email_credential_check`}});(0,Z.useEffect)(()=>{h.error&&a(h.error,{context:`byo_email_credential_check`,bestEffort:!0})},[h.error]);let g=h.data?.hasSecret===!0,_=(0,Z.useCallback)(e=>{f(e),n($e,e)},[]),v=(0,Z.useCallback)(()=>{n(Pe,p),P.success(`Email settings saved.`)},[p]),y=(0,Z.useMemo)(()=>Mt.find(e=>e.id===p)??Mt[0],[p]),x=(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(w,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{children:[`Configure `,y.displayName,` via the assistant CLI: ask the assistant to run the`,` `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:y.setupSkill}),` `,`skill. It walks you through storing the API key, detecting the domain, and (optionally) wiring up an inbound webhook.`]}),(0,Q.jsxs)(`a`,{href:y.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Open `,y.displayName,(0,Q.jsx)(C,{className:`h-3 w-3`})]})]})]}),S=(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(I,{value:p,onChange:e=>{(e===`mailgun`||e===`resend`)&&m(e)},options:Mt.map(e=>({value:e.id,label:e.displayName}))})]}),g?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-[var(--system-positive-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-default)]`,children:[(0,Q.jsx)(b,{className:`h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`span`,{children:[y.displayName,` API key configured. To reconfigure, run the`,` `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:y.setupSkill}),` `,`skill.`]})]}),(0,Q.jsxs)(`a`,{href:y.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-body-small-default text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Open `,y.displayName,(0,Q.jsx)(C,{className:`h-3 w-3`})]})]}):x,(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsx)($,{onClick:v,disabled:!1})})]});return l===`gated`?(0,Q.jsx)(zt,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,children:S}):(0,Q.jsx)(Rt,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,mode:u,onModeChange:_,children:u===`managed`?(0,Q.jsx)(`div`,{className:`space-y-4`,children:l===`disabled`?(0,Q.jsx)(Be,{children:`Log in to the Vellum platform to manage email settings.`}):(0,Q.jsx)(yn,{assistantId:e,assistantHandle:s,emailRootDomain:c})}):S})}function xn(){let e=Nt(),t=u(),{data:i}=d({...K({path:{assistant_id:e}}),staleTime:3e4}),o=H({onSuccess:n=>{X(t,{path:{assistant_id:e}},n)}}),s=fn(),[c,l]=un((0,Z.useMemo)(()=>ft(i?i.services?.[`image-generation`]?.mode??r(`vellum:ai:imageGenMode`,`your-own`):r(Ct,`your-own`),`your-own`),[i])),[f,p]=(0,Z.useState)(()=>r(ke,`gemini-3.1-flash-image-preview`)),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(!1),v=(0,Z.useCallback)(async()=>{_(!0);let r=m.trim(),i=c===`your-own`&&r.length>0;try{i&&await s(pt(f),r),await o.mutateAsync({path:{assistant_id:e},body:{services:{"image-generation":{mode:c}}}}).catch(e=>{throw P.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e});try{await V({path:{assistant_id:e},body:{modelId:f},throwOnError:!0})}catch(e){throw P.error(`Failed to update image generation model. Please try again.`),a(e,{context:`set_image_gen_model`}),e}finally{t.invalidateQueries({queryKey:Y({path:{assistant_id:e}})})}}catch{_(!1);return}_(!1);try{n(Ct,c),n(ke,f),i&&h(``),P.success(`Image generation settings saved.`)}catch(e){a(e,{context:`settings-ai-image-gen-persist-local`}),P.error(`Saved, but local preferences could not be written.`)}},[m,c,f,e,o,s,t]),y=(0,Z.useCallback)(()=>{h(``),p(`gemini-3.1-flash-image-preview`),n(ke,`gemini-3.1-flash-image-preview`)},[]);return(0,Q.jsx)(Rt,{title:`Image Generation`,subtitle:`Configure which model your assistant uses to generate images`,mode:c,onModeChange:e=>l(e),children:c===`managed`?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Active Model`}),(0,Q.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,Q.jsx)(I,{className:`flex-1`,value:f,onChange:p,options:at.map(e=>({value:e,label:Me[e]??e}))}),(0,Q.jsx)($,{onClick:v,disabled:g}),g&&(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(j,{label:`API Key`,type:`password`,value:m,onChange:e=>h(e.target.value),placeholder:pt(f)===`openai`?`Enter your OpenAI API key`:`Enter your Gemini API key`,fullWidth:!0}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Active Model`}),(0,Q.jsx)(I,{value:f,onChange:p,options:at.map(e=>({value:e,label:Me[e]??e}))})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:v,disabled:g}),g&&(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),(0,Q.jsx)(Ht,{onClick:y})]})]})})}async function Sn(e){let{provider:t,apiKey:n,voiceId:r,text:i}=e;if(n.trim().length===0)return{kind:`error`,message:`Save an API key for this provider first.`};try{return t===`elevenlabs`?await Cn(n,r,i):t===`deepgram`?await wn(n,i):t===`fish-audio`?{kind:`unsupported`,message:`Fish Audio TTS is only supported in the desktop app today. Use ElevenLabs or Deepgram to test from the browser.`}:t===`xai`?{kind:`unsupported`,message:`xAI TTS is only supported in the desktop app today. Use ElevenLabs or Deepgram to test from the browser.`}:{kind:`unsupported`,message:`TTS testing for "${t}" is not supported from the browser yet.`}}catch(e){return{kind:`error`,message:e instanceof Error?e.message:`Failed to reach the TTS provider.`}}}async function Cn(e,t,n){let r=t.trim();if(r.length===0)return{kind:`error`,message:`Enter and save a Voice ID before testing ElevenLabs.`};let i=await fetch(`https://api.elevenlabs.io/v1/text-to-speech/${encodeURIComponent(r)}?output_format=mp3_44100_128`,{method:`POST`,headers:{"xi-api-key":e,"Content-Type":`application/json`,Accept:`audio/mpeg`},body:JSON.stringify({text:n,model_id:`eleven_turbo_v2_5`})});return i.ok?{kind:`audio`,blob:await i.blob()}:{kind:`error`,message:await Tn(i,`ElevenLabs rejected the request.`)}}async function wn(e,t){let n=await fetch(`https://api.deepgram.com/v1/speak?model=aura-2-thalia-en`,{method:`POST`,headers:{Authorization:`Token ${e}`,"Content-Type":`application/json`,Accept:`audio/mpeg`},body:JSON.stringify({text:t})});return n.ok?{kind:`audio`,blob:await n.blob()}:{kind:`error`,message:await Tn(n,`Deepgram rejected the request.`)}}async function Tn(e,t){try{let n=await e.text();if(n.length===0)return`${t} (HTTP ${e.status})`;try{let e=JSON.parse(n);if(e&&typeof e==`object`&&`detail`in e&&typeof e.detail==`string`)return e.detail;if(e&&typeof e==`object`&&`message`in e&&typeof e.message==`string`)return e.message}catch{}return n.slice(0,200)}catch{return`${t} (HTTP ${e.status})`}}function En({assistantId:e,value:t,onChange:n,className:r}){let[i,a]=(0,Z.useState)(!1),{voices:o}=rt(e);if(o.length===0)return null;let s=o.find(e=>e.model===t)??o[0];return(0,Q.jsxs)(A.Root,{open:i,onOpenChange:a,children:[(0,Q.jsx)(A.Trigger,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Voice`,className:m(`flex h-9 w-full items-center gap-2 rounded-md border border-[var(--field-border)] bg-[var(--field-bg)] px-3 text-left text-body-medium-lighter text-[var(--content-default)] transition-colors focus:outline-none data-[state=open]:border-[var(--border-active)]`,r),children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:s?vt(s.description):`Select a voice`}),(0,Q.jsx)(v,{className:`h-3.5 w-3.5 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0})]})}),(0,Q.jsx)(A.Content,{side:`bottom`,align:`start`,className:`w-[var(--radix-popover-trigger-width)] p-1`,children:(0,Q.jsx)(ht,{assistantId:e,value:t,onChange:n,onSelect:()=>a(!1),showSource:!0})})]})}var Dn={elevenlabs:`voiceId`,"fish-audio":`referenceId`,xai:`voiceId`};function On({assistantId:e,hideSaveButton:t=!1,hideCredentialsGuide:i=!1,onSaveStateChange:a}={}){let o=Nt(),c=e??o,l=ae.use.name()??`your assistant`,f=de(),p=u(),{data:m}=d({...ne({path:{assistant_id:c}}),enabled:f,staleTime:1/0}),h=(0,Z.useMemo)(()=>{let e=m?.providers;if(!e)return lt;if(e.some(e=>e.id===`vellum`))return e;let t=lt.find(e=>e.id===`vellum`);return t?[t,...e]:e},[m]),{data:g}=d({...K({path:{assistant_id:c}}),enabled:f,staleTime:3e4}),_=g?.services?.tts,v=_?.mode===`managed`?`vellum`:_?.provider,y=`elevenlabs`,b=(0,Z.useMemo)(()=>v??r(`vellum:voice:ttsProvider`,y),[v,y]),x=!!v,[S,C]=un(b),[w,T]=(0,Z.useState)(``),[E,D]=(0,Z.useState)(``),[O,k]=(0,Z.useState)(``),[A,M]=(0,Z.useState)(!1),[N,F]=(0,Z.useState)(!1),[L,R]=(0,Z.useState)(!1),{voices:z,defaultModel:te,fetched:V}=De(c,{enabled:S===`vellum`}),H=_?.providers?.vellum?.model??te??``,[U,W]=un(H),G=z.find(e=>e.model===U)??z[0],q=(0,Z.useMemo)(()=>h.find(e=>e.id===S)??h[0],[S,h]),J=S===`vellum`&&q.supportsVoiceSelection&&U!==H,re=(0,Z.useCallback)(e=>{let t=r(Ze+e,``),n=r(Le+e,``);M(t.length>0),D(n),k(n),T(``)},[]);(0,Z.useEffect)(()=>{re(S)},[S,re]);let ie=(0,Z.useMemo)(()=>{let e=S!==b,t=w.trim().length>0,n=E.trim()!==O;return e||t||n||J},[S,b,w,E,O,J]),X=(0,Z.useCallback)(async()=>{let e=w.trim(),t=E.trim(),i=q.id;n(tt,i),e.length>0&&n(Ze+i,e),n(Le+i,t);let a=e.length>0?e:r(Ze+i,``),o=Dn[i];R(!0);try{if(a.length>0){let{response:e}=await ee({path:{assistant_id:c},body:{service:i,field:`api_key`,value:a,label:`${q.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}let e={...S!==b||!x?{provider:i,mode:i===`vellum`?`managed`:`your-own`}:{},...o?{providers:{[i]:{[o]:t}}}:{},...J?{providers:{vellum:{model:U}}}:{}};if(Object.keys(e).length>0){let{response:t}=await B({path:{assistant_id:c},body:{services:{tts:e}},throwOnError:!1});if(!t?.ok)throw Error(`Failed to save configuration (HTTP ${t?.status??`?`})`)}return M(a.length>0),k(t),T(``),p.invalidateQueries({queryKey:Y({path:{assistant_id:c}})}),P.success(`Text-to-speech settings saved`),!0}catch(e){return P.error(e instanceof Error?e.message:`Failed to save text-to-speech settings`),!1}finally{R(!1)}},[c,S,U,J,w,E,q,b,x,p]);(0,Z.useEffect)(()=>{a?.({hasChanges:ie,saving:L,save:X})},[a,ie,L,X]);let oe=(0,Z.useCallback)(()=>{n(Ze+S,``),M(!1),T(``)},[S]),se=(0,Z.useCallback)(async()=>{F(!0);try{let e=r(Ze+S,``),t=w.trim(),n=t.length>0?t:e;if(n.length===0){P.error(`Save an API key for this provider before testing.`);return}let i=r(Le+S,``),a=E.trim(),o=await Sn({provider:S,apiKey:n,voiceId:a.length>0?a:i,text:`Hey! It's ${l}. How does this sound?`});if(o.kind!==`audio`){P.error(o.message);return}let s=URL.createObjectURL(o.blob);try{let e=new Audio(s);await e.play(),await new Promise(t=>{e.onended=()=>t(),e.onerror=()=>t()})}finally{URL.revokeObjectURL(s)}}finally{F(!1)}},[l,w,S,E]),ce=A?`•••••••• (Enter a new key to replace)`:q.apiKeyPlaceholder,le=S===`vellum`,ue=le&&q.supportsVoiceSelection;return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(I,{value:S,onChange:C,options:h.map(e=>({value:e.id,label:e.displayName})),"aria-label":`TTS provider`})]}),!le&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,Q.jsx)(j,{type:`password`,value:w,onChange:e=>T(e.target.value),placeholder:ce,fullWidth:!0})]}),ue&&G&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Voice`}),(0,Q.jsx)(En,{assistantId:c,value:U,onChange:W})]}),ue&&V&&!G&&(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`No managed voices are currently available.`}),q.supportsVoiceSelection&&!le&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Voice ID`}),(0,Q.jsx)(j,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:`Enter a voice ID`,fullWidth:!0})]}),!i&&!le&&(0,Q.jsx)(Ut,{guide:q.credentialsGuide}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!le&&(0,Q.jsx)(s,{variant:`outlined`,onClick:se,disabled:N,children:N?`Testing…`:`Test`}),(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[!t&&(0,Q.jsx)($,{onClick:X,disabled:!ie||L}),A&&!le&&(0,Q.jsx)(Ht,{onClick:oe})]})]})]})}function kn(){return(0,Q.jsx)(zt,{title:`Text-to-Speech`,subtitle:`Configure how your assistant speaks`,children:(0,Q.jsx)(On,{})})}var An={vellum:{provider:`vellum`},deepgram:{provider:`deepgram`,credentialService:`deepgram`},openai:{provider:`openai-whisper`,credentialService:`openai`}},jn={vellum:`vellum`,deepgram:`deepgram`,"openai-whisper":`openai`},Mn=`deepgram`;function Nn({assistantId:e,hideSaveButton:t=!1,hideCredentialsGuide:i=!1,onSaveStateChange:a}={}){let o=Nt(),s=e??o,c=de(),l=u(),[f]=(0,Z.useState)(()=>He.filter(e=>!e.requiresNativeDictation||ze())),p=Mn,{data:m}=d({...K({path:{assistant_id:s}}),enabled:c,staleTime:3e4}),h=m?.services?.stt,g=h?.mode===`managed`?`vellum`:h?.provider,_=(0,Z.useMemo)(()=>{let e=g?jn[g]:void 0;if(e&&f.some(t=>t.id===e))return e;let t=r(Ye,p);return f.some(e=>e.id===t)?t:p},[g,f,p]),v=!!g,[y,b]=un(_),[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(!1),[T,D]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{let e=r(Ye,p);e===`macos-native`&&!f.some(t=>t.id===e)&&n(Ye,p)},[f,p]);let O=(0,Z.useMemo)(()=>f.find(e=>e.id===y)??f[0],[f,y]),k=O.apiKeyPlaceholder!==void 0;(0,Z.useEffect)(()=>{w(r(xt+y,``).length>0),S(``)},[y]);let A=(0,Z.useMemo)(()=>{let e=y!==_,t=x.trim().length>0;return e||t},[y,_,x]),M=(0,Z.useCallback)(async()=>{let e=x.trim();n(Ye,y),e.length>0&&n(xt+y,e);let t=An[y];D(!0);try{if(t?.credentialService){let n=e.length>0?e:r(xt+y,``);if(n.length>0){let{response:e}=await ee({path:{assistant_id:s},body:{service:t.credentialService,field:`api_key`,value:n,label:`${O.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}}if(t&&(y!==_||!v)||g===`vellum`&&y!==`vellum`){let e=t?.provider??Mn,{response:n}=await B({path:{assistant_id:s},body:{services:{stt:{provider:e,mode:e===`vellum`?`managed`:`your-own`}}},throwOnError:!1});if(!n?.ok)throw Error(`Failed to save configuration (HTTP ${n?.status??`?`})`)}return e.length>0&&w(!0),S(``),l.invalidateQueries({queryKey:Y({path:{assistant_id:s}})}),P.success(`Speech-to-text settings saved`),!0}catch(e){return P.error(e instanceof Error?e.message:`Failed to save speech-to-text settings`),!1}finally{D(!1)}},[s,y,x,O,_,v,g,l]);(0,Z.useEffect)(()=>{a?.({hasChanges:A,saving:T,save:M})},[a,A,T,M]);let N=(0,Z.useCallback)(()=>{n(xt+y,``),w(!1),S(``)},[y]),F=C?`•••••••• (Enter a new key to replace)`:O.apiKeyPlaceholder;return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(I,{value:y,onChange:b,options:f.map(e=>({value:e.id,label:e.displayName})),"aria-label":`STT provider`})]}),k&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,Q.jsx)(j,{type:`password`,value:x,onChange:e=>S(e.target.value),placeholder:F,fullWidth:!0})]}),O.setupWarning&&(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(E,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-mid-strong)]`}),(0,Q.jsx)(`span`,{children:O.setupWarning})]}),!i&&O.credentialsGuide&&(0,Q.jsx)(Ut,{guide:O.credentialsGuide}),y===`vellum`&&(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Transcription runs through your Vellum account.`}),(!t||C)&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[!t&&(0,Q.jsx)($,{onClick:M,disabled:!A||T}),C&&(0,Q.jsx)(Ht,{onClick:N})]})]})}function Pn(){return(0,Q.jsx)(zt,{title:`Speech-to-Text`,subtitle:`Configure how your assistant transcribes speech`,children:(0,Q.jsx)(Nn,{})})}function Fn(){return(0,Z.useEffect)(()=>{let e=window.location.hash.slice(1);e&&requestAnimationFrame(()=>{document.getElementById(e)?.scrollIntoView({block:`start`})})},[]),(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.jsx)(Bt,{}),(0,Q.jsx)(dn,{}),(0,Q.jsx)(hn,{}),(0,Q.jsx)(_n,{}),(0,Q.jsx)(bn,{}),(0,Q.jsx)(xn,{}),(0,Q.jsx)(kn,{}),(0,Q.jsx)(Pn,{})]})}export{Fn as AiPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-BxZ6HzpA.js";import{m as r,u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{t as o}from"./input-CGhuhT4R.js";import{t as s}from"./dropdown-Dftxb_kj.js";import{t as c}from"./is-electron-f6weDa36.js";import{u as l}from"./routes-DN3K5OaW.js";import{hn as u}from"./index-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-BxZ6HzpA.js";import{m as r,u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{t as o}from"./input-CGhuhT4R.js";import{t as s}from"./dropdown-Dftxb_kj.js";import{t as c}from"./is-electron-f6weDa36.js";import{u as l}from"./routes-DN3K5OaW.js";import{hn as u}from"./index-DA-27U7J.js";import{a as d,i as f,n as p,o as m,r as h,s as g}from"./provider-key-7P1U32J7.js";import"./onboarding-step-layout-BfSOxqy3.js";var _=e(t(),1),v=a();function y(){let e=i(),[t]=r(),a=t.get(`hosting`),y=c(),b=p(),[x,S]=(0,_.useState)(()=>b?.provider??f.id),[C,w]=(0,_.useState)(()=>b?.key??``),[T,E]=(0,_.useState)(()=>b?.model??m(b?.provider??f.id)??``),[D,O]=(0,_.useState)(()=>b?.baseUrl??``),[k,A]=(0,_.useState)(()=>b?.customModels??``),j=g(x)??f,M=j.models??[],N=j.requiresKey,P=M.length>0,F=x===`openai-compatible`,I=(!(N&&!F)||C.trim().length>0)&&(!P||T.trim().length>0)&&(!F||D.trim().length>0&&k.trim().length>0);return(0,v.jsx)(u,{children:(0,v.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center ${y?`min-h-full px-8 pt-21 pb-4 electron-prechat-type`:`px-6 py-16`} text-[var(--content-default)]`,children:[(0,v.jsx)(`h1`,{className:y?`text-title-large`:`text-3xl font-semibold tracking-tight`,style:{animation:`fadeInUp 0.5s ease-out 0.1s both`},children:`Connect a Model Provider`}),(0,v.jsx)(`p`,{className:`text-center text-body-medium-lighter text-[var(--content-tertiary)] ${y?`mt-3.5`:`mt-3`}`,style:{animation:`fadeInUp 0.5s ease-out 0.3s both`},children:`Choose the model provider your assistant should use.`}),(0,v.jsxs)(`div`,{className:`flex w-full flex-col gap-4 ${y?`mt-8`:`mt-10`}`,style:{animation:`fadeInUp 0.5s ease-out 0.4s both`},children:[(0,v.jsxs)(`div`,{className:`flex flex-col ${y?`gap-2`:`gap-1`}`,children:[(0,v.jsx)(`label`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,v.jsx)(s,{"aria-label":`Provider`,value:x,onChange:e=>{let t=g(e);t&&(S(t.id),w(``),E(m(t.id)??``))},options:d.map(e=>({value:e.id,label:e.displayName}))})]}),M.length>0&&(0,v.jsxs)(`div`,{className:`flex flex-col ${y?`gap-2`:`gap-1`}`,children:[(0,v.jsx)(`label`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Model`}),(0,v.jsx)(s,{"aria-label":`Model`,value:T,onChange:E,options:M.map(e=>({value:e.id,label:e.displayName}))})]}),F&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`div`,{className:`flex flex-col ${y?`gap-2`:`gap-1`}`,children:[(0,v.jsx)(`label`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Base URL`}),(0,v.jsx)(o,{type:`text`,placeholder:`http://localhost:1234/v1`,value:D,onChange:e=>O(e.target.value),fullWidth:!0})]}),(0,v.jsxs)(`div`,{className:`flex flex-col ${y?`gap-2`:`gap-1`}`,children:[(0,v.jsx)(`label`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Models`}),(0,v.jsx)(o,{type:`text`,placeholder:`model-1, model-2`,value:k,onChange:e=>A(e.target.value),fullWidth:!0}),(0,v.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Comma-separated model identifiers exposed by your endpoint.`})]})]}),N&&(0,v.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,v.jsx)(o,{type:`password`,label:`${j.displayName} API Key`,placeholder:j.apiKeyPlaceholder??`Enter your API key`,value:C,onChange:e=>w(e.target.value),className:`touch-mobile:text-[16px]`,fullWidth:!0}),j.docsUrl&&(0,v.jsxs)(`p`,{className:`self-start text-body-medium-lighter text-[var(--content-tertiary)]`,children:[`Don't have it?`,` `,(0,v.jsx)(`a`,{href:j.docsUrl,target:`_blank`,rel:`noreferrer`,className:`text-[var(--content-default)] underline`,children:`Get an API key here`})]})]})]}),(0,v.jsxs)(`div`,{className:`mt-8 flex w-full flex-col ${y?`gap-2.5`:`gap-2`}`,style:{animation:`fadeInUp 0.5s ease-out 0.5s both`},children:[(0,v.jsx)(n,{variant:`primary`,size:`regular`,fullWidth:!0,disabled:!I,onClick:()=>{if(!I)return;let t=T.trim()||m(x);h({provider:x,key:C.trim(),...t?{model:t}:{},...F?{baseUrl:D.trim(),customModels:k.trim()}:{}}),e(a?`${l.onboarding.privacy}?hosting=${a}`:l.onboarding.privacy)},className:y?void 0:`h-11 text-base`,children:`Continue`}),(0,v.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,onClick:()=>{e(l.onboarding.hosting)},className:y?void 0:`h-11 text-base`,children:`Back`})]})]})})}export{y as ApiKeyScreen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./toast-CJSlHuX8.js";import{n as t,t as n}from"./create-selectors-BbPasxJ6.js";import{c as r,n as i,s as a,t as o,u as s}from"./feature-flag-catalog-
|
|
1
|
+
import{n as e}from"./toast-CJSlHuX8.js";import{n as t,t as n}from"./create-selectors-BbPasxJ6.js";import{c as r,n as i,s as a,t as o,u as s}from"./feature-flag-catalog-Bkr5vS-F.js";import{h as c}from"./sdk.gen-CenbOmmb.js";var l={...o},u={...i},d=0,f={};function p(e={}){l={...o,...e};for(let e of Object.keys(f))delete f[e]}function m(e={}){u={...i,...e}}function h(){p(),m()}var g=a(`assistant`);function _(e){return l[e]??o[e]??!1}function v(e){return u[e]??i[e]??``}var y=n(t()(t=>{let n=t;return{...o,...g.bool,hasHydrated:!1,stringFlags:{...i,...g.str},setFlags:e=>t(t=>{p(e);let n={...e,...g.bool};return Object.keys(n).some(e=>n[e]!==t[e])?n:t}),setFlag:(n,i,a)=>{let o=++d,u=()=>{if(f[n]!==o)return;delete f[n];let a=_(n);t(e=>e[n]===i?{[n]:a}:e),e.error(`Couldn't update "${r(n)?.label??n}" — change reverted.`)},p=s(n);!a||!p||(f[n]=o,c({path:{assistant_id:a,flag_key:p},body:{enabled:i},throwOnError:!1}).then(e=>{e.response?.ok?(l[n]=i,f[n]===o&&delete f[n]):u()}).catch(u),t({[n]:g.bool[n]??i}))},markHydrated:()=>t({hasHydrated:!0}),resetForAssistantSwitch:()=>{h(),t({...o,...g.bool,hasHydrated:!1}),n({stringFlags:{...i,...g.str}})},setStringFlags:e=>n(t=>{m(e);let n={...e,...g.str},r=t.stringFlags;return Object.keys(n).some(e=>n[e]!==r[e])?{stringFlags:n}:t}),setStringFlag:(t,i,a)=>{let o=++d,l=()=>{if(f[t]!==o)return;delete f[t];let a=v(t);n(e=>e.stringFlags[t]===i?{stringFlags:{...e.stringFlags,[t]:a}}:e),e.error(`Couldn't update "${r(t)?.label??t}" — change reverted.`)},p=s(t);!a||!p||(f[t]=o,c({path:{assistant_id:a,flag_key:p},body:{enabled:i},throwOnError:!1}).then(e=>{e.response?.ok?(u[t]=i,f[t]===o&&delete f[t]):l()}).catch(l),n(e=>({stringFlags:{...e.stringFlags,[t]:g.str[t]??i}})))}}}));export{y as t};
|
package/dist/assets/{assistant-status-panel-BwLJwtUy.js → assistant-status-panel-BTxCCenj.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{n as t,t as n}from"./capture-error-EqyiBCqE.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./useQuery-B45lW1Kk.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{t as o}from"./loader-circle-CWO25Tky.js";import"./src-ChvLuWxs.js";import"./tag-D4RWxz2r.js";import{n as s}from"./toast-CJSlHuX8.js";import"./auth-store-De2L1iVx.js";import{a as c,r as l}from"./api-BB3OgWZK.js";import{t as u}from"./assistant-feature-flag-store-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{n as t,t as n}from"./capture-error-EqyiBCqE.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./useQuery-B45lW1Kk.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{t as o}from"./loader-circle-CWO25Tky.js";import"./src-ChvLuWxs.js";import"./tag-D4RWxz2r.js";import{n as s}from"./toast-CJSlHuX8.js";import"./auth-store-De2L1iVx.js";import{a as c,r as l}from"./api-BB3OgWZK.js";import{t as u}from"./assistant-feature-flag-store-BV_nEYvU.js";import{t as d}from"./use-active-assistant-id-COiCJBSe.js";import"./environment-store-PamE9l4Q.js";var f=e(r(),1),p=a();function m({value:e,max:t,caption:n}){let r=t>0?Math.max(0,Math.min(e/t*100,100)):0,i=r>90;return(0,p.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,p.jsx)(`div`,{className:`h-2 w-full overflow-hidden rounded-full bg-[var(--surface-active)]`,children:(0,p.jsx)(`div`,{className:`h-full rounded-full transition-[width] duration-200`,style:{width:`${r}%`,backgroundColor:i?`var(--system-negative-strong)`:`var(--system-positive-strong)`}})}),n&&(0,p.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:n})]})}var h=7,g=2e3;function _(e){let t=(0,f.useRef)(0),n=(0,f.useRef)(null),[r,i]=(0,f.useState)(null),a=(0,f.useCallback)(()=>{if(t.current+=1,t.current>=h){t.current=0;let r=u.getState(),a=!r.settingsDeveloperNav;r.setFlag(`settingsDeveloperNav`,a,e),i(a?`Developer mode enabled`:`Developer mode disabled`),n.current!==null&&clearTimeout(n.current),n.current=setTimeout(()=>{i(null),n.current=null},g)}},[e]);return(0,f.useEffect)(()=>()=>{n.current!==null&&clearTimeout(n.current)},[]),{onTap:a,message:r}}function v({version:e,loading:t,assistantId:n}){let{onTap:r,message:i}=_(n);return t?(0,p.jsxs)(`span`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,p.jsx)(o,{className:`h-4 w-4 animate-spin`}),`Loading version...`]}):e?(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`button`,{type:`button`,className:`break-all text-left text-body-medium-lighter text-[var(--content-default)]`,onClick:r,children:e}),i&&(0,p.jsx)(`p`,{className:`mt-1 text-body-small-default text-[var(--content-accent)]`,children:i})]}):(0,p.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`—`})}var y=`currentAssistant`,b=4e3,x=9e4;function S(e,t){return(e.memory?.maxMb??null)!==(t.memory?.maxMb??null)||(e.cpu?.maxCores??null)!==(t.cpu?.maxCores??null)}function C(){let e=d(),{data:r=null,isLoading:a,refetch:o}=i({queryKey:[y,e],queryFn:async()=>{let t=await l(e);return t.ok?t.data:null},retry:!1}),u=r?.id,[p,m]=(0,f.useState)(null),[h,g]=(0,f.useState)(!1),[_,v]=(0,f.useState)(!1),C=(0,f.useRef)(0),w=(0,f.useRef)(0),T=(0,f.useCallback)(async e=>{if(!u)return m(null),g(!1),null;C.current+=1;let r=C.current;g(!0);try{let t=await c(u);return r===C.current?t.ok?(m(t.data),t.data):(e?.keepStaleOnError||m(null),null):null}catch(i){return r===C.current?(e?.keepStaleOnError||m(null),!t(i)&&!e?.keepStaleOnError&&(n(i,{context:`fetch_assistant_healthz`}),s.error(`Failed to load assistant info`)),null):null}finally{r===C.current&&g(!1)}},[u]);return(0,f.useEffect)(()=>{T()},[T]),(0,f.useEffect)(()=>()=>{w.current+=1,v(!1),m(null)},[u]),{assistant:r,assistantLoading:a,healthz:p,healthzLoading:h,healthzPolling:_,refetch:(0,f.useCallback)(async()=>{await o(),await T()},[o,T]),refetchUntilResized:(0,f.useCallback)(async e=>{let t=++w.current,n=Date.now()+x;v(!0);let r=e;try{for(o();Date.now()<n&&t===w.current;){if(await new Promise(e=>setTimeout(e,b)),t!==w.current)return;let e=await T({keepStaleOnError:!0});if(t!==w.current)return;if(e){if(r==null){r=e;continue}if(S(e,r))return}}}finally{t===w.current&&v(!1)}},[T,o])}}function w(e){return e>=1024?`${(e/1024).toFixed(1)} GB`:`${e.toFixed(0)} MB`}export{m as a,_ as i,C as n,v as r,w as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-EqyiBCqE.js";import{t as n}from"./react-DJZBPgpf.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import{t as i}from"./typography-B_Zom8Gj.js";import"./src-ChvLuWxs.js";import{Bt as a,E as o,Ht as s,Ut as c,Vt as l,ht as u,mt as d}from"./index-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-EqyiBCqE.js";import{t as n}from"./react-DJZBPgpf.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import{t as i}from"./typography-B_Zom8Gj.js";import"./src-ChvLuWxs.js";import{Bt as a,E as o,Ht as s,Ut as c,Vt as l,ht as u,mt as d}from"./index-DA-27U7J.js";import{t as f}from"./status-badge-pill-DQHLgr0r.js";import{CodeBlock as p,SectionLabel as m}from"./tool-detail-panel-3ertbTbW.js";import{t as h}from"./detail-panel-stop-button-D2LN59n8.js";var g=e(n(),1),_=r();function v({status:e}){return(0,_.jsx)(f,{color:a(e),label:l(e)})}function y({entry:e,onClose:n}){let r=c(e.status),a=!r,l=a&&e.output!==void 0&&e.output!==``,f=a&&e.exitCode!=null,[y,b]=(0,g.useState)(!1),x=(0,g.useCallback)(()=>{b(!0),d(e.id).catch(e=>{b(!1),t(e,{context:`BackgroundTaskDetailPanel.stop`})})},[e.id]);return(0,_.jsxs)(o,{Glyph:u(e.toolName),title:s(e.status),headerTrailing:(0,_.jsx)(v,{status:e.status}),headerActions:r?(0,_.jsx)(h,{onStop:x,ariaLabel:`Stop command`,disabled:y}):void 0,closeVariant:`outlined`,closeLabel:`Close task detail`,onClose:n,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(m,{children:`Command`}),(0,_.jsx)(p,{text:e.command})]}),l&&(0,_.jsxs)(`div`,{className:`mt-5`,children:[(0,_.jsx)(m,{children:`Output`}),(0,_.jsx)(p,{text:e.output})]}),f&&(0,_.jsxs)(i,{variant:`body-small-default`,as:`p`,className:`mt-2 text-[var(--content-tertiary)]`,children:[`Exit code: `,e.exitCode]})]})}export{y as BackgroundTaskDetailPanel};
|