const n="/compass/".replace(/\/+$/,"");async function t(s,e){const r=await fetch(`${n}/api${s}`,{headers:{"Content-Type":"application/json",...e==null?void 0:e.headers},...e});if(!r.ok){const a=await r.text().catch(()=>"");throw new c(r.status,a)}return r.json()}class c extends Error{constructor(e,r){super(`API ${e}: ${r}`),this.status=e,this.body=r}}const o={overview:()=>t("/overview"),listAssistants:async()=>(await t("/assistants")).data??[],getAssistantConfig:s=>t(`/assistants/${s}/config`),setAssistantConfig:(s,e)=>t(`/assistants/${s}/config`,{method:"POST",body:JSON.stringify({values:e})}),listThreads:async(s=50)=>(await t(`/threads?limit=${s}`)).data??[],listMessages:async s=>(await t(`/threads/${s}/messages`)).data??[],listRuns:async s=>(await t(`/threads/${s}/runs`)).data??[],getRunConfig:(s,e)=>t(`/threads/${s}/runs/${e}/config`),listRunSteps:async(s,e)=>(await t(`/threads/${s}/runs/${e}/steps`)).data??[],compareRuns:s=>t(`/compare?run_ids=${s.join(",")}`),listTraces:async(s=50)=>(await t(`/traces?limit=${s}`)).traces??[],getRunTrace:async s=>(await t(`/traces/${s}`)).traces??[],getRunFlow:s=>t(`/runs/${s}/flow`)};function i(s){switch(s){case"completed":return"badge--success";case"in_progress":case"queued":return"badge--info";case"failed":case"cancelled":case"expired":return"badge--error";case"requires_action":return"badge--warning";default:return"badge--neutral"}}function u(s){return s?new Date(s*1e3).toLocaleString():"—"}function d(s){return s?s.length<=12?s:s.slice(0,6)+"…"+s.slice(-4):"—"}function f(s,e){if(!s||!e)return"—";const r=(e-s)*1e3;return r<1e3?`${Math.round(r)}ms`:`${(r/1e3).toFixed(1)}s`}export{i as a,o as c,f as d,u as f,d as s};
