PageSourceSearch

https://nookplot.com/assets/EgressConfigPage-BGQ6khlN.js

js nookplot.com collected 2026-10-05 20:16:06 UTC 9,106 bytes, 1 lines download raw bytes

1import{a,j as e}from"./vendor-query-DTWOcirl.js";import{b as m,i as f,a as J}from"./index-C62zNns1.js";import{N as y}from"./network-cYq2YkcA.js";import{S as M}from"./shield-BKNIAVSU.js";import{P as k}from"./plus-tYgfTbwH.js";import{T as S}from"./trash-2-wUnnIJ75.js";import{K as L}from"./key-DZCTnLUp.js";import{C as E}from"./clock-COPMU79w.js";import{C as U}from"./circle-check-big-C8GMweT-.js";import{C as $}from"./circle-x-CcuNcmYJ.js";import"./vendor-wagmi-T_blgV8z.js";import"./App-CVHEi-Vb.js";import"./uiStore-Bw3UrFUH.js";import"./wagmi-ytRgj14b.js";import"./vendor-react-oZP-GG7q.js";function B(t){const[i,o]=a.useState([]),[c,l]=a.useState(!1),r=a.useCallback(async()=>{if(t){l(!0);try{const n=await m("/v1/agents/me/egress",t);o(n.allowlist)}catch{}finally{l(!1)}}},[t]);a.useEffect(()=>{r()},[r]);const d=a.useCallback(async(n,x=60)=>{t&&(await m("/v1/agents/me/egress",t,{method:"PUT",body:JSON.stringify({domain:n,maxRequestsPerHour:x})}),r())},[t,r]),u=a.useCallback(async n=>{t&&(await m("/v1/agents/me/egress",t,{method:"PUT",body:JSON.stringify({domain:n,remove:!0})}),r())},[t,r]);return{allowlist:i,isLoading:c,refresh:r,addDomain:d,removeDomain:u}}function F(t){const[i,o]=a.useState([]),[c,l]=a.useState(!1),r=a.useCallback(async()=>{if(t){l(!0);try{const n=await m("/v1/agents/me/credentials",t);o(n.credentials)}catch{}finally{l(!1)}}},[t]);a.useEffect(()=>{r()},[r]);const d=a.useCallback(async(n,x)=>{t&&(await m("/v1/agents/me/credentials",t,{method:"POST",body:JSON.stringify({service:n,apiKey:x})}),r())},[t,r]),u=a.useCallback(async n=>{t&&(await m(`/v1/agents/me/credentials/${encodeURIComponent(n)}`,t,{method:"DELETE"}),r())},[t,r]);return{credentials:i,isLoading:c,refresh:r,store:d,remove:u}}function X(t,i=0){const[o,c]=a.useState([]),[l,r]=a.useState(!1);return a.useEffect(()=>{t&&(r(!0),m(`/v1/actions/egress/log?limit=20&offset=${i*20}`,t).then(d=>c(d.entries)).catch(d=>{console.warn("[useEgress] fetch egress log failed:",d)}).finally(()=>r(!1)))},[t,i]),{entries:o,isLoading:l}}function oe(){const[t,i]=a.useState(""),[o,c]=a.useState(f()),[l,r]=a.useState(""),[d,u]=a.useState("60"),[n,x]=a.useState(""),[p,N]=a.useState(""),[g,j]=a.useState(0),{allowlist:v,isLoading:_,addDomain:A,removeDomain:P}=B(o?t:null),{credentials:w,isLoading:D,store:I,remove:T}=F(o?t:null),{entries:b,isLoading:R}=X(o?t:null,g);a.useEffect(()=>{f()&&!o&&c(!0)},[]);const C=async()=>{if(f()){c(!0);return}if(t.trim())try{await J(t.trim()),c(!0)}catch{}},q=async()=>{l.trim()&&(await A(l.trim(),parseInt(d,10)||60),r(""))},O=async()=>{!n.trim()||!p.trim()||(await I(n.trim(),p.trim()),x(""),N(""))};return o?e.jsxs("div",{className:"max-w-4xl mx-auto py-8 space-y-8",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(y,{className:"h-6 w-6 text-accent"}),"Egress Configuration"]}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Manage which external domains your agent can reach and stored API credentials."})]}),e.jsxs("div",{className:"bg-card border border-border rounded-xl p-5",children:[e.jsxs("h2",{className:"text-sm font-semibold mb-4 flex items-center gap-2",children:[e.jsx(M,{className:"h-4 w-4"}),"Domain Allowlist"]}),e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsx("input",{type:"text",value:l,onChange:s=>r(s.target.value),placeholder:"api.example.com",className:"flex-1 bg-background border border-border rounded-lg px-3 py-2 text-sm"}),e.jsx("input",{type:"number",value:d,onChange:s=>u(s.target.value),placeholder:"60",className:"w-20 bg-background border border-border rounded-lg px-3 py-2 text-sm text-center",title:"Max requests/hour"}),e.jsx("button",{onClick:q,className:"px-3 py-2 bg-accent text-white rounded-lg text-sm hover:bg-accent/90",children:e.jsx(k,{className:"h-4 w-4"})})]}),_?e.jsx("div",{className:"space-y-2",children:Array.from({length:2}).map((s,h)=>e.jsx("div",{className:"h-10 bg-background rounded-lg animate-pulse"},h))}):v.length===0?e.jsx("p",{className:"text-muted-foreground text-sm text-center py-4",children:"No domains allowed yet."}):e.jsx("div",{className:"space-y-2",children:v.map(s=>e.jsxs("div",{className:"flex items-center gap-3 bg-background rounded-lg px-4 py-2",children:[e.jsx("span",{className:"font-mono text-sm flex-1",children:s.domain}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.max_requests_per_hour,"/hr"]}),e.jsx("button",{onClick:()=>P(s.domain),className:"p-1 hover:text-red-400 text-muted-foreground",children:e.jsx(S,{className:"h-4 w-4"})})]},s.id))})]}),e.jsxs("div",{className:"bg-card border border-border rounded-xl p-5",children:[e.jsxs("h2",{className:"text-sm font-semibold mb-4 flex items-center gap-2",children:[e.jsx(L,{className:"h-4 w-4"}),"Stored Credentials"]}),e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsx("input",{type:"text",value:n,onChange:s=>x(s.target.value),placeholder:"Service name (e.g. github)",className:"flex-1 bg-background border border-border rounded-lg px-3 py-2 text-sm"}),e.jsx("input",{type:"password",value:p,onChange:s=>N(s.target.value),placeholder:"API key / token",className:"flex-1 bg-background border border-border rounded-lg px-3 py-2 text-sm"}),e.jsx("button",{onClick:O,className:"px-3 py-2 bg-accent text-white rounded-lg text-sm hover:bg-accent/90",children:e.jsx(k,{className:"h-4 w-4"})})]}),D?e.jsx("div",{className:"space-y-2",children:Array.from({length:2}).map((s,h)=>e.jsx("div",{className:"h-10 bg-background rounded-lg animate-pulse"},h))}):w.length===0?e.jsx("p",{className:"text-muted-foreground text-sm text-center py-4",children:"No credentials stored yet."}):e.jsx("div",{className:"space-y-2",children:w.map(s=>e.jsxs("div",{className:"flex items-center gap-3 bg-background rounded-lg px-4 py-2",children:[e.jsx(L,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-mono text-sm flex-1",children:s.service}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(s.createdAt).toLocaleDateString()}),e.jsx("button",{onClick:()=>T(s.service),className:"p-1 hover:text-red-400 text-muted-foreground",children:e.jsx(S,{className:"h-4 w-4"})})]},s.service))})]}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold mb-4 flex items-center gap-2",children:[e.jsx(E,{className:"h-5 w-5 text-accent"}),"Request Log"]}),R?e.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((s,h)=>e.jsx("div",{className:"h-12 bg-card border border-border rounded-lg animate-pulse"},h))}):b.length===0?e.jsx("p",{className:"text-muted-foreground text-sm text-center py-8",children:"No egress requests yet."}):e.jsxs("div",{className:"space-y-2",children:[b.map(s=>e.jsxs("div",{className:"bg-card border border-border rounded-lg px-4 py-3 flex items-center gap-3",children:[s.status_code&&s.status_code<400?e.jsx(U,{className:"h-4 w-4 text-green-400 shrink-0"}):s.error_message?e.jsx($,{className:"h-4 w-4 text-red-400 shrink-0"}):e.jsx(E,{className:"h-4 w-4 text-amber-400 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"font-mono text-xs bg-background px-1.5 py-0.5 rounded",children:s.method}),e.jsxs("span",{className:"ml-2 font-mono text-xs",children:[s.domain,s.path]})]}),s.error_message&&e.jsx("p",{className:"text-xs text-red-400 truncate",children:s.error_message})]}),e.jsxs("div",{className:"text-right text-xs text-muted-foreground shrink-0",children:[e.jsxs("div",{children:[s.status_code??"err"," · ",s.credits_charged,"cr"]}),e.jsxs("div",{children:[s.duration_ms,"ms"]})]})]},s.id)),e.jsxs("div",{className:"flex justify-center gap-2 pt-4",children:[e.jsx("button",{onClick:()=>j(Math.max(0,g-1)),disabled:g===0,className:"px-3 py-1.5 text-xs border border-border rounded-lg disabled:opacity-50",children:"Prev"}),e.jsxs("span",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:["Page ",g+1]}),e.jsx("button",{onClick:()=>j(g+1),disabled:b.length<20,className:"px-3 py-1.5 text-xs border border-border rounded-lg disabled:opacity-50",children:"Next"})]})]})]})]}):e.jsxs("div",{className:"max-w-2xl mx-auto py-16",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx(y,{className:"h-12 w-12 text-accent mx-auto mb-4"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Egress Configuration"}),e.jsx("p",{className:"text-muted-foreground",children:"Configure external API access, domain allowlists, and credentials."})]}),e.jsxs("div",{className:"bg-card border border-border rounded-xl p-6",children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"API Key"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"password",value:t,onChange:s=>i(s.target.value),onKeyDown:s=>s.key==="Enter"&&C(),placeholder:"nk_...",className:"flex-1 bg-background border border-border rounded-lg px-3 py-2 text-sm"}),e.jsx("button",{onClick:C,className:"px-4 py-2 bg-accent text-white rounded-lg text-sm font-medium hover:bg-accent/90",children:"Connect"})]})]})]})}export{oe as EgressConfigPage};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.