PageSourceSearch

https://adpilot-489907.web.app/assets/Auditor-DYK73UQ1.js

js adpilot-489907.web.app collected 2026-10-03 12:17:09 UTC 31,550 bytes, 1 lines download raw bytes

1import{r as i,j as t,L as B,a as n}from"./index-tNhE6V5Q.js";import{S as xt,a as A,C as u,A as pt}from"./Dash-4uLE9yHf.js";const Y={fact_correction:{label:"Fact correction",color:"bg-[#FEF2F2] text-[#DC2626] border-[#FECACA]"},behavioral_rule:{label:"Behavioral rule",color:"bg-[#EEF2FF] text-[#4338CA] border-[#C7D2FE]"},kb_gap:{label:"KB gap",color:"bg-[#FFFBEB] text-[#B45309] border-[#FDE68A]"},product_data_gap:{label:"Product data gap",color:"bg-[#FFF7ED] text-[#C2410C] border-[#FED7AA]"},tone:{label:"Tone",color:"bg-[#F0F9FF] text-[#0369A1] border-[#BAE6FD]"},escalation_miss:{label:"Escalation miss",color:"bg-[#FAF5FF] text-[#7C3AED] border-[#E9D5FF]"},praise:{label:"Praise",color:"bg-[#ECFDF5] text-[#0E9F6E] border-[#A7F3D0]"}},Ge={high:"text-[#DC2626]",medium:"text-[#B45309]",low:"text-[#8A93A2]"},o={good:"text-[11px] bg-[#0E9F6E] text-white rounded-[7px] px-3 py-1.5 hover:opacity-90 disabled:opacity-50",ghost:"text-[11px] bg-white border border-[#E5E8ED] text-[#59616F] rounded-[7px] px-3 py-1.5 hover:bg-[#F6F7F9] disabled:opacity-50",accent:"text-[11px] bg-[#4338CA] text-white rounded-[7px] px-3 py-1.5 hover:opacity-90 disabled:opacity-50",info:"text-[11px] bg-[#2563EB] text-white rounded-[7px] px-3 py-1.5 hover:opacity-90 disabled:opacity-50",violet:"text-[11px] bg-[#7C3AED] text-white rounded-[7px] px-3 py-1.5 hover:opacity-90 disabled:opacity-50",dark:"text-[11px] bg-[#181B24] text-white rounded-[7px] px-3 py-1.5 hover:opacity-90 disabled:opacity-50"},x="border border-[#E5E8ED] rounded-[7px] px-3 py-2 text-[12px] text-[#181B24] placeholder:text-[#8A93A2] focus:outline-none focus:border-[#4338CA]";function ht(){const[Z,m]=i.useState([]),[Ie,z]=i.useState([]),[J,Ke]=i.useState({}),[F,X]=i.useState(!0),[ee,te]=i.useState(!1),[P,se]=i.useState(null),[ae,r]=i.useState(null),[ie,R]=i.useState(null),[w,T]=i.useState(""),[ne,re]=i.useState(!1),[q,le]=i.useState([]),[O,oe]=i.useState([]),[E,G]=i.useState(""),[C,I]=i.useState(""),[ce,de]=i.useState(!1),[xe,D]=i.useState(null),pe=i.useRef(null),ue=i.useRef(null),[p,K]=i.useState(null),[me,he]=i.useState([]),[ge,Le]=i.useState(0),[L,ve]=i.useState([]),[H,be]=i.useState({}),[fe,M]=i.useState({}),[ye,He]=i.useState({}),[j,h]=i.useState(null),[je,Me]=i.useState({}),[S,Ne]=i.useState(""),[Ae,Fe]=i.useState([]),[d,We]=i.useState(null),[we,Ee]=i.useState(!1),[Ce,De]=i.useState([]),[Se,Qe]=i.useState({}),[W,ke]=i.useState({}),[_e,Ue]=i.useState({}),[k,g]=i.useState(null),[$e,Be]=i.useState(!1),Pe=()=>Promise.all([n.get("/v1/agent/admin/auditor/findings?status=pending").then(e=>{m(e.findings||[]),Ke(e.by_category||{})}).catch(()=>m([])),n.get("/v1/agent/admin/auditor/runs").then(e=>z(e.runs||[])).catch(()=>z([]))]),_=()=>Promise.all([n.get("/v1/agent/admin/corrections/candidates").then(e=>le(e.candidates||[])).catch(()=>le([])),n.get("/v1/agent/admin/corrections").then(e=>oe(e.corrections||[])).catch(()=>oe([]))]),Q=()=>Promise.all([n.get("/v1/agent/admin/auditor/settings").then(e=>K(e.auto_correct)).catch(()=>K(null)),n.get("/v1/agent/admin/auditor/auto-corrections").then(e=>{he(e.items||[]),Le(e.total_active||0)}).catch(()=>he([]))]),Re=async e=>{try{const s=await n.post("/v1/agent/admin/auditor/settings",e);K(s.auto_correct)}catch(s){r(s instanceof Error?s.message:"Save failed")}},Ve=async e=>{confirm("Revert this auto-applied correction? The agent stops using it from its next message.")&&(await n.delete(`/v1/agent/admin/corrections/${e}`),Q())},N=()=>n.get("/v1/agent/admin/policies").then(e=>{const s=e.items||[];ve(s),be(Object.fromEntries(s.map(a=>[a.id,a.authoritative||a.text||""]))),M(Object.fromEntries(s.map(a=>[a.id,a.text||""])))}).catch(()=>ve([])),Ye=async e=>{const s=(H[e]||"").trim();if(s){h(e);try{const a=await n.post("/v1/agent/admin/policies/translate",{text:s});M(l=>({...l,[e]:a.agent_safe||""})),He(l=>({...l,[e]:a.stripped||""})),a.ok||r("Translation came back empty — review the customer-facing line before saving.")}catch(a){r(a instanceof Error?a.message:"Translate failed")}finally{h(null)}}},Ze=async e=>{h(e);try{await n.patch(`/v1/agent/admin/policies/${e}`,{text:H[e]||"",agent_safe:fe[e]||""}),r("Policy saved — Amico uses the customer-facing line from its next message."),N()}
1catch(s){r(s instanceof Error?s.message:"Save failed")}finally{h(null)}},ze=async e=>{confirm("Remove this store policy? The agent + auditor stop using it.")&&(await n.delete(`/v1/agent/admin/corrections/${e}`),N())},Te=async()=>{if(S.trim()){h("new");try{const e=await n.post("/v1/agent/admin/policies",{text:S.trim()});Ne(""),r(`Policy added — Amico got a customer-safe version${e.stripped?` (kept internal: ${e.stripped})`:""}.`),N()}catch(e){r(e instanceof Error?e.message:"Add failed")}finally{h(null)}}},Je=async e=>{const s=(je[e.id]??String(e.suggested_fix?.policy_point||e.title||"")).trim();if(s)try{await n.post(`/v1/agent/admin/auditor/findings/${e.id}/approve-policy`,{text:s}),m(a=>a.filter(l=>l.id!==e.id)),N(),r("Policy approved — added to your store policies; the agent now follows it.")}catch(a){r(a instanceof Error?a.message:"Approve failed")}},v=()=>Promise.all([n.get("/v1/agent/admin/knowledge/gaps?status=verified&limit=200"),n.get("/v1/agent/admin/knowledge/gaps?status=filled&limit=5")]).then(([e,s])=>{De([...e.gaps||[],...s.gaps||[]]),Qe(e.counts||{})}).catch(()=>De([])),Xe=async()=>{Be(!0),r(null);try{const e=await n.post("/v1/agent/admin/knowledge/gaps/surface",{});r(`Gap scan complete — ${e.surface?.created??0} new, ${e.verify?.verified??0} verified as real.`),v()}catch(e){r(e instanceof Error?e.message:"Scan failed")}finally{Be(!1)}},et=async e=>{const s=(W[e.id]||"").trim();if(s){g(e.id);try{const a=await n.post(`/v1/agent/admin/knowledge/gaps/${e.id}/fill`,{text:s,sku:(_e[e.id]||"").trim()||void 0});r(`Knowledge added → ${a.placement?.where||"KB"} (${a.placement?.chunks??0} chunks). The agent uses it from its next message.`),ke(l=>{const c={...l};return delete c[e.id],c}),v()}catch(a){r(a instanceof Error?a.message:"Fill failed")}finally{g(null)}}},tt=async e=>{if(confirm("Dismiss this knowledge gap? (Not a real gap / won't fill.)")){g(e.id);try{await n.post(`/v1/agent/admin/knowledge/gaps/${e.id}/dismiss`,{}),v()}catch(s){r(s instanceof Error?s.message:"Dismiss failed")}finally{g(null)}}},st=async e=>{if(confirm("Undo this filled answer? It is removed from the agent and the gap reopens for a corrected answer.")){g(e.id);try{await n.post(`/v1/agent/admin/knowledge/gaps/${e.id}/revert`,{}),r("Reverted — removed from the agent; the gap is back in the fill queue."),v()}catch(s){r(s instanceof Error?s.message:"Revert failed")}finally{g(null)}}},U=()=>n.get("/v1/agent/admin/hot-cache").then(e=>{Fe(e.items||[]),We(e.stats||null)}).catch(()=>Fe([])),at=async()=>{Ee(!0),r(null);try{const e=await n.post("/v1/agent/admin/hot-cache/rebuild",{});r(`Hot cache rebuilt — ${e.built??0} cached, ${e.archived??0} retired.`),U()}catch(e){r(e instanceof Error?e.message:"Rebuild failed")}finally{Ee(!1)}},it=()=>{X(!0),Promise.all([Pe(),_(),Q(),N(),v(),U()]).finally(()=>X(!1))};i.useEffect(it,[]);const nt=async()=>{te(!0),r(null);try{const e=await n.post("/v1/agent/admin/auditor/run",{});r(`Audit complete — reviewed ${e.conversations_reviewed??"?"} conversations, ${e.findings} findings${e.auto_applied?`, ${e.auto_applied} auto-applied ✓`:""}.`),Pe(),Q(),v(),U()}catch(e){r(e instanceof Error?e.message:"Audit failed")}finally{te(!1)}},V=async(e,s)=>{se(e);try{await n.post(`/v1/agent/admin/auditor/findings/${e}/${s}`,{}),m(a=>a.filter(l=>l.id!==e)),ie===e&&R(null),s==="accept"&&_()}catch(a){r(a instanceof Error?a.message:"Action failed")}finally{se(null)}},rt=e=>{R(s=>s===e?null:e),T("")},qe=async e=>{if(w.trim()){re(!0);try{const s=await n.post(`/v1/agent/admin/auditor/findings/${e}/discuss`,{message:w.trim()});T(""),s.withdraw?(m(a=>a.filter(l=>l.id!==e)),R(null),r("Auditor withdrew this finding after your input.")):s.finding&&m(a=>a.map(l=>l.id===e?s.finding:l))}catch(s){r(s instanceof Error?s.message:"Discuss failed")}finally{re(!1)}}},lt=e=>{G(e.question),I(""),D(null),pe.current?.scrollIntoView({behavior:"smooth",block:"start"}),setTimeout(()=>ue.current?.focus(),350)},ot=async()=>{if(!(!E.trim()||!C.trim())){de(!0),D(null);try{await n.post("/v1/agent/admin/corrections",{question:E,answer:C}),G(""),I(""),D("Saved ✓ — the agent uses this from its next message."),_()}catch(e){D(e instanceof Error?e.message:"Save failed")}finally{de(!1)}}},ct=async e=>{confirm("Remove this correction? The agent will stop using it.")&&(await n.delete(`/v1/agent/admin/corrections/${e}`),_())},b=Ie[0],f=Z.filter(e=>e.category==="policy_review"),$=Z.filter(e=>e.category!=="policy_review"),y=Ce.filter(e=>e.status==="verified"),Oe=Ce.filter(e=>e.status==="filled").slice(0,5);return t.jsxs("div",{className:"text-[#181B24]",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3 mb-4",children:[t.jsx("p",{className:"text-[12.5px] text-[#59616F] max-w-2xl",children:"A daily Opus review of real conversations. It judges our agent's answers against the verified facts it had, and learns tone & selling style from Zipchat history (facts never taken from Zipchat). Discuss a finding to refine it, then Accept to send the agreed fix to the agent — or add your own correction below."}),t.jsx("button",{onClick:nt,disabled:ee,className:"flex-shrink-0 bg-[#4338CA] text-white text-[12.5px] rounded-[8px] px-4 py-2 hover:opacity-90 disabled:opacity-50",children:ee?"Auditing…":"Run audit now"})]}),t.jsxs(xt,{children:[t.jsx(A,{label:"Pending findings",value:$.length,sub:"awaiting review",tone:$.length?"warn":"good"}),t.jsx(A,{label:"Policy flags",value:f.length,sub:"your call",tone:f.length?"warn":"default"}),t.jsx(A,{label:"Gaps to fill",value:y.length,sub:"verified real",tone
1:y.length?"info":"default"}),t.jsx(A,{label:"Auto-corrections",value:ge,sub:"active",tone:"accent"}),t.jsx(A,{label:"Hot answers",value:d?.active??0,sub:"cached",tone:"default"})]}),ae&&t.jsx("div",{className:"mb-4 text-[12px] bg-[#F6F7F9] border border-[#E5E8ED] rounded-[8px] px-3 py-2 text-[#59616F]",children:ae}),t.jsxs(u,{title:"Auto-correction",className:"mb-4",right:t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[t.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full border ${p?.enabled?"bg-[#ECFDF5] text-[#0E9F6E] border-[#A7F3D0]":"bg-[#EEF0F4] text-[#8A93A2] border-[#E5E8ED]"}`,children:p?.enabled?"ON":"OFF"}),t.jsxs("select",{value:p?.min_severity||"medium",onChange:e=>Re({min_severity:e.target.value}),title:"Minimum severity to auto-apply",className:"text-[11px] border border-[#E5E8ED] rounded-[6px] px-2 py-1 text-[#181B24]",children:[t.jsx("option",{value:"high",children:"high+"}),t.jsx("option",{value:"medium",children:"medium+"}),t.jsx("option",{value:"low",children:"low+"})]}),t.jsx("button",{onClick:()=>Re({enabled:!p?.enabled}),className:p?.enabled?o.dark:o.good,children:p?.enabled?"Turn OFF":"Turn ON"})]}),children:[t.jsxs("p",{className:"text-[12px] text-[#8A93A2] max-w-xl",children:["When ON, the auditor applies eligible findings automatically after each run — facts & behaviour rules at ",t.jsxs("b",{className:"text-[#59616F]",children:[p?.min_severity||"medium","+"]})," severity, up to ",t.jsx("b",{className:"text-[#59616F]",children:p?.daily_cap??10})," per run. Everything lands below and is fully reversible."]}),t.jsxs("div",{className:"mt-3 border-t border-[#EEF0F4] pt-3",children:[t.jsxs("div",{className:"text-[11px] font-semibold text-[#59616F] mb-2",children:["Auto-applied corrections (",ge," active)"]}),me.length===0&&t.jsx("div",{className:"text-[11px] text-[#8A93A2]",children:"Nothing auto-applied yet — eligible findings apply on the next audit run."}),t.jsx("div",{className:"space-y-1.5 max-h-72 overflow-auto",children:me.map(e=>t.jsxs("div",{className:`text-[11px] rounded-[8px] px-3 py-2 border flex items-start justify-between gap-2 ${e.status==="active"?"bg-[#ECFDF5]/40 border-[#A7F3D0]":"bg-[#F6F7F9] border-[#E5E8ED] opacity-60"}`,children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:`text-[9px] font-bold uppercase mr-1.5 ${e.type==="fact"?"text-[#DC2626]":"text-[#4338CA]"}`,children:e.type==="fact"?"fact":"rule"}),t.jsx("span",{className:"text-[#181B24] font-medium",children:e.question}),t.jsx("div",{className:"text-[#59616F] truncate",children:e.answer}),t.jsxs("div",{className:"text-[10px] text-[#8A93A2]",children:[e.created_at?new Date(e.created_at).toLocaleString():"",e.status!=="active"&&" · reverted"]})]}),e.status==="active"&&t.jsx("button",{onClick:()=>Ve(e.id),className:"text-[10px] text-[#8A93A2] hover:text-[#DC2626] flex-shrink-0",children:"Revert"})]},e.id))})]})]}),t.jsxs(u,{title:"Store Policies — your call",icon:"🔒",className:"mb-4 !border-[#FDE68A]",right:f.length>0?t.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full border bg-[#FFFBEB] text-[#B45309] border-[#FDE68A]",children:[f.length," flagged for review"]}):void 0,children:[t.jsxs("p",{className:"text-[12px] text-[#8A93A2] max-w-2xl",children:["Anything about returns/cancellation, warranty, COD, shipping charges, refunds, payment, pickup, price or stock is ",t.jsx("b",{className:"text-[#59616F]",children:"never auto-corrected"})," — the auditor flags it here for you. Approved policies guide the live agent."]}),f.length>0&&t.jsx("div",{className:"mt-3 space-y-2",children:f.map(e=>t.jsxs("div",{className:"border border-[#FDE68A] bg-[#FFFBEB]/40 rounded-[8px] p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-1",children:[t.jsx("span",{className:`text-[10px] font-bold uppercase ${Ge[e.severity]||"text-[#8A93A2]"}`,children:e.severity}),t.jsx("span",{className:"text-[10px] text-[#8A93A2] uppercase",children:e.source}),e.session_ref&&t.jsxs(B,{to:`/console/cs/conversations/${e.session_ref}`,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] font-mono text-[#4338CA] hover:underline",children:["💬 ",e.session_ref," ↗"]})]}),t.jsx("div",{className:"text-[13px] font-medium text-[#181B24]",children:e.title}),e.detail&&t.jsx("div",{className:"text-[12px] text-[#59616F] mt-1 whitespace-pre-wrap",children:e.detail}),e.evidence?.quote&&t.jsxs("div",{className:"text-[11px] text-[#8A93A2] mt-1 border-l-2 border-[#
1E5E8ED] pl-2 italic",children:['"',e.evidence.quote,'"']}),t.jsx("label",{className:"block text-[11px] font-semibold text-[#59616F] mt-2",children:"Your real policy (edit, then approve) — Amico gets an auto-translated customer-safe version:"}),t.jsx("textarea",{value:je[e.id]??String(e.suggested_fix?.policy_point||e.title||""),onChange:s=>Me(a=>({...a,[e.id]:s.target.value})),rows:2,className:`w-full mt-1 ${x}`}),t.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[t.jsx("button",{onClick:()=>Je(e),className:o.good,children:"Approve to policies"}),t.jsx("button",{onClick:()=>V(e.id,"reject"),className:o.ghost,children:"Dismiss"})]})]},e.id))}),t.jsxs("div",{className:"mt-3 border-t border-[#EEF0F4] pt-3",children:[t.jsxs("div",{className:"text-[11px] font-semibold text-[#59616F]",children:["Your store policies (",L.length,") — two layers"]}),t.jsxs("p",{className:"text-[11px] text-[#8A93A2] mb-2",children:["Write the ",t.jsx("b",{className:"text-[#59616F]",children:"real policy"}),` (with any 
1internal notes — e.g. "we allow a quiet grace period but don't advertise it"). Amico never repeats that verbatim: the auditor translates it into a `,t.jsx("b",{className:"text-[#59616F]",children:"customer-safe line"})," that's the only thing the agent sees."]}),t.jsxs("div",{className:"space-y-3",children:[L.map(e=>t.jsxs("div",{className:"border border-[#EEF0F4] rounded-[8px] p-2.5 bg-[#F6F7F9]/40",children:[t.jsx("label",{className:"block text-[10px] font-semibold text-[#59616F]",children:"Real policy (internal — Amico won't repeat this verbatim)"}),t.jsx("textarea",{value:H[e.id]??(e.authoritative||e.text),onChange:s=>be(a=>({...a,[e.id]:s.target.value})),rows:2,className:`w-full mt-0.5 text-[11px] ${x}`}),t.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[t.jsx("label",{className:"block text-[10px] font-semibold text-[#0E9F6E]",children:"What Amico tells customers (auto-translated — edit if needed)"}),t.jsx("button",{onClick:()=>Ye(e.id),disabled:j===e.id,className:"text-[10px] text-[#2563EB] hover:underline disabled:opacity-50",children:"↻ Re-translate"})]}),t.jsx("textarea",{value:fe[e.id]??e.text,onChange:s=>M(a=>({...a,[e.id]:s.target.value})),rows:2,className:`w-full mt-0.5 text-[11px] !border-[#A7F3D0] bg-white ${x}`}),ye[e.id]&&t.jsxs("div",{className:"text-[10px] text-[#B45309] mt-1",children:["Kept internal: ",ye[e.id]]}),t.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[t.jsx("button",{onClick:()=>Ze(e.id),disabled:j===e.id,className:o.accent,children:j===e.id?"Saving…":"Save"}),t.jsx("button",{onClick:()=>ze(e.id),className:"text-[10px] text-[#8A93A2] hover:text-[#DC2626]",children:"Remove"})]})]},e.id)),L.length===0&&t.jsx("div",{className:"text-[11px] text-[#8A93A2]",children:"No policies set yet — approve a flagged item above, or add one below."})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[t.jsx("input",{value:S,onChange:e=>Ne(e.target.value),placeholder:"Add a policy (your real version) — Amico gets a customer-safe translation",className:`flex-1 text-[11px] ${x}`,onKeyDown:e=>{e.key==="Enter"&&Te()}}),t.jsx("button",{onClick:Te,disabled:!S.trim()||j==="new",className:o.dark,children:j==="new"?"Adding…":"Add"})]})]})]}),t.jsxs(u,{title:"Knowledge Gaps — fill these",icon:"📚",className:"mb-4 !border-[#BAE6FD]",right:t.jsxs("div",{className:"flex items-center gap-2",children:[y.length>0&&t.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full border bg-[#F0F9FF] text-[#0369A1] border-[#BAE6FD]",children:[y.length," to fill"]}),t.jsx("button",{onClick:Xe,disabled:$e,className:o.info,children:$e?"Scanning…":"Scan for gaps"})]}),children:[t.jsxs("p",{className:"text-[12px] text-[#8A93A2] max-w-2xl",children:["The auditor surfaces things customers asked that the agent couldn't answer, then ",t.jsx("b",{className:"text-[#59616F]",children:"verifies the gap is real"})," (the answer truly isn't in its knowledge). Paste the answer and it's placed into the agent's knowledge bank — product questions go to that product's manual, general ones to company KB."]}),y.length>0?t.jsx("div",{className:"mt-3 space-y-2",children:y.map(e=>t.jsxs("div",{className:"border border-[#BAE6FD] bg-[#F0F9FF]/40 rounded-[8px] p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-1",children:[e.topic&&t.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full border bg-[#F0F9FF] text-[#0369A1] border-[#BAE6FD]",children:e.topic}),(e.hits??1)>1&&t.jsxs("span",{className:"text-[10px] text-[#B45309] font-semibold",children:["asked ",e.hits,"×"]}),e.session_ref&&t.jsxs(B,{to:`/console/cs/conversations/${e.session_ref}`,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] font-mono text-[#4338CA] hover:underline",children:["💬 ",e.session_ref," ↗"]})]}),t.jsx("div",{className:"text-[13px] font-medium text-[#181B24]",children:e.question}),e.verification?.reason&&t.jsxs("div",{className:"text-[11px] text-[#8A93A2] mt-0.5",children:["Why it's a real gap: ",e.verification.reason]}),e.verification?.answerable_fact&&t.jsxs("div",{className:"text-[11px] text-[#8A93A2] mt-0.5",children:["Needs: ",e.verification.answerable_fact]}),t.jsx("textarea",{value:W[e.id]||"",onChange:s=>ke(a=>({...a,[e.id]:s.target.value})),rows:2,placeholder:"Type or paste the answer the agent should give…",className:`w-full mt-2 ${x}`}),t.jsxs("div",{className:"flex items-center gap-2 mt-1.5 flex-wrap",children:[t.jsx("input",{value:_e[e.id]||"",onChange:s=>Ue(a=>({...a,[e.id]:s.target.value})),placeholder:"Product SKU (optional — for a product-specific answer)",className:`flex-1 min-w-[200px] text-[11px] ${x}`}),t.jsx("button",{onClick:()=>et(e),disabled:k===e.id||!(W[e.id]||"").trim(),className:o.good,children:k===e.id?"Saving…":"Fill & teach agent"}),t.jsx("button",{onClick:()=>tt(e),disabled:k===e.id,className:o.ghost,children:"Dismiss"})]})]},e.id))}):t.jsxs("div",{className:"mt-3 text-[11px] text-[#8A93A2]",children:["No verified gaps right now",Se.candidate?` · ${Se.candidate} checking…`:"",". The auditor adds them as customers hit things the agent can't answer."]}
1),Oe.length>0&&t.jsxs("div",{className:"mt-3 border-t border-[#EEF0F4] pt-2",children:[t.jsx("div",{className:"text-[10px] font-semibold text-[#8A93A2] uppercase mb-1",children:"Recently filled"}),Oe.map(e=>t.jsxs("div",{className:"text-[11px] text-[#59616F] flex items-center gap-2",children:[t.jsx("span",{className:"text-[#0E9F6E]",children:"✓"}),t.jsx("span",{className:"truncate",children:e.question}),t.jsxs("span",{className:"text-[#c9cdd6] flex-shrink-0",children:["→ ",e.placement?.where||"KB"]}),t.jsx("button",{onClick:()=>st(e),disabled:k===e.id,className:"ml-auto flex-shrink-0 text-[10px] text-[#8A93A2] hover:text-[#DC2626] disabled:opacity-50",children:"Revert"})]},e.id))]})]}),t.jsxs(u,{title:"Hot Answers — voice / first-line fast path",icon:"⚡",className:"mb-4 !border-[#E9D5FF]",right:t.jsxs("div",{className:"flex items-center gap-2",children:[d&&t.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full border bg-[#FAF5FF] text-[#7C3AED] border-[#E9D5FF]",children:[d.active," cached"]}),t.jsx("button",{onClick:at,disabled:we,className:o.violet,children:we?"Rebuilding…":"Rebuild cache"})]}),children:[t.jsxs("p",{className:"text-[12px] text-[#8A93A2] max-w-2xl",children:["The auditor distills your most common, stable, customer-safe answers into a tiny cache that returns instantly with ",t.jsx("b",{className:"text-[#59616F]",children:"no AI call"})," — the latency lever for voice. A voice front-end checks this first; on a miss it falls through to the full agent."]}),d&&d.active>0&&t.jsxs("div",{className:"flex flex-wrap gap-2 mt-2 text-[10px]",children:[Object.entries(d.by_source||{}).map(([e,s])=>t.jsxs("span",{className:"px-2 py-0.5 rounded-full border bg-[#F6F7F9] text-[#59616F] border-[#E5E8ED] tabular-nums",children:[e,": ",s]},e)),t.jsxs("span",{className:"px-2 py-0.5 rounded-full border bg-[#ECFDF5] text-[#0E9F6E] border-[#A7F3D0] tabular-nums",children:["🔊 voice-safe: ",d.voice_safe??0]}),d.last_built_at&&t.jsxs("span",{className:"text-[#8A93A2]",children:["built ",new Date(d.last_built_at).toLocaleString()]})]}),Ae.length>0?t.jsx("div",{className:"mt-3 space-y-1.5 max-h-72 overflow-auto",children:Ae.map(e=>t.jsxs("div",{className:"border border-[#EEF0F4] rounded-[8px] px-3 py-2",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("span",{className:"text-[11px] font-medium text-[#181B24]",children:e.question}),e.source&&t.jsx("span",{className:"text-[9px] uppercase text-[#8A93A2]",children:e.source}),e.voice_safe?t.jsx("span",{className:"text-[9px] text-[#0E9F6E]",children:"🔊 voice"}):t.jsx("span",{className:"text-[9px] text-[#8A93A2]",children:"text-only"})]}),e.voice_answer&&t.jsxs("div",{className:"text-[11px] text-[#8A93A2] mt-0.5",children:["“",e.voice_answer,"”"]})]},e.id))}):t.jsx("div",{className:"mt-3 text-[11px] text-[#8A93A2]",children:"Cache is empty — click Rebuild, or it fills automatically after the next audit."})]}),t.jsxs(u,{title:"Audit findings",className:"mb-4",right:b?t.jsxs("span",{className:"text-[11px] text-[#8A93A2] tabular-nums",children:["Last run: ",b.finished_at?new Date(b.finished_at).toLocaleString():"running…"," ·"," ",b.conversations_reviewed??0," conversations · ",b.findings_count??0," findings · ",b.model||"—"]}):void 0,children:[Object.keys(J).length>0&&t.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:Object.entries(J).map(([e,s])=>t.jsxs("span",{className:`text-[11px] px-2 py-0.5 rounded-full border tabular-nums ${Y[e]?.color||"bg-[#EEF0F4] text-[#59616F] border-[#E5E8ED]"}`,children:[Y[e]?.label||e,": ",s]},e))}),F&&t.jsx("div",{className:"text-[#8A93A2] text-[13px]",children:"Loading…"}),!F&&$.length===0&&t.jsx("div",{className:"text-[13px] text-[#8A93A2] border border-[#EEF0F4] rounded-[8px] p-8 text-center",children:"No pending findings. Run an audit to analyze recent conversations."}),t.jsx("div",{className:"space-y-3",children:$.map(e=>{const s=Y[e.category]||{label:e.category,color:"bg-[#EEF0F4] text-[#59616F] border-[#E5E8ED]"},a=ie===e.id,l=e.suggested_fix||{};
1return t.jsxs("div",{className:"border border-[#E5E8ED] rounded-[8px] p-3.5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-1",children:[t.jsx("span",{className:`text-[10px] font-semibold px-2 py-0.5 rounded-full border ${s.color}`,children:s.label}),t.jsx("span",{className:`text-[10px] font-bold uppercase ${Ge[e.severity]||"text-[#8A93A2]"}`,children:e.severity}),t.jsx("span",{className:"text-[10px] text-[#8A93A2] uppercase",children:e.source}),(e.frequency||1)>1&&t.jsxs("span",{className:"text-[10px] text-[#59616F] tabular-nums",children:["×",e.frequency," convos"]}),e.revised&&t.jsx("span",{className:"text-[10px] text-[#7C3AED] bg-[#FAF5FF] border border-[#E9D5FF] rounded-full px-1.5",children:"revised"}),e.session_ref&&t.jsxs(B,{to:`/console/cs/conversations/${e.session_ref}`,target:"_blank",rel:"noopener noreferrer",title:"Open this conversation in a new tab",className:"text-[10px] font-mono text-[#4338CA] hover:underline inline-flex items-center gap-0.5 truncate max-w-[220px]",children:["💬 ",e.session_ref,t.jsx("span",{className:"not-italic",children:" ↗"})]})]}),t.jsx("div",{className:"text-[13px] font-medium text-[#181B24]",children:e.title}),e.detail&&t.jsx("div",{className:"text-[12px] text-[#59616F] mt-1",children:e.detail}),e.evidence?.quote&&t.jsxs("div",{className:"text-[11px] text-[#8A93A2] mt-2 border-l-2 border-[#E5E8ED] pl-2 italic",children:['"',e.evidence.quote,'"']}),e.category==="fact_correction"&&l.answer&&t.jsxs("div",{className:"text-[11px] text-[#0E9F6E] bg-[#ECFDF5] border border-[#A7F3D0] rounded-[6px] px-2 py-1 mt-2",children:["Accept → saves correction: ",t.jsx("b",{children:"Q:"})," ",String(l.question||e.title)," · ",t.jsx("b",{children:"A:"})," ",String(l.answer)]}),e.category==="behavioral_rule"&&t.jsxs("div",{className:"text-[11px] text-[#4338CA] bg-[#EEF2FF] border border-[#C7D2FE] rounded-[6px] px-2 py-1 mt-2",children:["Accept → adds agent rule: ",String(l.rule||e.title)]})]}),t.jsxs("div",{className:"flex flex-col gap-1.5 flex-shrink-0",children:[t.jsx("button",{onClick:()=>V(e.id,"accept"),disabled:P===e.id,className:o.good,children:"Accept"}),t.jsxs("button",{onClick:()=>rt(e.id),disabled:P===e.id,className:`text-[11px] rounded-[7px] px-3 py-1.5 border disabled:opacity-50 ${a?"bg-[#7C3AED] text-white border-[#7C3AED]":"bg-white border-[#E9D5FF] text-[#7C3AED] hover:bg-[#FAF5FF]"}`,children:[a?"Close":"Discuss",e.discussion?.length?` (${Math.floor(e.discussion.length/2)||1})`:""]}),t.jsx("button",{onClick:()=>V(e.id,"reject"),disabled:P===e.id,className:o.ghost,children:"Reject"})]})]}),a&&t.jsxs("div",{className:"mt-3 border-t border-[#EEF0F4] pt-3",children:[(e.discussion||[]).length>0&&t.jsx("div",{className:"space-y-2 mb-3",children:(e.discussion||[]).map((c,dt)=>t.jsxs("div",{className:`text-[11px] rounded-[8px] px-3 py-2 ${c.role==="user"?"bg-[#F6F7F9] border border-[#E5E8ED] text-[#59616F]":"bg-[#FAF5FF] border border-[#E9D5FF] text-[#5B21B6]"}`,children:[t.jsxs("span",{className:"font-semibold mr-1",children:[c.role==="user"?"You":"Auditor",":"]}),c.text]},dt))}),t.jsxs("div",{className:"flex items-end gap-2",children:[t.jsx("textarea",{value:w,onChange:c=>T(c.target.value),rows:2,placeholder:"Push back, add context the auditor lacked, or ask it to reconsider…",className:`flex-1 ${x}`,onKeyDown:c=>{c.key==="Enter"&&(c.metaKey||c.ctrlKey)&&qe(e.id)}}),t.jsx("button",{onClick:()=>qe(e.id),disabled:ne||!w.trim(),className:o.violet,children:ne?"…":"Send"})]}),t.jsx("div",{className:"text-[10px] text-[#8A93A2] mt-1",children:"The auditor may revise or withdraw this finding. Accept then sends the refined fix to the agent. ⌘/Ctrl+Enter to send."})]})]},e.id)})})]}),t.jsxs("div",{className:"mt-8 pt-5 border-t border-[#E5E8ED]",children:[t.jsx("div",{className:"text-[15px] font-bold tracking-tight text-[#181B24]",children:"Corrections"}),t.jsx("p",{className:"text-[12.5px] text-[#8A93A2] mt-1 mb-4",children:"Teach the agent directly. Save a question → answer and it uses your answer (as a verified answer) from the next message on. Accepted fact-corrections from the audit above also land here."}),t.jsx("div",{ref:pe,children:t.jsxs(u,{title:"Add a correction",className:"mb-4",children:[t.jsx("input",{value:E,onChange:e=>G(e.target.value),placeholder:"Customer question (e.g. Do you ship to Nepal?)",className:`w-full mb-2 ${x}`}),t.jsx("textarea",{ref:ue,value:C,onChange:e=>I(e.target.value),rows:3,placeholder:"The correct answer the agent should give",className:`w-full mb-2 ${x}`}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:ot,disabled:ce||!E.trim()||!C.trim(),className:"bg-[#4338CA] text-white text-[12.5px] rounded-[8px] px-4 py-2 hover:opacity-90 disabled:opacity-50",children:ce?"Saving…":"Save correction"}),xe&&t.jsx("span",{className:"text-[12px] text-[#59616F]",children:xe})]})]})}),t.jsxs(pt,{children:[t.jsxs(u,{title:`Needs attention (${q.length})`,children:[t.jsx("div",{className:"text-[12px] text-[#8A93A2] mb-3",children:"Conversations the agent escalated to a human."}),t.jsxs("div",{className:"space-y-2",children:[q.map((e,s)=>
1t.jsxs("div",{className:"border border-[#EEF0F4] rounded-[8px] p-3",children:[t.jsx("div",{className:"text-[12px] text-[#181B24]",children:e.question||t.jsx("span",{className:"text-[#8A93A2]",children:"(no question captured)"})}),e.reason&&t.jsxs("div",{className:"text-[11px] text-[#B45309] mt-1",children:["⚠ ",e.reason]}),t.jsxs("div",{className:"flex items-center gap-3 mt-1.5",children:[t.jsx("button",{onClick:()=>lt(e),className:"text-[11px] text-[#4338CA] hover:underline",children:"Write correction →"}),(e.session_uuid||e.session_id)&&t.jsx(B,{to:`/console/cs/conversations/${e.session_uuid||e.session_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-[11px] text-[#8A93A2] hover:text-[#4338CA] hover:underline",children:"💬 View chat ↗"})]})]},s)),!F&&q.length===0&&t.jsx("div",{className:"text-[12px] text-[#8A93A2]",children:"No escalations — the agent is handling everything. 🎉"})]})]}),t.jsxs(u,{title:`Saved corrections (${O.length})`,children:[t.jsx("div",{className:"text-[12px] text-[#8A93A2] mb-3",children:"The agent treats these as verified answers."}),t.jsxs("div",{className:"space-y-2",children:[O.map(e=>t.jsxs("div",{className:"border border-[#EEF0F4] rounded-[8px] p-3",children:[t.jsxs("div",{className:"text-[12px] font-medium text-[#181B24]",children:["Q: ",e.question]}),t.jsxs("div",{className:"text-[12px] text-[#59616F] mt-1",children:["A: ",e.answer]}),t.jsx("button",{onClick:()=>ct(e.id),className:"text-[11px] text-[#8A93A2] hover:text-[#DC2626] mt-1.5",children:"Remove"})]},e.id)),!F&&O.length===0&&t.jsx("div",{className:"text-[12px] text-[#8A93A2]",children:"No corrections yet."})]})]})]})]})]})}export{ht 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.