@antseed/gateway-console 0.1.8 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/dist/assets/Activity-jZYZ0SDm.js +1 -0
  2. package/dist/assets/{Audit-DEeTafQK.js → Audit-C-dFTX_u.js} +1 -1
  3. package/dist/assets/{ChainGate-BGzMcc9t.js → ChainGate-In51TI2h.js} +1 -1
  4. package/dist/assets/ChannelClose-D8CcISX0.js +1 -0
  5. package/dist/assets/{Charts-BqpYsDwi.js → Charts-doK0mDVf.js} +1 -1
  6. package/dist/assets/{Chat-CoYr5t7Q.js → Chat-CaImcsH1.js} +34 -34
  7. package/dist/assets/{ConnectWallet-BPEdComN.js → ConnectWallet-DQ0PC6SO.js} +1 -1
  8. package/dist/assets/{DataTable-nSpXggux.js → DataTable-BTwj5g1m.js} +1 -1
  9. package/dist/assets/{KeyHolder-DaUngSci.js → KeyHolder-D90Uu-Jv.js} +1 -1
  10. package/dist/assets/Keys-B5LppZtn.js +1 -0
  11. package/dist/assets/Logs-Dw4sZ9lo.js +1 -0
  12. package/dist/assets/Members-CnaHKFut.js +1 -0
  13. package/dist/assets/{Migrate-LZPwWSjY.js → Migrate-BQYY5ty3.js} +1 -1
  14. package/dist/assets/Models-zIuHewdV.js +1 -0
  15. package/dist/assets/OperatorActions-DrRpfDBV.js +1 -0
  16. package/dist/assets/{OperatorGateAlert-BTIl2CQW.js → OperatorGateAlert-D92zhyXC.js} +1 -1
  17. package/dist/assets/{Overview-B3WLdQF3.js → Overview-CJmp6b7M.js} +1 -1
  18. package/dist/assets/{PeerPicker-BvexRNjB.js → PeerPicker-BJfjL7Dy.js} +1 -1
  19. package/dist/assets/PolicyEditor-BpoV34ra.js +1 -0
  20. package/dist/assets/{PolicyField-BL2_pz19.js → PolicyField-CfRYcr_J.js} +1 -1
  21. package/dist/assets/Presets-c1J4UwX0.js +4 -0
  22. package/dist/assets/Providers-B0LuYcAw.js +1 -0
  23. package/dist/assets/RequestLog-D2YGgG1C.js +1 -0
  24. package/dist/assets/Rewards-DNNxx3NO.js +2 -0
  25. package/dist/assets/RewardsClaim-nstcyJvi.js +1 -0
  26. package/dist/assets/Routing-B79eDIZL.js +1 -0
  27. package/dist/assets/{Segmented-D-_FvNVa.js → Segmented-BelxPFkk.js} +1 -1
  28. package/dist/assets/SelectField-BWyF8Ku8.js +1 -0
  29. package/dist/assets/Settings-Cws5Z--R.js +7 -0
  30. package/dist/assets/Staking-DHwoflHG.js +1 -0
  31. package/dist/assets/StakingDashboard-CJbBUUQE.css +1 -0
  32. package/dist/assets/StakingDashboard-DtOKTmys.js +1 -0
  33. package/dist/assets/Switch-BwBYBnSS.js +1 -0
  34. package/dist/assets/{Tabs-iPKA2Kfx.js → Tabs-yVL4Cd6z.js} +1 -1
  35. package/dist/assets/TextAreaField-B6jcl4RR.js +1 -0
  36. package/dist/assets/{UsageByModel-CWVN_g_S.js → UsageByModel-DhTF-c1H.js} +1 -1
  37. package/dist/assets/Wallet-QXhhg_E-.js +9 -0
  38. package/dist/assets/{WalletConfirm-PHdM3GaV.js → WalletConfirm-CgWBuaMN.js} +1 -1
  39. package/dist/assets/WalletFunding-Ydd9gD2t.js +1 -0
  40. package/dist/assets/{WalletSignIn-3MlBmMgW.js → WalletSignIn-DvVSFW4u.js} +1 -1
  41. package/dist/assets/Workspaces-DuxGwCQ2.js +1 -0
  42. package/dist/assets/{add-R0POQ3W1.js → add-ChFb9YAz.js} +1 -1
  43. package/dist/assets/{all-wallets-DVwWXGmT.js → all-wallets-rdNweGUd.js} +1 -1
  44. package/dist/assets/{app-store-BiL_qTZd.js → app-store-s294A1qn.js} +1 -1
  45. package/dist/assets/{apple-_Y_Xx6lJ.js → apple-Cs8Kx1eO.js} +1 -1
  46. package/dist/assets/{arrow-bottom-QxKexUBC.js → arrow-bottom-BMmCEQIa.js} +1 -1
  47. package/dist/assets/{arrow-bottom-circle-C-fUzpyi.js → arrow-bottom-circle-CThmnDp3.js} +1 -1
  48. package/dist/assets/{arrow-left-B5dxgBhW.js → arrow-left-BJxgCTi0.js} +1 -1
  49. package/dist/assets/{arrow-right-B4qewp0i.js → arrow-right-CnLYkBsH.js} +1 -1
  50. package/dist/assets/{arrow-top-BKBiVc06.js → arrow-top-Dc0DLP-U.js} +1 -1
  51. package/dist/assets/{bank-FHD-xNqV.js → bank-CSWOYeMW.js} +1 -1
  52. package/dist/assets/{basic-BccV4Pg1.js → basic-BHdv4O5I.js} +1 -1
  53. package/dist/assets/{browser-CLLI-CzN.js → browser-mp33aPgo.js} +1 -1
  54. package/dist/assets/{bundle-full-C_dLAJOc.js → bundle-full-CDQ5iC5h.js} +1 -1
  55. package/dist/assets/{card-NLpMEn-Z.js → card-BcVuRQiM.js} +1 -1
  56. package/dist/assets/ccip-O1XLvWon.js +1 -0
  57. package/dist/assets/{checkmark-ChFh19kF.js → checkmark-CQVJIWW1.js} +1 -1
  58. package/dist/assets/{checkmark-bold-CJoZ_Jrk.js → checkmark-bold-DDU5XQfq.js} +1 -1
  59. package/dist/assets/{chevron-bottom-yTRY8YSB.js → chevron-bottom-Bqi9FW2q.js} +1 -1
  60. package/dist/assets/{chevron-left-DFmsJ_8-.js → chevron-left-Vd5st0yB.js} +1 -1
  61. package/dist/assets/{chevron-right-IFdWvKJ1.js → chevron-right-BVwFrlss.js} +1 -1
  62. package/dist/assets/{chevron-top-Boye5Dtz.js → chevron-top-D5dQ2xFn.js} +1 -1
  63. package/dist/assets/{chrome-store-D8_25Dil.js → chrome-store-C9C4k8IO.js} +1 -1
  64. package/dist/assets/{clock-D9LUFCJ6.js → clock-Cuvc7bNo.js} +1 -1
  65. package/dist/assets/{close-C1PmyegA.js → close-fW1pJ13b.js} +1 -1
  66. package/dist/assets/{code-block-oleEXE1g.js → code-block-Djv3iQ0G.js} +2 -2
  67. package/dist/assets/{coinPlaceholder-DIV2a9lC.js → coinPlaceholder-CKymvNA8.js} +1 -1
  68. package/dist/assets/{compass-CHoy_ibd.js → compass-D3h_6fr8.js} +1 -1
  69. package/dist/assets/{copy-CHW4cQpR.js → copy-CNGN_cOz.js} +1 -1
  70. package/dist/assets/{core-BTKMBBlw.js → core-LDeQm5nv.js} +21 -22
  71. package/dist/assets/cursor-CTNYpsWo.js +3 -0
  72. package/dist/assets/{cursor-transparent-C642YpxV.js → cursor-transparent-BblOfv3t.js} +1 -1
  73. package/dist/assets/{desktop-CFX22rtl.js → desktop-gpVOlZ1-.js} +1 -1
  74. package/dist/assets/{disconnect-D3FRtzUF.js → disconnect-C_phPN0_.js} +1 -1
  75. package/dist/assets/{discord-DVAbkC-9.js → discord-Dk_2Plhc.js} +1 -1
  76. package/dist/assets/{en_US-Y4ZOVFV4-CkCCvmU2.js → en_US-Y4ZOVFV4-CmhP8GU2.js} +22 -22
  77. package/dist/assets/{etherscan-CbJMIgqi.js → etherscan-Cyrh-2Lr.js} +1 -1
  78. package/dist/assets/{exclamation-triangle-Co4Jh1eh.js → exclamation-triangle-SeeDwZ6A.js} +1 -1
  79. package/dist/assets/{extension-BDLbDfWs.js → extension-e_11O0GI.js} +1 -1
  80. package/dist/assets/{external-link-zdLNy8XP.js → external-link-Dl0AqCn3.js} +1 -1
  81. package/dist/assets/{facebook-JC7OgGSS.js → facebook-Cp_-Axbh.js} +1 -1
  82. package/dist/assets/{farcaster-Clihjnkd.js → farcaster-Zwu26KYL.js} +1 -1
  83. package/dist/assets/{filters-CUYKBCRj.js → filters-CdkpWvgi.js} +1 -1
  84. package/dist/assets/{github-D6Beytth.js → github-DuPUePDJ.js} +1 -1
  85. package/dist/assets/{google-BwFZTm-H.js → google-DlKW7Gx7.js} +1 -1
  86. package/dist/assets/{help-circle-bA9CuhxX.js → help-circle-19xLhjPt.js} +1 -1
  87. package/dist/assets/highlighted-body-KQOG7T2V-D7DB9nBd.js +1 -0
  88. package/dist/assets/{id-B1fJDhOC.js → id-B4PjxpL6.js} +1 -1
  89. package/dist/assets/{image-Bs0ponob.js → image-CHz8w95r.js} +1 -1
  90. package/dist/assets/{index-7LAxO3mh.js → index-BYZ6CM-r.js} +1 -1
  91. package/dist/assets/index-BhwNCc8y.js +1 -0
  92. package/dist/assets/{index-DBg2OUwU.js → index-CAflmCbT.js} +3 -3
  93. package/dist/assets/index-CZbdRW9K.js +1 -0
  94. package/dist/assets/index-CfhMI0GY.css +1 -0
  95. package/dist/assets/index-CgyFWy7G.js +16 -0
  96. package/dist/assets/index-DIcymBxc.js +91 -0
  97. package/dist/assets/index.es-0kjt2ETS.js +38 -0
  98. package/dist/assets/{info-Crty5prY.js → info-CFnwPck_.js} +1 -1
  99. package/dist/assets/{info-circle-bDiLcX0l.js → info-circle-DNYjRzmq.js} +1 -1
  100. package/dist/assets/{lightbulb-wiOiTKWo.js → lightbulb-DPrYcwVp.js} +1 -1
  101. package/dist/assets/{limits-CLb8Vgob.js → limits-D8_oE0N-.js} +1 -1
  102. package/dist/assets/{mail-Bpk1E7XK.js → mail-Do_T12XQ.js} +1 -1
  103. package/dist/assets/{mermaid-MCJ5UELQ-BGV7b3EX.js → mermaid-MCJ5UELQ-Cr83KTfF.js} +3 -3
  104. package/dist/assets/{metamask-sdk-C52uEAVB.js → metamask-sdk-CHSvqgLD.js} +1 -1
  105. package/dist/assets/{mobile-emFaTh5J.js → mobile-2wdwD-gm.js} +1 -1
  106. package/dist/assets/models-CLos5_p0.js +1 -0
  107. package/dist/assets/{more-zpBj89SK.js → more-CugjlKbm.js} +1 -1
  108. package/dist/assets/{network-placeholder-Ck50Grfu.js → network-placeholder-D0CvRN9Z.js} +1 -1
  109. package/dist/assets/{nftPlaceholder-Du211GMR.js → nftPlaceholder-CjCtJ3VF.js} +1 -1
  110. package/dist/assets/{off-_wDqmoP5.js → off-CjwzxGqC.js} +1 -1
  111. package/dist/assets/{play-store-CnBTcLjB.js → play-store-ts_mM-L7.js} +1 -1
  112. package/dist/assets/{plus-Cb-EWMOz.js → plus-CayVcA5r.js} +1 -1
  113. package/dist/assets/{qr-code-IAHrSZeD.js → qr-code-BJFXX7Ga.js} +1 -1
  114. package/dist/assets/{recycle-horizontal-Dp5-d1QB.js → recycle-horizontal-Dxd_xbuW.js} +1 -1
  115. package/dist/assets/{refresh-D-cPnY1R.js → refresh-2tSMiCzO.js} +1 -1
  116. package/dist/assets/{reown-logo-h7OXEqAA.js → reown-logo-C3tg9yiK.js} +1 -1
  117. package/dist/assets/{search-3DHLTaqT.js → search-By38_AjN.js} +1 -1
  118. package/dist/assets/{send-B4rs7eAg.js → send-DhLEHc2T.js} +1 -1
  119. package/dist/assets/sendTransaction-CqpP3CZj.js +1 -0
  120. package/dist/assets/stored-CFfx95Ep.js +1 -0
  121. package/dist/assets/{swapHorizontal-CvyPi1B5.js → swapHorizontal-BSy_Qzqy.js} +1 -1
  122. package/dist/assets/{swapHorizontalBold-08GsNiPL.js → swapHorizontalBold-B4pOkOa-.js} +1 -1
  123. package/dist/assets/{swapHorizontalMedium-BGToxjIs.js → swapHorizontalMedium-BbDDLHs6.js} +1 -1
  124. package/dist/assets/{swapHorizontalRoundedBold-Brn-wznU.js → swapHorizontalRoundedBold-MzTdSarg.js} +1 -1
  125. package/dist/assets/{swapVertical-DrQ-Bc70.js → swapVertical-D0uKM7wm.js} +1 -1
  126. package/dist/assets/{telegram-NopFeNMG.js → telegram-Q_WwsPzx.js} +1 -1
  127. package/dist/assets/{three-dots-DdTyzR9Y.js → three-dots-Cpl_X23E.js} +1 -1
  128. package/dist/assets/{twitch-CgscKAJj.js → twitch-B7x-eAo9.js} +1 -1
  129. package/dist/assets/{twitterIcon-Dj2w3xJD.js → twitterIcon-BRMMjDzW.js} +1 -1
  130. package/dist/assets/usage-DktoZRc8.js +1 -0
  131. package/dist/assets/{useInfiniteQuery-D6hnkAjP.js → useInfiniteQuery-NenQ5Num.js} +1 -1
  132. package/dist/assets/useTx-WkiDSW_A.js +1 -0
  133. package/dist/assets/{verify-DYZt4X2T.js → verify-BxTMhyZY.js} +1 -1
  134. package/dist/assets/{verify-filled-CsYaVqHh.js → verify-filled-CaKhO-hp.js} +1 -1
  135. package/dist/assets/{w3m-modal-DPin_wEK.js → w3m-modal-DZ2_0Ukm.js} +1 -1
  136. package/dist/assets/waitForCallsStatus-CtriTPoz.js +1 -0
  137. package/dist/assets/{wallet-BUXq0k4x.js → wallet-BeZF3I-Z.js} +1 -1
  138. package/dist/assets/{wallet-placeholder-BDl3Cn3J.js → wallet-placeholder-BDvuTJ6r.js} +1 -1
  139. package/dist/assets/{walletconnect-B8r28svX.js → walletconnect-U8tnyg6m.js} +1 -1
  140. package/dist/assets/{warning-circle-CyUfdBFs.js → warning-circle-Dg69jmuZ.js} +1 -1
  141. package/dist/assets/writeContract-DrAWt0yz.js +1 -0
  142. package/dist/assets/{x-DO-oPY_e.js → x-CJ-uWPue.js} +1 -1
  143. package/dist/index.html +2 -2
  144. package/package.json +1 -1
  145. package/dist/assets/Activity-BTHWjCfF.js +0 -1
  146. package/dist/assets/ChannelClose-B6aqPNyc.js +0 -1
  147. package/dist/assets/Disclosure-DaXKEWtB.js +0 -1
  148. package/dist/assets/Keys-BIlAH1SD.js +0 -1
  149. package/dist/assets/Logs-D6o56kmk.js +0 -1
  150. package/dist/assets/Members-33LlQeJ4.js +0 -1
  151. package/dist/assets/Models-n5Y-SyjO.js +0 -1
  152. package/dist/assets/OperatorActions-hBx0zsfp.js +0 -1
  153. package/dist/assets/PolicyEditor-zST9UHdU.js +0 -1
  154. package/dist/assets/Presets-CMVeG1hO.js +0 -4
  155. package/dist/assets/Providers-CVteCWoy.js +0 -1
  156. package/dist/assets/RequestLog-DHFCVVlZ.js +0 -1
  157. package/dist/assets/Rewards-D3Hh7Soh.js +0 -2
  158. package/dist/assets/RewardsClaim-D2E08Ty-.js +0 -1
  159. package/dist/assets/Routing-DSRUEAFE.js +0 -1
  160. package/dist/assets/SelectField-CL9GSHwf.js +0 -1
  161. package/dist/assets/Settings-DvqGXXJg.js +0 -7
  162. package/dist/assets/Switch-C5_JEBYO.js +0 -1
  163. package/dist/assets/TextAreaField-BwxpmCEP.js +0 -1
  164. package/dist/assets/Wallet-DUot1EZD.js +0 -9
  165. package/dist/assets/WalletFunding-BsxwGyzf.js +0 -1
  166. package/dist/assets/Workspaces-Cbcnklsg.js +0 -1
  167. package/dist/assets/ccip-CRC4f413.js +0 -1
  168. package/dist/assets/cursor-D7dlE2wt.js +0 -3
  169. package/dist/assets/highlighted-body-KQOG7T2V-BhiY5JgE.js +0 -1
  170. package/dist/assets/index-BwpQbdIU.js +0 -1
  171. package/dist/assets/index-CL8Uzy58.js +0 -91
  172. package/dist/assets/index-D8vXwUTI.css +0 -1
  173. package/dist/assets/index-DZnhs53K.js +0 -16
  174. package/dist/assets/index-DeMxDxlw.js +0 -1
  175. package/dist/assets/index.es-BMcYAA4u.js +0 -39
  176. package/dist/assets/models-BSFEBc_r.js +0 -1
  177. package/dist/assets/secp256k1-Cb4vPU9D.js +0 -1
  178. package/dist/assets/secp256k1-D_Ekx0rf.js +0 -1
  179. package/dist/assets/usage-CVWdWZuC.js +0 -1
  180. package/dist/assets/useTx-rdzQSfyH.js +0 -1
@@ -0,0 +1 @@
1
+ import{a4 as E,a5 as C,a6 as N,a7 as v,a8 as P,G as F,a9 as k,c as O,a1 as p,u as j,aa as B,w as H}from"./en_US-Y4ZOVFV4-CmhP8GU2.js";import{bo as $,c6 as G,j as y,ah as S,r as m,c7 as q,aO as L}from"./index-DIcymBxc.js";import{w as U}from"./writeContract-DrAWt0yz.js";async function J(e,t){const{abi:n,chainId:r,connector:s,...a}=t;let c;t.account?c=t.account:c=(await E(e,{assertChainId:!1,chainId:r,connector:s})).account;const o=e.getClient({chainId:r}),f=C(o,N,"simulateContract"),{result:h,request:u}=await f({...a,abi:n,account:c});return{chainId:o.chain.id,result:h,request:{...u,chainId:r}}}async function z(e,t){const{chainId:n,timeout:r=0,...s}=t,a=e.getClient({chainId:n}),o=await C(a,v,"waitForTransactionReceipt")({...s,timeout:r});if(o.status==="reverted"){const f=C(a,P,"getTransaction"),{from:h,...u}=await f({hash:o.transactionHash}),w=await C(a,F,"call")({...u,account:h,data:u.input,gasPrice:u.type!=="eip1559"?u.gasPrice:void 0,maxFeePerGas:u.type==="eip1559"?u.maxFeePerGas:void 0,maxPriorityFeePerGas:u.type==="eip1559"?u.maxPriorityFeePerGas:void 0}),A=w!=null&&w.data?k(`0x${w.data.substring(138)}`):"unknown reason";throw new Error(A)}return{...o,chainId:a.chain.id}}async function D(e,t){const{account:n,chainId:r,connector:s,...a}=t;let c;return typeof n=="object"&&(n==null?void 0:n.type)==="local"?c=e.getClient({chainId:r}):c=await E(e,{account:n??void 0,assertChainId:!1,chainId:r,connector:s}),await C(c,U,"writeContract")({...a,...n?{account:n}:{},chain:r?{id:r}:null})}function M(e){return{mutationFn(t){return D(e,t)},mutationKey:["writeContract"]}}function Q(e={}){const{mutation:t}=e,n=O(e),r=M(n),{mutate:s,mutateAsync:a,...c}=$({...t,...r});return{...c,writeContract:s,writeContractAsync:a}}const X=p(["function getOperator(address buyer) view returns (address)","function getOperatorNonce(address buyer) view returns (uint256)","function setOperator(address buyer, address operator, uint256 nonce, bytes buyerSig)","function transferOperator(address buyer, address newOperator)","function withdraw(address buyer, uint256 amount)","error NotAuthorized()","error InvalidAmount()","error InvalidAddress()","error InsufficientBalance()","error InvalidSignature()","error InvalidNonce()","error OperatorAlreadySet()"]),Z=p(["function claimBuyerReward(address buyer, uint256 epoch)","error NotRewardRecipient()","error RewardRecipientUnavailable()"]),tt=p(["function channels(bytes32 channelId) view returns (address buyer, address seller, uint128 deposit, uint128 settled, bytes32 metadataHash, uint256 deadline, uint256 settledAt, uint256 closeRequestedAt, uint8 status)","function requestClose(bytes32 channelId)","function withdraw(bytes32 channelId)","error ChannelNotActive()","error NotAuthorized()","error CloseAlreadyRequested()","error CloseNotReady()"]),et=p(["function claimBuyerEmissions(address buyer, uint256[] epochs)","error NotAuthorized()","error EpochNotFinalized()"]);function nt({chain:e,runner:t,done:n="Confirmed on chain."}){const r=t.lastHash?G(e,t.lastHash):null,s=r&&y.jsx("a",{className:"gc-link",href:r,target:"_blank",rel:"noopener noreferrer",children:"View transaction"});return y.jsxs(y.Fragment,{children:[t.status&&y.jsxs(S,{tone:"info",children:[t.status," ",t.running&&t.lastHash&&s]}),t.error&&y.jsxs(S,{tone:"danger",children:[t.error," ",!t.running&&s]}),!t.running&&!t.error&&t.confirmed&&y.jsxs(S,{tone:"success",children:[n," ",s]})]})}function at(e){const t=O(),{chainId:n}=j(),{switchChainAsync:r}=B(),[s,a]=m.useState(null),[c,o]=m.useState(null),[f,h]=m.useState(null),[u,g]=m.useState(null),[w,A]=m.useState(!1);async function T(_,l={}){var x,I,R;let b=null;A(!0),o(null),g(null),h(null);try{n!==e&&(a("Switch network in your wallet…"),await r({chainId:e}));for(const i of _){i.check&&(a(`${i.label}: checking…`),await i.check()),a(`${i.label}: confirm in your wallet…`);const d=await i.send();if(b=d,h(d),a(`${i.label}: waiting for confirmation…`),(await z(t,{hash:d,chainId:e})).status!=="success")throw new Error(`${i.label} reverted on chain.`)}return a(null),g(b),b}catch(i){a(null);const d=q(i);return d?(o(d.message),d.refresh&&((x=l.onStale)==null||x.call(l))):i instanceof L?(o(i.message),i.refresh&&((I=l.onStale)==null||I.call(l))):(o(H(i)),b&&((R=l.onStale)==null||R.call(l))),null}finally{A(!1)}}return{run:T,running:w,status:s,setStatus:a,error:c,lastHash:f,confirmed:u,wrongChain:n!==void 0&&n!==e,setError:o}}export{tt as C,X as D,et as L,nt as T,Z as U,Q as a,J as s,at as u};
@@ -1,4 +1,4 @@
1
- import{w as l}from"./core-BTKMBBlw.js";import"./index-CL8Uzy58.js";import"./index.es-BMcYAA4u.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CkCCvmU2.js";import"./clsx-B-dksMZM.js";import"./index-BwpQbdIU.js";const p=l`<svg fill="none" viewBox="0 0 28 28">
1
+ import{w as l}from"./core-LDeQm5nv.js";import"./index-DIcymBxc.js";import"./index.es-0kjt2ETS.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CmhP8GU2.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const p=l`<svg fill="none" viewBox="0 0 28 28">
2
2
  <path
