@antseed/gateway-console 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{Activity-aMw4GLn_.js → Activity-BHckTctH.js} +1 -1
- package/dist/assets/{Audit-CCre2vZ2.js → Audit-CheQE0ki.js} +1 -1
- package/dist/assets/{ChainGate-rOjMTVIg.js → ChainGate-BO2NzC31.js} +1 -1
- package/dist/assets/{ChannelClose-DkQxS0-Z.js → ChannelClose-ODGHySRH.js} +1 -1
- package/dist/assets/{Charts-NmIMcccv.js → Charts-CrCKBk_i.js} +1 -1
- package/dist/assets/{ConnectWallet-QN7kfDQq.js → ConnectWallet-BqD3R1R9.js} +1 -1
- package/dist/assets/{DataTable-D2QIQ-gI.js → DataTable-B36eMErM.js} +1 -1
- package/dist/assets/{Disclosure-h1MJg5Wn.js → Disclosure-DS6GTz8G.js} +1 -1
- package/dist/assets/{KeyHolder-DUhCBfBH.js → KeyHolder-CG5sSLQK.js} +1 -1
- package/dist/assets/{Keys-DIlH-qns.js → Keys-Cxz0K09V.js} +1 -1
- package/dist/assets/{Logs-BPrDGUHL.js → Logs-DV-trPqy.js} +1 -1
- package/dist/assets/{Members-Cud9TWBJ.js → Members-Cp_3A-Dy.js} +1 -1
- package/dist/assets/{Migrate-DEIQ12oJ.js → Migrate-BD-0-NY-.js} +1 -1
- package/dist/assets/{Models-DXI7RYae.js → Models-DHeLeAiN.js} +1 -1
- package/dist/assets/{OperatorActions-BC74iRfA.js → OperatorActions-Bety6436.js} +1 -1
- package/dist/assets/{OperatorGateAlert-CIQwPW1h.js → OperatorGateAlert-Jd5E0V_d.js} +1 -1
- package/dist/assets/{Overview-ipvNEEut.js → Overview-37mja3y-.js} +1 -1
- package/dist/assets/{PolicyEditor-CRhTwGq0.js → PolicyEditor-B5BAs2vC.js} +1 -1
- package/dist/assets/{PolicyField-0xAOIP4-.js → PolicyField-D7O5D7fl.js} +1 -1
- package/dist/assets/{Presets-DrJ48O3s.js → Presets-CgfFG3fw.js} +1 -1
- package/dist/assets/{Providers-CcIj0C5E.js → Providers-sZFgSVHV.js} +1 -1
- package/dist/assets/{RequestLog-CBZWWnHo.js → RequestLog-BbR8E_9_.js} +1 -1
- package/dist/assets/{Rewards-CUru480X.js → Rewards-CuWsg5m7.js} +2 -2
- package/dist/assets/{RewardsClaim-BjwCidx5.js → RewardsClaim-CRgTiF93.js} +1 -1
- package/dist/assets/{Routing-BO7JFJGH.js → Routing-BebcQMko.js} +1 -1
- package/dist/assets/{Segmented-BJmgB5-Y.js → Segmented-C9jux-Mr.js} +1 -1
- package/dist/assets/{SelectField-D_BPTzpT.js → SelectField-BSNXjRiC.js} +1 -1
- package/dist/assets/{Settings-qFQk36WV.js → Settings-BLIkiFNw.js} +1 -1
- package/dist/assets/{Switch-JCyfy3G5.js → Switch-hSHNLapF.js} +1 -1
- package/dist/assets/{Tabs-CGI9v1OW.js → Tabs-Dle_Eq4t.js} +1 -1
- package/dist/assets/{TextAreaField-4JuDDT4k.js → TextAreaField-9B3_7w3L.js} +1 -1
- package/dist/assets/{UsageByModel-jvNkVE4M.js → UsageByModel-6qZIqVRY.js} +1 -1
- package/dist/assets/{Wallet-tlCKFe2Q.js → Wallet-BbwYd9fm.js} +3 -3
- package/dist/assets/{WalletConfirm-Dz6gVYW9.js → WalletConfirm-Dm8Lr6DT.js} +1 -1
- package/dist/assets/{WalletFunding-NSKzSiY5.js → WalletFunding-CSVVBvPP.js} +1 -1
- package/dist/assets/{WalletSignIn-Bs_yxjak.js → WalletSignIn-DLX6sQbD.js} +1 -1
- package/dist/assets/{Workspaces-C79eSjJK.js → Workspaces-DZmGjFFI.js} +1 -1
- package/dist/assets/{add-CxYxphqt.js → add-DXI2Cp6k.js} +1 -1
- package/dist/assets/{all-wallets-BSHfFrwc.js → all-wallets-LQt3S9MV.js} +1 -1
- package/dist/assets/{app-store-DzDsfjeG.js → app-store-CRiNXiqm.js} +1 -1
- package/dist/assets/{apple-N_ET94Rt.js → apple-BXH3yGFL.js} +1 -1
- package/dist/assets/{arrow-bottom-U6RBQjWC.js → arrow-bottom-D3S4BxFo.js} +1 -1
- package/dist/assets/{arrow-bottom-circle-tDeqZ1Ky.js → arrow-bottom-circle-Zukia-8I.js} +1 -1
- package/dist/assets/{arrow-left-BShNPqIx.js → arrow-left-DHP2QErV.js} +1 -1
- package/dist/assets/{arrow-right-CNSfQOzD.js → arrow-right-Co_bi7Vn.js} +1 -1
- package/dist/assets/{arrow-top-DV_peLyo.js → arrow-top-D3hEtyvW.js} +1 -1
- package/dist/assets/{bank-CBIxfTrG.js → bank-CZ3b6K7o.js} +1 -1
- package/dist/assets/{basic-N6vekuGx.js → basic-nJtiapU4.js} +1 -1
- package/dist/assets/{browser-CSb6b6iQ.js → browser-CRgINMXV.js} +1 -1
- package/dist/assets/{card-DrFIu-YX.js → card-ZwByuY3V.js} +1 -1
- package/dist/assets/{ccip-kqAjTfpP.js → ccip-DpVxliwq.js} +1 -1
- package/dist/assets/{checkmark-CjzmzCYU.js → checkmark-BS_v4cXd.js} +1 -1
- package/dist/assets/{checkmark-bold-B66sPzPs.js → checkmark-bold-gJWlj_By.js} +1 -1
- package/dist/assets/{chevron-bottom--JM7vIl_.js → chevron-bottom-DB25HS1C.js} +1 -1
- package/dist/assets/{chevron-left-CPo0GZiC.js → chevron-left-nQo8fTuX.js} +1 -1
- package/dist/assets/{chevron-right-BgXTpiHp.js → chevron-right-D18s-hRU.js} +1 -1
- package/dist/assets/{chevron-top-BDxNAlrf.js → chevron-top-Dj1C_edY.js} +1 -1
- package/dist/assets/{chrome-store-BCPQdBXr.js → chrome-store-BM7Ft7N1.js} +1 -1
- package/dist/assets/{clock-B7Udw_0s.js → clock-Gp9Oq3uQ.js} +1 -1
- package/dist/assets/{close-ClhMnzas.js → close-CvZGqQc2.js} +1 -1
- package/dist/assets/{coinPlaceholder-Bsvaf8UD.js → coinPlaceholder-CxGDG0FR.js} +1 -1
- package/dist/assets/{compass-CtgRkLwG.js → compass-D_QgO5G3.js} +1 -1
- package/dist/assets/{copy-Cju_aL0g.js → copy-ClteGnkV.js} +1 -1
- package/dist/assets/{core-Dv4ivRNs.js → core-BGzEHhOa.js} +3 -3
- package/dist/assets/cursor-CrB_GPgJ.js +3 -0
- package/dist/assets/{cursor-transparent-A0O6SzCH.js → cursor-transparent-D2iBVjlE.js} +1 -1
- package/dist/assets/{desktop-CuYleYi9.js → desktop-C7ehLazj.js} +1 -1
- package/dist/assets/{disconnect-UdfoNj_d.js → disconnect-DfCN-2S3.js} +1 -1
- package/dist/assets/{discord-CBP0IyFM.js → discord-wpQmn3Vb.js} +1 -1
- package/dist/assets/{en_US-Y4ZOVFV4-3vDquI1C.js → en_US-Y4ZOVFV4-BuTiJwkw.js} +4 -4
- package/dist/assets/{etherscan-PHAlrHol.js → etherscan-2pj2VsLB.js} +1 -1
- package/dist/assets/{exclamation-triangle-udtYedHZ.js → exclamation-triangle-D3kTTS0o.js} +1 -1
- package/dist/assets/{extension-BSfnWZTn.js → extension-BaGxTMr_.js} +1 -1
- package/dist/assets/{external-link-BhINeBf6.js → external-link-DPkcev-7.js} +1 -1
- package/dist/assets/{facebook-DPMSywQV.js → facebook-B-3uuPNQ.js} +1 -1
- package/dist/assets/{farcaster-BgZocY3-.js → farcaster-CP4KBXgf.js} +1 -1
- package/dist/assets/{filters-H_ETj-7w.js → filters-DayLkPQN.js} +1 -1
- package/dist/assets/{github-Dnt_pb3p.js → github-nb58vW5j.js} +1 -1
- package/dist/assets/{google-Mu_8pwD-.js → google-Cbr4pP2d.js} +1 -1
- package/dist/assets/{help-circle-DRVJ-8K8.js → help-circle-dO8TgJbO.js} +1 -1
- package/dist/assets/{highlighted-body-KQOG7T2V-ClwcaYX1.js → highlighted-body-KQOG7T2V-D_9pxxPW.js} +1 -1
- package/dist/assets/{id-DXjcfKMm.js → id-FL_XAzzL.js} +1 -1
- package/dist/assets/{image-Bhqm-9NV.js → image-D0cgJ5JG.js} +1 -1
- package/dist/assets/{index-C21bvTBH.js → index-BjRmy3XE.js} +3 -3
- package/dist/assets/{index-BrcuwiCz.js → index-Bv4ef0pT.js} +1 -1
- package/dist/assets/{index-C9wUwD4n.js → index-CWuVUb-3.js} +3 -3
- package/dist/assets/{index-U4U6E7fq.css → index-CqEPMnZS.css} +1 -1
- package/dist/assets/{index-DNA9wtqn.js → index-DvqgpSC-.js} +1 -1
- package/dist/assets/{index-CR02SnS1.js → index-Vg8tZZdB.js} +1 -1
- package/dist/assets/index-iM-80gy8.js +1 -0
- package/dist/assets/{index.es-DX2eegnP.js → index.es-D7XOFxw2.js} +4 -4
- package/dist/assets/{info-BaRtFUwf.js → info-DtK2iYRv.js} +1 -1
- package/dist/assets/{info-circle-Bsl8G0Ii.js → info-circle-D7UwRt4U.js} +1 -1
- package/dist/assets/{lightbulb-BlV4kI0m.js → lightbulb-ClVdo2zx.js} +1 -1
- package/dist/assets/{limits-D_C7APR_.js → limits-BjBtkRFh.js} +1 -1
- package/dist/assets/{mail-BPcY_N8f.js → mail-D7xIfGjE.js} +1 -1
- package/dist/assets/{mermaid-MCJ5UELQ-DAirhLo4.js → mermaid-MCJ5UELQ-DTUKqcxP.js} +8 -8
- package/dist/assets/{metamask-sdk-B0WxSi8v.js → metamask-sdk-BFHzYYth.js} +1 -1
- package/dist/assets/{mobile-9_L4G6Kz.js → mobile-oyVoYDtW.js} +1 -1
- package/dist/assets/{models-BpLCh6Fr.js → models-D5AfPpBK.js} +1 -1
- package/dist/assets/{more-BMrrxkhZ.js → more-DWZmSEse.js} +1 -1
- package/dist/assets/{network-placeholder-CYXkxcyL.js → network-placeholder-DkrrPbIk.js} +1 -1
- package/dist/assets/{nftPlaceholder-CfIu_Ovu.js → nftPlaceholder-y-NnnMjT.js} +1 -1
- package/dist/assets/{off-BpqSEfQB.js → off-Bq6ESslh.js} +1 -1
- package/dist/assets/{play-store-BKqBXU1V.js → play-store-BVSRtmaK.js} +1 -1
- package/dist/assets/{plus-CSgT3KZh.js → plus-CiV0r3Hz.js} +1 -1
- package/dist/assets/{qr-code-edbLJ8Gf.js → qr-code-CQuLdjAg.js} +1 -1
- package/dist/assets/{recycle-horizontal-CuX0JB4-.js → recycle-horizontal-Dz6rR748.js} +1 -1
- package/dist/assets/{refresh-Dq45LHYF.js → refresh-DNo0Vden.js} +1 -1
- package/dist/assets/{reown-logo-CRobwYXY.js → reown-logo-sOWGngZq.js} +1 -1
- package/dist/assets/{search-gYoog0zk.js → search-rho6BP4J.js} +1 -1
- package/dist/assets/{secp256k1-uRM0t8uf.js → secp256k1-eMq7yeYD.js} +1 -1
- package/dist/assets/{send-Pm4IO0Hs.js → send-DxwNodDV.js} +1 -1
- package/dist/assets/{swapHorizontal-DhCZ210V.js → swapHorizontal-CJ1qgU06.js} +1 -1
- package/dist/assets/{swapHorizontalBold-DHO5cxVU.js → swapHorizontalBold-G3QDMS0U.js} +1 -1
- package/dist/assets/{swapHorizontalMedium-VGtbzLgi.js → swapHorizontalMedium-CRUvBpIN.js} +1 -1
- package/dist/assets/{swapHorizontalRoundedBold-6HTAC2Np.js → swapHorizontalRoundedBold-DOVIZTm_.js} +1 -1
- package/dist/assets/{swapVertical-Dg6bMEa-.js → swapVertical-KviDiZLh.js} +1 -1
- package/dist/assets/{telegram-CHXgC-Jw.js → telegram-96Q1zZ7u.js} +1 -1
- package/dist/assets/{three-dots-MixBEg-b.js → three-dots-CLIQcjDl.js} +1 -1
- package/dist/assets/{twitch-CWrx7ZD7.js → twitch-8bwY5wnt.js} +1 -1
- package/dist/assets/{twitterIcon-Vrp2iWQv.js → twitterIcon-yigFfTCz.js} +1 -1
- package/dist/assets/{usage-MPZYg7D2.js → usage-4421Rf6_.js} +1 -1
- package/dist/assets/{useInfiniteQuery-Bpu8bc5A.js → useInfiniteQuery-DXLHm6RI.js} +1 -1
- package/dist/assets/{useTx-Cp52G7Yo.js → useTx-JDF5s1ox.js} +1 -1
- package/dist/assets/{verify-Cv1Ie02p.js → verify-BvV_kZ_V.js} +1 -1
- package/dist/assets/{verify-filled-D4Of1TFY.js → verify-filled-D31I1gjO.js} +1 -1
- package/dist/assets/{w3m-modal-B8kvY5hN.js → w3m-modal-BSlq8p9f.js} +1 -1
- package/dist/assets/{wallet-uxpqh3A6.js → wallet-CBsAqlQ7.js} +1 -1
- package/dist/assets/{wallet-placeholder-C-l2svWA.js → wallet-placeholder-DHTeowzX.js} +1 -1
- package/dist/assets/{walletconnect-0CplSxZT.js → walletconnect-CR_egxhB.js} +1 -1
- package/dist/assets/{warning-circle-gLBXgr6A.js → warning-circle-BP-YPvjB.js} +1 -1
- package/dist/assets/{x-C17dW4I6.js → x-CpVuDSxb.js} +1 -1
- package/dist/index.html +3 -3
- package/package.json +3 -3
- package/dist/assets/cursor-D3NwpSI9.js +0 -3
- package/dist/assets/index-DqHGr8d4.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bh as J,v as Y,r as b,j as e,bi as k,I as P,bj as F,B as y,b3 as X,bk as Z,b7 as ee,bc as K,bl as se,bm as A,bn as le,bo as E,T as D,C as ie,bp as U,bg as ne,bq as ae,ac as te,br as ce,bs as re,bt as oe,b5 as de}from"./index-C21bvTBH.js";import{S as T}from"./SelectField-D_BPTzpT.js";import{S as V}from"./Segmented-BJmgB5-Y.js";import{S as L}from"./Switch-JCyfy3G5.js";import{D as R}from"./Disclosure-h1MJg5Wn.js";function C(l,c){const a=l==null?void 0:l.find(o=>J(o.peerId,c));return(a==null?void 0:a.displayName)??Y(c,8,4)}function z({value:l,onChange:c,peers:a,label:o,ordered:d,placeholder:t="Search sellers or paste a peer id"}){const[m,g]=b.useState(""),j=b.useId(),h=b.useId();function r(){const n=m.trim();if(!n)return;const p=a==null?void 0:a.find(x=>{var i;return((i=x.displayName)==null?void 0:i.toLowerCase())===n.toLowerCase()||x.peerId.toLowerCase()===n.toLowerCase()}),N=(p==null?void 0:p.peerId)??n;l.some(x=>x.toLowerCase()===N.toLowerCase())||c([...l,N]),g("")}return e.jsxs("div",{className:"gc-picker",children:[e.jsx("label",{className:"as-field__label",htmlFor:h,children:o}),l.length>0&&e.jsx("ol",{className:d?"gc-chips gc-chips--ordered":"gc-chips",children:l.map((n,p)=>e.jsxs("li",{className:"gc-chip",children:[d&&e.jsx("span",{className:"gc-chip__index",children:p+1}),e.jsx("span",{className:"gc-chip__label",title:n,children:C(a,n)}),d&&e.jsxs(e.Fragment,{children:[e.jsx(k,{label:`Move ${C(a,n)} up`,size:"sm",disabled:p===0,onClick:()=>c(F(l,p,-1)),children:e.jsx(P.up,{size:12})}),e.jsx(k,{label:`Move ${C(a,n)} down`,size:"sm",disabled:p===l.length-1,onClick:()=>c(F(l,p,1)),children:e.jsx(P.down,{size:12})})]}),e.jsx(k,{label:`Remove ${C(a,n)}`,size:"sm",onClick:()=>c(l.filter(N=>N!==n)),children:e.jsx(P.x,{size:12})})]},n))}),e.jsxs("div",{className:"gc-inline",children:[e.jsx("input",{id:h,className:"as-field__input gc-picker__input",list:j,value:m,placeholder:t,onChange:n=>g(n.target.value),onKeyDown:n=>{n.key==="Enter"&&(n.preventDefault(),r())}}),e.jsx("datalist",{id:j,children:a==null?void 0:a.map(n=>e.jsx("option",{value:n.peerId,children:n.displayName??Y(n.peerId)},n.peerId))}),e.jsx(y,{variant:"outline",size:"sm",onClick:r,disabled:!m.trim(),children:"Add"})]})]})}function me({value:l,onChange:c,label:a,suggestions:o,placeholder:d}){const[t,m]=b.useState(""),g=b.useId(),j=b.useId();function h(){const r=t.trim();r&&!l.includes(r)&&c([...l,r]),m("")}return e.jsxs("div",{className:"gc-picker",children:[e.jsx("label",{className:"as-field__label",htmlFor:j,children:a}),l.length>0&&e.jsx("ul",{className:"gc-chips",children:l.map(r=>e.jsxs("li",{className:"gc-chip",children:[e.jsx("span",{className:"gc-chip__label",children:r}),e.jsx(k,{label:`Remove ${r}`,size:"sm",onClick:()=>c(l.filter(n=>n!==r)),children:e.jsx(P.x,{size:12})})]},r))}),e.jsxs("div",{className:"gc-inline",children:[e.jsx("input",{id:j,className:"as-field__input gc-picker__input",list:g,value:t,placeholder:d,onChange:r=>m(r.target.value),onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),h())}}),e.jsx("datalist",{id:g,children:o==null?void 0:o.map(r=>e.jsx("option",{value:r},r))}),e.jsx(y,{variant:"outline",size:"sm",onClick:h,disabled:!t.trim(),children:"Add"})]})]})}function he({draft:l,parent:c,above:a,peers:o,lists:d}){const t=b.useMemo(()=>{if(!o||o.length===0)return null;let m;try{m=ne(l,d)}catch{return null}return{matched:ae(K(c,m),o,d).length,total:o.length}},[l,c,o,d]);return t?t.matched===0?e.jsxs(te,{tone:"warning",title:"No seller matches this policy",children:["With ",a?`${a} and `:"","these settings, none of the ",t.total," sellers this gateway sees can serve a request. Requests will fail until you loosen it."]}):e.jsxs("p",{className:"gc-muted","aria-live":"polite",children:["Matches ",t.matched," of ",t.total," sellers",a?` after ${a}`:"","."]}):null}function fe({value:l,onChange:c,peers:a,lists:o,showTemplates:d=!0,parent:t,disabled:m}){const[g,j]=b.useState(""),[h,r]=b.useState(null),n=(s,u)=>c({...l,[s]:u}),p=X(a),N=o.map(s=>({value:s.id,label:`${s.name} (${s.peerIds.length})`})),x=Z(ee().data),i=b.useMemo(()=>x||t?K(x,t):null,[x,t]),Q=x&&t?"the buyer config and the levels above":x?"the buyer config":t?"the levels above":"",$=s=>(x==null?void 0:x[s])!==void 0&&x[s]===(i==null?void 0:i[s])?"The buyer config":"The levels above",G=se(a)||l.minReputation!==""||(i==null?void 0:i.minReputation)!==void 0;function q(s){var O;let u;if(s==="own"){const w=o.find(H=>H.id===g);if(!w)return;u={allowMode:"only",allowedPeerIds:[],allowedListIds:[w.id]}}else u=ce(re(s));const f=oe(l,u),_=((O=A.find(w=>w.id===s))==null?void 0:O.label)??s;f.length>0?r({label:_,template:u,conflicts:f}):c(U(l,u))}function M(s,u){n("routes",l.routes.map((f,_)=>_===s?u:f))}const S=[l.maxInputUsdPerMillion,l.maxOutputUsdPerMillion,l.maxCachedInputUsdPerMillion,l.maxImageUsdPerImage].filter(s=>s.trim()!=="").length,I=(s,u)=>e.jsx(D,{size:"sm",className:"gc-num",label:u,inputMode:"decimal",value:l[s],placeholder:(i==null?void 0:i[s])!==void 0?`≤ ${de(i[s])} above`:"No cap",onChange:f=>n(s,f.target.value)}),v=e.jsxs(e.Fragment,{children:[e.jsx(he,{draft:l,parent:i,above:Q,peers:a,lists:o}),d&&!m&&e.jsxs("div",{className:"gc-policy__templates",children:[e.jsx("span",{className:"gc-muted",children:"Start from"}),A.filter(s=>s.id!=="own").map(s=>e.jsx(y,{size:"sm",variant:"outline",title:s.description,onClick:()=>q(s.id),children:s.label},s.id)),o.length>0&&e.jsxs("span",{className:"gc-inline",children:[e.jsx(T,{size:"sm","aria-label":"Peer list for Own peers only",value:g,onChange:j,options:[{value:"",label:"Own peer list…"},...N]}),e.jsx(y,{size:"sm",variant:"outline",disabled:!g,onClick:()=>q("own"),children:"Use"})]}),e.jsx(y,{size:"sm",variant:"link",className:"gc-policy__clear",onClick:()=>c(le()),children:"Clear policy"})]}),e.jsxs("div",{className:"gc-policy__cols",children:[e.jsxs("section",{className:"gc-policy__section",children:[e.jsx("h3",{children:"Sellers"}),e.jsx(V,{label:"Which sellers may serve",value:l.allowMode,onChange:s=>n("allowMode",s),options:[{value:"any",label:"Any seller"},{value:"only",label:"Only these"}]}),l.allowMode==="only"&&e.jsxs(e.Fragment,{children:[e.jsx(z,{label:"Allowed sellers",value:l.allowedPeerIds,onChange:s=>n("allowedPeerIds",s),peers:a}),e.jsx(W,{label:"Allowed peer lists",lists:o,value:l.allowedListIds,onChange:s=>n("allowedListIds",s)}),l.allowedPeerIds.length===0&&l.allowedListIds.length===0&&e.jsx("p",{className:"gc-warn",children:"An empty allow list means no seller can serve."})]}),e.jsx(z,{label:"Blocked sellers",value:l.blockedPeerIds,onChange:s=>n("blockedPeerIds",s),peers:a}),e.jsx(W,{label:"Blocked peer lists",lists:o,value:l.blockedListIds,onChange:s=>n("blockedListIds",s)})]}),e.jsxs("section",{className:"gc-policy__section",children:[e.jsx("h3",{children:"Quality and ranking"}),e.jsx(B,{label:"Minimum trust score",value:l.minTrustScore,onChange:s=>n("minTrustScore",s),floor:i==null?void 0:i.minTrustScore,floorSource:$("minTrustScore")}),e.jsxs("div",{className:"gc-policy__switches",children:[e.jsx(L,{checked:l.requireTee||!!(i!=null&&i.requireTee),disabled:!!(i!=null&&i.requireTee),onChange:s=>n("requireTee",s),label:"TEE sellers only"}),e.jsx(L,{checked:l.requireVerified||!!(i!=null&&i.requireVerified),disabled:!!(i!=null&&i.requireVerified),onChange:s=>n("requireVerified",s),label:"Verified sellers only"})]}),((i==null?void 0:i.requireTee)||(i==null?void 0:i.requireVerified))&&e.jsxs("span",{className:"as-field__hint",children:[i.requireTee&&i.requireVerified?"TEE and verified sellers are":i.requireTee?"TEE sellers are":"Verified sellers are"," already required above."]}),e.jsxs("div",{className:"gc-policy__pair",children:[e.jsx(T,{size:"sm",label:"Sort by",value:l.sort,onChange:s=>n("sort",s),options:[{value:"",label:"Inherit"},...Object.keys(E).map(s=>({value:s,label:E[s]}))]}),e.jsx(T,{size:"sm",label:"Free sellers first",value:l.preferFreePeers,onChange:s=>n("preferFreePeers",s),options:[{value:"inherit",label:"Inherit"},{value:"yes",label:"Yes"},{value:"no",label:"No"}]})]}),e.jsx(V,{label:"Which models may be used",value:l.modelsMode,onChange:s=>n("modelsMode",s),options:[{value:"any",label:"Any model"},{value:"only",label:"Only these models"}]}),l.modelsMode==="only"&&e.jsx(me,{label:"Allowed models",value:l.allowedModels,onChange:s=>n("allowedModels",s),suggestions:p,placeholder:"Model id"})]})]}),e.jsxs("div",{className:"gc-policy__advanced",children:[e.jsx(R,{title:"Price caps",summary:S?`${S} set`:"None",defaultOpen:m&&S>0,children:e.jsxs("div",{className:"gc-policy__caps",children:[I("maxInputUsdPerMillion","Input $/M"),I("maxOutputUsdPerMillion","Output $/M"),I("maxCachedInputUsdPerMillion","Cached input $/M"),I("maxImageUsdPerImage","$ per image")]})}),e.jsxs(R,{title:"Fallback chains",summary:l.routes.length?`${l.routes.length} chain${l.routes.length===1?"":"s"}`:"None",defaultOpen:m&&l.routes.length>0,children:[e.jsx("p",{className:"gc-fineprint",children:"Sellers to try first for a model, in order. After the chain, normal ranking continues unless the chain is strict."}),l.routes.map((s,u)=>e.jsxs("div",{className:"gc-route",children:[e.jsxs("div",{className:"gc-inline",children:[e.jsx(D,{size:"sm",label:"Model",list:"gc-policy-models",value:s.model,placeholder:"Model id",onChange:f=>M(u,{...s,model:f.target.value})}),e.jsx(L,{checked:s.strict,onChange:f=>M(u,{...s,strict:f}),label:"Strict"}),e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>n("routes",l.routes.filter((f,_)=>_!==u)),children:"Remove"})]}),e.jsx(z,{label:"Sellers, in order",ordered:!0,value:s.peerIds,onChange:f=>M(u,{...s,peerIds:f}),peers:a})]},u)),e.jsx("datalist",{id:"gc-policy-models",children:p.map(s=>e.jsx("option",{value:s},s))}),e.jsx("div",{children:e.jsx(y,{variant:"outline",size:"sm",onClick:()=>n("routes",[...l.routes,{model:"",peerIds:[],strict:!1}]),children:"Add fallback chain"})})]}),G&&e.jsx(R,{title:"Reputation",summary:l.minReputation!==""?`≥ ${l.minReputation}`:(i==null?void 0:i.minReputation)!==void 0?`Inherit (≥ ${i.minReputation})`:"Inherit",defaultOpen:m&&l.minReputation!=="",children:e.jsx(B,{label:"Minimum reputation",value:l.minReputation,onChange:s=>n("minReputation",s),floor:i==null?void 0:i.minReputation,floorSource:$("minReputation")})})]}),e.jsx(ie,{isOpen:h!==null,tone:"primary",title:`Apply “${(h==null?void 0:h.label)??""}”?`,confirmLabel:"Replace and apply",body:e.jsxs(e.Fragment,{children:["This template changes settings you already set: ",e.jsx("strong",{children:h==null?void 0:h.conflicts.join(", ")}),". Your other settings stay."]}),onClose:()=>r(null),onConfirm:()=>{h&&c(U(l,h.template)),r(null)}})]});return m?e.jsx("fieldset",{className:"gc-policy gc-policy--readonly",disabled:!0,children:v}):e.jsx("div",{className:"gc-policy",children:v})}function B({label:l,value:c,onChange:a,clearable:o=!0,hint:d,floor:t,floorSource:m="The levels above"}){const g=b.useId(),j=c!=="",h=t!==void 0&&t>0,r=h&&j&&Number(c)<=t,n=j?c:h?`${t} inherited`:"Inherit";return e.jsxs("div",{className:"gc-slider",children:[e.jsxs("div",{className:"gc-slider__head",children:[e.jsx("span",{className:"as-field__label",id:g,children:l}),e.jsx("span",{className:j?"gc-slider__value":"gc-slider__value gc-slider__value--inherit",children:n})]}),e.jsxs("div",{className:"gc-inline",children:[e.jsx("input",{type:"range",min:0,max:100,step:5,value:j?Number(c):h?t:0,"aria-labelledby":g,onChange:p=>a(p.target.value)}),o&&j&&e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>a(""),children:"Clear"})]}),r?e.jsxs("span",{className:"as-field__hint gc-override",children:[e.jsx("span",{className:"gc-attention","aria-hidden":"true"}),m," already requires ≥ ",t,". No effect."]}):h&&e.jsxs("span",{className:"as-field__hint",children:[m," requires ≥ ",t,". Only a higher value narrows it."]}),d&&e.jsx("span",{className:"as-field__hint",children:d})]})}function W({label:l,lists:c,value:a,onChange:o}){return c.length===0?null:e.jsxs("fieldset",{className:"gc-checks",children:[e.jsx("legend",{className:"as-field__label",children:l}),c.map(d=>e.jsxs("label",{className:"gc-check",children:[e.jsx("input",{type:"checkbox",checked:a.includes(d.id),onChange:t=>o(t.target.checked?[...a,d.id]:a.filter(m=>m!==d.id))}),d.name," ",e.jsxs("span",{className:"gc-muted",children:["(",d.peerIds.length,")"]})]},d.id))]})}export{fe as P,B as S,z as a,C as p};
|
|
1
|
+
import{bh as J,v as Y,r as b,j as e,bi as k,I as P,bj as F,B as y,b3 as X,bk as Z,b7 as ee,bc as K,bl as se,bm as A,bn as le,bo as E,T as D,C as ie,bp as U,bg as ne,bq as ae,ac as te,br as ce,bs as re,bt as oe,b5 as de}from"./index-BjRmy3XE.js";import{S as T}from"./SelectField-BSNXjRiC.js";import{S as V}from"./Segmented-C9jux-Mr.js";import{S as L}from"./Switch-hSHNLapF.js";import{D as R}from"./Disclosure-DS6GTz8G.js";function C(l,c){const a=l==null?void 0:l.find(o=>J(o.peerId,c));return(a==null?void 0:a.displayName)??Y(c,8,4)}function z({value:l,onChange:c,peers:a,label:o,ordered:d,placeholder:t="Search sellers or paste a peer id"}){const[m,g]=b.useState(""),j=b.useId(),h=b.useId();function r(){const n=m.trim();if(!n)return;const p=a==null?void 0:a.find(x=>{var i;return((i=x.displayName)==null?void 0:i.toLowerCase())===n.toLowerCase()||x.peerId.toLowerCase()===n.toLowerCase()}),N=(p==null?void 0:p.peerId)??n;l.some(x=>x.toLowerCase()===N.toLowerCase())||c([...l,N]),g("")}return e.jsxs("div",{className:"gc-picker",children:[e.jsx("label",{className:"as-field__label",htmlFor:h,children:o}),l.length>0&&e.jsx("ol",{className:d?"gc-chips gc-chips--ordered":"gc-chips",children:l.map((n,p)=>e.jsxs("li",{className:"gc-chip",children:[d&&e.jsx("span",{className:"gc-chip__index",children:p+1}),e.jsx("span",{className:"gc-chip__label",title:n,children:C(a,n)}),d&&e.jsxs(e.Fragment,{children:[e.jsx(k,{label:`Move ${C(a,n)} up`,size:"sm",disabled:p===0,onClick:()=>c(F(l,p,-1)),children:e.jsx(P.up,{size:12})}),e.jsx(k,{label:`Move ${C(a,n)} down`,size:"sm",disabled:p===l.length-1,onClick:()=>c(F(l,p,1)),children:e.jsx(P.down,{size:12})})]}),e.jsx(k,{label:`Remove ${C(a,n)}`,size:"sm",onClick:()=>c(l.filter(N=>N!==n)),children:e.jsx(P.x,{size:12})})]},n))}),e.jsxs("div",{className:"gc-inline",children:[e.jsx("input",{id:h,className:"as-field__input gc-picker__input",list:j,value:m,placeholder:t,onChange:n=>g(n.target.value),onKeyDown:n=>{n.key==="Enter"&&(n.preventDefault(),r())}}),e.jsx("datalist",{id:j,children:a==null?void 0:a.map(n=>e.jsx("option",{value:n.peerId,children:n.displayName??Y(n.peerId)},n.peerId))}),e.jsx(y,{variant:"outline",size:"sm",onClick:r,disabled:!m.trim(),children:"Add"})]})]})}function me({value:l,onChange:c,label:a,suggestions:o,placeholder:d}){const[t,m]=b.useState(""),g=b.useId(),j=b.useId();function h(){const r=t.trim();r&&!l.includes(r)&&c([...l,r]),m("")}return e.jsxs("div",{className:"gc-picker",children:[e.jsx("label",{className:"as-field__label",htmlFor:j,children:a}),l.length>0&&e.jsx("ul",{className:"gc-chips",children:l.map(r=>e.jsxs("li",{className:"gc-chip",children:[e.jsx("span",{className:"gc-chip__label",children:r}),e.jsx(k,{label:`Remove ${r}`,size:"sm",onClick:()=>c(l.filter(n=>n!==r)),children:e.jsx(P.x,{size:12})})]},r))}),e.jsxs("div",{className:"gc-inline",children:[e.jsx("input",{id:j,className:"as-field__input gc-picker__input",list:g,value:t,placeholder:d,onChange:r=>m(r.target.value),onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),h())}}),e.jsx("datalist",{id:g,children:o==null?void 0:o.map(r=>e.jsx("option",{value:r},r))}),e.jsx(y,{variant:"outline",size:"sm",onClick:h,disabled:!t.trim(),children:"Add"})]})]})}function he({draft:l,parent:c,above:a,peers:o,lists:d}){const t=b.useMemo(()=>{if(!o||o.length===0)return null;let m;try{m=ne(l,d)}catch{return null}return{matched:ae(K(c,m),o,d).length,total:o.length}},[l,c,o,d]);return t?t.matched===0?e.jsxs(te,{tone:"warning",title:"No seller matches this policy",children:["With ",a?`${a} and `:"","these settings, none of the ",t.total," sellers this gateway sees can serve a request. Requests will fail until you loosen it."]}):e.jsxs("p",{className:"gc-muted","aria-live":"polite",children:["Matches ",t.matched," of ",t.total," sellers",a?` after ${a}`:"","."]}):null}function fe({value:l,onChange:c,peers:a,lists:o,showTemplates:d=!0,parent:t,disabled:m}){const[g,j]=b.useState(""),[h,r]=b.useState(null),n=(s,u)=>c({...l,[s]:u}),p=X(a),N=o.map(s=>({value:s.id,label:`${s.name} (${s.peerIds.length})`})),x=Z(ee().data),i=b.useMemo(()=>x||t?K(x,t):null,[x,t]),Q=x&&t?"the buyer config and the levels above":x?"the buyer config":t?"the levels above":"",$=s=>(x==null?void 0:x[s])!==void 0&&x[s]===(i==null?void 0:i[s])?"The buyer config":"The levels above",G=se(a)||l.minReputation!==""||(i==null?void 0:i.minReputation)!==void 0;function q(s){var O;let u;if(s==="own"){const w=o.find(H=>H.id===g);if(!w)return;u={allowMode:"only",allowedPeerIds:[],allowedListIds:[w.id]}}else u=ce(re(s));const f=oe(l,u),_=((O=A.find(w=>w.id===s))==null?void 0:O.label)??s;f.length>0?r({label:_,template:u,conflicts:f}):c(U(l,u))}function M(s,u){n("routes",l.routes.map((f,_)=>_===s?u:f))}const S=[l.maxInputUsdPerMillion,l.maxOutputUsdPerMillion,l.maxCachedInputUsdPerMillion,l.maxImageUsdPerImage].filter(s=>s.trim()!=="").length,I=(s,u)=>e.jsx(D,{size:"sm",className:"gc-num",label:u,inputMode:"decimal",value:l[s],placeholder:(i==null?void 0:i[s])!==void 0?`≤ ${de(i[s])} above`:"No cap",onChange:f=>n(s,f.target.value)}),v=e.jsxs(e.Fragment,{children:[e.jsx(he,{draft:l,parent:i,above:Q,peers:a,lists:o}),d&&!m&&e.jsxs("div",{className:"gc-policy__templates",children:[e.jsx("span",{className:"gc-muted",children:"Start from"}),A.filter(s=>s.id!=="own").map(s=>e.jsx(y,{size:"sm",variant:"outline",title:s.description,onClick:()=>q(s.id),children:s.label},s.id)),o.length>0&&e.jsxs("span",{className:"gc-inline",children:[e.jsx(T,{size:"sm","aria-label":"Peer list for Own peers only",value:g,onChange:j,options:[{value:"",label:"Own peer list…"},...N]}),e.jsx(y,{size:"sm",variant:"outline",disabled:!g,onClick:()=>q("own"),children:"Use"})]}),e.jsx(y,{size:"sm",variant:"link",className:"gc-policy__clear",onClick:()=>c(le()),children:"Clear policy"})]}),e.jsxs("div",{className:"gc-policy__cols",children:[e.jsxs("section",{className:"gc-policy__section",children:[e.jsx("h3",{children:"Sellers"}),e.jsx(V,{label:"Which sellers may serve",value:l.allowMode,onChange:s=>n("allowMode",s),options:[{value:"any",label:"Any seller"},{value:"only",label:"Only these"}]}),l.allowMode==="only"&&e.jsxs(e.Fragment,{children:[e.jsx(z,{label:"Allowed sellers",value:l.allowedPeerIds,onChange:s=>n("allowedPeerIds",s),peers:a}),e.jsx(W,{label:"Allowed peer lists",lists:o,value:l.allowedListIds,onChange:s=>n("allowedListIds",s)}),l.allowedPeerIds.length===0&&l.allowedListIds.length===0&&e.jsx("p",{className:"gc-warn",children:"An empty allow list means no seller can serve."})]}),e.jsx(z,{label:"Blocked sellers",value:l.blockedPeerIds,onChange:s=>n("blockedPeerIds",s),peers:a}),e.jsx(W,{label:"Blocked peer lists",lists:o,value:l.blockedListIds,onChange:s=>n("blockedListIds",s)})]}),e.jsxs("section",{className:"gc-policy__section",children:[e.jsx("h3",{children:"Quality and ranking"}),e.jsx(B,{label:"Minimum trust score",value:l.minTrustScore,onChange:s=>n("minTrustScore",s),floor:i==null?void 0:i.minTrustScore,floorSource:$("minTrustScore")}),e.jsxs("div",{className:"gc-policy__switches",children:[e.jsx(L,{checked:l.requireTee||!!(i!=null&&i.requireTee),disabled:!!(i!=null&&i.requireTee),onChange:s=>n("requireTee",s),label:"TEE sellers only"}),e.jsx(L,{checked:l.requireVerified||!!(i!=null&&i.requireVerified),disabled:!!(i!=null&&i.requireVerified),onChange:s=>n("requireVerified",s),label:"Verified sellers only"})]}),((i==null?void 0:i.requireTee)||(i==null?void 0:i.requireVerified))&&e.jsxs("span",{className:"as-field__hint",children:[i.requireTee&&i.requireVerified?"TEE and verified sellers are":i.requireTee?"TEE sellers are":"Verified sellers are"," already required above."]}),e.jsxs("div",{className:"gc-policy__pair",children:[e.jsx(T,{size:"sm",label:"Sort by",value:l.sort,onChange:s=>n("sort",s),options:[{value:"",label:"Inherit"},...Object.keys(E).map(s=>({value:s,label:E[s]}))]}),e.jsx(T,{size:"sm",label:"Free sellers first",value:l.preferFreePeers,onChange:s=>n("preferFreePeers",s),options:[{value:"inherit",label:"Inherit"},{value:"yes",label:"Yes"},{value:"no",label:"No"}]})]}),e.jsx(V,{label:"Which models may be used",value:l.modelsMode,onChange:s=>n("modelsMode",s),options:[{value:"any",label:"Any model"},{value:"only",label:"Only these models"}]}),l.modelsMode==="only"&&e.jsx(me,{label:"Allowed models",value:l.allowedModels,onChange:s=>n("allowedModels",s),suggestions:p,placeholder:"Model id"})]})]}),e.jsxs("div",{className:"gc-policy__advanced",children:[e.jsx(R,{title:"Price caps",summary:S?`${S} set`:"None",defaultOpen:m&&S>0,children:e.jsxs("div",{className:"gc-policy__caps",children:[I("maxInputUsdPerMillion","Input $/M"),I("maxOutputUsdPerMillion","Output $/M"),I("maxCachedInputUsdPerMillion","Cached input $/M"),I("maxImageUsdPerImage","$ per image")]})}),e.jsxs(R,{title:"Fallback chains",summary:l.routes.length?`${l.routes.length} chain${l.routes.length===1?"":"s"}`:"None",defaultOpen:m&&l.routes.length>0,children:[e.jsx("p",{className:"gc-fineprint",children:"Sellers to try first for a model, in order. After the chain, normal ranking continues unless the chain is strict."}),l.routes.map((s,u)=>e.jsxs("div",{className:"gc-route",children:[e.jsxs("div",{className:"gc-inline",children:[e.jsx(D,{size:"sm",label:"Model",list:"gc-policy-models",value:s.model,placeholder:"Model id",onChange:f=>M(u,{...s,model:f.target.value})}),e.jsx(L,{checked:s.strict,onChange:f=>M(u,{...s,strict:f}),label:"Strict"}),e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>n("routes",l.routes.filter((f,_)=>_!==u)),children:"Remove"})]}),e.jsx(z,{label:"Sellers, in order",ordered:!0,value:s.peerIds,onChange:f=>M(u,{...s,peerIds:f}),peers:a})]},u)),e.jsx("datalist",{id:"gc-policy-models",children:p.map(s=>e.jsx("option",{value:s},s))}),e.jsx("div",{children:e.jsx(y,{variant:"outline",size:"sm",onClick:()=>n("routes",[...l.routes,{model:"",peerIds:[],strict:!1}]),children:"Add fallback chain"})})]}),G&&e.jsx(R,{title:"Reputation",summary:l.minReputation!==""?`≥ ${l.minReputation}`:(i==null?void 0:i.minReputation)!==void 0?`Inherit (≥ ${i.minReputation})`:"Inherit",defaultOpen:m&&l.minReputation!=="",children:e.jsx(B,{label:"Minimum reputation",value:l.minReputation,onChange:s=>n("minReputation",s),floor:i==null?void 0:i.minReputation,floorSource:$("minReputation")})})]}),e.jsx(ie,{isOpen:h!==null,tone:"primary",title:`Apply “${(h==null?void 0:h.label)??""}”?`,confirmLabel:"Replace and apply",body:e.jsxs(e.Fragment,{children:["This template changes settings you already set: ",e.jsx("strong",{children:h==null?void 0:h.conflicts.join(", ")}),". Your other settings stay."]}),onClose:()=>r(null),onConfirm:()=>{h&&c(U(l,h.template)),r(null)}})]});return m?e.jsx("fieldset",{className:"gc-policy gc-policy--readonly",disabled:!0,children:v}):e.jsx("div",{className:"gc-policy",children:v})}function B({label:l,value:c,onChange:a,clearable:o=!0,hint:d,floor:t,floorSource:m="The levels above"}){const g=b.useId(),j=c!=="",h=t!==void 0&&t>0,r=h&&j&&Number(c)<=t,n=j?c:h?`${t} inherited`:"Inherit";return e.jsxs("div",{className:"gc-slider",children:[e.jsxs("div",{className:"gc-slider__head",children:[e.jsx("span",{className:"as-field__label",id:g,children:l}),e.jsx("span",{className:j?"gc-slider__value":"gc-slider__value gc-slider__value--inherit",children:n})]}),e.jsxs("div",{className:"gc-inline",children:[e.jsx("input",{type:"range",min:0,max:100,step:5,value:j?Number(c):h?t:0,"aria-labelledby":g,onChange:p=>a(p.target.value)}),o&&j&&e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>a(""),children:"Clear"})]}),r?e.jsxs("span",{className:"as-field__hint gc-override",children:[e.jsx("span",{className:"gc-attention","aria-hidden":"true"}),m," already requires ≥ ",t,". No effect."]}):h&&e.jsxs("span",{className:"as-field__hint",children:[m," requires ≥ ",t,". Only a higher value narrows it."]}),d&&e.jsx("span",{className:"as-field__hint",children:d})]})}function W({label:l,lists:c,value:a,onChange:o}){return c.length===0?null:e.jsxs("fieldset",{className:"gc-checks",children:[e.jsx("legend",{className:"as-field__label",children:l}),c.map(d=>e.jsxs("label",{className:"gc-check",children:[e.jsx("input",{type:"checkbox",checked:a.includes(d.id),onChange:t=>o(t.target.checked?[...a,d.id]:a.filter(m=>m!==d.id))}),d.name," ",e.jsxs("span",{className:"gc-muted",children:["(",d.peerIds.length,")"]})]},d.id))]})}export{fe as P,B as S,z as a,C as p};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b9 as p,r as d,j as e,C as m,bz as x,bA as b,bB as v,t as j,be as y,bd as w,bg as f,b2 as C,B as h,A as k}from"./index-
|
|
1
|
+
import{b9 as p,r as d,j as e,C as m,bz as x,bA as b,bB as v,t as j,be as y,bd as w,bg as f,b2 as C,B as h,A as k}from"./index-BjRmy3XE.js";import{P}from"./PolicyEditor-B5BAs2vC.js";function L(){const a=p(),[s,n]=d.useState(null),l=d.useRef(null),r=t=>new Promise(u=>{l.current=u,n(t)}),o=t=>{var u;n(null),(u=l.current)==null||u.call(l,t),l.current=null},i=(t,u)=>x(t.some(g=>b(g,a.data??null)),u,r),c=(s==null?void 0:s.kind)==="narrowed"?e.jsx(m,{isOpen:!0,tone:"primary",title:"The levels above allow less",confirmLabel:"Save anyway",cancelLabel:"Go back",onClose:()=>o(!1),onConfirm:()=>o(!0),body:e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsx("span",{children:"Part of this change has no effect, because a workspace, member or admin restriction above it is tighter. Saving stores it as you entered it; only what the levels above allow applies."}),s.lines.length>0&&e.jsx("ul",{className:"gc-list",children:s.lines.map(t=>e.jsx("li",{children:t},t))})]})}):e.jsx(m,{isOpen:(s==null?void 0:s.kind)==="empty",tone:"danger",title:"Save an empty allow list?",confirmLabel:"Save anyway",cancelLabel:"Go back",onClose:()=>o(!1),onConfirm:()=>o(!0),body:e.jsxs(e.Fragment,{children:["With this allow list ",e.jsx("strong",{children:"no seller can serve"})," requests here (it names no seller, or none the levels above allow), so they fail until you change it. To let any seller serve, choose “Any seller” instead."]})});return{save:i,dialog:c}}function S({policy:a,invalid:s,empty:n="Inherits everything"}){if(s)return e.jsx("span",{className:"gc-warn",children:"Has an invalid setting; open it to fix."});const l=v(a);return l.length===0?e.jsx("span",{className:"gc-muted",children:n}):e.jsx("span",{className:"gc-chiprow",children:l.map(r=>e.jsx(j,{children:r},r))})}function A(a){const[s,n]=d.useState(()=>y(a)),l=p();return{draft:s,setDraft:n,reset:r=>n(y(r)),build:()=>w(f(s,l.data??null))}}function N(a,s){try{return{policy:f(a,s),error:null}}catch(n){return{policy:null,error:n instanceof Error?n.message:String(n)}}}function D({draft:a,setDraft:s,title:n="Routing policy"}){const l=C(),r=p(),[o,i]=d.useState(null),c=N(a,r.data??null),t=()=>{o&&s(o),i(null)};return e.jsxs("div",{className:"gc-policy-row",children:[e.jsxs("div",{className:"gc-policy-row__text",children:[e.jsx("span",{className:"as-field__label",children:n}),e.jsx(S,{policy:c.policy,invalid:c.error!==null})]}),e.jsx(h,{size:"sm",variant:"outline",onClick:()=>i(a),children:"Edit"}),e.jsx(k,{isOpen:o!==null,onClose:()=>i(null),size:"xl",title:n,subtitle:"Blank settings inherit from the level above, which this can only narrow. Saved with the form.",footer:e.jsxs(e.Fragment,{children:[c.error&&e.jsx("span",{className:"gc-warn gc-footer-note",children:c.error}),e.jsx(h,{variant:"ghost",onClick:t,children:"Cancel"}),e.jsx(h,{onClick:()=>i(null),children:"Done"})]}),children:e.jsx(P,{value:a,onChange:s,peers:l.data,lists:r.data??[]})})]})}export{D as P,L as a,S as b,N as d,A as u};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{u as D,i as J,b4 as B,r as n,s as E,j as e,P as $,B as y,I as f,k as L,Q as R,M as Q,ap as U,t as C,z as V,E as W,m as F,A as G,C as H,b2 as K,T as j,b3 as _,n as X,q as O,e as v}from"./index-
|
|
1
|
+
import{u as D,i as J,b4 as B,r as n,s as E,j as e,P as $,B as y,I as f,k as L,Q as R,M as Q,ap as U,t as C,z as V,E as W,m as F,A as G,C as H,b2 as K,T as j,b3 as _,n as X,q as O,e as v}from"./index-BjRmy3XE.js";import{u as Y,a as Z,P as ee}from"./PolicyField-D7O5D7fl.js";import{D as se}from"./DataTable-B36eMErM.js";import{S as re}from"./SelectField-BSNXjRiC.js";import{T as N}from"./TextAreaField-9B3_7w3L.js";import"./PolicyEditor-B5BAs2vC.js";import"./Segmented-C9jux-Mr.js";import"./roving-DkptacxO.js";import"./Switch-hSHNLapF.js";import"./Disclosure-DS6GTz8G.js";import"./index-iM-80gy8.js";function A(s){return s.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)}function te(s){return/^[a-z0-9][a-z0-9-]{0,47}$/.test(s)}function ae(s){if(!s.trim())return{};let a;try{a=JSON.parse(s)}catch{throw new Error("Parameters must be valid JSON.")}if(!a||typeof a!="object"||Array.isArray(a))throw new Error('Parameters must be a JSON object, like {"temperature": 0.2}.');return a}function oe({initial:s,prefill:a,onDone:m}){const{workspace:p,viewer:c}=D(),u=K(),[o,g]=n.useState((s==null?void 0:s.name)??(a==null?void 0:a.name)??""),[l,d]=n.useState((s==null?void 0:s.slug)??(a?A(a.name):"")),[t,q]=n.useState(!!s),[h,z]=n.useState((s==null?void 0:s.model)??(a==null?void 0:a.model)??""),[b,I]=n.useState(s?s.workspaceId??"":p.id),[S,M]=n.useState((s==null?void 0:s.systemPrompt)??""),[w,T]=n.useState(s&&Object.keys(s.params).length?JSON.stringify(s.params,null,2):""),x=Y(s==null?void 0:s.routingPolicy),P=Z(),i=E({mutationFn:()=>{if(!te(l))throw new Error("Slug must be lowercase letters, numbers and dashes.");const r={name:o.trim(),slug:l,model:h.trim(),workspaceId:b||null,systemPrompt:S.trim()||null,params:ae(w),routingPolicy:x.build()};return P.save([r.routingPolicy],k=>s?v.presets.update(s.id,r,k):v.presets.create(r,k))},onSuccess:r=>m(r),invalidate:[O.group("presets")],toast:"Preset saved"});return e.jsxs("form",{className:"gc-stack",onSubmit:r=>{r.preventDefault(),i.mutate()},children:[e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(j,{label:"Name",required:!0,value:o,onChange:r=>{g(r.target.value),t||d(A(r.target.value))}}),e.jsx(j,{label:"Slug",required:!0,value:l,onChange:r=>{q(!0),d(r.target.value)},hint:e.jsxs(e.Fragment,{children:["Called as ",e.jsxs("code",{children:["@preset/",l||"slug"]})]})})]}),e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(j,{label:"Model",required:!0,list:"gc-preset-models",value:h,onChange:r=>z(r.target.value)}),e.jsx("datalist",{id:"gc-preset-models",children:_(u.data).map(r=>e.jsx("option",{value:r},r))}),e.jsx(re,{label:"Available in",value:b,onChange:I,options:[{value:p.id,label:`${p.name} workspace`},...F(c)?[{value:"",label:"All workspaces"}]:[]]})]}),e.jsx(N,{label:"System prompt",rows:4,value:S,onChange:r=>M(r.target.value),hint:"Added before the client's messages."}),e.jsx(N,{label:"Parameters (JSON)",rows:4,mono:!0,value:w,placeholder:`{
|
|
2
2
|
"temperature": 0.2,
|
|
3
3
|
"max_tokens": 2048
|
|
4
4
|
}`,onChange:r=>T(r.target.value),hint:"Defaults merged under the client's own parameters."}),e.jsx(ee,{draft:x.draft,setDraft:x.setDraft}),i.error?e.jsx(X,{error:i.error,title:"Could not save the preset"}):null,e.jsxs("div",{className:"gc-actions",children:[e.jsx(y,{variant:"ghost",onClick:()=>m(),children:"Cancel"}),e.jsx(y,{type:"submit",disabled:i.isPending||!o.trim()||!h.trim(),children:i.isPending?"Saving…":"Save preset"})]}),P.dialog]})}function je(){const{workspace:s,viewer:a}=D(),m=J(a),p=B(s.id),[c,u]=n.useState(null),[o,g]=n.useState(null),l=E({mutationFn:d=>v.presets.remove(d.id),onSuccess:()=>g(null),invalidate:[O.group("presets")]});return e.jsxs("div",{className:"gc-page",children:[e.jsx($,{title:"Presets",description:e.jsxs(e.Fragment,{children:["A saved model, prompt, parameters and routing. Use one by sending ",e.jsx("code",{children:'"model": "@preset/<slug>"'}),"."]}),actions:m&&e.jsx(y,{variant:"brand",leadingIcon:e.jsx(f.plus,{size:14}),onClick:()=>u("new"),children:"New preset"})}),e.jsx(L,{flush:!0,children:e.jsx(R,{query:p,children:d=>e.jsx(se,{label:"Presets",rows:d,rowKey:t=>t.id,rowLabel:t=>t.name,actions:t=>m&&(t.workspaceId||F(a))?[{label:"Edit",onSelect:()=>u(t)},{label:"Delete",tone:"danger",onSelect:()=>g(t)}]:[],empty:e.jsx(W,{icon:e.jsx(f.presets,{size:18}),title:"No presets yet",body:"Presets let every client share one tuned setup without changing code."}),columns:[{key:"name",header:"Name",render:t=>e.jsx("span",{className:"gc-strong",children:t.name})},{key:"usage",header:"Use as model",render:t=>e.jsxs("span",{className:"gc-inline gc-inline--wrap",children:[e.jsxs(Q,{children:["@preset/",t.slug]}),e.jsx(U,{value:`@preset/${t.slug}`})]})},{key:"model",header:"Model",secondary:!0,render:t=>t.model},{key:"scope",header:"Scope",secondary:!0,render:t=>t.workspaceId?e.jsx(C,{children:"Workspace"}):e.jsx(C,{tone:"info",children:"All workspaces"})},{key:"policy",header:"Routing",secondary:!0,optional:!0,render:t=>e.jsx("span",{className:"gc-muted",children:V(t.routingPolicy)})}]})})}),e.jsx(G,{isOpen:c!==null,onClose:()=>u(null),size:"lg",title:c==="new"?"New preset":"Edit preset",children:c!==null&&e.jsx(oe,{initial:c==="new"?null:c,onDone:()=>u(null)})}),e.jsx(H,{isOpen:o!==null,busy:l.isPending,error:l.error,onClose:()=>g(null),onConfirm:()=>o&&l.mutate(o),title:"Delete this preset?",confirmLabel:"Delete preset",body:e.jsxs(e.Fragment,{children:["Requests that use ",e.jsxs("code",{children:["@preset/",o==null?void 0:o.slug]})," will fail."]})})]})}export{oe as PresetForm,je as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bW as qe,bh as pe,aI as Ve,u as X,a as fe,D as Ke,F as Ge,m as we,i as ye,r as p,O as Ye,b as ve,d as Qe,bX as We,bf as He,Y as U,bY as Je,bZ as Xe,e as L,ag as Ze,j as s,A as Z,ac as Y,n as ee,B as x,L as be,z as es,b9 as ss,s as xe,q as ke,k as je,Q as Pe,E as J,I as _,C as ts,T as q,v as F,M as Ce,ap as Se,t as N,a8 as ns,bU as $,ab as Ie,g as Ne,X as rs,b0 as $e,b_ as Ae,aS as as,b4 as os,b$ as ls,W as is,aU as cs,N as ds,aV as us,aW as ms,b2 as hs,b3 as gs,bl as ps,aY as fs,aZ as ws,a_ as ce,b6 as ys,x as de,a$ as vs,P as bs}from"./index-C21bvTBH.js";import{p as Q,a as xs}from"./PolicyEditor-CRhTwGq0.js";import{S as A}from"./SelectField-D_BPTzpT.js";import{D as Le}from"./DataTable-D2QIQ-gI.js";import{V as Fe,P as Me,b as ks,p as js,S as Ps}from"./models-BpLCh6Fr.js";import{f as Cs}from"./ants-B38m9Phv.js";import{PresetForm as Ss}from"./Presets-DrJ48O3s.js";import{T as Is,a as Ns}from"./Tabs-CGI9v1OW.js";import{S as W}from"./Switch-JCyfy3G5.js";import"./Segmented-BJmgB5-Y.js";import"./roving-DkptacxO.js";import"./Disclosure-h1MJg5Wn.js";import"./index-DqHGr8d4.js";import"./PolicyField-0xAOIP4-.js";import"./TextAreaField-4JuDDT4k.js";function Te(e,t="admin"){return t==="owner"&&Ve(e)?"ownerRoutingPolicy":"routingPolicy"}async function Ee(e,t){const n=(await e.keys.list({workspace:t.workspaceId})).find(a=>a.id===t.keyId);if(!n)throw new Error("That key no longer exists.");return n}async function De(e,t){switch(t.kind){case"gateway":return e.network.gatewayPolicy();case"workspace-org":return(await e.workspaces.get(t.workspaceId)).orgRoutingPolicy;case"workspace":return(await e.workspaces.get(t.workspaceId)).routingPolicy;case"member":{const n=(await e.members.list()).find(a=>a.id===t.memberId);if(!n)throw new Error("That member no longer exists.");return n.routingPolicy}case"key":{const n=await Ee(e,t);return n[Te(n,t.layer)]??null}}}async function $s(e,t,n,a){const o=a!=null&&a.confirmEmpty||a!=null&&a.acceptNarrowed?[a]:[];switch(t.kind){case"gateway":await e.network.setGatewayPolicy(n??{},...o);return;case"workspace-org":await e.workspaces.update(t.workspaceId,{orgRoutingPolicy:n},...o);return;case"workspace":await e.workspaces.update(t.workspaceId,{routingPolicy:n},...o);return;case"member":await e.members.update(t.memberId,{routingPolicy:n},...o);return;case"key":{const i=t.layer==="owner"?Te(await Ee(e,t),"owner"):"routingPolicy";await e.keys.update(t.keyId,{[i]:n},...o);return}}}const ue=e=>JSON.stringify(e??{},Object.keys(e??{}).sort());async function As(e,t,n,a,o,i){const m=await De(e,t),c=qe(m,n,a,o),g=ue(m)!==ue(c)||JSON.stringify(m??{})!==JSON.stringify(c);return g&&await $s(e,t,c,i),{before:m,after:c,changed:g}}function Ls(e,t,n){return e.kind==="key"?{model:t,key:e.keyId,workspace:e.workspaceId}:e.kind==="member"?{model:t,member:e.memberId,workspace:n}:e.kind==="gateway"?{model:t,workspace:n}:{model:t,workspace:e.workspaceId}}const Fs={allow:"Allowed",block:"Blocked",prefer:"Preferred"};function Ms(e){const{action:t,name:n,scopeLabel:a,changed:o,model:i,preview:m,peerId:c}=e,g=Fs[t],f=t==="prefer"?`already first for ${i}`:`already ${g.toLowerCase()}`,l=o?`${g} ${n} ${t==="prefer"?`for ${i} `:""}on ${a}`:`${n} was ${f} on ${a}; nothing changed`;if(!m)return t==="block"?{tone:o?"success":"info",text:`${l}.`}:{tone:"info",text:`${l}. ${e.previewError?`Could not check whether it can serve: ${e.previewError}`:"Could not check whether it can serve."}`};const u=m.candidates.find(v=>pe(v.peerId,c));if(t==="block")return u!=null&&u.eligible?{tone:"warning",text:`${l}, but the route preview still lists it as eligible for ${i}. Reload and check the policy.`}:{tone:o?"success":"info",text:`${l}.`};if(!m.modelAllowed)return{tone:"warning",text:`${l}, but ${i} is not an allowed model here, so it still cannot serve it.`};if(!u)return{tone:"info",text:`${l}. It does not offer ${i} right now, so the preview cannot show its rank.`};if(!u.eligible){const v=u.reasons.length?u.reasons.join("; "):"another level excludes it";return{tone:"warning",text:`${l}, but it still cannot serve ${i} here: ${v}.`}}return t==="prefer"&&u.rank!==null&&u.rank>1?{tone:"warning",text:`${l}, but it ranks #${u.rank} for ${i}: a fallback chain on another level comes first.`}:{tone:o?"success":"info",text:`${l}.${u.rank?` It ranks #${u.rank} for ${i}.`:""}`}}function Ts(e,t,n,a){return e==="gateway"?{kind:e}:e==="workspace"||e==="workspace-org"?{kind:e,workspaceId:n}:t?e==="member"?{kind:e,memberId:t}:{kind:"key",keyId:t,workspaceId:n,layer:a?"admin":"owner"}:null}function Es(e){return e.canForce?"Not allowed above":e.tone==="warning"?"Check the result":"Done"}function Ds({fetching:e,error:t,ready:n,policy:a}){return e?s.jsx(be,{rows:1}):t?s.jsx(ee,{error:t,title:"Could not load this scope's policy"}):n?s.jsxs("p",{className:"gc-muted",children:["Current policy: ",es(a)]}):null}const me={allow:{title:"Allow seller",verb:"Allow"},block:{title:"Block seller",verb:"Block"},prefer:{title:"Prefer seller",verb:"Prefer"}};function Oe({peer:e,action:t,onClose:n,peers:a}){var te,ne,re,ae;const{viewer:o,workspace:i,me:m}=X(),c=fe(),g=Ke(),f=Ge(),l=we(o),u=ye(o),v=[...l?[{value:"gateway",label:"Gateway default (everyone)"}]:[],...l?[{value:"workspace-org",label:`${i.name}: organization policy`}]:[],...u?[{value:"workspace",label:`${i.name}: workspace policy`}]:[],...l?[{value:"member",label:"A member"}]:[],{value:"key",label:"An API key"}],[y,h]=p.useState(v[0].value),[r,b]=p.useState(""),[k,D]=p.useState(""),O=Ye(y==="member"),R=ve(c,y==="key");p.useEffect(()=>{b("")},[y]),p.useEffect(()=>{var d;D(((d=e==null?void 0:e.services[0])==null?void 0:d.service)??"")},[e]);const w=(R.data??[]).filter(d=>d.status==="active"&&(u||d.ownerMemberId===m.member.id)),j=Ts(y,r,i.id,u),[S,T]=p.useState(null);p.useEffect(()=>{T(null)},[y,r,e]);const B=Qe({queryKey:["routing","scope-policy",j],queryFn:()=>De(L,j),enabled:j!==null&&e!==null,staleTime:0}),z=j!==null&&B.isSuccess&&(t!=="prefer"||k!==""),I=B.data??null,ze=t==="allow"&&z&&!(I!=null&&I.allowedPeerIds)&&!(I!=null&&I.allowedPeerLists),Ue=t==="block"&&z&&e!==null&&We(I,e.peerId);let E=((te=v.find(d=>d.value===y))==null?void 0:te.label.replace(/^A[n]? /,"the "))??"this scope";y==="key"&&(E=`key “${((ne=w.find(d=>d.id===r))==null?void 0:ne.label)??r}”`),y==="member"&&(E=`member “${((ae=(re=O.data)==null?void 0:re.find(d=>d.id===r))==null?void 0:ae.label)??r}”`);const P=He({mutationFn:async(d={})=>{var ie;if(!e||!j)return null;const C=k||((ie=e.services[0])==null?void 0:ie.service)||"",{changed:G}=await As(L,j,t,e.peerId,k||void 0,d);let oe=null,le=null;if(C)try{oe=await L.network.routePreview(Ls(j,C,i.id))}catch(_e){le=Ze(_e)}return Ms({action:t,name:Q(a,e.peerId),scopeLabel:E,changed:G,model:C,preview:oe,peerId:e.peerId,previewError:le})},onSuccess:d=>{for(const C of Xe)g.invalidateQueries({queryKey:[C]});d&&(d.tone==="success"?(f(d.text),n()):T(d))},onError:d=>{const C=e?Q(a,e.peerId):"this seller";if(U(d,"narrowed"))T({tone:"warning",canForce:!0,text:`Nothing changed yet. The levels above ${E} do not allow ${C}, so saving this would not let it serve. ${Je(d.details).join(" ")}`.trim()});else if(U(d,"empty_allow_list")){const G=t==="block"?`Blocking ${C}`:`Allowing only ${C}`;T({tone:"warning",text:`Nothing changed. ${G} on ${E} would leave no seller that the levels above allow, so requests would fail. Change the policy on the Routing page if you really want that.`})}}}),K=e?Q(a,e.peerId):"";return s.jsx(Z,{isOpen:e!==null,onClose:n,title:me[t].title,subtitle:K,children:s.jsxs("div",{className:"gc-stack",children:[s.jsx(A,{label:"Apply to",value:y,onChange:d=>h(d),options:v}),y==="member"&&s.jsx(A,{label:"Member",value:r,onChange:b,options:[{value:"",label:"Choose a member"},...(O.data??[]).filter(d=>d.status!=="disabled").map(d=>({value:d.id,label:d.label}))]}),y==="key"&&s.jsx(A,{label:"Key",value:r,onChange:b,options:[{value:"",label:w.length?"Choose a key":"No keys you can edit"},...w.map(d=>({value:d.id,label:d.label}))]}),t==="prefer"&&e&&s.jsx(A,{label:"For model",value:k,onChange:D,options:e.services.map(d=>({value:d.service,label:d.service})),hint:"The seller goes first in this model's fallback chain."}),s.jsx(Ds,{fetching:B.isFetching,error:B.error,ready:z,policy:I}),ze&&s.jsxs(Y,{tone:"warning",children:["This scope has no allow list yet. Allowing ",K," creates one, so only allowed sellers can serve it."]}),Ue&&s.jsxs(Y,{tone:"warning",title:"This is the only allowed seller",children:["Blocking ",K," empties this scope's allow list, so the allow list is removed: any seller that is not blocked may serve it again."]}),t==="block"&&s.jsx("p",{className:"gc-muted",children:"Blocked sellers never serve this scope or anything under it."}),y==="key"&&!u&&s.jsx("p",{className:"gc-muted",children:"This changes your own restrictions on the key. Restrictions a workspace admin set still apply."}),P.error&&!U(P.error,"narrowed")&&!U(P.error,"empty_allow_list")?s.jsx(ee,{error:P.error,title:"Could not update the policy"}):null,S?s.jsxs(s.Fragment,{children:[s.jsx(Y,{tone:S.tone,title:Es(S),children:S.text}),s.jsxs("div",{className:"gc-actions",children:[S.canForce&&s.jsx(x,{variant:"ghost",disabled:P.isPending,onClick:()=>{T(null),P.mutate({acceptNarrowed:!0})},children:"Save it anyway"}),s.jsx(x,{onClick:n,children:S.canForce?"Cancel":"Done"})]})]}):s.jsxs("div",{className:"gc-actions",children:[s.jsx(x,{variant:"ghost",onClick:n,children:"Cancel"}),s.jsx(x,{variant:t==="block"?"danger":"primary",disabled:!z||P.isPending,onClick:()=>P.mutate({}),children:P.isPending?"Saving…":me[t].verb})]})]})})}function Os({initial:e,peers:t,onDone:n}){const[a,o]=p.useState((e==null?void 0:e.name)??""),[i,m]=p.useState((e==null?void 0:e.description)??""),[c,g]=p.useState((e==null?void 0:e.peerIds)??[]),f=xe({mutationFn:()=>{const l={name:a.trim(),description:i.trim()||null,peerIds:c};return e?L.network.updatePeerList(e.id,l):L.network.createPeerList(l)},onSuccess:n,invalidate:[ke.peerLists]});return s.jsxs("form",{className:"gc-stack",onSubmit:l=>{l.preventDefault(),f.mutate()},children:[s.jsx(q,{label:"Name",required:!0,placeholder:"e.g. Our own sellers",value:a,onChange:l=>o(l.target.value)}),s.jsx(q,{label:"Description",value:i,onChange:l=>m(l.target.value)}),s.jsx(xs,{label:"Sellers",value:c,onChange:g,peers:t}),s.jsx("p",{className:"gc-fineprint",children:"Policies refer to a list by name, so editing it changes every policy that uses it."}),f.error?s.jsx(ee,{error:f.error,title:"Could not save the list"}):null,s.jsxs("div",{className:"gc-actions",children:[s.jsx(x,{variant:"ghost",onClick:n,children:"Cancel"}),s.jsx(x,{type:"submit",disabled:f.isPending||!a.trim(),children:f.isPending?"Saving…":"Save list"})]})]})}function Rs({peers:e}){const{viewer:t}=X(),n=we(t),a=ss(),[o,i]=p.useState(null),[m,c]=p.useState(null),g=xe({mutationFn:f=>L.network.removePeerList(f.id),onSuccess:()=>c(null),invalidate:[ke.peerLists]});return s.jsxs(je,{flush:!0,title:"Peer lists",description:"Named groups of sellers to allow or block in one step.",actions:n&&s.jsx(x,{size:"sm",variant:"outline",leadingIcon:s.jsx(_.plus,{size:14}),onClick:()=>i("new"),children:"New list"}),children:[s.jsx(Pe,{query:a,children:f=>s.jsx(Le,{label:"Peer lists",rows:f,rowKey:l=>l.id,rowLabel:l=>l.name,actions:l=>n?[{label:"Edit",onSelect:()=>i(l)},{label:"Delete",tone:"danger",onSelect:()=>c(l)}]:[],empty:s.jsx(J,{icon:s.jsx(_.network,{size:18}),title:"No peer lists",body:"Group sellers you trust, or ones you run yourself."}),columns:[{key:"name",header:"Name",render:l=>s.jsx("span",{className:"gc-strong",children:l.name})},{key:"desc",header:"Description",secondary:!0,render:l=>s.jsx("span",{className:"gc-muted",children:l.description??"—"})},{key:"count",header:"Sellers",align:"right",render:l=>l.peerIds.length}]})}),s.jsx(Z,{isOpen:o!==null,onClose:()=>i(null),title:o==="new"?"New peer list":"Edit peer list",size:"lg",children:o!==null&&s.jsx(Os,{initial:o==="new"?null:o,peers:e,onDone:()=>i(null)})}),s.jsx(ts,{isOpen:m!==null,busy:g.isPending,error:g.error,onClose:()=>c(null),onConfirm:()=>m&&g.mutate(m),title:"Delete this list?",confirmLabel:"Delete",body:"Policies refer to lists by reference: once deleted, the list adds no sellers to them. An allow list made only of deleted lists lets no seller serve."})]})}function Re(e,t){return t?e.services.filter(n=>n.service===t):e.services}function V(e,t,n=""){const a=Re(e,n).map(o=>o[t]).filter(o=>o!==null);return a.length?{min:Math.min(...a),max:Math.max(...a)}:null}function Bs(e,t=""){var n;return((n=V(e,"inputUsdPerMillion",t))==null?void 0:n.min)??null}function zs(e,t=""){var n;return((n=V(e,"outputUsdPerMillion",t))==null?void 0:n.min)??null}function se(e,t=""){return Re(e,t).some(n=>n.inputUsdPerMillion===0&&(n.outputUsdPerMillion??0)===0)}function Us(e,t){const n=t.search.trim().toLowerCase();return e.filter(a=>{var o;return!(n&&!a.peerId.toLowerCase().includes(n)&&!(a.displayName??"").toLowerCase().includes(n)&&!a.services.some(i=>i.service.toLowerCase().includes(n))||t.model&&!a.services.some(i=>i.service===t.model)||t.tee&&!a.tee||t.linked&&!((o=a.verificationLinks)!=null&&o.length)||t.free&&!se(a,t.model))})}const Be={"openai-chat-completions":"Chat completions","openai-responses":"Responses","anthropic-messages":"Messages","openai-images":"Images"};function he(e){return e===null?"—":String(Math.round(e))}function H(e){return e.displayName??F(e.peerId,8,4)}function M(e){return`${e.provider}:${e.service}`}function _s({peer:e}){const t=(e.health.coolingDownUntil??0)>Date.now();return s.jsxs("span",{className:"gc-seller__meta",children:[s.jsxs("span",{className:"gc-peer-id",children:[s.jsx(Ce,{title:e.peerId,children:F(e.peerId,6,4)}),s.jsx(Se,{iconOnly:!0,value:e.peerId,label:"Copy peer id"})]}),s.jsx(Fe,{links:e.verificationLinks}),e.tee&&s.jsx(N,{tone:"info",children:"TEE"}),se(e,"")&&s.jsx(N,{tone:"success",children:"Free"}),e.washFlagged&&s.jsx(N,{tone:"danger",children:"Flagged"}),t&&s.jsx(N,{tone:"warning",children:"Cooling down"}),s.jsxs("span",{className:"gc-muted",children:["Last seen ",ns(e.lastSeen)]})]})}function qs({peer:e,showReputation:t}){const n=(e.health.coolingDownUntil??0)>Date.now();return s.jsxs("div",{className:"gc-grid gc-grid--2 gc-figures gc-panel-figures",children:[s.jsx($,{label:"Trust score",value:he(e.trustScore)}),t&&s.jsx($,{label:"Reputation",value:he(e.reputationScore)}),s.jsx($,{label:"Stake",value:e.stakeAnts?Cs(e.stakeAnts):"—"}),s.jsx($,{label:"Network usage share",value:e.usageShareBps===null?"—":`${(e.usageShareBps/100).toFixed(2)}%`}),s.jsx($,{label:"Latency p50 (this gateway)",value:Ie(e.latencyMsP50)}),s.jsx($,{label:"Requests, 24h (this gateway)",value:Ne(e.requests24h)}),s.jsx($,{label:"Failure streak",value:n?`${e.health.failureStreak}, cooling down until ${rs(e.health.coolingDownUntil)}`:String(e.health.failureStreak)})]})}function Vs({peer:e,selected:t,onSelect:n}){const[a,o]=p.useState(""),i=a.trim().toLowerCase(),m=e.services.filter(c=>!i||c.service.toLowerCase().includes(i));return s.jsx(Me,{title:`Models (${e.services.length})`,actions:e.services.length>6&&s.jsx(q,{size:"sm",type:"search","aria-label":"Search this provider's models",placeholder:"Search models",value:a,onChange:c=>o(c.target.value)}),children:m.length===0?s.jsx("p",{className:"gc-fineprint",children:i?"No models match.":"This provider lists no models."}):s.jsx("ul",{className:"gc-panel-rows","aria-label":"Models and prices",children:m.map(c=>{const g=t!==null&&M(t)===M(c);return s.jsx(ks,{selected:g,title:s.jsx("span",{className:"gc-strong",children:c.service}),meta:s.jsxs(s.Fragment,{children:[s.jsx("span",{children:js(c)}),s.jsx("span",{children:Be[Ae(c)]})]}),actions:s.jsxs(s.Fragment,{children:[s.jsx(Se,{iconOnly:!0,value:$e(e.peerId,c.service),label:`Copy ${c.service} pinned to this provider (peer@model)`}),s.jsx(x,{size:"sm",variant:g?"outline":"ghost","aria-pressed":g,title:"Show the API call for this model",onClick:()=>n(c),children:"API call"})]})},M(c))})})})}function Ks({peer:e,service:t,onSelect:n}){var R;const{workspace:a,viewer:o}=X(),i=fe(),m=as(),c=ve(i),g=os(a.id),[f,l]=p.useState("curl"),[u,v]=p.useState(!1),y=Ae(t),h=$e(e.peerId,t.service),r=((R=g.data)==null?void 0:R.find(w=>w.model===h))??null,b=ls(m,e.peerId,t.service,y,r?`@preset/${r.slug}`:null),k=b.find(w=>w.id===f)??b[0],D=(c.data??[]).some(w=>w.status==="active"),O=ye(o);return s.jsxs(Me,{title:"API call",actions:e.services.length>1&&s.jsx(A,{size:"sm","aria-label":"Model",value:M(t),onChange:w=>{const j=e.services.find(S=>M(S)===w);j&&n(j)},options:e.services.map(w=>({value:M(w),label:w.service}))}),children:[s.jsxs("p",{className:"gc-fineprint",children:["Pinned to this provider with ",s.jsx("code",{children:F(h,10,12)}),"."]}),s.jsx(Is,{id:"gc-connect",label:"Ways to connect",value:k.id,onChange:l,className:"gc-connect-tabs",tabs:b.map(w=>({id:w.id,label:w.label}))}),s.jsxs(Ns,{tabsId:"gc-connect",tab:k.id,className:"gc-stack",children:[k.id==="codex"&&s.jsxs("div",{className:"gc-summary-row",children:[s.jsx("p",{className:"gc-fineprint gc-summary-row__text",children:r?s.jsxs(s.Fragment,{children:["Uses the preset ",s.jsxs("code",{children:["@preset/",r.slug]})," for this model. Codex needs a preset: with a raw GPT model name it switches to a tool format some sellers drop."]}):s.jsx(s.Fragment,{children:"Codex needs a preset, not a raw model name: with a GPT model name it switches to a tool format some sellers drop. Create one for this model, then use its slug."})}),!r&&O&&s.jsx(x,{size:"sm",variant:"outline",onClick:()=>v(!0),children:"Create preset for this model"})]}),k.id==="claude-code"&&y!=="anthropic-messages"&&s.jsxs("p",{className:"gc-fineprint",children:["This model speaks ",Be[y],"; the gateway translates Claude Code's requests for it."]}),s.jsx(is,{code:k.code,label:`${t.service} · ${k.label}`})]}),s.jsxs("p",{className:"gc-fineprint",children:["Set ",s.jsx("code",{children:cs})," to one of your API keys first."," ",c.data&&!D&&s.jsx(ds,{to:"keys",children:"Create an API key"})]}),s.jsx(Z,{isOpen:u,onClose:()=>v(!1),size:"lg",title:"New preset",children:u&&s.jsx(Ss,{initial:null,prefill:{name:t.service,model:h},onDone:w=>{v(!1),w&&l("codex")}})})]})}function Gs({peer:e,peers:t,showReputation:n}){const[a,o]=p.useState(null),[i,m]=p.useState(null),c=p.useRef(null),g=i??e.services[0]??null,f=l=>{var u;m(l),(u=c.current)==null||u.scrollIntoView({behavior:"smooth",block:"start"})};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"gc-stack",children:[s.jsx(_s,{peer:e}),s.jsxs("div",{className:"gc-panel-actions",children:[s.jsx(x,{size:"sm",variant:"outline",onClick:()=>o("allow"),children:"Allow"}),s.jsx(x,{size:"sm",variant:"outline",onClick:()=>o("prefer"),children:"Prefer"}),s.jsx(x,{size:"sm",variant:"danger",onClick:()=>o("block"),children:"Block"})]}),s.jsx(qs,{peer:e,showReputation:n})]}),s.jsx(Vs,{peer:e,selected:g,onSelect:f}),g&&s.jsx("div",{ref:c,className:"gc-scroll-target",children:s.jsx(Ks,{peer:e,service:g,onSelect:m})}),a&&s.jsx(Oe,{peer:e,action:a,peers:t,onClose:()=>o(null)})]})}function ge(e){return e===null?"—":String(Math.round(e))}function Ys({peer:e,model:t}){const n=(e.health.coolingDownUntil??0)>Date.now();return s.jsxs("div",{className:"gc-badges",children:[e.tee&&s.jsx(N,{tone:"info",children:"TEE"}),se(e,t)&&s.jsx(N,{tone:"success",children:"Free"}),e.washFlagged&&s.jsx(N,{tone:"danger",children:"Flagged"}),n&&s.jsx(N,{tone:"warning",children:"Cooling down"})]})}function ct(){const e=us(),t=ms(e.rest),n=hs(),a=p.useMemo(()=>{var h;return t?((h=n.data)==null?void 0:h.find(r=>pe(r.peerId,t)))??null:null},[n.data,t]),[o,i]=p.useState({search:"",model:"",tee:!1,linked:!1,free:!1}),[m,c]=p.useState(null),g=p.useMemo(()=>gs(n.data),[n.data]),f=ps(n.data),l=fs(),u=(h,r)=>i(b=>({...b,[h]:r})),v=t===null?null:{eyebrow:"Provider",title:a?H(a):F(t,8,6),body:n.isLoading?s.jsx(be,{rows:6}):a?s.jsx(Gs,{peer:a,peers:n.data,showReputation:f},a.peerId):s.jsx(J,{icon:s.jsx(_.providers,{size:18}),title:"Provider not found",body:`This gateway does not see ${F(t,8,6)} right now.`})},y=s.jsxs("div",{className:"gc-page",children:[s.jsx(je,{flush:!0,children:s.jsx(Pe,{query:n,rows:8,children:h=>s.jsx(Le,{label:"Providers",rows:Us(h,o),rowKey:r=>r.peerId,selectedKey:(a==null?void 0:a.peerId)??null,onRowClick:r=>de(vs("providers",r.peerId)),rowLabel:r=>H(r),actions:r=>[o.model!==""&&ys(l,r.peerId,o.model),{label:"Allow…",onSelect:()=>c({peer:r,kind:"allow"})},{label:"Prefer…",onSelect:()=>c({peer:r,kind:"prefer"})},{label:"Block…",tone:"danger",onSelect:()=>c({peer:r,kind:"block"})}],initialSort:{key:"trust",direction:"desc"},empty:s.jsx(J,{icon:s.jsx(_.providers,{size:18}),title:h.length?"No providers match these filters":"No providers found yet",body:h.length?void 0:"The buyer is still discovering the network. Check back in a minute."}),columns:[{key:"name",header:"Provider",sortValue:r=>r.displayName??r.peerId,render:r=>s.jsxs("div",{className:"gc-cell-lines",children:[s.jsx("div",{className:"gc-strong gc-ellipsis",title:r.displayName??r.peerId,children:H(r)}),r.displayName&&s.jsx("div",{className:"gc-muted gc-ellipsis",children:s.jsx(Ce,{title:r.peerId,children:F(r.peerId,6,4)})}),s.jsx(Ys,{peer:r,model:o.model})]}),after:r=>s.jsx(ws,{value:r.peerId,label:`Copy peer id ${r.peerId}`})},{key:"identity",header:"Domain / GitHub",secondary:!0,render:r=>{var b;return(b=r.verificationLinks)!=null&&b.length?s.jsx(Fe,{links:r.verificationLinks}):s.jsx("span",{className:"gc-muted",children:"—"})}},{key:"models",header:"Models",secondary:!0,optional:!0,render:r=>s.jsx("span",{className:"gc-muted",children:r.services.length})},{key:"input",header:"Input $/M",align:"right",sortValue:r=>Bs(r,o.model),render:r=>ce(V(r,"inputUsdPerMillion",o.model))},{key:"output",header:"Output $/M",align:"right",secondary:!0,sortValue:r=>zs(r,o.model),render:r=>ce(V(r,"outputUsdPerMillion",o.model))},{key:"trust",header:"Trust",align:"right",sortValue:r=>r.trustScore,render:r=>ge(r.trustScore)},...f?[{key:"reputation",header:"Reputation",align:"right",secondary:!0,optional:!0,sortValue:r=>r.reputationScore,render:r=>ge(r.reputationScore)}]:[],{key:"latency",header:"Latency",align:"right",secondary:!0,optional:!0,sortValue:r=>r.latencyMsP50,render:r=>Ie(r.latencyMsP50)},{key:"usage",header:"Your 24h",align:"right",secondary:!0,sortValue:r=>r.requests24h,render:r=>Ne(r.requests24h)}]})})}),s.jsx(Rs,{peers:n.data})]});return s.jsxs("div",{className:"gc-page",children:[s.jsx(bs,{title:"Providers",description:"Providers on the network this gateway can route to. Open one to copy its models and an API call, or allow, block or prefer it for any scope."}),s.jsxs("div",{className:"gc-toolbar",children:[s.jsx(q,{size:"sm",type:"search","aria-label":"Search providers",placeholder:"Search name, peer id or model",value:o.search,onChange:h=>u("search",h.target.value)}),s.jsx(A,{size:"sm","aria-label":"Filter by model",value:o.model,onChange:h=>u("model",h),options:[{value:"",label:"All models"},...g.map(h=>({value:h,label:h}))]}),s.jsx(W,{checked:o.linked,onChange:h=>u("linked",h),label:"Domain or GitHub"}),s.jsx(W,{checked:o.tee,onChange:h=>u("tee",h),label:"TEE"}),s.jsx(W,{checked:o.free,onChange:h=>u("free",h),label:"Free"})]}),s.jsx(Ps,{list:y,panel:v,onClose:()=>de("providers"),closeLabel:"Close provider"}),m&&s.jsx(Oe,{peer:m.peer,action:m.kind,peers:n.data,onClose:()=>c(null)})]})}export{ct as default};
|
|
1
|
+
import{bW as qe,bh as pe,aI as Ve,u as X,a as fe,D as Ke,F as Ge,m as we,i as ye,r as p,O as Ye,b as ve,d as Qe,bX as We,bf as He,Y as U,bY as Je,bZ as Xe,e as L,ag as Ze,j as s,A as Z,ac as Y,n as ee,B as x,L as be,z as es,b9 as ss,s as xe,q as ke,k as je,Q as Pe,E as J,I as _,C as ts,T as q,v as F,M as Ce,ap as Se,t as N,a8 as ns,bU as $,ab as Ie,g as Ne,X as rs,b0 as $e,b_ as Ae,aS as as,b4 as os,b$ as ls,W as is,aU as cs,N as ds,aV as us,aW as ms,b2 as hs,b3 as gs,bl as ps,aY as fs,aZ as ws,a_ as ce,b6 as ys,x as de,a$ as vs,P as bs}from"./index-BjRmy3XE.js";import{p as Q,a as xs}from"./PolicyEditor-B5BAs2vC.js";import{S as A}from"./SelectField-BSNXjRiC.js";import{D as Le}from"./DataTable-B36eMErM.js";import{V as Fe,P as Me,b as ks,p as js,S as Ps}from"./models-D5AfPpBK.js";import{f as Cs}from"./ants-B38m9Phv.js";import{PresetForm as Ss}from"./Presets-CgfFG3fw.js";import{T as Is,a as Ns}from"./Tabs-Dle_Eq4t.js";import{S as W}from"./Switch-hSHNLapF.js";import"./Segmented-C9jux-Mr.js";import"./roving-DkptacxO.js";import"./Disclosure-DS6GTz8G.js";import"./index-iM-80gy8.js";import"./PolicyField-D7O5D7fl.js";import"./TextAreaField-9B3_7w3L.js";function Te(e,t="admin"){return t==="owner"&&Ve(e)?"ownerRoutingPolicy":"routingPolicy"}async function Ee(e,t){const n=(await e.keys.list({workspace:t.workspaceId})).find(a=>a.id===t.keyId);if(!n)throw new Error("That key no longer exists.");return n}async function De(e,t){switch(t.kind){case"gateway":return e.network.gatewayPolicy();case"workspace-org":return(await e.workspaces.get(t.workspaceId)).orgRoutingPolicy;case"workspace":return(await e.workspaces.get(t.workspaceId)).routingPolicy;case"member":{const n=(await e.members.list()).find(a=>a.id===t.memberId);if(!n)throw new Error("That member no longer exists.");return n.routingPolicy}case"key":{const n=await Ee(e,t);return n[Te(n,t.layer)]??null}}}async function $s(e,t,n,a){const o=a!=null&&a.confirmEmpty||a!=null&&a.acceptNarrowed?[a]:[];switch(t.kind){case"gateway":await e.network.setGatewayPolicy(n??{},...o);return;case"workspace-org":await e.workspaces.update(t.workspaceId,{orgRoutingPolicy:n},...o);return;case"workspace":await e.workspaces.update(t.workspaceId,{routingPolicy:n},...o);return;case"member":await e.members.update(t.memberId,{routingPolicy:n},...o);return;case"key":{const i=t.layer==="owner"?Te(await Ee(e,t),"owner"):"routingPolicy";await e.keys.update(t.keyId,{[i]:n},...o);return}}}const ue=e=>JSON.stringify(e??{},Object.keys(e??{}).sort());async function As(e,t,n,a,o,i){const m=await De(e,t),c=qe(m,n,a,o),g=ue(m)!==ue(c)||JSON.stringify(m??{})!==JSON.stringify(c);return g&&await $s(e,t,c,i),{before:m,after:c,changed:g}}function Ls(e,t,n){return e.kind==="key"?{model:t,key:e.keyId,workspace:e.workspaceId}:e.kind==="member"?{model:t,member:e.memberId,workspace:n}:e.kind==="gateway"?{model:t,workspace:n}:{model:t,workspace:e.workspaceId}}const Fs={allow:"Allowed",block:"Blocked",prefer:"Preferred"};function Ms(e){const{action:t,name:n,scopeLabel:a,changed:o,model:i,preview:m,peerId:c}=e,g=Fs[t],f=t==="prefer"?`already first for ${i}`:`already ${g.toLowerCase()}`,l=o?`${g} ${n} ${t==="prefer"?`for ${i} `:""}on ${a}`:`${n} was ${f} on ${a}; nothing changed`;if(!m)return t==="block"?{tone:o?"success":"info",text:`${l}.`}:{tone:"info",text:`${l}. ${e.previewError?`Could not check whether it can serve: ${e.previewError}`:"Could not check whether it can serve."}`};const u=m.candidates.find(v=>pe(v.peerId,c));if(t==="block")return u!=null&&u.eligible?{tone:"warning",text:`${l}, but the route preview still lists it as eligible for ${i}. Reload and check the policy.`}:{tone:o?"success":"info",text:`${l}.`};if(!m.modelAllowed)return{tone:"warning",text:`${l}, but ${i} is not an allowed model here, so it still cannot serve it.`};if(!u)return{tone:"info",text:`${l}. It does not offer ${i} right now, so the preview cannot show its rank.`};if(!u.eligible){const v=u.reasons.length?u.reasons.join("; "):"another level excludes it";return{tone:"warning",text:`${l}, but it still cannot serve ${i} here: ${v}.`}}return t==="prefer"&&u.rank!==null&&u.rank>1?{tone:"warning",text:`${l}, but it ranks #${u.rank} for ${i}: a fallback chain on another level comes first.`}:{tone:o?"success":"info",text:`${l}.${u.rank?` It ranks #${u.rank} for ${i}.`:""}`}}function Ts(e,t,n,a){return e==="gateway"?{kind:e}:e==="workspace"||e==="workspace-org"?{kind:e,workspaceId:n}:t?e==="member"?{kind:e,memberId:t}:{kind:"key",keyId:t,workspaceId:n,layer:a?"admin":"owner"}:null}function Es(e){return e.canForce?"Not allowed above":e.tone==="warning"?"Check the result":"Done"}function Ds({fetching:e,error:t,ready:n,policy:a}){return e?s.jsx(be,{rows:1}):t?s.jsx(ee,{error:t,title:"Could not load this scope's policy"}):n?s.jsxs("p",{className:"gc-muted",children:["Current policy: ",es(a)]}):null}const me={allow:{title:"Allow seller",verb:"Allow"},block:{title:"Block seller",verb:"Block"},prefer:{title:"Prefer seller",verb:"Prefer"}};function Oe({peer:e,action:t,onClose:n,peers:a}){var te,ne,re,ae;const{viewer:o,workspace:i,me:m}=X(),c=fe(),g=Ke(),f=Ge(),l=we(o),u=ye(o),v=[...l?[{value:"gateway",label:"Gateway default (everyone)"}]:[],...l?[{value:"workspace-org",label:`${i.name}: organization policy`}]:[],...u?[{value:"workspace",label:`${i.name}: workspace policy`}]:[],...l?[{value:"member",label:"A member"}]:[],{value:"key",label:"An API key"}],[y,h]=p.useState(v[0].value),[r,b]=p.useState(""),[k,D]=p.useState(""),O=Ye(y==="member"),R=ve(c,y==="key");p.useEffect(()=>{b("")},[y]),p.useEffect(()=>{var d;D(((d=e==null?void 0:e.services[0])==null?void 0:d.service)??"")},[e]);const w=(R.data??[]).filter(d=>d.status==="active"&&(u||d.ownerMemberId===m.member.id)),j=Ts(y,r,i.id,u),[S,T]=p.useState(null);p.useEffect(()=>{T(null)},[y,r,e]);const B=Qe({queryKey:["routing","scope-policy",j],queryFn:()=>De(L,j),enabled:j!==null&&e!==null,staleTime:0}),z=j!==null&&B.isSuccess&&(t!=="prefer"||k!==""),I=B.data??null,ze=t==="allow"&&z&&!(I!=null&&I.allowedPeerIds)&&!(I!=null&&I.allowedPeerLists),Ue=t==="block"&&z&&e!==null&&We(I,e.peerId);let E=((te=v.find(d=>d.value===y))==null?void 0:te.label.replace(/^A[n]? /,"the "))??"this scope";y==="key"&&(E=`key “${((ne=w.find(d=>d.id===r))==null?void 0:ne.label)??r}”`),y==="member"&&(E=`member “${((ae=(re=O.data)==null?void 0:re.find(d=>d.id===r))==null?void 0:ae.label)??r}”`);const P=He({mutationFn:async(d={})=>{var ie;if(!e||!j)return null;const C=k||((ie=e.services[0])==null?void 0:ie.service)||"",{changed:G}=await As(L,j,t,e.peerId,k||void 0,d);let oe=null,le=null;if(C)try{oe=await L.network.routePreview(Ls(j,C,i.id))}catch(_e){le=Ze(_e)}return Ms({action:t,name:Q(a,e.peerId),scopeLabel:E,changed:G,model:C,preview:oe,peerId:e.peerId,previewError:le})},onSuccess:d=>{for(const C of Xe)g.invalidateQueries({queryKey:[C]});d&&(d.tone==="success"?(f(d.text),n()):T(d))},onError:d=>{const C=e?Q(a,e.peerId):"this seller";if(U(d,"narrowed"))T({tone:"warning",canForce:!0,text:`Nothing changed yet. The levels above ${E} do not allow ${C}, so saving this would not let it serve. ${Je(d.details).join(" ")}`.trim()});else if(U(d,"empty_allow_list")){const G=t==="block"?`Blocking ${C}`:`Allowing only ${C}`;T({tone:"warning",text:`Nothing changed. ${G} on ${E} would leave no seller that the levels above allow, so requests would fail. Change the policy on the Routing page if you really want that.`})}}}),K=e?Q(a,e.peerId):"";return s.jsx(Z,{isOpen:e!==null,onClose:n,title:me[t].title,subtitle:K,children:s.jsxs("div",{className:"gc-stack",children:[s.jsx(A,{label:"Apply to",value:y,onChange:d=>h(d),options:v}),y==="member"&&s.jsx(A,{label:"Member",value:r,onChange:b,options:[{value:"",label:"Choose a member"},...(O.data??[]).filter(d=>d.status!=="disabled").map(d=>({value:d.id,label:d.label}))]}),y==="key"&&s.jsx(A,{label:"Key",value:r,onChange:b,options:[{value:"",label:w.length?"Choose a key":"No keys you can edit"},...w.map(d=>({value:d.id,label:d.label}))]}),t==="prefer"&&e&&s.jsx(A,{label:"For model",value:k,onChange:D,options:e.services.map(d=>({value:d.service,label:d.service})),hint:"The seller goes first in this model's fallback chain."}),s.jsx(Ds,{fetching:B.isFetching,error:B.error,ready:z,policy:I}),ze&&s.jsxs(Y,{tone:"warning",children:["This scope has no allow list yet. Allowing ",K," creates one, so only allowed sellers can serve it."]}),Ue&&s.jsxs(Y,{tone:"warning",title:"This is the only allowed seller",children:["Blocking ",K," empties this scope's allow list, so the allow list is removed: any seller that is not blocked may serve it again."]}),t==="block"&&s.jsx("p",{className:"gc-muted",children:"Blocked sellers never serve this scope or anything under it."}),y==="key"&&!u&&s.jsx("p",{className:"gc-muted",children:"This changes your own restrictions on the key. Restrictions a workspace admin set still apply."}),P.error&&!U(P.error,"narrowed")&&!U(P.error,"empty_allow_list")?s.jsx(ee,{error:P.error,title:"Could not update the policy"}):null,S?s.jsxs(s.Fragment,{children:[s.jsx(Y,{tone:S.tone,title:Es(S),children:S.text}),s.jsxs("div",{className:"gc-actions",children:[S.canForce&&s.jsx(x,{variant:"ghost",disabled:P.isPending,onClick:()=>{T(null),P.mutate({acceptNarrowed:!0})},children:"Save it anyway"}),s.jsx(x,{onClick:n,children:S.canForce?"Cancel":"Done"})]})]}):s.jsxs("div",{className:"gc-actions",children:[s.jsx(x,{variant:"ghost",onClick:n,children:"Cancel"}),s.jsx(x,{variant:t==="block"?"danger":"primary",disabled:!z||P.isPending,onClick:()=>P.mutate({}),children:P.isPending?"Saving…":me[t].verb})]})]})})}function Os({initial:e,peers:t,onDone:n}){const[a,o]=p.useState((e==null?void 0:e.name)??""),[i,m]=p.useState((e==null?void 0:e.description)??""),[c,g]=p.useState((e==null?void 0:e.peerIds)??[]),f=xe({mutationFn:()=>{const l={name:a.trim(),description:i.trim()||null,peerIds:c};return e?L.network.updatePeerList(e.id,l):L.network.createPeerList(l)},onSuccess:n,invalidate:[ke.peerLists]});return s.jsxs("form",{className:"gc-stack",onSubmit:l=>{l.preventDefault(),f.mutate()},children:[s.jsx(q,{label:"Name",required:!0,placeholder:"e.g. Our own sellers",value:a,onChange:l=>o(l.target.value)}),s.jsx(q,{label:"Description",value:i,onChange:l=>m(l.target.value)}),s.jsx(xs,{label:"Sellers",value:c,onChange:g,peers:t}),s.jsx("p",{className:"gc-fineprint",children:"Policies refer to a list by name, so editing it changes every policy that uses it."}),f.error?s.jsx(ee,{error:f.error,title:"Could not save the list"}):null,s.jsxs("div",{className:"gc-actions",children:[s.jsx(x,{variant:"ghost",onClick:n,children:"Cancel"}),s.jsx(x,{type:"submit",disabled:f.isPending||!a.trim(),children:f.isPending?"Saving…":"Save list"})]})]})}function Rs({peers:e}){const{viewer:t}=X(),n=we(t),a=ss(),[o,i]=p.useState(null),[m,c]=p.useState(null),g=xe({mutationFn:f=>L.network.removePeerList(f.id),onSuccess:()=>c(null),invalidate:[ke.peerLists]});return s.jsxs(je,{flush:!0,title:"Peer lists",description:"Named groups of sellers to allow or block in one step.",actions:n&&s.jsx(x,{size:"sm",variant:"outline",leadingIcon:s.jsx(_.plus,{size:14}),onClick:()=>i("new"),children:"New list"}),children:[s.jsx(Pe,{query:a,children:f=>s.jsx(Le,{label:"Peer lists",rows:f,rowKey:l=>l.id,rowLabel:l=>l.name,actions:l=>n?[{label:"Edit",onSelect:()=>i(l)},{label:"Delete",tone:"danger",onSelect:()=>c(l)}]:[],empty:s.jsx(J,{icon:s.jsx(_.network,{size:18}),title:"No peer lists",body:"Group sellers you trust, or ones you run yourself."}),columns:[{key:"name",header:"Name",render:l=>s.jsx("span",{className:"gc-strong",children:l.name})},{key:"desc",header:"Description",secondary:!0,render:l=>s.jsx("span",{className:"gc-muted",children:l.description??"—"})},{key:"count",header:"Sellers",align:"right",render:l=>l.peerIds.length}]})}),s.jsx(Z,{isOpen:o!==null,onClose:()=>i(null),title:o==="new"?"New peer list":"Edit peer list",size:"lg",children:o!==null&&s.jsx(Os,{initial:o==="new"?null:o,peers:e,onDone:()=>i(null)})}),s.jsx(ts,{isOpen:m!==null,busy:g.isPending,error:g.error,onClose:()=>c(null),onConfirm:()=>m&&g.mutate(m),title:"Delete this list?",confirmLabel:"Delete",body:"Policies refer to lists by reference: once deleted, the list adds no sellers to them. An allow list made only of deleted lists lets no seller serve."})]})}function Re(e,t){return t?e.services.filter(n=>n.service===t):e.services}function V(e,t,n=""){const a=Re(e,n).map(o=>o[t]).filter(o=>o!==null);return a.length?{min:Math.min(...a),max:Math.max(...a)}:null}function Bs(e,t=""){var n;return((n=V(e,"inputUsdPerMillion",t))==null?void 0:n.min)??null}function zs(e,t=""){var n;return((n=V(e,"outputUsdPerMillion",t))==null?void 0:n.min)??null}function se(e,t=""){return Re(e,t).some(n=>n.inputUsdPerMillion===0&&(n.outputUsdPerMillion??0)===0)}function Us(e,t){const n=t.search.trim().toLowerCase();return e.filter(a=>{var o;return!(n&&!a.peerId.toLowerCase().includes(n)&&!(a.displayName??"").toLowerCase().includes(n)&&!a.services.some(i=>i.service.toLowerCase().includes(n))||t.model&&!a.services.some(i=>i.service===t.model)||t.tee&&!a.tee||t.linked&&!((o=a.verificationLinks)!=null&&o.length)||t.free&&!se(a,t.model))})}const Be={"openai-chat-completions":"Chat completions","openai-responses":"Responses","anthropic-messages":"Messages","openai-images":"Images"};function he(e){return e===null?"—":String(Math.round(e))}function H(e){return e.displayName??F(e.peerId,8,4)}function M(e){return`${e.provider}:${e.service}`}function _s({peer:e}){const t=(e.health.coolingDownUntil??0)>Date.now();return s.jsxs("span",{className:"gc-seller__meta",children:[s.jsxs("span",{className:"gc-peer-id",children:[s.jsx(Ce,{title:e.peerId,children:F(e.peerId,6,4)}),s.jsx(Se,{iconOnly:!0,value:e.peerId,label:"Copy peer id"})]}),s.jsx(Fe,{links:e.verificationLinks}),e.tee&&s.jsx(N,{tone:"info",children:"TEE"}),se(e,"")&&s.jsx(N,{tone:"success",children:"Free"}),e.washFlagged&&s.jsx(N,{tone:"danger",children:"Flagged"}),t&&s.jsx(N,{tone:"warning",children:"Cooling down"}),s.jsxs("span",{className:"gc-muted",children:["Last seen ",ns(e.lastSeen)]})]})}function qs({peer:e,showReputation:t}){const n=(e.health.coolingDownUntil??0)>Date.now();return s.jsxs("div",{className:"gc-grid gc-grid--2 gc-figures gc-panel-figures",children:[s.jsx($,{label:"Trust score",value:he(e.trustScore)}),t&&s.jsx($,{label:"Reputation",value:he(e.reputationScore)}),s.jsx($,{label:"Stake",value:e.stakeAnts?Cs(e.stakeAnts):"—"}),s.jsx($,{label:"Network usage share",value:e.usageShareBps===null?"—":`${(e.usageShareBps/100).toFixed(2)}%`}),s.jsx($,{label:"Latency p50 (this gateway)",value:Ie(e.latencyMsP50)}),s.jsx($,{label:"Requests, 24h (this gateway)",value:Ne(e.requests24h)}),s.jsx($,{label:"Failure streak",value:n?`${e.health.failureStreak}, cooling down until ${rs(e.health.coolingDownUntil)}`:String(e.health.failureStreak)})]})}function Vs({peer:e,selected:t,onSelect:n}){const[a,o]=p.useState(""),i=a.trim().toLowerCase(),m=e.services.filter(c=>!i||c.service.toLowerCase().includes(i));return s.jsx(Me,{title:`Models (${e.services.length})`,actions:e.services.length>6&&s.jsx(q,{size:"sm",type:"search","aria-label":"Search this provider's models",placeholder:"Search models",value:a,onChange:c=>o(c.target.value)}),children:m.length===0?s.jsx("p",{className:"gc-fineprint",children:i?"No models match.":"This provider lists no models."}):s.jsx("ul",{className:"gc-panel-rows","aria-label":"Models and prices",children:m.map(c=>{const g=t!==null&&M(t)===M(c);return s.jsx(ks,{selected:g,title:s.jsx("span",{className:"gc-strong",children:c.service}),meta:s.jsxs(s.Fragment,{children:[s.jsx("span",{children:js(c)}),s.jsx("span",{children:Be[Ae(c)]})]}),actions:s.jsxs(s.Fragment,{children:[s.jsx(Se,{iconOnly:!0,value:$e(e.peerId,c.service),label:`Copy ${c.service} pinned to this provider (peer@model)`}),s.jsx(x,{size:"sm",variant:g?"outline":"ghost","aria-pressed":g,title:"Show the API call for this model",onClick:()=>n(c),children:"API call"})]})},M(c))})})})}function Ks({peer:e,service:t,onSelect:n}){var R;const{workspace:a,viewer:o}=X(),i=fe(),m=as(),c=ve(i),g=os(a.id),[f,l]=p.useState("curl"),[u,v]=p.useState(!1),y=Ae(t),h=$e(e.peerId,t.service),r=((R=g.data)==null?void 0:R.find(w=>w.model===h))??null,b=ls(m,e.peerId,t.service,y,r?`@preset/${r.slug}`:null),k=b.find(w=>w.id===f)??b[0],D=(c.data??[]).some(w=>w.status==="active"),O=ye(o);return s.jsxs(Me,{title:"API call",actions:e.services.length>1&&s.jsx(A,{size:"sm","aria-label":"Model",value:M(t),onChange:w=>{const j=e.services.find(S=>M(S)===w);j&&n(j)},options:e.services.map(w=>({value:M(w),label:w.service}))}),children:[s.jsxs("p",{className:"gc-fineprint",children:["Pinned to this provider with ",s.jsx("code",{children:F(h,10,12)}),"."]}),s.jsx(Is,{id:"gc-connect",label:"Ways to connect",value:k.id,onChange:l,className:"gc-connect-tabs",tabs:b.map(w=>({id:w.id,label:w.label}))}),s.jsxs(Ns,{tabsId:"gc-connect",tab:k.id,className:"gc-stack",children:[k.id==="codex"&&s.jsxs("div",{className:"gc-summary-row",children:[s.jsx("p",{className:"gc-fineprint gc-summary-row__text",children:r?s.jsxs(s.Fragment,{children:["Uses the preset ",s.jsxs("code",{children:["@preset/",r.slug]})," for this model. Codex needs a preset: with a raw GPT model name it switches to a tool format some sellers drop."]}):s.jsx(s.Fragment,{children:"Codex needs a preset, not a raw model name: with a GPT model name it switches to a tool format some sellers drop. Create one for this model, then use its slug."})}),!r&&O&&s.jsx(x,{size:"sm",variant:"outline",onClick:()=>v(!0),children:"Create preset for this model"})]}),k.id==="claude-code"&&y!=="anthropic-messages"&&s.jsxs("p",{className:"gc-fineprint",children:["This model speaks ",Be[y],"; the gateway translates Claude Code's requests for it."]}),s.jsx(is,{code:k.code,label:`${t.service} · ${k.label}`})]}),s.jsxs("p",{className:"gc-fineprint",children:["Set ",s.jsx("code",{children:cs})," to one of your API keys first."," ",c.data&&!D&&s.jsx(ds,{to:"keys",children:"Create an API key"})]}),s.jsx(Z,{isOpen:u,onClose:()=>v(!1),size:"lg",title:"New preset",children:u&&s.jsx(Ss,{initial:null,prefill:{name:t.service,model:h},onDone:w=>{v(!1),w&&l("codex")}})})]})}function Gs({peer:e,peers:t,showReputation:n}){const[a,o]=p.useState(null),[i,m]=p.useState(null),c=p.useRef(null),g=i??e.services[0]??null,f=l=>{var u;m(l),(u=c.current)==null||u.scrollIntoView({behavior:"smooth",block:"start"})};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"gc-stack",children:[s.jsx(_s,{peer:e}),s.jsxs("div",{className:"gc-panel-actions",children:[s.jsx(x,{size:"sm",variant:"outline",onClick:()=>o("allow"),children:"Allow"}),s.jsx(x,{size:"sm",variant:"outline",onClick:()=>o("prefer"),children:"Prefer"}),s.jsx(x,{size:"sm",variant:"danger",onClick:()=>o("block"),children:"Block"})]}),s.jsx(qs,{peer:e,showReputation:n})]}),s.jsx(Vs,{peer:e,selected:g,onSelect:f}),g&&s.jsx("div",{ref:c,className:"gc-scroll-target",children:s.jsx(Ks,{peer:e,service:g,onSelect:m})}),a&&s.jsx(Oe,{peer:e,action:a,peers:t,onClose:()=>o(null)})]})}function ge(e){return e===null?"—":String(Math.round(e))}function Ys({peer:e,model:t}){const n=(e.health.coolingDownUntil??0)>Date.now();return s.jsxs("div",{className:"gc-badges",children:[e.tee&&s.jsx(N,{tone:"info",children:"TEE"}),se(e,t)&&s.jsx(N,{tone:"success",children:"Free"}),e.washFlagged&&s.jsx(N,{tone:"danger",children:"Flagged"}),n&&s.jsx(N,{tone:"warning",children:"Cooling down"})]})}function ct(){const e=us(),t=ms(e.rest),n=hs(),a=p.useMemo(()=>{var h;return t?((h=n.data)==null?void 0:h.find(r=>pe(r.peerId,t)))??null:null},[n.data,t]),[o,i]=p.useState({search:"",model:"",tee:!1,linked:!1,free:!1}),[m,c]=p.useState(null),g=p.useMemo(()=>gs(n.data),[n.data]),f=ps(n.data),l=fs(),u=(h,r)=>i(b=>({...b,[h]:r})),v=t===null?null:{eyebrow:"Provider",title:a?H(a):F(t,8,6),body:n.isLoading?s.jsx(be,{rows:6}):a?s.jsx(Gs,{peer:a,peers:n.data,showReputation:f},a.peerId):s.jsx(J,{icon:s.jsx(_.providers,{size:18}),title:"Provider not found",body:`This gateway does not see ${F(t,8,6)} right now.`})},y=s.jsxs("div",{className:"gc-page",children:[s.jsx(je,{flush:!0,children:s.jsx(Pe,{query:n,rows:8,children:h=>s.jsx(Le,{label:"Providers",rows:Us(h,o),rowKey:r=>r.peerId,selectedKey:(a==null?void 0:a.peerId)??null,onRowClick:r=>de(vs("providers",r.peerId)),rowLabel:r=>H(r),actions:r=>[o.model!==""&&ys(l,r.peerId,o.model),{label:"Allow…",onSelect:()=>c({peer:r,kind:"allow"})},{label:"Prefer…",onSelect:()=>c({peer:r,kind:"prefer"})},{label:"Block…",tone:"danger",onSelect:()=>c({peer:r,kind:"block"})}],initialSort:{key:"trust",direction:"desc"},empty:s.jsx(J,{icon:s.jsx(_.providers,{size:18}),title:h.length?"No providers match these filters":"No providers found yet",body:h.length?void 0:"The buyer is still discovering the network. Check back in a minute."}),columns:[{key:"name",header:"Provider",sortValue:r=>r.displayName??r.peerId,render:r=>s.jsxs("div",{className:"gc-cell-lines",children:[s.jsx("div",{className:"gc-strong gc-ellipsis",title:r.displayName??r.peerId,children:H(r)}),r.displayName&&s.jsx("div",{className:"gc-muted gc-ellipsis",children:s.jsx(Ce,{title:r.peerId,children:F(r.peerId,6,4)})}),s.jsx(Ys,{peer:r,model:o.model})]}),after:r=>s.jsx(ws,{value:r.peerId,label:`Copy peer id ${r.peerId}`})},{key:"identity",header:"Domain / GitHub",secondary:!0,render:r=>{var b;return(b=r.verificationLinks)!=null&&b.length?s.jsx(Fe,{links:r.verificationLinks}):s.jsx("span",{className:"gc-muted",children:"—"})}},{key:"models",header:"Models",secondary:!0,optional:!0,render:r=>s.jsx("span",{className:"gc-muted",children:r.services.length})},{key:"input",header:"Input $/M",align:"right",sortValue:r=>Bs(r,o.model),render:r=>ce(V(r,"inputUsdPerMillion",o.model))},{key:"output",header:"Output $/M",align:"right",secondary:!0,sortValue:r=>zs(r,o.model),render:r=>ce(V(r,"outputUsdPerMillion",o.model))},{key:"trust",header:"Trust",align:"right",sortValue:r=>r.trustScore,render:r=>ge(r.trustScore)},...f?[{key:"reputation",header:"Reputation",align:"right",secondary:!0,optional:!0,sortValue:r=>r.reputationScore,render:r=>ge(r.reputationScore)}]:[],{key:"latency",header:"Latency",align:"right",secondary:!0,optional:!0,sortValue:r=>r.latencyMsP50,render:r=>Ie(r.latencyMsP50)},{key:"usage",header:"Your 24h",align:"right",secondary:!0,sortValue:r=>r.requests24h,render:r=>Ne(r.requests24h)}]})})}),s.jsx(Rs,{peers:n.data})]});return s.jsxs("div",{className:"gc-page",children:[s.jsx(bs,{title:"Providers",description:"Providers on the network this gateway can route to. Open one to copy its models and an API call, or allow, block or prefer it for any scope."}),s.jsxs("div",{className:"gc-toolbar",children:[s.jsx(q,{size:"sm",type:"search","aria-label":"Search providers",placeholder:"Search name, peer id or model",value:o.search,onChange:h=>u("search",h.target.value)}),s.jsx(A,{size:"sm","aria-label":"Filter by model",value:o.model,onChange:h=>u("model",h),options:[{value:"",label:"All models"},...g.map(h=>({value:h,label:h}))]}),s.jsx(W,{checked:o.linked,onChange:h=>u("linked",h),label:"Domain or GitHub"}),s.jsx(W,{checked:o.tee,onChange:h=>u("tee",h),label:"TEE"}),s.jsx(W,{checked:o.free,onChange:h=>u("free",h),label:"Free"})]}),s.jsx(Ps,{list:y,panel:v,onClose:()=>de("providers"),closeLabel:"Close provider"}),m&&s.jsx(Oe,{peer:m.peer,action:m.kind,peers:n.data,onClose:()=>c(null)})]})}export{ct as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as R,j as e,L as p,n as x,X as y,M as d,v as I,ab as u,g as o,E as L,I as P,B as v,U as S,e as f,q as j,t as l,f as T,d as C,Y as M,ac as w,V as A,W as D}from"./index-
|
|
1
|
+
import{r as R,j as e,L as p,n as x,X as y,M as d,v as I,ab as u,g as o,E as L,I as P,B as v,U as S,e as f,q as j,t as l,f as T,d as C,Y as M,ac as w,V as A,W as D}from"./index-BjRmy3XE.js";import{u as E}from"./useInfiniteQuery-DXLHm6RI.js";import{f as q}from"./usage-4421Rf6_.js";import{D as F}from"./DataTable-B36eMErM.js";const K=50;function c(r){return r===null?e.jsx(l,{tone:"info",children:"In flight"}):r<400?e.jsx(l,{tone:"success",children:r}):r<500?e.jsx(l,{tone:"warning",children:r}):e.jsx(l,{tone:"danger",children:r})}function k({entry:r}){const n=q(r,Date.now());return n==="free"?e.jsx("span",{className:"gc-muted",title:"Served by a free seller: $0",children:"Free"}):n==="pending"?e.jsx("span",{className:"gc-muted",title:"The buyer reports spend a moment after the response",children:"pending"}):n==="not-recorded"?e.jsx("span",{className:"gc-muted",title:"No spend was reported for this request: the buyer lost it",children:"not recorded"}):e.jsx(e.Fragment,{children:T(r.spent)})}function O(r){try{return JSON.stringify(JSON.parse(r),null,2)}catch{return r}}function m({title:r,body:n}){return e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsx("div",{className:"as-field__label",children:r}),e.jsx(D,{code:O(n)})]})}function $({detail:r}){return!r.requestBody&&!r.responseBody?e.jsx("p",{className:"gc-fineprint",children:"Bodies are not stored for this request. Turn on content logging under Settings → Observability to keep them."}):e.jsxs(e.Fragment,{children:[r.requestBody&&e.jsx(m,{title:"Request body",body:r.requestBody}),r.responseBody&&e.jsx(m,{title:"Response body",body:r.responseBody})]})}function U({entry:r}){const n=C({queryKey:j.request(r.tag),queryFn:()=>f.usage.request(r.tag),retry:!1,staleTime:6e4}),t=n.data??r,i=M(n.error)&&n.error.status===404;return e.jsxs(e.Fragment,{children:[t.errorCode||t.errorMessage?e.jsx(w,{tone:"danger",title:t.errorCode??"Request failed",children:t.errorMessage??"No message was returned."}):null,e.jsx(A,{items:[["Status",c(t.status)],["Request",e.jsxs(d,{children:[t.method," ",t.path]},"p")],["Model",t.model??"—"],["Key",t.keyLabel],["End user",t.endUser??"—"],["Seller",t.sellerPeerId?e.jsx(d,{children:t.sellerPeerId},"s"):"—"],["Latency",u(t.latencyMs)],["Duration",t.finishedAt?u(t.finishedAt-t.startedAt):"—"],["Input tokens",o(t.inputTokens)],["Cached input",o(t.cachedInputTokens)],["Output tokens",o(t.outputTokens)],["Cost",e.jsx(k,{entry:t},"c")],["Tag",e.jsx(d,{children:t.tag},"t")]]}),n.isLoading&&e.jsx(p,{rows:2}),n.error&&!i?e.jsx(x,{error:n.error,title:"Could not load the bodies"}):null,n.data&&e.jsx($,{detail:n.data})]})}function V({filter:r,showKey:n=!0}){var g;const[t,i]=R.useState(null),a=E({queryKey:j.requests(r),queryFn:({pageParam:s})=>f.usage.requests({...r,before:s??void 0,limit:K}),initialPageParam:null,getNextPageParam:s=>s.nextBefore,refetchInterval:s=>{var h;return(h=s.state.data)!=null&&h.pages.some(N=>N.requests.some(B=>q(B,Date.now())==="pending"))?5e3:!1}});if(a.isLoading)return e.jsx(p,{rows:8});if(a.error)return e.jsx(x,{error:a.error,onRetry:()=>void a.refetch()});const b=((g=a.data)==null?void 0:g.pages.flatMap(s=>s.requests))??[];return e.jsxs(e.Fragment,{children:[e.jsx(F,{label:"Request log",rows:b,rowKey:s=>s.tag,onRowClick:i,rowLabel:s=>`request ${s.tag}`,empty:e.jsx(L,{icon:e.jsx(P.logs,{size:18}),title:"No requests found",body:"Requests appear here as soon as a key is used. Check the filters if you expected some."}),columns:[{key:"time",header:"Time",render:s=>e.jsx("span",{className:"gc-nowrap",children:y(s.startedAt)})},...n?[{key:"key",header:"Key",secondary:!0,render:s=>s.keyLabel}]:[],{key:"model",header:"Model",render:s=>e.jsxs("span",{className:"gc-ellipsis",children:[s.model??s.path,s.status!==null&&s.status>=400?e.jsxs("span",{className:"gc-narrow-only",children:[" ",c(s.status)]}):null]})},{key:"seller",header:"Seller",secondary:!0,optional:!0,render:s=>s.sellerPeerId?e.jsx(d,{title:s.sellerPeerId,children:I(s.sellerPeerId)}):"—"},{key:"status",header:"Status",secondary:!0,render:s=>e.jsx("span",{title:s.errorMessage??void 0,children:c(s.status)})},{key:"latency",header:"Latency",align:"right",secondary:!0,optional:!0,render:s=>u(s.latencyMs)},{key:"tokens",header:"Tokens",align:"right",secondary:!0,render:s=>`${o(s.inputTokens)} → ${o(s.outputTokens)}`},{key:"cost",header:"Cost",align:"right",render:s=>e.jsx(k,{entry:s})}]}),a.hasNextPage&&e.jsx("div",{className:"gc-load-more",children:e.jsx(v,{variant:"outline",size:"sm",disabled:a.isFetchingNextPage,onClick:()=>void a.fetchNextPage(),children:a.isFetchingNextPage?"Loading…":"Load older requests"})}),e.jsx(S,{isOpen:t!==null,onClose:()=>i(null),title:(t==null?void 0:t.model)??"Request",subtitle:t?y(t.startedAt):void 0,eyebrow:"Request",children:t&&e.jsx(U,{entry:t},t.tag)})]})}export{V as R};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/RewardsClaim-
|
|
2
|
-
import{u as v,D as b,F as k,d as N,q as m,G as S,H as R,r as c,j as e,P as z,Q as _,J as q,S as l,K as o,M as E,v as d,k as g,N as F,B as P,A as T,L as D,t as w,E as I,I as Q,_ as K,e as L}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/RewardsClaim-CRgTiF93.js","assets/index-BjRmy3XE.js","assets/index-CqEPMnZS.css","assets/ants-B38m9Phv.js","assets/useTx-JDF5s1ox.js","assets/en_US-Y4ZOVFV4-BuTiJwkw.js","assets/clsx-B-dksMZM.js","assets/index-iM-80gy8.js","assets/index-BwpQbdIU.js","assets/en_US-Y4ZOVFV4-CcVPgXVa.css","assets/ConnectWallet-BqD3R1R9.js","assets/OperatorGateAlert-Jd5E0V_d.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as v,D as b,F as k,d as N,q as m,G as S,H as R,r as c,j as e,P as z,Q as _,J as q,S as l,K as o,M as E,v as d,k as g,N as F,B as P,A as T,L as D,t as w,E as I,I as Q,_ as K,e as L}from"./index-BjRmy3XE.js";import{C as O}from"./ChainGate-BO2NzC31.js";import{f as r,a as $}from"./ants-B38m9Phv.js";import{D as B}from"./DataTable-B36eMErM.js";import"./index-iM-80gy8.js";const H=c.lazy(()=>K(()=>import("./RewardsClaim-CRgTiF93.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])));function W(){const{workspace:t}=v(),x=b(),y=k(),j=N({queryKey:m.rewards(t.id),queryFn:()=>L.wallet.rewards(t.id)}),h=S(),p=R(t.id),[C,i]=c.useState(!1);return e.jsxs("div",{className:"gc-page",children:[e.jsx(z,{title:"Rewards",description:"ANTS earned by this workspace's usage. Claimed ANTS go to the authorized wallet."}),e.jsx(_,{query:j,rows:3,children:n=>{var u;const A=p.data?p.data.operator:n.operator,a={...n,operator:A};return e.jsxs(e.Fragment,{children:[e.jsx(q,{stale:n.stale}),e.jsxs("div",{className:"gc-grid gc-grid--3",children:[e.jsx(l,{label:"Ready to claim",value:r(a.pendingAnts)}),e.jsx(l,{label:"From the legacy program",value:r(((u=a.legacy)==null?void 0:u.pendingAnts)??"0"),sub:a.legacy?"Claimed together with the rest":void 0}),e.jsx(l,{label:"Authorized wallet",value:o(a.operator)?e.jsx(E,{title:a.operator,children:d(a.operator)}):"Not set"})]}),e.jsx(g,{children:e.jsxs("div",{className:"gc-summary-row",children:[e.jsxs("div",{className:"gc-summary-row__text",children:[e.jsx("span",{className:"gc-strong",children:$(a.pendingAnts)?`${r(a.pendingAnts)} ready to claim`:"Nothing to claim yet"}),e.jsx("span",{className:"gc-fineprint",children:o(a.operator)?e.jsxs(e.Fragment,{children:["Claimed ANTS go to the authorized wallet ",d(a.operator),", which signs the claim."]}):e.jsxs(e.Fragment,{children:["Only the authorized wallet can claim, and none is set. Authorize one on ",e.jsx(F,{to:"wallet",children:"Wallet & Funding"}),"."]})})]}),e.jsx(P,{size:"sm",variant:"outline",disabled:!o(a.operator),onClick:()=>i(!0),children:"Claim rewards"})]})}),e.jsx(T,{isOpen:C,onClose:()=>i(!1),title:"Claim rewards",subtitle:`${r(a.pendingAnts)} ready. Sent to the authorized wallet${o(a.operator)?` ${d(a.operator)}`:""}.`,children:e.jsx(O,{chain:h.data,error:h.error,children:s=>e.jsx(c.Suspense,{fallback:e.jsx(D,{rows:2}),children:e.jsx(H,{rewards:a,chain:s,onDone:()=>{y("Rewards claimed"),i(!1),x.invalidateQueries({queryKey:m.rewards(t.id)})}})})})}),e.jsx(g,{flush:!0,title:"Current program by epoch",description:"Rewards accrue at each epoch boundary from this workspace's paid usage.",children:e.jsx(B,{label:"Reward epochs",rows:[...a.epochs].sort((s,f)=>f.epoch-s.epoch),rowKey:s=>String(s.epoch),empty:e.jsx(I,{icon:e.jsx(Q.rewards,{size:18}),title:"No rewards yet",body:"Rewards accrue per epoch as this workspace's keys are used."}),columns:[{key:"epoch",header:"Epoch",render:s=>s.epoch},{key:"amount",header:"Amount",align:"right",render:s=>r(s.pendingAnts)},{key:"state",header:"Status",render:s=>s.claimed?e.jsx(w,{tone:"success",children:"Claimed"}):e.jsx(w,{tone:"warning",children:"Unclaimed"})}]})})]})}})]})}export{W as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,u as R,H as B,aj as N,ak as E,ac as b,al as k,v as w,B as v}from"./index-
|
|
1
|
+
import{j as e,u as R,H as B,aj as N,ak as E,ac as b,al as k,v as w,B as v}from"./index-BjRmy3XE.js";import{a as I}from"./ants-B38m9Phv.js";import{u as O,a as S,T,U as x,s as C,L as j}from"./useTx-JDF5s1ox.js";import{a as _}from"./ConnectWallet-BqD3R1R9.js";import{O as W}from"./OperatorGateAlert-Jd5E0V_d.js";import{W as G,u as L,c as P}from"./en_US-Y4ZOVFV4-BuTiJwkw.js";import"./clsx-B-dksMZM.js";import"./index-iM-80gy8.js";import"./index-BwpQbdIU.js";function U(a,s){return a?"Claiming…":s===0?"Nothing to claim":s===1?"Claim":`Claim (${s} transactions)`}function Y({rewards:a,chain:s,onDone:A}){const{address:r}=L(),u=P(),{workspace:h}=R(),p=B(h.id),{refresh:y}=N(h.id),i=O(s.chainId),{writeContractAsync:g}=S(),d=E(s,"usageRewards"),f=a.epochs.filter(t=>!t.claimed&&I(t.pendingAnts)),o=a.legacy&&I(a.legacy.pendingAnts)?a.legacy:null,l=f.length+(o?1:0);if(!d)return e.jsx(b,{tone:"warning",children:"The gateway did not report the usage rewards contract address."});const m=k(p.data,r,"claim rewards");return m.ok?e.jsxs("div",{className:"gc-stack",children:[e.jsxs("p",{className:"gc-fineprint",children:["The ANTS go to ",w(m.operator),", the connected authorized wallet."]}),e.jsx(T,{chain:s,runner:i,done:"Rewards claimed."}),e.jsx(v,{disabled:i.running||l===0,onClick:async()=>{const t=f.map(n=>{const c=[a.address,BigInt(n.epoch)];return{label:`Claim epoch ${n.epoch}`,check:()=>C(u,{account:r,address:d,abi:x,functionName:"claimBuyerReward",args:c,chainId:s.chainId}),send:()=>g({address:d,abi:x,functionName:"claimBuyerReward",args:c,chainId:s.chainId})}});if(o){const n=[a.address,o.epochs.map(BigInt)],c=o.contract;t.push({label:"Claim legacy emissions",check:()=>C(u,{account:r,address:c,abi:j,functionName:"claimBuyerEmissions",args:n,chainId:s.chainId}),send:()=>g({address:c,abi:j,functionName:"claimBuyerEmissions",args:n,chainId:s.chainId})})}await i.run(t,{onStale:()=>void y().catch(()=>{})})&&A()},children:U(i.running,l)}),l>1&&e.jsx("p",{className:"gc-fineprint",children:"Each current-program epoch is its own transaction; legacy emissions are one more."})]}):e.jsx(W,{gate:m,state:p.data,connected:r})}function V(a){return e.jsx(G,{chain:a.chain,children:e.jsxs("div",{className:"gc-stack",children:[e.jsx(_,{}),e.jsx(Y,{...a})]})})}export{V as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as C,a as se,b2 as O,b3 as ae,m as D,r as u,b as te,c as re,b4 as ie,d as ne,j as e,k as K,T as le,B as b,L as $,n as z,aY as oe,ac as q,z as N,t as A,b5 as G,E as ce,b6 as de,e as T,q as W,P as ue,b7 as pe,b8 as ge,D as V,b9 as H,aK as ye,ba as X,bb as M,bc as _,bd as Q,i as me,F as he,be as R,bf as we,bg as fe,aM as ve,A as xe}from"./index-C21bvTBH.js";import{b as Z,a as je,d as be}from"./PolicyField-0xAOIP4-.js";import{p as Y,P as ke}from"./PolicyEditor-CRhTwGq0.js";import{S as U}from"./SelectField-D_BPTzpT.js";import{D as Pe}from"./DataTable-D2QIQ-gI.js";import{T as Se,a as Ne}from"./Tabs-CGI9v1OW.js";import"./Segmented-BJmgB5-Y.js";import"./roving-DkptacxO.js";import"./Switch-JCyfy3G5.js";import"./Disclosure-h1MJg5Wn.js";import"./index-DqHGr8d4.js";function P({level:a,children:t,result:i}){return e.jsxs("div",{className:i?"gc-source gc-source--result":"gc-source",children:[e.jsx("div",{className:"gc-source__level",children:a}),e.jsx("div",{className:"gc-source__policy",children:t})]})}function Ce(a,t,i,n){return a==="key"?(t??[]).filter(r=>r.status==="active").map(r=>({value:r.id,label:r.label})):a==="member"?(i??[]).map(({member:r})=>({value:r.id,label:r.label})):a==="preset"?(n??[]).map(r=>({value:r.slug,label:r.name})):[]}function Le(){const{workspace:a,viewer:t}=C(),i=se(),n=O(),r=ae(n.data),p=D(t),[s,c]=u.useState("workspace"),[l,g]=u.useState(""),[y,w]=u.useState(""),[f,v]=u.useState(null),m=te(i,s==="key"),d=re(a.id,s==="member"),L=ie(a.id,s==="preset"),h=ne({queryKey:W.routePreview(f??{}),queryFn:()=>T.network.routePreview(f),enabled:f!==null}),j=Ce(s,m.data,d.data,L.data);function x(){const o={model:y.trim(),workspace:a.id};s!=="workspace"&&l&&(o[s]=l),v(o)}return e.jsxs(K,{title:"Route preview",description:"See which sellers a request would go to, and why.",children:[e.jsxs("form",{className:"gc-toolbar",onSubmit:o=>{o.preventDefault(),x()},children:[e.jsx(U,{size:"sm","aria-label":"Preview for",value:s,onChange:o=>{c(o),g("")},options:[{value:"workspace",label:`Workspace: ${a.name}`},{value:"key",label:"A key"},...p?[{value:"member",label:"A member"}]:[],{value:"preset",label:"A preset"}]}),s!=="workspace"&&e.jsx(U,{size:"sm","aria-label":`Choose a ${s}`,value:l,onChange:g,options:[{value:"",label:`Choose a ${s}`},...j]}),e.jsx(le,{size:"sm","aria-label":"Model",placeholder:"Model id",list:"gc-preview-models",value:y,onChange:o=>w(o.target.value)}),e.jsx("datalist",{id:"gc-preview-models",children:r.map(o=>e.jsx("option",{value:o},o))}),e.jsx(b,{type:"submit",size:"sm",disabled:!y.trim()||s!=="workspace"&&!l,children:"Preview"})]}),h.isFetching&&e.jsx($,{rows:4}),h.error?e.jsx(z,{error:h.error}):null,h.data&&!h.isFetching&&e.jsx(Re,{preview:h.data})]})}const Ee={buyer:"Buyer",gateway:"Gateway","workspace-org":"Workspace (org policy)",workspace:"Workspace",member:"Member",key:"Key (admin)","key-owner":"Key (owner)",preset:"Preset"};function Me(a){return a.policy!==null?N(a.policy):e.jsx("span",{className:"gc-muted",children:a.level==="buyer"?"No hard limits":"Inherits"})}function Re({preview:a}){const{me:t}=C(),i=O(),n=oe(),r=a.candidates.filter(s=>s.eligible).length,p=s=>{var c;return s.id?s.level==="workspace"||s.level==="workspace-org"?((c=t.workspaces.find(l=>l.workspace.id===s.id))==null?void 0:c.workspace.name)??s.id:s.id:null};return e.jsxs("div",{className:"gc-stack",children:[!a.modelAllowed&&e.jsxs(q,{tone:"danger",title:"Model not allowed",children:["The policy does not allow ",a.model,". Requests for it get a 403."]}),e.jsxs("div",{className:"gc-sources",children:[a.sources.map((s,c)=>e.jsx(P,{level:e.jsxs(e.Fragment,{children:[Ee[s.level],p(s)?e.jsxs("span",{className:"gc-muted",children:[" · ",p(s)]}):null]}),children:Me(s)},`${s.level}-${c}`)),e.jsx(P,{level:"Effective",result:!0,children:N(a.policy)})]}),e.jsxs("p",{className:"gc-muted",children:[r," of ",a.candidates.length," sellers eligible."]}),r===0&&a.candidates.length>0&&e.jsxs(q,{tone:"warning",title:"No eligible seller",children:["Requests for ",a.model," fail with this policy. The reasons below show what excludes each seller."]}),e.jsx(Pe,{label:"Candidates",rows:[...a.candidates].sort((s,c)=>(s.rank??1e9)-(c.rank??1e9)),rowKey:s=>s.peerId,rowLabel:s=>s.displayName??Y(i.data,s.peerId),actions:s=>[de(n,s.peerId,a.model)],empty:e.jsx(ce,{title:"No seller offers this model"}),columns:[{key:"rank",header:"#",render:s=>s.rank??"—",width:"3rem"},{key:"seller",header:"Seller",render:s=>s.displayName??Y(i.data,s.peerId)},{key:"eligible",header:"Eligible",render:s=>s.eligible?e.jsx(A,{tone:"success",children:"Yes"}):e.jsx(A,{tone:"neutral",children:"No"})},{key:"reasons",header:"Why",render:s=>e.jsx("span",{className:"gc-muted",children:s.reasons.join(" · ")||"—"})},{key:"input",header:"Input $/M",align:"right",secondary:!0,render:s=>G(s.inputUsdPerMillion)},{key:"output",header:"Output $/M",align:"right",secondary:!0,render:s=>G(s.outputUsdPerMillion)},{key:"trust",header:"Trust",align:"right",secondary:!0,render:s=>s.trustScore===null?"—":Math.round(s.trustScore)}]})]})}const S={gateway:{title:"Gateway default",description:()=>"Applies to every request through this gateway. Workspaces, members, keys and presets can only narrow it."},org:{title:"Organization policy",description:a=>`Set by organization admins for ${a}. Workspace admins can only narrow it.`},workspace:{title:"Workspace policy",description:a=>`Set by ${a}'s admins, on top of the gateway default and the organization policy.`}},B=(a,t)=>JSON.stringify(a)===JSON.stringify(t);function qe(a,t){if(!a)return e.jsx(A,{children:"Read only"});if(t)return e.jsx(A,{tone:"warning",children:"Unsaved changes"})}function I({layer:a,source:t,parent:i,canEdit:n,onSave:r}){const{workspace:p}=C(),s=he(),c=O(),l=H(),g=je(),[y,w]=u.useState(()=>R(t)),[f,v]=u.useState(()=>R(t)),[m,d]=u.useState(null),[L,h]=u.useState(!1),j=u.useMemo(()=>R(t),[t]),x=!B(y,f);u.useEffect(()=>{B(j,f)||(!x||B(j,y)?(w(j),v(j),d(null)):d(j))},[j]);const o=we({mutationFn:async()=>{const k=fe(y,l.data??null);return await g.save([k],ee=>r(k,ee))===ve?null:k},onSuccess:k=>{if(!k)return;const F=R(k);w(F),v(F),d(null),h(!1),s(`${S[a].title} saved`)}}),E=be(y,l.data??null);return e.jsxs(K,{title:S[a].title,description:S[a].description(p.name),actions:qe(n,x),children:[e.jsxs("div",{className:"gc-policy-row",children:[e.jsxs("div",{className:"gc-policy-row__text",children:[e.jsx(Z,{policy:x?E.policy:t,invalid:x&&E.error!==null}),x&&e.jsx("span",{className:"gc-fineprint",children:"Showing your unsaved edits."})]}),e.jsx(b,{size:"sm",variant:"outline",onClick:()=>h(!0),children:n?"Edit":"View"})]}),m&&n&&!L&&e.jsx(q,{tone:"warning",title:"Changed elsewhere",children:"Someone saved this policy while you were editing it. Open it to reload theirs or keep yours."}),e.jsx(xe,{isOpen:L,onClose:()=>h(!1),size:"xl",title:S[a].title,subtitle:S[a].description(p.name),footer:n?e.jsxs(e.Fragment,{children:[E.error&&e.jsx("span",{className:"gc-warn gc-footer-note",children:E.error}),e.jsx(b,{variant:"ghost",disabled:!x,onClick:()=>{w(f),d(null)},children:"Discard changes"}),e.jsx(b,{disabled:o.isPending||!x,onClick:()=>o.mutate(),children:o.isPending?"Saving…":"Save policy"})]}):e.jsx(b,{variant:"outline",onClick:()=>h(!1),children:"Close"}),children:e.jsxs("div",{className:"gc-stack",children:[m&&n&&e.jsx(q,{tone:"warning",title:"Changed elsewhere",action:e.jsxs("div",{className:"gc-inline gc-inline--wrap",children:[e.jsx(b,{size:"sm",variant:"outline",onClick:()=>{w(m),v(m),d(null)},children:"Reload"}),e.jsx(b,{size:"sm",variant:"ghost",onClick:()=>{v(m),d(null)},children:"Keep editing"})]}),children:"Someone saved this policy while you were editing it. Reload to see their version (your edits are dropped), or keep editing and save to replace it."}),o.error?e.jsx(z,{error:o.error,title:"Could not save"}):null,e.jsx(ke,{value:y,onChange:w,peers:c.data,lists:l.data??[],parent:i,disabled:!n})]})}),g.dialog]})}function Ae(){const a=V(),t=X();return t.isLoading?e.jsx($,{rows:6}):t.error?e.jsx(z,{error:t.error,onRetry:()=>void t.refetch()}):e.jsx(I,{layer:"gateway",source:t.data??null,parent:null,canEdit:!0,onSave:async(i,n)=>{await T.network.setGatewayPolicy(i,n),await a.invalidateQueries({queryKey:W.group("routing")})}})}function J(){var f,v;const{workspace:a,viewer:t}=C(),i=V(),n=H(),r=ye(a.id),p=X(),s=n.data??[],c=p.data?M(p.data,s):null,l=((f=r.data)==null?void 0:f.orgRoutingPolicy)??null,g=((v=r.data)==null?void 0:v.routingPolicy)??null,y=u.useMemo(()=>_(c,l&&M(l,s),g&&M(g,s)),[c,l,g,s]);if(r.isLoading)return e.jsx($,{rows:6});if(r.error)return e.jsx(z,{error:r.error,onRetry:()=>void r.refetch()});const w=async()=>{await i.invalidateQueries({queryKey:W.group("workspaces")}),await i.invalidateQueries({queryKey:W.group("routing")})};return e.jsxs("div",{className:"gc-stack",children:[e.jsx(K,{title:"Effective for this workspace",description:"What keys in this workspace get before member, key and preset policies narrow it further.",children:e.jsxs("div",{className:"gc-sources",children:[e.jsx(P,{level:"Gateway default",children:N(p.data)}),e.jsx(P,{level:"Organization",children:N(l)}),e.jsx(P,{level:"Workspace",children:N(g)}),e.jsx(P,{level:"Effective",result:!0,children:e.jsx(Z,{policy:y})})]})}),e.jsx(I,{layer:"org",source:l,parent:c,canEdit:D(t),onSave:async(m,d)=>{await T.workspaces.update(a.id,{orgRoutingPolicy:Q(m)},d),await w()}}),e.jsx(I,{layer:"workspace",source:g,parent:_(c,l&&M(l,s)),canEdit:me(t),onSave:async(m,d)=>{await T.workspaces.update(a.id,{routingPolicy:Q(m)},d),await w()}})]})}function Te(){const a=pe();if(!a.data)return null;const t=ge(a.data);return e.jsxs("p",{className:"gc-fineprint",children:["Buyer config, which every policy here can only narrow: ",t.length>0?t.join(" · "):"none","."]})}function We(){const{viewer:a}=C(),t=D(a),[i,n]=u.useState(t?"gateway":"workspace");return t?e.jsxs(e.Fragment,{children:[e.jsx(Se,{id:"gc-routing-level",label:"Policy level",value:i,onChange:n,tabs:[{id:"gateway",label:"Gateway default"},{id:"workspace",label:"This workspace"}]}),e.jsx(Ne,{tabsId:"gc-routing-level",tab:i,children:i==="gateway"?e.jsx(Ae,{}):e.jsx(J,{})})]}):e.jsx(J,{})}function Ye(){return e.jsxs("div",{className:"gc-page",children:[e.jsx(ue,{title:"Routing",description:"Which sellers serve your requests and how they are ranked. Each level can only narrow the one above."}),e.jsx(Te,{}),e.jsx(We,{}),e.jsx(Le,{})]})}export{Ye as default};
|
|
1
|
+
import{u as C,a as se,b2 as O,b3 as ae,m as D,r as u,b as te,c as re,b4 as ie,d as ne,j as e,k as K,T as le,B as b,L as $,n as z,aY as oe,ac as q,z as N,t as A,b5 as G,E as ce,b6 as de,e as T,q as W,P as ue,b7 as pe,b8 as ge,D as V,b9 as H,aK as ye,ba as X,bb as M,bc as _,bd as Q,i as me,F as he,be as R,bf as we,bg as fe,aM as ve,A as xe}from"./index-BjRmy3XE.js";import{b as Z,a as je,d as be}from"./PolicyField-D7O5D7fl.js";import{p as Y,P as ke}from"./PolicyEditor-B5BAs2vC.js";import{S as U}from"./SelectField-BSNXjRiC.js";import{D as Pe}from"./DataTable-B36eMErM.js";import{T as Se,a as Ne}from"./Tabs-Dle_Eq4t.js";import"./Segmented-C9jux-Mr.js";import"./roving-DkptacxO.js";import"./Switch-hSHNLapF.js";import"./Disclosure-DS6GTz8G.js";import"./index-iM-80gy8.js";function P({level:a,children:t,result:i}){return e.jsxs("div",{className:i?"gc-source gc-source--result":"gc-source",children:[e.jsx("div",{className:"gc-source__level",children:a}),e.jsx("div",{className:"gc-source__policy",children:t})]})}function Ce(a,t,i,n){return a==="key"?(t??[]).filter(r=>r.status==="active").map(r=>({value:r.id,label:r.label})):a==="member"?(i??[]).map(({member:r})=>({value:r.id,label:r.label})):a==="preset"?(n??[]).map(r=>({value:r.slug,label:r.name})):[]}function Le(){const{workspace:a,viewer:t}=C(),i=se(),n=O(),r=ae(n.data),p=D(t),[s,c]=u.useState("workspace"),[l,g]=u.useState(""),[y,w]=u.useState(""),[f,v]=u.useState(null),m=te(i,s==="key"),d=re(a.id,s==="member"),L=ie(a.id,s==="preset"),h=ne({queryKey:W.routePreview(f??{}),queryFn:()=>T.network.routePreview(f),enabled:f!==null}),j=Ce(s,m.data,d.data,L.data);function x(){const o={model:y.trim(),workspace:a.id};s!=="workspace"&&l&&(o[s]=l),v(o)}return e.jsxs(K,{title:"Route preview",description:"See which sellers a request would go to, and why.",children:[e.jsxs("form",{className:"gc-toolbar",onSubmit:o=>{o.preventDefault(),x()},children:[e.jsx(U,{size:"sm","aria-label":"Preview for",value:s,onChange:o=>{c(o),g("")},options:[{value:"workspace",label:`Workspace: ${a.name}`},{value:"key",label:"A key"},...p?[{value:"member",label:"A member"}]:[],{value:"preset",label:"A preset"}]}),s!=="workspace"&&e.jsx(U,{size:"sm","aria-label":`Choose a ${s}`,value:l,onChange:g,options:[{value:"",label:`Choose a ${s}`},...j]}),e.jsx(le,{size:"sm","aria-label":"Model",placeholder:"Model id",list:"gc-preview-models",value:y,onChange:o=>w(o.target.value)}),e.jsx("datalist",{id:"gc-preview-models",children:r.map(o=>e.jsx("option",{value:o},o))}),e.jsx(b,{type:"submit",size:"sm",disabled:!y.trim()||s!=="workspace"&&!l,children:"Preview"})]}),h.isFetching&&e.jsx($,{rows:4}),h.error?e.jsx(z,{error:h.error}):null,h.data&&!h.isFetching&&e.jsx(Re,{preview:h.data})]})}const Ee={buyer:"Buyer",gateway:"Gateway","workspace-org":"Workspace (org policy)",workspace:"Workspace",member:"Member",key:"Key (admin)","key-owner":"Key (owner)",preset:"Preset"};function Me(a){return a.policy!==null?N(a.policy):e.jsx("span",{className:"gc-muted",children:a.level==="buyer"?"No hard limits":"Inherits"})}function Re({preview:a}){const{me:t}=C(),i=O(),n=oe(),r=a.candidates.filter(s=>s.eligible).length,p=s=>{var c;return s.id?s.level==="workspace"||s.level==="workspace-org"?((c=t.workspaces.find(l=>l.workspace.id===s.id))==null?void 0:c.workspace.name)??s.id:s.id:null};return e.jsxs("div",{className:"gc-stack",children:[!a.modelAllowed&&e.jsxs(q,{tone:"danger",title:"Model not allowed",children:["The policy does not allow ",a.model,". Requests for it get a 403."]}),e.jsxs("div",{className:"gc-sources",children:[a.sources.map((s,c)=>e.jsx(P,{level:e.jsxs(e.Fragment,{children:[Ee[s.level],p(s)?e.jsxs("span",{className:"gc-muted",children:[" · ",p(s)]}):null]}),children:Me(s)},`${s.level}-${c}`)),e.jsx(P,{level:"Effective",result:!0,children:N(a.policy)})]}),e.jsxs("p",{className:"gc-muted",children:[r," of ",a.candidates.length," sellers eligible."]}),r===0&&a.candidates.length>0&&e.jsxs(q,{tone:"warning",title:"No eligible seller",children:["Requests for ",a.model," fail with this policy. The reasons below show what excludes each seller."]}),e.jsx(Pe,{label:"Candidates",rows:[...a.candidates].sort((s,c)=>(s.rank??1e9)-(c.rank??1e9)),rowKey:s=>s.peerId,rowLabel:s=>s.displayName??Y(i.data,s.peerId),actions:s=>[de(n,s.peerId,a.model)],empty:e.jsx(ce,{title:"No seller offers this model"}),columns:[{key:"rank",header:"#",render:s=>s.rank??"—",width:"3rem"},{key:"seller",header:"Seller",render:s=>s.displayName??Y(i.data,s.peerId)},{key:"eligible",header:"Eligible",render:s=>s.eligible?e.jsx(A,{tone:"success",children:"Yes"}):e.jsx(A,{tone:"neutral",children:"No"})},{key:"reasons",header:"Why",render:s=>e.jsx("span",{className:"gc-muted",children:s.reasons.join(" · ")||"—"})},{key:"input",header:"Input $/M",align:"right",secondary:!0,render:s=>G(s.inputUsdPerMillion)},{key:"output",header:"Output $/M",align:"right",secondary:!0,render:s=>G(s.outputUsdPerMillion)},{key:"trust",header:"Trust",align:"right",secondary:!0,render:s=>s.trustScore===null?"—":Math.round(s.trustScore)}]})]})}const S={gateway:{title:"Gateway default",description:()=>"Applies to every request through this gateway. Workspaces, members, keys and presets can only narrow it."},org:{title:"Organization policy",description:a=>`Set by organization admins for ${a}. Workspace admins can only narrow it.`},workspace:{title:"Workspace policy",description:a=>`Set by ${a}'s admins, on top of the gateway default and the organization policy.`}},B=(a,t)=>JSON.stringify(a)===JSON.stringify(t);function qe(a,t){if(!a)return e.jsx(A,{children:"Read only"});if(t)return e.jsx(A,{tone:"warning",children:"Unsaved changes"})}function I({layer:a,source:t,parent:i,canEdit:n,onSave:r}){const{workspace:p}=C(),s=he(),c=O(),l=H(),g=je(),[y,w]=u.useState(()=>R(t)),[f,v]=u.useState(()=>R(t)),[m,d]=u.useState(null),[L,h]=u.useState(!1),j=u.useMemo(()=>R(t),[t]),x=!B(y,f);u.useEffect(()=>{B(j,f)||(!x||B(j,y)?(w(j),v(j),d(null)):d(j))},[j]);const o=we({mutationFn:async()=>{const k=fe(y,l.data??null);return await g.save([k],ee=>r(k,ee))===ve?null:k},onSuccess:k=>{if(!k)return;const F=R(k);w(F),v(F),d(null),h(!1),s(`${S[a].title} saved`)}}),E=be(y,l.data??null);return e.jsxs(K,{title:S[a].title,description:S[a].description(p.name),actions:qe(n,x),children:[e.jsxs("div",{className:"gc-policy-row",children:[e.jsxs("div",{className:"gc-policy-row__text",children:[e.jsx(Z,{policy:x?E.policy:t,invalid:x&&E.error!==null}),x&&e.jsx("span",{className:"gc-fineprint",children:"Showing your unsaved edits."})]}),e.jsx(b,{size:"sm",variant:"outline",onClick:()=>h(!0),children:n?"Edit":"View"})]}),m&&n&&!L&&e.jsx(q,{tone:"warning",title:"Changed elsewhere",children:"Someone saved this policy while you were editing it. Open it to reload theirs or keep yours."}),e.jsx(xe,{isOpen:L,onClose:()=>h(!1),size:"xl",title:S[a].title,subtitle:S[a].description(p.name),footer:n?e.jsxs(e.Fragment,{children:[E.error&&e.jsx("span",{className:"gc-warn gc-footer-note",children:E.error}),e.jsx(b,{variant:"ghost",disabled:!x,onClick:()=>{w(f),d(null)},children:"Discard changes"}),e.jsx(b,{disabled:o.isPending||!x,onClick:()=>o.mutate(),children:o.isPending?"Saving…":"Save policy"})]}):e.jsx(b,{variant:"outline",onClick:()=>h(!1),children:"Close"}),children:e.jsxs("div",{className:"gc-stack",children:[m&&n&&e.jsx(q,{tone:"warning",title:"Changed elsewhere",action:e.jsxs("div",{className:"gc-inline gc-inline--wrap",children:[e.jsx(b,{size:"sm",variant:"outline",onClick:()=>{w(m),v(m),d(null)},children:"Reload"}),e.jsx(b,{size:"sm",variant:"ghost",onClick:()=>{v(m),d(null)},children:"Keep editing"})]}),children:"Someone saved this policy while you were editing it. Reload to see their version (your edits are dropped), or keep editing and save to replace it."}),o.error?e.jsx(z,{error:o.error,title:"Could not save"}):null,e.jsx(ke,{value:y,onChange:w,peers:c.data,lists:l.data??[],parent:i,disabled:!n})]})}),g.dialog]})}function Ae(){const a=V(),t=X();return t.isLoading?e.jsx($,{rows:6}):t.error?e.jsx(z,{error:t.error,onRetry:()=>void t.refetch()}):e.jsx(I,{layer:"gateway",source:t.data??null,parent:null,canEdit:!0,onSave:async(i,n)=>{await T.network.setGatewayPolicy(i,n),await a.invalidateQueries({queryKey:W.group("routing")})}})}function J(){var f,v;const{workspace:a,viewer:t}=C(),i=V(),n=H(),r=ye(a.id),p=X(),s=n.data??[],c=p.data?M(p.data,s):null,l=((f=r.data)==null?void 0:f.orgRoutingPolicy)??null,g=((v=r.data)==null?void 0:v.routingPolicy)??null,y=u.useMemo(()=>_(c,l&&M(l,s),g&&M(g,s)),[c,l,g,s]);if(r.isLoading)return e.jsx($,{rows:6});if(r.error)return e.jsx(z,{error:r.error,onRetry:()=>void r.refetch()});const w=async()=>{await i.invalidateQueries({queryKey:W.group("workspaces")}),await i.invalidateQueries({queryKey:W.group("routing")})};return e.jsxs("div",{className:"gc-stack",children:[e.jsx(K,{title:"Effective for this workspace",description:"What keys in this workspace get before member, key and preset policies narrow it further.",children:e.jsxs("div",{className:"gc-sources",children:[e.jsx(P,{level:"Gateway default",children:N(p.data)}),e.jsx(P,{level:"Organization",children:N(l)}),e.jsx(P,{level:"Workspace",children:N(g)}),e.jsx(P,{level:"Effective",result:!0,children:e.jsx(Z,{policy:y})})]})}),e.jsx(I,{layer:"org",source:l,parent:c,canEdit:D(t),onSave:async(m,d)=>{await T.workspaces.update(a.id,{orgRoutingPolicy:Q(m)},d),await w()}}),e.jsx(I,{layer:"workspace",source:g,parent:_(c,l&&M(l,s)),canEdit:me(t),onSave:async(m,d)=>{await T.workspaces.update(a.id,{routingPolicy:Q(m)},d),await w()}})]})}function Te(){const a=pe();if(!a.data)return null;const t=ge(a.data);return e.jsxs("p",{className:"gc-fineprint",children:["Buyer config, which every policy here can only narrow: ",t.length>0?t.join(" · "):"none","."]})}function We(){const{viewer:a}=C(),t=D(a),[i,n]=u.useState(t?"gateway":"workspace");return t?e.jsxs(e.Fragment,{children:[e.jsx(Se,{id:"gc-routing-level",label:"Policy level",value:i,onChange:n,tabs:[{id:"gateway",label:"Gateway default"},{id:"workspace",label:"This workspace"}]}),e.jsx(Ne,{tabsId:"gc-routing-level",tab:i,children:i==="gateway"?e.jsx(Ae,{}):e.jsx(J,{})})]}):e.jsx(J,{})}function Ye(){return e.jsxs("div",{className:"gc-page",children:[e.jsx(ue,{title:"Routing",description:"Which sellers serve your requests and how they are ranked. Each level can only narrow the one above."}),e.jsx(Te,{}),e.jsx(We,{}),e.jsx(Le,{})]})}export{Ye as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as m}from"./index-
|
|
1
|
+
import{j as m}from"./index-BjRmy3XE.js";import{r as f,f as g}from"./roving-DkptacxO.js";function _({value:l,onChange:n,options:a,label:u,className:c}){const o=Math.max(0,a.findIndex(e=>e.value===l));return m.jsx("div",{className:["as-segmented",c].filter(Boolean).join(" "),role:"radiogroup","aria-label":u,children:a.map((e,d)=>{const i=e.value===l;return m.jsx("button",{type:"button",role:"radio","aria-checked":i,tabIndex:d===o?0:-1,disabled:e.disabled,className:i?"as-segmented__item as-segmented__item--on":"as-segmented__item",onClick:()=>n(e.value),onKeyDown:t=>{const r=f(t,d,a.length);if(r===null)return;t.preventDefault();const s=a[r];!s||s.disabled||(n(s.value),g(t,r,".as-segmented__item"))},children:e.label},e.value)})})}export{_ as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as j,j as e,Z as o,$ as h,a0 as f}from"./index-
|
|
1
|
+
import{r as j,j as e,Z as o,$ as h,a0 as f}from"./index-BjRmy3XE.js";function b({label:a,hint:d,error:t,options:c,onChange:r,className:i,id:n,size:u,...x}){const m=j.useId(),l=n??m;return e.jsxs("label",{className:f(i,u),htmlFor:l,children:[a&&e.jsx("span",{className:"as-field__label",children:a}),e.jsx("select",{id:l,className:o("as-field__select"),onChange:s=>r(s.target.value),...x,children:c.map(s=>e.jsx("option",{value:s.value,disabled:s.disabled,children:s.label},s.value))}),e.jsx(h,{error:t,hint:d})]})}export{b as S};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{D as re,F as ne,b2 as ge,b9 as xe,r as d,bf as ae,q,e as E,bq as ve,bc as be,b5 as K,f as fe,j as t,ac as D,bl as ye,T as O,B as y,n as $,C as ie,d as Se,P as je,Q as z,ad as we,k as A,V as le,M as ke,t as M,u as Pe,R as Re,s as Q,aG as Ne,a9 as W,aP as Ce,a8 as Me,E as Ie,I as G,A as Y,aF as qe,Y as Ue}from"./index-
|
|
1
|
+
import{D as re,F as ne,b2 as ge,b9 as xe,r as d,bf as ae,q,e as E,bq as ve,bc as be,b5 as K,f as fe,j as t,ac as D,bl as ye,T as O,B as y,n as $,C as ie,d as Se,P as je,Q as z,ad as we,k as A,V as le,M as ke,t as M,u as Pe,R as Re,s as Q,aG as Ne,a9 as W,aP as Ce,a8 as Me,E as Ie,I as G,A as Y,aF as qe,Y as Ue}from"./index-BjRmy3XE.js";import{a as J,S as Z}from"./PolicyEditor-B5BAs2vC.js";import{S as Te}from"./Segmented-C9jux-Mr.js";import{S as I}from"./Switch-hSHNLapF.js";import{D as F}from"./Disclosure-DS6GTz8G.js";import{T as oe}from"./TextAreaField-9B3_7w3L.js";import{T as Oe,a as Ee}from"./Tabs-Dle_Eq4t.js";import{D as Ae}from"./DataTable-B36eMErM.js";import{S as B}from"./SelectField-BSNXjRiC.js";import"./roving-DkptacxO.js";import"./index-iM-80gy8.js";function Fe(e){return Object.entries(e).map(([s,r])=>`${s}: ${r}`).join(`
|
|
2
2
|
`)}function De(e){const s={};for(const[r,a]of e.split(`
|
|
3
3
|
`).entries()){if(!a.trim())continue;const c=a.indexOf(":");if(c<=0)throw new Error(`Line ${r+1}: use "Name: value".`);const u=a.slice(0,c).trim();if(!/^[A-Za-z0-9!#$%&'*+.^_`|~-]+$/.test(u))throw new Error(`Line ${r+1}: "${u}" is not a valid header name.`);s[u]=a.slice(c+1).trim()}return s}const ce="••••";function $e(e){return e.split(`
|
|
4
4
|
`).map(s=>{const r=s.indexOf(":");return r>0&&s.slice(r+1).trim()===ce?s.slice(0,r).trim():null}).filter(s=>!!s)}function X(e){return e.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,j as s}from"./index-
|
|
1
|
+
import{r as e,j as s}from"./index-BjRmy3XE.js";function _({checked:a,onChange:r,label:l,description:t,disabled:n,className:o}){const c=e.useId(),i=e.useId();return s.jsxs("div",{className:["as-switch",o].filter(Boolean).join(" "),children:[s.jsx("button",{id:c,type:"button",role:"switch","aria-checked":a,"aria-describedby":t?i:void 0,disabled:n,className:a?"as-switch__track as-switch__track--on":"as-switch__track",onClick:()=>r(!a),children:s.jsx("span",{className:"as-switch__thumb"})}),s.jsxs("label",{htmlFor:c,className:"as-switch__text",children:[s.jsx("span",{className:"as-switch__label",children:l}),t&&s.jsx("span",{id:i,className:"as-switch__desc",children:t})]})]})}export{_ as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as _,j as l}from"./index-
|
|
1
|
+
import{r as _,j as l}from"./index-BjRmy3XE.js";import{r as j,f as I}from"./roving-DkptacxO.js";function u(a,n){return`${a}-tab-${n}`}function f(a,n){return`${a}-panel-${n}`}function y({value:a,onChange:n,tabs:e,id:s,label:o,className:x}){const p=_.useId(),d=s??p,m=Math.max(0,e.findIndex(t=>t.id===a));return l.jsx("div",{className:["as-tabs",x].filter(Boolean).join(" "),role:"tablist","aria-label":o,children:e.map((t,c)=>{const b=t.id===a;return l.jsx("button",{id:u(d,t.id),type:"button",role:"tab","aria-selected":b,"aria-controls":f(d,t.id),tabIndex:c===m?0:-1,className:b?"as-tabs__tab as-tabs__tab--on":"as-tabs__tab",onClick:()=>n(t.id),onKeyDown:r=>{const i=j(r,c,e.length);i!==null&&(r.preventDefault(),n(e[i].id),I(r,i,".as-tabs__tab"))},children:t.label},t.id)})})}function N({tabsId:a,tab:n,children:e,className:s,...o}){return l.jsx("div",{id:f(a,n),role:"tabpanel","aria-labelledby":u(a,n),tabIndex:0,className:["as-tabpanel",s].filter(Boolean).join(" "),...o,children:e})}export{y as T,N as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o,j as s,Z as c,$ as m,a0 as u}from"./index-
|
|
1
|
+
import{r as o,j as s,Z as c,$ as m,a0 as u}from"./index-BjRmy3XE.js";function j({label:a,hint:i,error:e,className:l,id:d,mono:r,...n}){const x=o.useId(),t=d??x;return s.jsxs("label",{className:u(l),htmlFor:t,children:[a&&s.jsx("span",{className:"as-field__label",children:a}),s.jsx("textarea",{id:t,className:c("as-field__textarea",r),"aria-invalid":e?!0:void 0,...n}),s.jsx(m,{error:e,hint:i})]})}export{j as T};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as y,d as q,j as t,L as O,n as x,E as j,I as C,l as M,g as b,f as R,h as v,e as w,q as I}from"./index-
|
|
1
|
+
import{r as y,d as q,j as t,L as O,n as x,E as j,I as C,l as M,g as b,f as R,h as v,e as w,q as I}from"./index-BjRmy3XE.js";import{a as L,b as U,c as B,t as N,s as _,O as F,d as $}from"./usage-4421Rf6_.js";import{S as c,O as A,a as H}from"./Charts-CrCKBk_i.js";const K=[{value:"spend",label:"Spend"},{value:"requests",label:"Requests"},{value:"tokens",label:"Tokens"}],z={spend:e=>R(e),requests:e=>b(e,{compact:!0}),tokens:e=>v(e)};function h(e){return e==="24h"?"hour":e==="90d"?"week":"day"}const D={input:c[0],cached:c[5],output:c[2]};function P(e,r){return e==="tokens"?`Tokens per ${h(r)} by type (input, cached input, output), UTC.`:`${K.find(l=>l.value===e).label} per ${h(r)} by model, UTC. The largest models get their own colour.`}function V({filter:e,range:r,now:l,metric:o,height:d}){const n=y.useMemo(()=>L(r,l),[r,l]),k={...e,from:n[0].from,to:n.at(-1).to-1,groupBy:$(r),splitBy:"model"},a=q({queryKey:I.usage(k),queryFn:()=>w.usage.report(k)}),i=y.useMemo(()=>U(a.data,n),[a.data,n]);if(a.isLoading)return t.jsx(O,{rows:1,height:d??240});if(a.error)return t.jsx(x,{error:a.error,onRetry:()=>void a.refetch()});const p=B(i);if(p===0)return t.jsx(j,{icon:t.jsx(C.activity,{size:18}),title:"No usage in this range",body:"Requests made with this workspace's keys show up here."});const m=o==="tokens"?N(i):_(i,o),f=m.series.map((s,u)=>({...s,color:o==="tokens"?D[s.key]:s.key===F?A:c[u%c.length]})),E=f.reduce((s,u)=>s+u.total,0),g=i.reduce((s,u)=>s+u.groups.reduce((S,T)=>S+M(T.spent),0),0);return t.jsxs(t.Fragment,{children:[t.jsx(H,{label:o==="tokens"?"tokens by type":`${o} by model`,labels:n.map(s=>s.label),columns:m.columns,series:f,format:z[o],height:d}),E===0&&t.jsxs("p",{className:"gc-fineprint",children:[b(p)," ",p===1?"request":"requests",", ",R(g)," recorded so far",o==="tokens"?" (no token counts reported yet)":"","."]})]})}export{K as M,V as U,P as c};
|