import{d as y,e as S,c as a,a as t,t as o,b as w,y as p,h as u,F as k,k as C,r as _,o as r,u as b,n as x,g as D,_ as O}from"./index.js";import{c as R,s as E}from"./client.js";const M={class:"page-header"},N={class:"flex gap-2"},U={key:0,class:"badge badge--neutral"},$={key:0,class:"loading-center"},A={key:1,class:"card"},B={class:"empty-state"},I={style:{color:"var(--text-muted)","margin-top":"8px","font-size":"0.85rem"}},V={key:2,class:"card"},L={key:3,class:"traces-list"},z=["onClick"],F={class:"trace-row__name"},H={class:"trace-row__icon"},K={class:"trace-row__info"},j={class:"trace-row__label"},q={class:"trace-row__id mono"},Q={class:"trace-row__count"},W={class:"trace-row__count-badge"},G={class:"trace-row__duration mono"},J={class:"trace-row__status"},P=["title"],X=y({__name:"TracesView",setup(Y){const f=D(),l=_([]),v=_(!0),c=_("");S(async()=>{try{l.value=await R.listTraces(100)}catch(s){c.value=s.message}finally{v.value=!1}});function g(s){s.run_id&&f.push(`/traces/${s.run_id}`)}function m(s){return s?s<1?"<1ms":s<1e3?`${Math.round(s)}ms`:`${(s/1e3).toFixed(1)}s`:"—"}function T(s){return s.includes(".openai")||s.includes("chat ")?"AI":s.includes(".streaming")||s.includes(".stream")?"ST":s.includes(".data_store")?"DB":s.includes(".queue")?"Q":s.includes(".worker")?"W":s.includes(".run")?"R":s.includes(".thread")?"TH":s.includes(".message")?"M":"TR"}function h(s){if(!s)return"—";const e=Date.now()-new Date(s).getTime(),n=Math.floor(e/1e3);if(n<60)return`${n}s ago`;const i=Math.floor(n/60);if(i<60)return`${i}m ago`;const d=Math.floor(i/60);return d<24?`${d}h ago`:`${Math.floor(d/24)}d ago`}return(s,e)=>(r(),a("div",null,[t("div",M,[e[0]||(e[0]=t("div",null,[t("h1",null,"Traces"),t("div",{class:"page-header__subtitle"},"Click a trace to view all spans")],-1)),t("div",N,[l.value.length?(r(),a("span",U,o(l.value.length)+" traces",1)):w("",!0)])]),v.value?(r(),a("div",$,[...e[1]||(e[1]=[t("div",{class:"spinner"},null,-1)])])):c.value?(r(),a("div",A,[t("div",B,[e[9]||(e[9]=p('<div class="empty-state__icon" data-v-62692cd0><svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" data-v-62692cd0><circle cx="11" cy="11" r="8" data-v-62692cd0></circle><line x1="21" y1="21" x2="16.65" y2="16.65" data-v-62692cd0></line></svg></div><div class="empty-state__title" data-v-62692cd0>Traces unavailable</div>',2)),t("p",I,[u(o(c.value),1),e[2]||(e[2]=t("br",null,null,-1)),e[3]||(e[3]=t("br",null,null,-1)),e[4]||(e[4]=u(" Make sure ClickHouse and the OTel Collector are running.",-1)),e[5]||(e[5]=t("br",null,null,-1)),e[6]||(e[6]=u(" Set ",-1)),e[7]||(e[7]=t("code",{class:"mono"},"CLICKHOUSE_URL",-1)),e[8]||(e[8]=u(" in your environment. ",-1))])])])):l.value.length===0?(r(),a("div",V,[...e[10]||(e[10]=[p('<div class="empty-state" data-v-62692cd0><div class="empty-state__icon" data-v-62692cd0><svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" data-v-62692cd0><polyline points="22 12 18 12 15 21 9 3 6 12 2 12" data-v-62692cd0></polyline></svg></div><div class="empty-state__title" data-v-62692cd0>No traces yet</div><p style="color:var(--text-muted);margin-top:8px;font-size:0.85rem;" data-v-62692cd0> Run your agent with tracing enabled to see traces here. </p></div>',1)])])):(r(),a("div",L,[e[11]||(e[11]=t("div",{class:"traces-list__header"},[t("span",null,"Trace"),t("span",null,"Spans"),t("span",null,"Duration"),t("span",null,"Status"),t("span",null,"Time")],-1)),(r(!0),a(k,null,C(l.value,n=>{var i;return r(),a("div",{key:n.TraceId,class:"trace-row",onClick:d=>g(n)},[t("div",F,[t("span",H,o(T(n.SpanName)),1),t("div",K,[t("span",j,o(n.SpanName),1),t("span",q,o(b(E)(n.run_id)),1)])]),t("div",Q,[t("span",W,o(n.span_count||"—"),1)]),t("div",G,o(m(n.duration_ms)),1),t("div",J,[t("span",{class:x(["badge",{"badge--success":n.StatusCode==="STATUS_CODE_OK","badge--error":n.StatusCode==="STATUS_CODE_ERROR","badge--neutral":n.StatusCode!=="STATUS_CODE_OK"&&n.StatusCode!=="STATUS_CODE_ERROR"}])},o(((i=n.StatusCode)==null?void 0:i.replace("STATUS_CODE_",""))||"UNSET"),3)]),t("div",{class:"trace-row__time",title:new Date(n.Timestamp).toLocaleString()},o(h(n.Timestamp)),9,P)],8,z)}),128))]))]))}}),st=O(X,[["__scopeId","data-v-62692cd0"]]);export{st as default};
