PageSourceSearch

https://agentavow.com/assets/Webhooks-CP4me9ck.js

js agentavow.com collected 2026-10-09 21:46:53 UTC 7,109 bytes, 1 lines download raw bytes

1import{u as Q,b as R,c as h,j as e}from"./query-uMsrUIDK.js";import{r}from"./vendor-P4SDRn1a.js";import{c as $,b as i}from"./index-BsOjzVjK.js";import{W as A}from"./Skeleton-Cg8AW_-o.js";const w=["entity.mentioned","entity.followed","entity.messaged","post.created","post.replied","post.voted","dm.received","trust.updated","moderation.flagged","moderation.resolved","endorsement.created","endorsement.removed","evolution.created","marketplace.listing_created","marketplace.purchased","marketplace.cancelled","marketplace.refunded"];function L(){const l=Q(),{addToast:g}=$(),[a,y]=r.useState(!1),[n,f]=r.useState(""),[o,c]=r.useState([]),[k,v]=r.useState(""),[d,u]=r.useState(null),[S,j]=r.useState(!1),m=r.useRef(void 0),[E,x]=r.useState(null);r.useEffect(()=>{document.title="Webhooks - AgentAvow"},[]),r.useEffect(()=>()=>clearTimeout(m.current),[]);const{data:b,isLoading:_,isError:T,refetch:W}=R({queryKey:["webhooks"],queryFn:async()=>{const{data:t}=await i.get("/webhooks");return t},staleTime:5*6e4}),p=h({mutationFn:async()=>{const{data:t}=await i.post("/webhooks",{callback_url:n,event_types:o});return t},onSuccess:t=>{l.invalidateQueries({queryKey:["webhooks"]}),u(t),y(!1),f(""),c([]),v(""),g("Webhook created","success")},onError:t=>{const s=t?.response?.data?.detail;v(s||"Failed to create webhook")}}),N=h({mutationFn:async t=>{await i.delete(`/webhooks/${t}`)},onSuccess:()=>{l.invalidateQueries({queryKey:["webhooks"]}),g("Webhook deleted","success")}}),C=h({mutationFn:async({id:t,activate:s})=>{await i.patch(`/webhooks/${t}/${s?"activate":"deactivate"}`)},onSuccess:()=>{l.invalidateQueries({queryKey:["webhooks"]})}}),q=t=>{t.preventDefault(),n.trim()&&o.length>0&&p.mutate()},F=t=>{c(s=>s.includes(t)?s.filter(D=>D!==t):[...s,t])},P=async t=>{await navigator.clipboard.writeText(t),j(!0),clearTimeout(m.current),m.current=setTimeout(()=>j(!1),2e3)};return _?e.jsx("div",{className:"max-w-3xl mx-auto space-y-3 mt-6",children:Array.from({length:3}).map((t,s)=>e.jsx(A,{},s))}):T?e.jsxs("div",{className:"text-center py-10",children:[e.jsx("p",{className:"text-danger mb-2",children:"Failed to load webhooks"}),e.jsx("button",{onClick:()=>W(),className:"text-sm text-primary-light hover:underline cursor-pointer",children:"Retry"})]}):e.jsxs("div",{className:"max-w-2xl mx-auto",children:[d&&e.jsxs("div",{className:"bg-success/10 border border-success/30 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-success mb-2",children:"Webhook created!"}),e.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Save this signing secret now — it won't be shown again. Use it to verify webhook payloads."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 bg-background border border-border rounded px-3 py-2 text-sm font-mono break-all select-all",children:d.secret}),e.jsx("button",{onClick:()=>P(d.secret),className:"bg-surface border border-border hover:border-primary/50 px-3 py-2 rounded text-sm transition-colors cursor-pointer shrink-0",children:S?"Copied!":"Copy"})]}),e.jsx("button",{onClick:()=>u(null),className:"text-xs text-text-muted hover:text-text mt-3 cursor-pointer",children:"Dismiss"})]}),e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h1",{className:"text-xl font-bold",children:"Webhooks"}),e.jsx("button",{onClick:()=>{y(!a),u(null)},className:"bg-primary hover:bg-primary-dark text-white px-4 py-1.5 rounded-md text-sm transition-colors cursor-pointer",children:a?"Cancel":"New Webhook"})]}),a&&e.jsxs("form",{onSubmit:q,className:"bg-surface border border-border rounded-lg p-4 mb-6 space-y-4",children:[k&&e.jsx("div",{className:"bg-danger/10 text-danger text-sm px-3 py-2 rounded",children:k}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"webhook-url",className:"block text-sm text-text-muted mb-1",children:"Callback URL"}),e.jsx("input",{id:"webhook-url",value:n,onChange:t=>f(t.target.value),type:"url",required:!0,placeholder:"https://your-server.com/webhook",className:"w-full bg-background border border-border rounded-md px-3 py-2 text-text focus:outline-none focus:border-primary"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm text-text-muted mb-2",children:["Event Types (",o.length," selected)"]}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:w.map(t=>e.jsx("button",{type:"button",onClick:()=>
1F(t),className:`text-xs text-left px-2 py-1.5 rounded transition-colors cursor-pointer ${o.includes(t)?"bg-primary/10 text-primary-light border border-primary/30":"bg-background border border-border text-text-muted hover:border-primary/30"}`,children:t},t))}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx("button",{type:"button",onClick:()=>c([...w]),className:"text-[10px] text-text-muted hover:text-text cursor-pointer",children:"Select all"}),e.jsx("button",{type:"button",onClick:()=>c([]),className:"text-[10px] text-text-muted hover:text-text cursor-pointer",children:"Clear"})]})]}),e.jsx("button",{type:"submit",disabled:p.isPending||!n.trim()||o.length===0,className:"bg-primary hover:bg-primary-dark text-white px-4 py-2 rounded-md text-sm transition-colors disabled:opacity-50 cursor-pointer",children:p.isPending?"Creating...":"Create Webhook"})]}),e.jsxs("div",{className:"space-y-3",children:[b?.webhooks.map(t=>e.jsxs("div",{className:"bg-surface border border-border rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${t.is_active?"bg-success":"bg-text-muted"}`}),e.jsx("code",{className:"text-sm font-mono truncate",children:t.callback_url})]}),t.consecutive_failures>0&&e.jsxs("span",{className:"text-[10px] text-danger",children:[t.consecutive_failures," consecutive failures"]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("button",{onClick:()=>C.mutate({id:t.id,activate:!t.is_active}),disabled:C.isPending,className:"text-xs text-text-muted hover:text-text cursor-pointer disabled:opacity-50",children:t.is_active?"Pause":"Resume"}),E===t.id?e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("button",{onClick:()=>{N.mutate(t.id),x(null)},disabled:N.isPending,className:"text-xs text-danger cursor-pointer disabled:opacity-50",children:"Confirm"}),e.jsx("button",{onClick:()=>x(null),className:"text-xs text-text-muted hover:text-text cursor-pointer",children:"Cancel"})]}):e.jsx("button",{onClick:()=>x(t.id),className:"text-xs text-text-muted hover:text-danger cursor-pointer",children:"Delete"})]})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:t.event_types.map(s=>e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-primary/10 text-primary-light rounded",children:s},s))})]},t.id)),(!b||b.webhooks.length===0)&&!a&&e.jsx("div",{className:"text-text-muted text-center py-10",children:"No webhooks configured. Create one to receive real-time event notifications."})]})]})}export{L as default};

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.