PageSourceSearch

https://prompeteer.ai/assets/AdminQualityFlywheel-CwX8_7eW.js

js prompeteer.ai collected 2026-10-05 12:27:38 UTC 15,822 bytes, 1 lines download raw bytes

1import{r as c,j as e}from"./vendor-react-CjtdLP_L.js";import{u as _,a as $}from"./vendor-query-Dm6IpjeQ.js";import{a as R,q as Y}from"./queryClient-CAqhRfHG.js";import{C as x,a as p,d as N,c as j,b as P}from"./card-LCaJb0qG.js";import{T as Z,a as ee,b as O,c as m,d as te,e as u}from"./table-Dl1NLCIB.js";import{B as r}from"./button-CgHkADzY.js";import{B as A}from"./badge-C1_E7bcS.js";import{u as le,L as f,I as w}from"./AuthModal-XlKB8C9v.js";import{S as se}from"./switch-DRsOhBdK.js";import{D as z,a as H,b as Q,c as V,e as G}from"./dialog-BmoBvzwc.js";import{S as ae,a as ie,b as ne,c as re,d as de}from"./select-ypFJox8d.js";import{N as ce}from"./Navigation-BihYueM1.js";import{F as oe}from"./Footer-i6iw7uTD.js";import{L as me}from"./index-DpJDnEHE.js";import{aT as ue,aK as he,ad as xe,bu as pe,w as je}from"./vendor-icons-CEtKkbCp.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./utils-09jiQjc0.js";import"./index-DYd1AhEw.js";import"./index-CXo7hDKg.js";import"./vendor-react-icons-C3u-PHNU.js";import"./index-CaH9w3gZ.js";import"./supabase--Raqy1d_.js";import"./index-DMBtqBCC.js";import"./auth-return-to-JRaTzEJL.js";import"./consent-D3s5Yi52.js";import"./Logo-Dtk25poC.js";import"./vendor-i18n-B-dTb0jX.js";import"./index-D8gd2y9N.js";import"./index-Bnm5UW7A.js";import"./index-Bl7FDrSo.js";import"./index-CfHttwlL.js";import"./index-CFQO6bFv.js";import"./useAuth-BOD9I5M3.js";import"./index-DC01emjG.js";import"./workspace-context-CmD3Vyun.js";import"./workspace-account-requests-DGgpqxXh.js";import"./dropdown-menu-YjUv8fUk.js";import"./index-NncAJq6c.js";import"./BeaconMark-BfuppPGY.js";import"./WorkspacePreferences-CMsTGmr9.js";import"./workspace-route-transition-Dap2JeOj.js";import"./beacon-request-Bo3SWsEZ.js";import"./beacon-access-LXtv0J6t.js";import"./app-chrome-Chb-SQcU.js";import"./index-CTrG49eW.js";import"./vendor-motion-DcfotHwo.js";import"./public-product-facts-DAmplUKb.js";function E(l){return l instanceof Error?l.message:typeof l=="string"?l:String(l)}function W({cell:l}){return l.killSwitchState==="forced_off"?e.jsxs(A,{variant:"destructive",className:"gap-1",children:[e.jsx(pe,{className:"h-3 w-3"})," forced_off"]}):l.enabled?e.jsxs(A,{variant:"default",className:"gap-1 bg-emerald-600",children:[e.jsx(je,{className:"h-3 w-3"})," auto"]}):e.jsx(A,{variant:"secondary",children:"disabled"})}function L({frac:l}){const d=Math.round(l*100),C=d>=90?"bg-red-500":d>=70?"bg-amber-500":"bg-emerald-500";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2 w-16 rounded bg-muted overflow-hidden",children:e.jsx("div",{className:`h-full ${C}`,style:{width:`${d}%`}})}),e.jsxs("span",{className:"text-xs tabular-nums",children:[d,"%"]})]})}function mt(){const{toast:l}=le(),{data:d,isLoading:C,refetch:S}=_({queryKey:["/api/admin/quality-flywheel/cells"]}),[s,g]=c.useState(null),[D,v]=c.useState(!1),h=()=>Y.invalidateQueries({queryKey:["/api/admin/quality-flywheel/cells"]}),y=$({mutationFn:async t=>(await R("POST",`/api/admin/quality-flywheel/cells/${encodeURIComponent(t.platform)}/${encodeURIComponent(t.modality)}/kill-switch`,{state:t.state,reason:t.reason})).json(),onSuccess:()=>{l({title:"Kill switch updated"}),h()},onError:t=>l({title:"Failed",description:E(t),variant:"destructive"})}),q=$({mutationFn:async t=>(await R("POST",`/api/admin/quality-flywheel/cells/${encodeURIComponent(t.platform)}/${encodeURIComponent(t.modality)}/budget`,t)).json(),onSuccess:()=>{l({title:"Budget updated"}),h()},onError:t=>l({title:"Failed",description:E(t),variant:"destructive"})}),b=$({mutationFn:async t=>(await R("POST","/api/admin/quality-flywheel/cells",t)).json(),onSuccess:()=>{l({title:"Cell saved"}),h(),v(!1)},onError:t=>l({title:"Failed",description:E(t),variant:"destructive"})}),M=$({mutationFn:async t=>(await R("POST",`/api/admin/quality-flywheel/cells/${encodeURIComponent(t.platform)}/${encodeURIComponent(t.modality)}/evaluate`,{})).json(),onSuccess:t=>{l({title:`Evaluated: ${t.decision?.action??"no_change"}`}),h()},onError:t=>l({title:"Failed",description:E(t),variant:"destructive"})}),{data:n}=_({queryKey:["/api/admin/quality-flywheel/platform-override-stats"],refetchInterval:6e4}),o=d?.cells??[],F=o.length,B=o.filter(t=>t.cell.killSwitchState==="forced_off").length,i=o.filter(t=>t.cell.enabled).length,k=o.filter(t=>typeof t.aPlusPlusWinRate=="number"),I=k.length>0?k.reduce((t,a)=>t+(a.aPlusPlusWinRate??0),0)/k.length:null,J=$({mutationFn:async t=>(await R("POST",`/api/admin/quality-flywheel/cells/${encodeURIComponent(t.platform)}/${encodeURIComponent(t.modality)}/activate-retrieval`,{enabled:t.enabled,reason:t.reason})).json(),onSuccess:()=>{l({title:"Retrieval gate updated"}),h()},onError:t=>l({title:"Failed",description:E(t),variant:"destructive"})});return e.jsxs("div",{className:"min-h-screen flex flex-col bg-background",children:[e.jsx(ce,{}),e.jsxs("main",{className:"flex-1 max-w-7xl mx-auto w-full p-6 space-y-6","data-testid":"page-admin-quality-flywheel",children:[e.jsxs("header",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Quality Flywheel"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Per-cell kill switches, budgets, and rollback policy. Live request path is unchanged; these controls take effect once T2/T3/T4 land."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(me,{href:"/admin/quality-flywheel/cell-rollout",children:e.jsxs(r,{variant:"outline","data-testid":"btn-cell-rollout",children:[e.jsx(ue,{className:"h-4 w-4 mr-2"})," Cell rollout"]})}),e.jsxs(r,{variant:"outline",onClick:()=>S(),"data-testid":"btn-refresh-cells",children:[e.jsx(he,{className:"h-4 w-4 mr-2"})," Refresh"]}),e.jsx(r,{onClick:()=>v(!0),"data-testid":"btn-new-cell",children:"+ New cell"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx(x,{children:e.jsxs(p,{children:[e.jsx(N,{children:"Total cells"}),e.jsx(j,{children:F})]})}),e.jsx(x,{children:e.jsxs(p,{children:[e.jsx(N,{children:"Enabled"}),e.jsx(j,{children:i})]})}),e.jsx(x,{children:e.jsxs(p,{children:[e.jsx(N,{children:"Tripped"}),e.jsx(j,{className:B?"text-red-600":"",children:B})]})}),e.jsxs(x,{"data-testid":"card-platform-override-mismatch",children:[e.jsxs(p,{children:[e.jsx(N,{children:"Platform-override mismatch (24h)"}),e.jsx(j,{className:n?.mismatchRate==null?"text-muted-foreground":n.mismatchRate>.05?"text-amber-600":"","data-testid":"card-platform-override-mismatch-rate",children:n?.mismatchRate==null?"-":`${(n.mismatchRate*100).toFixed(2)}%`})]}),e.jsxs(P,{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("div",{"data-testid":"card-platform-override-mismatch-counts",children:[n?.mismatches??0," mismatches /"," ",n?.overrideFires??0," NL overrides /"," ",n?.generations??0," generations"]}),n&&n.topMismatches.length>0&&e.jsxs("div",{className:"pt-1",children:["Top:"," ",n.topMismatches.slice(0,3).map((t,a)=>e.jsxs("span",{className:"tabular-nums",children:[a>0?", ":"",e.jsxs("code",{children:[t.speculative,"→",t.corrected]})," (",t.count,")"]},`${t.speculative}-${t.corrected}`))]})]})]}),e.jsxs(x,{"data-testid":"card-aplusplus-win-rate",children:[e.jsxs(p,{children:[e.jsx(N,{children:"A++ Win Rate (fleet, today)"}),e.jsx(j,{className:I==null?"text-muted-foreground":"",children:I==null?"-":`${(I*100).toFixed(1)}%`})]}),e.jsxs(P,{className:"text-xs text-muted-foreground",children:["wins / (wins + losses) across ",k.length," cell",k.length===1?"":"s"]})]})]}),e.jsxs(x,{children:[e.jsx(p,{children:e.jsx(j,{children:"Cell matrix"})}),e.jsx(P,{children:C?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading…"}):o.length===0?e.jsxs("div",{className:"text-sm text-muted-foreground","data-testid":"empty-cells",children:["No cells configured yet. Click ",e.jsx("strong",{children:"New cell"})," to add one (e.g. ",e.jsx("code",{children:"elevenlabs / audio"}),")."]}):e.jsxs(Z,{"data-testid":"table-cells",children:[e.jsx(ee,{children:e.jsxs(O,{children:[e.jsx(m,{children:"Cell"}),e.jsx(m,{children:"Status"}),e.jsx(m,{children:"Tiers"}),e.jsx(m,{children:"Burn (T2 / T3 / T4)"}),e.jsx(m,{children:"Regression today"}),e.jsx(m,{children:"Exemplars"}),e.jsx(m,{children:"Dedupe savings"}),e.jsx(m,{className:"text-right",children:"Actions"})]})}),e.jsx(te,{children:o.map(t=>e.jsxs(O,{"data-testid":`row-cell-${t.cell.platform}-${t.cell.modality}`,children:[e.jsxs(u,{className:"font-medium",children:[e.jsx("div",{children:t.cell.platform}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.cell.modality})]}),e.jsx(u,{children:e.jsx(W,{cell:t.cell})}),e.jsxs(u,{className:"text-xs",children:[e.jsxs("div",{children:["R: ",t.cell.retrievalEnabled?"✓":"-"]}
1),e.jsxs("div",{children:["T2/T3/T4: ",t.cell.t2Enabled?"✓":"-"," / ",t.cell.t3Enabled?"✓":"-"," / ",t.cell.t4Enabled?"✓":"-"]})]}),e.jsx(u,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx(L,{frac:t.burn.t2.tokens}),e.jsx(L,{frac:t.burn.t3.tokens}),e.jsx(L,{frac:t.burn.t4.tokens})]})}),e.jsxs(u,{children:[t.today?`${(t.today.regressionRateEstimate*100).toFixed(1)}%`:"-",e.jsxs("div",{className:"text-xs text-muted-foreground",children:["threshold ",(t.cell.regressionThreshold*100).toFixed(0),"%"]})]}),e.jsxs(u,{children:[e.jsx("div",{children:t.today?.exemplarCount??0}),e.jsxs("div",{className:"text-xs text-muted-foreground","data-testid":`cell-aplusplus-${t.cell.platform}-${t.cell.modality}`,children:["A++ ",t.aPlusPlusWinRate==null?"-":`${(t.aPlusPlusWinRate*100).toFixed(1)}%`]})]}),e.jsxs(u,{"data-testid":`cell-dedupe-${t.cell.platform}-${t.cell.modality}`,children:[e.jsxs("div",{className:"tabular-nums",children:[t.today?.dedupeSkippedCount??0," skips"]}),e.jsxs("div",{className:"text-xs text-muted-foreground tabular-nums",children:[(t.today?.dedupeSavedTokens??0).toLocaleString()," tok · $",Number(t.today?.dedupeSavedDollars??0).toFixed(4)]})]}),e.jsxs(u,{className:"text-right space-x-1",children:[e.jsx(r,{size:"sm",variant:"outline",onClick:()=>g(t),"data-testid":`btn-drill-${t.cell.platform}-${t.cell.modality}`,children:"Open"}),e.jsx(r,{size:"sm",variant:t.cell.retrievalEnabled?"secondary":"default",onClick:()=>{const a=!t.cell.retrievalEnabled,T=window.prompt(`Reason to ${a?"activate":"deactivate"} retrieval (audited):`,a?"shadow-eval gate passed":"manual deactivate");T&&J.mutate({platform:t.cell.platform,modality:t.cell.modality,enabled:a,reason:T})},"data-testid":`btn-retrieval-${t.cell.platform}-${t.cell.modality}`,children:t.cell.retrievalEnabled?"Pause retrieval":"Activate retrieval"}),e.jsx(r,{size:"sm",variant:t.cell.killSwitchState==="forced_off"?"default":"destructive",onClick:()=>{const a=window.prompt("Reason for kill-switch toggle (audited):","manual override");a&&y.mutate({platform:t.cell.platform,modality:t.cell.modality,state:t.cell.killSwitchState==="forced_off"?"auto":"forced_off",reason:a})},"data-testid":`btn-kill-${t.cell.platform}-${t.cell.modality}`,children:t.cell.killSwitchState==="forced_off"?"Restore":"Kill"})]})]},`${t.cell.platform}/${t.cell.modality}`))})]})})]}),e.jsx(z,{open:!!s,onOpenChange:t=>!t&&g(null),children:e.jsx(H,{className:"max-w-2xl",children:s&&e.jsxs(e.Fragment,{children:[e.jsx(Q,{children:e.jsxs(V,{children:[s.cell.platform," / ",s.cell.modality]})}),e.jsxs("div",{className:"space-y-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{cell:s.cell}),e.jsx("span",{className:"text-xs text-muted-foreground",children:s.cell.lastStateChangeAt?`last changed ${new Date(s.cell.lastStateChangeAt).toLocaleString()}`:""})]}),s.cell.lastStateChangeReason&&e.jsx("div",{className:"rounded bg-muted p-2 text-xs",children:s.cell.lastStateChangeReason}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:["t2","t3","t4"].map(t=>{const a=`dailyTokenBudget${t.toUpperCase()}`,T=`dailyDollarBudget${t.toUpperCase()}`;return e.jsxs(x,{children:[e.jsxs(p,{className:"p-3",children:[e.jsx(j,{className:"text-sm uppercase",children:t}),e.jsxs(N,{children:["burn ",Math.round(s.burn[t].tokens*100),"%"]})]}),e.jsxs(P,{className:"p-3 space-y-2 text-xs",children:[e.jsxs("div",{children:["tokens: ",String(s.cell[a])]}),e.jsxs("div",{children:["$: ",String(s.cell[T])]}),e.jsx(r,{size:"sm",variant:"outline",className:"w-full",onClick:()=>{const U=window.prompt(`New daily token budget (${t}):`,String(s.cell[a]));if(U==null)return;const K=window.prompt(`New daily $ budget (${t}):`,String(s.cell[T]));if(K==null)return;const X=window.prompt("Reason (audited):","tuning")??"tuning";q.mutate({platform:s.cell.platform,modality:s.cell.modality,tier:t,dailyTokenBudget:Number(U),dailyDollarBudget:Number(K),reason:X})},"data-testid":`btn-edit-budget-${t}`,children:"Edit budget"})]})]},t)})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"h-4 w-4 text-amber-500"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Auto-rollback trips at > ",(s.cell.regressionThreshold*100).toFixed(0),"% for ",s.cell.regressionConsecutiveSamples," consecutive samples."]})]})]}),e.jsxs(G,{children:[e.jsx(r,{variant:"outline",onClick:()=>M.mutate({platform:s.cell.platform,modality:s.cell.modality}),"data-testid":"btn-evaluate",children:"Re-evaluate policy"}),e.jsx(r,{onClick:()=>g(null),children:"Close"})]})]})})}),e.jsx(fe,{open:D,onOpenChange:v,onSubmit:t=>b.mutate(t)})]}),e.jsx(oe,{})]})}function fe({open:l,onOpenChange:d,onSubmit:C}){const[S,s]=c.useState(""),[g,D]=c.useState("text"),[v,h]=c.useState(!1),[y,q]=c.useState(1e5),[b,M]=c.useState(5),[n,o]=c.useState(.1),[F,B]=c.useState(3);
1return e.jsx(z,{open:l,onOpenChange:d,children:e.jsxs(H,{children:[e.jsx(Q,{children:e.jsx(V,{children:"New quality cell"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(f,{children:"Platform"}),e.jsx(w,{value:S,onChange:i=>s(i.target.value),placeholder:"elevenlabs","data-testid":"input-platform"})]}),e.jsxs("div",{children:[e.jsx(f,{children:"Modality"}),e.jsxs(ae,{value:g,onValueChange:D,children:[e.jsx(ie,{"data-testid":"select-modality",children:e.jsx(ne,{})}),e.jsx(re,{children:["text","image","video","audio","code","data","chat","research"].map(i=>e.jsx(de,{value:i,children:i},i))})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{checked:v,onCheckedChange:h,"data-testid":"switch-enabled"})," ",e.jsx(f,{children:"Enabled"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(f,{children:"Daily token budget (per tier)"}),e.jsx(w,{type:"number",value:y,onChange:i=>q(Number(i.target.value))})]}),e.jsxs("div",{children:[e.jsx(f,{children:"Daily $ budget (per tier)"}),e.jsx(w,{type:"number",step:"0.01",value:b,onChange:i=>M(Number(i.target.value))})]}),e.jsxs("div",{children:[e.jsx(f,{children:"Regression threshold (0..1)"}),e.jsx(w,{type:"number",step:"0.01",value:n,onChange:i=>o(Number(i.target.value))})]}),e.jsxs("div",{children:[e.jsx(f,{children:"Consecutive samples"}),e.jsx(w,{type:"number",value:F,onChange:i=>B(Number(i.target.value))})]})]})]}),e.jsxs(G,{children:[e.jsx(r,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(r,{onClick:()=>C({platform:S,modality:g,enabled:v,retrievalEnabled:!1,t2Enabled:!1,t3Enabled:!1,t4Enabled:!1,dailyTokenBudgetT2:y,dailyTokenBudgetT3:y,dailyTokenBudgetT4:y,dailyDollarBudgetT2:String(b),dailyDollarBudgetT3:String(b),dailyDollarBudgetT4:String(b),killSwitchState:"auto",regressionThreshold:n,regressionConsecutiveSamples:F,lastStateChangeReason:"created"}),disabled:!S.trim(),"data-testid":"btn-submit-cell",children:"Create"})]})]})})}export{mt 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.