3
3
  fill="currentColor"
4
4
  fill-rule="evenodd"
@@ -1,4 +1,4 @@
1
- import{w as l}from"./core-BTKMBBlw.js";import"./index-CL8Uzy58.js";import"./index.es-BMcYAA4u.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CkCCvmU2.js";import"./clsx-B-dksMZM.js";import"./index-BwpQbdIU.js";const c=l`<svg fill="none" viewBox="0 0 14 14">
1
+ import{w as l}from"./core-LDeQm5nv.js";import"./index-DIcymBxc.js";import"./index.es-0kjt2ETS.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CmhP8GU2.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const c=l`<svg fill="none" viewBox="0 0 14 14">
2
2
  <path
3
3
  fill="currentColor"
4
4
  fill-rule="evenodd"
@@ -1,4 +1,4 @@
1
- import{a as ve,s as fe,b as ge,p as be,M as g,S as se,R as l,i as v,r as P,c as f,d as a,A as K,e as ce,f as le,C as m,g as Y,h as ye,j as S,E as ie,O as E,k as q,l as oe,m as T,n as H,T as xe,o as Ce,q as ke,t as Se}from"./core-BTKMBBlw.js";import{c as u,n as w,r as d,o as F,U as We}from"./index-DBg2OUwU.js";import"./index-CL8Uzy58.js";import"./index.es-BMcYAA4u.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CkCCvmU2.js";import"./clsx-B-dksMZM.js";import"./index-BwpQbdIU.js";const p=be({message:"",open:!1,triggerRect:{width:0,height:0,top:0,left:0},variant:"shade"}),Re={state:p,subscribe(r){return ge(p,()=>r(p))},subscribeKey(r,e){return fe(p,r,e)},showTooltip({message:r,triggerRect:e,variant:t}){p.open=!0,p.message=r,p.triggerRect=e,p.variant=t},hide(){p.open=!1,p.message="",p.triggerRect={width:0,height:0,top:0,left:0}}},O=ve(Re),de={isUnsupportedChainView(){return l.state.view==="UnsupportedChain"||l.state.view==="SwitchNetwork"&&l.state.history.includes("UnsupportedChain")},async safeClose(){if(this.isUnsupportedChainView()){g.shake();return}if(await se.isSIWXCloseDisabled()){g.shake();return}g.close()}},$e=v`
1
+ import{a as ve,s as fe,b as ge,p as be,M as g,S as se,R as l,i as v,r as P,c as f,d as a,A as K,e as ce,f as le,C as m,g as Y,h as ye,j as S,E as ie,O as E,k as q,l as oe,m as T,n as H,T as xe,o as Ce,q as ke,t as Se}from"./core-LDeQm5nv.js";import{c as u,n as w,r as d,o as F,U as We}from"./index-CAflmCbT.js";import"./index-DIcymBxc.js";import"./index.es-0kjt2ETS.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CmhP8GU2.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const p=be({message:"",open:!1,triggerRect:{width:0,height:0,top:0,left:0},variant:"shade"}),Re={state:p,subscribe(r){return ge(p,()=>r(p))},subscribeKey(r,e){return fe(p,r,e)},showTooltip({message:r,triggerRect:e,variant:t}){p.open=!0,p.message=r,p.triggerRect=e,p.variant=t},hide(){p.open=!1,p.message="",p.triggerRect={width:0,height:0,top:0,left:0}}},O=ve(Re),de={isUnsupportedChainView(){return l.state.view==="UnsupportedChain"||l.state.view==="SwitchNetwork"&&l.state.history.includes("UnsupportedChain")},async safeClose(){if(this.isUnsupportedChainView()){g.shake();return}if(await se.isSIWXCloseDisabled()){g.shake();return}g.close()}},$e=v`
2
2
  :host {
3
3
  display: block;
4
4
  border-radius: clamp(0px, var(--wui-border-radius-l), 44px);
@@ -0,0 +1 @@
1
+ import{K as y,e as _,m as I,U as O,B as C,M as R,N as x,v as q,p as S,O as L,P as E,Q as B,R as N,A as P,g as T,k as j,S as D,D as M,y as z,T as U,V as W,X as $,Y as H}from"./en_US-Y4ZOVFV4-CmhP8GU2.js";import{s as G}from"./sendTransaction-CqpP3CZj.js";const k="0x5792579257925792579257925792579257925792579257925792579257925792",A=y(0,{size:32});async function J(s,a){var g;const{account:l=s.account,chain:p=s.chain,experimental_fallback:m,experimental_fallbackDelay:d=32,forceAtomic:c=!1,id:r,version:w="2.0.0"}=a,h=l?S(l):null;let t=a.capabilities;s.dataSuffix&&!((g=a.capabilities)!=null&&g.dataSuffix)&&(typeof s.dataSuffix=="string"?t={...a.capabilities,dataSuffix:{value:s.dataSuffix,optional:!0}}:t={...a.capabilities,dataSuffix:{value:s.dataSuffix.value,...s.dataSuffix.required?{}:{optional:!0}}});const b=a.calls.map(u=>{const e=u,i=e.abi?_({abi:e.abi,functionName:e.functionName,args:e.args}):e.data;return{data:e.dataSuffix&&i?I([i,e.dataSuffix]):i,to:e.to,value:e.value?y(e.value):void 0}});try{const u=await s.request({method:"wallet_sendCalls",params:[{atomicRequired:c,calls:b,capabilities:t,chainId:y(p.id),from:h==null?void 0:h.address,id:r,version:w}]},{retryCount:0});return typeof u=="string"?{id:u}:u}catch(u){const e=u;if(m&&(e.name==="MethodNotFoundRpcError"||e.name==="MethodNotSupportedRpcError"||e.name==="UnknownRpcError"||e.details.toLowerCase().includes("does not exist / is not available")||e.details.toLowerCase().includes("missing or invalid. request()")||e.details.toLowerCase().includes("did not match any variant of untagged enum")||e.details.toLowerCase().includes("account upgraded to unsupported contract")||e.details.toLowerCase().includes("eip-7702 not supported")||e.details.toLowerCase().includes("unsupported wc_ method")||e.details.toLowerCase().includes("feature toggled misconfigured")||e.details.toLowerCase().includes("jsonrpcengine: response has no error or result for request"))){if(t&&Object.values(t).some(f=>!f.optional)){const f="non-optional `capabilities` are not supported on fallback to `eth_sendTransaction`.";throw new O(new C(f,{details:f}))}if(c&&b.length>1){const n="`forceAtomic` is not supported on fallback to `eth_sendTransaction`.";throw new R(new C(n,{details:n}))}const i=[];for(const n of b){const f=G(s,{account:h,chain:p,data:n.data,to:n.to,value:n.value?x(n.value):void 0});i.push(f),d>0&&await new Promise(F=>setTimeout(F,d))}const o=await Promise.allSettled(i);if(o.every(n=>n.status==="rejected"))throw o[0].reason;const v=o.map(n=>n.status==="fulfilled"?n.value:A);return{id:I([...v,y(p.id,{size:32}),k])}}throw q(u,{...a,account:h,chain:a.chain})}}async function K(s,a){async function l(t){if(t.endsWith(k.slice(2))){const g=B(N(t,-64,-32)),u=N(t,0,-64).slice(2).match(/.{1,64}/g),e=await Promise.all(u.map(o=>A.slice(2)!==o?s.request({method:"eth_getTransactionReceipt",params:[`0x${o}`]},{dedupe:!0}):void 0)),i=e.some(o=>o===null)?100:e.every(o=>(o==null?void 0:o.status)==="0x1")?200:e.every(o=>(o==null?void 0:o.status)==="0x0")?500:600;return{atomic:!1,chainId:E(g),receipts:e.filter(Boolean),status:i,version:"2.0.0"}}return s.request({method:"wallet_getCallsStatus",params:[t]})}const{atomic:p=!1,chainId:m,receipts:d,version:c="2.0.0",...r}=await l(a.id),[w,h]=(()=>{const t=r.status;return t>=100&&t<200?["pending",t]:t>=200&&t<300?["success",t]:t>=300&&t<700?["failure",t]:t==="CONFIRMED"?["success",200]:t==="PENDING"?["pending",100]:[void 0,t]})();return{...r,atomic:p,chainId:m?E(m):void 0,receipts:(d==null?void 0:d.map(t=>({...t,blockNumber:x(t.blockNumber),gasUsed:x(t.gasUsed),status:L[t.status]})))??[],statusCode:h,status:w,version:c}}async function Z(s,a){var w;const{account:l=s.account,chainId:p,nonce:m}=a;if(!l)throw new P({docsPath:"/docs/eip7702/prepareAuthorization"});const d=S(l),c=(()=>{if(a.executor)return a.executor==="self"?a.executor:S(a.executor)})(),r={address:a.contractAddress??a.address,chainId:p,nonce:m};return typeof r.chainId>"u"&&(r.chainId=((w=s.chain)==null?void 0:w.id)??await T(s,j,"getChainId")({})),typeof r.nonce>"u"&&(r.nonce=await T(s,D,"getTransactionCount")({address:d.address,blockTag:"pending"}),(c==="self"||c!=null&&c.address&&M(c.address,d.address))&&(r.nonce+=1)),r}class Q extends C{constructor(a){super(`Call bundle failed with status: ${a.statusCode}`,{name:"BundleFailedError"}),Object.defineProperty(this,"result",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.result=a}}async function tt(s,a){const{id:l,pollingInterval:p=s.pollingInterval,status:m=({statusCode:i})=>i===200||i>=300,retryCount:d=4,retryDelay:c=({count:i})=>~~(1<<i)*200,timeout:r=6e4,throwOnFailure:w=!1}=a,h=z(["waitForCallsStatus",s.uid,l]),{promise:t,resolve:b,reject:g}=U();let u;const e=W(h,{resolve:b,reject:g},i=>{const o=$(async()=>{const v=n=>{clearTimeout(u),o(),n(),e()};try{const n=await H(async()=>{const f=await T(s,K,"getCallsStatus")({id:l});if(w&&f.status==="failure")throw new Q(f);return f},{retryCount:d,delay:c});if(!m(n))return;v(()=>i.resolve(n))}catch(n){v(()=>i.reject(n))}},{interval:p,emitOnBegin:!0});return o});return u=r?setTimeout(()=>{e(),clearTimeout(u),g(new V({id:l}))},r):void 0,await t}class V extends C{constructor({id:a}){super(`Timed out while waiting for call bundle with id "${a}" to be confirmed.`,{name:"WaitForCallsStatusTimeoutError"})}}export{K as g,Z as p,J as s,tt as w};
@@ -1,4 +1,4 @@
1
- import{w as o}from"./core-BTKMBBlw.js";import"./index-CL8Uzy58.js";import"./index.es-BMcYAA4u.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CkCCvmU2.js";import"./clsx-B-dksMZM.js";import"./index-BwpQbdIU.js";const m=o`<svg fill="none" viewBox="0 0 20 20">
1
+ import{w as o}from"./core-LDeQm5nv.js";import"./index-DIcymBxc.js";import"./index.es-0kjt2ETS.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CmhP8GU2.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const m=o`<svg fill="none" viewBox="0 0 20 20">
2
2
  <path
3
3
  fill="currentColor"
4
4
  fill-rule="evenodd"
@@ -1,4 +1,4 @@
1
- import{w as a}from"./core-BTKMBBlw.js";import"./index-CL8Uzy58.js";import"./index.es-BMcYAA4u.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CkCCvmU2.js";import"./clsx-B-dksMZM.js";import"./index-BwpQbdIU.js";const c=a`
1
+ import{w as a}from"./core-LDeQm5nv.js";import"./index-DIcymBxc.js";import"./index.es-0kjt2ETS.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CmhP8GU2.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const c=a`
2
2
  <svg fill="none" viewBox="0 0 48 44">
3
3
  <path
4
4
  style="fill: var(--wui-color-bg-300);"
@@ -1,4 +1,4 @@
1
- import{w as l}from"./core-BTKMBBlw.js";import"./index-CL8Uzy58.js";import"./index.es-BMcYAA4u.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CkCCvmU2.js";import"./clsx-B-dksMZM.js";import"./index-BwpQbdIU.js";const r=l`<svg fill="none" viewBox="0 0 96 67">
1
+ import{w as l}from"./core-LDeQm5nv.js";import"./index-DIcymBxc.js";import"./index.es-0kjt2ETS.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CmhP8GU2.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const r=l`<svg fill="none" viewBox="0 0 96 67">
2
2
  <path
3
3
  fill="currentColor"
4
4
  d="M25.32 18.8a32.56 32.56 0 0 1 45.36 0l1.5 1.47c.63.62.63 1.61 0 2.22l-5.15 5.05c-.31.3-.82.3-1.14 0l-2.07-2.03a22.71 22.71 0 0 0-31.64 0l-2.22 2.18c-.31.3-.82.3-1.14 0l-5.15-5.05a1.55 1.55 0 0 1 0-2.22l1.65-1.62Zm56.02 10.44 4.59 4.5c.63.6.63 1.6 0 2.21l-20.7 20.26c-.62.61-1.63.61-2.26 0L48.28 41.83a.4.4 0 0 0-.56 0L33.03 56.21c-.63.61-1.64.61-2.27 0L10.07 35.95a1.55 1.55 0 0 1 0-2.22l4.59-4.5a1.63 1.63 0 0 1 2.27 0L31.6 43.63a.4.4 0 0 0 .57 0l14.69-14.38a1.63 1.63 0 0 1 2.26 0l14.69 14.38a.4.4 0 0 0 .57 0l14.68-14.38a1.63 1.63 0 0 1 2.27 0Z"
@@ -1,4 +1,4 @@
1
- import{w as r}from"./core-BTKMBBlw.js";import"./index-CL8Uzy58.js";import"./index.es-BMcYAA4u.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CkCCvmU2.js";import"./clsx-B-dksMZM.js";import"./index-BwpQbdIU.js";const n=r`<svg fill="none" viewBox="0 0 20 20">
1
+ import{w as r}from"./core-LDeQm5nv.js";import"./index-DIcymBxc.js";import"./index.es-0kjt2ETS.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CmhP8GU2.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const n=r`<svg fill="none" viewBox="0 0 20 20">
2
2
  <path
3
3
  fill="currentColor"
4
4
  d="M11 6.67a1 1 0 1 0-2 0v2.66a1 1 0 0 0 2 0V6.67ZM10 14.5a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5Z"
@@ -0,0 +1 @@
1
+ import{A as g,e as l,g as y,d as A,p as C}from"./en_US-Y4ZOVFV4-CmhP8GU2.js";import{s as E}from"./sendTransaction-CqpP3CZj.js";async function a(n,r){return a.internal(n,E,"sendTransaction",r)}(function(n){async function r(c,u,f,w){const{abi:s,account:o=c.account,address:e,args:i,functionName:d,...p}=w;if(typeof o>"u")throw new g({docsPath:"/docs/contract/writeContract"});const t=o?C(o):null,h=l({abi:s,args:i,functionName:d});try{return await y(c,u,f)({data:h,to:e,account:t,...p})}catch(m){throw A(m,{abi:s,address:e,args:i,docsPath:"/docs/contract/writeContract",functionName:d,sender:t==null?void 0:t.address})}}n.internal=r})(a||(a={}));export{a as w};
@@ -1,4 +1,4 @@
1
- import{w as l}from"./core-BTKMBBlw.js";import"./index-CL8Uzy58.js";import"./index.es-BMcYAA4u.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CkCCvmU2.js";import"./clsx-B-dksMZM.js";import"./index-BwpQbdIU.js";const r=l`<svg fill="none" viewBox="0 0 41 40">
1
+ import{w as l}from"./core-LDeQm5nv.js";import"./index-DIcymBxc.js";import"./index.es-0kjt2ETS.js";import"./events-DQ172AOg.js";import"./en_US-Y4ZOVFV4-CmhP8GU2.js";import"./clsx-B-dksMZM.js";import"./index-BhwNCc8y.js";const r=l`<svg fill="none" viewBox="0 0 41 40">
2
2
  <g clip-path="url(#a)">
3
3
  <path fill="#000" d="M.8 0h40v40H.8z" />
4
4
  <path
package/dist/index.html CHANGED
@@ -7,8 +7,8 @@
7
7
  <meta name="referrer" content="no-referrer" />
8
8
  <title>Antseed Console</title>
9
9
  <link rel="icon" type="image/svg+xml" href="/console/assets/antseed-mark-3TDLhfuw.svg" />
10
- <script type="module" crossorigin src="/console/assets/index-CL8Uzy58.js"></script>
11
- <link rel="stylesheet" crossorigin href="/console/assets/index-D8vXwUTI.css">
10
+ <script type="module" crossorigin src="/console/assets/index-DIcymBxc.js"></script>
11
+ <link rel="stylesheet" crossorigin href="/console/assets/index-CfhMI0GY.css">
12
12
  </head>
13
13
  <body>
14
14
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antseed/gateway-console",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "Antseed gateway console: the web app the gateway serves at /console",
5
5
  "type": "module",
6
6
  "files": [
@@ -1 +0,0 @@
1
- import{u as L,a as Q,r as l,b as W,i as $,c as H,d as J,e as w,j as s,P as X,B as C,I,f as h,S as m,g as R,h as b,k as o,l as N,Q as Y,m as Z,E as _,n as ee,q as B}from"./index-CL8Uzy58.js";import{U as se,M as ae,c as te}from"./UsageByModel-CWVN_g_S.js";import{p as re}from"./PeerPicker-BvexRNjB.js";import{r as le,R as oe,g as M}from"./usage-CVWdWZuC.js";import{S as V}from"./Segmented-D-_FvNVa.js";import{S as k}from"./SelectField-CL9GSHwf.js";import{D as ne}from"./DataTable-nSpXggux.js";import"./Charts-BqpYsDwi.js";import"./roving-DkptacxO.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 he(){var q;const{viewer:v,workspace:x}=L(),n=Q(),[i,F]=l.useState("30d"),[r,z]=l.useState("model"),A=W(),f=a=>r!=="peer"?M(a):a.group?re(A.data,a.group):"No seller (not served)",[d,U]=l.useState("spend"),[c,j]=l.useState(""),[p,S]=l.useState(""),g=$(v),y=l.useMemo(()=>Date.now(),[i]),K=le(i,y),u={...n,key:c||void 0,member:p||n.member,from:K,to:y},D=H({workspace:x.id,member:n.member}),G=J(x.id,g),P=w({queryKey:B.usage({...u,groupBy:"day"}),queryFn:()=>h.usage.report({...u,groupBy:"day"})}),O=w({queryKey:B.usage({...u,groupBy:r}),queryFn:()=>h.usage.report({...u,groupBy:r})}),t=(q=P.data)==null?void 0:q.totals;return s.jsxs("div",{className:"gc-page",children:[s.jsx(X,{title:"Activity",description:"Spend and token usage over time.",actions:s.jsx(C,{variant:"outline",size:"sm",href:h.usage.exportUrl({...u,groupBy:r}),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:i,onChange:F,options:oe.map(a=>({value:a.id,label:a.label}))}),s.jsx(k,{size:"sm","aria-label":"Filter by key",value:c,onChange:j,options:[{value:"",label:"All keys"},...(D.data??[]).map(a=>({value:a.id,label:a.label}))]}),g&&s.jsx(k,{size:"sm","aria-label":"Filter by member",value:p,onChange:S,options:[{value:"",label:"All members"},...(G.data??[]).map(({member:a})=>({value:a.id,label:a.label}))]}),(c||p)&&s.jsx(C,{variant:"ghost",size:"sm",onClick:()=>{j(""),S("")},children:"Clear filters"})]}),s.jsxs("div",{className:"gc-grid gc-grid--4",children:[s.jsx(m,{label:"Spend",value:t?R(t.spent):"…"}),s.jsx(m,{label:"Requests",value:t?b(t.requests):"…",sub:t?`${b(t.failedRequests)} failed`:void 0}),s.jsx(m,{label:"Input tokens",value:t?o(t.inputTokens):"…",sub:t?`${o(t.cachedInputTokens)} cached`:void 0}),s.jsx(m,{label:"Output tokens",value:t?o(t.outputTokens):"…"})]}),s.jsx(N,{title:d==="tokens"?"Tokens by type":"Usage by model",description:te(d,i),actions:s.jsx(V,{label:"Chart metric",value:d,onChange:U,options:ae}),children:s.jsx(se,{filter:{...n,key:c||void 0,member:p||n.member},range:i,now:y,metric:d})}),s.jsx(N,{title:"Breakdown",flush:!0,actions:s.jsx(k,{size:"sm","aria-label":"Group by",value:r,onChange:a=>z(a),options:E.filter(a=>(!a.admin||g)&&(!a.org||ee(v))).map(a=>({value:a.value,label:`By ${a.label.toLowerCase()}`}))}),children:s.jsx(Y,{query:O,children:a=>{var T;return s.jsx(ne,{label:"Usage breakdown",rows:a.groups,rowKey:e=>e.group,initialSort:{key:"spent",direction:"desc"},empty:s.jsx(_,{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:((T=E.find(e=>e.value===r))==null?void 0:T.label)??"Group",render:e=>s.jsx("span",{className:"gc-ellipsis",title:r==="peer"?e.group:M(e),children:f(e)}),sortValue:e=>f(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=>o(e.inputTokens),sortValue:e=>e.inputTokens},{key:"cached",header:"Cached",align:"right",secondary:!0,render:e=>o(e.cachedInputTokens),sortValue:e=>e.cachedInputTokens},{key:"output",header:"Output",align:"right",secondary:!0,render:e=>o(e.outputTokens),sortValue:e=>e.outputTokens},{key:"spent",header:"Spend",align:"right",render:e=>R(e.spent),sortValue:e=>Z(e.spent)}]})}})})]})}export{he as default};
@@ -1 +0,0 @@
1
- import{j as e,J as T,aG as I,aH as E,ag as W,aI as R,aJ as O,g as C,aK as b,w as B,aL as x,B as S,aM as H,aN as w,aO as j}from"./index-CL8Uzy58.js";import{u as L,a as _,T as G,C as m,s as $}from"./useTx-rdzQSfyH.js";import{a as z}from"./ConnectWallet-BPEdComN.js";import{O as F}from"./OperatorGateAlert-BTIl2CQW.js";import{W as J,u as M,c as P,r as V}from"./en_US-Y4ZOVFV4-CkCCvmU2.js";import"./clsx-B-dksMZM.js";import"./index-BwpQbdIU.js";const D=1,K={request:"close channels on chain",withdraw:"withdraw channel reserves"};function U({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}=M(),g=P(),d=T(s),{refresh:N}=I(s),n=L(a.chainId),{writeContractAsync:k}=_(),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(U,{channel:r,step:t});const h=R(d.data,i,K[t]);if(!h.ok)return e.jsx(F,{gate:h,state:d.data,connected:i,onAuthorize:v});const l=r.channelId;async function q(){const[,,,,,,,c,A]=await V(g,{address:o,abi:m,functionName:"channels",args:[l],chainId:a.chainId});if(A!==D)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,{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:q,send:()=>k({address:o,abi:m,functionName:t==="request"?"requestClose":"withdraw",args:[l],chainId:a.chainId})}],{onStale:()=>{N().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(G,{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 re(s){return e.jsx(J,{chain:s.chain,children:e.jsxs("div",{className:"gc-stack",children:[e.jsx(z,{}),e.jsx(Q,{...s})]})})}export{re as default};
@@ -1 +0,0 @@
1
- import{j as s}from"./index-CL8Uzy58.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 +0,0 @@
1
- import{aB as ke,r as m,a_ as je,a$ as fe,j as s,C as ne,b0 as ve,X as Se,B as S,u as le,a as Ce,i as ce,d as de,c as Pe,t as ie,P as Le,I as K,T as U,l as Ne,Q as Ae,b1 as Ee,z as ue,b2 as X,A as me,g as ye,m as Te,as as Re,E as Z,b3 as pe,D as De,q as F,f as C,v,at as J,e as Ie,b4 as Me,b5 as Ke,b6 as Ue,b7 as ee,o as Fe,W as _e}from"./index-CL8Uzy58.js";import{u as se,a as Be,P as Oe}from"./PolicyField-BL2_pz19.js";import{T as Ye}from"./Tabs-iPKA2Kfx.js";import{l as te,d as ae,L as We}from"./limits-CLb8Vgob.js";import{t as $e}from"./dates-Pi3-Ywng.js";import{r as qe,e as ze}from"./usage-CVWdWZuC.js";import{S as he}from"./Switch-C5_JEBYO.js";import{D as Ve,u as He,P as Qe}from"./DataTable-nSpXggux.js";import{b as Ge}from"./Charts-BqpYsDwi.js";import{S as Xe}from"./SelectField-CL9GSHwf.js";import"./PolicyEditor-zST9UHdU.js";import"./PeerPicker-BvexRNjB.js";import"./Segmented-D-_FvNVa.js";import"./roving-DkptacxO.js";import"./Disclosure-DaXKEWtB.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 Je="30d";function es({keyId:e}){const[l]=m.useState(()=>Date.now()),o=qe(Je,l),c=Ie({queryKey:F.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(Ge,{label:"Daily spend, last 30 days",format:ye,per:"a day",emptyText:"no spend",values:ze(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 ${J(e.expiresAt)}`,children:["Until ",J(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(Oe,{draft:d.draft,setDraft:d.setDraft})]})}function ts({initial:e,layeredHint:l,onSaved:o,onCancel:c}){var q;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)??""),[x,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($e((e==null?void 0:e.expiresAt)??null)),[g,E]=m.useState((e==null?void 0:e.topupEnabled)??!1),[n,b]=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),be=Ke(y.id,a),_=((e==null?void 0:e.buyerIdentity)??((q=be.data)==null?void 0:q.buyerIdentity))==="default",B=de(y.id,a&&!e),R=Be(),[O,Y]=m.useState(null),D=p.admin,W=e?p.owner&&(p.layered||!p.admin):!p.admin,T=e!==null&&p.layered;let $=null;T&&($=p.admin?"Your restrictions as the key owner":"Your restrictions");const ge=e?"Save":"Create key",xe=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,z=D?w.build():null,V=W?t.build():null,H=ae(x),Q=ae(L);if(e){const f=Ue(p,e,{label:h.trim(),expiresAt:u,topupEnabled:g,adminLimits:H,adminPolicy:z,ownerLimits:Q,ownerPolicy:V}),G=await R.save([f.routingPolicy,f.ownerRoutingPolicy],we=>C.keys.update(e.id,f,we));return G===ee?ee:{key:G}}const M={label:h.trim(),workspaceId:y.id,limits:p.admin?H:Q,routingPolicy:p.admin?z:V,topupEnabled:p.admin?g:!1,expiresAt:u};return p.admin&&(M.ownerMemberId=n||null),R.save([M.routingPolicy],f=>C.keys.create(M,f))},onSuccess:o,invalidate:[F.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(U,{label:"Name",required:!0,placeholder:"e.g. Production backend",value:h,onChange:u=>k(u.target.value)}),!e&&a&&B.data&&s.jsx(Xe,{label:"Owner",value:n,onChange:b,options:B.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:x,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:$,idPrefix:"key-owner-limit",limits:L,onLimitsChange:N,limitsNote:xe,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(U,{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:g,onChange:E,disabled:_&&!g,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)."}),O?s.jsx(Fe,{error:O,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…":ge})]}),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(Qe,{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,x]=m.useState(null),[P,L]=m.useState(!1),[N,j]=m.useState(""),A=Pe(c),g=ie({mutationFn:async({kind:n,key:b})=>{n==="rotate"?h(await C.keys.rotate(b.id)):await C.keys.revoke(b.id)},onSuccess:()=>x(null),invalidate:[F.group("keys")],toast:(n,{kind:b})=>b==="revoke"?"Key revoked":null}),E=n=>{var b,w;return n.ownerMemberId?n.ownerMemberId===l.member.id?"You":((w=(b=d.data)==null?void 0:b.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(U,{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:(b,w)=>s.jsx(Ve,{label:"API keys",rows:b,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:()=>x({kind:"rotate",key:t})},{label:"Revoke",tone:"danger",onSelect:()=>x({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(X(t).limits)})},{key:"policy",header:"Routing",secondary:!0,optional:!0,render:t=>s.jsx("span",{className:"gc-muted",children:me(X(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:g.isPending,error:g.error,onClose:()=>{x(null),g.reset()},onConfirm:()=>k&&g.mutate(k),...os(k)})]})}export{js as default};
@@ -1 +0,0 @@
1
- import{r as s,a as D,c as E,j as e,P as I,B as y,I as U,f as q,T as p,l as M}from"./index-CL8Uzy58.js";import{R as B}from"./RequestLog-DHFCVVlZ.js";import{f as C}from"./dates-Pi3-Ywng.js";import{S as T}from"./SelectField-CL9GSHwf.js";import"./useInfiniteQuery-D6hnkAjP.js";import"./PeerPicker-BvexRNjB.js";import"./usage-CVWdWZuC.js";import"./DataTable-nSpXggux.js";function F(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,h]=s.useState(""),[v,b]=s.useState(""),[c,g]=s.useState(""),[d,x]=s.useState(""),k=E(a),f=F(r.trim()),S=F(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=>b(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"},...(k.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:h,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(""),h(""),b(""),g(""),x("")},children:"Clear filters"})]}),e.jsx(M,{flush:!0,children:e.jsx(B,{filter:j})})]})}export{V as default};
@@ -1 +0,0 @@
1
- import{u as W,n as G,r as d,d as ce,R as U,t as N,j as e,P as de,B as f,I as q,l as H,Q,b8 as _,z as me,A as ue,E as ae,C as B,D as T,f as w,G as ge,q as P,aE as be,v as D,at as se,b9 as ne,ba as he,as as J,T as I,ag as X,o as ie,b0 as pe,aM as ve}from"./index-CL8Uzy58.js";import{u as xe,a as je,P as ye}from"./PolicyField-BL2_pz19.js";import{l as ke,d as fe,L as we}from"./limits-CLb8Vgob.js";import{D as Y}from"./DataTable-nSpXggux.js";import{S as M}from"./SelectField-CL9GSHwf.js";import"./PolicyEditor-zST9UHdU.js";import"./PeerPicker-BvexRNjB.js";import"./Segmented-D-_FvNVa.js";import"./roving-DkptacxO.js";import"./Switch-C5_JEBYO.js";import"./Disclosure-DaXKEWtB.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 F=[P.group("members"),P.group("workspaces"),P.group("keys")],K=[...F,P.group("invites")],te=[{value:"member",label:"Member"},{value:"admin",label:"Admin"}];function V(s){return s.status==="disabled"?e.jsx(D,{tone:"danger",children:"Disabled"}):s.status==="invited"?e.jsx(D,{tone:"warning",children:"Invited"}):e.jsx(D,{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=G(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=U(i),L=ne(),x=Ce({label:c,email:g},S.data??[],L.data??[]),h=N({mutationFn:()=>{const a={label:c.trim(),email:g.trim()||null,orgRole:v,workspaces:Object.entries(y).filter(([,k])=>k).map(([k,O])=>({workspaceId:k,role:O})),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(M,{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(M,{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(M,{"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=G(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),[L,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:F,toast:"Member saved"}),a=N({mutationFn:()=>s.status==="disabled"?w.members.enable(s.id):w.members.disable(s.id),onSuccess:()=>{x(!1),t()},invalidate:F}),k=N({mutationFn:r=>w.members.removeCredential(s.id,r),onSuccess:()=>{S(null),t()},invalidate:F}),O=s.id===o.member.id,A=s.status==="disabled",$=m&&(s.orgRole!=="owner"||o.member.orgRole==="owner"),Z=O&&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(M,{label:"Organization role",value:g,disabled:O||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(D,{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:[$&&!O?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:L,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(M,{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=U();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=G(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=U(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"}),L=new Set((h=E.data)==null?void 0:h.map(({member:l})=>l.id)),x=(y.data??[]).filter(l=>!L.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(M,{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 +0,0 @@
1
- import{bd as E,r as m,j as e,be as V,X as $,bf as U,O as N,bg as R,bh as O,bi as _,bj as z,L as D,E as f,I as M,P as K,T as Y,y as I,l as q,Q,bk as G,M as b,h as H,bl as v,bm as T,bn as S,bo as W,aM as w,v as x,W as X,B as J,av as Z,aw as ee,w as L,k as se}from"./index-CL8Uzy58.js";import{T as te,a as ae}from"./Tabs-iPKA2Kfx.js";import{m as ne,f as le,M as P,S as ie,a as re,T as k,C as oe,P as C,b as ce,V as de,p as ue}from"./models-BSFEBc_r.js";import{S as A}from"./SelectField-CL9GSHwf.js";import{S as pe}from"./Switch-C5_JEBYO.js";import{D as he}from"./DataTable-nSpXggux.js";import"./roving-DkptacxO.js";function ge({model:s,format:n,id:o="gc-api-call",unsupported:i}){const p=E(),[h,r]=m.useState("curl");if(!n)return e.jsx("p",{className:"gc-fineprint",children:i??"The gateway does not serve this model through its API."});const a=V(p,s,n),d=a.find(c=>c.id===h)??a[0];return e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsx(te,{id:o,label:"Request examples",value:d.id,onChange:r,className:"gc-connect-tabs",tabs:a.map(c=>({id:c.id,label:c.label}))}),e.jsx(ae,{tabsId:o,tab:d.id,children:e.jsx($,{code:d.code,label:d.label})}),e.jsxs("p",{className:"gc-fineprint",children:["Set ",e.jsx("code",{children:U})," to one of your API keys first. ",e.jsx(N,{to:"keys",children:"API keys"})]})]})}function xe(s){return s===null?"—":String(Math.round(s))}function B(s){return s===null?"—":se(s)}function F(s){return s.fullTeeSellers>0?"end-to-end":s.offers.some(n=>n.teeScope==="seller-node")?"seller-node":null}function me({model:s}){return e.jsxs("div",{className:"gc-badges",children:[s.free&&e.jsx(x,{tone:"success",children:"Free"}),e.jsx(k,{tee:s.teeSellers>0,scope:F(s)})]})}function y(s){return s.displayName??L(s.peerId,8,4)}function Ie(){const s=R(),n=O(s.rest),o=_(),[i,p]=m.useState({search:"",type:"",free:!1}),h=m.useMemo(()=>ne(o.data),[o.data]),r=m.useMemo(()=>n?le(o.data,n):null,[o.data,n]),a=z(),d=(l,t)=>p(u=>({...u,[l]:t})),c=n===null?null:{eyebrow:"Model",title:(r==null?void 0:r.name)??n,body:o.isLoading?e.jsx(D,{rows:6}):r?e.jsx(je,{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 ${n} right now.`})},j=e.jsx(q,{flush:!0,children:e.jsx(Q,{query:o,rows:8,children:l=>e.jsx(he,{label:"Models",rows:re(l,i),rowKey:t=>t.id,selectedKey:(r==null?void 0:r.id)??null,onRowClick:t=>I(T("models",t.id)),rowLabel:t=>t.name,actions:t=>[{label:"Copy model id",onSelect:()=>void a(t.id)}],initialSort:{key:"sellers",direction:"desc"},empty:e.jsx(f,{icon:e.jsx(M.models,{size:18}),title:l.length?"No models match these filters":"No models found yet",body:l.length?void 0:"The buyer is still discovering the network. Check back in a minute."}),columns:[{key:"model",header:"Model",sortValue:t=>t.name.toLowerCase(),render:t=>e.jsxs("div",{className:"gc-cell-lines",children:[e.jsx("div",{className:"gc-strong gc-ellipsis",title:t.id,children:t.name}),t.name!==t.id&&e.jsx("div",{className:"gc-muted gc-ellipsis",children:e.jsx(b,{children:t.id})}),e.jsx(me,{model:t})]}),after:t=>e.jsx(G,{value:t.id,label:`Copy model id ${t.id}`})},{key:"type",header:"Type",secondary:!0,sortValue:t=>t.type,render:t=>e.jsx("span",{className:"gc-muted",children:P[t.type]})},{key:"sellers",header:"Providers",align:"right",sortValue:t=>t.sellers,render:t=>H(t.sellers)},{key:"input",header:"Input $/M",align:"right",sortValue:t=>{var u;return((u=t.inputUsdPerMillion)==null?void 0:u.min)??null},render:t=>v(t.inputUsdPerMillion)},{key:"output",header:"Output $/M",align:"right",secondary:!0,sortValue:t=>{var u;return((u=t.outputUsdPerMillion)==null?void 0:u.min)??null},render:t=>v(t.outputUsdPerMillion)},{key:"context",header:"Context",align:"right",secondary:!0,optional:!0,sortValue:t=>t.contextLength,render:t=>B(t.contextLength)}]})})});return e.jsxs("div",{className:"gc-page",children:[e.jsx(K,{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(Y,{size:"sm",type:"search","aria-label":"Search models",placeholder:"Search model or alias",value:i.search,onChange:l=>d("search",l.target.value)}),h.length>1&&e.jsx(A,{size:"sm","aria-label":"Filter by type",value:i.type,onChange:l=>d("type",l),options:[{value:"",label:"All types"},...h.map(l=>({value:l,label:P[l]}))]}),e.jsx(pe,{checked:i.free,onChange:l=>d("free",l),label:"Free"})]}),e.jsx(ie,{list:j,panel:c,onClose:()=>I("models"),closeLabel:"Close model"})]})}function g(s){return`${s.peerId}:${s.serviceId}`}function je({model:s}){const[n,o]=m.useState(""),i=s.offers.find(a=>g(a)===n)??null,p=i?S(i.peerId,i.serviceId):s.id,h=W(s.type,i),r=s.offers.some(a=>a.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(w,{iconOnly:!0,value:s.id,label:"Copy model id"})]}),e.jsx(x,{children:P[s.type]}),s.free&&e.jsx(x,{tone:"success",children:"Free"}),e.jsx(k,{tee:s.teeSellers>0,scope:F(s)})]}),e.jsx(X,{items:[["Context",B(s.contextLength)],["Capabilities",s.capabilities.length?e.jsx("span",{className:"gc-badges",children:s.capabilities.map(a=>e.jsx(x,{children:oe[a]},a))}):"—"],["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(a=>{var j;const d=S(a.peerId,a.serviceId),c=n===g(a);return e.jsx(ce,{selected:c,title:e.jsx(N,{to:T("providers",a.peerId),children:y(a)}),meta:e.jsxs(e.Fragment,{children:[e.jsx("span",{children:ue(a)}),e.jsxs("span",{children:["Trust ",xe(a.trustScore)]}),a.firstTokenMsP50!==null&&e.jsxs("span",{children:[Z(a.firstTokenMsP50)," first token"]}),a.tokensPerSecondP50!==null&&e.jsx("span",{children:ee(a.tokensPerSecondP50)}),a.serviceId!==s.id&&e.jsx(b,{children:a.serviceId})]}),badges:(((j=a.verificationLinks)==null?void 0:j.length)||a.tee||a.free)&&e.jsxs("div",{className:"gc-badges",children:[e.jsx(de,{links:a.verificationLinks}),e.jsx(k,{tee:a.tee,scope:a.teeScope}),a.free&&e.jsx(x,{tone:"success",children:"Free"})]}),actions:e.jsxs(e.Fragment,{children:[e.jsx(w,{iconOnly:!0,value:d,label:`Copy ${y(a)}'s model id (peer@model)`}),e.jsx(J,{size:"sm",variant:c?"outline":"ghost","aria-pressed":c,title:"Use this provider in the API call below",onClick:()=>o(c?"":g(a)),children:c?"Pinned":"Pin"})]})},g(a))})})}),e.jsxs(C,{title:"API call",actions:s.offers.length>0&&e.jsx(A,{size:"sm","aria-label":"Route the call",value:n,onChange:o,options:[{value:"",label:"Best provider (automatic)"},...s.offers.map(a=>({value:g(a),label:y(a)}))]}),children:[e.jsx("p",{className:"gc-fineprint",children:i?e.jsxs(e.Fragment,{children:["Pinned to ",y(i)," 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(ge,{id:"gc-model-call",model:p,format:h,unsupported:`${P[s.type]} models are not served through the gateway's /v1 API.`})]})]})}export{Ie as default};
@@ -1 +0,0 @@
1
- import{j as e,u as te,F as ae,r as k,aH as q,ag as N,aP as ne,aQ as re,w,Y as se,aR as y,B as I,aS as ie,aT as p,T as oe,D as le,aN as M,aU as ce,aF as de,aV as he,q as ue,aW as we,aX as fe,aE as L,aY as H,aZ as R,Z as $}from"./index-CL8Uzy58.js";import{u as Z,a as V,T as K,D as C,s as U}from"./useTx-rdzQSfyH.js";import{a as ge,C as X}from"./ConnectWallet-BPEdComN.js";import{W as me,u as G,c as Y,b as ye,r as Q}from"./en_US-Y4ZOVFV4-CkCCvmU2.js";import"./clsx-B-dksMZM.js";import"./index-BwpQbdIU.js";async function J(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=Y(),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:C,functionName:"getOperator",args:[c],chainId:s.chainId}),Q(i,{address:a,abi:C,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}=G(),W=Y(),o=Z(a.chainId),{writeContractAsync:B}=V(),{signMessageAsync:P}=ye(),{me:z}=te(),E=ae(),v=ee(a),[x,h]=k.useState(!1),[f,b]=k.useState(!1),[g,u]=k.useState(null),m=q(a,"deposits");if(!m)return e.jsx(N,{tone:"warning",children:"The gateway did not report the deposits contract address."});if(!n)return e.jsx(X,{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(L(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},F=await o.run([{label:"Authorize wallet",check:async()=>{try{H(t,await v(t.buyer),O)}catch(D){if(!(D instanceof M)||!D.retryAuth)throw D;o.setStatus("The operator nonce changed; getting a fresh authorization…");const _=await R.authorize(s,r);H(_,await v(_.buyer),O),t=_}await U(W,{account:n,address:m,abi:C,functionName:"setOperator",args:[t.buyer,r,BigInt(t.nonce),t.signature],chainId:a.chainId})},send:()=>B({address:m,abi:C,functionName:"setOperator",args:[t.buyer,r,BigInt(t.nonce),t.signature],chainId:a.chainId})}],{onStale:d});F&&c(await J(s,F,r))}async function l(r){b(!0),o.setError(null);try{const t=r==="passkey"?await ce():await de(n,O=>P({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:L(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(N,{tone:"warning",children:j}),x&&e.jsx(N,{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(I,{size:"sm",disabled:f,onClick:()=>void l("passkey"),children:"Confirm with a passkey"}),e.jsx(I,{size:"sm",variant:"outline",disabled:f,onClick:()=>void l("wallet"),children:f?"Check your wallet…":`Confirm with ${w(n)}`})]})]})}),e.jsx(K,{chain:a,runner:o,done:"Wallet authorized."}),e.jsx(I,{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}=G(),W=Y(),o=Z(a.chainId),{writeContractAsync:B}=V(),P=ee(a),[z,E]=k.useState(""),[v,x]=k.useState(!1),[h,f]=k.useState(null),b=q(a,"deposits"),g=ie(i,n);if(!b)return e.jsx(N,{tone:"warning",children:"The gateway did not report the deposits contract address."});if(!n)return e.jsx(X,{label:`Connect ${w(i.operator)} to manage it`});if(!g.canManage)return e.jsx(N,{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 P(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 U(W,{account:n,address:b,abi:C,functionName:"transferOperator",args:[i.buyer,l],chainId:a.chainId})},send:()=>B({address:b,abi:C,functionName:"transferOperator",args:[i.buyer,l],chainId:a.chainId})}],{onStale:d});T&&(E(""),x(!1),c(await J(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(K,{chain:a,runner:o,done:"Authorized wallet updated."}),e.jsxs("div",{className:"gc-inline gc-inline--wrap",children:[e.jsx(I,{disabled:o.running||!m||A||!j&&!v,onClick:()=>f("transfer"),children:"Transfer authorization"}),e.jsx(I,{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 Ae(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{Ae as default};
@@ -1 +0,0 @@
1
- import{r as y,a2 as G,a3 as J,a4 as K,a5 as B,u as X,a6 as Z,j as e,a7 as ee,a8 as se,a9 as le,aa as A,B as j,ab as ie,ac as F,T as z,D as ne,ad as E,I as ae,ae as te,af as re,ag as ce,ah as oe,ai as de,aj as me,ak as he}from"./index-CL8Uzy58.js";import{P as k,C as ue}from"./PeerPicker-BvexRNjB.js";import{S}from"./SelectField-CL9GSHwf.js";import{S as v}from"./Segmented-D-_FvNVa.js";import{S as T}from"./Switch-C5_JEBYO.js";import{D as R}from"./Disclosure-DaXKEWtB.js";function pe({draft:l,parent:d,above:t,peers:c,lists:m}){const n=y.useMemo(()=>{if(!c||c.length===0)return null;let h;try{h=te(l,m)}catch{return null}return{matched:re(B(d,h),c,m).length,total:c.length}},[l,d,c,m]);return n?n.matched===0?e.jsxs(ce,{tone:"warning",title:"No seller matches this policy",children:["With ",t?`${t} and `:"","these settings, none of the ",n.total," sellers this gateway sees can serve a request. Requests will fail until you loosen it."]}):e.jsxs("p",{className:"gc-muted","aria-live":"polite",children:["Matches ",n.matched," of ",n.total," sellers",t?` after ${t}`:"","."]}):null}function Ne({value:l,onChange:d,peers:t,lists:c,showTemplates:m=!0,parent:n,disabled:h}){const[x,b]=y.useState(""),[o,p]=y.useState(null),a=(s,r)=>d({...l,[s]:r}),N=G(t),I=c.map(s=>({value:s.id,label:`${s.name} (${s.peerIds.length})`})),g=J(K().data),i=y.useMemo(()=>g||n?B(g,n):null,[g,n]),D=g&&n?"the buyer config and the levels above":g?"the buyer config":n?"the levels above":"",w=s=>(g==null?void 0:g[s])!==void 0&&g[s]===(i==null?void 0:i[s])?"The buyer config":"The levels above",{viewer:W}=X(),Y=Z("settings",W)?e.jsx("a",{className:"gc-link",href:se("settings?tab=buyer"),onClick:ee("settings?tab=buyer"),children:"Change"}):null,O=s=>w(s)==="The buyer config"?Y:null,H=le(t)||l.minReputation!==""||(i==null?void 0:i.minReputation)!==void 0;function q(s){var $;let r;if(s==="own"){const C=c.find(Q=>Q.id===x);if(!C)return;r={allowMode:"only",allowedPeerIds:[],allowedListIds:[C.id]}}else r=oe(de(s));const u=me(l,r),f=(($=A.find(C=>C.id===s))==null?void 0:$.label)??s;u.length>0?p({label:f,template:r,conflicts:u}):d(E(l,r))}function P(s,r){a("routes",l.routes.map((u,f)=>f===s?r:u))}const M=[l.maxInputUsdPerMillion,l.maxOutputUsdPerMillion,l.maxCachedInputUsdPerMillion,l.maxImageUsdPerImage].filter(s=>s.trim()!=="").length,_=(s,r)=>e.jsx(z,{size:"sm",className:"gc-num",label:r,inputMode:"decimal",value:l[s],placeholder:(i==null?void 0:i[s])!==void 0?`≤ ${he(i[s])} above`:"No cap",onChange:u=>a(s,u.target.value)}),L=e.jsxs(e.Fragment,{children:[e.jsx(pe,{draft:l,parent:i,above:D,peers:t,lists:c}),m&&!h&&e.jsxs("div",{className:"gc-policy__templates",children:[e.jsx("span",{className:"gc-muted",children:"Start from"}),A.filter(s=>s.id!=="own").map(s=>e.jsx(j,{size:"sm",variant:"outline",title:s.description,onClick:()=>q(s.id),children:s.label},s.id)),c.length>0&&e.jsxs("span",{className:"gc-inline",children:[e.jsx(S,{size:"sm","aria-label":"Peer list for Own peers only",value:x,onChange:b,options:[{value:"",label:"Own peer list…"},...I]}),e.jsx(j,{size:"sm",variant:"outline",disabled:!x,onClick:()=>q("own"),children:"Use"})]}),e.jsx(j,{size:"sm",variant:"link",className:"gc-policy__clear",onClick:()=>d(ie()),children:"Clear policy"})]}),e.jsxs("div",{className:"gc-policy__cols",children:[e.jsxs("section",{className:"gc-policy__section",children:[e.jsx("h3",{children:"Sellers"}),e.jsx(v,{label:"Which sellers may serve",value:l.allowMode,onChange:s=>a("allowMode",s),options:[{value:"any",label:"Any seller"},{value:"only",label:"Only these"}]}),l.allowMode==="only"&&e.jsxs(e.Fragment,{children:[e.jsx(k,{label:"Allowed sellers",value:l.allowedPeerIds,onChange:s=>a("allowedPeerIds",s),peers:t}),e.jsx(V,{label:"Allowed peer lists",lists:c,value:l.allowedListIds,onChange:s=>a("allowedListIds",s)}),l.allowedPeerIds.length===0&&l.allowedListIds.length===0&&e.jsx("p",{className:"gc-warn",children:"An empty allow list means no seller can serve."})]}),e.jsx(k,{label:"Blocked sellers",value:l.blockedPeerIds,onChange:s=>a("blockedPeerIds",s),peers:t}),e.jsx(V,{label:"Blocked peer lists",lists:c,value:l.blockedListIds,onChange:s=>a("blockedListIds",s)})]}),e.jsxs("section",{className:"gc-policy__section",children:[e.jsx("h3",{children:"Quality and ranking"}),e.jsx(U,{label:"Minimum trust score",value:l.minTrustScore,onChange:s=>a("minTrustScore",s),floor:i==null?void 0:i.minTrustScore,floorSource:w("minTrustScore"),floorAction:O("minTrustScore")}),e.jsxs("div",{className:"gc-policy__switches",children:[e.jsx(T,{checked:l.requireTee||!!(i!=null&&i.requireTee),disabled:!!(i!=null&&i.requireTee),onChange:s=>a("requireTee",s),label:"TEE sellers only"}),e.jsx(T,{checked:l.requireVerified||!!(i!=null&&i.requireVerified),disabled:!!(i!=null&&i.requireVerified),onChange:s=>a("requireVerified",s),label:"Verified sellers only"})]}),((i==null?void 0:i.requireTee)||(i==null?void 0:i.requireVerified))&&e.jsxs("span",{className:"as-field__hint",children:[i.requireTee&&i.requireVerified?"TEE and verified sellers are":i.requireTee?"TEE sellers are":"Verified sellers are"," already required above."]}),e.jsxs("div",{className:"gc-policy__pair",children:[e.jsx(S,{size:"sm",label:"Sort by",value:l.sort,onChange:s=>a("sort",s),options:[{value:"",label:"Inherit"},...Object.keys(F).map(s=>({value:s,label:F[s]}))]}),e.jsx(S,{size:"sm",label:"Free sellers first",value:l.preferFreePeers,onChange:s=>a("preferFreePeers",s),options:[{value:"inherit",label:"Inherit"},{value:"yes",label:"Yes"},{value:"no",label:"No"}]})]}),e.jsx(v,{label:"Which models may be used",value:l.modelsMode,onChange:s=>a("modelsMode",s),options:[{value:"any",label:"Any model"},{value:"only",label:"Only these models"}]}),l.modelsMode==="only"&&e.jsx(ue,{label:"Allowed models",value:l.allowedModels,onChange:s=>a("allowedModels",s),suggestions:N,placeholder:"Model id"})]})]}),e.jsxs("div",{className:"gc-policy__advanced",children:[e.jsx(R,{title:"Price caps",summary:M?`${M} set`:"None",defaultOpen:h&&M>0,children:e.jsxs("div",{className:"gc-policy__caps",children:[_("maxInputUsdPerMillion","Input $/M"),_("maxOutputUsdPerMillion","Output $/M"),_("maxCachedInputUsdPerMillion","Cached input $/M"),_("maxImageUsdPerImage","$ per image")]})}),e.jsxs(R,{title:"Fallback chains",summary:l.routes.length?`${l.routes.length} chain${l.routes.length===1?"":"s"}`:"None",defaultOpen:h&&l.routes.length>0,children:[e.jsx("p",{className:"gc-fineprint",children:"Sellers to try first for a model, in order. After the chain, normal ranking continues unless the chain is strict."}),l.routes.map((s,r)=>e.jsxs("div",{className:"gc-route",children:[e.jsxs("div",{className:"gc-inline",children:[e.jsx(z,{size:"sm",label:"Model",list:"gc-policy-models",value:s.model,placeholder:"Model id",onChange:u=>P(r,{...s,model:u.target.value})}),e.jsx(T,{checked:s.strict,onChange:u=>P(r,{...s,strict:u}),label:"Strict"}),e.jsx(j,{variant:"ghost",size:"sm",onClick:()=>a("routes",l.routes.filter((u,f)=>f!==r)),children:"Remove"})]}),e.jsx(k,{label:"Sellers, in order",ordered:!0,value:s.peerIds,onChange:u=>P(r,{...s,peerIds:u}),peers:t})]},r)),e.jsx("datalist",{id:"gc-policy-models",children:N.map(s=>e.jsx("option",{value:s},s))}),e.jsx("div",{children:e.jsx(j,{variant:"outline",size:"sm",onClick:()=>a("routes",[...l.routes,{model:"",peerIds:[],strict:!1}]),children:"Add fallback chain"})})]}),H&&e.jsx(R,{title:"Reputation",summary:l.minReputation!==""?`≥ ${l.minReputation}`:(i==null?void 0:i.minReputation)!==void 0?`Inherit (≥ ${i.minReputation})`:"Inherit",defaultOpen:h&&l.minReputation!=="",children:e.jsx(U,{label:"Minimum reputation",value:l.minReputation,onChange:s=>a("minReputation",s),floor:i==null?void 0:i.minReputation,floorSource:w("minReputation"),floorAction:O("minReputation")})})]}),e.jsx(ne,{isOpen:o!==null,tone:"primary",title:`Apply “${(o==null?void 0:o.label)??""}”?`,confirmLabel:"Replace and apply",body:e.jsxs(e.Fragment,{children:["This template changes settings you already set: ",e.jsx("strong",{children:o==null?void 0:o.conflicts.join(", ")}),". Your other settings stay."]}),onClose:()=>p(null),onConfirm:()=>{o&&d(E(l,o.template)),p(null)}})]});return h?e.jsx("fieldset",{className:"gc-policy gc-policy--readonly",disabled:!0,children:L}):e.jsx("div",{className:"gc-policy",children:L})}function U({label:l,value:d,onChange:t,clearable:c=!0,hint:m,floor:n,floorSource:h="The levels above",floorAction:x}){const b=y.useId(),o=d!=="",p=n!==void 0&&n>0,a=p&&o&&Number(d)<=n,N=a?String(n):o?d:p?`${n} inherited`:"Inherit";return e.jsxs("div",{className:"gc-slider",children:[e.jsxs("div",{className:"gc-slider__head",children:[e.jsx("span",{className:"as-field__label",id:b,children:l}),e.jsx("span",{className:o?"gc-slider__value":"gc-slider__value gc-slider__value--inherit",children:N})]}),e.jsxs("div",{className:"gc-inline",children:[e.jsx("input",{type:"range",min:0,max:100,step:5,value:o?Math.max(Number(d),p?n:0):p?n:0,"aria-labelledby":b,onChange:I=>t(String(Math.max(Number(I.target.value),p?n:0)))}),c&&o&&e.jsx(j,{variant:"ghost",size:"sm",onClick:()=>t(""),children:"Clear"})]}),p&&(o&&!a?e.jsxs("span",{className:"as-field__hint",children:[h," requires ≥ ",n,". Only a higher value narrows it."]}):e.jsxs("span",{className:"as-field__hint gc-override",children:[e.jsx(ae.lock,{size:12})," Locked at ",n," by ",h.replace(/^The /,"the "),".",x?e.jsxs(e.Fragment,{children:[" ",x]}):null]})),m&&e.jsx("span",{className:"as-field__hint",children:m})]})}function V({label:l,lists:d,value:t,onChange:c}){return d.length===0?null:e.jsxs("fieldset",{className:"gc-checks",children:[e.jsx("legend",{className:"as-field__label",children:l}),d.map(m=>e.jsxs("label",{className:"gc-check",children:[e.jsx("input",{type:"checkbox",checked:t.includes(m.id),onChange:n=>c(n.target.checked?[...t,m.id]:t.filter(h=>h!==m.id))}),m.name," ",e.jsxs("span",{className:"gc-muted",children:["(",m.peerIds.length,")"]})]},m.id))]})}export{Ne as P,U as S};
@@ -1,4 +0,0 @@
1
- import{u as A,i as J,bp as B,r as n,t as E,j as e,P as $,B as y,I as k,l as L,Q as R,M as Q,aM as U,v as C,A as V,E as W,n as F,C as G,D as H,b as K,T as j,a2 as _,o as X,q as O,f as v}from"./index-CL8Uzy58.js";import{u as Y,a as Z,P as ee}from"./PolicyField-BL2_pz19.js";import{D as se}from"./DataTable-nSpXggux.js";import{S as re}from"./SelectField-CL9GSHwf.js";import{T as N}from"./TextAreaField-BwxpmCEP.js";import"./PolicyEditor-zST9UHdU.js";import"./PeerPicker-BvexRNjB.js";import"./Segmented-D-_FvNVa.js";import"./roving-DkptacxO.js";import"./Switch-C5_JEBYO.js";import"./Disclosure-DaXKEWtB.js";function D(s){return s.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)}function te(s){return/^[a-z0-9][a-z0-9-]{0,47}$/.test(s)}function ae(s){if(!s.trim())return{};let a;try{a=JSON.parse(s)}catch{throw new Error("Parameters must be valid JSON.")}if(!a||typeof a!="object"||Array.isArray(a))throw new Error('Parameters must be a JSON object, like {"temperature": 0.2}.');return a}function oe({initial:s,prefill:a,onDone:m}){const{workspace:p,viewer:c}=A(),u=K(),[o,g]=n.useState((s==null?void 0:s.name)??(a==null?void 0:a.name)??""),[l,d]=n.useState((s==null?void 0:s.slug)??(a?D(a.name):"")),[t,M]=n.useState(!!s),[h,q]=n.useState((s==null?void 0:s.model)??(a==null?void 0:a.model)??""),[b,I]=n.useState(s?s.workspaceId??"":p.id),[S,T]=n.useState((s==null?void 0:s.systemPrompt)??""),[w,z]=n.useState(s&&Object.keys(s.params).length?JSON.stringify(s.params,null,2):""),x=Y(s==null?void 0:s.routingPolicy),P=Z(),i=E({mutationFn:()=>{if(!te(l))throw new Error("Slug must be lowercase letters, numbers and dashes.");const r={name:o.trim(),slug:l,model:h.trim(),workspaceId:b||null,systemPrompt:S.trim()||null,params:ae(w),routingPolicy:x.build()};return P.save([r.routingPolicy],f=>s?v.presets.update(s.id,r,f):v.presets.create(r,f))},onSuccess:r=>m(r),invalidate:[O.group("presets")],toast:"Preset saved"});return e.jsxs("form",{className:"gc-stack",onSubmit:r=>{r.preventDefault(),i.mutate()},children:[e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(j,{label:"Name",required:!0,value:o,onChange:r=>{g(r.target.value),t||d(D(r.target.value))}}),e.jsx(j,{label:"Slug",required:!0,value:l,onChange:r=>{M(!0),d(r.target.value)},hint:e.jsxs(e.Fragment,{children:["Called as ",e.jsxs("code",{children:["@preset/",l||"slug"]})]})})]}),e.jsxs("div",{className:"gc-grid gc-grid--2",children:[e.jsx(j,{label:"Model",required:!0,list:"gc-preset-models",value:h,onChange:r=>q(r.target.value)}),e.jsx("datalist",{id:"gc-preset-models",children:_(u.data).map(r=>e.jsx("option",{value:r},r))}),e.jsx(re,{label:"Available in",value:b,onChange:I,options:[{value:p.id,label:`${p.name} workspace`},...F(c)?[{value:"",label:"All workspaces"}]:[]]})]}),e.jsx(N,{label:"System prompt",rows:4,value:S,onChange:r=>T(r.target.value),hint:"Added before the client's messages."}),e.jsx(N,{label:"Parameters (JSON)",rows:4,mono:!0,value:w,placeholder:`{
2
- "temperature": 0.2,
3
- "max_tokens": 2048
4
- }`,onChange:r=>z(r.target.value),hint:"Defaults merged under the client's own parameters."}),e.jsx(ee,{draft:x.draft,setDraft:x.setDraft}),i.error?e.jsx(X,{error:i.error,title:"Could not save the preset"}):null,e.jsxs("div",{className:"gc-actions",children:[e.jsx(y,{variant:"ghost",onClick:()=>m(),children:"Cancel"}),e.jsx(y,{type:"submit",disabled:i.isPending||!o.trim()||!h.trim(),children:i.isPending?"Saving…":"Save preset"})]}),P.dialog]})}function je(){const{workspace:s,viewer:a}=A(),m=J(a),p=B(s.id),[c,u]=n.useState(null),[o,g]=n.useState(null),l=E({mutationFn:d=>v.presets.remove(d.id),onSuccess:()=>g(null),invalidate:[O.group("presets")]});return e.jsxs("div",{className:"gc-page",children:[e.jsx($,{title:"Presets",description:e.jsxs(e.Fragment,{children:["A saved model, prompt, parameters and routing. Use one by sending ",e.jsx("code",{children:'"model": "@preset/<slug>"'}),"."]}),actions:m&&e.jsx(y,{variant:"brand",leadingIcon:e.jsx(k.plus,{size:14}),onClick:()=>u("new"),children:"New preset"})}),e.jsx(L,{flush:!0,children:e.jsx(R,{query:p,children:d=>e.jsx(se,{label:"Presets",rows:d,rowKey:t=>t.id,rowLabel:t=>t.name,actions:t=>m&&(t.workspaceId||F(a))?[{label:"Edit",onSelect:()=>u(t)},{label:"Delete",tone:"danger",onSelect:()=>g(t)}]:[],empty:e.jsx(W,{icon:e.jsx(k.presets,{size:18}),title:"No presets yet",body:"Presets let every client share one tuned setup without changing code."}),columns:[{key:"name",header:"Name",render:t=>e.jsx("span",{className:"gc-strong",children:t.name})},{key:"usage",header:"Use as model",render:t=>e.jsxs("span",{className:"gc-inline gc-inline--wrap",children:[e.jsxs(Q,{children:["@preset/",t.slug]}),e.jsx(U,{value:`@preset/${t.slug}`})]})},{key:"model",header:"Model",secondary:!0,render:t=>t.model},{key:"scope",header:"Scope",secondary:!0,render:t=>t.workspaceId?e.jsx(C,{children:"Workspace"}):e.jsx(C,{tone:"info",children:"All workspaces"})},{key:"policy",header:"Routing",secondary:!0,optional:!0,render:t=>e.jsx("span",{className:"gc-muted",children:V(t.routingPolicy)})}]})})}),e.jsx(G,{isOpen:c!==null,onClose:()=>u(null),size:"lg",title:c==="new"?"New preset":"Edit preset",children:c!==null&&e.jsx(oe,{initial:c==="new"?null:c,onDone:()=>u(null)})}),e.jsx(H,{isOpen:o!==null,busy:l.isPending,error:l.error,onClose:()=>g(null),onConfirm:()=>o&&l.mutate(o),title:"Delete this preset?",confirmLabel:"Delete preset",body:e.jsxs(e.Fragment,{children:["Requests that use ",e.jsxs("code",{children:["@preset/",o==null?void 0:o.slug]})," will fail."]})})]})}export{oe as PresetForm,je as default};
@@ -1 +0,0 @@
1
- import{bX as Ke,ax as pe,b3 as Ge,u as X,a as fe,F as Qe,G as Ye,n as we,i as ye,r as p,R as He,c as be,e as Je,bY as We,bx as Xe,Z as q,bZ as Ze,b_ as es,f as A,aE as ss,j as s,C as Z,ag as Q,o as ee,B as k,L as ve,A as ts,bs as rs,t as ke,q as xe,l as je,Q as Pe,E as W,I as V,D as ns,T as _,w as F,M as Se,aM as Ce,v as L,as,bV as N,av as Ie,aw as Ne,h as $e,Y as os,bn as Ae,b$ as Fe,bd as ls,bp as is,c0 as cs,X as ds,bf as us,O as ms,bg as hs,bh as gs,b as ps,a2 as fs,a9 as ws,bj as ys,bk as bs,bl as ce,bq as vs,y as de,bm as ks,P as xs}from"./index-CL8Uzy58.js";import{p as Y,P as js}from"./PeerPicker-BvexRNjB.js";import{S as $}from"./SelectField-CL9GSHwf.js";import{D as Le}from"./DataTable-nSpXggux.js";import{V as Me,T as Te,P as De,b as Ps,p as Ss,S as Cs}from"./models-BSFEBc_r.js";import{f as Is}from"./ants-B38m9Phv.js";import{PresetForm as Ns}from"./Presets-CMVeG1hO.js";import{T as $s,a as As}from"./Tabs-iPKA2Kfx.js";import{S as H}from"./Switch-C5_JEBYO.js";import"./PolicyField-BL2_pz19.js";import"./PolicyEditor-zST9UHdU.js";import"./Segmented-D-_FvNVa.js";import"./roving-DkptacxO.js";import"./Disclosure-DaXKEWtB.js";import"./TextAreaField-BwxpmCEP.js";function Ee(e,t="admin"){return t==="owner"&&Ge(e)?"ownerRoutingPolicy":"routingPolicy"}async function Oe(e,t){const r=(await e.keys.list({workspace:t.workspaceId})).find(a=>a.id===t.keyId);if(!r)throw new Error("That key no longer exists.");return r}async function Re(e,t){switch(t.kind){case"gateway":return e.network.gatewayPolicy();case"workspace-org":return(await e.workspaces.get(t.workspaceId)).orgRoutingPolicy;case"workspace":return(await e.workspaces.get(t.workspaceId)).routingPolicy;case"member":{const r=(await e.members.list()).find(a=>a.id===t.memberId);if(!r)throw new Error("That member no longer exists.");return r.routingPolicy}case"key":{const r=await Oe(e,t);return r[Ee(r,t.layer)]??null}}}async function Fs(e,t,r,a){const o=a!=null&&a.confirmEmpty||a!=null&&a.acceptNarrowed?[a]:[];switch(t.kind){case"gateway":await e.network.setGatewayPolicy(r??{},...o);return;case"workspace-org":await e.workspaces.update(t.workspaceId,{orgRoutingPolicy:r},...o);return;case"workspace":await e.workspaces.update(t.workspaceId,{routingPolicy:r},...o);return;case"member":await e.members.update(t.memberId,{routingPolicy:r},...o);return;case"key":{const i=t.layer==="owner"?Ee(await Oe(e,t),"owner"):"routingPolicy";await e.keys.update(t.keyId,{[i]:r},...o);return}}}const ue=e=>JSON.stringify(e??{},Object.keys(e??{}).sort());async function Ls(e,t,r,a,o,i){const m=await Re(e,t),c=Ke(m,r,a,o),g=ue(m)!==ue(c)||JSON.stringify(m??{})!==JSON.stringify(c);return g&&await Fs(e,t,c,i),{before:m,after:c,changed:g}}function Ms(e,t,r){return e.kind==="key"?{model:t,key:e.keyId,workspace:e.workspaceId}:e.kind==="member"?{model:t,member:e.memberId,workspace:r}:e.kind==="gateway"?{model:t,workspace:r}:{model:t,workspace:e.workspaceId}}const Ts={allow:"Allowed",block:"Blocked",prefer:"Preferred"};function Ds(e){const{action:t,name:r,scopeLabel:a,changed:o,model:i,preview:m,peerId:c}=e,g=Ts[t],f=t==="prefer"?`already first for ${i}`:`already ${g.toLowerCase()}`,l=o?`${g} ${r} ${t==="prefer"?`for ${i} `:""}on ${a}`:`${r} was ${f} on ${a}; nothing changed`;if(!m)return t==="block"?{tone:o?"success":"info",text:`${l}.`}:{tone:"info",text:`${l}. ${e.previewError?`Could not check whether it can serve: ${e.previewError}`:"Could not check whether it can serve."}`};const u=m.candidates.find(b=>pe(b.peerId,c));if(t==="block")return u!=null&&u.eligible?{tone:"warning",text:`${l}, but the route preview still lists it as eligible for ${i}. Reload and check the policy.`}:{tone:o?"success":"info",text:`${l}.`};if(!m.modelAllowed)return{tone:"warning",text:`${l}, but ${i} is not an allowed model here, so it still cannot serve it.`};if(!u)return{tone:"info",text:`${l}. It does not offer ${i} right now, so the preview cannot show its rank.`};if(!u.eligible){const b=u.reasons.length?u.reasons.join("; "):"another level excludes it";return{tone:"warning",text:`${l}, but it still cannot serve ${i} here: ${b}.`}}return t==="prefer"&&u.rank!==null&&u.rank>1?{tone:"warning",text:`${l}, but it ranks #${u.rank} for ${i}: a fallback chain on another level comes first.`}:{tone:o?"success":"info",text:`${l}.${u.rank?` It ranks #${u.rank} for ${i}.`:""}`}}function Es(e,t,r,a){return e==="gateway"?{kind:e}:e==="workspace"||e==="workspace-org"?{kind:e,workspaceId:r}:t?e==="member"?{kind:e,memberId:t}:{kind:"key",keyId:t,workspaceId:r,layer:a?"admin":"owner"}:null}function Os(e){return e.canForce?"Not allowed above":e.tone==="warning"?"Check the result":"Done"}function Rs({fetching:e,error:t,ready:r,policy:a}){return e?s.jsx(ve,{rows:1}):t?s.jsx(ee,{error:t,title:"Could not load this scope's policy"}):r?s.jsxs("p",{className:"gc-muted",children:["Current policy: ",ts(a)]}):null}const me={allow:{title:"Allow seller",verb:"Allow"},block:{title:"Block seller",verb:"Block"},prefer:{title:"Prefer seller",verb:"Prefer"}};function Be({peer:e,action:t,onClose:r,peers:a}){var te,re,ne,ae;const{viewer:o,workspace:i,me:m}=X(),c=fe(),g=Qe(),f=Ye(),l=we(o),u=ye(o),b=[...l?[{value:"gateway",label:"Gateway default (everyone)"}]:[],...l?[{value:"workspace-org",label:`${i.name}: organization policy`}]:[],...u?[{value:"workspace",label:`${i.name}: workspace policy`}]:[],...l?[{value:"member",label:"A member"}]:[],{value:"key",label:"An API key"}],[y,h]=p.useState(b[0].value),[n,v]=p.useState(""),[x,E]=p.useState(""),O=He(y==="member"),R=be(c,y==="key");p.useEffect(()=>{v("")},[y]),p.useEffect(()=>{var d;E(((d=e==null?void 0:e.services[0])==null?void 0:d.service)??"")},[e]);const w=(R.data??[]).filter(d=>d.status==="active"&&(u||d.ownerMemberId===m.member.id)),j=Es(y,n,i.id,u),[C,T]=p.useState(null);p.useEffect(()=>{T(null)},[y,n,e]);const B=Je({queryKey:["routing","scope-policy",j],queryFn:()=>Re(A,j),enabled:j!==null&&e!==null,staleTime:0}),z=j!==null&&B.isSuccess&&(t!=="prefer"||x!==""),I=B.data??null,Ve=t==="allow"&&z&&!(I!=null&&I.allowedPeerIds)&&!(I!=null&&I.allowedPeerLists),_e=t==="block"&&z&&e!==null&&We(I,e.peerId);let D=((te=b.find(d=>d.value===y))==null?void 0:te.label.replace(/^A[n]? /,"the "))??"this scope";y==="key"&&(D=`key “${((re=w.find(d=>d.id===n))==null?void 0:re.label)??n}”`),y==="member"&&(D=`member “${((ae=(ne=O.data)==null?void 0:ne.find(d=>d.id===n))==null?void 0:ae.label)??n}”`);const P=Xe({mutationFn:async(d={})=>{var ie;if(!e||!j)return null;const S=x||((ie=e.services[0])==null?void 0:ie.service)||"",{changed:G}=await Ls(A,j,t,e.peerId,x||void 0,d);let oe=null,le=null;if(S)try{oe=await A.network.routePreview(Ms(j,S,i.id))}catch(Ue){le=ss(Ue)}return Ds({action:t,name:Y(a,e.peerId),scopeLabel:D,changed:G,model:S,preview:oe,peerId:e.peerId,previewError:le})},onSuccess:d=>{for(const S of es)g.invalidateQueries({queryKey:[S]});d&&(d.tone==="success"?(f(d.text),r()):T(d))},onError:d=>{const S=e?Y(a,e.peerId):"this seller";if(q(d,"narrowed"))T({tone:"warning",canForce:!0,text:`Nothing changed yet. The levels above ${D} do not allow ${S}, so saving this would not let it serve. ${Ze(d.details).join(" ")}`.trim()});else if(q(d,"empty_allow_list")){const G=t==="block"?`Blocking ${S}`:`Allowing only ${S}`;T({tone:"warning",text:`Nothing changed. ${G} on ${D} would leave no seller that the levels above allow, so requests would fail. Change the policy on the Routing page if you really want that.`})}}}),K=e?Y(a,e.peerId):"";return s.jsx(Z,{isOpen:e!==null,onClose:r,title:me[t].title,subtitle:K,children:s.jsxs("div",{className:"gc-stack",children:[s.jsx($,{label:"Apply to",value:y,onChange:d=>h(d),options:b}),y==="member"&&s.jsx($,{label:"Member",value:n,onChange:v,options:[{value:"",label:"Choose a member"},...(O.data??[]).filter(d=>d.status!=="disabled").map(d=>({value:d.id,label:d.label}))]}),y==="key"&&s.jsx($,{label:"Key",value:n,onChange:v,options:[{value:"",label:w.length?"Choose a key":"No keys you can edit"},...w.map(d=>({value:d.id,label:d.label}))]}),t==="prefer"&&e&&s.jsx($,{label:"For model",value:x,onChange:E,options:e.services.map(d=>({value:d.service,label:d.service})),hint:"The seller goes first in this model's fallback chain."}),s.jsx(Rs,{fetching:B.isFetching,error:B.error,ready:z,policy:I}),Ve&&s.jsxs(Q,{tone:"warning",children:["This scope has no allow list yet. Allowing ",K," creates one, so only allowed sellers can serve it."]}),_e&&s.jsxs(Q,{tone:"warning",title:"This is the only allowed seller",children:["Blocking ",K," empties this scope's allow list, so the allow list is removed: any seller that is not blocked may serve it again."]}),t==="block"&&s.jsx("p",{className:"gc-muted",children:"Blocked sellers never serve this scope or anything under it."}),y==="key"&&!u&&s.jsx("p",{className:"gc-muted",children:"This changes your own restrictions on the key. Restrictions a workspace admin set still apply."}),P.error&&!q(P.error,"narrowed")&&!q(P.error,"empty_allow_list")?s.jsx(ee,{error:P.error,title:"Could not update the policy"}):null,C?s.jsxs(s.Fragment,{children:[s.jsx(Q,{tone:C.tone,title:Os(C),children:C.text}),s.jsxs("div",{className:"gc-actions",children:[C.canForce&&s.jsx(k,{variant:"ghost",disabled:P.isPending,onClick:()=>{T(null),P.mutate({acceptNarrowed:!0})},children:"Save it anyway"}),s.jsx(k,{onClick:r,children:C.canForce?"Cancel":"Done"})]})]}):s.jsxs("div",{className:"gc-actions",children:[s.jsx(k,{variant:"ghost",onClick:r,children:"Cancel"}),s.jsx(k,{variant:t==="block"?"danger":"primary",disabled:!z||P.isPending,onClick:()=>P.mutate({}),children:P.isPending?"Saving…":me[t].verb})]})]})})}function Bs({initial:e,peers:t,onDone:r}){const[a,o]=p.useState((e==null?void 0:e.name)??""),[i,m]=p.useState((e==null?void 0:e.description)??""),[c,g]=p.useState((e==null?void 0:e.peerIds)??[]),f=ke({mutationFn:()=>{const l={name:a.trim(),description:i.trim()||null,peerIds:c};return e?A.network.updatePeerList(e.id,l):A.network.createPeerList(l)},onSuccess:r,invalidate:[xe.peerLists]});return s.jsxs("form",{className:"gc-stack",onSubmit:l=>{l.preventDefault(),f.mutate()},children:[s.jsx(_,{label:"Name",required:!0,placeholder:"e.g. Our own sellers",value:a,onChange:l=>o(l.target.value)}),s.jsx(_,{label:"Description",value:i,onChange:l=>m(l.target.value)}),s.jsx(js,{label:"Sellers",value:c,onChange:g,peers:t}),s.jsx("p",{className:"gc-fineprint",children:"Policies refer to a list by name, so editing it changes every policy that uses it."}),f.error?s.jsx(ee,{error:f.error,title:"Could not save the list"}):null,s.jsxs("div",{className:"gc-actions",children:[s.jsx(k,{variant:"ghost",onClick:r,children:"Cancel"}),s.jsx(k,{type:"submit",disabled:f.isPending||!a.trim(),children:f.isPending?"Saving…":"Save list"})]})]})}function zs({peers:e}){const{viewer:t}=X(),r=we(t),a=rs(),[o,i]=p.useState(null),[m,c]=p.useState(null),g=ke({mutationFn:f=>A.network.removePeerList(f.id),onSuccess:()=>c(null),invalidate:[xe.peerLists]});return s.jsxs(je,{flush:!0,title:"Peer lists",description:"Named groups of sellers to allow or block in one step.",actions:r&&s.jsx(k,{size:"sm",variant:"outline",leadingIcon:s.jsx(V.plus,{size:14}),onClick:()=>i("new"),children:"New list"}),children:[s.jsx(Pe,{query:a,children:f=>s.jsx(Le,{label:"Peer lists",rows:f,rowKey:l=>l.id,rowLabel:l=>l.name,actions:l=>r?[{label:"Edit",onSelect:()=>i(l)},{label:"Delete",tone:"danger",onSelect:()=>c(l)}]:[],empty:s.jsx(W,{icon:s.jsx(V.network,{size:18}),title:"No peer lists",body:"Group sellers you trust, or ones you run yourself."}),columns:[{key:"name",header:"Name",render:l=>s.jsx("span",{className:"gc-strong",children:l.name})},{key:"desc",header:"Description",secondary:!0,render:l=>s.jsx("span",{className:"gc-muted",children:l.description??"—"})},{key:"count",header:"Sellers",align:"right",render:l=>l.peerIds.length}]})}),s.jsx(Z,{isOpen:o!==null,onClose:()=>i(null),title:o==="new"?"New peer list":"Edit peer list",size:"lg",children:o!==null&&s.jsx(Bs,{initial:o==="new"?null:o,peers:e,onDone:()=>i(null)})}),s.jsx(ns,{isOpen:m!==null,busy:g.isPending,error:g.error,onClose:()=>c(null),onConfirm:()=>m&&g.mutate(m),title:"Delete this list?",confirmLabel:"Delete",body:"Policies refer to lists by reference: once deleted, the list adds no sellers to them. An allow list made only of deleted lists lets no seller serve."})]})}function ze(e,t){return t?e.services.filter(r=>r.service===t):e.services}function U(e,t,r=""){const a=ze(e,r).map(o=>o[t]).filter(o=>o!==null);return a.length?{min:Math.min(...a),max:Math.max(...a)}:null}function qs(e,t=""){var r;return((r=U(e,"inputUsdPerMillion",t))==null?void 0:r.min)??null}function Vs(e,t=""){var r;return((r=U(e,"outputUsdPerMillion",t))==null?void 0:r.min)??null}function se(e,t=""){return ze(e,t).some(r=>r.inputUsdPerMillion===0&&(r.outputUsdPerMillion??0)===0)}function _s(e,t){const r=t.search.trim().toLowerCase();return e.filter(a=>{var o;return!(r&&!a.peerId.toLowerCase().includes(r)&&!(a.displayName??"").toLowerCase().includes(r)&&!a.services.some(i=>i.service.toLowerCase().includes(r))||t.model&&!a.services.some(i=>i.service===t.model)||t.tee&&!a.tee||t.linked&&!((o=a.verificationLinks)!=null&&o.length)||t.free&&!se(a,t.model))})}const qe={"openai-chat-completions":"Chat completions","openai-responses":"Responses","anthropic-messages":"Messages","openai-images":"Images"};function he(e){return e===null?"—":String(Math.round(e))}function J(e){return e.displayName??F(e.peerId,8,4)}function M(e){return`${e.provider}:${e.service}`}function Us({peer:e}){const t=(e.health.coolingDownUntil??0)>Date.now();return s.jsxs("span",{className:"gc-seller__meta",children:[s.jsxs("span",{className:"gc-peer-id",children:[s.jsx(Se,{title:e.peerId,children:F(e.peerId,6,4)}),s.jsx(Ce,{iconOnly:!0,value:e.peerId,label:"Copy peer id"})]}),s.jsx(Me,{links:e.verificationLinks}),s.jsx(Te,{tee:e.tee,scope:e.teeScope}),se(e,"")&&s.jsx(L,{tone:"success",children:"Free"}),e.washFlagged&&s.jsx(L,{tone:"danger",children:"Flagged"}),t&&s.jsx(L,{tone:"warning",children:"Cooling down"}),s.jsxs("span",{className:"gc-muted",children:["Last seen ",as(e.lastSeen)]})]})}function Ks({peer:e,showReputation:t}){const r=(e.health.coolingDownUntil??0)>Date.now();return s.jsxs("div",{className:"gc-grid gc-grid--2 gc-figures gc-panel-figures",children:[s.jsx(N,{label:"Trust score",value:he(e.trustScore)}),t&&s.jsx(N,{label:"Reputation",value:he(e.reputationScore)}),s.jsx(N,{label:"Stake",value:e.stakeAnts?Is(e.stakeAnts):"—"}),s.jsx(N,{label:"Network usage share",value:e.usageShareBps===null?"—":`${(e.usageShareBps/100).toFixed(2)}%`}),s.jsx(N,{label:"First token p50 (this gateway)",value:Ie(e.firstTokenMsP50)}),s.jsx(N,{label:"Speed p50 (this gateway)",value:Ne(e.tokensPerSecondP50)}),s.jsx(N,{label:"Requests, 24h (this gateway)",value:$e(e.requests24h)}),s.jsx(N,{label:"Failure streak",value:r?`${e.health.failureStreak}, cooling down until ${os(e.health.coolingDownUntil)}`:String(e.health.failureStreak)})]})}function Gs({peer:e,selected:t,onSelect:r}){const[a,o]=p.useState(""),i=a.trim().toLowerCase(),m=e.services.filter(c=>!i||c.service.toLowerCase().includes(i));return s.jsx(De,{title:`Models (${e.services.length})`,actions:e.services.length>6&&s.jsx(_,{size:"sm",type:"search","aria-label":"Search this provider's models",placeholder:"Search models",value:a,onChange:c=>o(c.target.value)}),children:m.length===0?s.jsx("p",{className:"gc-fineprint",children:i?"No models match.":"This provider lists no models."}):s.jsx("ul",{className:"gc-panel-rows","aria-label":"Models and prices",children:m.map(c=>{const g=t!==null&&M(t)===M(c);return s.jsx(Ps,{selected:g,title:s.jsx("span",{className:"gc-strong",children:c.service}),meta:s.jsxs(s.Fragment,{children:[s.jsx("span",{children:Ss(c)}),s.jsx("span",{children:qe[Fe(c)]})]}),actions:s.jsxs(s.Fragment,{children:[s.jsx(Ce,{iconOnly:!0,value:Ae(e.peerId,c.service),label:`Copy ${c.service} pinned to this provider (peer@model)`}),s.jsx(k,{size:"sm",variant:g?"outline":"ghost","aria-pressed":g,title:"Show the API call for this model",onClick:()=>r(c),children:"API call"})]})},M(c))})})})}function Qs({peer:e,service:t,onSelect:r}){var R;const{workspace:a,viewer:o}=X(),i=fe(),m=ls(),c=be(i),g=is(a.id),[f,l]=p.useState("curl"),[u,b]=p.useState(!1),y=Fe(t),h=Ae(e.peerId,t.service),n=((R=g.data)==null?void 0:R.find(w=>w.model===h))??null,v=cs(m,e.peerId,t.service,y,n?`@preset/${n.slug}`:null),x=v.find(w=>w.id===f)??v[0],E=(c.data??[]).some(w=>w.status==="active"),O=ye(o);return s.jsxs(De,{title:"API call",actions:e.services.length>1&&s.jsx($,{size:"sm","aria-label":"Model",value:M(t),onChange:w=>{const j=e.services.find(C=>M(C)===w);j&&r(j)},options:e.services.map(w=>({value:M(w),label:w.service}))}),children:[s.jsxs("p",{className:"gc-fineprint",children:["Pinned to this provider with ",s.jsx("code",{children:F(h,10,12)}),"."]}),s.jsx($s,{id:"gc-connect",label:"Ways to connect",value:x.id,onChange:l,className:"gc-connect-tabs",tabs:v.map(w=>({id:w.id,label:w.label}))}),s.jsxs(As,{tabsId:"gc-connect",tab:x.id,className:"gc-stack",children:[x.id==="codex"&&s.jsxs("div",{className:"gc-summary-row",children:[s.jsx("p",{className:"gc-fineprint gc-summary-row__text",children:n?s.jsxs(s.Fragment,{children:["Uses the preset ",s.jsxs("code",{children:["@preset/",n.slug]})," for this model. Codex needs a preset: with a raw GPT model name it switches to a tool format some sellers drop."]}):s.jsx(s.Fragment,{children:"Codex needs a preset, not a raw model name: with a GPT model name it switches to a tool format some sellers drop. Create one for this model, then use its slug."})}),!n&&O&&s.jsx(k,{size:"sm",variant:"outline",onClick:()=>b(!0),children:"Create preset for this model"})]}),x.id==="claude-code"&&y!=="anthropic-messages"&&s.jsxs("p",{className:"gc-fineprint",children:["This model speaks ",qe[y],"; the gateway translates Claude Code's requests for it."]}),s.jsx(ds,{code:x.code,label:`${t.service} · ${x.label}`})]}),s.jsxs("p",{className:"gc-fineprint",children:["Set ",s.jsx("code",{children:us})," to one of your API keys first."," ",c.data&&!E&&s.jsx(ms,{to:"keys",children:"Create an API key"})]}),s.jsx(Z,{isOpen:u,onClose:()=>b(!1),size:"lg",title:"New preset",children:u&&s.jsx(Ns,{initial:null,prefill:{name:t.service,model:h},onDone:w=>{b(!1),w&&l("codex")}})})]})}function Ys({peer:e,peers:t,showReputation:r}){const[a,o]=p.useState(null),[i,m]=p.useState(null),c=p.useRef(null),g=i??e.services[0]??null,f=l=>{var u;m(l),(u=c.current)==null||u.scrollIntoView({behavior:"smooth",block:"start"})};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"gc-stack",children:[s.jsx(Us,{peer:e}),s.jsxs("div",{className:"gc-panel-actions",children:[s.jsx(k,{size:"sm",variant:"outline",onClick:()=>o("allow"),children:"Allow"}),s.jsx(k,{size:"sm",variant:"outline",onClick:()=>o("prefer"),children:"Prefer"}),s.jsx(k,{size:"sm",variant:"danger",onClick:()=>o("block"),children:"Block"})]}),s.jsx(Ks,{peer:e,showReputation:r})]}),s.jsx(Gs,{peer:e,selected:g,onSelect:f}),g&&s.jsx("div",{ref:c,className:"gc-scroll-target",children:s.jsx(Qs,{peer:e,service:g,onSelect:m})}),a&&s.jsx(Be,{peer:e,action:a,peers:t,onClose:()=>o(null)})]})}function ge(e){return e===null?"—":String(Math.round(e))}function Hs({peer:e,model:t}){const r=(e.health.coolingDownUntil??0)>Date.now();return s.jsxs("div",{className:"gc-badges",children:[s.jsx(Te,{tee:e.tee,scope:e.teeScope}),se(e,t)&&s.jsx(L,{tone:"success",children:"Free"}),e.washFlagged&&s.jsx(L,{tone:"danger",children:"Flagged"}),r&&s.jsx(L,{tone:"warning",children:"Cooling down"})]})}function ut(){const e=hs(),t=gs(e.rest),r=ps(),a=p.useMemo(()=>{var h;return t?((h=r.data)==null?void 0:h.find(n=>pe(n.peerId,t)))??null:null},[r.data,t]),[o,i]=p.useState({search:"",model:"",tee:!1,linked:!1,free:!1}),[m,c]=p.useState(null),g=p.useMemo(()=>fs(r.data),[r.data]),f=ws(r.data),l=ys(),u=(h,n)=>i(v=>({...v,[h]:n})),b=t===null?null:{eyebrow:"Provider",title:a?J(a):F(t,8,6),body:r.isLoading?s.jsx(ve,{rows:6}):a?s.jsx(Ys,{peer:a,peers:r.data,showReputation:f},a.peerId):s.jsx(W,{icon:s.jsx(V.providers,{size:18}),title:"Provider not found",body:`This gateway does not see ${F(t,8,6)} right now.`})},y=s.jsxs("div",{className:"gc-page",children:[s.jsx(je,{flush:!0,children:s.jsx(Pe,{query:r,rows:8,children:h=>s.jsx(Le,{label:"Providers",rows:_s(h,o),rowKey:n=>n.peerId,selectedKey:(a==null?void 0:a.peerId)??null,onRowClick:n=>de(ks("providers",n.peerId)),rowLabel:n=>J(n),actions:n=>[o.model!==""&&vs(l,n.peerId,o.model),{label:"Allow…",onSelect:()=>c({peer:n,kind:"allow"})},{label:"Prefer…",onSelect:()=>c({peer:n,kind:"prefer"})},{label:"Block…",tone:"danger",onSelect:()=>c({peer:n,kind:"block"})}],initialSort:{key:"trust",direction:"desc"},empty:s.jsx(W,{icon:s.jsx(V.providers,{size:18}),title:h.length?"No providers match these filters":"No providers found yet",body:h.length?void 0:"The buyer is still discovering the network. Check back in a minute."}),columns:[{key:"name",header:"Provider",sortValue:n=>n.displayName??n.peerId,render:n=>s.jsxs("div",{className:"gc-cell-lines",children:[s.jsx("div",{className:"gc-strong gc-ellipsis",title:n.displayName??n.peerId,children:J(n)}),n.displayName&&s.jsx("div",{className:"gc-muted gc-ellipsis",children:s.jsx(Se,{title:n.peerId,children:F(n.peerId,6,4)})}),s.jsx(Hs,{peer:n,model:o.model})]}),after:n=>s.jsx(bs,{value:n.peerId,label:`Copy peer id ${n.peerId}`})},{key:"identity",header:"Domain / GitHub",secondary:!0,render:n=>{var v;return(v=n.verificationLinks)!=null&&v.length?s.jsx(Me,{links:n.verificationLinks}):s.jsx("span",{className:"gc-muted",children:"—"})}},{key:"models",header:"Models",secondary:!0,optional:!0,render:n=>s.jsx("span",{className:"gc-muted",children:n.services.length})},{key:"input",header:"Input $/M",align:"right",sortValue:n=>qs(n,o.model),render:n=>ce(U(n,"inputUsdPerMillion",o.model))},{key:"output",header:"Output $/M",align:"right",secondary:!0,sortValue:n=>Vs(n,o.model),render:n=>ce(U(n,"outputUsdPerMillion",o.model))},{key:"trust",header:"Trust",align:"right",sortValue:n=>n.trustScore,render:n=>ge(n.trustScore)},...f?[{key:"reputation",header:"Reputation",align:"right",secondary:!0,optional:!0,sortValue:n=>n.reputationScore,render:n=>ge(n.reputationScore)}]:[],{key:"firstToken",header:"First token",align:"right",secondary:!0,optional:!0,sortValue:n=>n.firstTokenMsP50,render:n=>Ie(n.firstTokenMsP50)},{key:"speed",header:"Speed",align:"right",secondary:!0,optional:!0,sortValue:n=>n.tokensPerSecondP50,render:n=>Ne(n.tokensPerSecondP50)},{key:"usage",header:"Your 24h",align:"right",secondary:!0,sortValue:n=>n.requests24h,render:n=>$e(n.requests24h)}]})})}),s.jsx(zs,{peers:r.data})]});return s.jsxs("div",{className:"gc-page",children:[s.jsx(xs,{title:"Providers",description:"Providers on the network this gateway can route to. Open one to copy its models and an API call, or allow, block or prefer it for any scope."}),s.jsxs("div",{className:"gc-toolbar",children:[s.jsx(_,{size:"sm",type:"search","aria-label":"Search providers",placeholder:"Search name, peer id or model",value:o.search,onChange:h=>u("search",h.target.value)}),s.jsx($,{size:"sm","aria-label":"Filter by model",value:o.model,onChange:h=>u("model",h),options:[{value:"",label:"All models"},...g.map(h=>({value:h,label:h}))]}),s.jsx(H,{checked:o.linked,onChange:h=>u("linked",h),label:"Domain or GitHub"}),s.jsx(H,{checked:o.tee,onChange:h=>u("tee",h),label:"TEE"}),s.jsx(H,{checked:o.free,onChange:h=>u("free",h),label:"Free"})]}),s.jsx(Cs,{list:y,panel:b,onClose:()=>de("providers"),closeLabel:"Close provider"}),m&&s.jsx(Be,{peer:m.peer,action:m.kind,peers:r.data,onClose:()=>c(null)})]})}export{ut as default};
@@ -1 +0,0 @@
1
- import{r as P,j as e,L as f,o as x,Y as m,av as l,aw as y,h as i,E as T,I as v,B as C,V as I,f as j,q as k,v as d,b as L,M as u,g as F,e as w,Z as M,ag as A,W as D,X as E}from"./index-CL8Uzy58.js";import{u as K}from"./useInfiniteQuery-D6hnkAjP.js";import{p as O}from"./PeerPicker-BvexRNjB.js";import{f as q}from"./usage-CVWdWZuC.js";import{D as $}from"./DataTable-nSpXggux.js";const _=50;function c(t){return t===null?e.jsx(d,{tone:"info",children:"In flight"}):t<400?e.jsx(d,{tone:"success",children:t}):t<500?e.jsx(d,{tone:"warning",children:t}):e.jsx(d,{tone:"danger",children:t})}function N({entry:t}){const n=q(t,Date.now());return n==="free"?e.jsx("span",{className:"gc-muted",title:"Served by a free seller: $0",children:"Free"}):n==="pending"?e.jsx("span",{className:"gc-muted",title:"The buyer reports spend a moment after the response",children:"pending"}):n==="not-recorded"?e.jsx("span",{className:"gc-muted",title:"No spend was reported for this request: the buyer lost it",children:"not recorded"}):e.jsx(e.Fragment,{children:F(t.spent)})}function b({peerId:t,full:n=!1}){const r=L(),o=O(r.data,t);return n?e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsx("span",{children:o}),e.jsx(u,{children:t})]}):e.jsx("span",{className:"gc-ellipsis",title:t,children:o})}function z(t){try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}function p({title:t,body:n}){return e.jsxs("div",{className:"gc-stack gc-stack--tight",children:[e.jsx("div",{className:"as-field__label",children:t}),e.jsx(E,{code:z(n)})]})}function J({detail:t}){return!t.requestBody&&!t.responseBody?e.jsx("p",{className:"gc-fineprint",children:"Bodies are not stored for this request. Turn on content logging under Settings → Observability to keep them."}):e.jsxs(e.Fragment,{children:[t.requestBody&&e.jsx(p,{title:"Request body",body:t.requestBody}),t.responseBody&&e.jsx(p,{title:"Response body",body:t.responseBody})]})}function Q({entry:t}){const n=w({queryKey:k.request(t.tag),queryFn:()=>j.usage.request(t.tag),retry:!1,staleTime:6e4}),r=n.data??t,o=M(n.error)&&n.error.status===404;return e.jsxs(e.Fragment,{children:[r.errorCode||r.errorMessage?e.jsx(A,{tone:"danger",title:r.errorCode??"Request failed",children:r.errorMessage??"No message was returned."}):null,e.jsx(D,{items:[["Status",c(r.status)],["Request",e.jsxs(u,{children:[r.method," ",r.path]},"p")],["Model",r.model??"—"],["Key",r.keyLabel],["End user",r.endUser??"—"],["Seller",r.sellerPeerId?e.jsx(b,{peerId:r.sellerPeerId,full:!0},"s"):"—"],["First token",l(r.firstTokenMs)],["Speed",y(r.tokensPerSecond)],["Duration",r.finishedAt?l(r.finishedAt-r.startedAt):"—"],["Input tokens",i(r.inputTokens)],["Cached input",i(r.cachedInputTokens)],["Output tokens",i(r.outputTokens)],["Cost",e.jsx(N,{entry:r},"c")],["Tag",e.jsx(u,{children:r.tag},"t")]]}),n.isLoading&&e.jsx(f,{rows:2}),n.error&&!o?e.jsx(x,{error:n.error,title:"Could not load the bodies"}):null,n.data&&e.jsx(J,{detail:n.data})]})}function X({filter:t,showKey:n=!0}){var g;const[r,o]=P.useState(null),a=K({queryKey:k.requests(t),queryFn:({pageParam:s})=>j.usage.requests({...t,before:s??void 0,limit:_}),initialPageParam:null,getNextPageParam:s=>s.nextBefore,refetchInterval:s=>{var h;return(h=s.state.data)!=null&&h.pages.some(B=>B.requests.some(R=>q(R,Date.now())==="pending"))?5e3:!1}});if(a.isLoading)return e.jsx(f,{rows:8});if(a.error)return e.jsx(x,{error:a.error,onRetry:()=>void a.refetch()});const S=((g=a.data)==null?void 0:g.pages.flatMap(s=>s.requests))??[];return e.jsxs(e.Fragment,{children:[e.jsx($,{label:"Request log",rows:S,rowKey:s=>s.tag,onRowClick:o,rowLabel:s=>`request ${s.tag}`,empty:e.jsx(T,{icon:e.jsx(v.logs,{size:18}),title:"No requests found",body:"Requests appear here as soon as a key is used. Check the filters if you expected some."}),columns:[{key:"time",header:"Time",render:s=>e.jsx("span",{className:"gc-nowrap",children:m(s.startedAt)})},...n?[{key:"key",header:"Key",secondary:!0,render:s=>s.keyLabel}]:[],{key:"model",header:"Model",render:s=>e.jsxs("span",{className:"gc-ellipsis",children:[s.model??e.jsxs("span",{className:"gc-muted",children:[s.method," ",s.path]}),s.status!==null&&s.status>=400?e.jsxs("span",{className:"gc-narrow-only",children:[" ",c(s.status)]}):null]})},{key:"seller",header:"Seller",render:s=>s.sellerPeerId?e.jsx(b,{peerId:s.sellerPeerId}):"—"},{key:"status",header:"Status",secondary:!0,render:s=>e.jsx("span",{title:s.errorMessage??void 0,children:c(s.status)})},{key:"firstToken",header:"First token",align:"right",secondary:!0,optional:!0,render:s=>l(s.firstTokenMs)},{key:"speed",header:"Speed",align:"right",secondary:!0,optional:!0,render:s=>y(s.tokensPerSecond)},{key:"tokens",header:"Tokens",align:"right",secondary:!0,render:s=>`${i(s.inputTokens)} → ${i(s.outputTokens)}`},{key:"cost",header:"Cost",align:"right",render:s=>e.jsx(N,{entry:s})}]}),a.hasNextPage&&e.jsx("div",{className:"gc-load-more",children:e.jsx(C,{variant:"outline",size:"sm",disabled:a.isFetchingNextPage,onClick:()=>void a.fetchNextPage(),children:a.isFetchingNextPage?"Loading…":"Load older requests"})}),e.jsx(I,{isOpen:r!==null,onClose:()=>o(null),title:(r==null?void 0:r.model)??"Request",subtitle:r?m(r.startedAt):void 0,eyebrow:"Request",children:r&&e.jsx(Q,{entry:r},r.tag)})]})}export{X as R};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/RewardsClaim-D2E08Ty-.js","assets/index-CL8Uzy58.js","assets/index-D8vXwUTI.css","assets/ants-B38m9Phv.js","assets/useTx-rdzQSfyH.js","assets/en_US-Y4ZOVFV4-CkCCvmU2.js","assets/clsx-B-dksMZM.js","assets/index-BwpQbdIU.js","assets/en_US-Y4ZOVFV4-CcVPgXVa.css","assets/ConnectWallet-BPEdComN.js","assets/OperatorGateAlert-BTIl2CQW.js"])))=>i.map(i=>d[i]);
2
- import{u as A,F as b,G as N,e as S,q as m,H as k,J as R,r as c,j as e,P as z,Q as _,K as q,S as l,N as o,M as E,w as d,l as g,O as F,B as P,C as T,L as I,v as w,E as O,I as Q,_ as D,f as K}from"./index-CL8Uzy58.js";import{C as L}from"./ChainGate-BGzMcc9t.js";import{f as r,a as $}from"./ants-B38m9Phv.js";import{D as B}from"./DataTable-nSpXggux.js";const H=c.lazy(()=>D(()=>import("./RewardsClaim-D2E08Ty-.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])));function U(){const{workspace:t}=A(),x=b(),y=N(),j=S({queryKey:m.rewards(t.id),queryFn:()=>K.wallet.rewards(t.id)}),h=k(),p=R(t.id),[C,i]=c.useState(!1);return e.jsxs("div",{className:"gc-page",children:[e.jsx(z,{title:"Rewards",description:"ANTS earned by this workspace's usage. Claimed ANTS go to the authorized wallet."}),e.jsx(_,{query:j,rows:3,children:n=>{var u;const f=p.data?p.data.operator:n.operator,a={...n,operator:f};return e.jsxs(e.Fragment,{children:[e.jsx(q,{stale:n.stale}),e.jsxs("div",{className:"gc-grid gc-grid--3",children:[e.jsx(l,{label:"Ready to claim",value:r(a.pendingAnts)}),e.jsx(l,{label:"From the legacy program",value:r(((u=a.legacy)==null?void 0:u.pendingAnts)??"0"),sub:a.legacy?"Claimed together with the rest":void 0}),e.jsx(l,{label:"Authorized wallet",value:o(a.operator)?e.jsx(E,{title:a.operator,children:d(a.operator)}):"Not set"})]}),e.jsx(g,{children:e.jsxs("div",{className:"gc-summary-row",children:[e.jsxs("div",{className:"gc-summary-row__text",children:[e.jsx("span",{className:"gc-strong",children:$(a.pendingAnts)?`${r(a.pendingAnts)} ready to claim`:"Nothing to claim yet"}),e.jsx("span",{className:"gc-fineprint",children:o(a.operator)?e.jsxs(e.Fragment,{children:["Claimed ANTS go to the authorized wallet ",d(a.operator),", which signs the claim."]}):e.jsxs(e.Fragment,{children:["Only the authorized wallet can claim, and none is set. Authorize one on ",e.jsx(F,{to:"wallet",children:"Wallet & Funding"}),"."]})})]}),e.jsx(P,{size:"sm",variant:"outline",disabled:!o(a.operator),onClick:()=>i(!0),children:"Claim rewards"})]})}),e.jsx(T,{isOpen:C,onClose:()=>i(!1),title:"Claim rewards",subtitle:`${r(a.pendingAnts)} ready. Sent to the authorized wallet${o(a.operator)?` ${d(a.operator)}`:""}.`,children:e.jsx(L,{chain:h.data,error:h.error,children:s=>e.jsx(c.Suspense,{fallback:e.jsx(I,{rows:2}),children:e.jsx(H,{rewards:a,chain:s,onDone:()=>{y("Rewards claimed"),i(!1),x.invalidateQueries({queryKey:m.rewards(t.id)})}})})})}),e.jsx(g,{flush:!0,title:"Current program by epoch",description:"Rewards accrue at each epoch boundary from this workspace's paid usage.",children:e.jsx(B,{label:"Reward epochs",rows:[...a.epochs].sort((s,v)=>v.epoch-s.epoch),rowKey:s=>String(s.epoch),empty:e.jsx(O,{icon:e.jsx(Q.rewards,{size:18}),title:"No rewards yet",body:"Rewards accrue per epoch as this workspace's keys are used."}),columns:[{key:"epoch",header:"Epoch",render:s=>s.epoch},{key:"amount",header:"Amount",align:"right",render:s=>r(s.pendingAnts)},{key:"state",header:"Status",render:s=>s.claimed?e.jsx(w,{tone:"success",children:"Claimed"}):e.jsx(w,{tone:"warning",children:"Unclaimed"})}]})})]})}})]})}export{U as default};
@@ -1 +0,0 @@
1
- import{j as e,u as R,J as B,aG as N,aH as w,ag as E,aI as b,w as k,B as O}from"./index-CL8Uzy58.js";import{a as I}from"./ants-B38m9Phv.js";import{u as S,a as T,T as v,U as x,s as C,L as A}from"./useTx-rdzQSfyH.js";import{a as _}from"./ConnectWallet-BPEdComN.js";import{O as G}from"./OperatorGateAlert-BTIl2CQW.js";import{W,u as L,c as P}from"./en_US-Y4ZOVFV4-CkCCvmU2.js";import"./clsx-B-dksMZM.js";import"./index-BwpQbdIU.js";function U(a,s){return a?"Claiming…":s===0?"Nothing to claim":s===1?"Claim":`Claim (${s} transactions)`}function Y({rewards:a,chain:s,onDone:j}){const{address:r}=L(),u=P(),{workspace:h}=R(),g=B(h.id),{refresh:y}=N(h.id),i=S(s.chainId),{writeContractAsync:p}=T(),d=w(s,"usageRewards"),f=a.epochs.filter(n=>!n.claimed&&I(n.pendingAnts)),o=a.legacy&&I(a.legacy.pendingAnts)?a.legacy:null,l=f.length+(o?1:0);if(!d)return e.jsx(E,{tone:"warning",children:"The gateway did not report the usage rewards contract address."});const m=b(g.data,r,"claim rewards");return m.ok?e.jsxs("div",{className:"gc-stack",children:[e.jsxs("p",{className:"gc-fineprint",children:["The ANTS go to ",k(m.operator),", the connected authorized wallet."]}),e.jsx(v,{chain:s,runner:i,done:"Rewards claimed."}),e.jsx(O,{disabled:i.running||l===0,onClick:async()=>{const n=f.map(t=>{const c=[a.address,BigInt(t.epoch)];return{label:`Claim epoch ${t.epoch}`,check:()=>C(u,{account:r,address:d,abi:x,functionName:"claimBuyerReward",args:c,chainId:s.chainId}),send:()=>p({address:d,abi:x,functionName:"claimBuyerReward",args:c,chainId:s.chainId})}});if(o){const t=[a.address,o.epochs.map(BigInt)],c=o.contract;n.push({label:"Claim legacy emissions",check:()=>C(u,{account:r,address:c,abi:A,functionName:"claimBuyerEmissions",args:t,chainId:s.chainId}),send:()=>p({address:c,abi:A,functionName:"claimBuyerEmissions",args:t,chainId:s.chainId})})}await i.run(n,{onStale:()=>void y().catch(()=>{})})&&j()},children:U(i.running,l)}),l>1&&e.jsx("p",{className:"gc-fineprint",children:"Each current-program epoch is its own transaction; legacy emissions are one more."})]}):e.jsx(G,{gate:m,state:g.data,connected:r})}function Q(a){return e.jsx(W,{chain:a.chain,children:e.jsxs("div",{className:"gc-stack",children:[e.jsx(_,{}),e.jsx(Y,{...a})]})})}export{Q as default};
@@ -1 +0,0 @@
1
- import{u as C,a as se,b as O,a2 as ae,n as $,r as u,c as te,d as re,bp as ie,e as ne,j as e,l as D,T as le,B as b,L as G,o as z,bj as oe,ag as q,A as N,v as A,ak as K,E as ce,bq as de,f as T,q as W,P as ue,a4 as pe,br as ge,F as V,bs as H,b5 as ye,bt as X,bu as M,a5 as _,bv as Q,i as me,G as he,bw as R,bx as we,ae as fe,b7 as ve,C as xe}from"./index-CL8Uzy58.js";import{b as Z,a as je,d as be}from"./PolicyField-BL2_pz19.js";import{P as ke}from"./PolicyEditor-zST9UHdU.js";import{p as U}from"./PeerPicker-BvexRNjB.js";import{S as Y}from"./SelectField-CL9GSHwf.js";import{D as Pe}from"./DataTable-nSpXggux.js";import{T as Se,a as Ne}from"./Tabs-iPKA2Kfx.js";import"./Segmented-D-_FvNVa.js";import"./roving-DkptacxO.js";import"./Switch-C5_JEBYO.js";import"./Disclosure-DaXKEWtB.js";function P({level:a,children:t,result:i}){return e.jsxs("div",{className:i?"gc-source gc-source--result":"gc-source",children:[e.jsx("div",{className:"gc-source__level",children:a}),e.jsx("div",{className:"gc-source__policy",children:t})]})}function Ce(a,t,i,n){return a==="key"?(t??[]).filter(r=>r.status==="active").map(r=>({value:r.id,label:r.label})):a==="member"?(i??[]).map(({member:r})=>({value:r.id,label:r.label})):a==="preset"?(n??[]).map(r=>({value:r.slug,label:r.name})):[]}function Le(){const{workspace:a,viewer:t}=C(),i=se(),n=O(),r=ae(n.data),p=$(t),[s,c]=u.useState("workspace"),[l,g]=u.useState(""),[y,w]=u.useState(""),[f,v]=u.useState(null),m=te(i,s==="key"),d=re(a.id,s==="member"),L=ie(a.id,s==="preset"),h=ne({queryKey:W.routePreview(f??{}),queryFn:()=>T.network.routePreview(f),enabled:f!==null}),j=Ce(s,m.data,d.data,L.data);function x(){const o={model:y.trim(),workspace:a.id};s!=="workspace"&&l&&(o[s]=l),v(o)}return e.jsxs(D,{title:"Route preview",description:"See which sellers a request would go to, and why.",children:[e.jsxs("form",{className:"gc-toolbar",onSubmit:o=>{o.preventDefault(),x()},children:[e.jsx(Y,{size:"sm","aria-label":"Preview for",value:s,onChange:o=>{c(o),g("")},options:[{value:"workspace",label:`Workspace: ${a.name}`},{value:"key",label:"A key"},...p?[{value:"member",label:"A member"}]:[],{value:"preset",label:"A preset"}]}),s!=="workspace"&&e.jsx(Y,{size:"sm","aria-label":`Choose a ${s}`,value:l,onChange:g,options:[{value:"",label:`Choose a ${s}`},...j]}),e.jsx(le,{size:"sm","aria-label":"Model",placeholder:"Model id",list:"gc-preview-models",value:y,onChange:o=>w(o.target.value)}),e.jsx("datalist",{id:"gc-preview-models",children:r.map(o=>e.jsx("option",{value:o},o))}),e.jsx(b,{type:"submit",size:"sm",disabled:!y.trim()||s!=="workspace"&&!l,children:"Preview"})]}),h.isFetching&&e.jsx(G,{rows:4}),h.error?e.jsx(z,{error:h.error}):null,h.data&&!h.isFetching&&e.jsx(Re,{preview:h.data})]})}const Ee={buyer:"Buyer",gateway:"Gateway","workspace-org":"Workspace (org policy)",workspace:"Workspace",member:"Member",key:"Key (admin)","key-owner":"Key (owner)",preset:"Preset"};function Me(a){return a.policy!==null?N(a.policy):e.jsx("span",{className:"gc-muted",children:a.level==="buyer"?"No hard limits":"Inherits"})}function Re({preview:a}){const{me:t}=C(),i=O(),n=oe(),r=a.candidates.filter(s=>s.eligible).length,p=s=>{var c;return s.id?s.level==="workspace"||s.level==="workspace-org"?((c=t.workspaces.find(l=>l.workspace.id===s.id))==null?void 0:c.workspace.name)??s.id:s.id:null};return e.jsxs("div",{className:"gc-stack",children:[!a.modelAllowed&&e.jsxs(q,{tone:"danger",title:"Model not allowed",children:["The policy does not allow ",a.model,". Requests for it get a 403."]}),e.jsxs("div",{className:"gc-sources",children:[a.sources.map((s,c)=>e.jsx(P,{level:e.jsxs(e.Fragment,{children:[Ee[s.level],p(s)?e.jsxs("span",{className:"gc-muted",children:[" · ",p(s)]}):null]}),children:Me(s)},`${s.level}-${c}`)),e.jsx(P,{level:"Effective",result:!0,children:N(a.policy)})]}),e.jsxs("p",{className:"gc-muted",children:[r," of ",a.candidates.length," sellers eligible."]}),r===0&&a.candidates.length>0&&e.jsxs(q,{tone:"warning",title:"No eligible seller",children:["Requests for ",a.model," fail with this policy. The reasons below show what excludes each seller."]}),e.jsx(Pe,{label:"Candidates",rows:[...a.candidates].sort((s,c)=>(s.rank??1e9)-(c.rank??1e9)),rowKey:s=>s.peerId,rowLabel:s=>s.displayName??U(i.data,s.peerId),actions:s=>[de(n,s.peerId,a.model)],empty:e.jsx(ce,{title:"No seller offers this model"}),columns:[{key:"rank",header:"#",render:s=>s.rank??"—",width:"3rem"},{key:"seller",header:"Seller",render:s=>s.displayName??U(i.data,s.peerId)},{key:"eligible",header:"Eligible",render:s=>s.eligible?e.jsx(A,{tone:"success",children:"Yes"}):e.jsx(A,{tone:"neutral",children:"No"})},{key:"reasons",header:"Why",render:s=>e.jsx("span",{className:"gc-muted",children:s.reasons.join(" · ")||"—"})},{key:"input",header:"Input $/M",align:"right",secondary:!0,render:s=>K(s.inputUsdPerMillion)},{key:"output",header:"Output $/M",align:"right",secondary:!0,render:s=>K(s.outputUsdPerMillion)},{key:"trust",header:"Trust",align:"right",secondary:!0,render:s=>s.trustScore===null?"—":Math.round(s.trustScore)}]})]})}const S={gateway:{title:"Gateway default",description:()=>"Applies to every request through this gateway. Workspaces, members, keys and presets can only narrow it."},org:{title:"Organization policy",description:a=>`Set by organization admins for ${a}. Workspace admins can only narrow it.`},workspace:{title:"Workspace policy",description:a=>`Set by ${a}'s admins, on top of the gateway default and the organization policy.`}},B=(a,t)=>JSON.stringify(a)===JSON.stringify(t);function qe(a,t){if(!a)return e.jsx(A,{children:"Read only"});if(t)return e.jsx(A,{tone:"warning",children:"Unsaved changes"})}function I({layer:a,source:t,parent:i,canEdit:n,onSave:r}){const{workspace:p}=C(),s=he(),c=O(),l=H(),g=je(),[y,w]=u.useState(()=>R(t)),[f,v]=u.useState(()=>R(t)),[m,d]=u.useState(null),[L,h]=u.useState(!1),j=u.useMemo(()=>R(t),[t]),x=!B(y,f);u.useEffect(()=>{B(j,f)||(!x||B(j,y)?(w(j),v(j),d(null)):d(j))},[j]);const o=we({mutationFn:async()=>{const k=fe(y,l.data??null);return await g.save([k],ee=>r(k,ee))===ve?null:k},onSuccess:k=>{if(!k)return;const F=R(k);w(F),v(F),d(null),h(!1),s(`${S[a].title} saved`)}}),E=be(y,l.data??null);return e.jsxs(D,{title:S[a].title,description:S[a].description(p.name),actions:qe(n,x),children:[e.jsxs("div",{className:"gc-policy-row",children:[e.jsxs("div",{className:"gc-policy-row__text",children:[e.jsx(Z,{policy:x?E.policy:t,invalid:x&&E.error!==null}),x&&e.jsx("span",{className:"gc-fineprint",children:"Showing your unsaved edits."})]}),e.jsx(b,{size:"sm",variant:"outline",onClick:()=>h(!0),children:n?"Edit":"View"})]}),m&&n&&!L&&e.jsx(q,{tone:"warning",title:"Changed elsewhere",children:"Someone saved this policy while you were editing it. Open it to reload theirs or keep yours."}),e.jsx(xe,{isOpen:L,onClose:()=>h(!1),size:"xl",title:S[a].title,subtitle:S[a].description(p.name),footer:n?e.jsxs(e.Fragment,{children:[E.error&&e.jsx("span",{className:"gc-warn gc-footer-note",children:E.error}),e.jsx(b,{variant:"ghost",disabled:!x,onClick:()=>{w(f),d(null)},children:"Discard changes"}),e.jsx(b,{disabled:o.isPending||!x,onClick:()=>o.mutate(),children:o.isPending?"Saving…":"Save policy"})]}):e.jsx(b,{variant:"outline",onClick:()=>h(!1),children:"Close"}),children:e.jsxs("div",{className:"gc-stack",children:[m&&n&&e.jsx(q,{tone:"warning",title:"Changed elsewhere",action:e.jsxs("div",{className:"gc-inline gc-inline--wrap",children:[e.jsx(b,{size:"sm",variant:"outline",onClick:()=>{w(m),v(m),d(null)},children:"Reload"}),e.jsx(b,{size:"sm",variant:"ghost",onClick:()=>{v(m),d(null)},children:"Keep editing"})]}),children:"Someone saved this policy while you were editing it. Reload to see their version (your edits are dropped), or keep editing and save to replace it."}),o.error?e.jsx(z,{error:o.error,title:"Could not save"}):null,e.jsx(ke,{value:y,onChange:w,peers:c.data,lists:l.data??[],parent:i,disabled:!n})]})}),g.dialog]})}function Ae(){const a=V(),t=X();return t.isLoading?e.jsx(G,{rows:6}):t.error?e.jsx(z,{error:t.error,onRetry:()=>void t.refetch()}):e.jsx(I,{layer:"gateway",source:t.data??null,parent:null,canEdit:!0,onSave:async(i,n)=>{await T.network.setGatewayPolicy(i,n),await a.invalidateQueries({queryKey:W.group("routing")})}})}function J(){var f,v;const{workspace:a,viewer:t}=C(),i=V(),n=H(),r=ye(a.id),p=X(),s=n.data??[],c=p.data?M(p.data,s):null,l=((f=r.data)==null?void 0:f.orgRoutingPolicy)??null,g=((v=r.data)==null?void 0:v.routingPolicy)??null,y=u.useMemo(()=>_(c,l&&M(l,s),g&&M(g,s)),[c,l,g,s]);if(r.isLoading)return e.jsx(G,{rows:6});if(r.error)return e.jsx(z,{error:r.error,onRetry:()=>void r.refetch()});const w=async()=>{await i.invalidateQueries({queryKey:W.group("workspaces")}),await i.invalidateQueries({queryKey:W.group("routing")})};return e.jsxs("div",{className:"gc-stack",children:[e.jsx(D,{title:"Effective for this workspace",description:"What keys in this workspace get before member, key and preset policies narrow it further.",children:e.jsxs("div",{className:"gc-sources",children:[e.jsx(P,{level:"Gateway default",children:N(p.data)}),e.jsx(P,{level:"Organization",children:N(l)}),e.jsx(P,{level:"Workspace",children:N(g)}),e.jsx(P,{level:"Effective",result:!0,children:e.jsx(Z,{policy:y})})]})}),e.jsx(I,{layer:"org",source:l,parent:c,canEdit:$(t),onSave:async(m,d)=>{await T.workspaces.update(a.id,{orgRoutingPolicy:Q(m)},d),await w()}}),e.jsx(I,{layer:"workspace",source:g,parent:_(c,l&&M(l,s)),canEdit:me(t),onSave:async(m,d)=>{await T.workspaces.update(a.id,{routingPolicy:Q(m)},d),await w()}})]})}function Te(){const a=pe();if(!a.data)return null;const t=ge(a.data);return e.jsxs("p",{className:"gc-fineprint",children:["Buyer config, which every policy here can only narrow: ",t.length>0?t.join(" · "):"none","."]})}function We(){const{viewer:a}=C(),t=$(a),[i,n]=u.useState(t?"gateway":"workspace");return t?e.jsxs(e.Fragment,{children:[e.jsx(Se,{id:"gc-routing-level",label:"Policy level",value:i,onChange:n,tabs:[{id:"gateway",label:"Gateway default"},{id:"workspace",label:"This workspace"}]}),e.jsx(Ne,{tabsId:"gc-routing-level",tab:i,children:i==="gateway"?e.jsx(Ae,{}):e.jsx(J,{})})]}):e.jsx(J,{})}function Ue(){return e.jsxs("div",{className:"gc-page",children:[e.jsx(ue,{title:"Routing",description:"Which sellers serve your requests and how they are ranked. Each level can only narrow the one above."}),e.jsx(Te,{}),e.jsx(We,{}),e.jsx(Le,{})]})}export{Ue as default};
@@ -1 +0,0 @@
1
- import{r as j,j as e,$ as o,a0 as h,a1 as f}from"./index-CL8Uzy58.js";function b({label:a,hint:d,error:t,options:c,onChange:r,className:i,id:n,size:u,...x}){const m=j.useId(),l=n??m;return e.jsxs("label",{className:f(i,u),htmlFor:l,children:[a&&e.jsx("span",{className:"as-field__label",children:a}),e.jsx("select",{id:l,className:o("as-field__select"),onChange:s=>r(s.target.value),...x,children:c.map(s=>e.jsx("option",{value:s.value,disabled:s.disabled,children:s.label},s.value))}),e.jsx(h,{error:t,hint:d})]})}export{b as S};
@@ -1,7 +0,0 @@
1
- import{F as re,G as ne,b as ge,bs as xe,r as d,bx as ae,q as U,f as E,af as ve,a5 as be,ak as K,g as fe,j as t,ag as D,a9 as ye,T as O,B as y,o as $,D as ie,e as Se,P as je,Q as z,aB as we,l as A,W as le,M as ke,v as M,u as Pe,U as Re,t as Q,b1 as Ne,at as W,ba as Ce,as as Me,E as Ie,I as G,C as J,b0 as Ue,Z as qe}from"./index-CL8Uzy58.js";import{P as Y}from"./PeerPicker-BvexRNjB.js";import{S as Z}from"./PolicyEditor-zST9UHdU.js";import{S as Te}from"./Segmented-D-_FvNVa.js";import{S as I}from"./Switch-C5_JEBYO.js";import{D as F}from"./Disclosure-DaXKEWtB.js";import{T as oe}from"./TextAreaField-BwxpmCEP.js";import{T as Oe,a as Ee}from"./Tabs-iPKA2Kfx.js";import{D as Ae}from"./DataTable-nSpXggux.js";import{S as L}from"./SelectField-CL9GSHwf.js";import"./roving-DkptacxO.js";function Fe(e){return Object.entries(e).map(([s,r])=>`${s}: ${r}`).join(`
2
- `)}function De(e){const s={};for(const[r,n]of e.split(`
3
- `).entries()){if(!n.trim())continue;const c=n.indexOf(":");if(c<=0)throw new Error(`Line ${r+1}: use "Name: value".`);const u=n.slice(0,c).trim();if(!/^[A-Za-z0-9!#$%&'*+.^_`|~-]+$/.test(u))throw new Error(`Line ${r+1}: "${u}" is not a valid header name.`);s[u]=n.slice(c+1).trim()}return s}const ce="••••";function $e(e){return e.split(`
4
- `).map(s=>{const r=s.indexOf(":");return r>0&&s.slice(r+1).trim()===ce?s.slice(0,r).trim():null}).filter(s=>!!s)}function X(e){return e.split(`
5
- `).map(s=>{const r=s.indexOf(":");return r>0&&s.slice(r+1).trim()===ce?`${s.slice(0,r)}: `:s}).join(`
6
- `)}function _e(e,s){if(!e||!s)return!1;try{return new URL(e).origin!==new URL(s).origin}catch{return e!==s}}function Be(e){const s={},r=(n,c,u)=>{const a=e[n].trim();if(a===""){c&&(s[n]="Required.");return}const h=Number(a);!Number.isFinite(h)||h<0?s[n]="Use a number of 0 or more.":u!==void 0&&h>u&&(s[n]=`At most ${u}.`)};return r("input",!0),r("output",!0),r("cached",!1),r("reputation",!0,100),s}function w(e,s={}){const r=e.trim();if(r==="")return s.required?"Required.":void 0;const n=Number(r),c=s.min??0;if(!Number.isFinite(n))return"Use a number.";if(s.integer&&!Number.isInteger(n))return"Use a whole number.";if(n<c)return`Use ${c} or more.`;if(s.max!==void 0&&n>s.max)return`At most ${s.max}.`}function V(e){return e.split(/[\n,]/).map(s=>s.trim()).filter(Boolean)}function ee(e){const s=e.find(r=>!/^(?:0x)?[0-9a-f]{40}$/i.test(r));return s?`"${s}" is not a 40-character hex seller id.`:void 0}function te(e){const s=e.find(r=>!/^https?:\/\/\S+$/.test(r));return s?`"${s}" is not an http(s) URL.`:void 0}function ue(e,s){return e.some(r=>r===s||s.startsWith(`${r}.`)||r.startsWith(`${s}.`))}function Le(){return t.jsxs("span",{className:"gc-override",children:[t.jsx("span",{className:"gc-attention","aria-hidden":"true"}),"Overridden by the buyer's environment or start flags"]})}function se(e){const s=e.routingPreferences,r=n=>n===null?"":String(n);return{allowMode:s.allowedPeerIds.length>0?"only":"any",allowedPeerIds:[...s.allowedPeerIds],blockedPeerIds:[...s.blockedPeerIds],minTrustScore:String(s.minTrustScore),minReputation:String(e.minPeerReputation),preferFree:s.preferFreePeers,softInputCap:String(s.maxInputUsdPerMillion),maxInput:String(e.maxPricing.inputUsdPerMillion),maxOutput:String(e.maxPricing.outputUsdPerMillion),maxCached:r(e.maxPricing.cachedInputUsdPerMillion),verify:e.verifier.enabled,requireVerified:e.verifier.require,verifiers:e.verifier.prefer.join(", "),sampleRate:r(e.evidence.sampleRate),maxSampleBytes:r(e.evidence.maxSampleBytes),autoSweep:e.payments.autoSweep,maxPerRequest:String(e.payments.maxPerRequestUsdc),maxReserve:String(e.payments.maxReserveUsdc),rpcUrl:e.payments.rpcUrl??"",fallbackRpcUrls:e.payments.fallbackRpcUrls.join(`
7
- `),peerRefreshMs:String(e.network.peerRefreshIntervalMs),metadataTimeoutMs:String(e.network.metadataFetchTimeoutMs),requestTimeoutMs:String(e.network.requestTimeoutMs),maxStreamMs:String(e.network.maxStreamDurationMs),perServiceMetadata:!e.network.disableMetadataV2Services}}function Ve(e){const s=Be({input:e.maxInput,output:e.maxOutput,cached:e.maxCached,reputation:e.minReputation}),r={maxInput:s.input,maxOutput:s.output,maxCached:s.cached,softInputCap:w(e.softInputCap,{required:!0}),allowedPeerIds:e.allowMode==="only"?ee(e.allowedPeerIds):void 0,blockedPeerIds:ee(e.blockedPeerIds),sampleRate:w(e.sampleRate,{max:1}),maxSampleBytes:w(e.maxSampleBytes,{min:1,integer:!0}),maxPerRequest:w(e.maxPerRequest,{required:!0,min:1e-6}),maxReserve:w(e.maxReserve,{required:!0,min:1e-6}),rpcUrl:e.rpcUrl.trim()?te([e.rpcUrl.trim()]):void 0,fallbackRpcUrls:te(V(e.fallbackRpcUrls)),peerRefreshMs:w(e.peerRefreshMs,{required:!0,min:1e3,integer:!0}),metadataTimeoutMs:w(e.metadataTimeoutMs,{required:!0,min:100,integer:!0}),requestTimeoutMs:w(e.requestTimeoutMs,{required:!0,min:1,integer:!0}),maxStreamMs:w(e.maxStreamMs,{required:!0,min:1,integer:!0})};return Object.fromEntries(Object.entries(r).filter(([,n])=>n))}function ze(e){const s=r=>r.trim()?Number(r):null;return{routingPreferences:{minTrustScore:Number(e.minTrustScore),maxInputUsdPerMillion:Number(e.softInputCap),preferFreePeers:e.preferFree,allowedPeerIds:e.allowMode==="only"?e.allowedPeerIds:[],blockedPeerIds:e.blockedPeerIds},maxPricing:{inputUsdPerMillion:Number(e.maxInput),outputUsdPerMillion:Number(e.maxOutput),cachedInputUsdPerMillion:s(e.maxCached)},minPeerReputation:Number(e.minReputation),verifier:{enabled:e.verify,require:e.verify&&e.requireVerified,prefer:e.verify?V(e.verifiers):[]},evidence:{sampleRate:s(e.sampleRate),maxSampleBytes:s(e.maxSampleBytes)},payments:{autoSweep:e.autoSweep,maxPerRequestUsdc:Number(e.maxPerRequest),maxReserveUsdc:Number(e.maxReserve),rpcUrl:e.rpcUrl.trim()||null,fallbackRpcUrls:V(e.fallbackRpcUrls)},network:{peerRefreshIntervalMs:Number(e.peerRefreshMs),metadataFetchTimeoutMs:Number(e.metadataTimeoutMs),requestTimeoutMs:Number(e.requestTimeoutMs),maxStreamDurationMs:Number(e.maxStreamMs),disableMetadataV2Services:!e.perServiceMetadata}}}const He=["allowMode","allowedPeerIds","blockedPeerIds","minTrustScore","preferFree","softInputCap"];function B(e,s){return Object.keys(s).filter(r=>JSON.stringify(e[r])!==JSON.stringify(s[r]))}function Ke(e){const s=r=>r.trim()&&Number.isFinite(Number(r))?Number(r):void 0;return{...e.allowMode==="only"&&e.allowedPeerIds.length>0?{allowedPeerIds:e.allowedPeerIds}:{},...e.blockedPeerIds.length>0?{blockedPeerIds:e.blockedPeerIds}:{},...s(e.minTrustScore)?{minTrustScore:s(e.minTrustScore)}:{},...s(e.minReputation)?{minReputation:s(e.minReputation)}:{},...s(e.maxInput)!==void 0?{maxInputUsdPerMillion:s(e.maxInput)}:{},...s(e.maxOutput)!==void 0?{maxOutputUsdPerMillion:s(e.maxOutput)}:{},...s(e.maxCached)!==void 0?{maxCachedInputUsdPerMillion:s(e.maxCached)}:{}}}function Qe({buyer:e}){const s=re(),r=ne(),n=ge(),c=xe(),u=d.useMemo(()=>se(e),[e]),[a,h]=d.useState(u),[k,P]=d.useState(u),[v,S]=d.useState(null),[b,p]=d.useState(!1),[j,g]=d.useState(!1),l=(i,R)=>h(N=>({...N,[i]:R})),m=i=>{h(i),P(i),S(null)},o=Ve(a),q=B(k,a);d.useEffect(()=>{B(k,u).length!==0&&(q.length===0||B(u,a).length===0?m(u):S(u))},[u]);const _=q.some(i=>!He.includes(i)),C=i=>ue(e.overrides,i)?t.jsx(Le,{}):void 0,H=(i,R)=>C(i)??R,f=ae({mutationFn:()=>E.settings.updateBuyer(ze(a)),onSuccess:i=>{const{restartRequired:R,...N}=i;s.setQueryData(U.settings,N),m(se(N.buyer)),s.invalidateQueries({queryKey:U.buyerLimits}),p(!1),g(R===!0),r(_?R?"Saved. Restart the buyer to apply them.":"Saved. The buyer is restarting.":"Saved. The buyer applies these at once.")}}),T=d.useMemo(()=>!n.data||n.data.length===0?null:{matched:ve(be(Ke(a)),n.data,c.data??[]).length,total:n.data.length},[a,n.data,c.data]),de=`${K(Number(a.maxInput))} in · ${K(Number(a.maxOutput))} out`,me=a.verify?a.requireVerified?"Required":"On":"Off",pe=`${a.autoSweep?"Auto-sweep on":"Auto-sweep off"} · ${fe(Number(a.maxPerRequest))} per request`,x=(i,R,N={})=>t.jsx(O,{size:"sm",className:N.className??"gc-num",label:R,inputMode:"decimal",placeholder:N.placeholder,value:a[i],error:o[i],hint:N.hint,onChange:he=>l(i,he.target.value)});return t.jsxs("div",{className:"gc-stack",children:[t.jsxs("div",{className:"gc-policy",children:[T&&(T.matched===0?t.jsxs(D,{tone:"warning",title:"No seller matches these settings",children:["None of the ",T.total," sellers this gateway sees passes them, so every request will fail."]}):t.jsxs("p",{className:"gc-muted","aria-live":"polite",children:["Matches ",T.matched," of ",T.total," sellers. Every key can only narrow this."]})),t.jsxs("div",{className:"gc-policy__cols",children:[t.jsxs("section",{className:"gc-policy__section",children:[t.jsx("h3",{children:"Sellers"}),t.jsx(Te,{label:"Which sellers may serve",value:a.allowMode,onChange:i=>l("allowMode",i),options:[{value:"any",label:"Any seller"},{value:"only",label:"Only these"}]}),a.allowMode==="only"&&t.jsxs(t.Fragment,{children:[t.jsx(Y,{label:"Allowed sellers",value:a.allowedPeerIds,onChange:i=>l("allowedPeerIds",i),peers:n.data}),o.allowedPeerIds&&t.jsx("p",{className:"gc-warn",children:o.allowedPeerIds}),a.allowedPeerIds.length===0&&t.jsx("p",{className:"gc-fineprint",children:"With no sellers listed, any seller may serve."})]}),t.jsx(Y,{label:"Blocked sellers",value:a.blockedPeerIds,onChange:i=>l("blockedPeerIds",i),peers:n.data}),o.blockedPeerIds&&t.jsx("p",{className:"gc-warn",children:o.blockedPeerIds}),t.jsx("p",{className:"gc-fineprint",children:"Blocked here means blocked for every key."})]}),t.jsxs("section",{className:"gc-policy__section",children:[t.jsx("h3",{children:"Quality and ranking"}),t.jsx(Z,{label:"Minimum trust score",clearable:!1,value:a.minTrustScore,onChange:i=>l("minTrustScore",i),hint:"Keys can raise it, not lower it."}),(ye(n.data)||a.minReputation!=="0")&&t.jsx(Z,{label:"Minimum reputation",clearable:!1,value:a.minReputation,onChange:i=>l("minReputation",i),hint:H("minPeerReputation","Applies to pinned sellers too.")}),t.jsx("div",{className:"gc-policy__switches",children:t.jsx(I,{checked:a.preferFree,onChange:i=>l("preferFree",i),label:"Free sellers first"})}),x("softInputCap","Soft input price limit $/M",{hint:"Pricier sellers rank lower; none is excluded.",className:"gc-num gc-num--wide"})]})]}),t.jsxs("div",{className:"gc-policy__advanced",children:[t.jsxs(F,{title:"Price caps",summary:de,children:[t.jsx("p",{className:"gc-fineprint",children:"Hard limits for every request, pinned sellers included."}),t.jsxs("div",{className:"gc-policy__caps",children:[x("maxInput","Input $/M",{hint:C("maxPricing.inputUsdPerMillion")}),x("maxOutput","Output $/M",{hint:C("maxPricing.outputUsdPerMillion")}),x("maxCached","Cached input $/M",{placeholder:"Same as input"})]})]}),t.jsxs(F,{title:"Verification",summary:me,children:[C("verifier"),t.jsxs("div",{className:"gc-policy__switches",children:[t.jsx(I,{checked:a.verify,onChange:i=>l("verify",i),label:"Verify sellers"}),t.jsx(I,{checked:a.verify&&a.requireVerified,disabled:!a.verify,onChange:i=>l("requireVerified",i),label:"Require verification"})]}),t.jsx(O,{size:"sm",label:"Verifiers",value:a.verifiers,disabled:!a.verify,placeholder:"Seller's trusted default",hint:"Ordered, comma-separated verifier ids, e.g. TEE attestation.",onChange:i=>l("verifiers",i.target.value)}),t.jsxs("div",{className:"gc-policy__caps",children:[x("sampleRate","Evidence sample rate",{placeholder:"Default",hint:"Share of responses kept, 0 to 1."}),x("maxSampleBytes","Largest sample (bytes)",{placeholder:"Default",className:"gc-num gc-num--wide"})]})]}),t.jsxs(F,{title:"Payments",summary:pe,children:[t.jsx(I,{checked:a.autoSweep,onChange:i=>l("autoSweep",i),label:"Sweep deposits automatically",description:"Move USDC that arrives in the workspace wallets into their deposits."}),t.jsxs("div",{className:"gc-policy__caps",children:[x("maxPerRequest","Max per request (USDC)",{className:"gc-num gc-num--wide"}),x("maxReserve","Max channel reserve (USDC)",{className:"gc-num gc-num--wide"})]}),t.jsx(O,{size:"sm",label:"Base RPC URL",value:a.rpcUrl,error:o.rpcUrl,placeholder:"Chain default",hint:H("payments.rpcUrl","Your own endpoint avoids public rate limits. Saved URLs show without their path; leave them as they are to keep them."),onChange:i=>l("rpcUrl",i.target.value)}),t.jsx(oe,{label:"Fallback RPC URLs",rows:2,mono:!0,value:a.fallbackRpcUrls,error:o.fallbackRpcUrls,hint:"One per line, tried in order.",onChange:i=>l("fallbackRpcUrls",i.target.value)})]}),t.jsxs(F,{title:"Network and timeouts",summary:`Refresh ${Math.round(Number(a.peerRefreshMs)/1e3)} s`,children:[t.jsxs("div",{className:"gc-policy__caps",children:[x("peerRefreshMs","Peer refresh (ms)",{className:"gc-num gc-num--wide"}),x("metadataTimeoutMs","Metadata timeout (ms)",{className:"gc-num gc-num--wide",hint:C("network.metadataFetchTimeoutMs")}),x("requestTimeoutMs","Response start timeout (ms)",{className:"gc-num gc-num--wide"}),x("maxStreamMs","Longest stream (ms)",{className:"gc-num gc-num--wide",hint:C("network.maxStreamDurationMs")})]}),t.jsx(I,{checked:a.perServiceMetadata,onChange:i=>l("perServiceMetadata",i),label:"Per-service attribution in signed metadata",description:C("network.disableMetadataV2Services")??"Tells sellers which service each request used."})]})]})]}),j&&t.jsxs(D,{tone:"warning",title:"Restart the buyer to apply",children:["Saved, but this buyer was not restarted automatically. Restart it (for example ",t.jsx("code",{children:"systemctl restart antseed-buyer"}),", or stop and start ",t.jsx("code",{children:"antseed buyer start"}),") to use the new settings."]}),v&&t.jsx(D,{tone:"warning",title:"Changed elsewhere",action:t.jsxs("div",{className:"gc-inline gc-inline--wrap",children:[t.jsx(y,{size:"sm",variant:"outline",onClick:()=>m(v),children:"Reload"}),t.jsx(y,{size:"sm",variant:"ghost",onClick:()=>{P(v),S(null)},children:"Keep editing"})]}),children:"Someone saved the buyer settings while you were editing them. Reload to see their version (your edits are dropped), or keep editing and save to replace it."}),!b&&f.error?t.jsx($,{error:f.error,title:"Could not save"}):null,t.jsxs("div",{className:"gc-actions",children:[t.jsx("span",{className:"gc-fineprint gc-actions__note",children:q.length===0?"No changes.":_?"Saving restarts the buyer.":"Applies at once, without a restart."}),t.jsx(y,{variant:"ghost",disabled:q.length===0||f.isPending,onClick:()=>m(v??k),children:"Reset"}),t.jsx(y,{disabled:q.length===0||Object.keys(o).length>0||f.isPending,onClick:()=>_?p(!0):f.mutate(),children:f.isPending?"Saving…":"Save"})]}),t.jsx(ie,{isOpen:b,busy:f.isPending,error:f.error,onClose:()=>{p(!1),f.reset()},onConfirm:()=>f.mutate(),title:"Restart the buyer?",confirmLabel:"Save and restart",tone:"primary",body:"These changes need a buyer restart. Requests in flight finish first; new requests wait a few seconds while it reconnects."})]})}const We=["general","buyer","observability","tokens","auth"];function Ge(){const e=we();return t.jsx(A,{title:"Gateway",children:t.jsx(z,{query:e,children:s=>t.jsx(le,{items:[["Public URL",s.publicUrl?t.jsx(ke,{children:s.publicUrl},"u"):t.jsx("span",{className:"gc-muted",children:"Not set. Clients use this console's address."})],["Version",s.version],["Buyer",s.buyer.reachable?t.jsx(M,{tone:"success",children:"Connected"},"b"):t.jsx(M,{tone:"danger",children:"Unreachable"},"b")],["Sellers seen",String(s.buyer.peers)],["Spend feed",s.spendFeed],["USDC top-ups (x402)",s.x402?"On":"Off"]]})})})}function Je({settings:e}){const s=e.buyer;return t.jsx(A,{title:"Buyer",description:t.jsxs(t.Fragment,{children:["The top of every routing policy: workspaces, members, keys and presets can only narrow it. Saved to the config file of the buyer on port ",s.proxyPort,ue(s.overrides,"proxyPort")?" (set by its start flags)":"","."]}),children:t.jsx(Qe,{buyer:s})})}function Ye({settings:e}){const s=re(),r=ne(),n=e.observability,[c,u]=d.useState(n.otlpEndpoint??""),[a,h]=d.useState(Fe(n.otlpHeaders)),[k,P]=d.useState(n.logContent),[v,S]=d.useState(n.retentionDays===null?"":String(n.retentionDays)),b=c.trim()&&!/^https?:\/\/\S+$/.test(c.trim())?"Use an http:// or https:// URL.":void 0,p=_e(n.otlpEndpoint,c.trim()||null)?$e(a):[],j=p.length?`Enter the value of ${p.join(", ")} again: saved values are not sent to a new endpoint.`:void 0,g=ae({mutationFn:()=>{if(b)throw new Error(b);if(j)throw new Error(j);const l=v===""?null:Number(v);return E.settings.setObservability({otlpEndpoint:c.trim()||null,otlpHeaders:De(a),logContent:k,retentionDays:l})},onSuccess:l=>{const{restartRequired:m,...o}=l;s.setQueryData(U.settings,o),r(m?"Observability saved. Restart the gateway to apply it.":"Observability saved")},onError:l=>{qe(l,"otlp_headers_required")&&h(X(a))}});return t.jsx(A,{title:"Observability",description:"Send one OpenTelemetry trace per request, and choose what the request log keeps.",children:t.jsxs("form",{className:"gc-stack",onSubmit:l=>{l.preventDefault(),g.mutate()},children:[t.jsx(O,{label:"OTLP/HTTP endpoint",placeholder:"https://otel.example.com/v1/traces",value:c,error:b,onChange:l=>u(l.target.value)}),t.jsx(oe,{label:"Headers",rows:3,mono:!0,placeholder:"Authorization: Bearer …",value:a,onChange:l=>h(l.target.value),error:j,hint:"One per line, as Name: value. Saved values show as ••••; leave them as they are to keep them (for the same endpoint only)."}),p.length>0&&t.jsx("div",{children:t.jsx(y,{size:"sm",variant:"outline",onClick:()=>h(X(a)),children:"Clear saved values to re-enter them"})}),t.jsx(I,{checked:k,onChange:P,label:"Store request and response bodies",description:"Off by default. Bodies can contain personal data; only turn this on if you need it."}),t.jsx(L,{label:"Keep the request log for",value:v,onChange:S,options:[{value:"7",label:"7 days"},{value:"30",label:"30 days"},{value:"90",label:"90 days"},{value:"365",label:"1 year"},{value:"",label:"Forever"}]}),g.error?t.jsx($,{error:g.error,title:"Could not save"}):null,t.jsx("div",{className:"gc-actions",children:t.jsx(y,{type:"submit",disabled:g.isPending,children:g.isPending?"Saving…":"Save"})})]})})}function Ze(){const{me:e}=Pe(),s=e.member.orgRole==="owner",r=Re(),[n,c]=d.useState(!1),[u,a]=d.useState(""),[h,k]=d.useState("read"),[P,v]=d.useState("90"),[S,b]=d.useState(null),[p,j]=d.useState(null),g=Q({mutationFn:()=>E.adminTokens.create(u.trim(),h,P==="never"?null:Number(P)),onSuccess:m=>{c(!1),a(""),b(m.secret)},invalidate:[U.adminTokens]}),l=Q({mutationFn:m=>E.adminTokens.revoke(m.id),onSuccess:()=>j(null),invalidate:[U.adminTokens]});return t.jsxs(A,{flush:!0,title:"Management tokens",description:t.jsxs(t.Fragment,{children:["For scripts and CI. Send as ",t.jsx("code",{children:"Authorization: Bearer …"})," to ",t.jsx("code",{children:"/console/api"}),"."]}),actions:t.jsx(y,{size:"sm",leadingIcon:t.jsx(G.plus,{size:14}),onClick:()=>c(!0),children:"New token"}),children:[t.jsx(z,{query:r,children:m=>t.jsx(Ae,{label:"Management tokens",rows:m,rowKey:o=>o.id,rowLabel:o=>o.label,actions:o=>[{label:"Revoke",tone:"danger",onSelect:()=>j(o)}],empty:t.jsx(Ie,{icon:t.jsx(G.keys,{size:18}),title:"No management tokens"}),columns:[{key:"label",header:"Name",render:o=>t.jsx(Ne,{name:o.label,hint:o.hint})},{key:"scope",header:"Scope",render:o=>o.scope==="admin"?t.jsx(M,{tone:"warning",children:"Admin"}):t.jsx(M,{children:"Read only"})},{key:"created",header:"Created",secondary:!0,optional:!0,render:o=>W(o.createdAt)},{key:"expires",header:"Expires",secondary:!0,render:o=>t.jsx(Ce,{at:o.expiresAt,format:W})},{key:"used",header:"Last used",secondary:!0,optional:!0,render:o=>Me(o.lastUsedAt)}]})}),t.jsx(J,{isOpen:n,onClose:()=>c(!1),title:"New management token",children:t.jsxs("form",{className:"gc-stack",onSubmit:m=>{m.preventDefault(),g.mutate()},children:[t.jsx(O,{label:"Name",required:!0,value:u,onChange:m=>a(m.target.value),placeholder:"e.g. Terraform"}),t.jsx(L,{label:"Scope",value:h,onChange:m=>k(m),options:[{value:"read",label:"Read only (GET requests)"},{value:"admin",label:"Admin (everything an org admin can do)"}]}),t.jsx(L,{label:"Expires after",value:P,onChange:v,options:[{value:"30",label:"30 days"},{value:"90",label:"90 days"},{value:"365",label:"1 year"},...s?[{value:"never",label:"Never"}]:[]],hint:"Short-lived tokens limit the damage if one leaks."}),g.error?t.jsx($,{error:g.error,title:"Could not create the token"}):null,t.jsxs("div",{className:"gc-actions",children:[t.jsx(y,{variant:"ghost",onClick:()=>c(!1),children:"Cancel"}),t.jsx(y,{type:"submit",disabled:g.isPending||!u.trim(),children:"Create token"})]})]})}),t.jsx(J,{isOpen:S!==null,onClose:()=>b(null),title:"Token created",children:S&&t.jsxs("div",{className:"gc-stack",children:[t.jsx(Ue,{secret:S}),t.jsx("div",{className:"gc-actions",children:t.jsx(y,{onClick:()=>b(null),children:"Done"})})]})}),t.jsx(ie,{isOpen:p!==null,busy:l.isPending,error:l.error,onClose:()=>j(null),onConfirm:()=>p&&l.mutate(p),title:"Revoke this token?",confirmLabel:"Revoke",body:`Anything using ${(p==null?void 0:p.label)??"this token"} loses access immediately.`})]})}function Xe({settings:e}){const s=e.auth,r=n=>n?t.jsx(M,{tone:"success",children:"On"}):t.jsx(M,{children:"Off"});return t.jsx(A,{title:"Sign-in methods",description:"Configured on the gateway host with environment variables. Read only here.",children:t.jsxs("div",{className:"gc-stack",children:[t.jsx(le,{items:[["Passkeys",r(s.passkey)],["Wallet (Sign-In with Ethereum)",r(s.wallet)],["OpenID Connect",s.oidc?t.jsx(M,{tone:"success",children:s.oidc.label},"o"):r(!1)],["Cloudflare Access",r(s.cloudflareAccess)],["API key view for key holders",r(s.apiKeyLogin)]]}),t.jsx(D,{tone:"info",title:"Using your own identity provider",children:"Set the OpenID Connect issuer, client id and secret in the gateway's environment and restart it, or put the console behind Cloudflare Access and enable trusted Access headers. The gateway docs list the exact variables. Antseed runs no sign-in service of its own."})]})})}function et({tab:e,settings:s}){return e==="buyer"?t.jsx(Je,{settings:s}):e==="observability"?t.jsx(Ye,{settings:s}):t.jsx(Xe,{settings:s})}function mt(){const[e,s]=d.useState(()=>{const n=new URLSearchParams(window.location.search).get("tab");return We.includes(n)?n:"general"}),r=Se({queryKey:U.settings,queryFn:E.settings.get});return d.useEffect(()=>{var n;(n=window.scrollTo)==null||n.call(window,0,0)},[e]),t.jsxs("div",{className:"gc-page",children:[t.jsx(je,{title:"Settings"}),t.jsx(Oe,{id:"gc-settings",label:"Settings sections",value:e,onChange:s,tabs:[{id:"general",label:"General"},{id:"buyer",label:"Buyer"},{id:"observability",label:"Observability"},{id:"tokens",label:"Management tokens"},{id:"auth",label:"Sign-in"}]}),t.jsxs(Ee,{tabsId:"gc-settings",tab:e,className:"gc-stack",children:[e==="general"&&t.jsx(Ge,{}),e==="tokens"&&t.jsx(Ze,{}),(e==="buyer"||e==="observability"||e==="auth")&&t.jsx(z,{query:r,children:n=>t.jsx(et,{tab:e,settings:n})}),r.error&&e==="general"?t.jsx($,{error:r.error}):null]})]})}export{mt as default};
@@ -1 +0,0 @@
1
- import{r as e,j as s}from"./index-CL8Uzy58.js";function _({checked:a,onChange:r,label:l,description:t,disabled:n,className:o}){const c=e.useId(),i=e.useId();return s.jsxs("div",{className:["as-switch",o].filter(Boolean).join(" "),children:[s.jsx("button",{id:c,type:"button",role:"switch","aria-checked":a,"aria-describedby":t?i:void 0,disabled:n,className:a?"as-switch__track as-switch__track--on":"as-switch__track",onClick:()=>r(!a),children:s.jsx("span",{className:"as-switch__thumb"})}),s.jsxs("label",{htmlFor:c,className:"as-switch__text",children:[s.jsx("span",{className:"as-switch__label",children:l}),t&&s.jsx("span",{id:i,className:"as-switch__desc",children:t})]})]})}export{_ as S};
@@ -1 +0,0 @@
1
- import{r as o,j as s,$ as c,a0 as m,a1 as u}from"./index-CL8Uzy58.js";function j({label:a,hint:i,error:e,className:l,id:d,mono:r,...n}){const x=o.useId(),t=d??x;return s.jsxs("label",{className:u(l),htmlFor:t,children:[a&&s.jsx("span",{className:"as-field__label",children:a}),s.jsx("textarea",{id:t,className:c("as-field__textarea",r),"aria-invalid":e?!0:void 0,...n}),s.jsx(m,{error:e,hint:i})]})}export{j as T};