@antseed/gateway-console 0.1.0 → 0.1.1
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-TLrqPYT_.js → Activity-aMw4GLn_.js} +1 -1
- package/dist/assets/{Audit-Ulc9lO-n.js → Audit-CCre2vZ2.js} +1 -1
- package/dist/assets/{ChainGate-DByG6cpi.js → ChainGate-rOjMTVIg.js} +1 -1
- package/dist/assets/{ChannelClose-o3JlhOLp.js → ChannelClose-DkQxS0-Z.js} +1 -1
- package/dist/assets/{Charts-ogViQ7jC.js → Charts-NmIMcccv.js} +1 -1
- package/dist/assets/{ConnectWallet-BgR8VSGh.js → ConnectWallet-QN7kfDQq.js} +1 -1
- package/dist/assets/{DataTable-Cizb1YVv.js → DataTable-D2QIQ-gI.js} +1 -1
- package/dist/assets/{Disclosure-Ygp-7rwy.js → Disclosure-h1MJg5Wn.js} +1 -1
- package/dist/assets/{KeyHolder-BnyOBKE-.js → KeyHolder-DUhCBfBH.js} +1 -1
- package/dist/assets/{Keys-ySYMBnwu.js → Keys-DIlH-qns.js} +1 -1
- package/dist/assets/{Logs-B3jGPBKu.js → Logs-BPrDGUHL.js} +1 -1
- package/dist/assets/{Members-DoR2B86a.js → Members-Cud9TWBJ.js} +1 -1
- package/dist/assets/Migrate-DEIQ12oJ.js +1 -0
- package/dist/assets/{Models-B3ydIRK0.js → Models-DXI7RYae.js} +1 -1
- package/dist/assets/{OperatorActions-BiEyggac.js → OperatorActions-BC74iRfA.js} +1 -1
- package/dist/assets/{OperatorGateAlert-YOWZD4vB.js → OperatorGateAlert-CIQwPW1h.js} +1 -1
- package/dist/assets/{Overview-C4HAFyAv.js → Overview-ipvNEEut.js} +1 -1
- package/dist/assets/{PolicyEditor-CxJuR6mU.js → PolicyEditor-CRhTwGq0.js} +1 -1
- package/dist/assets/{PolicyField-B7_URv8N.js → PolicyField-0xAOIP4-.js} +1 -1
- package/dist/assets/{Presets-B1xDCjO5.js → Presets-DrJ48O3s.js} +1 -1
- package/dist/assets/{Providers-DvAeVyia.js → Providers-CcIj0C5E.js} +1 -1
- package/dist/assets/{RequestLog-DYJGceII.js → RequestLog-CBZWWnHo.js} +1 -1
- package/dist/assets/{Rewards-B5U3sj8Q.js → Rewards-CUru480X.js} +2 -2
- package/dist/assets/{RewardsClaim-BvXAMTsl.js → RewardsClaim-BjwCidx5.js} +1 -1
- package/dist/assets/{Routing-CmwA_zD2.js → Routing-BO7JFJGH.js} +1 -1
- package/dist/assets/{Segmented-DfgcyK0R.js → Segmented-BJmgB5-Y.js} +1 -1
- package/dist/assets/{SelectField-BCIB_aud.js → SelectField-D_BPTzpT.js} +1 -1
- package/dist/assets/{Settings-CNzp4dy6.js → Settings-qFQk36WV.js} +1 -1
- package/dist/assets/{Switch-GA0Kao4V.js → Switch-JCyfy3G5.js} +1 -1
- package/dist/assets/{Tabs-dykHKE0J.js → Tabs-CGI9v1OW.js} +1 -1
- package/dist/assets/{TextAreaField-DWl60i8s.js → TextAreaField-4JuDDT4k.js} +1 -1
- package/dist/assets/{UsageByModel-BEa6PT2A.js → UsageByModel-jvNkVE4M.js} +1 -1
- package/dist/assets/{Wallet-Uy4ZSU5T.js → Wallet-tlCKFe2Q.js} +3 -3
- package/dist/assets/{WalletConfirm-DnVf8fxx.js → WalletConfirm-Dz6gVYW9.js} +1 -1
- package/dist/assets/{WalletFunding-Evna4htj.js → WalletFunding-NSKzSiY5.js} +1 -1
- package/dist/assets/{WalletSignIn-DTELVhCs.js → WalletSignIn-Bs_yxjak.js} +1 -1
- package/dist/assets/{Workspaces-B2-b1tIs.js → Workspaces-C79eSjJK.js} +1 -1
- package/dist/assets/{add-j5zdPda_.js → add-CxYxphqt.js} +1 -1
- package/dist/assets/{all-wallets-CA6rWtJi.js → all-wallets-BSHfFrwc.js} +1 -1
- package/dist/assets/{app-store-DVSDl9sG.js → app-store-DzDsfjeG.js} +1 -1
- package/dist/assets/{apple-F6q4P0GW.js → apple-N_ET94Rt.js} +1 -1
- package/dist/assets/{arrow-bottom-DTDfowA3.js → arrow-bottom-U6RBQjWC.js} +1 -1
- package/dist/assets/{arrow-bottom-circle-BuTjDGNx.js → arrow-bottom-circle-tDeqZ1Ky.js} +1 -1
- package/dist/assets/{arrow-left-B6jPBX4Q.js → arrow-left-BShNPqIx.js} +1 -1
- package/dist/assets/{arrow-right-CtG-tU7-.js → arrow-right-CNSfQOzD.js} +1 -1
- package/dist/assets/{arrow-top-tqiU407U.js → arrow-top-DV_peLyo.js} +1 -1
- package/dist/assets/{bank-GyeZDLGq.js → bank-CBIxfTrG.js} +1 -1
- package/dist/assets/{basic-CmQlzGue.js → basic-N6vekuGx.js} +1 -1
- package/dist/assets/{browser-B2noKwpy.js → browser-CSb6b6iQ.js} +1 -1
- package/dist/assets/{card-BzkRiTRW.js → card-DrFIu-YX.js} +1 -1
- package/dist/assets/{ccip-B5yDFwGe.js → ccip-kqAjTfpP.js} +1 -1
- package/dist/assets/{checkmark-BPvD-RlS.js → checkmark-CjzmzCYU.js} +1 -1
- package/dist/assets/{checkmark-bold-15LUuMgT.js → checkmark-bold-B66sPzPs.js} +1 -1
- package/dist/assets/{chevron-bottom-B4wBpHkq.js → chevron-bottom--JM7vIl_.js} +1 -1
- package/dist/assets/{chevron-left-CVZZ7Yrp.js → chevron-left-CPo0GZiC.js} +1 -1
- package/dist/assets/{chevron-right-CHU8KrpS.js → chevron-right-BgXTpiHp.js} +1 -1
- package/dist/assets/{chevron-top-1zX-3DnW.js → chevron-top-BDxNAlrf.js} +1 -1
- package/dist/assets/{chrome-store-C1tTudWr.js → chrome-store-BCPQdBXr.js} +1 -1
- package/dist/assets/{clock-DzN1w847.js → clock-B7Udw_0s.js} +1 -1
- package/dist/assets/{close-2PkXZunJ.js → close-ClhMnzas.js} +1 -1
- package/dist/assets/{coinPlaceholder-CPo15KWk.js → coinPlaceholder-Bsvaf8UD.js} +1 -1
- package/dist/assets/{compass-BkQOvGr9.js → compass-CtgRkLwG.js} +1 -1
- package/dist/assets/{copy-D7J_9yWu.js → copy-Cju_aL0g.js} +1 -1
- package/dist/assets/{core-D7Iu3F-N.js → core-Dv4ivRNs.js} +3 -3
- package/dist/assets/cursor-D3NwpSI9.js +3 -0
- package/dist/assets/{cursor-transparent-5cw6wIF5.js → cursor-transparent-A0O6SzCH.js} +1 -1
- package/dist/assets/{desktop-CN9tnTE4.js → desktop-CuYleYi9.js} +1 -1
- package/dist/assets/{disconnect-BT0EHVOp.js → disconnect-UdfoNj_d.js} +1 -1
- package/dist/assets/{discord-Aua-xz-O.js → discord-CBP0IyFM.js} +1 -1
- package/dist/assets/{en_US-Y4ZOVFV4-Dx46mx69.js → en_US-Y4ZOVFV4-3vDquI1C.js} +4 -4
- package/dist/assets/{etherscan-CFVn8yLT.js → etherscan-PHAlrHol.js} +1 -1
- package/dist/assets/{exclamation-triangle-DuGroEVd.js → exclamation-triangle-udtYedHZ.js} +1 -1
- package/dist/assets/{extension-vxS12Di_.js → extension-BSfnWZTn.js} +1 -1
- package/dist/assets/{external-link-_BcrwSiW.js → external-link-BhINeBf6.js} +1 -1
- package/dist/assets/{facebook-DmCisZFD.js → facebook-DPMSywQV.js} +1 -1
- package/dist/assets/{farcaster-BicNTxi0.js → farcaster-BgZocY3-.js} +1 -1
- package/dist/assets/{filters-DsqaapJj.js → filters-H_ETj-7w.js} +1 -1
- package/dist/assets/{github-Cy8vtSA1.js → github-Dnt_pb3p.js} +1 -1
- package/dist/assets/{google-DWOb5WfA.js → google-Mu_8pwD-.js} +1 -1
- package/dist/assets/{help-circle-D71RiRr9.js → help-circle-DRVJ-8K8.js} +1 -1
- package/dist/assets/{highlighted-body-KQOG7T2V-BnrhMNof.js → highlighted-body-KQOG7T2V-ClwcaYX1.js} +1 -1
- package/dist/assets/{id-DrPfUse9.js → id-DXjcfKMm.js} +1 -1
- package/dist/assets/{image-CnNTNyxr.js → image-Bhqm-9NV.js} +1 -1
- package/dist/assets/{index-Davt47yI.js → index-BrcuwiCz.js} +1 -1
- package/dist/assets/{index-BC-1LZkB.js → index-C21bvTBH.js} +3 -3
- package/dist/assets/{index-DKArLaJL.js → index-C9wUwD4n.js} +3 -3
- package/dist/assets/{index-DAL5B3y6.js → index-CR02SnS1.js} +1 -1
- package/dist/assets/{index-DoyAkmwr.js → index-DNA9wtqn.js} +1 -1
- package/dist/assets/index-DqHGr8d4.js +1 -0
- package/dist/assets/{index-CTBUSmCv.css → index-U4U6E7fq.css} +1 -1
- package/dist/assets/{index.es-_gKXPOax.js → index.es-DX2eegnP.js} +4 -4
- package/dist/assets/{info-DyD6yyYg.js → info-BaRtFUwf.js} +1 -1
- package/dist/assets/{info-circle-Ci0aBoWf.js → info-circle-Bsl8G0Ii.js} +1 -1
- package/dist/assets/{lightbulb-Bc9E0FQl.js → lightbulb-BlV4kI0m.js} +1 -1
- package/dist/assets/{limits-DONLLmCg.js → limits-D_C7APR_.js} +1 -1
- package/dist/assets/{mail-DX77ctj9.js → mail-BPcY_N8f.js} +1 -1
- package/dist/assets/mermaid-MCJ5UELQ-BFJCTi2D.css +1 -0
- package/dist/assets/{mermaid-MCJ5UELQ-C7m1hGo2.js → mermaid-MCJ5UELQ-DAirhLo4.js} +172 -167
- package/dist/assets/{metamask-sdk-BIed_ryS.js → metamask-sdk-B0WxSi8v.js} +1 -1
- package/dist/assets/{mobile-D5d7E8aH.js → mobile-9_L4G6Kz.js} +1 -1
- package/dist/assets/{models-B4dUNXf8.js → models-BpLCh6Fr.js} +1 -1
- package/dist/assets/{more-C0LpQuB5.js → more-BMrrxkhZ.js} +1 -1
- package/dist/assets/{network-placeholder-DyHu8rcA.js → network-placeholder-CYXkxcyL.js} +1 -1
- package/dist/assets/{nftPlaceholder-BSGI5wo_.js → nftPlaceholder-CfIu_Ovu.js} +1 -1
- package/dist/assets/{off-DaDUbVtw.js → off-BpqSEfQB.js} +1 -1
- package/dist/assets/{play-store-JqDZrwEV.js → play-store-BKqBXU1V.js} +1 -1
- package/dist/assets/{plus-DRfkCkbA.js → plus-CSgT3KZh.js} +1 -1
- package/dist/assets/{qr-code-xpdnr3F5.js → qr-code-edbLJ8Gf.js} +1 -1
- package/dist/assets/{recycle-horizontal-DCb4o2oq.js → recycle-horizontal-CuX0JB4-.js} +1 -1
- package/dist/assets/{refresh-Dh1nUzf1.js → refresh-Dq45LHYF.js} +1 -1
- package/dist/assets/{reown-logo-D2B07KAj.js → reown-logo-CRobwYXY.js} +1 -1
- package/dist/assets/{search-DxSQ6hKW.js → search-gYoog0zk.js} +1 -1
- package/dist/assets/{secp256k1-CjIPHKIU.js → secp256k1-uRM0t8uf.js} +1 -1
- package/dist/assets/{send-fGQXWcs3.js → send-Pm4IO0Hs.js} +1 -1
- package/dist/assets/{swapHorizontal-BBY5Lgpd.js → swapHorizontal-DhCZ210V.js} +1 -1
- package/dist/assets/{swapHorizontalBold-Cq-sYmrj.js → swapHorizontalBold-DHO5cxVU.js} +1 -1
- package/dist/assets/{swapHorizontalMedium-BqOEbUvj.js → swapHorizontalMedium-VGtbzLgi.js} +1 -1
- package/dist/assets/{swapHorizontalRoundedBold-C0OuqTc3.js → swapHorizontalRoundedBold-6HTAC2Np.js} +1 -1
- package/dist/assets/{swapVertical-BXdNxS19.js → swapVertical-Dg6bMEa-.js} +1 -1
- package/dist/assets/{telegram-BmiIZY4i.js → telegram-CHXgC-Jw.js} +1 -1
- package/dist/assets/{three-dots-DTapkkpV.js → three-dots-MixBEg-b.js} +1 -1
- package/dist/assets/{twitch-DYg0xYBZ.js → twitch-CWrx7ZD7.js} +1 -1
- package/dist/assets/{twitterIcon-CWX6L2yg.js → twitterIcon-Vrp2iWQv.js} +1 -1
- package/dist/assets/{usage-kR1h5urb.js → usage-MPZYg7D2.js} +1 -1
- package/dist/assets/{useInfiniteQuery-CgC_8jUi.js → useInfiniteQuery-Bpu8bc5A.js} +1 -1
- package/dist/assets/{useTx-VVmPNn5M.js → useTx-Cp52G7Yo.js} +1 -1
- package/dist/assets/{verify-9xDOJyem.js → verify-Cv1Ie02p.js} +1 -1
- package/dist/assets/{verify-filled-Ddmmdp9A.js → verify-filled-D4Of1TFY.js} +1 -1
- package/dist/assets/{w3m-modal-Db-ExkQd.js → w3m-modal-B8kvY5hN.js} +1 -1
- package/dist/assets/{wallet-placeholder-BCJd28d4.js → wallet-placeholder-C-l2svWA.js} +1 -1
- package/dist/assets/{wallet-BFpW6bHU.js → wallet-uxpqh3A6.js} +1 -1
- package/dist/assets/{walletconnect-RK9ghEgJ.js → walletconnect-0CplSxZT.js} +1 -1
- package/dist/assets/{warning-circle-BN9_WKsD.js → warning-circle-gLBXgr6A.js} +1 -1
- package/dist/assets/{x-B_Ut3Zzd.js → x-C17dW4I6.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/dist/assets/Migrate-BO1VvY3j.js +0 -1
- package/dist/assets/cursor-D_ZL5xdj.js +0 -3
- package/dist/assets/index-DX_0N6eB.js +0 -1
- package/dist/assets/mermaid-MCJ5UELQ-BwMuBn9t.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as O,a as P,r,i as Q,b as W,c as $,d as T,j as s,P as L,B as C,I,e as h,S as p,f as R,g as b,h as l,k as B,Q as H,l as J,E as X,m as Y,q as M}from"./index-
|
|
1
|
+
import{u as O,a as P,r,i as Q,b as W,c as $,d as T,j as s,P as L,B as C,I,e as h,S as p,f as R,g as b,h as l,k as B,Q as H,l as J,E as X,m as Y,q as M}from"./index-C21bvTBH.js";import{U as Z,M as _,c as ee}from"./UsageByModel-jvNkVE4M.js";import{r as se,R as ae,g as k}from"./usage-MPZYg7D2.js";import{S as V}from"./Segmented-BJmgB5-Y.js";import{S as v}from"./SelectField-D_BPTzpT.js";import{D as te}from"./DataTable-D2QIQ-gI.js";import"./Charts-NmIMcccv.js";import"./roving-DkptacxO.js";import"./index-DqHGr8d4.js";const E=[{value:"model",label:"Model"},{value:"key",label:"Key"},{value:"peer",label:"Seller"},{value:"user",label:"End user"},{value:"member",label:"Member",admin:!0},{value:"workspace",label:"Workspace",org:!0},{value:"day",label:"Day"}];function pe(){var q;const{viewer:x,workspace:j}=O(),o=P(),[n,F]=r.useState("30d"),[i,N]=r.useState("model"),[d,z]=r.useState("spend"),[c,f]=r.useState(""),[m,S]=r.useState(""),g=Q(x),y=r.useMemo(()=>Date.now(),[n]),A=se(n,y),u={...o,key:c||void 0,member:m||o.member,from:A,to:y},U=W({workspace:j.id,member:o.member}),K=$(j.id,g),D=T({queryKey:M.usage({...u,groupBy:"day"}),queryFn:()=>h.usage.report({...u,groupBy:"day"})}),G=T({queryKey:M.usage({...u,groupBy:i}),queryFn:()=>h.usage.report({...u,groupBy:i})}),t=(q=D.data)==null?void 0:q.totals;return s.jsxs("div",{className:"gc-page",children:[s.jsx(L,{title:"Activity",description:"Spend and token usage over time.",actions:s.jsx(C,{variant:"outline",size:"sm",href:h.usage.exportUrl({...u,groupBy:i}),download:!0,leadingIcon:s.jsx(I.download,{size:14}),children:"Export CSV"})}),s.jsxs("div",{className:"gc-toolbar",children:[s.jsx(V,{label:"Time range",value:n,onChange:F,options:ae.map(a=>({value:a.id,label:a.label}))}),s.jsx(v,{size:"sm","aria-label":"Filter by key",value:c,onChange:f,options:[{value:"",label:"All keys"},...(U.data??[]).map(a=>({value:a.id,label:a.label}))]}),g&&s.jsx(v,{size:"sm","aria-label":"Filter by member",value:m,onChange:S,options:[{value:"",label:"All members"},...(K.data??[]).map(({member:a})=>({value:a.id,label:a.label}))]}),(c||m)&&s.jsx(C,{variant:"ghost",size:"sm",onClick:()=>{f(""),S("")},children:"Clear filters"})]}),s.jsxs("div",{className:"gc-grid gc-grid--4",children:[s.jsx(p,{label:"Spend",value:t?R(t.spent):"…"}),s.jsx(p,{label:"Requests",value:t?b(t.requests):"…",sub:t?`${b(t.failedRequests)} failed`:void 0}),s.jsx(p,{label:"Input tokens",value:t?l(t.inputTokens):"…",sub:t?`${l(t.cachedInputTokens)} cached`:void 0}),s.jsx(p,{label:"Output tokens",value:t?l(t.outputTokens):"…"})]}),s.jsx(B,{title:d==="tokens"?"Tokens by type":"Usage by model",description:ee(d,n),actions:s.jsx(V,{label:"Chart metric",value:d,onChange:z,options:_}),children:s.jsx(Z,{filter:{...o,key:c||void 0,member:m||o.member},range:n,now:y,metric:d})}),s.jsx(B,{title:"Breakdown",flush:!0,actions:s.jsx(v,{size:"sm","aria-label":"Group by",value:i,onChange:a=>N(a),options:E.filter(a=>(!a.admin||g)&&(!a.org||Y(x))).map(a=>({value:a.value,label:`By ${a.label.toLowerCase()}`}))}),children:s.jsx(H,{query:G,children:a=>{var w;return s.jsx(te,{label:"Usage breakdown",rows:a.groups,rowKey:e=>e.group,initialSort:{key:"spent",direction:"desc"},empty:s.jsx(X,{icon:s.jsx(I.activity,{size:18}),title:"No usage in this range",body:"Requests made with this workspace's keys show up here."}),columns:[{key:"label",header:((w=E.find(e=>e.value===i))==null?void 0:w.label)??"Group",render:e=>s.jsx("span",{className:"gc-ellipsis",title:k(e),children:k(e)}),sortValue:e=>k(e)},{key:"requests",header:"Requests",align:"right",render:e=>b(e.requests),sortValue:e=>e.requests},{key:"failed",header:"Failed",align:"right",secondary:!0,render:e=>b(e.failedRequests),sortValue:e=>e.failedRequests},{key:"input",header:"Input",align:"right",secondary:!0,render:e=>l(e.inputTokens),sortValue:e=>e.inputTokens},{key:"cached",header:"Cached",align:"right",secondary:!0,render:e=>l(e.cachedInputTokens),sortValue:e=>e.cachedInputTokens},{key:"output",header:"Output",align:"right",secondary:!0,render:e=>l(e.outputTokens),sortValue:e=>e.outputTokens},{key:"spent",header:"Spend",align:"right",render:e=>R(e.spent),sortValue:e=>J(e.spent)}]})}})})]})}export{pe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o,O as A,R as y,j as e,P as w,B as b,k as P,U as N,V as S,M as d,W as C,X as x,L as E,Y as I,E as g,I as m,n as L,t as T,e as F,q as M}from"./index-
|
|
1
|
+
import{r as o,O as A,R as y,j as e,P as w,B as b,k as P,U as N,V as S,M as d,W as C,X as x,L as E,Y as I,E as g,I as m,n as L,t as T,e as F,q as M}from"./index-C21bvTBH.js";import{u as z}from"./useInfiniteQuery-Bpu8bc5A.js";import{S as h}from"./SelectField-D_BPTzpT.js";import{D as B}from"./DataTable-D2QIQ-gI.js";import"./index-DqHGr8d4.js";const R=50,W=[{value:"",label:"All actions"},{value:"auth",label:"Sign-ins"},{value:"key",label:"API keys"},{value:"member",label:"Members"},{value:"invite",label:"Invites"},{value:"workspace",label:"Workspaces"},{value:"routing",label:"Gateway routing"},{value:"peer_list",label:"Peer lists"},{value:"preset",label:"Presets"},{value:"wallet",label:"Wallets"},{value:"channel",label:"Channels"},{value:"settings",label:"Settings"},{value:"token",label:"Management tokens"}],u={member:"Member",token:"Token",key:"API key",system:"System",cli:"CLI"};function c(t){return t.actor.label??t.actor.id??u[t.actor.kind]}function $(t){return z({queryKey:M.audit(t),queryFn:({pageParam:i})=>F.audit.list({...t,before:i??void 0,limit:R}),initialPageParam:null,getNextPageParam:i=>i.nextBefore})}function D({query:t,filtered:i,onSelect:l}){var s;if(t.isLoading)return e.jsx(E,{rows:8});if(I(t.error)&&t.error.status===404)return e.jsx(g,{icon:e.jsx(m.audit,{size:18}),title:"Audit log not available",body:"This gateway version does not record an audit log yet."});if(t.error)return e.jsx(L,{error:t.error,onRetry:()=>void t.refetch()});const n=((s=t.data)==null?void 0:s.pages.flatMap(a=>a.entries))??[];return e.jsxs(e.Fragment,{children:[e.jsx(B,{label:"Audit log",rows:n,rowKey:a=>a.id,onRowClick:l,rowLabel:a=>`${a.action} by ${c(a)}`,empty:e.jsx(g,{icon:e.jsx(m.audit,{size:18}),title:i?"No entries match":"Nothing recorded yet"}),columns:[{key:"at",header:"When",render:a=>e.jsx("span",{className:"gc-nowrap",children:x(a.at)})},{key:"actor",header:"Who",secondary:!0,render:a=>e.jsxs("span",{children:[c(a)," ",e.jsx(T,{children:u[a.actor.kind]})]})},{key:"action",header:"Action",render:a=>e.jsxs(e.Fragment,{children:[e.jsx(d,{children:a.action}),e.jsx("div",{className:"gc-narrow-only gc-muted",children:c(a)})]})},{key:"target",header:"Target",secondary:!0,render:a=>a.target?a.target.label??a.target.id??a.target.kind:"—"},{key:"ip",header:"IP",secondary:!0,optional:!0,render:a=>a.ip?e.jsx(d,{children:a.ip}):"—"}]}),t.hasNextPage&&e.jsx("div",{className:"gc-load-more",children:e.jsx(b,{variant:"outline",size:"sm",disabled:t.isFetchingNextPage,onClick:()=>void t.fetchNextPage(),children:t.isFetchingNextPage?"Loading…":"Load older entries"})})]})}function J(){const[t,i]=o.useState(""),[l,n]=o.useState(""),[s,a]=o.useState(null),j=A(),v=y(),p=[{value:"",label:"Anyone"},...(j.data??[]).map(r=>({value:r.id,label:r.label})),...(v.data??[]).map(r=>({value:r.id,label:`Token: ${r.label}`}))],k=o.useMemo(()=>({actor:t||void 0,action:l||void 0}),[t,l]),f=$(k);return e.jsxs("div",{className:"gc-page",children:[e.jsx(w,{title:"Audit log",description:"Who changed what in this organization: keys, members, workspaces, routing, wallets and settings."}),e.jsxs("div",{className:"gc-toolbar",children:[e.jsx(h,{size:"sm","aria-label":"Filter by who",value:t,onChange:i,options:p}),e.jsx(h,{size:"sm","aria-label":"Filter by action",value:l,onChange:n,options:W}),(t||l)&&e.jsx(b,{variant:"ghost",size:"sm",onClick:()=>{i(""),n("")},children:"Clear filters"})]}),e.jsx(P,{flush:!0,children:e.jsx(D,{query:f,filtered:!!(t||l),onSelect:a})}),e.jsx(N,{isOpen:s!==null,onClose:()=>a(null),eyebrow:"Audit entry",title:(s==null?void 0:s.action)??"",subtitle:s?x(s.at):void 0,children:s&&e.jsxs(e.Fragment,{children:[e.jsx(S,{items:[["Who",`${c(s)} (${u[s.actor.kind]})`],["Actor id",s.actor.id?e.jsx(d,{children:s.actor.id},"a"):"—"],["Target",s.target?`${s.target.kind}: ${s.target.label??s.target.id??"—"}`:"—"],["IP address",s.ip??"—"],["Entry id",e.jsx(d,{children:s.id},"i")]]}),Object.keys(s.details).length>0&&e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsx("div",{className:"as-field__label",children:"Details"}),e.jsx(C,{code:JSON.stringify(s.details,null,2)})]})]})})]})}export{J as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r,n,L as a,r as o}from"./index-
|
|
1
|
+
import{j as r,n,L as a,r as o}from"./index-C21bvTBH.js";function i({chain:s,error:t,children:e}){return t?r.jsx(n,{error:t}):s?r.jsx(o.Suspense,{fallback:r.jsx(a,{rows:2}),children:e(s)}):r.jsx(a,{rows:2})}export{i as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,H as T,aj as I,ak as E,ac as W,al as R,am as O,f as C,an as b,v as B,ao as x,B as S,ap as H,aq as w,ar as j}from"./index-
|
|
1
|
+
import{j as e,H as T,aj as I,ak as E,ac as W,al as R,am as O,f as C,an as b,v as B,ao as x,B as S,ap as H,aq as w,ar as j}from"./index-C21bvTBH.js";import{u as _,a as L,T as $,C as m,s as G}from"./useTx-Cp52G7Yo.js";import{a as z}from"./ConnectWallet-QN7kfDQq.js";import{O as F}from"./OperatorGateAlert-CIQwPW1h.js";import{W as P,u as V,c as D,r as M}from"./en_US-Y4ZOVFV4-3vDquI1C.js";import"./clsx-B-dksMZM.js";import"./index-DqHGr8d4.js";import"./index-BwpQbdIU.js";const U=1,J={request:"close channels on chain",withdraw:"withdraw channel reserves"};function K({channel:s,step:r}){const a=`antseed buyer channels ${r==="request"?"request-close":"withdraw"} ${s.channelId}`;return e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsx("p",{className:"gc-muted",children:"This workspace's authorized wallet is the wallet the gateway holds, so a browser wallet cannot sign this. Run on the gateway host (the workspace wallet pays the network fee in ETH):"}),e.jsxs("div",{className:"gc-address",children:[e.jsx("code",{className:"gc-mono",children:a}),e.jsx(H,{value:a,label:"Copy command"})]})]})}function Q({workspaceId:s,channel:r,chain:a,step:t,onDone:f,onAuthorize:v}){var p;const{address:i}=V(),g=D(),d=T(s),{refresh:k}=I(s),n=_(a.chainId),{writeContractAsync:q}=L(),o=E(a,"channels");if(!o)return e.jsx(W,{tone:"warning",children:"The gateway did not report the payment channels contract address."});if(((p=d.data)==null?void 0:p.relation)==="self")return e.jsx(K,{channel:r,step:t});const h=R(d.data,i,J[t]);if(!h.ok)return e.jsx(F,{gate:h,state:d.data,connected:i,onAuthorize:v});const l=r.channelId;async function N(){const[,,,,,,,c,A]=await M(g,{address:o,abi:m,functionName:"channels",args:[l],chainId:a.chainId});if(A!==U)throw new w("This channel is already settled or closed; nothing is left to do. The list now shows it.",!0);if(t==="request"&&c>0n)throw new w("A close was already requested for this channel. The list now shows when the reserve can be withdrawn.",!0);if(t==="withdraw"&&Number(c)*1e3+j>Date.now())throw new w(`The grace period ends in ${x(Number(c)*1e3+j)}. Withdraw then.`,!0);await G(g,{account:i,address:o,abi:m,functionName:t==="request"?"requestClose":"withdraw",args:[l],chainId:a.chainId})}async function y(){await n.run([{label:t==="request"?"Request close":"Withdraw reserve",check:N,send:()=>q({address:o,abi:m,functionName:t==="request"?"requestClose":"withdraw",args:[l],chainId:a.chainId})}],{onStale:()=>{k().catch(()=>{}),f(t)}})&&f(t)}const u=O(r);return e.jsxs("div",{className:"gc-stack",children:[t==="request"?e.jsxs("p",{className:"gc-muted",children:["The seller gets 15 minutes to settle what was spent. After that, withdraw the unused reserve (about ",C(b(r)),") back to the workspace balance. Both steps are signed by the authorized wallet ",B(h.operator),", which pays the network fee in ETH on ",a.name,"."]}):e.jsxs("p",{className:"gc-muted",children:["The grace period ",u&&u>Date.now()?`ends in ${x(u)}`:"has ended",". Withdrawing returns the unused reserve (about ",C(b(r)),") to the workspace balance; nothing leaves the workspace."]}),e.jsx($,{chain:a,runner:n,done:t==="request"?"Close requested. Withdraw the reserve in 15 minutes.":"Reserve returned to the balance."}),e.jsx(S,{fullWidth:!0,disabled:n.running,onClick:()=>void y(),children:n.running?"Working…":t==="request"?"Request on-chain close":"Withdraw unused reserve"})]})}function ne(s){return e.jsx(P,{chain:s.chain,children:e.jsxs("div",{className:"gc-stack",children:[e.jsx(z,{}),e.jsx(Q,{...s})]})})}export{ne as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as $,j as a}from"./index-
|
|
1
|
+
import{r as $,j as a}from"./index-C21bvTBH.js";const S=s=>s.toLocaleString("en-US");function E(s){const t=$.useRef(null),[e,l]=$.useState(s);return $.useEffect(()=>{const c=t.current;if(!c)return;const u=()=>l(Math.max(c.clientWidth,120));if(u(),typeof ResizeObserver>"u")return;const n=new ResizeObserver(u);return n.observe(c),()=>n.disconnect()},[]),[t,e]}function O(s){const t=10**Math.floor(Math.log10(s));for(const e of[1,2,2.5,5,10])if(s<=e*t)return e*t;return 10*t}function R({left:s,top:t,width:e,innerHeight:l,scaleMax:c,format:u}){return a.jsx(a.Fragment,{children:[0,.25,.5,.75,1].map(n=>{const i=t+l*(1-n);return a.jsxs("g",{children:[a.jsx("line",{x1:s,x2:e,y1:i,y2:i,className:n===0?"as-chart__axis":"as-chart__grid"}),a.jsx("text",{x:s-8,y:i+3.5,textAnchor:"end",className:"as-chart__tick",children:u(c*n)})]},n)})})}function A({points:s,height:t=200,format:e=S,label:l}){const[c,u]=$.useState(null),[n,i]=E(640),M=Math.max(...s.map(_=>_.value),0),j=M>0?O(M):1,o={top:8,bottom:24,left:Math.min(64,Math.max(36,e(j).length*7+8))},v=Math.max(i-o.left,40),f=t-o.top-o.bottom,r=v/Math.max(s.length,1),N=Math.max(2,Math.min(32,r*.68)),b=Math.max(1,Math.ceil(s.length/Math.max(1,Math.floor(v/64)))),x=c!==null?s[c]:null;return a.jsxs("div",{className:"as-chart",ref:n,children:[a.jsx("div",{className:"as-chart__readout","aria-live":"polite",children:x?a.jsxs(a.Fragment,{children:[a.jsx("strong",{children:e(x.value)})," ",a.jsxs("span",{children:[x.label,x.sub?` · ${x.sub}`:""]})]}):a.jsxs(a.Fragment,{children:[a.jsx("strong",{children:e(s.reduce((_,p)=>_+p.value,0))})," ",a.jsx("span",{children:"total"})]})}),a.jsxs("svg",{viewBox:`0 0 ${i} ${t}`,width:i,height:t,role:"img","aria-label":l,className:"as-chart__svg",onMouseLeave:()=>u(null),children:[a.jsx(R,{left:o.left,top:o.top,width:i,innerHeight:f,scaleMax:j,format:e}),s.map((_,p)=>{const k=_.value/j*f,d=o.left+p*r+(r-N)/2;return a.jsxs("g",{onMouseEnter:()=>u(p),children:[a.jsx("rect",{x:o.left+p*r,y:o.top,width:r,height:f,fill:"transparent"}),a.jsx("rect",{x:d,y:o.top+f-k,width:N,height:Math.max(k,_.value>0?1:0),rx:1.5,className:c===p?"as-chart__bar as-chart__bar--on":"as-chart__bar",children:a.jsx("title",{children:`${_.label}: ${e(_.value)}`})}),p%b===0&&a.jsx("text",{x:o.left+p*r+r/2,y:t-6,textAnchor:"middle",className:"as-chart__tick",children:_.label})]},p)})]})]})}function z({items:s,format:t=S}){const e=Math.max(...s.map(l=>l.value),0)||1;return a.jsx("ul",{className:"as-share",children:s.map(l=>a.jsxs("li",{children:[a.jsxs("div",{className:"as-share__row",children:[a.jsx("span",{className:"as-share__label",title:l.label,children:l.label}),a.jsx("span",{className:"as-share__value",children:t(l.value)})]}),a.jsx("div",{className:"as-share__bar",children:a.jsx("span",{style:{width:`${l.value/e*100}%`}})}),l.sub&&a.jsx("div",{className:"as-share__sub",children:l.sub})]},l.label))})}function I({values:s,label:t,width:e=96,height:l=24,format:c=S,per:u,emptyText:n="no data"}){const i=Math.max(...s,0);if(s.length<2||i===0)return a.jsx("span",{className:"as-spark as-spark--empty",role:"img","aria-label":`${t}: ${n}`});const M=e/(s.length-1),j=o=>l-2-o/i*(l-4),g=s.map((o,v)=>`${v===0?"M":"L"}${(v*M).toFixed(1)} ${j(o).toFixed(1)}`).join(" ");return a.jsxs("svg",{className:"as-spark",viewBox:`0 0 ${e} ${l}`,width:e,height:l,role:"img","aria-label":`${t}: peak ${c(i)}${u?` ${u}`:""}`,children:[a.jsx("path",{d:`${g} L${e} ${l} L0 ${l} Z`,className:"as-spark__area"}),a.jsx("path",{d:g,className:"as-spark__line"})]})}const T=["var(--as-series-1)","var(--as-series-2)","var(--as-series-3)","var(--as-series-4)","var(--as-series-5)","var(--as-series-6)"],U="var(--as-series-other)";function C(s,t,e){return s+t/2<e/2?Math.min(s+t+8,Math.max(e-192,0)):Math.max(s-8-184,0)}function Y({labels:s,columns:t,series:e,height:l=240,format:c,label:u}){const[n,i]=$.useState(null),[M,j]=E(640),g=t.map(h=>e.reduce((m,y)=>m+(h[y.key]??0),0)),o=Math.max(...g,0),v=o>0?O(o):1,r={top:8,bottom:24,left:Math.min(64,Math.max(36,c(v).length*7+8)),right:0},N=Math.max(j-r.left-r.right,40),b=l-r.top-r.bottom,x=N/Math.max(t.length,1),_=Math.max(3,Math.min(36,x*.68)),p=Math.max(1,Math.ceil(t.length/Math.max(1,Math.floor(N/64)))),k=e.reduce((h,m)=>h+m.total,0),d=n!==null?{index:n,sum:g[n]??0,column:t[n]??{}}:null,B=d?C(r.left+d.index*x,x,j):0;return a.jsxs("div",{className:"as-chart",ref:M,children:[a.jsxs("div",{className:"as-chart__readout","aria-live":"polite",children:[a.jsx("strong",{children:c(d?d.sum:k)}),a.jsx("span",{children:d?s[d.index]:"total in range"})]}),a.jsxs("div",{className:"as-chart__plot",children:[a.jsxs("svg",{viewBox:`0 0 ${j} ${l}`,width:j,height:l,role:"img","aria-label":u,className:n!==null?"as-chart__svg as-chart__svg--hovering":"as-chart__svg",onMouseLeave:()=>i(null),children:[a.jsx(R,{left:r.left,top:r.top,width:j,innerHeight:b,scaleMax:v,format:c}),t.map((h,m)=>{let y=r.top+b;const H=r.left+m*x+(x-_)/2;return a.jsxs("g",{className:n===m?"as-chart__col as-chart__col--on":"as-chart__col",onMouseEnter:()=>i(m),children:[a.jsx("rect",{x:r.left+m*x,y:r.top,width:x,height:b,fill:"transparent"}),e.map(w=>{const L=h[w.key]??0;if(L<=0)return null;const W=Math.max(L/v*b,1);return y-=W,a.jsx("rect",{x:H,y,width:_,height:W,fill:w.color,className:"as-chart__seg"},w.key)}),a.jsx("title",{children:`${s[m]}: ${c(g[m]??0)}`}),m%p===0&&a.jsx("text",{x:r.left+m*x+x/2,y:l-6,textAnchor:"middle",className:"as-chart__tick",children:s[m]})]},m)})]}),d&&d.sum>0&&a.jsxs("div",{className:"as-chart__tip",style:{left:B,top:0},children:[a.jsxs("div",{className:"as-chart__tip-head",children:[s[d.index]," · ",c(d.sum)]}),e.filter(h=>(d.column[h.key]??0)>0).map(h=>a.jsxs("div",{className:"as-chart__tip-row",children:[a.jsx("span",{className:"as-swatch",style:{background:h.color}}),a.jsx("span",{children:h.label}),a.jsx("span",{children:c(d.column[h.key]??0)})]},h.key))]})]}),e.length>0&&a.jsx("ul",{className:"as-legend","aria-label":"Legend",children:e.map(h=>a.jsxs("li",{className:"as-legend__item",children:[a.jsx("span",{className:"as-swatch",style:{background:h.color}}),a.jsx("span",{className:"as-legend__label",title:h.label,children:h.label}),a.jsx("strong",{children:c(h.total)})]},h.key))})]})}export{A as B,U as O,T as S,Y as a,I as b,z as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as n,B as i}from"./index-
|
|
1
|
+
import{j as n,B as i}from"./index-C21bvTBH.js";import{C as c}from"./en_US-Y4ZOVFV4-3vDquI1C.js";function u({label:e="Connect wallet",fullWidth:s=!0,size:r,variant:t}){return n.jsx(c.Custom,{children:({openConnectModal:a,mounted:l})=>n.jsx(i,{fullWidth:s,size:r,variant:t,disabled:!l,onClick:a,children:e})})}function h(){return n.jsx(c.Custom,{children:({account:e,chain:s,mounted:r,openAccountModal:t,openChainModal:a})=>!r||!e||!s?null:n.jsxs("div",{className:"gc-connected",children:[n.jsx("span",{className:"gc-connected__dot","aria-hidden":"true"}),n.jsxs("span",{children:["Connected ",n.jsx("code",{className:"gc-mono",children:e.displayName})]}),s.unsupported&&n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":"true",children:"·"}),n.jsx("span",{className:"gc-warn",children:"Wrong network"}),n.jsx(i,{variant:"link",size:"sm",onClick:a,children:"Switch network"})]}),n.jsx("span",{"aria-hidden":"true",children:"·"}),n.jsx(i,{variant:"link",size:"sm",onClick:t,children:"Change"})]})})}export{u as C,h as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as h,j as n,B as E}from"./index-
|
|
1
|
+
import{r as h,j as n,B as E}from"./index-C21bvTBH.js";import{r as D}from"./index-DqHGr8d4.js";function w(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[n.jsx("circle",{cx:"12",cy:"5",r:"1.7"}),n.jsx("circle",{cx:"12",cy:"12",r:"1.7"}),n.jsx("circle",{cx:"12",cy:"19",r:"1.7"})]})}const v=176;function M({label:t,items:i,trigger:b,className:g}){const d=i.filter(Boolean),[o,p]=h.useState(!1),[_,k]=h.useState({}),m=h.useRef(null),l=h.useRef(null),y=h.useId(),x=h.useCallback(e=>{var s;p(!1),e&&((s=m.current)==null||s.focus())},[]);if(h.useLayoutEffect(()=>{var u,c;if(!o||!m.current)return;const e=m.current.getBoundingClientRect(),s=d.length*34+10,f=e.bottom+4+s<=window.innerHeight,r=Math.max(8,Math.min(e.right-v,window.innerWidth-v-8));k(f?{top:e.bottom+4,left:r}:{top:Math.max(8,e.top-4-s),left:r}),(c=(u=l.current)==null?void 0:u.querySelector('[role="menuitem"]:not([disabled])'))==null||c.focus()},[o,d.length]),h.useEffect(()=>{if(!o)return;const e=f=>{var u,c;const r=f.target;(u=l.current)!=null&&u.contains(r)||(c=m.current)!=null&&c.contains(r)||x(!1)},s=()=>x(!1);return document.addEventListener("mousedown",e),window.addEventListener("resize",s),window.addEventListener("scroll",s,!0),()=>{document.removeEventListener("mousedown",e),window.removeEventListener("resize",s),window.removeEventListener("scroll",s,!0)}},[o,x]),d.length===0)return null;function a(e){var r,u,c,j,N;const s=[...((r=l.current)==null?void 0:r.querySelectorAll('[role="menuitem"]:not([disabled])'))??[]],f=s.indexOf(document.activeElement);e.key==="Escape"?(e.preventDefault(),e.stopPropagation(),x(!0)):e.key==="ArrowDown"?(e.preventDefault(),(u=s[(f+1)%s.length])==null||u.focus()):e.key==="ArrowUp"?(e.preventDefault(),(c=s[(f-1+s.length)%s.length])==null||c.focus()):e.key==="Home"?(e.preventDefault(),(j=s[0])==null||j.focus()):e.key==="End"?(e.preventDefault(),(N=s[s.length-1])==null||N.focus()):e.key==="Tab"&&x(!1)}return n.jsxs(n.Fragment,{children:[n.jsx("button",{ref:m,type:"button",className:["as-icon-button","as-action-menu__trigger",g].filter(Boolean).join(" "),"aria-label":t,title:t,"aria-haspopup":"menu","aria-expanded":o,"aria-controls":o?y:void 0,onClick:e=>{e.stopPropagation(),p(s=>!s)},onKeyDown:e=>{e.key==="ArrowDown"&&!o&&(e.preventDefault(),p(!0))},children:b??n.jsx(w,{})}),o&&typeof document<"u"&&D.createPortal(n.jsx("div",{ref:l,id:y,role:"menu","aria-label":t,className:"as-action-menu",style:{..._,width:v},onKeyDown:a,onClick:e=>e.stopPropagation(),children:d.map((e,s)=>n.jsx("button",{type:"button",role:"menuitem",tabIndex:-1,disabled:e.disabled,className:e.tone==="danger"?"as-action-menu__item as-action-menu__item--danger":"as-action-menu__item",onClick:()=>{x(!0),e.onSelect()},children:e.label},s))}),document.body)]})}function P(t){return[t.align==="right"?"as-num":null,t.secondary?"as-secondary":null,t.optional?"as-optional":null].filter(Boolean).join(" ")||void 0}function C(t,i){if((t==null?void 0:t.key)===i)return t.direction==="asc"?"ascending":"descending"}function S(t,i){return(t==null?void 0:t.key)!==i?"":t.direction==="asc"?"↑":"↓"}function I({rows:t,columns:i,rowKey:b,onRowClick:g,rowLabel:d,actions:o,empty:p,label:_,initialSort:k,selectedKey:m}){const[l,y]=h.useState(k??null),x=h.useMemo(()=>{if(!l)return t;const a=i.find(f=>f.key===l.key);if(!(a!=null&&a.sortValue))return t;const e=a.sortValue,s=l.direction==="asc"?1:-1;return[...t].sort((f,r)=>{const u=e(f),c=e(r);return u===c?0:u===null?1:c===null?-1:(u<c?-1:1)*s})},[t,i,l]);return t.length===0&&p?n.jsx(n.Fragment,{children:p}):n.jsx("div",{className:"as-table-wrap",children:n.jsxs("table",{className:"as-table","aria-label":_,children:[n.jsx("thead",{children:n.jsxs("tr",{children:[i.map(a=>{const e=(l==null?void 0:l.key)===a.key;return n.jsx("th",{className:P(a),style:a.width?{width:a.width}:void 0,"aria-sort":C(l,a.key),children:a.sortValue?n.jsxs("button",{type:"button",className:"as-table__sort",onClick:()=>y({key:a.key,direction:e&&l.direction==="desc"?"asc":"desc"}),children:[a.header,n.jsx("span",{"aria-hidden":"true",className:"as-table__arrow",children:S(l,a.key)})]}):a.header},a.key)}),o&&n.jsx("th",{className:"as-table__actions",children:n.jsx("span",{className:"as-sr",children:"Actions"})})]})}),n.jsx("tbody",{children:x.map(a=>{const e=b(a),s=m!=null&&e===m,f=[g?"as-table__row--click":null,s?"as-table__row--selected":null].filter(Boolean).join(" ");return n.jsxs("tr",{className:f||void 0,"aria-current":s?"true":void 0,onClick:g?()=>g(a):void 0,children:[i.map((r,u)=>n.jsx("td",{className:P(r),children:(()=>{const c=u===0&&g?n.jsx("button",{type:"button",className:"as-table__open","aria-label":d?`Open ${d(a)}`:void 0,onClick:j=>{j.stopPropagation(),g(a)},children:r.render(a)}):r.render(a);return r.after?n.jsxs("div",{className:"as-table__lead",children:[c,r.after(a)]}):c})()},r.key)),o&&n.jsx("td",{className:"as-table__actions",onClick:r=>r.stopPropagation(),children:n.jsx(M,{label:d?`Actions for ${d(a)}`:"Actions",items:o(a)})})]},e)})})]})})}function L(t,i,b=""){const[g,d]=h.useState(0);h.useEffect(()=>{d(0)},[b]);const o=Math.max(1,Math.ceil(t.length/i)),p=Math.min(g,o-1);return{items:t.slice(p*i,(p+1)*i),page:p,pages:o,total:t.length,setPage:d}}function H({pager:t,noun:i}){return t.pages<=1?null:n.jsxs("nav",{className:"as-pager","aria-label":`${i} pages`,children:[n.jsxs("span",{className:"as-pager__status",children:["Page ",t.page+1," of ",t.pages," · ",t.total," ",i]}),n.jsxs("div",{className:"as-pager__buttons",children:[n.jsx(E,{variant:"outline",size:"sm",disabled:t.page===0,onClick:()=>t.setPage(t.page-1),children:"Previous"}),n.jsx(E,{variant:"outline",size:"sm",disabled:t.page>=t.pages-1,onClick:()=>t.setPage(t.page+1),children:"Next"})]})]})}export{I as D,H as P,L as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./index-
|
|
1
|
+
import{j as s}from"./index-C21bvTBH.js";function n({title:i,summary:e,children:o,defaultOpen:r,className:a}){return s.jsxs("details",{className:["as-disclosure",a].filter(Boolean).join(" "),open:r,children:[s.jsxs("summary",{className:"as-disclosure__summary",children:[s.jsx("span",{className:"as-disclosure__title",children:i}),e!=null&&e!==""&&s.jsx("span",{className:"as-disclosure__meta",children:e}),s.jsx("svg",{className:"as-disclosure__chevron",width:"12",height:"12",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:s.jsx("path",{d:"M4 6l4 4 4-4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})]}),s.jsx("div",{className:"as-disclosure__body",children:o})]})}export{n as D};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a1 as v,a2 as N,d as g,q as k,j as e,a3 as q,a4 as x,a5 as w,B as R,I as S,P as B,t as y,a6 as E,S as P,a7 as _,f as n,k as d,Q as I,V as A,g as D,a8 as K,a9 as L,z as O,l as c,e as j,aa as T}from"./index-
|
|
1
|
+
import{a1 as v,a2 as N,d as g,q as k,j as e,a3 as q,a4 as x,a5 as w,B as R,I as S,P as B,t as y,a6 as E,S as P,a7 as _,f as n,k as d,Q as I,V as A,g as D,a8 as K,a9 as L,z as O,l as c,e as j,aa as T}from"./index-C21bvTBH.js";import{R as F}from"./RequestLog-CBZWWnHo.js";import{r as z,e as M}from"./usage-MPZYg7D2.js";import{B as Q}from"./Charts-NmIMcccv.js";import"./useInfiniteQuery-Bpu8bc5A.js";import"./DataTable-D2QIQ-gI.js";import"./index-DqHGr8d4.js";function W(){var m;const h=v(),u=N(),s=((m=u.data)==null?void 0:m.kind)==="key"?u.data.me.key:null,l=Date.now(),o=z("30d",l),f=g({queryKey:k.usage({key:s==null?void 0:s.id,from:o,groupBy:"day"}),queryFn:()=>j.usage.report({key:s.id,from:o,to:l,groupBy:"day"}),enabled:!!s}),b=g({queryKey:["key-periods",s==null?void 0:s.id],enabled:!!s,queryFn:async()=>{const a=await Promise.all(["daily","weekly","monthly"].map(async i=>{const t=await j.usage.report({key:s.id,from:T(i,l)});return[i,c(t.totals.spent)]}));return Object.fromEntries([...a,["total",c(s.usage.spent)]])}});return e.jsxs("div",{className:"gc-keyholder",children:[e.jsxs("header",{className:"gc-topbar",children:[e.jsxs("div",{className:"gc-topbar__inner",children:[e.jsx(q,{to:null,tagged:!0}),e.jsx("div",{className:"gc-topbar__spacer"}),e.jsx(x,{className:"gc-endpoint--inline"}),e.jsx(w,{}),e.jsx(R,{variant:"outline",size:"sm",leadingIcon:e.jsx(S.logout,{size:14}),onClick:()=>void h(),children:"Sign out"})]}),e.jsx("div",{className:"gc-topbar__strip",children:e.jsx(x,{})})]}),e.jsx("main",{className:"gc-main",id:"gc-main",children:s&&e.jsxs("div",{className:"gc-page",children:[e.jsx(B,{title:s.label,description:e.jsxs(e.Fragment,{children:["Key ",e.jsx("code",{children:s.hint})," · ",s.status==="active"?e.jsx(y,{tone:"success",children:"Active"}):e.jsx(y,{tone:"danger",children:"Revoked"})]})}),e.jsx("div",{className:"gc-grid gc-grid--4",children:E.map(a=>{var p;const i=s.limits[a],t=((p=b.data)==null?void 0:p[a])??null,r=i===null?null:c(i);return e.jsx(P,{label:`${_[a]} spend`,value:t===null?"…":n(t),sub:r===null?"No limit":`${n(Math.max(r-(t??0),0))} left of ${n(r)}`,meter:r&&t!==null?t/r:null},a)})}),e.jsx(d,{title:"Spend, last 30 days",children:e.jsx(I,{query:f,rows:1,children:a=>e.jsx(Q,{format:n,label:"Daily spend",points:M(a,o,l)})})}),e.jsx(d,{title:"Key details",children:e.jsx(A,{items:[["Requests",D(s.usage.requests)],["Spent in total",n(s.usage.spent)],["Last used",K(s.lastUsedAt)],["Expires",s.expiresAt?L(s.expiresAt):"Never"],["Top-ups",s.topupEnabled?"Allowed":"Off"],["Routing",O(s.routingPolicy)]]})}),e.jsx(d,{flush:!0,title:"Requests",children:e.jsx(F,{filter:{key:s.id},showKey:!1})})]})})]})}export{W as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ad as ke,r as m,aD as je,aE as fe,j as s,A as ne,aF as ve,W as Se,B as S,u as le,a as Ce,i as ce,c as de,b as Pe,s as ie,P as Le,I as K,T as F,k as Ne,Q as Ae,aG as Ee,y as ue,aH as J,z as me,f as ye,l as Te,a8 as Re,E as Z,aI as pe,C as De,q as U,e as C,t as v,a9 as X,d as Ie,aJ as Me,aK as Ke,aL as Fe,aM as ee,n as Ue,V as _e}from"./index-BC-1LZkB.js";import{u as se,a as Oe,P as Be}from"./PolicyField-B7_URv8N.js";import{T as Ye}from"./Tabs-dykHKE0J.js";import{l as te,d as ae,L as We}from"./limits-DONLLmCg.js";import{t as qe}from"./dates-Pi3-Ywng.js";import{r as ze,e as $e}from"./usage-kR1h5urb.js";import{S as he}from"./Switch-GA0Kao4V.js";import{D as Ve,u as He,P as Ge}from"./DataTable-Cizb1YVv.js";import{b as Qe}from"./Charts-ogViQ7jC.js";import{S as Je}from"./SelectField-BCIB_aud.js";import"./PolicyEditor-CxJuR6mU.js";import"./Segmented-DfgcyK0R.js";import"./roving-DkptacxO.js";import"./Disclosure-Ygp-7rwy.js";import"./index-DX_0N6eB.js";function Ze({result:e,onClose:l}){var r;const o=ke(),[c,y]=m.useState("curl"),d=je((r=o.data)==null?void 0:r.publicUrl,window.location.origin),i=e?fe(d,e.secret):[],a=i.find(h=>h.id===c);return s.jsx(ne,{isOpen:e!==null,onClose:l,size:"lg",eyebrow:"API key",title:e?`${e.key.label} is ready`:"",children:e&&s.jsxs("div",{className:"gc-stack",children:[s.jsx(ve,{secret:e.secret}),s.jsxs("div",{children:[s.jsx("div",{className:"as-field__label",children:"Use it"}),s.jsxs("p",{className:"gc-muted",children:["Base URL ",s.jsxs("code",{children:[d,"/v1"]}),". Replace ",s.jsx("code",{children:"<model>"})," with a model from the Models page."]})]}),s.jsx(Ye,{value:c,onChange:y,tabs:i.map(h=>({id:h.id,label:h.label}))}),a&&s.jsx(Se,{code:a.code}),s.jsx("div",{className:"gc-actions",children:s.jsx(S,{onClick:l,children:"Done"})})]})})}const Xe="30d";function es({keyId:e}){const[l]=m.useState(()=>Date.now()),o=ze(Xe,l),c=Ie({queryKey:U.usage({key:e,from:o,groupBy:"day",spark:!0}),queryFn:()=>C.usage.report({key:e,from:o,to:l,groupBy:"day"}),staleTime:6e4});return c.data?s.jsx(Qe,{label:"Daily spend, last 30 days",format:ye,per:"a day",emptyText:"no spend",values:$e(c.data,o,l).map(y=>y.value)}):s.jsx("span",{className:"as-spark as-spark--empty","aria-hidden":"true"})}function ss(e){return e.status==="revoked"?s.jsx(v,{tone:"danger",children:"Revoked"}):e.expiresAt&&e.expiresAt<Date.now()?s.jsx(v,{tone:"warning",children:"Expired"}):e.expiresAt?s.jsxs(v,{tone:"neutral",title:`Expires ${X(e.expiresAt)}`,children:["Until ",X(e.expiresAt)]}):s.jsx(v,{tone:"success",children:"Active"})}function re({title:e,note:l,limits:o,policy:c}){return s.jsxs("div",{className:"gc-layer gc-layer--readonly",children:[s.jsxs("div",{className:"gc-inline gc-inline--between",children:[s.jsx("div",{className:"as-field__label",children:e}),s.jsx(v,{children:"Read only"})]}),s.jsx(_e,{items:[["Spend limits",ue(o??null)],["Routing",me(c??null)]]}),s.jsx("p",{className:"gc-fineprint",children:l})]})}function oe({title:e,idPrefix:l,limits:o,onLimitsChange:c,limitsNote:y,policy:d}){return s.jsxs("div",{className:"gc-layer",children:[e&&s.jsx("div",{className:"as-field__label",children:e}),s.jsxs("div",{children:[s.jsx("div",{className:"as-field__label gc-label-row",children:"Spend limits (USD)"}),s.jsx(We,{idPrefix:l,value:o,onChange:c}),s.jsx("p",{className:"gc-fineprint",children:y})]}),s.jsx(Be,{draft:d.draft,setDraft:d.setDraft})]})}function ts({initial:e,layeredHint:l,onSaved:o,onCancel:c}){var z;const{workspace:y,viewer:d,me:i}=le(),a=ce(d),r=pe(e)?e:null,[h,k]=m.useState((e==null?void 0:e.label)??""),[b,P]=m.useState(te(e==null?void 0:e.limits)),[L,N]=m.useState(te(r?r.ownerLimits:e==null?void 0:e.limits)),[j,A]=m.useState(qe((e==null?void 0:e.expiresAt)??null)),[x,E]=m.useState((e==null?void 0:e.topupEnabled)??!1),[n,g]=m.useState((e==null?void 0:e.ownerMemberId)??i.member.id),w=se(e==null?void 0:e.routingPolicy),t=se(r?r.ownerRoutingPolicy:e==null?void 0:e.routingPolicy),p=Me(e,{memberId:i.member.id,workspaceAdmin:a},l),ge=Ke(y.id,a),_=((e==null?void 0:e.buyerIdentity)??((z=ge.data)==null?void 0:z.buyerIdentity))==="default",O=de(y.id,a&&!e),R=Oe(),[B,Y]=m.useState(null),D=p.admin,W=e?p.owner&&(p.layered||!p.admin):!p.admin,T=e!==null&&p.layered;let q=null;T&&(q=p.admin?"Your restrictions as the key owner":"Your restrictions");const xe=e?"Save":"Create key",be=p.layered||!e?"UTC periods; weeks start Monday. Workspace, member and admin limits apply too.":"You can only tighten your key: a higher or cleared limit is ignored.",I=ie({mutationFn:async()=>{const u=j?Date.parse(`${j}T23:59:59Z`):null,$=D?w.build():null,V=W?t.build():null,H=ae(b),G=ae(L);if(e){const f=Fe(p,e,{label:h.trim(),expiresAt:u,topupEnabled:x,adminLimits:H,adminPolicy:$,ownerLimits:G,ownerPolicy:V}),Q=await R.save([f.routingPolicy,f.ownerRoutingPolicy],we=>C.keys.update(e.id,f,we));return Q===ee?ee:{key:Q}}const M={label:h.trim(),workspaceId:y.id,limits:p.admin?H:G,routingPolicy:p.admin?$:V,topupEnabled:p.admin?x:!1,expiresAt:u};return p.admin&&(M.ownerMemberId=n||null),R.save([M.routingPolicy],f=>C.keys.create(M,f))},onSuccess:o,invalidate:[U.group("keys")],toast:u=>u.secret?null:"Key saved",onError:Y});return s.jsxs("form",{className:"gc-stack",onSubmit:u=>{u.preventDefault(),Y(null),I.mutate()},children:[s.jsx(F,{label:"Name",required:!0,placeholder:"e.g. Production backend",value:h,onChange:u=>k(u.target.value)}),!e&&a&&O.data&&s.jsx(Je,{label:"Owner",value:n,onChange:g,options:O.data.map(({member:u})=>({value:u.id,label:u.id===i.member.id?`${u.label} (you)`:u.label}))}),D&&s.jsx(oe,{title:T?"Workspace admin restrictions":null,idPrefix:"key-limit",limits:b,onLimitsChange:P,limitsNote:"UTC periods; weeks start Monday. The workspace and member budgets apply too.",policy:w}),!D&&T&&s.jsx(re,{title:"Set by workspace admins",limits:e.limits,policy:e.routingPolicy,note:"These always apply to this key. Your own restrictions below can only add to them."}),W&&s.jsx(oe,{title:q,idPrefix:"key-owner-limit",limits:L,onLimitsChange:N,limitsNote:be,policy:t}),T&&!p.owner&&s.jsx(re,{title:"Set by the key owner",limits:r==null?void 0:r.ownerLimits,policy:r==null?void 0:r.ownerRoutingPolicy,note:"Only the key's owner changes these. They apply on top of yours."}),s.jsx(F,{label:"Expires",type:"date",value:j,onChange:u=>A(u.target.value),hint:a?"Leave blank for no expiry.":"You can set or bring forward an expiry; only an admin can extend or remove it."}),a&&s.jsx(he,{checked:x,onChange:E,disabled:_&&!x,label:"Allow top-ups",description:_?"Keys paid from the default wallet cannot be topped up.":"Let the key holder add funds to this key with USDC (x402)."}),B?s.jsx(Ue,{error:B,title:"Could not save the key"}):null,s.jsxs("div",{className:"gc-actions",children:[s.jsx(S,{variant:"ghost",onClick:c,children:"Cancel"}),s.jsx(S,{type:"submit",disabled:I.isPending||!h.trim(),children:I.isPending?"Saving…":xe})]}),R.dialog]})}const as=25;function rs({list:e,search:l,showRevoked:o,ownerLabel:c,render:y}){const d=l.trim().toLowerCase(),i=m.useMemo(()=>e.filter(r=>(o||r.status==="active")&&(!d||r.label.toLowerCase().includes(d)||r.hint.toLowerCase().includes(d)||c(r).toLowerCase().includes(d))),[e,o,d,c]),a=He(i,as,`${d}|${o}`);return s.jsxs(s.Fragment,{children:[y(a.items,i.length===0&&e.length>0),s.jsx(Ge,{pager:a,noun:"keys"})]})}function os(e){return(e==null?void 0:e.kind)==="rotate"?{title:"Rotate this key?",confirmLabel:"Rotate key",tone:"primary",body:s.jsxs(s.Fragment,{children:["The current secret for ",s.jsx("strong",{children:e.key.label})," stops working now. You get a new secret to replace it."]})}:{title:"Revoke this key?",confirmLabel:"Revoke key",tone:"danger",body:s.jsxs(s.Fragment,{children:["Requests with ",s.jsx("strong",{children:e==null?void 0:e.key.label})," fail from now on. This cannot be undone."]})}}function js(){const{workspace:e,me:l,viewer:o}=le(),c=Ce(),y=ce(o),d=de(e.id,y),[i,a]=m.useState(()=>new URLSearchParams(window.location.search).get("new")==="1"?"new":null),[r,h]=m.useState(null),[k,b]=m.useState(null),[P,L]=m.useState(!1),[N,j]=m.useState(""),A=Pe(c),x=ie({mutationFn:async({kind:n,key:g})=>{n==="rotate"?h(await C.keys.rotate(g.id)):await C.keys.revoke(g.id)},onSuccess:()=>b(null),invalidate:[U.group("keys")],toast:(n,{kind:g})=>g==="revoke"?"Key revoked":null}),E=n=>{var g,w;return n.ownerMemberId?n.ownerMemberId===l.member.id?"You":((w=(g=d.data)==null?void 0:g.find(({member:t})=>t.id===n.ownerMemberId))==null?void 0:w.member.label)??"Another member":"—"};return s.jsxs("div",{className:"gc-page",children:[s.jsx(Le,{title:"API keys",description:`Keys for the ${e.name} workspace. Each key spends from this workspace's wallet.`,actions:s.jsx(S,{variant:"brand",leadingIcon:s.jsx(K.plus,{size:14}),onClick:()=>a("new"),children:"Create key"})}),s.jsxs("div",{className:"gc-toolbar",children:[s.jsx(F,{size:"sm",type:"search","aria-label":"Search keys",placeholder:"Search name, hint or owner",value:N,onChange:n=>j(n.target.value)}),s.jsx(he,{checked:P,onChange:L,label:"Show revoked"})]}),s.jsx(Ne,{flush:!0,children:s.jsx(Ae,{query:A,children:n=>s.jsx(rs,{list:n,search:N,showRevoked:P,ownerLabel:E,render:(g,w)=>s.jsx(Ve,{label:"API keys",rows:g,rowKey:t=>t.id,rowLabel:t=>t.label,onRowClick:t=>t.status==="active"&&a(t),actions:t=>t.status==="active"?[{label:"Edit",onSelect:()=>a(t)},{label:"Rotate secret",onSelect:()=>b({kind:"rotate",key:t})},{label:"Revoke",tone:"danger",onSelect:()=>b({kind:"revoke",key:t})}]:[],empty:w?s.jsx(Z,{icon:s.jsx(K.keys,{size:18}),title:"No keys match",body:"Try another search, or show revoked keys."}):s.jsx(Z,{icon:s.jsx(K.keys,{size:18}),title:"No keys yet",body:"Create a key to call models through this gateway.",action:s.jsx(S,{onClick:()=>a("new"),children:"Create key"})}),columns:[{key:"label",header:"Name",sortValue:t=>t.label,render:t=>s.jsx(Ee,{name:t.label,hint:t.hint})},{key:"owner",header:"Owner",secondary:!0,render:E},{key:"limits",header:"Limits",secondary:!0,optional:!0,render:t=>s.jsx("span",{className:"gc-muted",children:ue(J(t).limits)})},{key:"policy",header:"Routing",secondary:!0,optional:!0,render:t=>s.jsx("span",{className:"gc-muted",children:me(J(t).policy)})},...y?[{key:"trend",header:"30 days",secondary:!0,render:t=>s.jsx(es,{keyId:t.id})}]:[],{key:"month",header:"This month",align:"right",sortValue:t=>Te(t.usage.spentThisMonth),render:t=>ye(t.usage.spentThisMonth)},{key:"used",header:"Last used",secondary:!0,optional:!0,sortValue:t=>t.lastUsedAt,render:t=>Re(t.lastUsedAt)},{key:"status",header:"Status",secondary:!0,render:ss}]})})})}),s.jsx(ne,{isOpen:i!==null,onClose:()=>a(null),size:"lg",title:i==="new"?"Create API key":"Edit API key",children:i!==null&&s.jsx(ts,{initial:i==="new"?null:i,layeredHint:(A.data??[]).some(pe),onCancel:()=>a(null),onSaved:n=>{a(null),n.secret&&h({key:n.key,secret:n.secret})}})}),s.jsx(Ze,{result:r,onClose:()=>h(null)}),s.jsx(De,{isOpen:k!==null,busy:x.isPending,error:x.error,onClose:()=>{b(null),x.reset()},onConfirm:()=>k&&x.mutate(k),...os(k)})]})}export{js as default};
|
|
1
|
+
import{ad as ke,r as m,aD as je,aE as fe,j as s,A as ne,aF as ve,W as Se,B as S,u as le,a as Ce,i as ce,c as de,b as Pe,s as ie,P as Le,I as K,T as F,k as Ne,Q as Ae,aG as Ee,y as ue,aH as J,z as me,f as ye,l as Te,a8 as Re,E as Z,aI as pe,C as De,q as U,e as C,t as v,a9 as X,d as Ie,aJ as Me,aK as Ke,aL as Fe,aM as ee,n as Ue,V as _e}from"./index-C21bvTBH.js";import{u as se,a as Oe,P as Be}from"./PolicyField-0xAOIP4-.js";import{T as Ye}from"./Tabs-CGI9v1OW.js";import{l as te,d as ae,L as We}from"./limits-D_C7APR_.js";import{t as qe}from"./dates-Pi3-Ywng.js";import{r as ze,e as $e}from"./usage-MPZYg7D2.js";import{S as he}from"./Switch-JCyfy3G5.js";import{D as Ve,u as He,P as Ge}from"./DataTable-D2QIQ-gI.js";import{b as Qe}from"./Charts-NmIMcccv.js";import{S as Je}from"./SelectField-D_BPTzpT.js";import"./PolicyEditor-CRhTwGq0.js";import"./Segmented-BJmgB5-Y.js";import"./roving-DkptacxO.js";import"./Disclosure-h1MJg5Wn.js";import"./index-DqHGr8d4.js";function Ze({result:e,onClose:l}){var r;const o=ke(),[c,y]=m.useState("curl"),d=je((r=o.data)==null?void 0:r.publicUrl,window.location.origin),i=e?fe(d,e.secret):[],a=i.find(h=>h.id===c);return s.jsx(ne,{isOpen:e!==null,onClose:l,size:"lg",eyebrow:"API key",title:e?`${e.key.label} is ready`:"",children:e&&s.jsxs("div",{className:"gc-stack",children:[s.jsx(ve,{secret:e.secret}),s.jsxs("div",{children:[s.jsx("div",{className:"as-field__label",children:"Use it"}),s.jsxs("p",{className:"gc-muted",children:["Base URL ",s.jsxs("code",{children:[d,"/v1"]}),". Replace ",s.jsx("code",{children:"<model>"})," with a model from the Models page."]})]}),s.jsx(Ye,{value:c,onChange:y,tabs:i.map(h=>({id:h.id,label:h.label}))}),a&&s.jsx(Se,{code:a.code}),s.jsx("div",{className:"gc-actions",children:s.jsx(S,{onClick:l,children:"Done"})})]})})}const Xe="30d";function es({keyId:e}){const[l]=m.useState(()=>Date.now()),o=ze(Xe,l),c=Ie({queryKey:U.usage({key:e,from:o,groupBy:"day",spark:!0}),queryFn:()=>C.usage.report({key:e,from:o,to:l,groupBy:"day"}),staleTime:6e4});return c.data?s.jsx(Qe,{label:"Daily spend, last 30 days",format:ye,per:"a day",emptyText:"no spend",values:$e(c.data,o,l).map(y=>y.value)}):s.jsx("span",{className:"as-spark as-spark--empty","aria-hidden":"true"})}function ss(e){return e.status==="revoked"?s.jsx(v,{tone:"danger",children:"Revoked"}):e.expiresAt&&e.expiresAt<Date.now()?s.jsx(v,{tone:"warning",children:"Expired"}):e.expiresAt?s.jsxs(v,{tone:"neutral",title:`Expires ${X(e.expiresAt)}`,children:["Until ",X(e.expiresAt)]}):s.jsx(v,{tone:"success",children:"Active"})}function re({title:e,note:l,limits:o,policy:c}){return s.jsxs("div",{className:"gc-layer gc-layer--readonly",children:[s.jsxs("div",{className:"gc-inline gc-inline--between",children:[s.jsx("div",{className:"as-field__label",children:e}),s.jsx(v,{children:"Read only"})]}),s.jsx(_e,{items:[["Spend limits",ue(o??null)],["Routing",me(c??null)]]}),s.jsx("p",{className:"gc-fineprint",children:l})]})}function oe({title:e,idPrefix:l,limits:o,onLimitsChange:c,limitsNote:y,policy:d}){return s.jsxs("div",{className:"gc-layer",children:[e&&s.jsx("div",{className:"as-field__label",children:e}),s.jsxs("div",{children:[s.jsx("div",{className:"as-field__label gc-label-row",children:"Spend limits (USD)"}),s.jsx(We,{idPrefix:l,value:o,onChange:c}),s.jsx("p",{className:"gc-fineprint",children:y})]}),s.jsx(Be,{draft:d.draft,setDraft:d.setDraft})]})}function ts({initial:e,layeredHint:l,onSaved:o,onCancel:c}){var z;const{workspace:y,viewer:d,me:i}=le(),a=ce(d),r=pe(e)?e:null,[h,k]=m.useState((e==null?void 0:e.label)??""),[b,P]=m.useState(te(e==null?void 0:e.limits)),[L,N]=m.useState(te(r?r.ownerLimits:e==null?void 0:e.limits)),[j,A]=m.useState(qe((e==null?void 0:e.expiresAt)??null)),[x,E]=m.useState((e==null?void 0:e.topupEnabled)??!1),[n,g]=m.useState((e==null?void 0:e.ownerMemberId)??i.member.id),w=se(e==null?void 0:e.routingPolicy),t=se(r?r.ownerRoutingPolicy:e==null?void 0:e.routingPolicy),p=Me(e,{memberId:i.member.id,workspaceAdmin:a},l),ge=Ke(y.id,a),_=((e==null?void 0:e.buyerIdentity)??((z=ge.data)==null?void 0:z.buyerIdentity))==="default",O=de(y.id,a&&!e),R=Oe(),[B,Y]=m.useState(null),D=p.admin,W=e?p.owner&&(p.layered||!p.admin):!p.admin,T=e!==null&&p.layered;let q=null;T&&(q=p.admin?"Your restrictions as the key owner":"Your restrictions");const xe=e?"Save":"Create key",be=p.layered||!e?"UTC periods; weeks start Monday. Workspace, member and admin limits apply too.":"You can only tighten your key: a higher or cleared limit is ignored.",I=ie({mutationFn:async()=>{const u=j?Date.parse(`${j}T23:59:59Z`):null,$=D?w.build():null,V=W?t.build():null,H=ae(b),G=ae(L);if(e){const f=Fe(p,e,{label:h.trim(),expiresAt:u,topupEnabled:x,adminLimits:H,adminPolicy:$,ownerLimits:G,ownerPolicy:V}),Q=await R.save([f.routingPolicy,f.ownerRoutingPolicy],we=>C.keys.update(e.id,f,we));return Q===ee?ee:{key:Q}}const M={label:h.trim(),workspaceId:y.id,limits:p.admin?H:G,routingPolicy:p.admin?$:V,topupEnabled:p.admin?x:!1,expiresAt:u};return p.admin&&(M.ownerMemberId=n||null),R.save([M.routingPolicy],f=>C.keys.create(M,f))},onSuccess:o,invalidate:[U.group("keys")],toast:u=>u.secret?null:"Key saved",onError:Y});return s.jsxs("form",{className:"gc-stack",onSubmit:u=>{u.preventDefault(),Y(null),I.mutate()},children:[s.jsx(F,{label:"Name",required:!0,placeholder:"e.g. Production backend",value:h,onChange:u=>k(u.target.value)}),!e&&a&&O.data&&s.jsx(Je,{label:"Owner",value:n,onChange:g,options:O.data.map(({member:u})=>({value:u.id,label:u.id===i.member.id?`${u.label} (you)`:u.label}))}),D&&s.jsx(oe,{title:T?"Workspace admin restrictions":null,idPrefix:"key-limit",limits:b,onLimitsChange:P,limitsNote:"UTC periods; weeks start Monday. The workspace and member budgets apply too.",policy:w}),!D&&T&&s.jsx(re,{title:"Set by workspace admins",limits:e.limits,policy:e.routingPolicy,note:"These always apply to this key. Your own restrictions below can only add to them."}),W&&s.jsx(oe,{title:q,idPrefix:"key-owner-limit",limits:L,onLimitsChange:N,limitsNote:be,policy:t}),T&&!p.owner&&s.jsx(re,{title:"Set by the key owner",limits:r==null?void 0:r.ownerLimits,policy:r==null?void 0:r.ownerRoutingPolicy,note:"Only the key's owner changes these. They apply on top of yours."}),s.jsx(F,{label:"Expires",type:"date",value:j,onChange:u=>A(u.target.value),hint:a?"Leave blank for no expiry.":"You can set or bring forward an expiry; only an admin can extend or remove it."}),a&&s.jsx(he,{checked:x,onChange:E,disabled:_&&!x,label:"Allow top-ups",description:_?"Keys paid from the default wallet cannot be topped up.":"Let the key holder add funds to this key with USDC (x402)."}),B?s.jsx(Ue,{error:B,title:"Could not save the key"}):null,s.jsxs("div",{className:"gc-actions",children:[s.jsx(S,{variant:"ghost",onClick:c,children:"Cancel"}),s.jsx(S,{type:"submit",disabled:I.isPending||!h.trim(),children:I.isPending?"Saving…":xe})]}),R.dialog]})}const as=25;function rs({list:e,search:l,showRevoked:o,ownerLabel:c,render:y}){const d=l.trim().toLowerCase(),i=m.useMemo(()=>e.filter(r=>(o||r.status==="active")&&(!d||r.label.toLowerCase().includes(d)||r.hint.toLowerCase().includes(d)||c(r).toLowerCase().includes(d))),[e,o,d,c]),a=He(i,as,`${d}|${o}`);return s.jsxs(s.Fragment,{children:[y(a.items,i.length===0&&e.length>0),s.jsx(Ge,{pager:a,noun:"keys"})]})}function os(e){return(e==null?void 0:e.kind)==="rotate"?{title:"Rotate this key?",confirmLabel:"Rotate key",tone:"primary",body:s.jsxs(s.Fragment,{children:["The current secret for ",s.jsx("strong",{children:e.key.label})," stops working now. You get a new secret to replace it."]})}:{title:"Revoke this key?",confirmLabel:"Revoke key",tone:"danger",body:s.jsxs(s.Fragment,{children:["Requests with ",s.jsx("strong",{children:e==null?void 0:e.key.label})," fail from now on. This cannot be undone."]})}}function js(){const{workspace:e,me:l,viewer:o}=le(),c=Ce(),y=ce(o),d=de(e.id,y),[i,a]=m.useState(()=>new URLSearchParams(window.location.search).get("new")==="1"?"new":null),[r,h]=m.useState(null),[k,b]=m.useState(null),[P,L]=m.useState(!1),[N,j]=m.useState(""),A=Pe(c),x=ie({mutationFn:async({kind:n,key:g})=>{n==="rotate"?h(await C.keys.rotate(g.id)):await C.keys.revoke(g.id)},onSuccess:()=>b(null),invalidate:[U.group("keys")],toast:(n,{kind:g})=>g==="revoke"?"Key revoked":null}),E=n=>{var g,w;return n.ownerMemberId?n.ownerMemberId===l.member.id?"You":((w=(g=d.data)==null?void 0:g.find(({member:t})=>t.id===n.ownerMemberId))==null?void 0:w.member.label)??"Another member":"—"};return s.jsxs("div",{className:"gc-page",children:[s.jsx(Le,{title:"API keys",description:`Keys for the ${e.name} workspace. Each key spends from this workspace's wallet.`,actions:s.jsx(S,{variant:"brand",leadingIcon:s.jsx(K.plus,{size:14}),onClick:()=>a("new"),children:"Create key"})}),s.jsxs("div",{className:"gc-toolbar",children:[s.jsx(F,{size:"sm",type:"search","aria-label":"Search keys",placeholder:"Search name, hint or owner",value:N,onChange:n=>j(n.target.value)}),s.jsx(he,{checked:P,onChange:L,label:"Show revoked"})]}),s.jsx(Ne,{flush:!0,children:s.jsx(Ae,{query:A,children:n=>s.jsx(rs,{list:n,search:N,showRevoked:P,ownerLabel:E,render:(g,w)=>s.jsx(Ve,{label:"API keys",rows:g,rowKey:t=>t.id,rowLabel:t=>t.label,onRowClick:t=>t.status==="active"&&a(t),actions:t=>t.status==="active"?[{label:"Edit",onSelect:()=>a(t)},{label:"Rotate secret",onSelect:()=>b({kind:"rotate",key:t})},{label:"Revoke",tone:"danger",onSelect:()=>b({kind:"revoke",key:t})}]:[],empty:w?s.jsx(Z,{icon:s.jsx(K.keys,{size:18}),title:"No keys match",body:"Try another search, or show revoked keys."}):s.jsx(Z,{icon:s.jsx(K.keys,{size:18}),title:"No keys yet",body:"Create a key to call models through this gateway.",action:s.jsx(S,{onClick:()=>a("new"),children:"Create key"})}),columns:[{key:"label",header:"Name",sortValue:t=>t.label,render:t=>s.jsx(Ee,{name:t.label,hint:t.hint})},{key:"owner",header:"Owner",secondary:!0,render:E},{key:"limits",header:"Limits",secondary:!0,optional:!0,render:t=>s.jsx("span",{className:"gc-muted",children:ue(J(t).limits)})},{key:"policy",header:"Routing",secondary:!0,optional:!0,render:t=>s.jsx("span",{className:"gc-muted",children:me(J(t).policy)})},...y?[{key:"trend",header:"30 days",secondary:!0,render:t=>s.jsx(es,{keyId:t.id})}]:[],{key:"month",header:"This month",align:"right",sortValue:t=>Te(t.usage.spentThisMonth),render:t=>ye(t.usage.spentThisMonth)},{key:"used",header:"Last used",secondary:!0,optional:!0,sortValue:t=>t.lastUsedAt,render:t=>Re(t.lastUsedAt)},{key:"status",header:"Status",secondary:!0,render:ss}]})})})}),s.jsx(ne,{isOpen:i!==null,onClose:()=>a(null),size:"lg",title:i==="new"?"Create API key":"Edit API key",children:i!==null&&s.jsx(ts,{initial:i==="new"?null:i,layeredHint:(A.data??[]).some(pe),onCancel:()=>a(null),onSaved:n=>{a(null),n.secret&&h({key:n.key,secret:n.secret})}})}),s.jsx(Ze,{result:r,onClose:()=>h(null)}),s.jsx(De,{isOpen:k!==null,busy:x.isPending,error:x.error,onClose:()=>{b(null),x.reset()},onConfirm:()=>k&&x.mutate(k),...os(k)})]})}export{js as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,a as D,b as E,j as e,P as I,B as y,I as U,e as q,T as p,k as M}from"./index-
|
|
1
|
+
import{r as s,a as D,b as E,j as e,P as I,B as y,I as U,e as q,T as p,k as M}from"./index-C21bvTBH.js";import{R as B}from"./RequestLog-CBZWWnHo.js";import{f as C}from"./dates-Pi3-Ywng.js";import{S as T}from"./SelectField-D_BPTzpT.js";import"./useInfiniteQuery-Bpu8bc5A.js";import"./usage-MPZYg7D2.js";import"./DataTable-D2QIQ-gI.js";import"./index-DqHGr8d4.js";function k(a,o=300){const[l,r]=s.useState(a);return s.useEffect(()=>{const i=window.setTimeout(()=>r(a),o);return()=>window.clearTimeout(i)},[a,o]),l}function V(){const a=D(),[o,l]=s.useState(""),[r,i]=s.useState(""),[n,b]=s.useState(""),[v,h]=s.useState(""),[c,g]=s.useState(""),[d,x]=s.useState(""),F=E(a),f=k(r.trim()),S=k(v.trim()),u=C(c,"start"),m=C(d,"end"),w=u!==void 0&&m!==void 0&&u>m,j=s.useMemo(()=>({...a,key:o||void 0,model:f||void 0,status:n||void 0,q:S||void 0,from:u,to:m}),[a.workspace,a.member,o,f,n,S,u,m]),z=!!(o||r||n||v||c||d);return e.jsxs("div",{className:"gc-page",children:[e.jsx(I,{title:"Logs",description:"Every request through this workspace's keys.",actions:e.jsx(y,{variant:"outline",size:"sm",href:q.usage.exportUrl(j),download:!0,leadingIcon:e.jsx(U.download,{size:14}),children:"Export CSV"})}),e.jsxs("div",{className:"gc-toolbar",children:[e.jsx(p,{size:"sm",type:"search","aria-label":"Search requests",placeholder:"Search model, key, end user or error",value:v,onChange:t=>h(t.target.value),className:"gc-toolbar__grow"}),e.jsx(T,{size:"sm","aria-label":"Filter by key",value:o,onChange:l,options:[{value:"",label:"All keys"},...(F.data??[]).map(t=>({value:t.id,label:t.label}))]}),e.jsx(p,{size:"sm","aria-label":"Filter by model",placeholder:"Model",value:r,onChange:t=>i(t.target.value)}),e.jsx(T,{size:"sm","aria-label":"Filter by status",value:n,onChange:b,options:[{value:"",label:"Any status"},{value:"success",label:"Succeeded"},{value:"error",label:"Failed"}]}),e.jsx(p,{size:"sm",type:"date","aria-label":"From date (UTC)",title:"From (UTC)",value:c,max:d||void 0,onChange:t=>g(t.target.value)}),e.jsx(p,{size:"sm",type:"date","aria-label":"To date (UTC)",title:"To (UTC)",value:d,min:c||void 0,onChange:t=>x(t.target.value),error:w?"Ends before it starts":void 0}),z&&e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>{l(""),i(""),b(""),h(""),g(""),x("")},children:"Clear filters"})]}),e.jsx(M,{flush:!0,children:e.jsx(B,{filter:j})})]})}export{V as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as W,m as U,r as d,c as ce,O as G,s as N,j as e,P as de,B as f,I as q,k as H,Q,aN as _,y as me,z as ue,E as ae,A as B,C as T,e as w,F as ge,q as P,ag as be,t as F,a9 as se,aO as ne,aP as he,a8 as J,T as I,ac as X,n as ie,aF as pe,ap as ve}from"./index-BC-1LZkB.js";import{u as xe,a as je,P as ye}from"./PolicyField-B7_URv8N.js";import{l as ke,d as fe,L as we}from"./limits-DONLLmCg.js";import{D as Y}from"./DataTable-Cizb1YVv.js";import{S as O}from"./SelectField-BCIB_aud.js";import"./PolicyEditor-CxJuR6mU.js";import"./Segmented-DfgcyK0R.js";import"./roving-DkptacxO.js";import"./Switch-GA0Kao4V.js";import"./Disclosure-Ygp-7rwy.js";import"./index-DX_0N6eB.js";const z=(s,t)=>!!s&&!!t&&s.trim().toLowerCase()===t.trim().toLowerCase();function Ce(s,t,o){const n=[],m=Date.now();for(const i of t)z(i.email,s.email)?n.push(`${i.label} already uses ${i.email}.`):z(i.label,s.label)&&n.push(`A member named ${i.label} already exists${i.status==="invited"?" (invited, not joined yet)":""}.`);for(const i of o)i.expiresAt<m||(z(i.email,s.email)?n.push(`A pending invite already goes to ${i.email}.`):z(i.label,s.label)&&n.push(`A pending invite for ${i.label} already exists.`));return[...new Set(n)]}const D=[P.group("members"),P.group("workspaces"),P.group("keys")],K=[...D,P.group("invites")],te=[{value:"member",label:"Member"},{value:"admin",label:"Admin"}];function V(s){return s.status==="disabled"?e.jsx(F,{tone:"danger",children:"Disabled"}):s.status==="invited"?e.jsx(F,{tone:"warning",children:"Invited"}):e.jsx(F,{tone:"success",children:"Active"})}function le(s,t){return s==="owner"?["member","admin","owner"]:t?["member","admin"]:["member"]}function re(s){return s.map(t=>({value:t,label:_[t]}))}function Se({onCreated:s,onCancel:t}){const{me:o,viewer:n,workspace:m}=W(),i=U(n),C=o.workspaces.filter(a=>i||a.role==="admin").map(a=>a.workspace),[c,u]=d.useState(""),[g,p]=d.useState(""),[v,R]=d.useState("member"),[j,E]=d.useState("72"),[y,b]=d.useState({[m.id]:"member"}),S=G(i),M=ne(),x=Ce({label:c,email:g},S.data??[],M.data??[]),h=N({mutationFn:()=>{const a={label:c.trim(),email:g.trim()||null,orgRole:v,workspaces:Object.entries(y).filter(([,k])=>k).map(([k,L])=>({workspaceId:k,role:L})),expiresInHours:Number(j)||72};return w.invites.create(a)},onSuccess:s,invalidate:K}),l=x.length?"Create anyway":"Create invite link";return e.jsxs("form",{className:"gc-stack",onSubmit:a=>{a.preventDefault(),h.mutate()},children:[e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(I,{label:"Name",required:!0,value:c,onChange:a=>u(a.target.value)}),e.jsx(I,{label:"Email (optional)",type:"email",value:g,onChange:a=>p(a.target.value),hint:"Required when they will sign in with your identity provider."})]}),e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(O,{label:"Organization role",value:v,onChange:a=>R(a),options:re(le(o.member.orgRole,i)),hint:v==="member"?"Sees only the workspaces below.":"Can manage every workspace."}),e.jsx(O,{label:"Link expires after",value:j,onChange:E,options:[{value:"24",label:"1 day"},{value:"72",label:"3 days"},{value:"168",label:"7 days"}]})]}),e.jsxs("fieldset",{className:"gc-checks",children:[e.jsx("legend",{className:"as-field__label",children:"Workspaces"}),C.map(a=>e.jsxs("div",{className:"gc-inline gc-inline--between",children:[e.jsx("span",{children:a.name}),e.jsx(O,{"aria-label":`Role in ${a.name}`,value:y[a.id]??"",onChange:k=>b({...y,[a.id]:k}),options:[{value:"",label:"No access"},...te]})]},a.id))]}),x.length>0&&e.jsx(X,{tone:"warning",title:"Possible duplicate",children:e.jsx("ul",{className:"gc-list",children:x.map(a=>e.jsx("li",{children:a},a))})}),h.error?e.jsx(ie,{error:h.error,title:"Could not create the invite"}):null,e.jsxs("div",{className:"gc-actions",children:[e.jsx(f,{variant:"ghost",onClick:t,children:"Cancel"}),e.jsx(f,{type:"submit",disabled:h.isPending||!c.trim(),children:h.isPending?"Creating…":l})]})]})}function Ne({member:s,onDone:t}){const{me:o,viewer:n}=W(),m=U(n),[i,C]=d.useState(s.label),[c,u]=d.useState(s.email??""),[g,p]=d.useState(s.orgRole),[v,R]=d.useState(ke(s.limits)),[j,E]=d.useState(s.maxKeys===null?"":String(s.maxKeys)),y=xe(s.routingPolicy),[b,S]=d.useState(null),[M,x]=d.useState(!1),h=je(),l=N({mutationFn:async()=>{const r=j.trim()===""?null:Number(j);if(r!==null&&(!Number.isInteger(r)||r<0))throw new Error("Key limit must be a whole number.");const ee={label:i.trim(),email:c.trim()||null,limits:fe(v),maxKeys:r,routingPolicy:y.build(),...m?{orgRole:g}:{}};return h.save([ee.routingPolicy],oe=>w.members.update(s.id,ee,oe))},onSuccess:t,invalidate:D,toast:"Member saved"}),a=N({mutationFn:()=>s.status==="disabled"?w.members.enable(s.id):w.members.disable(s.id),onSuccess:()=>{x(!1),t()},invalidate:D}),k=N({mutationFn:r=>w.members.removeCredential(s.id,r),onSuccess:()=>{S(null),t()},invalidate:D}),L=s.id===o.member.id,A=s.status==="disabled",$=m&&(s.orgRole!=="owner"||o.member.orgRole==="owner"),Z=L&&s.credentials.length<=1;return e.jsxs("form",{className:"gc-stack",onSubmit:r=>{r.preventDefault(),l.mutate()},children:[e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(I,{label:"Name",value:i,onChange:r=>C(r.target.value)}),e.jsx(I,{label:"Email",type:"email",value:c,onChange:r=>u(r.target.value)})]}),e.jsxs("div",{className:"gc-grid gc-grid--2",children:[m&&e.jsx(O,{label:"Organization role",value:g,disabled:L||s.orgRole==="owner"&&o.member.orgRole!=="owner",onChange:r=>p(r),options:re(le(o.member.orgRole,!0))}),e.jsx(I,{label:"Keys they may create",inputMode:"numeric",placeholder:"No limit",value:j,onChange:r=>E(r.target.value)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"as-field__label gc-label-row",children:"Spend limits across their keys (USD)"}),e.jsx(we,{idPrefix:"member-limit",value:v,onChange:R})]}),e.jsx(ye,{draft:y.draft,setDraft:y.setDraft}),e.jsxs("div",{children:[e.jsx("div",{className:"as-field__label gc-label-row",children:"Sign-in methods"}),s.credentials.length===0?e.jsx("p",{className:"gc-muted",children:"None yet."}):e.jsx("ul",{className:"gc-list",children:s.credentials.map(r=>e.jsxs("li",{className:"gc-inline gc-inline--between",children:[e.jsxs("span",{children:[e.jsx(F,{children:r.kind})," ",r.label," ",e.jsxs("span",{className:"gc-muted",children:["· last used ",J(r.lastUsedAt)]})]}),$&&e.jsx(f,{variant:"ghost",size:"sm",disabled:Z,title:Z?"Add another sign-in method first":void 0,onClick:()=>S(r),children:"Remove"})]},r.id))})]}),!$&&e.jsx(X,{tone:"info",children:"Only an owner can change an owner's profile, status or sign-in methods."}),l.error?e.jsx(ie,{error:l.error,title:"Could not save"}):null,e.jsxs("div",{className:"gc-actions gc-actions--split",children:[$&&!L?e.jsx(f,{variant:A?"outline":"danger",size:"sm",onClick:()=>x(!0),children:A?"Enable member":"Disable member"}):e.jsx("span",{}),e.jsxs("div",{className:"gc-actions",children:[e.jsx(f,{variant:"ghost",onClick:t,children:"Cancel"}),$&&e.jsx(f,{type:"submit",disabled:l.isPending,children:l.isPending?"Saving…":"Save"})]})]}),e.jsx(T,{isOpen:M,busy:a.isPending,error:a.error,onClose:()=>x(!1),onConfirm:()=>a.mutate(),title:A?"Enable this member?":"Disable this member?",tone:A?"primary":"danger",confirmLabel:A?"Enable":"Disable",body:A?`${s.label} can sign in again. Their revoked keys stay revoked.`:`${s.label} is signed out and all of their keys are revoked.`}),e.jsx(T,{isOpen:b!==null,busy:k.isPending,error:k.error,onClose:()=>S(null),onConfirm:()=>b&&k.mutate(b.id),title:"Remove this sign-in method?",confirmLabel:"Remove",body:`${(b==null?void 0:b.label)??""} can no longer be used to sign in as ${s.label}.`}),h.dialog]})}function Re({member:s,role:t}){const{workspace:o,me:n}=W(),m=ge(),i=N({mutationFn:c=>w.workspaces.setMember(o.id,s.id,c),invalidate:s.id===n.member.id?[P.workspaceMembers(o.id),P.me]:[P.workspaceMembers(o.id)],toast:(c,u)=>`${s.label} is now a workspace ${u}`,onError:c=>m(`Could not change ${s.label}'s role: ${be(c)}`,"danger")}),C=s.orgRole!=="member";return e.jsx("div",{onClick:c=>c.stopPropagation(),children:e.jsx(O,{size:"sm","aria-label":`Workspace role for ${s.label}`,value:t,disabled:i.isPending||C,title:C?"Organization admins administer every workspace":void 0,onChange:c=>i.mutate(c),options:te})})}function Pe({onEdit:s}){const t=G();return e.jsx(H,{flush:!0,title:"Everyone in the organization",children:e.jsx(Q,{query:t,children:o=>e.jsx(Y,{label:"All members",rows:o,rowKey:n=>n.id,onRowClick:s,rowLabel:n=>n.label,actions:n=>[{label:"Edit member",onSelect:()=>s(n)}],columns:[{key:"name",header:"Name",sortValue:n=>n.label,render:n=>e.jsxs("span",{className:"gc-strong",children:[n.label,n.status!=="active"&&e.jsxs("span",{className:"gc-narrow-only",children:[" ",V(n)]})]})},{key:"email",header:"Email",secondary:!0,render:n=>n.email??"—"},{key:"role",header:"Role",render:n=>_[n.orgRole]},{key:"keys",header:"Key limit",secondary:!0,optional:!0,render:n=>n.maxKeys??"No limit"},{key:"since",header:"Joined",secondary:!0,sortValue:n=>n.createdAt,render:n=>n.status==="invited"?e.jsxs("span",{className:"gc-muted",children:["Invited ",se(n.createdAt)]}):se(n.createdAt)},{key:"status",header:"Status",secondary:!0,render:V}]})})})}function Ee(){const s=ne(),[t,o]=d.useState(null),n=N({mutationFn:m=>w.invites.revoke(m.id),onSuccess:()=>o(null),invalidate:K});return e.jsxs(H,{flush:!0,title:"Pending invites",children:[e.jsx(Q,{query:s,children:m=>e.jsx(Y,{label:"Pending invites",rows:m,rowKey:i=>i.id,rowLabel:i=>`invite for ${i.label}`,empty:e.jsx(ae,{icon:e.jsx(q.members,{size:18}),title:"No pending invites"}),actions:i=>[{label:"Revoke invite",tone:"danger",onSelect:()=>o(i)}],columns:[{key:"name",header:"Name",render:i=>e.jsx("span",{className:"gc-strong",children:i.label})},{key:"email",header:"Email",secondary:!0,render:i=>i.email??"—"},{key:"role",header:"Role",render:i=>_[i.orgRole]},{key:"expires",header:"Expires",secondary:!0,render:i=>e.jsx(he,{at:i.expiresAt,format:J})}]})}),e.jsx(T,{isOpen:t!==null,busy:n.isPending,error:n.error,onClose:()=>o(null),onConfirm:()=>t&&n.mutate(t),title:"Revoke this invite?",confirmLabel:"Revoke",body:"The link stops working."})]})}function Ae({invite:s,onClose:t}){return e.jsx(B,{isOpen:s!==null,onClose:t,title:"Invite link",size:"lg",children:s&&e.jsxs("div",{className:"gc-stack",children:[s.url?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Send this link to ",e.jsx("strong",{children:s.label}),". It works once and expires ",J(s.expiresAt),"."]}),e.jsx(pe,{secret:s.url,note:"This link is shown only once. Anyone with it can join as this member."})]}):e.jsx(X,{tone:"warning",children:"The gateway did not return a link for this invite."}),e.jsxs("div",{className:"gc-actions",children:[s.url&&e.jsx(ve,{value:s.url,label:"Copy link",size:"md"}),e.jsx(f,{onClick:t,children:"Done"})]})]})})}function _e(){var h;const{viewer:s,workspace:t,me:o}=W(),n=U(s),[m,i]=d.useState(!1),[C,c]=d.useState(null),[u,g]=d.useState(null),[p,v]=d.useState(null),[R,j]=d.useState(""),E=ce(t.id),y=G(n),b=N({mutationFn:l=>w.workspaces.removeMember(t.id,l.id),onSuccess:()=>v(null),invalidate:K,toast:"Removed from workspace"}),S=N({mutationFn:l=>w.workspaces.setMember(t.id,l,"member"),onSuccess:()=>j(""),invalidate:K,toast:"Added to workspace"}),M=new Set((h=E.data)==null?void 0:h.map(({member:l})=>l.id)),x=(y.data??[]).filter(l=>!M.has(l.id)&&l.status==="active");return e.jsxs("div",{className:"gc-page",children:[e.jsx(de,{title:"Members",description:"Who can use this gateway, their budgets and routing.",actions:e.jsx(f,{variant:"brand",leadingIcon:e.jsx(q.plus,{size:14}),onClick:()=>i(!0),children:"Invite member"})}),e.jsx(H,{flush:!0,title:`${t.name} workspace`,actions:n&&x.length>0?e.jsxs("div",{className:"gc-inline",children:[e.jsx(O,{size:"sm","aria-label":"Add an existing member",value:R,onChange:j,options:[{value:"",label:"Add existing member…"},...x.map(l=>({value:l.id,label:l.label}))]}),e.jsx(f,{size:"sm",variant:"outline",disabled:!R||S.isPending,onClick:()=>S.mutate(R),children:"Add"})]}):void 0,children:e.jsx(Q,{query:E,children:l=>e.jsx(Y,{label:"Workspace members",rows:l,rowKey:a=>a.member.id,onRowClick:n?a=>g(a.member):void 0,rowLabel:a=>a.member.label,actions:a=>[n&&{label:"Edit member",onSelect:()=>g(a.member)},a.member.id!==o.member.id&&{label:"Remove from workspace",tone:"danger",onSelect:()=>v(a.member)}],empty:e.jsx(ae,{icon:e.jsx(q.members,{size:18}),title:"No members in this workspace"}),columns:[{key:"name",header:"Name",sortValue:a=>a.member.label,render:a=>e.jsxs("div",{children:[e.jsx("div",{className:"gc-strong",children:a.member.label}),e.jsx("div",{className:"gc-muted",children:a.member.email??_[a.member.orgRole]})]})},{key:"role",header:"Workspace role",render:a=>e.jsx(Re,{member:a.member,role:a.role})},{key:"limits",header:"Limits",secondary:!0,optional:!0,render:a=>e.jsx("span",{className:"gc-muted",children:me(a.member.limits)})},{key:"policy",header:"Routing",secondary:!0,optional:!0,render:a=>e.jsx("span",{className:"gc-muted",children:ue(a.member.routingPolicy)})},{key:"status",header:"Status",secondary:!0,render:a=>V(a.member)}]})})}),n&&e.jsx(Pe,{onEdit:g}),e.jsx(Ee,{}),e.jsx(B,{isOpen:m,onClose:()=>i(!1),size:"lg",title:"Invite a member",children:m&&e.jsx(Se,{onCancel:()=>i(!1),onCreated:l=>{i(!1),c(l)}})}),e.jsx(Ae,{invite:C,onClose:()=>c(null)}),e.jsx(B,{isOpen:u!==null,onClose:()=>g(null),size:"lg",title:(u==null?void 0:u.label)??"",eyebrow:"Member",children:u&&e.jsx(Ne,{member:u,onDone:()=>g(null)},u.id)}),e.jsx(T,{isOpen:p!==null,busy:b.isPending,error:b.error,onClose:()=>v(null),onConfirm:()=>p&&b.mutate(p),title:"Remove from workspace?",confirmLabel:"Remove",body:`${(p==null?void 0:p.label)??""} loses access to ${t.name}. Their keys in this workspace stop working.`})]})}export{_e as default};
|
|
1
|
+
import{u as W,m as U,r as d,c as ce,O as G,s as N,j as e,P as de,B as f,I as q,k as H,Q,aN as _,y as me,z as ue,E as ae,A as B,C as T,e as w,F as ge,q as P,ag as be,t as F,a9 as se,aO as ne,aP as he,a8 as J,T as I,ac as X,n as ie,aF as pe,ap as ve}from"./index-C21bvTBH.js";import{u as xe,a as je,P as ye}from"./PolicyField-0xAOIP4-.js";import{l as ke,d as fe,L as we}from"./limits-D_C7APR_.js";import{D as Y}from"./DataTable-D2QIQ-gI.js";import{S as O}from"./SelectField-D_BPTzpT.js";import"./PolicyEditor-CRhTwGq0.js";import"./Segmented-BJmgB5-Y.js";import"./roving-DkptacxO.js";import"./Switch-JCyfy3G5.js";import"./Disclosure-h1MJg5Wn.js";import"./index-DqHGr8d4.js";const z=(s,t)=>!!s&&!!t&&s.trim().toLowerCase()===t.trim().toLowerCase();function Ce(s,t,o){const n=[],m=Date.now();for(const i of t)z(i.email,s.email)?n.push(`${i.label} already uses ${i.email}.`):z(i.label,s.label)&&n.push(`A member named ${i.label} already exists${i.status==="invited"?" (invited, not joined yet)":""}.`);for(const i of o)i.expiresAt<m||(z(i.email,s.email)?n.push(`A pending invite already goes to ${i.email}.`):z(i.label,s.label)&&n.push(`A pending invite for ${i.label} already exists.`));return[...new Set(n)]}const D=[P.group("members"),P.group("workspaces"),P.group("keys")],K=[...D,P.group("invites")],te=[{value:"member",label:"Member"},{value:"admin",label:"Admin"}];function V(s){return s.status==="disabled"?e.jsx(F,{tone:"danger",children:"Disabled"}):s.status==="invited"?e.jsx(F,{tone:"warning",children:"Invited"}):e.jsx(F,{tone:"success",children:"Active"})}function le(s,t){return s==="owner"?["member","admin","owner"]:t?["member","admin"]:["member"]}function re(s){return s.map(t=>({value:t,label:_[t]}))}function Se({onCreated:s,onCancel:t}){const{me:o,viewer:n,workspace:m}=W(),i=U(n),C=o.workspaces.filter(a=>i||a.role==="admin").map(a=>a.workspace),[c,u]=d.useState(""),[g,p]=d.useState(""),[v,R]=d.useState("member"),[j,E]=d.useState("72"),[y,b]=d.useState({[m.id]:"member"}),S=G(i),M=ne(),x=Ce({label:c,email:g},S.data??[],M.data??[]),h=N({mutationFn:()=>{const a={label:c.trim(),email:g.trim()||null,orgRole:v,workspaces:Object.entries(y).filter(([,k])=>k).map(([k,L])=>({workspaceId:k,role:L})),expiresInHours:Number(j)||72};return w.invites.create(a)},onSuccess:s,invalidate:K}),l=x.length?"Create anyway":"Create invite link";return e.jsxs("form",{className:"gc-stack",onSubmit:a=>{a.preventDefault(),h.mutate()},children:[e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(I,{label:"Name",required:!0,value:c,onChange:a=>u(a.target.value)}),e.jsx(I,{label:"Email (optional)",type:"email",value:g,onChange:a=>p(a.target.value),hint:"Required when they will sign in with your identity provider."})]}),e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(O,{label:"Organization role",value:v,onChange:a=>R(a),options:re(le(o.member.orgRole,i)),hint:v==="member"?"Sees only the workspaces below.":"Can manage every workspace."}),e.jsx(O,{label:"Link expires after",value:j,onChange:E,options:[{value:"24",label:"1 day"},{value:"72",label:"3 days"},{value:"168",label:"7 days"}]})]}),e.jsxs("fieldset",{className:"gc-checks",children:[e.jsx("legend",{className:"as-field__label",children:"Workspaces"}),C.map(a=>e.jsxs("div",{className:"gc-inline gc-inline--between",children:[e.jsx("span",{children:a.name}),e.jsx(O,{"aria-label":`Role in ${a.name}`,value:y[a.id]??"",onChange:k=>b({...y,[a.id]:k}),options:[{value:"",label:"No access"},...te]})]},a.id))]}),x.length>0&&e.jsx(X,{tone:"warning",title:"Possible duplicate",children:e.jsx("ul",{className:"gc-list",children:x.map(a=>e.jsx("li",{children:a},a))})}),h.error?e.jsx(ie,{error:h.error,title:"Could not create the invite"}):null,e.jsxs("div",{className:"gc-actions",children:[e.jsx(f,{variant:"ghost",onClick:t,children:"Cancel"}),e.jsx(f,{type:"submit",disabled:h.isPending||!c.trim(),children:h.isPending?"Creating…":l})]})]})}function Ne({member:s,onDone:t}){const{me:o,viewer:n}=W(),m=U(n),[i,C]=d.useState(s.label),[c,u]=d.useState(s.email??""),[g,p]=d.useState(s.orgRole),[v,R]=d.useState(ke(s.limits)),[j,E]=d.useState(s.maxKeys===null?"":String(s.maxKeys)),y=xe(s.routingPolicy),[b,S]=d.useState(null),[M,x]=d.useState(!1),h=je(),l=N({mutationFn:async()=>{const r=j.trim()===""?null:Number(j);if(r!==null&&(!Number.isInteger(r)||r<0))throw new Error("Key limit must be a whole number.");const ee={label:i.trim(),email:c.trim()||null,limits:fe(v),maxKeys:r,routingPolicy:y.build(),...m?{orgRole:g}:{}};return h.save([ee.routingPolicy],oe=>w.members.update(s.id,ee,oe))},onSuccess:t,invalidate:D,toast:"Member saved"}),a=N({mutationFn:()=>s.status==="disabled"?w.members.enable(s.id):w.members.disable(s.id),onSuccess:()=>{x(!1),t()},invalidate:D}),k=N({mutationFn:r=>w.members.removeCredential(s.id,r),onSuccess:()=>{S(null),t()},invalidate:D}),L=s.id===o.member.id,A=s.status==="disabled",$=m&&(s.orgRole!=="owner"||o.member.orgRole==="owner"),Z=L&&s.credentials.length<=1;return e.jsxs("form",{className:"gc-stack",onSubmit:r=>{r.preventDefault(),l.mutate()},children:[e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(I,{label:"Name",value:i,onChange:r=>C(r.target.value)}),e.jsx(I,{label:"Email",type:"email",value:c,onChange:r=>u(r.target.value)})]}),e.jsxs("div",{className:"gc-grid gc-grid--2",children:[m&&e.jsx(O,{label:"Organization role",value:g,disabled:L||s.orgRole==="owner"&&o.member.orgRole!=="owner",onChange:r=>p(r),options:re(le(o.member.orgRole,!0))}),e.jsx(I,{label:"Keys they may create",inputMode:"numeric",placeholder:"No limit",value:j,onChange:r=>E(r.target.value)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"as-field__label gc-label-row",children:"Spend limits across their keys (USD)"}),e.jsx(we,{idPrefix:"member-limit",value:v,onChange:R})]}),e.jsx(ye,{draft:y.draft,setDraft:y.setDraft}),e.jsxs("div",{children:[e.jsx("div",{className:"as-field__label gc-label-row",children:"Sign-in methods"}),s.credentials.length===0?e.jsx("p",{className:"gc-muted",children:"None yet."}):e.jsx("ul",{className:"gc-list",children:s.credentials.map(r=>e.jsxs("li",{className:"gc-inline gc-inline--between",children:[e.jsxs("span",{children:[e.jsx(F,{children:r.kind})," ",r.label," ",e.jsxs("span",{className:"gc-muted",children:["· last used ",J(r.lastUsedAt)]})]}),$&&e.jsx(f,{variant:"ghost",size:"sm",disabled:Z,title:Z?"Add another sign-in method first":void 0,onClick:()=>S(r),children:"Remove"})]},r.id))})]}),!$&&e.jsx(X,{tone:"info",children:"Only an owner can change an owner's profile, status or sign-in methods."}),l.error?e.jsx(ie,{error:l.error,title:"Could not save"}):null,e.jsxs("div",{className:"gc-actions gc-actions--split",children:[$&&!L?e.jsx(f,{variant:A?"outline":"danger",size:"sm",onClick:()=>x(!0),children:A?"Enable member":"Disable member"}):e.jsx("span",{}),e.jsxs("div",{className:"gc-actions",children:[e.jsx(f,{variant:"ghost",onClick:t,children:"Cancel"}),$&&e.jsx(f,{type:"submit",disabled:l.isPending,children:l.isPending?"Saving…":"Save"})]})]}),e.jsx(T,{isOpen:M,busy:a.isPending,error:a.error,onClose:()=>x(!1),onConfirm:()=>a.mutate(),title:A?"Enable this member?":"Disable this member?",tone:A?"primary":"danger",confirmLabel:A?"Enable":"Disable",body:A?`${s.label} can sign in again. Their revoked keys stay revoked.`:`${s.label} is signed out and all of their keys are revoked.`}),e.jsx(T,{isOpen:b!==null,busy:k.isPending,error:k.error,onClose:()=>S(null),onConfirm:()=>b&&k.mutate(b.id),title:"Remove this sign-in method?",confirmLabel:"Remove",body:`${(b==null?void 0:b.label)??""} can no longer be used to sign in as ${s.label}.`}),h.dialog]})}function Re({member:s,role:t}){const{workspace:o,me:n}=W(),m=ge(),i=N({mutationFn:c=>w.workspaces.setMember(o.id,s.id,c),invalidate:s.id===n.member.id?[P.workspaceMembers(o.id),P.me]:[P.workspaceMembers(o.id)],toast:(c,u)=>`${s.label} is now a workspace ${u}`,onError:c=>m(`Could not change ${s.label}'s role: ${be(c)}`,"danger")}),C=s.orgRole!=="member";return e.jsx("div",{onClick:c=>c.stopPropagation(),children:e.jsx(O,{size:"sm","aria-label":`Workspace role for ${s.label}`,value:t,disabled:i.isPending||C,title:C?"Organization admins administer every workspace":void 0,onChange:c=>i.mutate(c),options:te})})}function Pe({onEdit:s}){const t=G();return e.jsx(H,{flush:!0,title:"Everyone in the organization",children:e.jsx(Q,{query:t,children:o=>e.jsx(Y,{label:"All members",rows:o,rowKey:n=>n.id,onRowClick:s,rowLabel:n=>n.label,actions:n=>[{label:"Edit member",onSelect:()=>s(n)}],columns:[{key:"name",header:"Name",sortValue:n=>n.label,render:n=>e.jsxs("span",{className:"gc-strong",children:[n.label,n.status!=="active"&&e.jsxs("span",{className:"gc-narrow-only",children:[" ",V(n)]})]})},{key:"email",header:"Email",secondary:!0,render:n=>n.email??"—"},{key:"role",header:"Role",render:n=>_[n.orgRole]},{key:"keys",header:"Key limit",secondary:!0,optional:!0,render:n=>n.maxKeys??"No limit"},{key:"since",header:"Joined",secondary:!0,sortValue:n=>n.createdAt,render:n=>n.status==="invited"?e.jsxs("span",{className:"gc-muted",children:["Invited ",se(n.createdAt)]}):se(n.createdAt)},{key:"status",header:"Status",secondary:!0,render:V}]})})})}function Ee(){const s=ne(),[t,o]=d.useState(null),n=N({mutationFn:m=>w.invites.revoke(m.id),onSuccess:()=>o(null),invalidate:K});return e.jsxs(H,{flush:!0,title:"Pending invites",children:[e.jsx(Q,{query:s,children:m=>e.jsx(Y,{label:"Pending invites",rows:m,rowKey:i=>i.id,rowLabel:i=>`invite for ${i.label}`,empty:e.jsx(ae,{icon:e.jsx(q.members,{size:18}),title:"No pending invites"}),actions:i=>[{label:"Revoke invite",tone:"danger",onSelect:()=>o(i)}],columns:[{key:"name",header:"Name",render:i=>e.jsx("span",{className:"gc-strong",children:i.label})},{key:"email",header:"Email",secondary:!0,render:i=>i.email??"—"},{key:"role",header:"Role",render:i=>_[i.orgRole]},{key:"expires",header:"Expires",secondary:!0,render:i=>e.jsx(he,{at:i.expiresAt,format:J})}]})}),e.jsx(T,{isOpen:t!==null,busy:n.isPending,error:n.error,onClose:()=>o(null),onConfirm:()=>t&&n.mutate(t),title:"Revoke this invite?",confirmLabel:"Revoke",body:"The link stops working."})]})}function Ae({invite:s,onClose:t}){return e.jsx(B,{isOpen:s!==null,onClose:t,title:"Invite link",size:"lg",children:s&&e.jsxs("div",{className:"gc-stack",children:[s.url?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Send this link to ",e.jsx("strong",{children:s.label}),". It works once and expires ",J(s.expiresAt),"."]}),e.jsx(pe,{secret:s.url,note:"This link is shown only once. Anyone with it can join as this member."})]}):e.jsx(X,{tone:"warning",children:"The gateway did not return a link for this invite."}),e.jsxs("div",{className:"gc-actions",children:[s.url&&e.jsx(ve,{value:s.url,label:"Copy link",size:"md"}),e.jsx(f,{onClick:t,children:"Done"})]})]})})}function _e(){var h;const{viewer:s,workspace:t,me:o}=W(),n=U(s),[m,i]=d.useState(!1),[C,c]=d.useState(null),[u,g]=d.useState(null),[p,v]=d.useState(null),[R,j]=d.useState(""),E=ce(t.id),y=G(n),b=N({mutationFn:l=>w.workspaces.removeMember(t.id,l.id),onSuccess:()=>v(null),invalidate:K,toast:"Removed from workspace"}),S=N({mutationFn:l=>w.workspaces.setMember(t.id,l,"member"),onSuccess:()=>j(""),invalidate:K,toast:"Added to workspace"}),M=new Set((h=E.data)==null?void 0:h.map(({member:l})=>l.id)),x=(y.data??[]).filter(l=>!M.has(l.id)&&l.status==="active");return e.jsxs("div",{className:"gc-page",children:[e.jsx(de,{title:"Members",description:"Who can use this gateway, their budgets and routing.",actions:e.jsx(f,{variant:"brand",leadingIcon:e.jsx(q.plus,{size:14}),onClick:()=>i(!0),children:"Invite member"})}),e.jsx(H,{flush:!0,title:`${t.name} workspace`,actions:n&&x.length>0?e.jsxs("div",{className:"gc-inline",children:[e.jsx(O,{size:"sm","aria-label":"Add an existing member",value:R,onChange:j,options:[{value:"",label:"Add existing member…"},...x.map(l=>({value:l.id,label:l.label}))]}),e.jsx(f,{size:"sm",variant:"outline",disabled:!R||S.isPending,onClick:()=>S.mutate(R),children:"Add"})]}):void 0,children:e.jsx(Q,{query:E,children:l=>e.jsx(Y,{label:"Workspace members",rows:l,rowKey:a=>a.member.id,onRowClick:n?a=>g(a.member):void 0,rowLabel:a=>a.member.label,actions:a=>[n&&{label:"Edit member",onSelect:()=>g(a.member)},a.member.id!==o.member.id&&{label:"Remove from workspace",tone:"danger",onSelect:()=>v(a.member)}],empty:e.jsx(ae,{icon:e.jsx(q.members,{size:18}),title:"No members in this workspace"}),columns:[{key:"name",header:"Name",sortValue:a=>a.member.label,render:a=>e.jsxs("div",{children:[e.jsx("div",{className:"gc-strong",children:a.member.label}),e.jsx("div",{className:"gc-muted",children:a.member.email??_[a.member.orgRole]})]})},{key:"role",header:"Workspace role",render:a=>e.jsx(Re,{member:a.member,role:a.role})},{key:"limits",header:"Limits",secondary:!0,optional:!0,render:a=>e.jsx("span",{className:"gc-muted",children:me(a.member.limits)})},{key:"policy",header:"Routing",secondary:!0,optional:!0,render:a=>e.jsx("span",{className:"gc-muted",children:ue(a.member.routingPolicy)})},{key:"status",header:"Status",secondary:!0,render:a=>V(a.member)}]})})}),n&&e.jsx(Pe,{onEdit:g}),e.jsx(Ee,{}),e.jsx(B,{isOpen:m,onClose:()=>i(!1),size:"lg",title:"Invite a member",children:m&&e.jsx(Se,{onCancel:()=>i(!1),onCreated:l=>{i(!1),c(l)}})}),e.jsx(Ae,{invite:C,onClose:()=>c(null)}),e.jsx(B,{isOpen:u!==null,onClose:()=>g(null),size:"lg",title:(u==null?void 0:u.label)??"",eyebrow:"Member",children:u&&e.jsx(Ne,{member:u,onDone:()=>g(null)},u.id)}),e.jsx(T,{isOpen:p!==null,busy:b.isPending,error:b.error,onClose:()=>v(null),onConfirm:()=>p&&b.mutate(p),title:"Remove from workspace?",confirmLabel:"Remove",body:`${(p==null?void 0:p.label)??""} loses access to ${t.name}. Their keys in this workspace stop working.`})]})}export{_e as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as v,ad as _,r as g,ae as f,af as N,m as k,j as e,ac as p,P as S,I as l,k as x,T as j,W as r,t as y}from"./index-C21bvTBH.js";const T="https://antseed.com/docs/gateway/migrate",C="https://antseed.com/docs/tunnels",P={local:"This computer only",lan:"Your network only",public:"Public"};function o({n:s,title:a,children:t}){return e.jsxs("li",{className:"gc-migrate__step",children:[e.jsx("span",{className:"gc-migrate__num","aria-hidden":"true",children:s}),e.jsxs("div",{className:"gc-migrate__body",children:[e.jsx("h3",{className:"gc-migrate__title",children:a}),t]})]})}function d({icon:s,title:a,children:t}){return e.jsxs("div",{className:"gc-migrate__why",children:[e.jsx("span",{className:"gc-migrate__why-icon","aria-hidden":"true",children:s}),e.jsxs("div",{children:[e.jsx("div",{className:"gc-migrate__why-title",children:a}),e.jsx("p",{className:"gc-migrate__why-text",children:t})]})]})}function I({exposure:s}){return e.jsxs("div",{className:"gc-migrate__now",children:[e.jsxs("div",{className:"gc-migrate__now-head",children:[e.jsx("span",{className:"gc-muted",children:"Right now"}),e.jsx(y,{tone:s.mode==="public"?"neutral":"warning",children:P[s.mode]}),s.listenHost&&e.jsx("code",{className:"gc-migrate__addr",children:s.listenHost})]}),s.reasons.length>0&&e.jsx("ul",{className:"gc-migrate__reasons",children:s.reasons.map(a=>e.jsx("li",{children:a},a))})]})}function A(){var u;const{viewer:s}=v(),a=_(),[t,w]=g.useState(""),[h,b]=g.useState(""),m=f(t),n=N({domain:m,server:h}),i=(u=a.data)==null?void 0:u.exposure;return k(s)?e.jsxs("div",{className:"gc-page gc-migrate",children:[e.jsx(S,{title:"Move this gateway to a server",description:"Keep every key, member, workspace, wallet and its usage history. Your apps only need the new base URL."}),i&&e.jsx(I,{exposure:i}),(i==null?void 0:i.mode)==="public"&&e.jsxs(p,{tone:"info",title:"Already public",children:["This gateway has a public address (",i.publicUrl,"). You can still move it to another machine with the same steps."]}),e.jsxs("div",{className:"gc-migrate__whys",children:[e.jsx(d,{icon:e.jsx(l.activity,{size:16}),title:"Always on",children:"Keys keep working when your laptop sleeps, travels or restarts."}),e.jsx(d,{icon:e.jsx(l.shield,{size:16}),title:"HTTPS on your domain",children:"Automatic TLS at an address like https://llm.example.com, with passkeys and single sign-on."}),e.jsx(d,{icon:e.jsx(l.members,{size:16}),title:"Team access",children:"Teammates, CI and hosted tools reach it from anywhere, each with their own key and budget."})]}),e.jsxs(x,{title:e.jsxs("span",{className:"gc-inline",children:["Recommended: a small Linux server ",e.jsx(y,{tone:"neutral",children:"About 10 minutes"})]}),description:"Any VPS with a public IP works (1 vCPU, 1 GB RAM). Point a DNS name at it and open ports 80 and 443.",children:[e.jsxs("div",{className:"gc-migrate__inputs",children:[e.jsx(j,{label:"Domain for the gateway",placeholder:"llm.example.com",value:t,onChange:c=>w(c.target.value),error:t.trim()&&!m?"Enter a host name such as llm.example.com":void 0,spellCheck:!1,autoCapitalize:"off"}),e.jsx(j,{label:"Server SSH login",placeholder:"user@your-server",value:h,onChange:c=>b(c.target.value),spellCheck:!1,autoCapitalize:"off",mono:!0})]}),e.jsxs("ol",{className:"gc-migrate__steps",children:[e.jsxs(o,{n:1,title:"Export it on this computer",children:[e.jsx("p",{children:"Writes a password-protected bundle readable only by you. It holds the wallet keys, so keep the password apart from the file."}),e.jsx(r,{code:n.exportBundle,label:"This computer"})]}),e.jsx(o,{n:2,title:"Copy the bundle to the server",children:e.jsx(r,{code:n.copy,label:"This computer"})}),e.jsxs(o,{n:3,title:"Install the gateway on the server and import the bundle",children:[e.jsx("p",{children:"Installs the CLI, restores the bundle as the service user, starts the buyer and gateway with automatic HTTPS. It asks for the bundle password."}),e.jsx(r,{code:n.install,label:"Server"})]}),e.jsxs(o,{n:4,title:"Point your apps at the new address",children:[e.jsx("p",{children:"API keys stay the same. Only the base URL changes:"}),e.jsx(r,{code:n.baseUrl,label:"New base URL"})]}),e.jsxs(o,{n:5,title:"Stop the gateway on this computer",children:[e.jsxs("p",{children:["Press Ctrl+C where ",e.jsx("code",{children:"antseed gateway start"})," runs, which also stops the buyer it started (stop a buyer you run yourself too, or quit the desktop app's gateway), then delete the bundle on both machines. Never run both gateways: two buyers paying from the same wallet conflict."]}),e.jsx(r,{code:n.stop,label:"Both machines"})]})]}),e.jsxs("div",{className:"gc-migrate__note",children:[e.jsx("strong",{children:"Signing in afterwards."})," Everyone signs in again on the new address. Wallet and single sign-on keep working; passkeys are tied to the domain they were made on, so add a new one with a one-time link from the server:",e.jsx(r,{code:n.recover,label:"Server"})]}),e.jsxs("p",{className:"gc-fineprint",children:[e.jsx(l.shield,{size:12})," Wallet keys never pass through this browser: the console only shows commands. ",e.jsx("a",{className:"gc-link",href:T,target:"_blank",rel:"noreferrer",children:"Full guide"})]})]}),e.jsx(x,{title:"Alternative: keep it here behind a Cloudflare tunnel",description:"Gives this computer a public HTTPS address without moving anything.",children:e.jsxs("div",{className:"gc-stack",children:[e.jsx(r,{code:n.tunnel,label:"This computer, instead of gateway start"}),e.jsxs("ul",{className:"gc-migrate__caveats",children:[e.jsx("li",{children:"Keys still stop working whenever this computer sleeps, loses its connection or restarts."}),e.jsxs("li",{children:["Needs a Cloudflare account and a named tunnel whose public hostname points at ",e.jsx("code",{children:"http://localhost:8379"}),"."]}),e.jsx("li",{children:"Traffic and model responses run through your home or office connection."})]}),e.jsxs("a",{className:"gc-link",href:C,target:"_blank",rel:"noreferrer",children:["Tunnel guide ",e.jsx(l.external,{size:12})]})]})})]}):e.jsx(p,{tone:"warning",title:"Not available",children:"Only organization owners and admins can move the gateway."})}export{A as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aS as A,r as m,j as e,aT as F,W as B,aU as V,N as w,aV as $,aW as U,aX as R,aY as _,L as z,E as f,I as M,P as O,T as D,x as k,k as K,Q as Y,aZ as q,M as b,g as Q,a_ as v,a$ as S,b0 as I,b1 as W,ap as N,t as u,V as G,B as H,ab as X,v as L,h as Z}from"./index-
|
|
1
|
+
import{aS as A,r as m,j as e,aT as F,W as B,aU as V,N as w,aV as $,aW as U,aX as R,aY as _,L as z,E as f,I as M,P as O,T as D,x as k,k as K,Q as Y,aZ as q,M as b,g as Q,a_ as v,a$ as S,b0 as I,b1 as W,ap as N,t as u,V as G,B as H,ab as X,v as L,h as Z}from"./index-C21bvTBH.js";import{T as J,a as ee}from"./Tabs-CGI9v1OW.js";import{m as se,f as ae,M as P,S as te,a as ne,C as ie,P as C,b as le,V as re,p as oe}from"./models-BpLCh6Fr.js";import{S as T}from"./SelectField-D_BPTzpT.js";import{S as ce}from"./Switch-JCyfy3G5.js";import{D as de}from"./DataTable-D2QIQ-gI.js";import"./roving-DkptacxO.js";import"./index-DqHGr8d4.js";function ue({model:s,format:i,id:o="gc-api-call",unsupported:l}){const p=A(),[g,r]=m.useState("curl");if(!i)return e.jsx("p",{className:"gc-fineprint",children:l??"The gateway does not serve this model through its API."});const t=F(p,s,i),d=t.find(c=>c.id===g)??t[0];return e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsx(J,{id:o,label:"Request examples",value:d.id,onChange:r,className:"gc-connect-tabs",tabs:t.map(c=>({id:c.id,label:c.label}))}),e.jsx(ee,{tabsId:o,tab:d.id,children:e.jsx(B,{code:d.code,label:d.label})}),e.jsxs("p",{className:"gc-fineprint",children:["Set ",e.jsx("code",{children:V})," to one of your API keys first. ",e.jsx(w,{to:"keys",children:"API keys"})]})]})}function he(s){return s===null?"—":String(Math.round(s))}function E(s){return s===null?"—":Z(s)}function pe({model:s}){return e.jsxs("div",{className:"gc-badges",children:[s.free&&e.jsx(u,{tone:"success",children:"Free"}),s.teeSellers>0&&e.jsx(u,{tone:"info",children:"TEE"})]})}function y(s){return s.displayName??L(s.peerId,8,4)}function Me(){const s=$(),i=U(s.rest),o=R(),[l,p]=m.useState({search:"",type:"",free:!1}),g=m.useMemo(()=>se(o.data),[o.data]),r=m.useMemo(()=>i?ae(o.data,i):null,[o.data,i]),t=_(),d=(n,a)=>p(h=>({...h,[n]:a})),c=i===null?null:{eyebrow:"Model",title:(r==null?void 0:r.name)??i,body:o.isLoading?e.jsx(z,{rows:6}):r?e.jsx(ge,{model:r},r.id):e.jsx(f,{icon:e.jsx(M.models,{size:18}),title:"Model not found",body:`No provider on the network offers ${i} right now.`})},j=e.jsx(K,{flush:!0,children:e.jsx(Y,{query:o,rows:8,children:n=>e.jsx(de,{label:"Models",rows:ne(n,l),rowKey:a=>a.id,selectedKey:(r==null?void 0:r.id)??null,onRowClick:a=>k(S("models",a.id)),rowLabel:a=>a.name,actions:a=>[{label:"Copy model id",onSelect:()=>void t(a.id)}],initialSort:{key:"sellers",direction:"desc"},empty:e.jsx(f,{icon:e.jsx(M.models,{size:18}),title:n.length?"No models match these filters":"No models found yet",body:n.length?void 0:"The buyer is still discovering the network. Check back in a minute."}),columns:[{key:"model",header:"Model",sortValue:a=>a.name.toLowerCase(),render:a=>e.jsxs("div",{className:"gc-cell-lines",children:[e.jsx("div",{className:"gc-strong gc-ellipsis",title:a.id,children:a.name}),a.name!==a.id&&e.jsx("div",{className:"gc-muted gc-ellipsis",children:e.jsx(b,{children:a.id})}),e.jsx(pe,{model:a})]}),after:a=>e.jsx(q,{value:a.id,label:`Copy model id ${a.id}`})},{key:"type",header:"Type",secondary:!0,sortValue:a=>a.type,render:a=>e.jsx("span",{className:"gc-muted",children:P[a.type]})},{key:"sellers",header:"Providers",align:"right",sortValue:a=>a.sellers,render:a=>Q(a.sellers)},{key:"input",header:"Input $/M",align:"right",sortValue:a=>{var h;return((h=a.inputUsdPerMillion)==null?void 0:h.min)??null},render:a=>v(a.inputUsdPerMillion)},{key:"output",header:"Output $/M",align:"right",secondary:!0,sortValue:a=>{var h;return((h=a.outputUsdPerMillion)==null?void 0:h.min)??null},render:a=>v(a.outputUsdPerMillion)},{key:"context",header:"Context",align:"right",secondary:!0,optional:!0,sortValue:a=>a.contextLength,render:a=>E(a.contextLength)}]})})});return e.jsxs("div",{className:"gc-page",children:[e.jsx(O,{title:"Models",description:"Every model on the network. Open one to see its providers, copy a model id and get a ready-to-run API call."}),e.jsxs("div",{className:"gc-toolbar",children:[e.jsx(D,{size:"sm",type:"search","aria-label":"Search models",placeholder:"Search model or alias",value:l.search,onChange:n=>d("search",n.target.value)}),g.length>1&&e.jsx(T,{size:"sm","aria-label":"Filter by type",value:l.type,onChange:n=>d("type",n),options:[{value:"",label:"All types"},...g.map(n=>({value:n,label:P[n]}))]}),e.jsx(ce,{checked:l.free,onChange:n=>d("free",n),label:"Free"})]}),e.jsx(te,{list:j,panel:c,onClose:()=>k("models"),closeLabel:"Close model"})]})}function x(s){return`${s.peerId}:${s.serviceId}`}function ge({model:s}){const[i,o]=m.useState(""),l=s.offers.find(t=>x(t)===i)??null,p=l?I(l.peerId,l.serviceId):s.id,g=W(s.type,l),r=s.offers.some(t=>t.usdPerImage!==null);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsxs("span",{className:"gc-seller__meta",children:[e.jsxs("span",{className:"gc-peer-id",children:[e.jsx(b,{title:s.id,children:s.id}),e.jsx(N,{iconOnly:!0,value:s.id,label:"Copy model id"})]}),e.jsx(u,{children:P[s.type]}),s.free&&e.jsx(u,{tone:"success",children:"Free"}),s.teeSellers>0&&e.jsx(u,{tone:"info",children:"TEE"})]}),e.jsx(G,{items:[["Context",E(s.contextLength)],["Capabilities",s.capabilities.length?e.jsx("span",{className:"gc-badges",children:s.capabilities.map(t=>e.jsx(u,{children:ie[t]},t))}):"—"],["Aliases",s.aliases.length?e.jsx(b,{children:s.aliases.join(", ")}):"—"],...r?[]:[["Input $/M",v(s.inputUsdPerMillion)],["Output $/M",v(s.outputUsdPerMillion)]]]})]}),e.jsx(C,{title:`Providers (${s.offers.length})`,children:s.offers.length===0?e.jsx("p",{className:"gc-fineprint",children:"No provider offers this model right now."}):e.jsx("ul",{className:"gc-panel-rows","aria-label":"Providers offering this model",children:s.offers.map(t=>{var j;const d=I(t.peerId,t.serviceId),c=i===x(t);return e.jsx(le,{selected:c,title:e.jsx(w,{to:S("providers",t.peerId),children:y(t)}),meta:e.jsxs(e.Fragment,{children:[e.jsx("span",{children:oe(t)}),e.jsxs("span",{children:["Trust ",he(t.trustScore)]}),t.latencyMsP50!==null&&e.jsx("span",{children:X(t.latencyMsP50)}),t.serviceId!==s.id&&e.jsx(b,{children:t.serviceId})]}),badges:(((j=t.verificationLinks)==null?void 0:j.length)||t.tee||t.free)&&e.jsxs("div",{className:"gc-badges",children:[e.jsx(re,{links:t.verificationLinks}),t.tee&&e.jsx(u,{tone:"info",children:"TEE"}),t.free&&e.jsx(u,{tone:"success",children:"Free"})]}),actions:e.jsxs(e.Fragment,{children:[e.jsx(N,{iconOnly:!0,value:d,label:`Copy ${y(t)}'s model id (peer@model)`}),e.jsx(H,{size:"sm",variant:c?"outline":"ghost","aria-pressed":c,title:"Use this provider in the API call below",onClick:()=>o(c?"":x(t)),children:c?"Pinned":"Pin"})]})},x(t))})})}),e.jsxs(C,{title:"API call",actions:s.offers.length>0&&e.jsx(T,{size:"sm","aria-label":"Route the call",value:i,onChange:o,options:[{value:"",label:"Best provider (automatic)"},...s.offers.map(t=>({value:x(t),label:y(t)}))]}),children:[e.jsx("p",{className:"gc-fineprint",children:l?e.jsxs(e.Fragment,{children:["Pinned to ",y(l)," with ",e.jsx("code",{children:L(p,10,12)}),"."]}):e.jsxs(e.Fragment,{children:["The gateway picks the best provider for ",e.jsx("code",{children:s.id})," under your routing policy."]})}),e.jsx(ue,{id:"gc-model-call",model:p,format:g,unsupported:`${P[s.type]} models are not served through the gateway's /v1 API.`})]})]})}export{Me as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,u as te,D as ae,r as C,ak as q,ac as I,as as ne,at as re,v as w,X as se,au as y,B as N,av as ie,T as oe,C as le,aq as M,aw as p,ax as ce,ah as de,ay as he,q as ue,az as we,aA as fe,ag as F,aB as H,aC as R,Y as $}from"./index-
|
|
1
|
+
import{j as e,u as te,D as ae,r as C,ak as q,ac as I,as as ne,at as re,v as w,X as se,au as y,B as N,av as ie,T as oe,C as le,aq as M,aw as p,ax as ce,ah as de,ay as he,q as ue,az as we,aA as fe,ag as F,aB as H,aC as R,Y as $}from"./index-C21bvTBH.js";import{u as K,a as V,T as X,D as k,s as Z}from"./useTx-Cp52G7Yo.js";import{a as ge,C as G}from"./ConnectWallet-QN7kfDQq.js";import{W as me,u as J,c as L,b as ye,r as Q}from"./en_US-Y4ZOVFV4-3vDquI1C.js";import"./clsx-B-dksMZM.js";import"./index-DqHGr8d4.js";import"./index-BwpQbdIU.js";async function U(s,i,a){let c=await R.sync(s,i);for(let d=0;d<3&&!y(c.operator??p,a??p);d+=1)await new Promise(n=>setTimeout(n,3500)),c=await R.sync(s,i);return c}function ee(s){const i=L(),a=q(s,"deposits");return async c=>{if(!a)throw new M("The gateway did not report the deposits contract address.",!1);const[d,n]=await Promise.all([Q(i,{address:a,abi:k,functionName:"getOperator",args:[c],chainId:s.chainId}),Q(i,{address:a,abi:k,functionName:"getOperatorNonce",args:[c],chainId:s.chainId})]);return{operator:y(d,p)?null:d,nonce:n}}}function pe({workspaceId:s,state:i,chain:a,onChanged:c,onStale:d}){const{address:n}=J(),W=L(),o=K(a.chainId),{writeContractAsync:B}=V(),{signMessageAsync:D}=ye(),{me:z}=te(),E=ae(),v=ee(a),[x,h]=C.useState(!1),[f,b]=C.useState(!1),[g,u]=C.useState(null),m=q(a,"deposits");if(!m)return e.jsx(I,{tone:"warning",children:"The gateway did not report the deposits contract address."});if(!n)return e.jsx(G,{label:"Connect the wallet to authorize"});const j=ne(i,n);async function A(r){try{const t=await R.authorize(s,r);return h(!1),t}catch(t){return $(t,"reauth_required")?(h("any"),o.setError(null),null):$(t,"reauth_other_credential")?(h("other"),o.setError(null),null):($(t,"operator_already_set")&&d(),o.setError(F(t)),null)}}async function S(r){u(r);let t=await A(r);if(!t)return;const O={depositsContract:m,chainId:a.chainId,operator:r},Y=await o.run([{label:"Authorize wallet",check:async()=>{try{H(t,await v(t.buyer),O)}catch(P){if(!(P instanceof M)||!P.retryAuth)throw P;o.setStatus("The operator nonce changed; getting a fresh authorization…");const _=await R.authorize(s,r);H(_,await v(_.buyer),O),t=_}await Z(W,{account:n,address:m,abi:k,functionName:"setOperator",args:[t.buyer,r,BigInt(t.nonce),t.signature],chainId:a.chainId})},send:()=>B({address:m,abi:k,functionName:"setOperator",args:[t.buyer,r,BigInt(t.nonce),t.signature],chainId:a.chainId})}],{onStale:d});Y&&c(await U(s,Y,r))}async function l(r){b(!0),o.setError(null);try{const t=r==="passkey"?await ce():await de(n,O=>D({message:O}));if(he(t,z.member.id),E.setQueryData(ue.me,t),h(!1),g&&n&&!y(g,n)){o.setError(`Confirmed. Switch back to ${w(g)}, then authorize it.`);return}await S(g??n)}catch(t){o.setError(fe(t)?we:F(t))}finally{b(!1)}}const T=re(i);return e.jsxs("div",{className:"gc-stack",children:[e.jsxs("p",{children:["Authorize ",e.jsx("code",{children:w(n)})," to withdraw this workspace's funds and claim its ANTS rewards. It will be the only wallet able to transfer or remove the role later."]}),T.length>0&&e.jsx("ul",{className:"gc-fineprint",children:T.map(r=>e.jsxs("li",{children:[e.jsx("code",{children:w(r.address)})," ",r.ready?"can be authorized":`can be authorized from ${se(r.eligibleAt)}`,y(r.address,n)?" (connected)":""]},r.address))}),j&&e.jsx(I,{tone:"warning",children:j}),x&&e.jsx(I,{tone:"info",title:"Confirm it is you",children:e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsx("span",{children:x==="other"?`Confirm with a different sign-in method than ${w(g??n)}, the wallet you are authorizing: a passkey, or another of your wallets (connect it, confirm, then switch back).`:"Authorizing a withdrawal wallet needs a fresh sign-in."}),e.jsxs("div",{className:"gc-inline gc-inline--wrap",children:[e.jsx(N,{size:"sm",disabled:f,onClick:()=>void l("passkey"),children:"Confirm with a passkey"}),e.jsx(N,{size:"sm",variant:"outline",disabled:f,onClick:()=>void l("wallet"),children:f?"Check your wallet…":`Confirm with ${w(n)}`})]})]})}),e.jsx(X,{chain:a,runner:o,done:"Wallet authorized."}),e.jsx(N,{fullWidth:!0,disabled:o.running||f||!!j,onClick:()=>void S(n),children:o.running?"Working…":"Authorize this wallet"}),e.jsxs("p",{className:"gc-fineprint",children:["You will sign in again, then confirm one transaction from this wallet (it pays the network fee in ETH on ",a.name,")."]})]})}function xe({workspaceId:s,state:i,chain:a,onChanged:c,onStale:d}){const{address:n}=J(),W=L(),o=K(a.chainId),{writeContractAsync:B}=V(),D=ee(a),[z,E]=C.useState(""),[v,x]=C.useState(!1),[h,f]=C.useState(null),b=q(a,"deposits"),g=ie(i,n);if(!b)return e.jsx(I,{tone:"warning",children:"The gateway did not report the deposits contract address."});if(!n)return e.jsx(G,{label:`Connect ${w(i.operator)} to manage it`});if(!g.canManage)return e.jsx(I,{tone:"warning",children:g.manageHint??"Only the authorized wallet can transfer or remove the role."});const u=z.trim(),m=/^0x[0-9a-fA-F]{40}$/.test(u)&&!y(u,p),j=i.eligibleWallets.some(l=>y(l.address,u)),A=y(u,i.buyer);async function S(l){f(null);const T=await o.run([{label:l===p?"Remove authorized wallet":"Transfer authorization",check:async()=>{const r=await D(i.buyer);if(!y(r.operator,n))throw new M(`The authorized wallet is now ${r.operator?w(r.operator):"not set"}, not the connected wallet. The panel now shows it.`,!0);await Z(W,{account:n,address:b,abi:k,functionName:"transferOperator",args:[i.buyer,l],chainId:a.chainId})},send:()=>B({address:b,abi:k,functionName:"transferOperator",args:[i.buyer,l],chainId:a.chainId})}],{onStale:d});T&&(E(""),x(!1),c(await U(s,T,l===p?null:l)))}return e.jsxs("div",{className:"gc-stack",children:[e.jsx("p",{children:"The connected wallet is the authorized wallet. You can hand the role to another wallet or remove it. Both are immediate and only the new wallet (or, after removal, the organization owner through the gateway) can change it again."}),e.jsx(oe,{label:"New authorized wallet",placeholder:"0x…",value:z,onChange:l=>{E(l.target.value),x(!1)},error:z&&!m?"Enter a 0x wallet address.":A?"That is the workspace wallet itself; the gateway CLI handles that case.":void 0}),m&&!A&&!j&&e.jsxs("label",{className:"gc-inline",children:[e.jsx("input",{type:"checkbox",checked:v,onChange:l=>x(l.target.checked)}),e.jsxs("span",{children:[w(u)," is not one of your sign-in wallets. I control it, or trust whoever does with this workspace's withdrawals and rewards."]})]}),e.jsx(X,{chain:a,runner:o,done:"Authorized wallet updated."}),e.jsxs("div",{className:"gc-inline gc-inline--wrap",children:[e.jsx(N,{disabled:o.running||!m||A||!j&&!v,onClick:()=>f("transfer"),children:"Transfer authorization"}),e.jsx(N,{variant:"outline",disabled:o.running,onClick:()=>f("clear"),children:"Remove authorized wallet"})]}),e.jsx(le,{isOpen:h!==null,onClose:()=>f(null),tone:"danger",title:h==="clear"?"Remove the authorized wallet?":`Transfer to ${w(u)}?`,confirmLabel:h==="clear"?"Remove":"Transfer",body:h==="clear"?"Nobody will be able to withdraw or claim rewards until the organization owner authorizes a wallet again through the gateway. Requests keep working.":`${w(u)} will receive all future withdrawals and ANTS rewards, and only it can change this again. Your connected wallet loses the role.`,onConfirm:()=>void S(h==="clear"?p:u)})]})}function Te(s){return e.jsx(me,{chain:s.chain,children:e.jsxs("div",{className:"gc-stack",children:[e.jsx(ge,{}),s.mode==="authorize"?e.jsx(pe,{...s}):e.jsx(xe,{...s})]})})}export{Te as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as o,ac as l,v as n,B as i,x as s}from"./index-
|
|
1
|
+
import{j as o,ac as l,v as n,B as i,x as s}from"./index-C21bvTBH.js";import{C as c}from"./ConnectWallet-QN7kfDQq.js";function p({gate:r,state:t,connected:e,onAuthorize:a}){return o.jsxs("div",{className:"gc-stack",children:[o.jsx(l,{tone:r.operator?"warning":"info",title:r.operator?"Use the authorized wallet":"No authorized wallet",children:r.reason}),r.operator&&!e&&o.jsx(c,{label:`Connect ${n(r.operator)}`}),!r.operator&&(t==null?void 0:t.canAuthorize)&&o.jsx(i,{fullWidth:!0,onClick:a??(()=>s("wallet")),children:"Authorize a wallet"})]})}export{p as O};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var fe=s=>{throw TypeError(s)};var ee=(s,t,r)=>t.has(s)||fe("Cannot "+r);var l=(s,t,r)=>(ee(s,t,"read from private field"),r?r.call(s):t.get(s)),v=(s,t,r)=>t.has(s)?fe("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,r),y=(s,t,r,a)=>(ee(s,t,"write to private field"),a?a.call(s,r):t.set(s,r),r),k=(s,t,r)=>(ee(s,t,"access private method"),r);import{bC as $e,bD as oe,bE as Me,bF as Qe,bu as Oe,D as Te,bG as Le,bH as _e,r as E,bI as Pe,bJ as Fe,bK as Ie,bL as ze,bM as we,bN as De,bO as He,a7 as Ke,l as $,u as Ee,bP as ve,j as e,B as se,x as te,I as P,m as Ue,bQ as xe,bR as je,a as We,i as Ge,aK as Ve,bS as Je,ad as Xe,aa as re,e as X,q as Y,d as ae,bT as Ye,b as Ze,P as ke,ac as Z,f as b,N as F,S as qe,g as z,k as I,L as pe,n as ye,bU as A,E as es,t as Ne,bV as ss}from"./index-BC-1LZkB.js";import{U as ts,M as rs,c as as}from"./UsageByModel-BEa6PT2A.js";import{g as is}from"./usage-kR1h5urb.js";import{S as ns}from"./Segmented-DfgcyK0R.js";import{c as os}from"./Charts-ogViQ7jC.js";import"./roving-DkptacxO.js";function Re(s,t){const r=new Set(t);return s.filter(a=>!r.has(a))}function ls(s,t,r){const a=s.slice(0);return a[t]=r,a}var Q,m,T,L,x,q,D,H,K,U,p,le,ce,ue,de,he,Se,cs=(Se=class extends $e{constructor(t,r,a){super();v(this,p);v(this,Q);v(this,m);v(this,T);v(this,L);v(this,x);v(this,q);v(this,D);v(this,H);v(this,K);v(this,U,[]);y(this,Q,t),y(this,L,a),y(this,T,[]),y(this,x,[]),y(this,m,[]),this.setQueries(r)}onSubscribe(){this.listeners.size===1&&l(this,x).forEach(t=>{t.subscribe(r=>{k(this,p,de).call(this,t,r)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,l(this,x).forEach(t=>{t.destroy()})}setQueries(t,r){y(this,T,t),y(this,L,r),oe.batch(()=>{const a=l(this,x),o=k(this,p,ue).call(this,l(this,T));o.forEach(d=>d.observer.setOptions(d.defaultedQueryOptions));const i=o.map(d=>d.observer),n=i.map(d=>d.getCurrentResult()),c=a.length!==i.length,N=i.some((d,S)=>d!==a[S]),R=c||N,_=R?!0:n.some((d,S)=>{const C=l(this,m)[S];return!C||!Me(d,C)});!R&&!_||(R&&(y(this,U,o),y(this,x,i)),y(this,m,n),this.hasListeners()&&(R&&(Re(a,i).forEach(d=>{d.destroy()}),Re(i,a).forEach(d=>{d.subscribe(S=>{k(this,p,de).call(this,d,S)})})),k(this,p,he).call(this)))})}getCurrentResult(){return l(this,m)}getQueries(){return l(this,x).map(t=>t.getCurrentQuery())}getObservers(){return l(this,x)}getOptimisticResult(t,r){const a=k(this,p,ue).call(this,t),o=a.map(n=>n.observer.getOptimisticResult(n.defaultedQueryOptions)),i=a.map(n=>n.defaultedQueryOptions.queryHash);return[o,n=>k(this,p,ce).call(this,n??o,r,i),()=>k(this,p,le).call(this,o,a)]}},Q=new WeakMap,m=new WeakMap,T=new WeakMap,L=new WeakMap,x=new WeakMap,q=new WeakMap,D=new WeakMap,H=new WeakMap,K=new WeakMap,U=new WeakMap,p=new WeakSet,le=function(t,r){return r.map((a,o)=>{const i=t[o];return a.defaultedQueryOptions.notifyOnChangeProps?i:a.observer.trackResult(i,n=>{r.forEach(c=>{c.observer.trackProp(n)})})})},ce=function(t,r,a){if(r){const o=l(this,K),i=a!==void 0&&o!==void 0&&(o.length!==a.length||a.some((n,c)=>n!==o[c]));return(!l(this,q)||l(this,m)!==l(this,H)||i||r!==l(this,D))&&(y(this,D,r),y(this,H,l(this,m)),a!==void 0&&y(this,K,a),y(this,q,Qe(l(this,q),r(t)))),l(this,q)}return t},ue=function(t){const r=new Map;l(this,x).forEach(o=>{const i=o.options.queryHash;if(!i)return;const n=r.get(i);n?n.push(o):r.set(i,[o])});const a=[];return t.forEach(o=>{var N;const i=l(this,Q).defaultQueryOptions(o),c=((N=r.get(i.queryHash))==null?void 0:N.shift())??new Oe(l(this,Q),i);a.push({defaultedQueryOptions:i,observer:c})}),a},de=function(t,r){const a=l(this,x).indexOf(t);a!==-1&&(y(this,m,ls(l(this,m),a,r)),k(this,p,he).call(this))},he=function(){var t;if(this.hasListeners()){const r=l(this,q),a=k(this,p,le).call(this,l(this,m),l(this,U)),o=k(this,p,ce).call(this,a,(t=l(this,L))==null?void 0:t.combine);r!==o&&oe.batch(()=>{this.listeners.forEach(i=>{i(l(this,m))})})}},Se);function us({queries:s,...t},r){const a=Te(),o=Le(),i=_e(),n=E.useMemo(()=>s.map(h=>{const g=a.defaultQueryOptions(h);return g._optimisticResults=o?"isRestoring":"optimistic",g}),[s,a,o]);n.forEach(h=>{Pe(h);const g=a.getQueryCache().get(h.queryHash);Fe(h,i,g)}),Ie(i);const[c]=E.useState(()=>new cs(a,n,t)),[N,R,_]=c.getOptimisticResult(n,t.combine),d=!o&&t.subscribed!==!1;E.useSyncExternalStore(E.useCallback(h=>d?c.subscribe(oe.batchCalls(h)):ze,[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),E.useEffect(()=>{c.setQueries(n,t)},[n,t,c]);const C=N.some((h,g)=>we(n[g],h))?N.flatMap((h,g)=>{const f=n[g];if(f&&we(f,h)){const W=new Oe(a,f);return De(f,W,i)}return[]}):[];if(C.length>0)throw Promise.all(C);const O=N.find((h,g)=>{const f=n[g];return f&&He({result:h,errorResetBoundary:i,throwOnError:f.throwOnError,query:a.getQueryCache().get(f.queryHash),suspense:f.suspense})});if(O!=null&&O.error)throw O.error;return R(_())}const ds=.8;function hs(s,t){if(!s)return[];const r=[];for(const[a,o]of t){const i=s[a];if(i===null||o===null)continue;const n=$(i),c=n===0?1:o/n;c>=ds&&r.push({period:a,label:Ke[a],spent:o,limit:n,fraction:c,reached:c>=1})}return r}function ps(s,t,r){const a=t/r,o=a>0?s/a:null,i=o===null?s<1:o<7;return{available:s,dailySpend:a,days:o,low:i}}function ie({title:s,body:t,action:r}){return e.jsxs("div",{className:"gc-setup",children:[e.jsxs("div",{className:"gc-setup__text",children:[e.jsx("div",{className:"gc-setup__title",children:s}),e.jsx("div",{className:"gc-setup__body",children:t})]}),r]})}const ys=e.jsxs("svg",{width:"28",height:"24",viewBox:"0 0 28 24","aria-hidden":"true",className:"gc-empty-tile__bars",children:[e.jsx("rect",{x:"2",y:"12",width:"6",height:"12",rx:"1.5"}),e.jsx("rect",{x:"11",y:"6",width:"6",height:"18",rx:"1.5"}),e.jsx("rect",{x:"20",y:"0",width:"6",height:"24",rx:"1.5"})]}),gs=[{id:"keys",title:"API keys",body:"Create keys for apps and people, with budgets and their own routing."},{id:"chat",title:"Chat",body:"Try any model on the network and see which seller answers."},{id:"wallet",title:"Wallet & Funding",body:"Fund the workspace wallet and authorize who can withdraw."},{id:"routing",title:"Routing",body:"Choose which sellers may serve, price caps, TEE only, fallbacks."},{id:"providers",title:"Providers",body:"Every provider this gateway sees, with prices, trust and latency."},{id:"models",title:"Models",body:"Every model on the network, its providers and a ready-to-run API call."},{id:"presets",title:"Presets",body:"Save a model, system prompt and parameters as @preset/<name>."},{id:"members",title:"Members",body:"Invite people and choose what each of them may do."},{id:"activity",title:"Activity",body:"Spend, requests and tokens by model, key and member."},{id:"settings",title:"Settings",body:"Buyer settings every policy starts from, observability and sign-in."}];function ms({hasKeys:s,fundsKnown:t,funded:r}){const{workspace:a,viewer:o}=Ee(),i=gs.filter(n=>ve(n.id,o));return e.jsxs(e.Fragment,{children:[!s&&e.jsx(ie,{title:"No API keys yet",body:"Create your first API key to start using this workspace from your apps.",action:e.jsx(se,{variant:"brand",leadingIcon:e.jsx(P.plus,{size:14}),onClick:()=>te("keys?new=1"),children:"Create API key"})}),t&&!r&&ve("wallet",o)&&e.jsx(ie,{title:"No funds yet",body:e.jsxs(e.Fragment,{children:["Requests to paid sellers are paid in USDC from the ",a.name," wallet. Free sellers work without funds."]}),action:e.jsx(se,{variant:"outline",onClick:()=>te("wallet?fund=1"),children:"Add funds"})}),Ue(o)&&e.jsx(ie,{title:"Review buyer settings",body:"Price caps, minimum trust (60 by default) and verification apply to every key.",action:e.jsx(se,{variant:"ghost",onClick:()=>te("settings"),children:"Open settings"})}),e.jsxs("div",{className:"gc-section-head",children:[e.jsx("h2",{children:"This week's usage"}),e.jsxs("a",{className:"gc-link",href:je("activity"),onClick:xe("activity"),children:["View activity ",e.jsx(P.right,{size:13})]})]}),e.jsx("div",{className:"gc-grid gc-grid--3",children:["No spend this week","No requests this week","No tokens this week"].map(n=>e.jsxs("div",{className:"gc-empty-tile",children:[ys,e.jsx("span",{children:n})]},n))}),e.jsx("div",{className:"gc-grid gc-grid--3",children:i.map(n=>{const c=P[n.id]??P.overview;return e.jsxs("a",{className:"gc-section-card",href:je(n.id),onClick:xe(n.id),children:[e.jsx("span",{className:"gc-section-card__icon",children:e.jsx(c,{size:16})}),e.jsxs("span",{className:"gc-section-card__text",children:[e.jsx("span",{className:"gc-section-card__title",children:n.title}),e.jsx("span",{className:"gc-section-card__body",children:n.body})]}),e.jsx(P.right,{size:14,className:"gc-section-card__chevron"})]},n.id)})})]})}const ne=[{period:"daily",label:"Today"},{period:"weekly",label:"This week"},{period:"monthly",label:"This month"}];function bs(s,t){return t&&s!==null?s/t:t===0?1:null}function fs({label:s,spent:t,limit:r}){const a=r===null?null:$(r);return e.jsx(qe,{label:`Spend ${s.toLowerCase()}`,value:t===null?"…":b(t),sub:a===null?"No budget":`of ${b(a)} budget`,meter:bs(t,a)})}function ws(s){return s?s.days===null?"No recent spend":Ae(s.days):"…"}function vs({wallet:s,funds:t}){return s.isLoading?e.jsx(pe,{rows:1,height:48}):s.error?e.jsx(ye,{error:s.error,onRetry:()=>void s.refetch()}):s.data?e.jsxs("div",{className:"gc-grid gc-grid--4 gc-figures",children:[e.jsx(A,{label:"Available",value:b(s.data.available),strong:!0}),e.jsx(A,{label:"Reserved in channels",value:b(s.data.reserved)}),e.jsx(A,{label:"In wallet, not deposited",value:b(s.data.walletUsdc)}),e.jsx(A,{label:"Runway",value:ws(t)})]}):null}function xs({status:s}){if(s.isLoading)return e.jsx(pe,{rows:1,height:40});if(s.error)return e.jsx(ye,{error:s.error});if(!s.data)return null;const{buyer:t}=s.data;return e.jsxs("div",{className:"gc-grid gc-grid--4 gc-figures",children:[e.jsx(A,{label:"Buyer",value:t.reachable?e.jsx(Ne,{tone:"success",children:"Connected"}):e.jsx(Ne,{tone:"danger",children:"Unreachable"})}),e.jsx(A,{label:"Sellers seen",value:z(t.peers)}),e.jsx(A,{label:"DHT nodes",value:z(t.dhtNodes)}),e.jsx(A,{label:"Buyer uptime",value:t.uptimeMs===null?"—":ss(t.uptimeMs)})]})}function qs(){var me,be;const{workspace:s,viewer:t}=Ee(),r=We(),a=Ge(t),o=Ve(s.id),i=Je(s.id,a),n=Xe(),c=Date.now(),[N]=E.useState(c),[R,_]=E.useState("spend"),d=E.useMemo(()=>({...r}),[r.workspace,r.member]),S=us({queries:ne.map(({period:u})=>{const w=re(u,c);return{queryKey:Y.usage({...r,from:w,groupBy:"day"}),queryFn:()=>X.usage.report({...r,from:w,groupBy:"day"})}})}),C=re("monthly",c),O=ae({queryKey:Y.usage({...r,from:C,groupBy:"key"}),queryFn:()=>X.usage.report({...r,from:C,groupBy:"key"})}),h=ae({queryKey:Y.usage({...r,from:C,groupBy:"model"}),queryFn:()=>X.usage.report({...r,from:C,groupBy:"model"})}),g=re("daily",c),f=g-7*864e5,W=ae({queryKey:Y.usage({workspace:s.id,from:f,to:g,groupBy:"day"}),queryFn:()=>X.usage.report({workspace:s.id,from:f,to:g-1,groupBy:"day"}),enabled:a}),B=Ye(),G=Ze({workspace:s.id}),V=((me=o.data)==null?void 0:me.limits)??null,M=(be=S[2])==null?void 0:be.data,ge=u=>{var J;const w=(J=S[u])==null?void 0:J.data;return w?$(w.totals.spent):null},Be=hs(V,ne.map(({period:u},w)=>[u,ge(w)])),j=i.data&&W.data?ps($(i.data.available),$(W.data.totals.spent),7):null;if(M!==void 0&&M.totals.requests===0&&G.data!==void 0&&G.data.every(u=>u.usage.requests===0)){const u=(G.data??[]).some(w=>w.status==="active"&&!w.label.startsWith("Web chat"));return e.jsxs("div",{className:"gc-page",children:[e.jsx(ke,{title:s.name,description:"Nothing has run through this workspace yet. Here is where to start."}),e.jsx(ms,{hasKeys:G.isLoading||u,fundsKnown:a&&i.data!==void 0,funded:i.data?$(i.data.available)>0:!0})]})}return e.jsxs("div",{className:"gc-page",children:[e.jsx(ke,{title:"Overview",description:`${s.name} workspace${r.member?" · your usage":""}`}),(j==null?void 0:j.low)&&e.jsx(Z,{tone:j.days!==null&&j.days<1?"danger":"warning",title:"Balance is running low",action:e.jsx(F,{to:"wallet",children:"Add funds"}),children:j.days===null?`Only ${b(j.available)} is available.`:`${b(j.available)} available lasts about ${Ae(j.days)} at last week's pace (${b(j.dailySpend)} a day).`}),B.currentMissingOperator&&e.jsx(Z,{tone:"warning",title:"No authorized wallet",action:e.jsx(F,{to:"wallet",children:B.canAuthorize?"Authorize a wallet":"View wallet"}),children:B.canAuthorize?`Nobody can withdraw ${s.name}'s funds or claim its ANTS rewards until you authorize one of your wallets. Requests keep working.`:`Nobody can withdraw ${s.name}'s funds or claim its ANTS rewards until the organization owner authorizes a wallet. Requests keep working.`}),B.withdrawable.count>0&&e.jsxs(Z,{tone:"warning",title:`${B.withdrawable.count} channel${B.withdrawable.count===1?"":"s"} ready to withdraw`,action:e.jsx(F,{to:"wallet",children:"Withdraw"}),children:["About ",b(B.withdrawable.amount)," of unused reserve can return to the balance."]}),Be.map(u=>e.jsx(Z,{tone:u.reached?"danger":"warning",title:u.reached?`${u.label} budget reached`:`${u.label} budget almost used`,children:u.reached?`${s.name} has spent ${b(u.spent)} of its ${b(u.limit)} ${u.label.toLowerCase()} budget. New requests are refused until the period resets.`:`${Math.round(u.fraction*100)}% of the ${b(u.limit)} ${u.label.toLowerCase()} budget is used.`},u.period)),e.jsxs("div",{className:"gc-grid gc-grid--4",children:[ne.map(({period:u,label:w},J)=>e.jsx(fs,{label:w,spent:ge(J),limit:(V==null?void 0:V[u])??null},u)),e.jsx(qe,{label:"Requests this month",value:M?z(M.totals.requests):"…",sub:M?`${z(M.totals.failedRequests)} failed`:void 0})]}),e.jsx(I,{title:"Last 7 days",description:as(R,"7d"),actions:e.jsxs(e.Fragment,{children:[e.jsx(ns,{label:"Chart metric",value:R,onChange:_,options:rs}),e.jsx(F,{to:"activity",children:"All activity"})]}),children:e.jsx(ts,{filter:d,range:"7d",now:N,metric:R,height:200})}),a&&e.jsx(I,{title:"Balance",actions:e.jsx(F,{to:"wallet",children:"Add funds"}),children:e.jsx(vs,{wallet:i,funds:j})}),e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(I,{title:"Top keys this month",children:e.jsx(Ce,{report:O.data,loading:O.isLoading,error:O.error,empty:"No spend this month."})}),e.jsx(I,{title:"Top models this month",children:e.jsx(Ce,{report:h.data,loading:h.isLoading,error:h.error,empty:"No spend this month."})})]}),e.jsx(I,{title:"Gateway",children:e.jsx(xs,{status:n})})]})}function Ae(s){return s<1?"under a day":s<60?`${Math.floor(s)} day${Math.floor(s)===1?"":"s"}`:`${Math.floor(s/30)} months`}function Ce({report:s,loading:t,error:r,empty:a}){if(t)return e.jsx(pe,{rows:4,height:22});if(r)return e.jsx(ye,{error:r});const o=((s==null?void 0:s.groups)??[]).map(i=>({label:is(i),value:$(i.spent),sub:`${z(i.requests)} requests`})).filter(i=>i.value>0).sort((i,n)=>n.value-i.value).slice(0,5);return o.length===0?e.jsx(es,{title:a}):e.jsx(os,{items:o,format:b})}export{qs as default};
|
|
1
|
+
var fe=s=>{throw TypeError(s)};var ee=(s,t,r)=>t.has(s)||fe("Cannot "+r);var l=(s,t,r)=>(ee(s,t,"read from private field"),r?r.call(s):t.get(s)),v=(s,t,r)=>t.has(s)?fe("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,r),y=(s,t,r,a)=>(ee(s,t,"write to private field"),a?a.call(s,r):t.set(s,r),r),k=(s,t,r)=>(ee(s,t,"access private method"),r);import{bC as $e,bD as oe,bE as Me,bF as Qe,bu as Oe,D as Te,bG as Le,bH as _e,r as E,bI as Pe,bJ as Fe,bK as Ie,bL as ze,bM as we,bN as De,bO as He,a7 as Ke,l as $,u as Ee,bP as ve,j as e,B as se,x as te,I as P,m as Ue,bQ as xe,bR as je,a as We,i as Ge,aK as Ve,bS as Je,ad as Xe,aa as re,e as X,q as Y,d as ae,bT as Ye,b as Ze,P as ke,ac as Z,f as b,N as F,S as qe,g as z,k as I,L as pe,n as ye,bU as A,E as es,t as Ne,bV as ss}from"./index-C21bvTBH.js";import{U as ts,M as rs,c as as}from"./UsageByModel-jvNkVE4M.js";import{g as is}from"./usage-MPZYg7D2.js";import{S as ns}from"./Segmented-BJmgB5-Y.js";import{c as os}from"./Charts-NmIMcccv.js";import"./roving-DkptacxO.js";function Re(s,t){const r=new Set(t);return s.filter(a=>!r.has(a))}function ls(s,t,r){const a=s.slice(0);return a[t]=r,a}var Q,m,T,L,x,q,D,H,K,U,p,le,ce,ue,de,he,Se,cs=(Se=class extends $e{constructor(t,r,a){super();v(this,p);v(this,Q);v(this,m);v(this,T);v(this,L);v(this,x);v(this,q);v(this,D);v(this,H);v(this,K);v(this,U,[]);y(this,Q,t),y(this,L,a),y(this,T,[]),y(this,x,[]),y(this,m,[]),this.setQueries(r)}onSubscribe(){this.listeners.size===1&&l(this,x).forEach(t=>{t.subscribe(r=>{k(this,p,de).call(this,t,r)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,l(this,x).forEach(t=>{t.destroy()})}setQueries(t,r){y(this,T,t),y(this,L,r),oe.batch(()=>{const a=l(this,x),o=k(this,p,ue).call(this,l(this,T));o.forEach(d=>d.observer.setOptions(d.defaultedQueryOptions));const i=o.map(d=>d.observer),n=i.map(d=>d.getCurrentResult()),c=a.length!==i.length,N=i.some((d,S)=>d!==a[S]),R=c||N,_=R?!0:n.some((d,S)=>{const C=l(this,m)[S];return!C||!Me(d,C)});!R&&!_||(R&&(y(this,U,o),y(this,x,i)),y(this,m,n),this.hasListeners()&&(R&&(Re(a,i).forEach(d=>{d.destroy()}),Re(i,a).forEach(d=>{d.subscribe(S=>{k(this,p,de).call(this,d,S)})})),k(this,p,he).call(this)))})}getCurrentResult(){return l(this,m)}getQueries(){return l(this,x).map(t=>t.getCurrentQuery())}getObservers(){return l(this,x)}getOptimisticResult(t,r){const a=k(this,p,ue).call(this,t),o=a.map(n=>n.observer.getOptimisticResult(n.defaultedQueryOptions)),i=a.map(n=>n.defaultedQueryOptions.queryHash);return[o,n=>k(this,p,ce).call(this,n??o,r,i),()=>k(this,p,le).call(this,o,a)]}},Q=new WeakMap,m=new WeakMap,T=new WeakMap,L=new WeakMap,x=new WeakMap,q=new WeakMap,D=new WeakMap,H=new WeakMap,K=new WeakMap,U=new WeakMap,p=new WeakSet,le=function(t,r){return r.map((a,o)=>{const i=t[o];return a.defaultedQueryOptions.notifyOnChangeProps?i:a.observer.trackResult(i,n=>{r.forEach(c=>{c.observer.trackProp(n)})})})},ce=function(t,r,a){if(r){const o=l(this,K),i=a!==void 0&&o!==void 0&&(o.length!==a.length||a.some((n,c)=>n!==o[c]));return(!l(this,q)||l(this,m)!==l(this,H)||i||r!==l(this,D))&&(y(this,D,r),y(this,H,l(this,m)),a!==void 0&&y(this,K,a),y(this,q,Qe(l(this,q),r(t)))),l(this,q)}return t},ue=function(t){const r=new Map;l(this,x).forEach(o=>{const i=o.options.queryHash;if(!i)return;const n=r.get(i);n?n.push(o):r.set(i,[o])});const a=[];return t.forEach(o=>{var N;const i=l(this,Q).defaultQueryOptions(o),c=((N=r.get(i.queryHash))==null?void 0:N.shift())??new Oe(l(this,Q),i);a.push({defaultedQueryOptions:i,observer:c})}),a},de=function(t,r){const a=l(this,x).indexOf(t);a!==-1&&(y(this,m,ls(l(this,m),a,r)),k(this,p,he).call(this))},he=function(){var t;if(this.hasListeners()){const r=l(this,q),a=k(this,p,le).call(this,l(this,m),l(this,U)),o=k(this,p,ce).call(this,a,(t=l(this,L))==null?void 0:t.combine);r!==o&&oe.batch(()=>{this.listeners.forEach(i=>{i(l(this,m))})})}},Se);function us({queries:s,...t},r){const a=Te(),o=Le(),i=_e(),n=E.useMemo(()=>s.map(h=>{const g=a.defaultQueryOptions(h);return g._optimisticResults=o?"isRestoring":"optimistic",g}),[s,a,o]);n.forEach(h=>{Pe(h);const g=a.getQueryCache().get(h.queryHash);Fe(h,i,g)}),Ie(i);const[c]=E.useState(()=>new cs(a,n,t)),[N,R,_]=c.getOptimisticResult(n,t.combine),d=!o&&t.subscribed!==!1;E.useSyncExternalStore(E.useCallback(h=>d?c.subscribe(oe.batchCalls(h)):ze,[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),E.useEffect(()=>{c.setQueries(n,t)},[n,t,c]);const C=N.some((h,g)=>we(n[g],h))?N.flatMap((h,g)=>{const f=n[g];if(f&&we(f,h)){const W=new Oe(a,f);return De(f,W,i)}return[]}):[];if(C.length>0)throw Promise.all(C);const O=N.find((h,g)=>{const f=n[g];return f&&He({result:h,errorResetBoundary:i,throwOnError:f.throwOnError,query:a.getQueryCache().get(f.queryHash),suspense:f.suspense})});if(O!=null&&O.error)throw O.error;return R(_())}const ds=.8;function hs(s,t){if(!s)return[];const r=[];for(const[a,o]of t){const i=s[a];if(i===null||o===null)continue;const n=$(i),c=n===0?1:o/n;c>=ds&&r.push({period:a,label:Ke[a],spent:o,limit:n,fraction:c,reached:c>=1})}return r}function ps(s,t,r){const a=t/r,o=a>0?s/a:null,i=o===null?s<1:o<7;return{available:s,dailySpend:a,days:o,low:i}}function ie({title:s,body:t,action:r}){return e.jsxs("div",{className:"gc-setup",children:[e.jsxs("div",{className:"gc-setup__text",children:[e.jsx("div",{className:"gc-setup__title",children:s}),e.jsx("div",{className:"gc-setup__body",children:t})]}),r]})}const ys=e.jsxs("svg",{width:"28",height:"24",viewBox:"0 0 28 24","aria-hidden":"true",className:"gc-empty-tile__bars",children:[e.jsx("rect",{x:"2",y:"12",width:"6",height:"12",rx:"1.5"}),e.jsx("rect",{x:"11",y:"6",width:"6",height:"18",rx:"1.5"}),e.jsx("rect",{x:"20",y:"0",width:"6",height:"24",rx:"1.5"})]}),gs=[{id:"keys",title:"API keys",body:"Create keys for apps and people, with budgets and their own routing."},{id:"chat",title:"Chat",body:"Try any model on the network and see which seller answers."},{id:"wallet",title:"Wallet & Funding",body:"Fund the workspace wallet and authorize who can withdraw."},{id:"routing",title:"Routing",body:"Choose which sellers may serve, price caps, TEE only, fallbacks."},{id:"providers",title:"Providers",body:"Every provider this gateway sees, with prices, trust and latency."},{id:"models",title:"Models",body:"Every model on the network, its providers and a ready-to-run API call."},{id:"presets",title:"Presets",body:"Save a model, system prompt and parameters as @preset/<name>."},{id:"members",title:"Members",body:"Invite people and choose what each of them may do."},{id:"activity",title:"Activity",body:"Spend, requests and tokens by model, key and member."},{id:"settings",title:"Settings",body:"Buyer settings every policy starts from, observability and sign-in."}];function ms({hasKeys:s,fundsKnown:t,funded:r}){const{workspace:a,viewer:o}=Ee(),i=gs.filter(n=>ve(n.id,o));return e.jsxs(e.Fragment,{children:[!s&&e.jsx(ie,{title:"No API keys yet",body:"Create your first API key to start using this workspace from your apps.",action:e.jsx(se,{variant:"brand",leadingIcon:e.jsx(P.plus,{size:14}),onClick:()=>te("keys?new=1"),children:"Create API key"})}),t&&!r&&ve("wallet",o)&&e.jsx(ie,{title:"No funds yet",body:e.jsxs(e.Fragment,{children:["Requests to paid sellers are paid in USDC from the ",a.name," wallet. Free sellers work without funds."]}),action:e.jsx(se,{variant:"outline",onClick:()=>te("wallet?fund=1"),children:"Add funds"})}),Ue(o)&&e.jsx(ie,{title:"Review buyer settings",body:"Price caps, minimum trust (60 by default) and verification apply to every key.",action:e.jsx(se,{variant:"ghost",onClick:()=>te("settings"),children:"Open settings"})}),e.jsxs("div",{className:"gc-section-head",children:[e.jsx("h2",{children:"This week's usage"}),e.jsxs("a",{className:"gc-link",href:je("activity"),onClick:xe("activity"),children:["View activity ",e.jsx(P.right,{size:13})]})]}),e.jsx("div",{className:"gc-grid gc-grid--3",children:["No spend this week","No requests this week","No tokens this week"].map(n=>e.jsxs("div",{className:"gc-empty-tile",children:[ys,e.jsx("span",{children:n})]},n))}),e.jsx("div",{className:"gc-grid gc-grid--3",children:i.map(n=>{const c=P[n.id]??P.overview;return e.jsxs("a",{className:"gc-section-card",href:je(n.id),onClick:xe(n.id),children:[e.jsx("span",{className:"gc-section-card__icon",children:e.jsx(c,{size:16})}),e.jsxs("span",{className:"gc-section-card__text",children:[e.jsx("span",{className:"gc-section-card__title",children:n.title}),e.jsx("span",{className:"gc-section-card__body",children:n.body})]}),e.jsx(P.right,{size:14,className:"gc-section-card__chevron"})]},n.id)})})]})}const ne=[{period:"daily",label:"Today"},{period:"weekly",label:"This week"},{period:"monthly",label:"This month"}];function bs(s,t){return t&&s!==null?s/t:t===0?1:null}function fs({label:s,spent:t,limit:r}){const a=r===null?null:$(r);return e.jsx(qe,{label:`Spend ${s.toLowerCase()}`,value:t===null?"…":b(t),sub:a===null?"No budget":`of ${b(a)} budget`,meter:bs(t,a)})}function ws(s){return s?s.days===null?"No recent spend":Ae(s.days):"…"}function vs({wallet:s,funds:t}){return s.isLoading?e.jsx(pe,{rows:1,height:48}):s.error?e.jsx(ye,{error:s.error,onRetry:()=>void s.refetch()}):s.data?e.jsxs("div",{className:"gc-grid gc-grid--4 gc-figures",children:[e.jsx(A,{label:"Available",value:b(s.data.available),strong:!0}),e.jsx(A,{label:"Reserved in channels",value:b(s.data.reserved)}),e.jsx(A,{label:"In wallet, not deposited",value:b(s.data.walletUsdc)}),e.jsx(A,{label:"Runway",value:ws(t)})]}):null}function xs({status:s}){if(s.isLoading)return e.jsx(pe,{rows:1,height:40});if(s.error)return e.jsx(ye,{error:s.error});if(!s.data)return null;const{buyer:t}=s.data;return e.jsxs("div",{className:"gc-grid gc-grid--4 gc-figures",children:[e.jsx(A,{label:"Buyer",value:t.reachable?e.jsx(Ne,{tone:"success",children:"Connected"}):e.jsx(Ne,{tone:"danger",children:"Unreachable"})}),e.jsx(A,{label:"Sellers seen",value:z(t.peers)}),e.jsx(A,{label:"DHT nodes",value:z(t.dhtNodes)}),e.jsx(A,{label:"Buyer uptime",value:t.uptimeMs===null?"—":ss(t.uptimeMs)})]})}function qs(){var me,be;const{workspace:s,viewer:t}=Ee(),r=We(),a=Ge(t),o=Ve(s.id),i=Je(s.id,a),n=Xe(),c=Date.now(),[N]=E.useState(c),[R,_]=E.useState("spend"),d=E.useMemo(()=>({...r}),[r.workspace,r.member]),S=us({queries:ne.map(({period:u})=>{const w=re(u,c);return{queryKey:Y.usage({...r,from:w,groupBy:"day"}),queryFn:()=>X.usage.report({...r,from:w,groupBy:"day"})}})}),C=re("monthly",c),O=ae({queryKey:Y.usage({...r,from:C,groupBy:"key"}),queryFn:()=>X.usage.report({...r,from:C,groupBy:"key"})}),h=ae({queryKey:Y.usage({...r,from:C,groupBy:"model"}),queryFn:()=>X.usage.report({...r,from:C,groupBy:"model"})}),g=re("daily",c),f=g-7*864e5,W=ae({queryKey:Y.usage({workspace:s.id,from:f,to:g,groupBy:"day"}),queryFn:()=>X.usage.report({workspace:s.id,from:f,to:g-1,groupBy:"day"}),enabled:a}),B=Ye(),G=Ze({workspace:s.id}),V=((me=o.data)==null?void 0:me.limits)??null,M=(be=S[2])==null?void 0:be.data,ge=u=>{var J;const w=(J=S[u])==null?void 0:J.data;return w?$(w.totals.spent):null},Be=hs(V,ne.map(({period:u},w)=>[u,ge(w)])),j=i.data&&W.data?ps($(i.data.available),$(W.data.totals.spent),7):null;if(M!==void 0&&M.totals.requests===0&&G.data!==void 0&&G.data.every(u=>u.usage.requests===0)){const u=(G.data??[]).some(w=>w.status==="active"&&!w.label.startsWith("Web chat"));return e.jsxs("div",{className:"gc-page",children:[e.jsx(ke,{title:s.name,description:"Nothing has run through this workspace yet. Here is where to start."}),e.jsx(ms,{hasKeys:G.isLoading||u,fundsKnown:a&&i.data!==void 0,funded:i.data?$(i.data.available)>0:!0})]})}return e.jsxs("div",{className:"gc-page",children:[e.jsx(ke,{title:"Overview",description:`${s.name} workspace${r.member?" · your usage":""}`}),(j==null?void 0:j.low)&&e.jsx(Z,{tone:j.days!==null&&j.days<1?"danger":"warning",title:"Balance is running low",action:e.jsx(F,{to:"wallet",children:"Add funds"}),children:j.days===null?`Only ${b(j.available)} is available.`:`${b(j.available)} available lasts about ${Ae(j.days)} at last week's pace (${b(j.dailySpend)} a day).`}),B.currentMissingOperator&&e.jsx(Z,{tone:"warning",title:"No authorized wallet",action:e.jsx(F,{to:"wallet",children:B.canAuthorize?"Authorize a wallet":"View wallet"}),children:B.canAuthorize?`Nobody can withdraw ${s.name}'s funds or claim its ANTS rewards until you authorize one of your wallets. Requests keep working.`:`Nobody can withdraw ${s.name}'s funds or claim its ANTS rewards until the organization owner authorizes a wallet. Requests keep working.`}),B.withdrawable.count>0&&e.jsxs(Z,{tone:"warning",title:`${B.withdrawable.count} channel${B.withdrawable.count===1?"":"s"} ready to withdraw`,action:e.jsx(F,{to:"wallet",children:"Withdraw"}),children:["About ",b(B.withdrawable.amount)," of unused reserve can return to the balance."]}),Be.map(u=>e.jsx(Z,{tone:u.reached?"danger":"warning",title:u.reached?`${u.label} budget reached`:`${u.label} budget almost used`,children:u.reached?`${s.name} has spent ${b(u.spent)} of its ${b(u.limit)} ${u.label.toLowerCase()} budget. New requests are refused until the period resets.`:`${Math.round(u.fraction*100)}% of the ${b(u.limit)} ${u.label.toLowerCase()} budget is used.`},u.period)),e.jsxs("div",{className:"gc-grid gc-grid--4",children:[ne.map(({period:u,label:w},J)=>e.jsx(fs,{label:w,spent:ge(J),limit:(V==null?void 0:V[u])??null},u)),e.jsx(qe,{label:"Requests this month",value:M?z(M.totals.requests):"…",sub:M?`${z(M.totals.failedRequests)} failed`:void 0})]}),e.jsx(I,{title:"Last 7 days",description:as(R,"7d"),actions:e.jsxs(e.Fragment,{children:[e.jsx(ns,{label:"Chart metric",value:R,onChange:_,options:rs}),e.jsx(F,{to:"activity",children:"All activity"})]}),children:e.jsx(ts,{filter:d,range:"7d",now:N,metric:R,height:200})}),a&&e.jsx(I,{title:"Balance",actions:e.jsx(F,{to:"wallet",children:"Add funds"}),children:e.jsx(vs,{wallet:i,funds:j})}),e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(I,{title:"Top keys this month",children:e.jsx(Ce,{report:O.data,loading:O.isLoading,error:O.error,empty:"No spend this month."})}),e.jsx(I,{title:"Top models this month",children:e.jsx(Ce,{report:h.data,loading:h.isLoading,error:h.error,empty:"No spend this month."})})]}),e.jsx(I,{title:"Gateway",children:e.jsx(xs,{status:n})})]})}function Ae(s){return s<1?"under a day":s<60?`${Math.floor(s)} day${Math.floor(s)===1?"":"s"}`:`${Math.floor(s/30)} months`}function Ce({report:s,loading:t,error:r,empty:a}){if(t)return e.jsx(pe,{rows:4,height:22});if(r)return e.jsx(ye,{error:r});const o=((s==null?void 0:s.groups)??[]).map(i=>({label:is(i),value:$(i.spent),sub:`${z(i.requests)} requests`})).filter(i=>i.value>0).sort((i,n)=>n.value-i.value).slice(0,5);return o.length===0?e.jsx(es,{title:a}):e.jsx(os,{items:o,format:b})}export{qs as default};
|