llmxray 0.4.1 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +265 -265
  2. package/dist/assets/{AITrainingPage-VU-Nu5i0.js → AITrainingPage-DEU4UAR7.js} +1 -1
  3. package/dist/assets/AnalyticsPage-C7mNUAil.js +1 -0
  4. package/dist/assets/{BenchmarkPage-CQUTAU0c.js → BenchmarkPage-jiUqdHmg.js} +2 -2
  5. package/dist/assets/{ComparisonPage-DSO_-JZF.js → ComparisonPage-BoBWSObY.js} +3 -3
  6. package/dist/assets/CostDashboardPage-BKQDsZhx.js +1 -0
  7. package/dist/assets/{DashboardPage-lqAFJvOo.js → DashboardPage-CV8Ejgxv.js} +43 -43
  8. package/dist/assets/{EmbeddingsPage-DDBfFe8z.js → EmbeddingsPage-DXjVT4eU.js} +1 -1
  9. package/dist/assets/{GoogleCallbackPage-H8X6YDz9.js → GoogleCallbackPage-BUIkYpZv.js} +1 -1
  10. package/dist/assets/{JsonTreeNode-DQ_R5Euc.js → JsonTreeNode-C0UNUwZm.js} +1 -1
  11. package/dist/assets/{ModelCapabilityIcons.vue_vue_type_script_setup_true_lang-CV939MUZ.js → ModelCapabilityIcons.vue_vue_type_script_setup_true_lang-vQNvYFzV.js} +1 -1
  12. package/dist/assets/{RAGPage-DbZxWHmi.js → RAGPage-Dv4UDEyz.js} +1 -1
  13. package/dist/assets/SessionPage-B0fMQGSB.js +15 -0
  14. package/dist/assets/{SettingsPage-fmgr8zF9.js → SettingsPage-DTJP-4xU.js} +1 -1
  15. package/dist/assets/{StatusBadge.vue_vue_type_script_setup_true_lang-BbHpA7hy.js → StatusBadge.vue_vue_type_script_setup_true_lang-BiB0M6lv.js} +1 -1
  16. package/dist/assets/{StorageGauge.vue_vue_type_style_index_0_lang-Dd3BsCg6.js → StorageGauge.vue_vue_type_style_index_0_lang-DToi3R0q.js} +1 -1
  17. package/dist/assets/{SystemPage-Bd3SBsWI.js → SystemPage-BPK15qwe.js} +2 -2
  18. package/dist/assets/{TabBar.vue_vue_type_script_setup_true_lang-DlSEPHs6.js → TabBar.vue_vue_type_script_setup_true_lang-BtGCdMZK.js} +1 -1
  19. package/dist/assets/{TokenStreamDisplay.vue_vue_type_script_setup_true_lang-P-I0kJTd.js → TokenStreamDisplay.vue_vue_type_script_setup_true_lang-B6juPZsY.js} +1 -1
  20. package/dist/assets/{ToolWorkshopPage-D9doB8PF.js → ToolWorkshopPage-DmpoHHaD.js} +3 -3
  21. package/dist/assets/{agent-store-CuCtjbhV.js → agent-store-C6w1zV86.js} +1 -1
  22. package/dist/assets/{canvas-ai-db-DBUT-nyD.js → canvas-ai-db-BpqhUp6k.js} +1 -1
  23. package/dist/assets/{download-C3s6K1NW.js → download-pCIjWOn5.js} +1 -1
  24. package/dist/assets/{generate-service-DrRYe_-5.js → generate-service-DmtXqq_h.js} +1 -1
  25. package/dist/assets/{google-auth-store-B0WvuFWG.js → google-auth-store-Dgv2FihL.js} +1 -1
  26. package/dist/assets/index-534TcCbY.js +8 -0
  27. package/dist/assets/index-B72Sw9uL.css +1 -0
  28. package/dist/assets/{index-CUNpOQX9.js → index-ClITfJ3t.js} +1 -1
  29. package/dist/assets/{index-DoMyvAkM.js → index-DHuj6tKB.js} +1 -1
  30. package/dist/assets/{info-D-oZIv7P.js → info-Eg1tUw1x.js} +1 -1
  31. package/dist/assets/{metrics-store-DRErjO4D.js → metrics-store-7m97Sb7w.js} +1 -1
  32. package/dist/assets/{papaparse.min-DJzuA_ek.js → papaparse.min-3FeAYh4d.js} +1 -1
  33. package/dist/assets/{pencil-MO2uWQbW.js → pencil-CZp68oBU.js} +1 -1
  34. package/dist/assets/{rag-store-CBWvD3Va.js → rag-store-Bm0nxdec.js} +3 -3
  35. package/dist/assets/session-store-BQ0TF24S.js +1 -0
  36. package/dist/assets/{share-2-CnM5sBDm.js → share-2-CJJGZsZO.js} +1 -1
  37. package/dist/assets/{storage-store-cx_2Hb_J.js → storage-store-6qFwk_C5.js} +1 -1
  38. package/dist/assets/stream-handler-BM5egg14.js +4 -0
  39. package/dist/assets/{tool-workshop-store-Cb4eb3e4.js → tool-workshop-store-9_FKfdnT.js} +1 -1
  40. package/dist/assets/toolcall-store-C4Trr01T.js +1 -0
  41. package/dist/assets/{trash-2-Cj-NOsVZ.js → trash-2-DjfJXqVK.js} +1 -1
  42. package/dist/index.html +2 -2
  43. package/package.json +88 -88
  44. package/dist/assets/CostDashboardPage-BLzCE-bT.js +0 -1
  45. package/dist/assets/SessionPage-DvtFE4GS.js +0 -15
  46. package/dist/assets/index-Bawj8X2v.css +0 -1
  47. package/dist/assets/index-DYHBy1xj.js +0 -8
  48. package/dist/assets/stream-handler-CXdBM2li.js +0 -4
  49. package/dist/assets/toolcall-store-xQEQUq5f.js +0 -1
@@ -1 +1 @@
1
- import{d as ae,r as _,a as N,o as le,n as ne,b as U,e as n,g as K,f as e,j as a,B as oe,w as Q,t,i as T,l as H,V as ie,F as A,k as W,W as re,p as V,x as G,s as Z,h as P,y as ee,A as de,C as L,G as J,u as S,q as ce,D as X,Y as ue,v as te}from"./index-DYHBy1xj.js";import{c as I}from"./format-BqVZ9rwM.js";import{u as me}from"./storage-store-cx_2Hb_J.js";import{_ as ve}from"./StorageGauge.vue_vue_type_style_index_0_lang-Dd3BsCg6.js";import{_ as pe}from"./_plugin-vue_export-helper-DlAUqK2U.js";const fe=ae("embeddings",()=>{const y=_([]),i=_(!1),o=_(null),x=N(()=>[...y.value].sort((c,m)=>m.timestamp-c.timestamp));async function v(c,m){i.value=!0,o.value=null;const g=Date.now();try{const k=(await le.embed({model:c,input:m})).embeddings[0];if(!k)throw new Error("No embedding returned");const p={id:ne(),model:c,input:m,vector:k,dimensions:k.length,timestamp:Date.now(),durationMs:Date.now()-g};return y.value.push(p),p}catch(M){throw o.value=M instanceof Error?M.message:"Embedding failed",M}finally{i.value=!1}}function b(c,m){if(c.length!==m.length)return 0;let g=0,M=0,k=0;for(let d=0;d<c.length;d++)g+=c[d]*m[d],M+=c[d]*c[d],k+=m[d]*m[d];const p=Math.sqrt(M)*Math.sqrt(k);return p===0?0:g/p}function h(c,m){return{score:b(c.vector,m.vector),a:c,b:m}}function z(){y.value=[]}function B(c){y.value=y.value.filter(m=>m.id!==c)}return{results:y,recentResults:x,loading:i,error:o,embed:v,cosineSimilarity:b,comparePair:h,clearResults:z,removeResult:B}}),O=U({__name:"LoadingSpinner",props:{size:{}},setup(y){return(i,o)=>(a(),n("div",{class:K(["inline-block animate-spin rounded-full border-2 border-current border-t-transparent text-accent",{"h-4 w-4":y.size==="sm"||!y.size,"h-6 w-6":y.size==="md","h-8 w-8":y.size==="lg"}]),role:"status"},[...o[0]||(o[0]=[e("span",{class:"sr-only"},"Loading...",-1)])],2))}}),ge={class:"space-y-1"},xe={key:0,class:"text-xs text-text-muted"},be=["height"],he={class:"text-text-muted"},ye={class:"flex items-center justify-between text-[10px] text-text-muted"},Y=U({__name:"EmbeddingVectorViz",props:{vector:{},label:{},height:{}},setup(y){const i=y,o=_(null),x=_(null),v=_(null),b=N(()=>i.height??120);function h(){const c=o.value,m=x.value;if(!c||!m)return;const g=c.getContext("2d");if(!g)return;const M=i.vector,k=m.clientWidth,p=b.value,d=window.devicePixelRatio||1;c.width=k*d,c.height=p*d,c.style.width=`${k}px`,c.style.height=`${p}px`,g.scale(d,d),g.clearRect(0,0,k,p);const u=k/M.length,r=p/2;let f=0;for(const w of M)Math.abs(w)>f&&(f=Math.abs(w));f===0&&(f=1);for(let w=0;w<M.length;w++){const R=M[w],j=R/f,D=Math.abs(j)*(r-2),C=.3+Math.abs(j)*.7;R>=0?(g.fillStyle=`rgba(139, 92, 246, ${C})`,g.fillRect(w*u,r-D,Math.max(u,.5),D)):(g.fillStyle=`rgba(251, 146, 60, ${C})`,g.fillRect(w*u,r,Math.max(u,.5),D))}g.strokeStyle="rgba(100, 116, 139, 0.3)",g.lineWidth=1,g.beginPath(),g.moveTo(0,r),g.lineTo(k,r),g.stroke()}function z(c){const m=o.value;if(!m)return;const g=m.getBoundingClientRect(),M=c.clientX-g.left,k=g.width/i.vector.length,p=Math.floor(M/k);p>=0&&p<i.vector.length?v.value={index:p,value:i.vector[p],x:c.clientX-g.left,y:c.clientY-g.top}:v.value=null}function B(){v.value=null}return oe(h),Q(()=>i.vector,h),(c,m)=>(a(),n("div",ge,[y.label?(a(),n("div",xe,t(y.label),1)):T("",!0),e("div",{ref_key:"containerRef",ref:x,class:"relative overflow-hidden rounded-lg border border-border-default bg-surface"},[e("canvas",{ref_key:"canvasRef",ref:o,height:b.value,class:"w-full cursor-crosshair",onMousemove:z,onMouseleave:B},null,40,be),v.value?(a(),n("div",{key:0,class:"pointer-events-none absolute z-10 rounded border border-border-default bg-surface-raised px-2 py-1 text-[10px] shadow-lg",style:H({left:`${Math.min(v.value.x,(x.value?.clientWidth??200)-120)}px`,top:`${v.value.y-36}px`})},[e("span",he,"dim["+t(v.value.index)+"]",1),e("span",{class:K(["ms-1.5 font-mono",v.value.value>=0?"text-accent":"text-warning"])},t(v.value.value.toFixed(6)),3)],4)):T("",!0)],512),e("div",ye,[m[0]||(m[0]=ie('<div class="flex items-center gap-3"><span class="flex items-center gap-1"><span class="inline-block h-1.5 w-1.5 rounded-full bg-[rgb(139,92,246)]"></span> Positive </span><span class="flex items-center gap-1"><span class="inline-block h-1.5 w-1.5 rounded-full bg-[rgb(251,146,60)]"></span> Negative </span></div>',1)),e("span",null,"All "+t(y.vector.length)+" dimensions",1)])]))}}),_e={class:"grid grid-cols-4 gap-2 text-xs lg:grid-cols-8"},$e={class:"text-text-muted"},ke={class:"font-medium text-text-primary"},we={class:"pointer-events-none absolute bottom-full left-1/2 z-50 mb-2 -translate-x-1/2 opacity-0 transition-opacity group-hover:opacity-100"},Me={class:"w-52 rounded-lg border border-border-default bg-surface-raised px-3 py-2 text-[10px] leading-relaxed text-text-secondary shadow-lg"},Ce=U({__name:"EmbeddingStats",props:{result:{}},setup(y){const i=y,o=N(()=>{const v=i.result.vector;let b=1/0,h=-1/0,z=0,B=0,c=0;for(const p of v)p<b&&(b=p),p>h&&(h=p),z+=p,B+=p*p,Math.abs(p)<.001&&c++;const m=z/v.length,g=B/v.length-m*m,M=Math.sqrt(B),k=c/v.length*100;return{dimensions:v.length,min:b.toFixed(4),max:h.toFixed(4),mean:m.toFixed(4),stdDev:Math.sqrt(Math.max(0,g)).toFixed(4),l2Norm:M.toFixed(4),sparsity:k.toFixed(1),duration:I(i.result.durationMs),memoryBytes:v.length*8}}),x=N(()=>[{key:"dims",label:"Dims",value:o.value.dimensions,tooltip:"Number of dimensions in the embedding vector. Higher dimensions capture more semantic nuance but use more memory."},{key:"min",label:"Min",value:o.value.min,tooltip:"Smallest value across all dimensions. Shows the negative activation floor of the embedding space."},{key:"max",label:"Max",value:o.value.max,tooltip:"Largest value across all dimensions. Shows the positive activation ceiling of the embedding space."},{key:"mean",label:"Mean",value:o.value.mean,tooltip:"Average value across all dimensions. Near-zero means the vector is well-centered, which is typical for normalized embeddings."},{key:"stdDev",label:"Std Dev",value:o.value.stdDev,tooltip:"Standard deviation — measures how spread out the values are. Higher means more varied activations across dimensions."},{key:"l2Norm",label:"L2 Norm",value:o.value.l2Norm,tooltip:"Euclidean length of the vector. Normalized embeddings have L2 norm close to 1.0, making cosine similarity equivalent to dot product."},{key:"sparsity",label:"Sparsity",value:`${o.value.sparsity}%`,tooltip:"Percentage of dimensions with near-zero values (|v| < 0.001). High sparsity means the text activates only a subset of the semantic dimensions."},{key:"duration",label:"Time",value:o.value.duration,tooltip:"Time taken by the model to compute the embedding vector from the input text."}]);return(v,b)=>(a(),n("div",_e,[(a(!0),n(A,null,W(x.value,h=>(a(),n("div",{key:h.key,class:"group relative rounded-lg bg-surface p-2 cursor-help"},[e("div",$e,t(h.label),1),e("div",ke,t(h.value),1),e("div",we,[e("div",Me,t(h.tooltip),1),b[0]||(b[0]=e("div",{class:"mx-auto h-2 w-2 -translate-y-1 rotate-45 border-b border-e border-border-default bg-surface-raised"},null,-1))])]))),128))]))}}),Se={key:0,class:"relative overflow-hidden rounded-lg border border-border-default bg-surface p-4"},Re={class:"mb-3 flex items-center justify-between text-[10px] text-text-muted"},ze={key:0},Be={key:1},Te={key:2},Ae={key:3,class:"font-mono"},Ve={class:"relative h-24 flex items-center justify-center"},Fe={key:0,class:"absolute inset-0 flex flex-wrap items-center justify-center gap-1.5 px-4"},De={key:0,class:"absolute inset-0 flex items-center justify-center"},Ne={class:"flex items-end gap-px h-16"},Ee={class:"text-text-muted"},je={class:"mt-3 flex items-center justify-between"},Pe={class:"flex items-center gap-3 text-[10px] text-text-muted"},qe={key:0,class:"text-text-muted"},We={class:"flex items-center gap-2 text-[10px] text-text-muted shrink-0"},Le=U({__name:"EmbeddingTransformViz",props:{inputText:{},isEmbedding:{type:Boolean},vector:{}},setup(y){const i=y,o=_("idle"),x=_(0),v=_(null),b=_(null),h=_(null);let z=0,B=0;const c=N(()=>i.inputText.split(/\s+/).filter(Boolean).slice(0,20)),m=N(()=>{if(!i.vector)return null;let d=0,u=0;for(const w of i.vector)w>=0?d++:u++;const r=d/i.vector.length;let f;return r>.7?f="Mostly positive activations":r<.3?f="Mostly negative activations":f="Balanced activation spread",{positive:d,negative:u,character:f}});function g(){const d=b.value,u=h.value;if(!d||!u||!i.vector)return;const r=d.getContext("2d");if(!r)return;const f=i.vector,w=u.clientWidth,R=96,j=window.devicePixelRatio||1;d.width=w*j,d.height=R*j,d.style.width=`${w}px`,d.style.height=`${R}px`,r.scale(j,j),r.clearRect(0,0,w,R);const D=w/f.length,C=R/2;let q=0;for(const E of f)Math.abs(E)>q&&(q=Math.abs(E));q===0&&(q=1);for(let E=0;E<f.length;E++){const s=f[E],$=s/q,l=Math.abs($)*(C-2),F=.3+Math.abs($)*.7;s>=0?(r.fillStyle=`rgba(139, 92, 246, ${F})`,r.fillRect(E*D,C-l,Math.max(D,.5),l)):(r.fillStyle=`rgba(251, 146, 60, ${F})`,r.fillRect(E*D,C,Math.max(D,.5),l))}r.strokeStyle="rgba(100, 116, 139, 0.3)",r.lineWidth=1,r.beginPath(),r.moveTo(0,C),r.lineTo(w,C),r.stroke()}function M(d){const u=b.value;if(!u||!i.vector)return;const r=u.getBoundingClientRect(),f=d.clientX-r.left,w=r.width/i.vector.length,R=Math.floor(f/w);R>=0&&R<i.vector.length?v.value={index:R,value:i.vector[R],x:d.clientX-r.left,y:d.clientY-r.top}:v.value=null}function k(){v.value=null}function p(d){B||(B=d);const u=d-B;u<600?(o.value="decomposing",x.value=u/600):u<1200&&(o.value="transforming",x.value=(u-600)/600),i.isEmbedding&&(z=requestAnimationFrame(p))}return Q(()=>i.isEmbedding,d=>{d?(B=0,x.value=0,v.value=null,o.value="decomposing",z=requestAnimationFrame(p)):(cancelAnimationFrame(z),i.vector?(o.value="complete",x.value=1,ee(g)):(o.value="idle",x.value=0))}),Q(()=>i.vector,()=>{o.value==="complete"&&i.vector&&ee(g)}),re(()=>cancelAnimationFrame(z)),(d,u)=>o.value!=="idle"||y.vector?(a(),n("div",Se,[e("div",Re,[o.value==="decomposing"?(a(),n("span",ze,"Tokenizing text...")):o.value==="transforming"?(a(),n("span",Be,"Projecting into embedding space...")):o.value==="complete"&&m.value?(a(),n("span",Te,t(m.value.character),1)):T("",!0),y.vector?(a(),n("span",Ae,t(y.vector.length)+" dimensions · "+t(m.value?.positive)+" positive · "+t(m.value?.negative)+" negative ",1)):T("",!0)]),e("div",Ve,[V(G,{name:"fade"},{default:Z(()=>[o.value==="decomposing"||o.value==="idle"&&!y.vector?(a(),n("div",Fe,[(a(!0),n(A,null,W(c.value,(r,f)=>(a(),n("span",{key:f,class:"inline-block rounded bg-accent/10 px-1.5 py-0.5 font-mono text-xs text-accent transition-all duration-500",style:H({opacity:o.value==="decomposing"?Math.max(0,1-x.value*1.5+f*.1):1,transform:o.value==="decomposing"?`translateY(${x.value*20*(f%2===0?-1:1)}px) scale(${1-x.value*.3})`:"none"})},t(r),5))),128))])):T("",!0)]),_:1}),V(G,{name:"fade"},{default:Z(()=>[o.value==="transforming"?(a(),n("div",De,[e("div",Ne,[(a(),n(A,null,W(60,r=>e("div",{key:r,class:"w-1 rounded-full transition-all duration-300",style:H({height:`${Math.abs(Math.sin(r*.5+x.value*10))*x.value*100}%`,backgroundColor:Math.sin(r*.5+x.value*10)>=0?`rgba(139, 92, 246, ${.3+x.value*.5})`:`rgba(251, 146, 60, ${.3+x.value*.5})`,opacity:Math.min(1,x.value*2)})},null,4)),64))])])):T("",!0)]),_:1}),V(G,{name:"fade"},{default:Z(()=>[o.value==="complete"&&y.vector?(a(),n("div",{key:0,ref_key:"canvasContainerRef",ref:h,class:"absolute inset-0"},[e("canvas",{ref_key:"canvasRef",ref:b,class:"w-full h-full cursor-crosshair",onMousemove:M,onMouseleave:k},null,544),v.value?(a(),n("div",{key:0,class:"pointer-events-none absolute z-10 rounded border border-border-default bg-surface-raised px-2 py-1 text-[10px] shadow-lg",style:H({left:`${Math.min(v.value.x,(h.value?.clientWidth??200)-120)}px`,top:`${v.value.y-36}px`})},[e("span",Ee,"dim["+t(v.value.index)+"]",1),e("span",{class:K(["ms-1.5 font-mono",v.value.value>=0?"text-accent":"text-warning"])},t(v.value.value.toFixed(6)),3)],4)):T("",!0)],512)):T("",!0)]),_:1})]),e("div",je,[e("div",Pe,[u[0]||(u[0]=e("span",{class:"flex items-center gap-1"},[e("span",{class:"inline-block h-2 w-2 rounded-full bg-[rgb(139,92,246)]"}),P(" Positive activation ")],-1)),u[1]||(u[1]=e("span",{class:"flex items-center gap-1"},[e("span",{class:"inline-block h-2 w-2 rounded-full bg-[rgb(251,146,60)]"}),P(" Negative activation ")],-1)),o.value==="complete"?(a(),n("span",qe," · Each bar = one semantic dimension. Taller = stronger signal. ")):T("",!0)]),e("div",We,[u[2]||(u[2]=e("span",{class:"rounded bg-surface-overlay px-1.5 py-0.5"},"Text",-1)),u[3]||(u[3]=e("span",null,"→",-1)),u[4]||(u[4]=e("span",{class:"rounded bg-surface-overlay px-1.5 py-0.5"},"Tokens",-1)),u[5]||(u[5]=e("span",null,"→",-1)),e("span",{class:K(["rounded px-1.5 py-0.5",o.value==="complete"?"bg-accent/10 text-accent":"bg-surface-overlay"])}," Vector ",2)])])])):T("",!0)}}),Ie=pe(Le,[["__scopeId","data-v-07aa1650"]]),Ue={class:"flex flex-col items-center gap-2"},He={class:"relative h-32 w-32"},Xe={viewBox:"0 0 100 100",class:"h-full w-full -rotate-90"},Ye=["stroke","stroke-dasharray"],Ke={class:"absolute inset-0 flex flex-col items-center justify-center"},Ge={class:"text-2xl font-bold text-text-primary"},se=U({__name:"SimilarityMeter",props:{score:{}},setup(y){const i=y,o=N(()=>Math.round(i.score*100)),x=N(()=>i.score>=.8?"#4ade80":i.score>=.5?"#fbbf24":"#f87171"),v=N(()=>i.score>=.9?"Very Similar":i.score>=.7?"Similar":i.score>=.5?"Somewhat Similar":i.score>=.3?"Weakly Related":"Dissimilar");return(b,h)=>(a(),n("div",Ue,[e("div",He,[(a(),n("svg",Xe,[h[0]||(h[0]=e("circle",{cx:"50",cy:"50",r:"42",fill:"none",class:"stroke-surface-overlay","stroke-width":"8"},null,-1)),e("circle",{cx:"50",cy:"50",r:"42",fill:"none",stroke:x.value,"stroke-width":"8","stroke-linecap":"round","stroke-dasharray":`${o.value*2.64} 264`},null,8,Ye)])),e("div",Ke,[e("span",Ge,t(o.value)+"%",1)])]),e("span",{class:"text-sm font-medium",style:H({color:x.value})},t(v.value),5),h[1]||(h[1]=e("span",{class:"text-xs text-text-muted"},"Cosine Similarity",-1))]))}}),Ze={class:"space-y-8"},Je={class:"flex items-center gap-3"},Oe={key:0,value:"",disabled:""},Qe=["value"],et={key:0,class:"text-xs text-warning"},tt={class:"rounded-lg border border-border-default bg-surface-raised p-5 space-y-4"},st={class:"text-base font-semibold text-text-primary"},ot={class:"text-sm text-text-muted"},at=["placeholder","disabled","onKeydown"],lt={class:"flex items-center gap-3"},nt=["disabled"],it={key:0,class:"flex items-center gap-2"},rt={key:1},dt={key:0,class:"text-sm text-error"},ct={class:"text-xs"},ut={class:"cursor-pointer text-text-muted hover:text-text-secondary"},mt={class:"mt-2 grid grid-cols-5 gap-1 font-mono text-text-secondary"},vt=["title"],pt={class:"rounded-lg border border-border-default bg-surface-raised p-5 space-y-4"},ft={class:"text-base font-semibold text-text-primary"},gt={class:"text-sm text-text-muted"},xt={class:"grid grid-cols-1 gap-4 lg:grid-cols-2"},bt={class:"block text-xs font-medium text-text-muted mb-1"},ht=["placeholder","disabled"],yt={class:"block text-xs font-medium text-text-muted mb-1"},_t=["placeholder","disabled"],$t=["disabled"],kt={key:0,class:"flex items-center gap-2"},wt={key:1},Mt={key:0,class:"flex flex-col items-center gap-6 py-4 lg:flex-row lg:items-start lg:justify-center"},Ct={class:"flex-1 space-y-2"},St={class:"text-xs font-medium text-text-muted"},Rt={class:"rounded-lg bg-surface p-3 text-sm text-text-secondary"},zt={class:"flex-1 space-y-2"},Bt={class:"text-xs font-medium text-text-muted"},Tt={class:"rounded-lg bg-surface p-3 text-sm text-text-secondary"},At={class:"rounded-lg border border-border-default bg-surface-raised p-5 space-y-4"},Vt={class:"text-base font-semibold text-text-primary"},Ft={class:"text-sm text-text-muted"},Dt={class:"grid grid-cols-1 gap-4 lg:grid-cols-2"},Nt={class:"block text-xs font-medium text-text-muted mb-1"},Et=["disabled"],jt=["value"],Pt={class:"block text-xs font-medium text-text-muted mb-1"},qt=["disabled"],Wt=["value"],Lt=["placeholder","disabled"],It=["disabled"],Ut={key:0,class:"flex items-center gap-2"},Ht={key:1},Xt={class:"grid grid-cols-1 gap-4 lg:grid-cols-2"},Yt={class:"space-y-3 rounded-lg border border-border-default bg-surface p-3"},Kt={class:"flex items-center justify-between"},Gt={class:"text-xs font-medium text-accent"},Zt={class:"text-[10px] text-text-muted"},Jt={class:"grid grid-cols-4 gap-1.5 text-[10px]"},Ot={class:"rounded bg-surface-overlay p-1.5"},Qt={class:"text-text-muted"},es={class:"font-medium text-text-primary"},ts={class:"rounded bg-surface-overlay p-1.5"},ss={class:"text-text-muted"},os={class:"font-medium text-text-primary"},as={class:"rounded bg-surface-overlay p-1.5"},ls={class:"text-text-muted"},ns={class:"font-medium text-text-primary"},is={class:"rounded bg-surface-overlay p-1.5"},rs={class:"text-text-muted"},ds={class:"font-medium text-text-primary"},cs={class:"space-y-3 rounded-lg border border-border-default bg-surface p-3"},us={class:"flex items-center justify-between"},ms={class:"text-xs font-medium text-accent"},vs={class:"text-[10px] text-text-muted"},ps={class:"grid grid-cols-4 gap-1.5 text-[10px]"},fs={class:"rounded bg-surface-overlay p-1.5"},gs={class:"text-text-muted"},xs={class:"font-medium text-text-primary"},bs={class:"rounded bg-surface-overlay p-1.5"},hs={class:"text-text-muted"},ys={class:"font-medium text-text-primary"},_s={class:"rounded bg-surface-overlay p-1.5"},$s={class:"text-text-muted"},ks={class:"font-medium text-text-primary"},ws={class:"rounded bg-surface-overlay p-1.5"},Ms={class:"text-text-muted"},Cs={class:"font-medium text-text-primary"},Ss={class:"rounded-lg border border-border-default bg-surface p-4 text-center"},Rs={class:"mt-2 text-xs text-text-muted"},zs={class:"text-sm text-text-muted py-2"},Bs={class:"text-xs text-text-muted"},Ts={key:1,class:"rounded-lg border border-border-default bg-surface-raised p-5 space-y-4"},As={class:"flex items-center justify-between"},Vs={class:"text-base font-semibold text-text-primary"},Fs={class:"space-y-2"},Ds=["onClick"],Ns={class:"flex-1 min-w-0"},Es={class:"truncate text-sm text-text-primary"},js={class:"flex gap-3 text-xs text-text-muted mt-0.5"},Ps=["onClick"],Hs=U({__name:"EmbeddingsPage",setup(y){const i=de(),o=fe(),x=me(),v=N(()=>x.getDatabaseById("message-memory")),b=_(""),h=_(""),z=_(null),B=_(""),c=_(""),m=_(null),g=_(null),M=_(null),k=_(!1),p=_(""),d=_(""),u=_(""),r=_(null),f=_(null),w=_(null),R=_(!1);async function j(){if(!(!p.value||!d.value||!u.value.trim())){R.value=!0,w.value=null,r.value=null,f.value=null;try{const[s,$]=await Promise.all([o.embed(p.value,u.value.trim()),o.embed(d.value,u.value.trim())]);r.value=s,f.value=$,s.dimensions===$.dimensions&&(w.value=o.cosineSimilarity(s.vector,$.vector))}catch{}finally{R.value=!1}}}const D=N(()=>i.models.filter(s=>s.name.includes("embed")||s.name.includes("nomic")||s.name.includes("minilm")||s.name.includes("snowflake")||s.name.includes("mxbai")||s.name.includes("bge"))),C=N(()=>D.value.length>0?D.value:i.models);async function q(){if(!(!b.value||!h.value.trim()))try{z.value=await o.embed(b.value,h.value.trim())}catch{}}async function E(){if(!(!b.value||!B.value.trim()||!c.value.trim())){k.value=!0,M.value=null;try{const[s,$]=await Promise.all([o.embed(b.value,B.value.trim()),o.embed(b.value,c.value.trim())]);m.value=s,g.value=$,M.value=o.cosineSimilarity(s.vector,$.vector)}catch{}finally{k.value=!1}}}return oe(async()=>{i.models.length===0&&await i.fetchModels(),C.value.length>0&&!b.value&&(b.value=C.value[0].name),C.value.length>=2?(p.value=C.value[0].name,d.value=C.value[1].name):C.value.length===1&&(p.value=C.value[0].name,d.value=C.value[0].name),await x.refreshIfStale()}),(s,$)=>(a(),n("div",Ze,[e("div",Je,[L(e("select",{"onUpdate:modelValue":$[0]||($[0]=l=>b.value=l),class:"rounded-lg border border-border-default bg-surface px-3 py-2 text-sm text-text-primary focus:border-accent focus:outline-none"},[C.value.length===0?(a(),n("option",Oe,t(s.$t("embeddings.modelSelector.noModels")),1)):T("",!0),(a(!0),n(A,null,W(C.value,l=>(a(),n("option",{key:l.name,value:l.name},t(l.name)+" "+t(S(i).capabilityIcons(l.name)),9,Qe))),128))],512),[[J,b.value]]),D.value.length===0&&S(i).models.length>0?(a(),n("span",et,t(s.$t("embeddings.modelSelector.noEmbeddingModels")),1)):T("",!0)]),S(x).origin&&v.value?(a(),ce(ve,{key:0,used:v.value.totalBytes,total:S(x).origin.quota,compact:"",label:`${s.$t("embeddings.storage.embeddingMemory")} · ${v.value.recordCount.toLocaleString()} ${s.$t("embeddings.storage.records")}`},null,8,["used","total","label"])):T("",!0),e("section",tt,[e("h2",st,t(s.$t("embeddings.playground.title")),1),e("p",ot,t(s.$t("embeddings.playground.description")),1),L(e("textarea",{"onUpdate:modelValue":$[1]||($[1]=l=>h.value=l),class:"w-full rounded-lg border border-border-default bg-surface px-4 py-3 text-sm text-text-primary placeholder-text-muted focus:border-accent focus:outline-none resize-none",rows:"3",placeholder:s.$t("embeddings.playground.placeholder"),disabled:S(o).loading,onKeydown:ue(te(q,["ctrl"]),["enter"])},null,40,at),[[X,h.value]]),e("div",lt,[e("button",{class:"rounded-lg bg-accent px-4 py-2 text-sm font-medium text-surface hover:bg-accent-hover transition-colors disabled:opacity-50",disabled:S(o).loading||!b.value||!h.value.trim(),onClick:q},[S(o).loading?(a(),n("span",it,[V(O,{size:"sm"}),P(" "+t(s.$t("embeddings.playground.embedding")),1)])):(a(),n("span",rt,t(s.$t("embeddings.playground.embed")),1))],8,nt),S(o).error?(a(),n("span",dt,t(S(o).error),1)):T("",!0)]),V(Ie,{"input-text":h.value,"is-embedding":S(o).loading,vector:z.value?.vector??null},null,8,["input-text","is-embedding","vector"]),z.value?(a(),n(A,{key:0},[V(Ce,{result:z.value},null,8,["result"]),e("details",ct,[e("summary",ut,t(s.$t("embeddings.playground.showRawValues",{total:z.value.dimensions})),1),e("div",mt,[(a(!0),n(A,null,W(z.value.vector.slice(0,50),(l,F)=>(a(),n("span",{key:F,class:"rounded bg-surface px-1.5 py-0.5",title:`dim[${F}]`},t(l.toFixed(4)),9,vt))),128))])])],64)):T("",!0)]),e("section",pt,[e("h2",ft,t(s.$t("embeddings.similarity.title")),1),e("p",gt,t(s.$t("embeddings.similarity.description")),1),e("div",xt,[e("div",null,[e("label",bt,t(s.$t("embeddings.similarity.textA")),1),L(e("textarea",{"onUpdate:modelValue":$[2]||($[2]=l=>B.value=l),class:"w-full rounded-lg border border-border-default bg-surface px-4 py-3 text-sm text-text-primary placeholder-text-muted focus:border-accent focus:outline-none resize-none",rows:"3",placeholder:s.$t("embeddings.similarity.placeholderA"),disabled:k.value},null,8,ht),[[X,B.value]])]),e("div",null,[e("label",yt,t(s.$t("embeddings.similarity.textB")),1),L(e("textarea",{"onUpdate:modelValue":$[3]||($[3]=l=>c.value=l),class:"w-full rounded-lg border border-border-default bg-surface px-4 py-3 text-sm text-text-primary placeholder-text-muted focus:border-accent focus:outline-none resize-none",rows:"3",placeholder:s.$t("embeddings.similarity.placeholderB"),disabled:k.value},null,8,_t),[[X,c.value]])])]),e("button",{class:"rounded-lg bg-accent px-4 py-2 text-sm font-medium text-surface hover:bg-accent-hover transition-colors disabled:opacity-50",disabled:k.value||!b.value||!B.value.trim()||!c.value.trim(),onClick:E},[k.value?(a(),n("span",kt,[V(O,{size:"sm"}),P(" "+t(s.$t("embeddings.similarity.comparing")),1)])):(a(),n("span",wt,t(s.$t("embeddings.similarity.compare")),1))],8,$t),M.value!==null&&m.value&&g.value?(a(),n("div",Mt,[e("div",Ct,[e("div",St,t(s.$t("embeddings.similarity.textA")),1),e("div",Rt,t(m.value.input),1),V(Y,{vector:m.value.vector,height:80},null,8,["vector"])]),V(se,{score:M.value},null,8,["score"]),e("div",zt,[e("div",Bt,t(s.$t("embeddings.similarity.textB")),1),e("div",Tt,t(g.value.input),1),V(Y,{vector:g.value.vector,height:80},null,8,["vector"])])])):T("",!0)]),e("section",At,[e("h2",Vt,t(s.$t("embeddings.modelComparison.title")),1),e("p",Ft,t(s.$t("embeddings.modelComparison.description")),1),e("div",Dt,[e("div",null,[e("label",Nt,t(s.$t("embeddings.modelComparison.modelA")),1),L(e("select",{"onUpdate:modelValue":$[4]||($[4]=l=>p.value=l),class:"w-full rounded-lg border border-border-default bg-surface px-3 py-2 text-sm text-text-primary outline-none focus:border-accent",disabled:R.value},[(a(!0),n(A,null,W(C.value,l=>(a(),n("option",{key:l.name,value:l.name},t(l.name)+" "+t(S(i).capabilityIcons(l.name)),9,jt))),128))],8,Et),[[J,p.value]])]),e("div",null,[e("label",Pt,t(s.$t("embeddings.modelComparison.modelB")),1),L(e("select",{"onUpdate:modelValue":$[5]||($[5]=l=>d.value=l),class:"w-full rounded-lg border border-border-default bg-surface px-3 py-2 text-sm text-text-primary outline-none focus:border-accent",disabled:R.value},[(a(!0),n(A,null,W(C.value,l=>(a(),n("option",{key:l.name,value:l.name},t(l.name)+" "+t(S(i).capabilityIcons(l.name)),9,Wt))),128))],8,qt),[[J,d.value]])])]),L(e("textarea",{"onUpdate:modelValue":$[6]||($[6]=l=>u.value=l),class:"w-full rounded-lg border border-border-default bg-surface px-4 py-3 text-sm text-text-primary placeholder-text-muted focus:border-accent focus:outline-none resize-none",rows:"2",placeholder:s.$t("embeddings.modelComparison.placeholder"),disabled:R.value},null,8,Lt),[[X,u.value]]),e("button",{class:"rounded-lg bg-accent px-4 py-2 text-sm font-medium text-surface hover:bg-accent-hover transition-colors disabled:opacity-50",disabled:R.value||!p.value||!d.value||!u.value.trim(),onClick:j},[R.value?(a(),n("span",Ut,[V(O,{size:"sm"}),P(" "+t(s.$t("embeddings.modelComparison.comparingModels")),1)])):(a(),n("span",Ht,t(s.$t("embeddings.modelComparison.compareModels")),1))],8,It),r.value&&f.value?(a(),n(A,{key:0},[e("div",Xt,[e("div",Yt,[e("div",Kt,[e("span",Gt,t(r.value.model),1),e("span",Zt,t(r.value.dimensions)+"d · "+t(S(I)(r.value.durationMs)),1)]),V(Y,{vector:r.value.vector,height:80},null,8,["vector"]),e("div",Jt,[e("div",Ot,[e("div",Qt,t(s.$t("embeddings.stats.dims")),1),e("div",es,t(r.value.dimensions),1)]),e("div",ts,[e("div",ss,t(s.$t("embeddings.stats.l2Norm")),1),e("div",os,t(Math.sqrt(r.value.vector.reduce((l,F)=>l+F*F,0)).toFixed(2)),1)]),e("div",as,[e("div",ls,t(s.$t("embeddings.stats.sparsity")),1),e("div",ns,t((r.value.vector.filter(l=>Math.abs(l)<.001).length/r.value.dimensions*100).toFixed(1))+"%",1)]),e("div",is,[e("div",rs,t(s.$t("embeddings.stats.time")),1),e("div",ds,t(S(I)(r.value.durationMs)),1)])])]),e("div",cs,[e("div",us,[e("span",ms,t(f.value.model),1),e("span",vs,t(f.value.dimensions)+"d · "+t(S(I)(f.value.durationMs)),1)]),V(Y,{vector:f.value.vector,height:80},null,8,["vector"]),e("div",ps,[e("div",fs,[e("div",gs,t(s.$t("embeddings.stats.dims")),1),e("div",xs,t(f.value.dimensions),1)]),e("div",bs,[e("div",hs,t(s.$t("embeddings.stats.l2Norm")),1),e("div",ys,t(Math.sqrt(f.value.vector.reduce((l,F)=>l+F*F,0)).toFixed(2)),1)]),e("div",_s,[e("div",$s,t(s.$t("embeddings.stats.sparsity")),1),e("div",ks,t((f.value.vector.filter(l=>Math.abs(l)<.001).length/f.value.dimensions*100).toFixed(1))+"%",1)]),e("div",ws,[e("div",Ms,t(s.$t("embeddings.stats.time")),1),e("div",Cs,t(S(I)(f.value.durationMs)),1)])])])]),e("div",Ss,[w.value!==null?(a(),n(A,{key:0},[V(se,{score:w.value},null,8,["score"]),e("p",Rs,[P(t(s.$t("embeddings.modelComparison.crossModelSimilarity"))+" ",1),w.value<.5?(a(),n(A,{key:0},[P(t(s.$t("embeddings.modelComparison.veryDifferent")),1)],64)):w.value<.8?(a(),n(A,{key:1},[P(t(s.$t("embeddings.modelComparison.moderateAgreement")),1)],64)):(a(),n(A,{key:2},[P(t(s.$t("embeddings.modelComparison.highAgreement")),1)],64))])],64)):(a(),n(A,{key:1},[e("p",zs,t(s.$t("embeddings.modelComparison.dimensionsMismatch",{dimA:r.value.dimensions,dimB:f.value.dimensions})),1),e("p",Bs,t(s.$t("embeddings.modelComparison.compareStats")),1)],64))])],64)):T("",!0)]),S(o).recentResults.length>0?(a(),n("section",Ts,[e("div",As,[e("h2",Vs,t(s.$t("embeddings.history.title")),1),e("button",{class:"text-xs text-text-muted hover:text-error transition-colors",onClick:$[7]||($[7]=l=>S(o).clearResults())},t(s.$t("embeddings.history.clearAll")),1)]),e("div",Fs,[(a(!0),n(A,null,W(S(o).recentResults.slice(0,10),l=>(a(),n("div",{key:l.id,class:"flex items-center justify-between rounded-lg bg-surface px-4 py-2 hover:bg-surface-overlay transition-colors cursor-pointer",onClick:F=>z.value=l},[e("div",Ns,[e("div",Es,t(l.input),1),e("div",js,[e("span",null,t(l.model),1),e("span",null,t(l.dimensions)+"d",1),e("span",null,t(S(I)(l.durationMs)),1)])]),e("button",{class:"ms-3 text-text-muted hover:text-error text-xs",onClick:te(F=>S(o).removeResult(l.id),["stop"])}," ✕ ",8,Ps)],8,Ds))),128))])])):T("",!0)]))}});export{Hs as default};
1
+ import{d as ae,r as _,a as N,o as le,n as ne,b as U,e as n,g as K,f as e,j as a,B as oe,w as Q,t,i as T,l as H,V as ie,F as A,k as W,W as re,p as V,x as G,s as Z,h as P,y as ee,A as de,C as L,G as J,u as S,q as ce,D as X,Y as ue,v as te}from"./index-534TcCbY.js";import{c as I}from"./format-BqVZ9rwM.js";import{u as me}from"./storage-store-6qFwk_C5.js";import{_ as ve}from"./StorageGauge.vue_vue_type_style_index_0_lang-DToi3R0q.js";import{_ as pe}from"./_plugin-vue_export-helper-DlAUqK2U.js";const fe=ae("embeddings",()=>{const y=_([]),i=_(!1),o=_(null),x=N(()=>[...y.value].sort((c,m)=>m.timestamp-c.timestamp));async function v(c,m){i.value=!0,o.value=null;const g=Date.now();try{const k=(await le.embed({model:c,input:m})).embeddings[0];if(!k)throw new Error("No embedding returned");const p={id:ne(),model:c,input:m,vector:k,dimensions:k.length,timestamp:Date.now(),durationMs:Date.now()-g};return y.value.push(p),p}catch(M){throw o.value=M instanceof Error?M.message:"Embedding failed",M}finally{i.value=!1}}function b(c,m){if(c.length!==m.length)return 0;let g=0,M=0,k=0;for(let d=0;d<c.length;d++)g+=c[d]*m[d],M+=c[d]*c[d],k+=m[d]*m[d];const p=Math.sqrt(M)*Math.sqrt(k);return p===0?0:g/p}function h(c,m){return{score:b(c.vector,m.vector),a:c,b:m}}function z(){y.value=[]}function B(c){y.value=y.value.filter(m=>m.id!==c)}return{results:y,recentResults:x,loading:i,error:o,embed:v,cosineSimilarity:b,comparePair:h,clearResults:z,removeResult:B}}),O=U({__name:"LoadingSpinner",props:{size:{}},setup(y){return(i,o)=>(a(),n("div",{class:K(["inline-block animate-spin rounded-full border-2 border-current border-t-transparent text-accent",{"h-4 w-4":y.size==="sm"||!y.size,"h-6 w-6":y.size==="md","h-8 w-8":y.size==="lg"}]),role:"status"},[...o[0]||(o[0]=[e("span",{class:"sr-only"},"Loading...",-1)])],2))}}),ge={class:"space-y-1"},xe={key:0,class:"text-xs text-text-muted"},be=["height"],he={class:"text-text-muted"},ye={class:"flex items-center justify-between text-[10px] text-text-muted"},Y=U({__name:"EmbeddingVectorViz",props:{vector:{},label:{},height:{}},setup(y){const i=y,o=_(null),x=_(null),v=_(null),b=N(()=>i.height??120);function h(){const c=o.value,m=x.value;if(!c||!m)return;const g=c.getContext("2d");if(!g)return;const M=i.vector,k=m.clientWidth,p=b.value,d=window.devicePixelRatio||1;c.width=k*d,c.height=p*d,c.style.width=`${k}px`,c.style.height=`${p}px`,g.scale(d,d),g.clearRect(0,0,k,p);const u=k/M.length,r=p/2;let f=0;for(const w of M)Math.abs(w)>f&&(f=Math.abs(w));f===0&&(f=1);for(let w=0;w<M.length;w++){const R=M[w],j=R/f,D=Math.abs(j)*(r-2),C=.3+Math.abs(j)*.7;R>=0?(g.fillStyle=`rgba(139, 92, 246, ${C})`,g.fillRect(w*u,r-D,Math.max(u,.5),D)):(g.fillStyle=`rgba(251, 146, 60, ${C})`,g.fillRect(w*u,r,Math.max(u,.5),D))}g.strokeStyle="rgba(100, 116, 139, 0.3)",g.lineWidth=1,g.beginPath(),g.moveTo(0,r),g.lineTo(k,r),g.stroke()}function z(c){const m=o.value;if(!m)return;const g=m.getBoundingClientRect(),M=c.clientX-g.left,k=g.width/i.vector.length,p=Math.floor(M/k);p>=0&&p<i.vector.length?v.value={index:p,value:i.vector[p],x:c.clientX-g.left,y:c.clientY-g.top}:v.value=null}function B(){v.value=null}return oe(h),Q(()=>i.vector,h),(c,m)=>(a(),n("div",ge,[y.label?(a(),n("div",xe,t(y.label),1)):T("",!0),e("div",{ref_key:"containerRef",ref:x,class:"relative overflow-hidden rounded-lg border border-border-default bg-surface"},[e("canvas",{ref_key:"canvasRef",ref:o,height:b.value,class:"w-full cursor-crosshair",onMousemove:z,onMouseleave:B},null,40,be),v.value?(a(),n("div",{key:0,class:"pointer-events-none absolute z-10 rounded border border-border-default bg-surface-raised px-2 py-1 text-[10px] shadow-lg",style:H({left:`${Math.min(v.value.x,(x.value?.clientWidth??200)-120)}px`,top:`${v.value.y-36}px`})},[e("span",he,"dim["+t(v.value.index)+"]",1),e("span",{class:K(["ms-1.5 font-mono",v.value.value>=0?"text-accent":"text-warning"])},t(v.value.value.toFixed(6)),3)],4)):T("",!0)],512),e("div",ye,[m[0]||(m[0]=ie('<div class="flex items-center gap-3"><span class="flex items-center gap-1"><span class="inline-block h-1.5 w-1.5 rounded-full bg-[rgb(139,92,246)]"></span> Positive </span><span class="flex items-center gap-1"><span class="inline-block h-1.5 w-1.5 rounded-full bg-[rgb(251,146,60)]"></span> Negative </span></div>',1)),e("span",null,"All "+t(y.vector.length)+" dimensions",1)])]))}}),_e={class:"grid grid-cols-4 gap-2 text-xs lg:grid-cols-8"},$e={class:"text-text-muted"},ke={class:"font-medium text-text-primary"},we={class:"pointer-events-none absolute bottom-full left-1/2 z-50 mb-2 -translate-x-1/2 opacity-0 transition-opacity group-hover:opacity-100"},Me={class:"w-52 rounded-lg border border-border-default bg-surface-raised px-3 py-2 text-[10px] leading-relaxed text-text-secondary shadow-lg"},Ce=U({__name:"EmbeddingStats",props:{result:{}},setup(y){const i=y,o=N(()=>{const v=i.result.vector;let b=1/0,h=-1/0,z=0,B=0,c=0;for(const p of v)p<b&&(b=p),p>h&&(h=p),z+=p,B+=p*p,Math.abs(p)<.001&&c++;const m=z/v.length,g=B/v.length-m*m,M=Math.sqrt(B),k=c/v.length*100;return{dimensions:v.length,min:b.toFixed(4),max:h.toFixed(4),mean:m.toFixed(4),stdDev:Math.sqrt(Math.max(0,g)).toFixed(4),l2Norm:M.toFixed(4),sparsity:k.toFixed(1),duration:I(i.result.durationMs),memoryBytes:v.length*8}}),x=N(()=>[{key:"dims",label:"Dims",value:o.value.dimensions,tooltip:"Number of dimensions in the embedding vector. Higher dimensions capture more semantic nuance but use more memory."},{key:"min",label:"Min",value:o.value.min,tooltip:"Smallest value across all dimensions. Shows the negative activation floor of the embedding space."},{key:"max",label:"Max",value:o.value.max,tooltip:"Largest value across all dimensions. Shows the positive activation ceiling of the embedding space."},{key:"mean",label:"Mean",value:o.value.mean,tooltip:"Average value across all dimensions. Near-zero means the vector is well-centered, which is typical for normalized embeddings."},{key:"stdDev",label:"Std Dev",value:o.value.stdDev,tooltip:"Standard deviation — measures how spread out the values are. Higher means more varied activations across dimensions."},{key:"l2Norm",label:"L2 Norm",value:o.value.l2Norm,tooltip:"Euclidean length of the vector. Normalized embeddings have L2 norm close to 1.0, making cosine similarity equivalent to dot product."},{key:"sparsity",label:"Sparsity",value:`${o.value.sparsity}%`,tooltip:"Percentage of dimensions with near-zero values (|v| < 0.001). High sparsity means the text activates only a subset of the semantic dimensions."},{key:"duration",label:"Time",value:o.value.duration,tooltip:"Time taken by the model to compute the embedding vector from the input text."}]);return(v,b)=>(a(),n("div",_e,[(a(!0),n(A,null,W(x.value,h=>(a(),n("div",{key:h.key,class:"group relative rounded-lg bg-surface p-2 cursor-help"},[e("div",$e,t(h.label),1),e("div",ke,t(h.value),1),e("div",we,[e("div",Me,t(h.tooltip),1),b[0]||(b[0]=e("div",{class:"mx-auto h-2 w-2 -translate-y-1 rotate-45 border-b border-e border-border-default bg-surface-raised"},null,-1))])]))),128))]))}}),Se={key:0,class:"relative overflow-hidden rounded-lg border border-border-default bg-surface p-4"},Re={class:"mb-3 flex items-center justify-between text-[10px] text-text-muted"},ze={key:0},Be={key:1},Te={key:2},Ae={key:3,class:"font-mono"},Ve={class:"relative h-24 flex items-center justify-center"},Fe={key:0,class:"absolute inset-0 flex flex-wrap items-center justify-center gap-1.5 px-4"},De={key:0,class:"absolute inset-0 flex items-center justify-center"},Ne={class:"flex items-end gap-px h-16"},Ee={class:"text-text-muted"},je={class:"mt-3 flex items-center justify-between"},Pe={class:"flex items-center gap-3 text-[10px] text-text-muted"},qe={key:0,class:"text-text-muted"},We={class:"flex items-center gap-2 text-[10px] text-text-muted shrink-0"},Le=U({__name:"EmbeddingTransformViz",props:{inputText:{},isEmbedding:{type:Boolean},vector:{}},setup(y){const i=y,o=_("idle"),x=_(0),v=_(null),b=_(null),h=_(null);let z=0,B=0;const c=N(()=>i.inputText.split(/\s+/).filter(Boolean).slice(0,20)),m=N(()=>{if(!i.vector)return null;let d=0,u=0;for(const w of i.vector)w>=0?d++:u++;const r=d/i.vector.length;let f;return r>.7?f="Mostly positive activations":r<.3?f="Mostly negative activations":f="Balanced activation spread",{positive:d,negative:u,character:f}});function g(){const d=b.value,u=h.value;if(!d||!u||!i.vector)return;const r=d.getContext("2d");if(!r)return;const f=i.vector,w=u.clientWidth,R=96,j=window.devicePixelRatio||1;d.width=w*j,d.height=R*j,d.style.width=`${w}px`,d.style.height=`${R}px`,r.scale(j,j),r.clearRect(0,0,w,R);const D=w/f.length,C=R/2;let q=0;for(const E of f)Math.abs(E)>q&&(q=Math.abs(E));q===0&&(q=1);for(let E=0;E<f.length;E++){const s=f[E],$=s/q,l=Math.abs($)*(C-2),F=.3+Math.abs($)*.7;s>=0?(r.fillStyle=`rgba(139, 92, 246, ${F})`,r.fillRect(E*D,C-l,Math.max(D,.5),l)):(r.fillStyle=`rgba(251, 146, 60, ${F})`,r.fillRect(E*D,C,Math.max(D,.5),l))}r.strokeStyle="rgba(100, 116, 139, 0.3)",r.lineWidth=1,r.beginPath(),r.moveTo(0,C),r.lineTo(w,C),r.stroke()}function M(d){const u=b.value;if(!u||!i.vector)return;const r=u.getBoundingClientRect(),f=d.clientX-r.left,w=r.width/i.vector.length,R=Math.floor(f/w);R>=0&&R<i.vector.length?v.value={index:R,value:i.vector[R],x:d.clientX-r.left,y:d.clientY-r.top}:v.value=null}function k(){v.value=null}function p(d){B||(B=d);const u=d-B;u<600?(o.value="decomposing",x.value=u/600):u<1200&&(o.value="transforming",x.value=(u-600)/600),i.isEmbedding&&(z=requestAnimationFrame(p))}return Q(()=>i.isEmbedding,d=>{d?(B=0,x.value=0,v.value=null,o.value="decomposing",z=requestAnimationFrame(p)):(cancelAnimationFrame(z),i.vector?(o.value="complete",x.value=1,ee(g)):(o.value="idle",x.value=0))}),Q(()=>i.vector,()=>{o.value==="complete"&&i.vector&&ee(g)}),re(()=>cancelAnimationFrame(z)),(d,u)=>o.value!=="idle"||y.vector?(a(),n("div",Se,[e("div",Re,[o.value==="decomposing"?(a(),n("span",ze,"Tokenizing text...")):o.value==="transforming"?(a(),n("span",Be,"Projecting into embedding space...")):o.value==="complete"&&m.value?(a(),n("span",Te,t(m.value.character),1)):T("",!0),y.vector?(a(),n("span",Ae,t(y.vector.length)+" dimensions · "+t(m.value?.positive)+" positive · "+t(m.value?.negative)+" negative ",1)):T("",!0)]),e("div",Ve,[V(G,{name:"fade"},{default:Z(()=>[o.value==="decomposing"||o.value==="idle"&&!y.vector?(a(),n("div",Fe,[(a(!0),n(A,null,W(c.value,(r,f)=>(a(),n("span",{key:f,class:"inline-block rounded bg-accent/10 px-1.5 py-0.5 font-mono text-xs text-accent transition-all duration-500",style:H({opacity:o.value==="decomposing"?Math.max(0,1-x.value*1.5+f*.1):1,transform:o.value==="decomposing"?`translateY(${x.value*20*(f%2===0?-1:1)}px) scale(${1-x.value*.3})`:"none"})},t(r),5))),128))])):T("",!0)]),_:1}),V(G,{name:"fade"},{default:Z(()=>[o.value==="transforming"?(a(),n("div",De,[e("div",Ne,[(a(),n(A,null,W(60,r=>e("div",{key:r,class:"w-1 rounded-full transition-all duration-300",style:H({height:`${Math.abs(Math.sin(r*.5+x.value*10))*x.value*100}%`,backgroundColor:Math.sin(r*.5+x.value*10)>=0?`rgba(139, 92, 246, ${.3+x.value*.5})`:`rgba(251, 146, 60, ${.3+x.value*.5})`,opacity:Math.min(1,x.value*2)})},null,4)),64))])])):T("",!0)]),_:1}),V(G,{name:"fade"},{default:Z(()=>[o.value==="complete"&&y.vector?(a(),n("div",{key:0,ref_key:"canvasContainerRef",ref:h,class:"absolute inset-0"},[e("canvas",{ref_key:"canvasRef",ref:b,class:"w-full h-full cursor-crosshair",onMousemove:M,onMouseleave:k},null,544),v.value?(a(),n("div",{key:0,class:"pointer-events-none absolute z-10 rounded border border-border-default bg-surface-raised px-2 py-1 text-[10px] shadow-lg",style:H({left:`${Math.min(v.value.x,(h.value?.clientWidth??200)-120)}px`,top:`${v.value.y-36}px`})},[e("span",Ee,"dim["+t(v.value.index)+"]",1),e("span",{class:K(["ms-1.5 font-mono",v.value.value>=0?"text-accent":"text-warning"])},t(v.value.value.toFixed(6)),3)],4)):T("",!0)],512)):T("",!0)]),_:1})]),e("div",je,[e("div",Pe,[u[0]||(u[0]=e("span",{class:"flex items-center gap-1"},[e("span",{class:"inline-block h-2 w-2 rounded-full bg-[rgb(139,92,246)]"}),P(" Positive activation ")],-1)),u[1]||(u[1]=e("span",{class:"flex items-center gap-1"},[e("span",{class:"inline-block h-2 w-2 rounded-full bg-[rgb(251,146,60)]"}),P(" Negative activation ")],-1)),o.value==="complete"?(a(),n("span",qe," · Each bar = one semantic dimension. Taller = stronger signal. ")):T("",!0)]),e("div",We,[u[2]||(u[2]=e("span",{class:"rounded bg-surface-overlay px-1.5 py-0.5"},"Text",-1)),u[3]||(u[3]=e("span",null,"→",-1)),u[4]||(u[4]=e("span",{class:"rounded bg-surface-overlay px-1.5 py-0.5"},"Tokens",-1)),u[5]||(u[5]=e("span",null,"→",-1)),e("span",{class:K(["rounded px-1.5 py-0.5",o.value==="complete"?"bg-accent/10 text-accent":"bg-surface-overlay"])}," Vector ",2)])])])):T("",!0)}}),Ie=pe(Le,[["__scopeId","data-v-07aa1650"]]),Ue={class:"flex flex-col items-center gap-2"},He={class:"relative h-32 w-32"},Xe={viewBox:"0 0 100 100",class:"h-full w-full -rotate-90"},Ye=["stroke","stroke-dasharray"],Ke={class:"absolute inset-0 flex flex-col items-center justify-center"},Ge={class:"text-2xl font-bold text-text-primary"},se=U({__name:"SimilarityMeter",props:{score:{}},setup(y){const i=y,o=N(()=>Math.round(i.score*100)),x=N(()=>i.score>=.8?"#4ade80":i.score>=.5?"#fbbf24":"#f87171"),v=N(()=>i.score>=.9?"Very Similar":i.score>=.7?"Similar":i.score>=.5?"Somewhat Similar":i.score>=.3?"Weakly Related":"Dissimilar");return(b,h)=>(a(),n("div",Ue,[e("div",He,[(a(),n("svg",Xe,[h[0]||(h[0]=e("circle",{cx:"50",cy:"50",r:"42",fill:"none",class:"stroke-surface-overlay","stroke-width":"8"},null,-1)),e("circle",{cx:"50",cy:"50",r:"42",fill:"none",stroke:x.value,"stroke-width":"8","stroke-linecap":"round","stroke-dasharray":`${o.value*2.64} 264`},null,8,Ye)])),e("div",Ke,[e("span",Ge,t(o.value)+"%",1)])]),e("span",{class:"text-sm font-medium",style:H({color:x.value})},t(v.value),5),h[1]||(h[1]=e("span",{class:"text-xs text-text-muted"},"Cosine Similarity",-1))]))}}),Ze={class:"space-y-8"},Je={class:"flex items-center gap-3"},Oe={key:0,value:"",disabled:""},Qe=["value"],et={key:0,class:"text-xs text-warning"},tt={class:"rounded-lg border border-border-default bg-surface-raised p-5 space-y-4"},st={class:"text-base font-semibold text-text-primary"},ot={class:"text-sm text-text-muted"},at=["placeholder","disabled","onKeydown"],lt={class:"flex items-center gap-3"},nt=["disabled"],it={key:0,class:"flex items-center gap-2"},rt={key:1},dt={key:0,class:"text-sm text-error"},ct={class:"text-xs"},ut={class:"cursor-pointer text-text-muted hover:text-text-secondary"},mt={class:"mt-2 grid grid-cols-5 gap-1 font-mono text-text-secondary"},vt=["title"],pt={class:"rounded-lg border border-border-default bg-surface-raised p-5 space-y-4"},ft={class:"text-base font-semibold text-text-primary"},gt={class:"text-sm text-text-muted"},xt={class:"grid grid-cols-1 gap-4 lg:grid-cols-2"},bt={class:"block text-xs font-medium text-text-muted mb-1"},ht=["placeholder","disabled"],yt={class:"block text-xs font-medium text-text-muted mb-1"},_t=["placeholder","disabled"],$t=["disabled"],kt={key:0,class:"flex items-center gap-2"},wt={key:1},Mt={key:0,class:"flex flex-col items-center gap-6 py-4 lg:flex-row lg:items-start lg:justify-center"},Ct={class:"flex-1 space-y-2"},St={class:"text-xs font-medium text-text-muted"},Rt={class:"rounded-lg bg-surface p-3 text-sm text-text-secondary"},zt={class:"flex-1 space-y-2"},Bt={class:"text-xs font-medium text-text-muted"},Tt={class:"rounded-lg bg-surface p-3 text-sm text-text-secondary"},At={class:"rounded-lg border border-border-default bg-surface-raised p-5 space-y-4"},Vt={class:"text-base font-semibold text-text-primary"},Ft={class:"text-sm text-text-muted"},Dt={class:"grid grid-cols-1 gap-4 lg:grid-cols-2"},Nt={class:"block text-xs font-medium text-text-muted mb-1"},Et=["disabled"],jt=["value"],Pt={class:"block text-xs font-medium text-text-muted mb-1"},qt=["disabled"],Wt=["value"],Lt=["placeholder","disabled"],It=["disabled"],Ut={key:0,class:"flex items-center gap-2"},Ht={key:1},Xt={class:"grid grid-cols-1 gap-4 lg:grid-cols-2"},Yt={class:"space-y-3 rounded-lg border border-border-default bg-surface p-3"},Kt={class:"flex items-center justify-between"},Gt={class:"text-xs font-medium text-accent"},Zt={class:"text-[10px] text-text-muted"},Jt={class:"grid grid-cols-4 gap-1.5 text-[10px]"},Ot={class:"rounded bg-surface-overlay p-1.5"},Qt={class:"text-text-muted"},es={class:"font-medium text-text-primary"},ts={class:"rounded bg-surface-overlay p-1.5"},ss={class:"text-text-muted"},os={class:"font-medium text-text-primary"},as={class:"rounded bg-surface-overlay p-1.5"},ls={class:"text-text-muted"},ns={class:"font-medium text-text-primary"},is={class:"rounded bg-surface-overlay p-1.5"},rs={class:"text-text-muted"},ds={class:"font-medium text-text-primary"},cs={class:"space-y-3 rounded-lg border border-border-default bg-surface p-3"},us={class:"flex items-center justify-between"},ms={class:"text-xs font-medium text-accent"},vs={class:"text-[10px] text-text-muted"},ps={class:"grid grid-cols-4 gap-1.5 text-[10px]"},fs={class:"rounded bg-surface-overlay p-1.5"},gs={class:"text-text-muted"},xs={class:"font-medium text-text-primary"},bs={class:"rounded bg-surface-overlay p-1.5"},hs={class:"text-text-muted"},ys={class:"font-medium text-text-primary"},_s={class:"rounded bg-surface-overlay p-1.5"},$s={class:"text-text-muted"},ks={class:"font-medium text-text-primary"},ws={class:"rounded bg-surface-overlay p-1.5"},Ms={class:"text-text-muted"},Cs={class:"font-medium text-text-primary"},Ss={class:"rounded-lg border border-border-default bg-surface p-4 text-center"},Rs={class:"mt-2 text-xs text-text-muted"},zs={class:"text-sm text-text-muted py-2"},Bs={class:"text-xs text-text-muted"},Ts={key:1,class:"rounded-lg border border-border-default bg-surface-raised p-5 space-y-4"},As={class:"flex items-center justify-between"},Vs={class:"text-base font-semibold text-text-primary"},Fs={class:"space-y-2"},Ds=["onClick"],Ns={class:"flex-1 min-w-0"},Es={class:"truncate text-sm text-text-primary"},js={class:"flex gap-3 text-xs text-text-muted mt-0.5"},Ps=["onClick"],Hs=U({__name:"EmbeddingsPage",setup(y){const i=de(),o=fe(),x=me(),v=N(()=>x.getDatabaseById("message-memory")),b=_(""),h=_(""),z=_(null),B=_(""),c=_(""),m=_(null),g=_(null),M=_(null),k=_(!1),p=_(""),d=_(""),u=_(""),r=_(null),f=_(null),w=_(null),R=_(!1);async function j(){if(!(!p.value||!d.value||!u.value.trim())){R.value=!0,w.value=null,r.value=null,f.value=null;try{const[s,$]=await Promise.all([o.embed(p.value,u.value.trim()),o.embed(d.value,u.value.trim())]);r.value=s,f.value=$,s.dimensions===$.dimensions&&(w.value=o.cosineSimilarity(s.vector,$.vector))}catch{}finally{R.value=!1}}}const D=N(()=>i.models.filter(s=>s.name.includes("embed")||s.name.includes("nomic")||s.name.includes("minilm")||s.name.includes("snowflake")||s.name.includes("mxbai")||s.name.includes("bge"))),C=N(()=>D.value.length>0?D.value:i.models);async function q(){if(!(!b.value||!h.value.trim()))try{z.value=await o.embed(b.value,h.value.trim())}catch{}}async function E(){if(!(!b.value||!B.value.trim()||!c.value.trim())){k.value=!0,M.value=null;try{const[s,$]=await Promise.all([o.embed(b.value,B.value.trim()),o.embed(b.value,c.value.trim())]);m.value=s,g.value=$,M.value=o.cosineSimilarity(s.vector,$.vector)}catch{}finally{k.value=!1}}}return oe(async()=>{i.models.length===0&&await i.fetchModels(),C.value.length>0&&!b.value&&(b.value=C.value[0].name),C.value.length>=2?(p.value=C.value[0].name,d.value=C.value[1].name):C.value.length===1&&(p.value=C.value[0].name,d.value=C.value[0].name),await x.refreshIfStale()}),(s,$)=>(a(),n("div",Ze,[e("div",Je,[L(e("select",{"onUpdate:modelValue":$[0]||($[0]=l=>b.value=l),class:"rounded-lg border border-border-default bg-surface px-3 py-2 text-sm text-text-primary focus:border-accent focus:outline-none"},[C.value.length===0?(a(),n("option",Oe,t(s.$t("embeddings.modelSelector.noModels")),1)):T("",!0),(a(!0),n(A,null,W(C.value,l=>(a(),n("option",{key:l.name,value:l.name},t(l.name)+" "+t(S(i).capabilityIcons(l.name)),9,Qe))),128))],512),[[J,b.value]]),D.value.length===0&&S(i).models.length>0?(a(),n("span",et,t(s.$t("embeddings.modelSelector.noEmbeddingModels")),1)):T("",!0)]),S(x).origin&&v.value?(a(),ce(ve,{key:0,used:v.value.totalBytes,total:S(x).origin.quota,compact:"",label:`${s.$t("embeddings.storage.embeddingMemory")} · ${v.value.recordCount.toLocaleString()} ${s.$t("embeddings.storage.records")}`},null,8,["used","total","label"])):T("",!0),e("section",tt,[e("h2",st,t(s.$t("embeddings.playground.title")),1),e("p",ot,t(s.$t("embeddings.playground.description")),1),L(e("textarea",{"onUpdate:modelValue":$[1]||($[1]=l=>h.value=l),class:"w-full rounded-lg border border-border-default bg-surface px-4 py-3 text-sm text-text-primary placeholder-text-muted focus:border-accent focus:outline-none resize-none",rows:"3",placeholder:s.$t("embeddings.playground.placeholder"),disabled:S(o).loading,onKeydown:ue(te(q,["ctrl"]),["enter"])},null,40,at),[[X,h.value]]),e("div",lt,[e("button",{class:"rounded-lg bg-accent px-4 py-2 text-sm font-medium text-surface hover:bg-accent-hover transition-colors disabled:opacity-50",disabled:S(o).loading||!b.value||!h.value.trim(),onClick:q},[S(o).loading?(a(),n("span",it,[V(O,{size:"sm"}),P(" "+t(s.$t("embeddings.playground.embedding")),1)])):(a(),n("span",rt,t(s.$t("embeddings.playground.embed")),1))],8,nt),S(o).error?(a(),n("span",dt,t(S(o).error),1)):T("",!0)]),V(Ie,{"input-text":h.value,"is-embedding":S(o).loading,vector:z.value?.vector??null},null,8,["input-text","is-embedding","vector"]),z.value?(a(),n(A,{key:0},[V(Ce,{result:z.value},null,8,["result"]),e("details",ct,[e("summary",ut,t(s.$t("embeddings.playground.showRawValues",{total:z.value.dimensions})),1),e("div",mt,[(a(!0),n(A,null,W(z.value.vector.slice(0,50),(l,F)=>(a(),n("span",{key:F,class:"rounded bg-surface px-1.5 py-0.5",title:`dim[${F}]`},t(l.toFixed(4)),9,vt))),128))])])],64)):T("",!0)]),e("section",pt,[e("h2",ft,t(s.$t("embeddings.similarity.title")),1),e("p",gt,t(s.$t("embeddings.similarity.description")),1),e("div",xt,[e("div",null,[e("label",bt,t(s.$t("embeddings.similarity.textA")),1),L(e("textarea",{"onUpdate:modelValue":$[2]||($[2]=l=>B.value=l),class:"w-full rounded-lg border border-border-default bg-surface px-4 py-3 text-sm text-text-primary placeholder-text-muted focus:border-accent focus:outline-none resize-none",rows:"3",placeholder:s.$t("embeddings.similarity.placeholderA"),disabled:k.value},null,8,ht),[[X,B.value]])]),e("div",null,[e("label",yt,t(s.$t("embeddings.similarity.textB")),1),L(e("textarea",{"onUpdate:modelValue":$[3]||($[3]=l=>c.value=l),class:"w-full rounded-lg border border-border-default bg-surface px-4 py-3 text-sm text-text-primary placeholder-text-muted focus:border-accent focus:outline-none resize-none",rows:"3",placeholder:s.$t("embeddings.similarity.placeholderB"),disabled:k.value},null,8,_t),[[X,c.value]])])]),e("button",{class:"rounded-lg bg-accent px-4 py-2 text-sm font-medium text-surface hover:bg-accent-hover transition-colors disabled:opacity-50",disabled:k.value||!b.value||!B.value.trim()||!c.value.trim(),onClick:E},[k.value?(a(),n("span",kt,[V(O,{size:"sm"}),P(" "+t(s.$t("embeddings.similarity.comparing")),1)])):(a(),n("span",wt,t(s.$t("embeddings.similarity.compare")),1))],8,$t),M.value!==null&&m.value&&g.value?(a(),n("div",Mt,[e("div",Ct,[e("div",St,t(s.$t("embeddings.similarity.textA")),1),e("div",Rt,t(m.value.input),1),V(Y,{vector:m.value.vector,height:80},null,8,["vector"])]),V(se,{score:M.value},null,8,["score"]),e("div",zt,[e("div",Bt,t(s.$t("embeddings.similarity.textB")),1),e("div",Tt,t(g.value.input),1),V(Y,{vector:g.value.vector,height:80},null,8,["vector"])])])):T("",!0)]),e("section",At,[e("h2",Vt,t(s.$t("embeddings.modelComparison.title")),1),e("p",Ft,t(s.$t("embeddings.modelComparison.description")),1),e("div",Dt,[e("div",null,[e("label",Nt,t(s.$t("embeddings.modelComparison.modelA")),1),L(e("select",{"onUpdate:modelValue":$[4]||($[4]=l=>p.value=l),class:"w-full rounded-lg border border-border-default bg-surface px-3 py-2 text-sm text-text-primary outline-none focus:border-accent",disabled:R.value},[(a(!0),n(A,null,W(C.value,l=>(a(),n("option",{key:l.name,value:l.name},t(l.name)+" "+t(S(i).capabilityIcons(l.name)),9,jt))),128))],8,Et),[[J,p.value]])]),e("div",null,[e("label",Pt,t(s.$t("embeddings.modelComparison.modelB")),1),L(e("select",{"onUpdate:modelValue":$[5]||($[5]=l=>d.value=l),class:"w-full rounded-lg border border-border-default bg-surface px-3 py-2 text-sm text-text-primary outline-none focus:border-accent",disabled:R.value},[(a(!0),n(A,null,W(C.value,l=>(a(),n("option",{key:l.name,value:l.name},t(l.name)+" "+t(S(i).capabilityIcons(l.name)),9,Wt))),128))],8,qt),[[J,d.value]])])]),L(e("textarea",{"onUpdate:modelValue":$[6]||($[6]=l=>u.value=l),class:"w-full rounded-lg border border-border-default bg-surface px-4 py-3 text-sm text-text-primary placeholder-text-muted focus:border-accent focus:outline-none resize-none",rows:"2",placeholder:s.$t("embeddings.modelComparison.placeholder"),disabled:R.value},null,8,Lt),[[X,u.value]]),e("button",{class:"rounded-lg bg-accent px-4 py-2 text-sm font-medium text-surface hover:bg-accent-hover transition-colors disabled:opacity-50",disabled:R.value||!p.value||!d.value||!u.value.trim(),onClick:j},[R.value?(a(),n("span",Ut,[V(O,{size:"sm"}),P(" "+t(s.$t("embeddings.modelComparison.comparingModels")),1)])):(a(),n("span",Ht,t(s.$t("embeddings.modelComparison.compareModels")),1))],8,It),r.value&&f.value?(a(),n(A,{key:0},[e("div",Xt,[e("div",Yt,[e("div",Kt,[e("span",Gt,t(r.value.model),1),e("span",Zt,t(r.value.dimensions)+"d · "+t(S(I)(r.value.durationMs)),1)]),V(Y,{vector:r.value.vector,height:80},null,8,["vector"]),e("div",Jt,[e("div",Ot,[e("div",Qt,t(s.$t("embeddings.stats.dims")),1),e("div",es,t(r.value.dimensions),1)]),e("div",ts,[e("div",ss,t(s.$t("embeddings.stats.l2Norm")),1),e("div",os,t(Math.sqrt(r.value.vector.reduce((l,F)=>l+F*F,0)).toFixed(2)),1)]),e("div",as,[e("div",ls,t(s.$t("embeddings.stats.sparsity")),1),e("div",ns,t((r.value.vector.filter(l=>Math.abs(l)<.001).length/r.value.dimensions*100).toFixed(1))+"%",1)]),e("div",is,[e("div",rs,t(s.$t("embeddings.stats.time")),1),e("div",ds,t(S(I)(r.value.durationMs)),1)])])]),e("div",cs,[e("div",us,[e("span",ms,t(f.value.model),1),e("span",vs,t(f.value.dimensions)+"d · "+t(S(I)(f.value.durationMs)),1)]),V(Y,{vector:f.value.vector,height:80},null,8,["vector"]),e("div",ps,[e("div",fs,[e("div",gs,t(s.$t("embeddings.stats.dims")),1),e("div",xs,t(f.value.dimensions),1)]),e("div",bs,[e("div",hs,t(s.$t("embeddings.stats.l2Norm")),1),e("div",ys,t(Math.sqrt(f.value.vector.reduce((l,F)=>l+F*F,0)).toFixed(2)),1)]),e("div",_s,[e("div",$s,t(s.$t("embeddings.stats.sparsity")),1),e("div",ks,t((f.value.vector.filter(l=>Math.abs(l)<.001).length/f.value.dimensions*100).toFixed(1))+"%",1)]),e("div",ws,[e("div",Ms,t(s.$t("embeddings.stats.time")),1),e("div",Cs,t(S(I)(f.value.durationMs)),1)])])])]),e("div",Ss,[w.value!==null?(a(),n(A,{key:0},[V(se,{score:w.value},null,8,["score"]),e("p",Rs,[P(t(s.$t("embeddings.modelComparison.crossModelSimilarity"))+" ",1),w.value<.5?(a(),n(A,{key:0},[P(t(s.$t("embeddings.modelComparison.veryDifferent")),1)],64)):w.value<.8?(a(),n(A,{key:1},[P(t(s.$t("embeddings.modelComparison.moderateAgreement")),1)],64)):(a(),n(A,{key:2},[P(t(s.$t("embeddings.modelComparison.highAgreement")),1)],64))])],64)):(a(),n(A,{key:1},[e("p",zs,t(s.$t("embeddings.modelComparison.dimensionsMismatch",{dimA:r.value.dimensions,dimB:f.value.dimensions})),1),e("p",Bs,t(s.$t("embeddings.modelComparison.compareStats")),1)],64))])],64)):T("",!0)]),S(o).recentResults.length>0?(a(),n("section",Ts,[e("div",As,[e("h2",Vs,t(s.$t("embeddings.history.title")),1),e("button",{class:"text-xs text-text-muted hover:text-error transition-colors",onClick:$[7]||($[7]=l=>S(o).clearResults())},t(s.$t("embeddings.history.clearAll")),1)]),e("div",Fs,[(a(!0),n(A,null,W(S(o).recentResults.slice(0,10),l=>(a(),n("div",{key:l.id,class:"flex items-center justify-between rounded-lg bg-surface px-4 py-2 hover:bg-surface-overlay transition-colors cursor-pointer",onClick:F=>z.value=l},[e("div",Ns,[e("div",Es,t(l.input),1),e("div",js,[e("span",null,t(l.model),1),e("span",null,t(l.dimensions)+"d",1),e("span",null,t(S(I)(l.durationMs)),1)])]),e("button",{class:"ms-3 text-text-muted hover:text-error text-xs",onClick:te(F=>S(o).removeResult(l.id),["stop"])}," ✕ ",8,Ps)],8,Ds))),128))])])):T("",!0)]))}});export{Hs as default};
@@ -1 +1 @@
1
- import{b as g,B as p,e as n,f as e,F as i,h as b,t as x,u as c,at as v,H as y,r as f,j as a}from"./index-DYHBy1xj.js";import{u as k}from"./google-auth-store-B0WvuFWG.js";import"./google-auth-CfEcVMA7.js";const w={class:"flex items-center justify-center h-full"},C={class:"rounded-xl border border-border-default bg-surface-raised p-8 shadow-lg w-[400px] text-center"},G={class:"text-xs text-text-muted mt-2"},h={class:"text-text-primary font-medium"},B={class:"text-xs text-error mt-2"},z=g({__name:"GoogleCallbackPage",setup(S){const u=v(),d=y(),m=k(),s=f("loading"),r=f("");return p(async()=>{const l=u.query.code,t=u.query.error;if(t){s.value="error",r.value=`Google authorization was denied: ${t}`;return}if(!l){s.value="error",r.value="No authorization code received from Google.";return}try{await m.handleOAuthCallback(l),s.value="success",setTimeout(()=>d.replace("/settings"),1500)}catch(o){s.value="error",r.value=o instanceof Error?o.message:String(o)}}),(l,t)=>(a(),n("div",w,[e("div",C,[s.value==="loading"?(a(),n(i,{key:0},[t[1]||(t[1]=e("div",{class:"inline-block h-8 w-8 rounded-full border-2 border-accent border-t-transparent animate-spin mb-4"},null,-1)),t[2]||(t[2]=e("h3",{class:"text-sm font-medium text-text-primary"},"Connecting Google Account",-1)),t[3]||(t[3]=e("p",{class:"text-xs text-text-muted mt-2"},"Exchanging authorization code for tokens...",-1))],64)):s.value==="success"?(a(),n(i,{key:1},[t[5]||(t[5]=e("div",{class:"inline-flex items-center justify-center h-10 w-10 rounded-full bg-success/10 mb-4"},[e("span",{class:"text-success text-lg"},"✓")],-1)),t[6]||(t[6]=e("h3",{class:"text-sm font-medium text-text-primary"},"Google Account Connected",-1)),e("p",G,[t[4]||(t[4]=b(" Connected as ",-1)),e("span",h,x(c(m).userEmail??"unknown"),1)]),t[7]||(t[7]=e("p",{class:"text-[10px] text-text-muted mt-3"},"Redirecting to Settings...",-1))],64)):(a(),n(i,{key:2},[t[8]||(t[8]=e("div",{class:"inline-flex items-center justify-center h-10 w-10 rounded-full bg-error/10 mb-4"},[e("span",{class:"text-error text-lg"},"✗")],-1)),t[9]||(t[9]=e("h3",{class:"text-sm font-medium text-text-primary"},"Connection Failed",-1)),e("p",B,x(r.value),1),e("button",{class:"mt-4 rounded-lg bg-surface-overlay px-4 py-2 text-xs text-text-primary hover:bg-border-default transition-colors",onClick:t[0]||(t[0]=o=>c(d).push("/settings"))}," Back to Settings ")],64))])]))}});export{z as default};
1
+ import{b as g,B as p,e as n,f as e,F as i,h as b,t as x,u as c,at as v,H as y,r as f,j as a}from"./index-534TcCbY.js";import{u as k}from"./google-auth-store-Dgv2FihL.js";import"./google-auth-CfEcVMA7.js";const w={class:"flex items-center justify-center h-full"},C={class:"rounded-xl border border-border-default bg-surface-raised p-8 shadow-lg w-[400px] text-center"},G={class:"text-xs text-text-muted mt-2"},h={class:"text-text-primary font-medium"},B={class:"text-xs text-error mt-2"},z=g({__name:"GoogleCallbackPage",setup(S){const u=v(),d=y(),m=k(),s=f("loading"),r=f("");return p(async()=>{const l=u.query.code,t=u.query.error;if(t){s.value="error",r.value=`Google authorization was denied: ${t}`;return}if(!l){s.value="error",r.value="No authorization code received from Google.";return}try{await m.handleOAuthCallback(l),s.value="success",setTimeout(()=>d.replace("/settings"),1500)}catch(o){s.value="error",r.value=o instanceof Error?o.message:String(o)}}),(l,t)=>(a(),n("div",w,[e("div",C,[s.value==="loading"?(a(),n(i,{key:0},[t[1]||(t[1]=e("div",{class:"inline-block h-8 w-8 rounded-full border-2 border-accent border-t-transparent animate-spin mb-4"},null,-1)),t[2]||(t[2]=e("h3",{class:"text-sm font-medium text-text-primary"},"Connecting Google Account",-1)),t[3]||(t[3]=e("p",{class:"text-xs text-text-muted mt-2"},"Exchanging authorization code for tokens...",-1))],64)):s.value==="success"?(a(),n(i,{key:1},[t[5]||(t[5]=e("div",{class:"inline-flex items-center justify-center h-10 w-10 rounded-full bg-success/10 mb-4"},[e("span",{class:"text-success text-lg"},"✓")],-1)),t[6]||(t[6]=e("h3",{class:"text-sm font-medium text-text-primary"},"Google Account Connected",-1)),e("p",G,[t[4]||(t[4]=b(" Connected as ",-1)),e("span",h,x(c(m).userEmail??"unknown"),1)]),t[7]||(t[7]=e("p",{class:"text-[10px] text-text-muted mt-3"},"Redirecting to Settings...",-1))],64)):(a(),n(i,{key:2},[t[8]||(t[8]=e("div",{class:"inline-flex items-center justify-center h-10 w-10 rounded-full bg-error/10 mb-4"},[e("span",{class:"text-error text-lg"},"✗")],-1)),t[9]||(t[9]=e("h3",{class:"text-sm font-medium text-text-primary"},"Connection Failed",-1)),e("p",B,x(r.value),1),e("button",{class:"mt-4 rounded-lg bg-surface-overlay px-4 py-2 text-xs text-text-primary hover:bg-border-default transition-colors",onClick:t[0]||(t[0]=o=>c(d).push("/settings"))}," Back to Settings ")],64))])]))}});export{z as default};
@@ -1,4 +1,4 @@
1
- import{b as S,r as L,e as g,l as O,u as w,v as E,g as v,f as d,t as m,i as j,F as k,k as R,q as C,al as x,j as h}from"./index-DYHBy1xj.js";import{_ as J}from"./_plugin-vue_export-helper-DlAUqK2U.js";function H(e,c="json"){if(e.length===0)return`return ${c}`;const t=e.map(a=>K(a)),s=new Map;for(const a of t)s.set(a,(s.get(a)??0)+1);const r=e.map((a,y)=>{let f=t[y];return(s.get(f)??0)>1&&(f=N(a)),` ${f}: ${c}.${a}`});return r.length===1?`return {${r[0].trim().replace(/^/," ").replace(/$/," ")}}`:`return {
1
+ import{b as S,r as L,e as g,l as O,u as w,v as E,g as v,f as d,t as m,i as j,F as k,k as R,q as C,al as x,j as h}from"./index-534TcCbY.js";import{_ as J}from"./_plugin-vue_export-helper-DlAUqK2U.js";function H(e,c="json"){if(e.length===0)return`return ${c}`;const t=e.map(a=>K(a)),s=new Map;for(const a of t)s.set(a,(s.get(a)??0)+1);const r=e.map((a,y)=>{let f=t[y];return(s.get(f)??0)>1&&(f=N(a)),` ${f}: ${c}.${a}`});return r.length===1?`return {${r[0].trim().replace(/^/," ").replace(/$/," ")}}`:`return {
2
2
  ${r.join(`,
3
3
  `)}
4
4
  }`}function K(e){const t=e.replace(/\[\d+\]/g,"").split(".");return t[t.length-1]??e}function N(e){const t=e.replace(/\[\d+\]/g,"").split(".");return t.length>=2?`${t[t.length-2]}_${t[t.length-1]}`:t[t.length-1]??e}function ne(e){if(e.length===0)return[];const c=e.map(s=>K(s)),t=new Map;for(const s of c)t.set(s,(t.get(s)??0)+1);return e.map((s,r)=>{let a=c[r];return(t.get(a)??0)>1&&(a=N(s)),{jsonPath:s,returnKey:a}})}function se(e,c){const t={},s=[];for(const r of e){const a=V(c,r.jsonPath);t[r.returnKey]={type:I(a)},s.push(r.returnKey)}return{type:"object",properties:t,required:s}}function V(e,c){const t=c.replace(/\[(\d+)\]/g,".$1").split(".");let s=e;for(const r of t){if(s==null||typeof s!="object")return;s=s[r]}return s}function I(e){return e==null||typeof e=="string"?"string":typeof e=="number"?Number.isInteger(e)?"integer":"number":typeof e=="boolean"?"boolean":Array.isArray(e)?"array":typeof e=="object"?"object":"string"}function re(e,c,t){const s=H(c),r=[],a=t?.method??"GET",y=t?.headers??{},f=t?.body,T=new Set(t?.secretHeaders??[]),u={};for(const[o,i]of Object.entries(y)){if(T.has(o)){const p=o.replace(/-/g,"_").toUpperCase();u[o]=`__ENV_${p}__`;continue}const l=o.toLowerCase();l==="authorization"?i.toLowerCase().startsWith("bearer ")?(r.push({name:"apiKey",type:"string"}),u[o]="__BEARER_PARAM__"):(r.push({name:"apiKey",type:"string"}),u[o]="__AUTH_PARAM__"):l.startsWith("x-api")||l.includes("api-key")||l.includes("apikey")?(r.push({name:"apiKey",type:"string"}),u[o]="__APIKEY_PARAM__"):u[o]=i}const $=Object.keys(u).length>0,b=f&&(a==="POST"||a==="PUT"),P=a!=="GET"||$||b;let _;if(!P)_=`const res = await fetch("${e}")`;else{const o=[];if(a!=="GET"&&o.push(` method: "${a}"`),$){const i=Object.entries(u).map(([l,p])=>{if(p==="__BEARER_PARAM__")return` "${l}": "Bearer " + apiKey`;if(p==="__AUTH_PARAM__")return` "${l}": apiKey`;if(p==="__APIKEY_PARAM__")return` "${l}": apiKey`;if(p.startsWith("__ENV_")&&p.endsWith("__")){const M=p.slice(6,-2);return` "${l}": process.env.${M}`}return` "${l}": "${p}"`});o.push(` headers: {
@@ -1 +1 @@
1
- import{b as r,A as c,e as t,F as i,k as m,i as p,a as u,q as d,g as _,K as k,j as s,M as C}from"./index-DYHBy1xj.js";const b={key:0,class:"inline-flex items-center gap-0.5"},f=r({__name:"ModelCapabilityIcons",props:{modelName:{}},setup(o){const l=o,n=c(),a=u(()=>C(n.getCapabilities(l.modelName)));return(g,h)=>a.value.length>0?(s(),t("span",b,[(s(!0),t(i,null,m(a.value,e=>(s(),d(k(e.icon),{key:e.key,class:_(["h-3 w-3 shrink-0",e.color]),title:e.label},null,8,["class","title"]))),128))])):p("",!0)}});export{f as _};
1
+ import{b as r,A as c,e as t,F as i,k as m,i as p,a as u,q as d,g as _,K as k,j as s,M as C}from"./index-534TcCbY.js";const b={key:0,class:"inline-flex items-center gap-0.5"},f=r({__name:"ModelCapabilityIcons",props:{modelName:{}},setup(o){const l=o,n=c(),a=u(()=>C(n.getCapabilities(l.modelName)));return(g,h)=>a.value.length>0?(s(),t("span",b,[(s(!0),t(i,null,m(a.value,e=>(s(),d(k(e.icon),{key:e.key,class:_(["h-3 w-3 shrink-0",e.color]),title:e.label},null,8,["class","title"]))),128))])):p("",!0)}});export{f as _};
@@ -1 +1 @@
1
- import{b as $,e as a,v as D,g as _,f as e,t as s,r as y,j as l,F as k,k as S,i as v,h as w,C as B,D as M,Y as F,l as N,A,B as E,w as T,G as j,u as m,p as b,a as C}from"./index-DYHBy1xj.js";import{d as I,u as L}from"./rag-store-CBWvD3Va.js";import{u as P}from"./storage-store-cx_2Hb_J.js";import{_ as R}from"./StorageGauge.vue_vue_type_style_index_0_lang-Dd3BsCg6.js";import{b as U}from"./format-BqVZ9rwM.js";import"./vector-db-ChAzHl5A.js";const V={class:"space-y-2"},z={class:"text-sm font-medium text-text-primary"},G={class:"text-xs text-text-muted"},q=".pdf,.docx,.txt,.md,.csv",K=$({__name:"DocumentUploadZone",emits:["upload"],setup(u,{emit:n}){const h=n,i=y(!1),c=y(null);function p(d){i.value=!1;const o=Array.from(d.dataTransfer?.files??[]).filter(g=>I(g.name)!==null);o.length>0&&h("upload",o)}function f(d){const t=d.target,g=Array.from(t.files??[]).filter(x=>I(x.name)!==null);g.length>0&&h("upload",g),t.value=""}function r(){c.value?.click()}return(d,t)=>(l(),a("div",{class:_(["relative rounded-xl border-2 border-dashed p-8 text-center transition-colors cursor-pointer",i.value?"border-accent bg-accent/5":"border-border-default hover:border-accent/50"]),onDragover:t[0]||(t[0]=D(o=>i.value=!0,["prevent"])),onDragleave:t[1]||(t[1]=D(o=>i.value=!1,["prevent"])),onDrop:D(p,["prevent"]),onClick:r},[e("input",{ref_key:"fileInput",ref:c,type:"file",accept:q,multiple:"",class:"hidden",onChange:f},null,544),e("div",V,[t[2]||(t[2]=e("div",{class:"text-3xl"},"📄",-1)),e("p",z,s(d.$t("rag.upload.dropText")),1),e("p",G,s(d.$t("rag.upload.supportedFormats")),1)])],34))}}),Y={key:0,class:"rounded-lg bg-surface-overlay p-6 text-center"},Z={class:"text-sm text-text-muted"},H={key:1,class:"space-y-2"},J=["title","onClick"],O={key:0,class:"text-xs"},Q={key:1,class:"h-5 w-5"},W={class:"text-lg"},X={class:"flex-1 min-w-0"},ee={class:"text-sm font-medium text-text-primary truncate"},te={class:"text-xs text-text-muted"},se={key:0,class:"ms-1"},oe={class:"text-xs text-text-muted shrink-0"},re=["title","onClick"],ne=768,ae=$({__name:"DocumentList",props:{documents:{},enabledIds:{}},emits:["toggle","remove"],setup(u,{emit:n}){const h=n;function i(r){return r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:`${(r/(1024*1024)).toFixed(1)} MB`}function c(r){return new Date(r).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function p(r){return r.sizeBytes+r.chunkCount*ne*8}const f={pdf:"📕",docx:"📘",txt:"📝",md:"📋",csv:"📊"};return(r,d)=>u.documents.length===0?(l(),a("div",Y,[e("p",Z,s(r.$t("rag.documents.noDocuments")),1)])):(l(),a("div",H,[(l(!0),a(k,null,S(u.documents,t=>(l(),a("div",{key:t.id,class:"flex items-center gap-3 rounded-lg border border-border-default bg-surface-raised px-4 py-3 transition-colors"},[t.status==="ready"?(l(),a("button",{key:0,class:_(["flex h-5 w-5 shrink-0 items-center justify-center rounded border transition-colors",u.enabledIds.has(t.id)?"border-accent bg-accent text-white":"border-border-default hover:border-accent"]),title:r.$t("rag.documents.toggleContext"),onClick:o=>h("toggle",t.id)},[u.enabledIds.has(t.id)?(l(),a("span",O,"✓")):v("",!0)],10,J)):(l(),a("span",Q)),e("span",W,s(f[t.format]??"📄"),1),e("div",X,[e("p",ee,s(t.name),1),e("p",te,[w(s(i(t.sizeBytes))+" · "+s(t.chunkCount)+" chunks · ~"+s(i(p(t)))+" stored · "+s(t.embeddingModel)+" ",1),t.status!=="ready"?(l(),a("span",se,[d[0]||(d[0]=w(" · ",-1)),e("span",{class:_(t.status==="error"?"text-error":"text-accent")},s(t.status),3)])):v("",!0)])]),e("span",oe,s(c(t.addedAt)),1),e("button",{class:"shrink-0 rounded p-1 text-text-muted hover:text-error transition-colors",title:r.$t("rag.documents.removeDocument"),onClick:o=>h("remove",t.id)}," ✕ ",8,re)]))),128))]))}}),le={class:"space-y-4"},ie={class:"flex gap-2"},de=["placeholder"],ce=["disabled"],ue={key:0,class:"space-y-3"},me={class:"text-xs text-text-muted"},ge={class:"mb-2 flex items-center justify-between"},he={class:"text-xs font-medium text-text-secondary"},pe=["onClick"],fe=["onClick"],xe=$({__name:"RAGSearchPanel",props:{results:{},isSearching:{type:Boolean}},emits:["search"],setup(u,{emit:n}){const h=n,i=y(""),c=y(new Set);function p(){const r=i.value.trim();r&&(c.value=new Set,h("search",r))}function f(r){const d=new Set(c.value);d.has(r)?d.delete(r):d.add(r),c.value=d}return(r,d)=>(l(),a("div",le,[e("div",ie,[B(e("input",{"onUpdate:modelValue":d[0]||(d[0]=t=>i.value=t),type:"text",placeholder:r.$t("rag.search.placeholder"),class:"flex-1 rounded-lg border border-border-default bg-surface px-4 py-2 text-sm text-text-primary placeholder-text-muted outline-none focus:border-accent",onKeydown:F(p,["enter"])},null,40,de),[[M,i.value]]),e("button",{disabled:!i.value.trim()||u.isSearching,class:"rounded-lg bg-accent px-4 py-2 text-sm text-white transition-colors hover:bg-accent-hover disabled:opacity-40",onClick:p},s(u.isSearching?r.$t("rag.search.searching"):r.$t("rag.search.button")),9,ce)]),u.results.length>0?(l(),a("div",ue,[e("p",me,s(u.results.length)+" "+s(r.$t("rag.search.results")),1),(l(!0),a(k,null,S(u.results,(t,o)=>(l(),a("div",{key:o,class:"rounded-lg border border-border-default bg-surface-raised p-4"},[e("div",ge,[e("span",he,s(t.documentName),1),e("span",{class:_(["rounded-full px-2 py-0.5 text-[10px] font-medium",t.score>.8?"bg-success/10 text-success":t.score>.5?"bg-warning/10 text-warning":"bg-surface-overlay text-text-muted"])},s((t.score*100).toFixed(1))+"% ",3)]),e("p",{class:_(["text-sm text-text-primary leading-relaxed whitespace-pre-wrap cursor-pointer",c.value.has(o)?"":"line-clamp-4"]),onClick:g=>f(o)},s(t.chunk.content),11,pe),e("button",{class:"mt-1.5 text-[10px] text-accent hover:underline",onClick:g=>f(o)},s(c.value.has(o)?r.$t("rag.search.showLess"):r.$t("rag.search.showFullChunk")),9,fe)]))),128))])):v("",!0)]))}}),ve={key:0,class:"rounded-lg border border-accent/30 bg-accent/5 p-4"},be={class:"flex items-center justify-between mb-2"},_e={class:"text-sm font-medium text-text-primary"},ye={class:"text-xs text-text-muted"},$e={class:"h-1.5 rounded-full bg-surface-overlay overflow-hidden"},ke=$({__name:"IngestProgress",props:{progress:{}},setup(u){return(n,h)=>u.progress?(l(),a("div",ve,[e("div",be,[e("span",_e,s(u.progress.message),1),e("span",ye,s((u.progress.progress*100).toFixed(0))+"%",1)]),e("div",$e,[e("div",{class:"h-full rounded-full bg-accent transition-all duration-300",style:N({width:`${u.progress.progress*100}%`})},null,4)])])):v("",!0)}}),we={class:"space-y-6"},De={class:"flex items-center justify-between"},Se={class:"text-lg font-semibold text-text-primary"},Ce={class:"text-sm text-text-muted"},Ie={key:0,value:"",disabled:""},Be=["value"],Me={key:0,class:"rounded-lg border border-border-default bg-surface-raised p-3 space-y-2"},Fe={class:"flex items-center justify-between text-xs"},Ne={class:"text-text-secondary font-medium"},Ae={class:"text-text-muted"},Ee={key:1,class:"rounded-lg border border-error/30 bg-error/5 px-4 py-3 text-sm text-error"},Te={class:"mb-3 text-sm font-medium text-text-secondary"},je={class:"mb-3 text-sm font-medium text-text-secondary"},Ge=$({__name:"RAGPage",setup(u){const n=L(),h=A(),i=P(),c=y(""),p=C(()=>i.getDatabaseById("rag")),f=C(()=>n.readyDocuments.reduce((o,g)=>o+g.chunkCount,0));E(async()=>{await h.fetchModels(),c.value=h.embeddingModelNames[0]??"",await n.loadDocuments(),await i.refreshIfStale()}),T(()=>n.isIngesting,(o,g)=>{!o&&g&&i.refresh()});async function r(o){if(c.value)for(const g of o)try{await n.addDocument(g,c.value)}catch{}}async function d(o){await n.removeDocument(o),await i.refresh()}async function t(o){c.value&&await n.search(o,c.value)}return(o,g)=>(l(),a("div",we,[e("div",De,[e("div",null,[e("h2",Se,s(o.$t("rag.title")),1),e("p",Ce,s(o.$t("rag.subtitle")),1)]),B(e("select",{"onUpdate:modelValue":g[0]||(g[0]=x=>c.value=x),class:"rounded-lg border border-border-default bg-surface px-3 py-1.5 text-sm text-text-primary outline-none focus:border-accent"},[m(h).embeddingModelNames.length===0?(l(),a("option",Ie,s(o.$t("rag.modelSelector.noEmbeddingModels")),1)):v("",!0),(l(!0),a(k,null,S(m(h).embeddingModelNames,x=>(l(),a("option",{key:x,value:x},s(x)+" "+s(m(h).capabilityIcons(x)),9,Be))),128))],512),[[j,c.value]])]),m(i).origin?(l(),a("div",Me,[e("div",Fe,[e("span",Ne,s(o.$t("rag.storage.title")),1),e("span",Ae,[w(s(m(n).readyDocuments.length)+" "+s(o.$t("rag.storage.documents"))+" · "+s(f.value.toLocaleString())+" "+s(o.$t("rag.storage.chunks"))+" ",1),p.value?(l(),a(k,{key:0},[w("· "+s(m(U)(p.value.totalBytes))+" "+s(o.$t("rag.storage.stored")),1)],64)):v("",!0)])]),b(R,{used:p.value?.totalBytes??0,total:m(i).origin.quota,label:o.$t("rag.storage.ragStorage"),animating:m(n).isIngesting,compact:""},null,8,["used","total","label","animating"])])):v("",!0),b(K,{onUpload:r}),b(ke,{progress:m(n).ingestProgress},null,8,["progress"]),m(n).error?(l(),a("div",Ee,s(m(n).error),1)):v("",!0),e("div",null,[e("h3",Te,s(o.$t("rag.documents.title"))+" ("+s(m(n).readyDocuments.length)+") ",1),b(ae,{documents:m(n).documents,"enabled-ids":m(n).enabledDocumentIds,onToggle:m(n).toggleDocument,onRemove:d},null,8,["documents","enabled-ids","onToggle"])]),e("div",null,[e("h3",je,s(o.$t("rag.search.title")),1),b(xe,{results:m(n).searchResults,"is-searching":m(n).isSearching,onSearch:t},null,8,["results","is-searching"])])]))}});export{Ge as default};
1
+ import{b as $,e as a,v as D,g as _,f as e,t as s,r as y,j as l,F as k,k as S,i as v,h as w,C as B,D as M,Y as F,l as N,A,B as E,w as T,G as j,u as m,p as b,a as C}from"./index-534TcCbY.js";import{d as I,u as L}from"./rag-store-Bm0nxdec.js";import{u as P}from"./storage-store-6qFwk_C5.js";import{_ as R}from"./StorageGauge.vue_vue_type_style_index_0_lang-DToi3R0q.js";import{b as U}from"./format-BqVZ9rwM.js";import"./vector-db-ChAzHl5A.js";const V={class:"space-y-2"},z={class:"text-sm font-medium text-text-primary"},G={class:"text-xs text-text-muted"},q=".pdf,.docx,.txt,.md,.csv",K=$({__name:"DocumentUploadZone",emits:["upload"],setup(u,{emit:n}){const h=n,i=y(!1),c=y(null);function p(d){i.value=!1;const o=Array.from(d.dataTransfer?.files??[]).filter(g=>I(g.name)!==null);o.length>0&&h("upload",o)}function f(d){const t=d.target,g=Array.from(t.files??[]).filter(x=>I(x.name)!==null);g.length>0&&h("upload",g),t.value=""}function r(){c.value?.click()}return(d,t)=>(l(),a("div",{class:_(["relative rounded-xl border-2 border-dashed p-8 text-center transition-colors cursor-pointer",i.value?"border-accent bg-accent/5":"border-border-default hover:border-accent/50"]),onDragover:t[0]||(t[0]=D(o=>i.value=!0,["prevent"])),onDragleave:t[1]||(t[1]=D(o=>i.value=!1,["prevent"])),onDrop:D(p,["prevent"]),onClick:r},[e("input",{ref_key:"fileInput",ref:c,type:"file",accept:q,multiple:"",class:"hidden",onChange:f},null,544),e("div",V,[t[2]||(t[2]=e("div",{class:"text-3xl"},"📄",-1)),e("p",z,s(d.$t("rag.upload.dropText")),1),e("p",G,s(d.$t("rag.upload.supportedFormats")),1)])],34))}}),Y={key:0,class:"rounded-lg bg-surface-overlay p-6 text-center"},Z={class:"text-sm text-text-muted"},H={key:1,class:"space-y-2"},J=["title","onClick"],O={key:0,class:"text-xs"},Q={key:1,class:"h-5 w-5"},W={class:"text-lg"},X={class:"flex-1 min-w-0"},ee={class:"text-sm font-medium text-text-primary truncate"},te={class:"text-xs text-text-muted"},se={key:0,class:"ms-1"},oe={class:"text-xs text-text-muted shrink-0"},re=["title","onClick"],ne=768,ae=$({__name:"DocumentList",props:{documents:{},enabledIds:{}},emits:["toggle","remove"],setup(u,{emit:n}){const h=n;function i(r){return r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:`${(r/(1024*1024)).toFixed(1)} MB`}function c(r){return new Date(r).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function p(r){return r.sizeBytes+r.chunkCount*ne*8}const f={pdf:"📕",docx:"📘",txt:"📝",md:"📋",csv:"📊"};return(r,d)=>u.documents.length===0?(l(),a("div",Y,[e("p",Z,s(r.$t("rag.documents.noDocuments")),1)])):(l(),a("div",H,[(l(!0),a(k,null,S(u.documents,t=>(l(),a("div",{key:t.id,class:"flex items-center gap-3 rounded-lg border border-border-default bg-surface-raised px-4 py-3 transition-colors"},[t.status==="ready"?(l(),a("button",{key:0,class:_(["flex h-5 w-5 shrink-0 items-center justify-center rounded border transition-colors",u.enabledIds.has(t.id)?"border-accent bg-accent text-white":"border-border-default hover:border-accent"]),title:r.$t("rag.documents.toggleContext"),onClick:o=>h("toggle",t.id)},[u.enabledIds.has(t.id)?(l(),a("span",O,"✓")):v("",!0)],10,J)):(l(),a("span",Q)),e("span",W,s(f[t.format]??"📄"),1),e("div",X,[e("p",ee,s(t.name),1),e("p",te,[w(s(i(t.sizeBytes))+" · "+s(t.chunkCount)+" chunks · ~"+s(i(p(t)))+" stored · "+s(t.embeddingModel)+" ",1),t.status!=="ready"?(l(),a("span",se,[d[0]||(d[0]=w(" · ",-1)),e("span",{class:_(t.status==="error"?"text-error":"text-accent")},s(t.status),3)])):v("",!0)])]),e("span",oe,s(c(t.addedAt)),1),e("button",{class:"shrink-0 rounded p-1 text-text-muted hover:text-error transition-colors",title:r.$t("rag.documents.removeDocument"),onClick:o=>h("remove",t.id)}," ✕ ",8,re)]))),128))]))}}),le={class:"space-y-4"},ie={class:"flex gap-2"},de=["placeholder"],ce=["disabled"],ue={key:0,class:"space-y-3"},me={class:"text-xs text-text-muted"},ge={class:"mb-2 flex items-center justify-between"},he={class:"text-xs font-medium text-text-secondary"},pe=["onClick"],fe=["onClick"],xe=$({__name:"RAGSearchPanel",props:{results:{},isSearching:{type:Boolean}},emits:["search"],setup(u,{emit:n}){const h=n,i=y(""),c=y(new Set);function p(){const r=i.value.trim();r&&(c.value=new Set,h("search",r))}function f(r){const d=new Set(c.value);d.has(r)?d.delete(r):d.add(r),c.value=d}return(r,d)=>(l(),a("div",le,[e("div",ie,[B(e("input",{"onUpdate:modelValue":d[0]||(d[0]=t=>i.value=t),type:"text",placeholder:r.$t("rag.search.placeholder"),class:"flex-1 rounded-lg border border-border-default bg-surface px-4 py-2 text-sm text-text-primary placeholder-text-muted outline-none focus:border-accent",onKeydown:F(p,["enter"])},null,40,de),[[M,i.value]]),e("button",{disabled:!i.value.trim()||u.isSearching,class:"rounded-lg bg-accent px-4 py-2 text-sm text-white transition-colors hover:bg-accent-hover disabled:opacity-40",onClick:p},s(u.isSearching?r.$t("rag.search.searching"):r.$t("rag.search.button")),9,ce)]),u.results.length>0?(l(),a("div",ue,[e("p",me,s(u.results.length)+" "+s(r.$t("rag.search.results")),1),(l(!0),a(k,null,S(u.results,(t,o)=>(l(),a("div",{key:o,class:"rounded-lg border border-border-default bg-surface-raised p-4"},[e("div",ge,[e("span",he,s(t.documentName),1),e("span",{class:_(["rounded-full px-2 py-0.5 text-[10px] font-medium",t.score>.8?"bg-success/10 text-success":t.score>.5?"bg-warning/10 text-warning":"bg-surface-overlay text-text-muted"])},s((t.score*100).toFixed(1))+"% ",3)]),e("p",{class:_(["text-sm text-text-primary leading-relaxed whitespace-pre-wrap cursor-pointer",c.value.has(o)?"":"line-clamp-4"]),onClick:g=>f(o)},s(t.chunk.content),11,pe),e("button",{class:"mt-1.5 text-[10px] text-accent hover:underline",onClick:g=>f(o)},s(c.value.has(o)?r.$t("rag.search.showLess"):r.$t("rag.search.showFullChunk")),9,fe)]))),128))])):v("",!0)]))}}),ve={key:0,class:"rounded-lg border border-accent/30 bg-accent/5 p-4"},be={class:"flex items-center justify-between mb-2"},_e={class:"text-sm font-medium text-text-primary"},ye={class:"text-xs text-text-muted"},$e={class:"h-1.5 rounded-full bg-surface-overlay overflow-hidden"},ke=$({__name:"IngestProgress",props:{progress:{}},setup(u){return(n,h)=>u.progress?(l(),a("div",ve,[e("div",be,[e("span",_e,s(u.progress.message),1),e("span",ye,s((u.progress.progress*100).toFixed(0))+"%",1)]),e("div",$e,[e("div",{class:"h-full rounded-full bg-accent transition-all duration-300",style:N({width:`${u.progress.progress*100}%`})},null,4)])])):v("",!0)}}),we={class:"space-y-6"},De={class:"flex items-center justify-between"},Se={class:"text-lg font-semibold text-text-primary"},Ce={class:"text-sm text-text-muted"},Ie={key:0,value:"",disabled:""},Be=["value"],Me={key:0,class:"rounded-lg border border-border-default bg-surface-raised p-3 space-y-2"},Fe={class:"flex items-center justify-between text-xs"},Ne={class:"text-text-secondary font-medium"},Ae={class:"text-text-muted"},Ee={key:1,class:"rounded-lg border border-error/30 bg-error/5 px-4 py-3 text-sm text-error"},Te={class:"mb-3 text-sm font-medium text-text-secondary"},je={class:"mb-3 text-sm font-medium text-text-secondary"},Ge=$({__name:"RAGPage",setup(u){const n=L(),h=A(),i=P(),c=y(""),p=C(()=>i.getDatabaseById("rag")),f=C(()=>n.readyDocuments.reduce((o,g)=>o+g.chunkCount,0));E(async()=>{await h.fetchModels(),c.value=h.embeddingModelNames[0]??"",await n.loadDocuments(),await i.refreshIfStale()}),T(()=>n.isIngesting,(o,g)=>{!o&&g&&i.refresh()});async function r(o){if(c.value)for(const g of o)try{await n.addDocument(g,c.value)}catch{}}async function d(o){await n.removeDocument(o),await i.refresh()}async function t(o){c.value&&await n.search(o,c.value)}return(o,g)=>(l(),a("div",we,[e("div",De,[e("div",null,[e("h2",Se,s(o.$t("rag.title")),1),e("p",Ce,s(o.$t("rag.subtitle")),1)]),B(e("select",{"onUpdate:modelValue":g[0]||(g[0]=x=>c.value=x),class:"rounded-lg border border-border-default bg-surface px-3 py-1.5 text-sm text-text-primary outline-none focus:border-accent"},[m(h).embeddingModelNames.length===0?(l(),a("option",Ie,s(o.$t("rag.modelSelector.noEmbeddingModels")),1)):v("",!0),(l(!0),a(k,null,S(m(h).embeddingModelNames,x=>(l(),a("option",{key:x,value:x},s(x)+" "+s(m(h).capabilityIcons(x)),9,Be))),128))],512),[[j,c.value]])]),m(i).origin?(l(),a("div",Me,[e("div",Fe,[e("span",Ne,s(o.$t("rag.storage.title")),1),e("span",Ae,[w(s(m(n).readyDocuments.length)+" "+s(o.$t("rag.storage.documents"))+" · "+s(f.value.toLocaleString())+" "+s(o.$t("rag.storage.chunks"))+" ",1),p.value?(l(),a(k,{key:0},[w("· "+s(m(U)(p.value.totalBytes))+" "+s(o.$t("rag.storage.stored")),1)],64)):v("",!0)])]),b(R,{used:p.value?.totalBytes??0,total:m(i).origin.quota,label:o.$t("rag.storage.ragStorage"),animating:m(n).isIngesting,compact:""},null,8,["used","total","label","animating"])])):v("",!0),b(K,{onUpload:r}),b(ke,{progress:m(n).ingestProgress},null,8,["progress"]),m(n).error?(l(),a("div",Ee,s(m(n).error),1)):v("",!0),e("div",null,[e("h3",Te,s(o.$t("rag.documents.title"))+" ("+s(m(n).readyDocuments.length)+") ",1),b(ae,{documents:m(n).documents,"enabled-ids":m(n).enabledDocumentIds,onToggle:m(n).toggleDocument,onRemove:d},null,8,["documents","enabled-ids","onToggle"])]),e("div",null,[e("h3",je,s(o.$t("rag.search.title")),1),b(xe,{results:m(n).searchResults,"is-searching":m(n).isSearching,onSearch:t},null,8,["results","is-searching"])])]))}});export{Ge as default};
@@ -0,0 +1,15 @@
1
+ import{u as xe}from"./session-store-BQ0TF24S.js";import{u as fe}from"./metrics-store-7m97Sb7w.js";import{b as be,a as te,u as ve}from"./agent-store-C6w1zV86.js";import{d as ge,a as ye,b as he}from"./download-WPaeALA4.js";import{_ as ke}from"./TabBar.vue_vue_type_script_setup_true_lang-BtGCdMZK.js";import{b as _e,_ as se,n as $e,s as O,u as we}from"./StatusBadge.vue_vue_type_script_setup_true_lang-BiB0M6lv.js";import{_ as Ce}from"./TokenStreamDisplay.vue_vue_type_script_setup_true_lang-B6juPZsY.js";import{c as B,a as Te,f as Y,e as Me}from"./format-BqVZ9rwM.js";import{C as J,a as K,L as U,P as Se,b as ze,p as oe,c as Q,d as ne,i as Ne,e as Le,B as re,f as ae}from"./index-ClITfJ3t.js";import{b as N,e as l,f as e,t as c,p as w,u as C,a as $,j as s,F as L,k as A,q as P,g as F,h as M,d as Ae,r as S,A as le,i as y,K as Ie,l as H,L as Pe,M as je,B as X,w as V,C as W,G as De,v as ie,T as Fe,X as Re,D as Z,H as Oe,z as Be}from"./index-534TcCbY.js";import{I as j}from"./info-Eg1tUw1x.js";import{u as qe}from"./toolcall-store-C4Trr01T.js";import{u as He}from"./tool-workshop-store-9_FKfdnT.js";import{s as Ee,J as Ve,g as We}from"./JsonTreeNode-C0UNUwZm.js";import{D as Ge}from"./download-pCIjWOn5.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";const Je={class:"rounded-lg border border-border-default bg-surface-raised p-4"},Ke={class:"mb-3 text-sm font-medium text-text-secondary"},Ue={class:"h-40"},Qe=N({__name:"LatencyChart",props:{tokenLatencies:{},title:{}},setup(t){J.register(K,U,Se,ze,oe,Q,ne,Ne);const a=t,r=$(()=>({labels:a.tokenLatencies.map((m,d)=>`${d}`),datasets:[{label:"Token Latency (ms)",data:a.tokenLatencies,borderColor:"#a855f7",backgroundColor:"rgba(168, 85, 247, 0.1)",borderWidth:1.5,pointRadius:0,fill:!0,tension:.3}]})),n={responsive:!0,maintainAspectRatio:!1,plugins:{legend:{display:!1},title:{display:!1}},scales:{x:{display:!1},y:{ticks:{color:"#94a3b8",font:{size:10}},grid:{color:"rgba(71, 85, 105, 0.3)"}}}};return(m,d)=>(s(),l("div",Je,[e("h3",Ke,c(t.title??"Token Latency"),1),e("div",Ue,[w(C(Le),{data:r.value,options:n},null,8,["data"])])]))}}),Xe={class:"rounded-lg border border-border-default bg-surface-raised p-4"},Ye={class:"h-20"},Ze={class:"mt-2 flex gap-4 text-xs text-text-muted"},et=N({__name:"TokenCountBar",props:{promptTokens:{},completionTokens:{}},setup(t){J.register(K,U,re,oe,Q,ne);const a=t,r=$(()=>({labels:["Tokens"],datasets:[{label:"Prompt",data:[a.promptTokens],backgroundColor:"#818cf8"},{label:"Completion",data:[a.completionTokens],backgroundColor:"#a855f7"}]})),n={indexAxis:"y",responsive:!0,maintainAspectRatio:!1,plugins:{legend:{position:"bottom",labels:{color:"#94a3b8",font:{size:11}}}},scales:{x:{stacked:!0,ticks:{color:"#94a3b8",font:{size:10}},grid:{color:"rgba(71, 85, 105, 0.3)"}},y:{stacked:!0,display:!1}}};return(m,d)=>(s(),l("div",Xe,[d[0]||(d[0]=e("h3",{class:"mb-3 text-sm font-medium text-text-secondary"},"Token Distribution",-1)),e("div",Ye,[w(C(ae),{data:r.value,options:n},null,8,["data"])]),e("div",Ze,[e("span",null,"Total: "+c(t.promptTokens+t.completionTokens),1)])]))}}),tt={key:0,class:"space-y-4"},st={class:"grid grid-cols-2 gap-3 lg:grid-cols-3 xl:grid-cols-6"},ot={class:"grid grid-cols-1 gap-3 lg:grid-cols-2"},nt={key:1,class:"rounded-lg border border-border-default bg-surface-raised p-8 text-center text-sm text-text-muted"},rt=N({__name:"MetricsDashboard",props:{metrics:{}},setup(t){const a=t,r=$(()=>{const n=a.metrics;return n?[{label:"Time to First Token",value:B(n.ttftMs),unit:""},{label:"Tokens/Second",value:Te(n.tokensPerSecond),unit:""},{label:"Total Duration",value:B(n.totalDurationMs),unit:""},{label:"Prompt Tokens",value:Y(n.promptTokenCount),unit:"tok"},{label:"Completion Tokens",value:Y(n.completionTokenCount),unit:"tok"},{label:"Model Load",value:B(n.loadDurationMs),unit:""}]:[]});return(n,m)=>t.metrics?(s(),l("div",tt,[e("div",st,[(s(!0),l(L,null,A(r.value,d=>(s(),P(_e,{key:d.label,label:d.label,value:d.value,unit:d.unit},null,8,["label","value","unit"]))),128))]),e("div",ot,[w(Qe,{"token-latencies":t.metrics.tokenLatencies},null,8,["token-latencies"]),w(et,{"prompt-tokens":t.metrics.promptTokenCount,"completion-tokens":t.metrics.completionTokenCount},null,8,["prompt-tokens","completion-tokens"])])])):(s(),l("div",nt," Metrics will appear after generation completes. "))}}),at={class:"flex gap-3"},lt={class:"flex flex-col items-center"},it={class:"flex h-8 w-8 items-center justify-center rounded-full bg-surface-overlay text-sm"},dt={class:"flex-1 pb-4"},ut={class:"flex items-center gap-2 mb-1"},ct={class:"text-xs text-text-muted"},mt={class:"rounded-lg border border-border-default bg-surface p-3 text-sm text-text-primary leading-relaxed"},pt=N({__name:"ReasoningStep",props:{step:{}},setup(t){const a={thought:{color:"text-accent",icon:"💭"},observation:{color:"text-success",icon:"👁"},action:{color:"text-warning",icon:"⚡"},conclusion:{color:"text-[#a78bfa]",icon:"✓"},reflection:{color:"text-[#f472b6]",icon:"↻"}};return(r,n)=>(s(),l("div",at,[e("div",lt,[e("div",it,c(a[t.step.type]?.icon??"•"),1),n[0]||(n[0]=e("div",{class:"flex-1 w-px bg-border-default"},null,-1))]),e("div",dt,[e("div",ut,[e("span",{class:F(["text-xs font-semibold uppercase tracking-wide",a[t.step.type]?.color??"text-text-secondary"])},c(t.step.type),3),e("span",ct," Step "+c(t.step.index+1)+" · "+c(C(B)(t.step.durationMs)),1)]),e("div",mt,c(t.step.content),1)])]))}}),xt={class:"space-y-4"},ft={class:"flex items-center gap-4 rounded-lg border border-border-default bg-surface-raised p-4"},bt={class:"text-sm text-text-secondary"},vt={class:"font-semibold text-text-primary"},gt={class:"flex gap-2"},yt={key:0,class:"space-y-0"},ht={key:1,class:"rounded-lg border border-border-default bg-surface-raised p-8 text-center text-sm text-text-muted"},kt=N({__name:"ReasoningViewer",props:{sessionId:{}},setup(t){const a=t,r=be(),n=$(()=>r.getSteps(a.sessionId)),m=$(()=>{const d={};for(const p of n.value)d[p.type]=(d[p.type]??0)+1;return d});return(d,p)=>(s(),l("div",xt,[e("div",ft,[e("div",bt,[e("span",vt,c(n.value.length),1),p[0]||(p[0]=M(" reasoning steps detected ",-1))]),e("div",gt,[(s(!0),l(L,null,A(m.value,(i,u)=>(s(),l("span",{key:u,class:"rounded-full bg-surface-overlay px-2.5 py-0.5 text-xs text-text-secondary"},c(u)+": "+c(i),1))),128))])]),n.value.length>0?(s(),l("div",yt,[(s(!0),l(L,null,A(n.value,i=>(s(),P(pt,{key:i.id,step:i},null,8,["step"]))),128))])):(s(),l("div",ht,[...p[1]||(p[1]=[e("p",null,"No reasoning steps detected.",-1),e("p",{class:"mt-1"},"Use a model with chain-of-thought support (e.g., DeepSeek-R1) or structured reasoning patterns.",-1)])]))]))}}),de=Ae("introspection",()=>{const t=S(new Map),a=S(new Map),r=S(new Map);function n(x){return t.value.get(x)??null}function m(x,b){t.value.set(x,b)}function d(x){return a.value.get(x)??[]}function p(x,b){a.value.set(x,b)}function i(x){return r.value.get(x)??[]}function u(x,b){r.value.set(x,b)}return{architectureByModel:t,attentionPatterns:a,layerActivations:r,getArchitecture:n,setArchitecture:m,getAttentionPatterns:d,setAttentionPatterns:p,getLayerActivations:i,setLayerActivations:u}});function _t(t,a){const r=a.model_info,n=a.details.family||"unknown",m=R(r,"block_count")??32,d=R(r,"embedding_length")??4096,p=R(r,"attention.head_count")??32,i=R(r,"attention.head_count_kv")??p,u=R(r,"context_length")??4096,x=R(r,"feed_forward_length")??d*4,b=a.details.parameter_size||"0",g=Ct(b),v=Tt(m);return{family:n,blockCount:m,embeddingLength:d,attentionHeadCount:p,kvHeadCount:i,contextLength:u,feedForwardLength:x,layers:v,totalParameters:g,quantization:a.details.quantization_level||"unknown"}}function $t(t,a,r){const n=[],m=t.length,d=Math.min(a,2),p=Math.min(r,2);for(let i=0;i<p;i++)for(let u=0;u<d;u++){const x=[];for(let b=0;b<m;b++){const g=[];for(let k=0;k<m;k++)if(k>b)g.push(0);else{const T=b-k,o=Math.exp(-T*(.1+i*.05)),f=Math.random()*.15,h=k===b?.3:0;g.push(Math.min(1,o+f+h))}const v=g.reduce((k,T)=>k+T,0);x.push(v>0?g.map(k=>k/v):g)}n.push({tokenLabels:t,matrix:x,headIndex:u,layerIndex:i})}return n}function wt(t){const a=[];for(const r of t.layers){const n=Math.sqrt(t.embeddingLength)*(1+Math.random()*.5),m=r.type==="attention"?1:r.type==="feed_forward"?1.3:.8;a.push({layerIndex:r.index,layerName:r.name,meanActivation:(.5+Math.random()*.5)*m,maxActivation:(2+Math.random()*3)*m,norm:n*m*(.8+Math.random()*.4)})}return a}function R(t,a){for(const[r,n]of Object.entries(t))if(r.endsWith(a)&&typeof n=="number")return n}function Ct(t){const a=t.match(/([\d.]+)\s*([BMK])?/i);if(!a)return 0;const r=parseFloat(a[1]),n=(a[2]??"").toUpperCase();return n==="B"?r*1e9:n==="M"?r*1e6:n==="K"?r*1e3:r}function Tt(t){const a=[];let r=0;a.push({index:r++,name:"token_embedding",type:"embedding",parameterCount:0});for(let n=0;n<t;n++)a.push({index:r++,name:`block_${n}_attention`,type:"attention",parameterCount:0}),a.push({index:r++,name:`block_${n}_ffn`,type:"feed_forward",parameterCount:0}),a.push({index:r++,name:`block_${n}_norm`,type:"norm",parameterCount:0});return a.push({index:r++,name:"output",type:"output",parameterCount:0}),a}async function Mt(t){const a=le(),r=de();await a.fetchModelInfo(t);const n=a.getModelDetails(t);if(n){const m=_t(t,n);r.setArchitecture(t,m)}}const St={class:"space-y-4"},zt={key:0,class:"rounded-lg bg-surface p-4"},Nt={class:"flex items-center gap-2 flex-wrap"},Lt=["onMouseenter"],At={key:1,class:"absolute top-full left-1/2 -translate-x-1/2 mt-2 w-56 rounded-lg border border-border-default bg-surface-overlay px-3 py-2 text-xs text-text-secondary shadow-lg z-10"},It={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},Pt={class:"flex items-center gap-1 text-xs text-text-muted"},jt={class:"text-sm font-medium text-text-primary"},Dt={key:0,class:"absolute top-full left-1/2 -translate-x-1/2 mt-2 w-56 rounded-lg border border-border-default bg-surface-overlay px-3 py-2 text-xs text-text-secondary shadow-lg z-10"},Ft={class:"flex items-center gap-1 text-xs text-text-muted"},Rt={class:"text-sm font-medium text-text-primary"},Ot={key:0,class:"absolute top-full left-1/2 -translate-x-1/2 mt-2 w-56 rounded-lg border border-border-default bg-surface-overlay px-3 py-2 text-xs text-text-secondary shadow-lg z-10"},Bt={class:"flex items-center gap-1 text-xs text-text-muted"},qt={class:"text-sm font-medium text-text-primary"},Ht={key:0,class:"absolute top-full left-1/2 -translate-x-1/2 mt-2 w-64 rounded-lg border border-border-default bg-surface-overlay px-3 py-2 text-xs text-text-secondary shadow-lg z-10"},Et={class:"flex items-center gap-1 text-xs text-text-muted"},Vt={class:"text-sm font-medium text-text-primary"},Wt={key:0,class:"absolute top-full left-1/2 -translate-x-1/2 mt-2 w-64 rounded-lg border border-border-default bg-surface-overlay px-3 py-2 text-xs text-text-secondary shadow-lg z-10"},Gt={class:"rounded-lg bg-surface p-4"},Jt={class:"flex items-center gap-1 mb-3"},Kt={class:"text-xs font-medium text-text-muted uppercase tracking-wide"},Ut={key:0,class:"absolute top-full left-1/2 -translate-x-1/2 mt-2 w-64 rounded-lg border border-border-default bg-surface-overlay px-3 py-2 text-xs text-text-secondary shadow-lg z-10"},Qt={class:"flex items-center gap-2 flex-wrap"},Xt=["onMouseenter"],Yt={class:"text-xs text-text-primary"},Zt={class:"text-xs text-text-muted"},es={key:0,class:"absolute top-full left-1/2 -translate-x-1/2 mt-2 w-60 rounded-lg border border-border-default bg-surface-overlay px-3 py-2 text-xs text-text-secondary shadow-lg z-10"},ts={class:"grid grid-cols-2 gap-3 text-xs"},ss={class:"ms-1 text-text-primary"},os={key:0,class:"absolute top-full left-1/2 -translate-x-1/2 mt-2 w-60 rounded-lg border border-border-default bg-surface-overlay px-3 py-2 text-xs text-text-secondary shadow-lg z-10"},ns={class:"ms-1 text-text-primary"},rs={key:0,class:"absolute top-full left-1/2 -translate-x-1/2 mt-2 w-64 rounded-lg border border-border-default bg-surface-overlay px-3 py-2 text-xs text-text-secondary shadow-lg z-10"},as={class:"ms-1 text-text-primary"},ls={key:0,class:"absolute top-full left-1/2 -translate-x-1/2 mt-2 w-60 rounded-lg border border-border-default bg-surface-overlay px-3 py-2 text-xs text-text-secondary shadow-lg z-10"},is={class:"ms-1 text-text-primary"},ds={key:0,class:"absolute top-full left-1/2 -translate-x-1/2 mt-2 w-64 rounded-lg border border-border-default bg-surface-overlay px-3 py-2 text-xs text-text-secondary shadow-lg z-10"},us={key:1,class:"rounded-lg bg-surface"},cs={key:0,class:"border-t border-border-default px-4 pb-4 pt-2"},ms={class:"w-full text-xs"},ps={class:"py-1.5 pe-4 text-text-muted font-mono"},xs={class:"py-1.5 text-text-primary font-mono"},fs={key:2,class:"rounded-lg bg-surface"},bs={key:0,class:"border-t border-border-default px-4 pb-4 pt-2"},vs={class:"overflow-auto rounded-lg bg-surface-raised p-3 text-xs text-text-secondary font-mono leading-relaxed"},gs=N({__name:"ModelArchitectureDiagram",props:{architecture:{},modelName:{}},setup(t){const a=t,r=le(),n=$(()=>a.modelName?r.getModelDetails(a.modelName)??null:null),m=$(()=>{if(!n.value?.parameters)return null;const T=Pe(n.value.parameters);return Object.keys(T).length>0?T:null}),d=$(()=>n.value?.template??null),p=S(!1),i=S(!1),u=$(()=>a.modelName?je(r.getCapabilities(a.modelName)):[]),x={embedding:"#818cf8",attention:"#a855f7",feed_forward:"#fb923c",norm:"#94a3b8",output:"#4ade80"},b=$(()=>{const T=a.architecture;return[{label:"Embedding",color:x.embedding,count:1,desc:"Converts input tokens into dense numerical vectors the model can process"},{label:"Attention",color:x.attention,count:T.blockCount,desc:"Lets each token attend to every other token to capture relationships and context"},{label:"FFN",color:x.feed_forward,count:T.blockCount,desc:"Feed-Forward Network — applies non-linear transformations to refine representations"},{label:"LayerNorm",color:x.norm,count:T.blockCount,desc:"Normalizes activations between layers to stabilize and speed up training"},{label:"Output",color:x.output,count:1,desc:"Projects the final hidden state back to vocabulary size to predict the next token"}]}),g=S(null);function v(T){g.value=T}function k(){g.value=null}return(T,o)=>(s(),l("div",St,[u.value.length>0?(s(),l("div",zt,[o[12]||(o[12]=e("h4",{class:"text-xs font-medium text-text-muted uppercase tracking-wide mb-3"},"Capabilities",-1)),e("div",Nt,[(s(!0),l(L,null,A(u.value,f=>(s(),l("div",{key:f.key,class:"relative flex items-center gap-1.5 rounded-lg border border-border-default px-3 py-1.5",onMouseenter:h=>v("cap-"+f.key),onMouseleave:k},[f.icon?(s(),P(Ie(f.icon),{key:0,class:F(["h-3.5 w-3.5 shrink-0",f.color])},null,8,["class"])):y("",!0),e("span",{class:F(["text-xs font-medium",f.color])},c(f.label),3),g.value==="cap-"+f.key?(s(),l("div",At,[M(c(f.desc)+" ",1),o[11]||(o[11]=e("div",{class:"absolute bottom-full left-1/2 -translate-x-1/2 -mb-px border-4 border-transparent border-b-surface-overlay"},null,-1))])):y("",!0)],40,Lt))),128))])])):y("",!0),e("div",It,[e("div",{class:"relative rounded-lg bg-surface p-3",onMouseenter:o[0]||(o[0]=f=>v("family")),onMouseleave:k},[e("div",Pt,[o[13]||(o[13]=M(" Family ",-1)),w(C(j),{class:"h-3 w-3"})]),e("div",jt,c(t.architecture.family),1),g.value==="family"?(s(),l("div",Dt,[...o[14]||(o[14]=[M(" The base model architecture family (e.g. llama, qwen). Models in the same family share the same neural network design. ",-1),e("div",{class:"absolute bottom-full left-1/2 -translate-x-1/2 -mb-px border-4 border-transparent border-b-surface-overlay"},null,-1)])])):y("",!0)],32),e("div",{class:"relative rounded-lg bg-surface p-3",onMouseenter:o[1]||(o[1]=f=>v("params")),onMouseleave:k},[e("div",Ft,[o[15]||(o[15]=M(" Parameters ",-1)),w(C(j),{class:"h-3 w-3"})]),e("div",Rt,c(C(Me)(t.architecture.totalParameters)),1),g.value==="params"?(s(),l("div",Ot,[...o[16]||(o[16]=[M(" Total number of trainable weights in the model. More parameters generally means greater capability but requires more memory and compute. ",-1),e("div",{class:"absolute bottom-full left-1/2 -translate-x-1/2 -mb-px border-4 border-transparent border-b-surface-overlay"},null,-1)])])):y("",!0)],32),e("div",{class:"relative rounded-lg bg-surface p-3",onMouseenter:o[2]||(o[2]=f=>v("ctx")),onMouseleave:k},[e("div",Bt,[o[17]||(o[17]=M(" Context Length ",-1)),w(C(j),{class:"h-3 w-3"})]),e("div",qt,c(t.architecture.contextLength.toLocaleString()),1),g.value==="ctx"?(s(),l("div",Ht,[...o[18]||(o[18]=[M(" Maximum number of tokens (prompt + response) the model can process in a single conversation. Longer context allows more detailed instructions and longer conversations. ",-1),e("div",{class:"absolute bottom-full left-1/2 -translate-x-1/2 -mb-px border-4 border-transparent border-b-surface-overlay"},null,-1)])])):y("",!0)],32),e("div",{class:"relative rounded-lg bg-surface p-3",onMouseenter:o[3]||(o[3]=f=>v("quant")),onMouseleave:k},[e("div",Et,[o[19]||(o[19]=M(" Quantization ",-1)),w(C(j),{class:"h-3 w-3"})]),e("div",Vt,c(t.architecture.quantization),1),g.value==="quant"?(s(),l("div",Wt,[...o[20]||(o[20]=[M(" How model weights are compressed. Q4_K_M means 4-bit quantization with K-quant medium quality — smaller file size and faster inference with a small quality trade-off vs full precision (F16/F32). ",-1),e("div",{class:"absolute bottom-full left-1/2 -translate-x-1/2 -mb-px border-4 border-transparent border-b-surface-overlay"},null,-1)])])):y("",!0)],32)]),e("div",Gt,[e("div",Jt,[e("h4",Kt,"Layer Structure ("+c(t.architecture.blockCount)+" blocks)",1),e("div",{class:"relative",onMouseenter:o[4]||(o[4]=f=>v("layers")),onMouseleave:k},[w(C(j),{class:"h-3 w-3 text-text-muted"}),g.value==="layers"?(s(),l("div",Ut,[...o[21]||(o[21]=[M(" Transformer models are built from repeated blocks. Each block contains attention, feed-forward, and normalization layers. More blocks = deeper model. ",-1),e("div",{class:"absolute bottom-full left-1/2 -translate-x-1/2 -mb-px border-4 border-transparent border-b-surface-overlay"},null,-1)])])):y("",!0)],32)]),e("div",Qt,[(s(!0),l(L,null,A(b.value,f=>(s(),l("div",{key:f.label,class:"relative flex items-center gap-2 rounded-lg border border-border-default px-3 py-2",onMouseenter:h=>v("block-"+f.label),onMouseleave:k},[e("div",{class:"h-3 w-3 rounded-sm",style:H({backgroundColor:f.color})},null,4),e("span",Yt,c(f.label),1),e("span",Zt,"×"+c(f.count),1),g.value==="block-"+f.label?(s(),l("div",es,[M(c(f.desc)+" ",1),o[22]||(o[22]=e("div",{class:"absolute bottom-full left-1/2 -translate-x-1/2 -mb-px border-4 border-transparent border-b-surface-overlay"},null,-1))])):y("",!0)],40,Xt))),128))])]),e("div",ts,[e("div",{class:"relative rounded-lg bg-surface p-3",onMouseenter:o[5]||(o[5]=f=>v("aheads")),onMouseleave:k},[o[24]||(o[24]=e("span",{class:"text-text-muted"},"Attention Heads",-1)),w(C(j),{class:"inline ms-1 h-3 w-3 text-text-muted align-text-top"}),e("span",ss,c(t.architecture.attentionHeadCount),1),g.value==="aheads"?(s(),l("div",os,[...o[23]||(o[23]=[M(" Number of parallel attention computations per layer. Each head learns to focus on different patterns (syntax, semantics, position, etc.). ",-1),e("div",{class:"absolute bottom-full left-1/2 -translate-x-1/2 -mb-px border-4 border-transparent border-b-surface-overlay"},null,-1)])])):y("",!0)],32),e("div",{class:"relative rounded-lg bg-surface p-3",onMouseenter:o[6]||(o[6]=f=>v("kvheads")),onMouseleave:k},[o[26]||(o[26]=e("span",{class:"text-text-muted"},"KV Heads",-1)),w(C(j),{class:"inline ms-1 h-3 w-3 text-text-muted align-text-top"}),e("span",ns,c(t.architecture.kvHeadCount),1),g.value==="kvheads"?(s(),l("div",rs,[...o[25]||(o[25]=[M(" Key-Value heads used in Grouped Query Attention (GQA). Fewer KV heads than attention heads means memory savings — multiple query heads share the same key/value projections. ",-1),e("div",{class:"absolute bottom-full left-1/2 -translate-x-1/2 -mb-px border-4 border-transparent border-b-surface-overlay"},null,-1)])])):y("",!0)],32),e("div",{class:"relative rounded-lg bg-surface p-3",onMouseenter:o[7]||(o[7]=f=>v("embdim")),onMouseleave:k},[o[28]||(o[28]=e("span",{class:"text-text-muted"},"Embedding Dim",-1)),w(C(j),{class:"inline ms-1 h-3 w-3 text-text-muted align-text-top"}),e("span",as,c(t.architecture.embeddingLength),1),g.value==="embdim"?(s(),l("div",ls,[...o[27]||(o[27]=[M(" Size of the vector representing each token inside the model. Larger dimensions can capture richer semantic information but increase memory and compute. ",-1),e("div",{class:"absolute bottom-full left-1/2 -translate-x-1/2 -mb-px border-4 border-transparent border-b-surface-overlay"},null,-1)])])):y("",!0)],32),e("div",{class:"relative rounded-lg bg-surface p-3",onMouseenter:o[8]||(o[8]=f=>v("ffndim")),onMouseleave:k},[o[30]||(o[30]=e("span",{class:"text-text-muted"},"FFN Dim",-1)),w(C(j),{class:"inline ms-1 h-3 w-3 text-text-muted align-text-top"}),e("span",is,c(t.architecture.feedForwardLength),1),g.value==="ffndim"?(s(),l("div",ds,[...o[29]||(o[29]=[M(` Width of the feed-forward network's hidden layer. Typically 2-4x the embedding dimension. This is where much of the model's "knowledge" is stored as learned patterns. `,-1),e("div",{class:"absolute bottom-full left-1/2 -translate-x-1/2 -mb-px border-4 border-transparent border-b-surface-overlay"},null,-1)])])):y("",!0)],32)]),m.value?(s(),l("div",us,[e("button",{class:"flex w-full items-center justify-between p-4 text-start",onClick:o[9]||(o[9]=f=>p.value=!p.value)},[o[32]||(o[32]=e("h4",{class:"text-xs font-medium text-text-muted uppercase tracking-wide"},"Model Defaults",-1)),(s(),l("svg",{class:F(["h-4 w-4 text-text-muted transition-transform",p.value?"rotate-180":""]),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[...o[31]||(o[31]=[e("path",{d:"M6 9l6 6 6-6"},null,-1)])],2))]),p.value?(s(),l("div",cs,[e("table",ms,[(s(!0),l(L,null,A(m.value,(f,h)=>(s(),l("tr",{key:h,class:"border-b border-border-default/50 last:border-0"},[e("td",ps,c(h),1),e("td",xs,c(f),1)]))),128))])])):y("",!0)])):y("",!0),d.value?(s(),l("div",fs,[e("button",{class:"flex w-full items-center justify-between p-4 text-start",onClick:o[10]||(o[10]=f=>i.value=!i.value)},[o[34]||(o[34]=e("h4",{class:"text-xs font-medium text-text-muted uppercase tracking-wide"},"Chat Template",-1)),(s(),l("svg",{class:F(["h-4 w-4 text-text-muted transition-transform",i.value?"rotate-180":""]),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[...o[33]||(o[33]=[e("path",{d:"M6 9l6 6 6-6"},null,-1)])],2))]),i.value?(s(),l("div",bs,[e("pre",vs,c(d.value),1)])):y("",!0)])):y("",!0)]))}}),ys={class:"space-y-3"},hs={class:"flex items-center justify-between"},ks=["value"],_s={key:0,class:"overflow-auto rounded-lg border border-border-default bg-surface p-2"},$s=N({__name:"AttentionHeatmap",props:{patterns:{}},setup(t){const a=t,r=S(0),n=S(null),m=$(()=>a.patterns[r.value]??null);function d(){const p=n.value,i=m.value;if(!p||!i)return;const u=p.getContext("2d");if(!u)return;const x=i.matrix.length,b=Math.min(Math.floor(400/x),20),g=x*b;p.width=g,p.height=g;for(let v=0;v<x;v++)for(let k=0;k<x;k++){const T=i.matrix[v]?.[k]??0,o=Math.floor(T*255);u.fillStyle=`rgb(${Math.floor(56+T*100)}, ${Math.floor(100+o*.5)}, ${o})`,u.fillRect(k*b,v*b,b,b)}}return X(d),V([m],d),(p,i)=>(s(),l("div",ys,[e("div",hs,[i[1]||(i[1]=e("div",{class:"flex items-center gap-2"},[e("h4",{class:"text-sm font-medium text-text-secondary"},"Attention Pattern"),e("span",{class:"rounded-full bg-warning/20 px-2 py-0.5 text-xs text-warning"},"Illustrative")],-1)),t.patterns.length>1?W((s(),l("select",{key:0,"onUpdate:modelValue":i[0]||(i[0]=u=>r.value=u),class:"rounded border border-border-default bg-surface px-2 py-1 text-xs text-text-primary"},[(s(!0),l(L,null,A(t.patterns,(u,x)=>(s(),l("option",{key:x,value:x}," Layer "+c(u.layerIndex)+" / Head "+c(u.headIndex),9,ks))),128))],512)),[[De,r.value,void 0,{number:!0}]]):y("",!0)]),m.value?(s(),l("div",_s,[e("canvas",{ref_key:"canvasRef",ref:n,class:"max-w-full"},null,512)])):y("",!0),i[2]||(i[2]=e("p",{class:"text-xs text-text-muted leading-relaxed"},[M(" This is a "),e("strong",{class:"text-warning"},"synthetic illustration"),M(" of how attention patterns work in transformer models — it shows causal masking (tokens can only attend to previous tokens) and positional decay (nearby tokens get more attention). Real attention weights are not available through the Ollama API, so this visualization demonstrates the concept rather than reflecting actual model behavior. ")],-1))]))}}),ws={class:"space-y-3"},Cs={class:"h-48 rounded-lg border border-border-default bg-surface-raised p-4"},Ts=N({__name:"LayerActivationChart",props:{activations:{}},setup(t){J.register(K,U,re,Q);const a=t,r=$(()=>({labels:a.activations.map(m=>m.layerName.replace(/^block_\d+_/,"")),datasets:[{label:"Norm",data:a.activations.map(m=>m.norm),backgroundColor:"#a855f7"}]})),n={responsive:!0,maintainAspectRatio:!1,plugins:{legend:{display:!1}},scales:{x:{display:!1},y:{ticks:{color:"#94a3b8",font:{size:10}},grid:{color:"rgba(71, 85, 105, 0.3)"}}}};return(m,d)=>(s(),l("div",ws,[d[0]||(d[0]=e("div",{class:"flex items-center gap-2"},[e("h4",{class:"text-sm font-medium text-text-secondary"},"Layer Activation Norms"),e("span",{class:"rounded-full bg-warning/20 px-2 py-0.5 text-xs text-warning"},"Simulated")],-1)),e("div",Cs,[w(C(ae),{data:r.value,options:n},null,8,["data"])]),d[1]||(d[1]=e("p",{class:"text-xs text-text-muted leading-relaxed"},[M(" This is a "),e("strong",{class:"text-warning"},"simulated visualization"),M(" of activation norms across the model's layers. In a real model, these norms reveal how much each layer contributes to the output — unusually high norms can indicate exploding gradients or bottleneck layers, while low norms may suggest underutilized capacity. Actual activation data requires hooking into the inference engine, which the Ollama API does not expose. ")],-1))]))}}),Ms={class:"space-y-6"},Ss={key:0},zs={key:1},Ns={key:2},Ls={key:3,class:"rounded-lg border border-border-default bg-surface-raised p-8 text-center text-sm text-text-muted"},As=N({__name:"IntrospectionPanel",props:{sessionId:{},modelName:{}},setup(t){const a=t,r=de(),n=te(),m=$(()=>r.getArchitecture(a.modelName)),d=$(()=>r.getAttentionPatterns(a.sessionId)),p=$(()=>r.getLayerActivations(a.sessionId));return X(async()=>{m.value||await Mt(a.modelName);const i=m.value;if(i){if(d.value.length===0){const x=n.getTokens(a.sessionId).slice(0,30).map(b=>b.text);if(x.length>0){const b=$t(x,i.attentionHeadCount,i.blockCount);r.setAttentionPatterns(a.sessionId,b)}}if(p.value.length===0){const u=wt(i);r.setLayerActivations(a.sessionId,u)}}}),(i,u)=>(s(),l("div",Ms,[m.value?(s(),l("div",Ss,[u[0]||(u[0]=e("h3",{class:"mb-3 text-sm font-medium text-text-secondary"},"Model Architecture",-1)),w(gs,{architecture:m.value,"model-name":t.modelName},null,8,["architecture","model-name"])])):y("",!0),d.value.length>0?(s(),l("div",zs,[w($s,{patterns:d.value},null,8,["patterns"])])):y("",!0),p.value.length>0?(s(),l("div",Ns,[w(Ts,{activations:p.value},null,8,["activations"])])):y("",!0),m.value?y("",!0):(s(),l("div",Ls," Loading model introspection data... "))]))}}),Is={class:"overflow-auto rounded-lg bg-surface p-3 text-xs text-text-secondary font-mono max-h-80"},G=N({__name:"JsonViewer",props:{data:{},maxDepth:{}},setup(t){const a=t,r=$(()=>{try{return JSON.stringify(a.data,null,2)}catch{return String(a.data)}});return(n,m)=>(s(),l("pre",Is,c(r.value),1))}}),Ps={class:"rounded-lg border border-border-default bg-surface-raised"},js={class:"flex items-center gap-3"},Ds={class:"text-sm font-medium text-text-primary"},Fs={class:"ms-2 text-xs text-text-muted"},Rs={class:"flex items-center gap-2"},Os={key:0,class:"border-t border-border-default p-4 space-y-3"},Bs={key:0},qs={key:1},Hs={class:"rounded-lg bg-error/10 p-3 text-xs text-error"},Es=N({__name:"ToolCallCard",props:{entry:{}},emits:["optimize"],setup(t,{emit:a}){const r=t,n=a,m=$(()=>r.entry.status==="completed"&&r.entry.result!=null&&typeof r.entry.result=="object"),d=S(!1);return(p,i)=>(s(),l("div",Ps,[e("button",{class:"flex w-full items-center justify-between px-4 py-3 text-start hover:bg-surface-overlay transition-colors",onClick:i[0]||(i[0]=u=>d.value=!d.value)},[e("div",js,[i[2]||(i[2]=e("span",{class:"text-base"},"⚡",-1)),e("div",null,[e("span",Ds,c(t.entry.functionName),1),e("span",Fs,c(t.entry.durationMs!=null?C(B)(t.entry.durationMs):"pending"),1)])]),e("div",Rs,[w(se,{status:t.entry.status},null,8,["status"]),e("span",{class:F(["text-text-muted transition-transform text-xs",{"rotate-180":d.value}])},"▾",2)])]),d.value?(s(),l("div",Os,[e("div",null,[i[3]||(i[3]=e("div",{class:"text-xs font-medium text-text-muted uppercase tracking-wide mb-1"},"Arguments",-1)),w(G,{data:t.entry.arguments},null,8,["data"])]),t.entry.result!==void 0?(s(),l("div",Bs,[i[4]||(i[4]=e("div",{class:"text-xs font-medium text-text-muted uppercase tracking-wide mb-1"},"Result",-1)),w(G,{data:t.entry.result},null,8,["data"])])):y("",!0),t.entry.error?(s(),l("div",qs,[i[5]||(i[5]=e("div",{class:"text-xs font-medium text-error uppercase tracking-wide mb-1"},"Error",-1)),e("pre",Hs,c(t.entry.error),1)])):y("",!0),m.value?(s(),l("button",{key:2,class:"mt-1 rounded-md border border-border-default px-3 py-1.5 text-xs font-medium text-accent hover:bg-surface-overlay transition-colors",onClick:i[1]||(i[1]=ie(u=>n("optimize",t.entry),["stop"]))}," Optimize this Tool ")):y("",!0)])):y("",!0)]))}}),Vs={class:"space-y-4"},Ws={class:"flex items-center gap-4 rounded-lg border border-border-default bg-surface-raised p-4"},Gs={class:"text-sm text-text-secondary"},Js={class:"font-semibold text-text-primary"},Ks={key:0,class:"text-sm text-text-secondary"},Us={class:"text-text-primary"},Qs={key:0,class:"space-y-3"},Xs={key:1,class:"rounded-lg border border-border-default bg-surface-raised p-8 text-center text-sm text-text-muted"},Ys=N({__name:"ToolCallTimeline",props:{sessionId:{}},emits:["optimize"],setup(t,{emit:a}){const r=t,n=a,m=qe(),d=$(()=>m.getToolCalls(r.sessionId)),p=$(()=>d.value.reduce((i,u)=>i+(u.durationMs??0),0));return(i,u)=>(s(),l("div",Vs,[e("div",Ws,[e("div",Gs,[e("span",Js,c(d.value.length),1),u[1]||(u[1]=M(" tool calls ",-1))]),p.value>0?(s(),l("div",Ks,[u[2]||(u[2]=M(" Total: ",-1)),e("span",Us,c(C(B)(p.value)),1)])):y("",!0)]),d.value.length>0?(s(),l("div",Qs,[(s(!0),l(L,null,A(d.value,x=>(s(),P(Es,{key:x.id,entry:x,onOptimize:u[0]||(u[0]=b=>n("optimize",b))},null,8,["entry"]))),128))])):(s(),l("div",Xs,[...u[3]||(u[3]=[e("p",null,"No tool calls in this session.",-1),e("p",{class:"mt-1"},"Use chat mode with tool definitions to see tool call activity.",-1)])]))]))}});function Zs(t){const a=ve(),r=$(()=>a.getGraph(t.value)),n=S(800),m=S(400),d=$(()=>{const i=r.value?.nodes??[];if(i.length===0)return[];const u=180,x=60,b=60,g=m.value/2,v=i.length*(u+b);return n.value=Math.max(800,v+100),i.map((k,T)=>({...k,x:50+T*(u+b),y:g-x/2}))}),p=$(()=>{const i=r.value?.edges??[],u=new Map(d.value.map(x=>[x.id,x]));return i.map(x=>{const b=u.get(x.source),g=u.get(x.target);return!b||!g?null:{...x,x1:b.x+180,y1:b.y+30,x2:g.x,y2:g.y+30}}).filter(x=>x!==null)});return{graph:r,layoutNodes:d,layoutEdges:p,svgWidth:n,svgHeight:m}}const eo=["transform"],to=["stroke"],so={x:"12",y:"24",class:"fill-text-primary text-xs font-medium","font-size":"12"},oo={x:"12",y:"44",class:"fill-text-secondary text-xs","font-size":"11"},no=N({__name:"AgentNode",props:{node:{},selected:{type:Boolean}},emits:["select"],setup(t){const a=t,r=$(()=>$e[a.node.type]??"#94a3b8"),n={start:"▶",llm_call:"◈",tool_call:"⚡",decision:"◇",output:"■",error:"✕"};return(m,d)=>(s(),l("g",{transform:`translate(${t.node.x}, ${t.node.y})`,class:"cursor-pointer",onClick:d[0]||(d[0]=p=>m.$emit("select",t.node.id))},[e("rect",{width:"180",height:"60",rx:"8",class:F(["fill-surface-raised stroke-2",{"stroke-[3]":t.selected}]),stroke:r.value},null,10,to),e("text",so,c(n[t.node.type]??"•")+" "+c(t.node.type),1),e("text",oo,c(t.node.label.slice(0,22))+c(t.node.label.length>22?"...":""),1)],8,eo))}}),ro={key:0,class:"rounded-lg border border-border-default bg-surface-raised p-4 space-y-3"},ao={class:"text-sm font-medium text-text-primary"},lo={class:"grid grid-cols-2 gap-2 text-xs text-text-secondary"},io={class:"text-text-primary"},uo={class:"text-text-primary"},co={key:0},mo=N({__name:"AgentStateDiff",props:{node:{}},setup(t){return(a,r)=>t.node?(s(),l("div",ro,[e("h4",ao,c(t.node.label),1),e("div",lo,[e("div",null,[r[0]||(r[0]=M("Type: ",-1)),e("span",io,c(t.node.type),1)]),e("div",null,[r[1]||(r[1]=M("Step: ",-1)),e("span",uo,c(t.node.stepIndex),1)])]),Object.keys(t.node.state).length>0?(s(),l("div",co,[r[2]||(r[2]=e("div",{class:"text-xs font-medium text-text-muted uppercase tracking-wide mb-1"},"State",-1)),w(G,{data:t.node.state},null,8,["data"])])):y("",!0)])):y("",!0)}}),po={class:"space-y-4"},xo={key:0,class:"flex gap-4"},fo={class:"flex-1 overflow-auto rounded-lg border border-border-default bg-surface"},bo=["width","height"],vo=["x1","y1","x2","y2"],go={class:"w-72 shrink-0"},yo={key:0,class:"rounded-lg border border-border-default bg-surface-raised p-4 text-center text-sm text-text-muted"},ho={key:1,class:"rounded-lg border border-border-default bg-surface-raised p-8 text-center text-sm text-text-muted"},ko=N({__name:"AgentGraphView",props:{sessionId:{}},setup(t){const a=t,r=$(()=>a.sessionId),{layoutNodes:n,layoutEdges:m,svgWidth:d,svgHeight:p}=Zs(r),i=S(null),u=$(()=>i.value?n.value.find(x=>x.id===i.value)??null:null);return(x,b)=>(s(),l("div",po,[C(n).length>0?(s(),l("div",xo,[e("div",fo,[(s(),l("svg",{width:C(d),height:C(p),class:"min-w-full"},[(s(!0),l(L,null,A(C(m),g=>(s(),l("line",{key:g.id,x1:g.x1,y1:g.y1,x2:g.x2,y2:g.y2,class:"stroke-border-default","stroke-width":"2","marker-end":"url(#arrowhead)"},null,8,vo))),128)),b[1]||(b[1]=e("defs",null,[e("marker",{id:"arrowhead",markerWidth:"10",markerHeight:"7",refX:"10",refY:"3.5",orient:"auto"},[e("polygon",{points:"0 0, 10 3.5, 0 7",class:"fill-border-default"})])],-1)),(s(!0),l(L,null,A(C(n),g=>(s(),P(no,{key:g.id,node:g,selected:i.value===g.id,onSelect:b[0]||(b[0]=v=>i.value=v)},null,8,["node","selected"]))),128))],8,bo))]),e("div",go,[w(mo,{node:u.value},null,8,["node"]),u.value?y("",!0):(s(),l("div",yo," Click a node to inspect its state. "))])])):(s(),l("div",ho,[...b[2]||(b[2]=[e("p",null,"No agent graph data for this session.",-1),e("p",{class:"mt-1"},"Agent graph nodes are created during generation.",-1)])]))]))}}),_o={class:"rounded-lg border border-border-default bg-surface-raised overflow-hidden"},$o={class:"flex items-center justify-between px-4 py-2 border-b border-border-default"},wo={class:"flex items-center gap-2"},Co={class:"text-sm font-medium text-text-primary"},To={class:"rounded-full bg-surface-overlay px-2 py-0.5 text-xs text-text-muted"},Mo={class:"flex items-center gap-3 text-xs text-text-secondary"},So={class:"text-text-muted"},zo={class:"h-1 bg-surface"},No={class:"px-4 py-3 text-xs text-text-secondary font-mono whitespace-pre-wrap max-h-40 overflow-auto"},Lo=N({__name:"PromptSection",props:{section:{},totalTokens:{}},setup(t){const r=O[t.section.type]??O.unknown;return(n,m)=>(s(),l("div",_o,[e("div",$o,[e("div",wo,[e("div",{class:"h-3 w-3 rounded-sm",style:H({backgroundColor:C(r)})},null,4),e("span",Co,c(t.section.label),1),e("span",To,c(t.section.type),1)]),e("div",Mo,[e("span",null,"~"+c(t.section.tokenCount)+" tokens",1),e("span",So,c(t.section.percentage.toFixed(1))+"%",1)])]),e("div",zo,[e("div",{class:"h-full transition-all",style:H({width:`${t.section.percentage}%`,backgroundColor:C(r)})},null,4)]),e("pre",No,c(t.section.content),1)]))}}),Ao={class:"rounded-lg border border-border-default bg-surface-raised p-4"},Io={class:"text-xs font-medium text-text-muted uppercase tracking-wide mb-3"},Po={class:"flex h-6 overflow-hidden rounded-lg"},jo=["title"],Do={class:"mt-3 flex flex-wrap gap-3 text-xs"},Fo={class:"text-text-secondary"},Ro={class:"text-text-muted"},Oo=N({__name:"PromptTokenCount",props:{sections:{},totalTokens:{}},setup(t){return(a,r)=>(s(),l("div",Ao,[e("h4",Io," Token Distribution (~"+c(t.totalTokens)+" total) ",1),e("div",Po,[(s(!0),l(L,null,A(t.sections,n=>(s(),l("div",{key:n.id,class:"transition-all",style:H({width:`${n.percentage}%`,backgroundColor:C(O)[n.type]??C(O).unknown,minWidth:n.percentage>0?"2px":"0"}),title:`${n.label}: ~${n.tokenCount} tokens (${n.percentage.toFixed(1)}%)`},null,12,jo))),128))]),e("div",Do,[(s(!0),l(L,null,A(t.sections,n=>(s(),l("div",{key:n.id,class:"flex items-center gap-1.5"},[e("div",{class:"h-2.5 w-2.5 rounded-sm",style:H({backgroundColor:C(O)[n.type]??C(O).unknown})},null,4),e("span",Fo,c(n.label),1),e("span",Ro,"("+c(n.percentage.toFixed(0))+"%)",1)]))),128))])]))}}),Bo={key:0,class:"space-y-4"},qo={class:"space-y-3"},Ho={key:0,class:"rounded-lg border border-border-default bg-surface-raised p-4"},Eo={class:"space-y-2"},Vo={class:"flex items-center gap-2"},Wo={class:"rounded-full bg-surface-overlay px-2 py-0.5 text-xs text-text-muted"},Go={class:"text-text-secondary truncate max-w-md"},Jo={class:"text-xs text-text-muted"},Ko={key:1,class:"rounded-lg border border-border-default bg-surface-raised p-8 text-center text-sm text-text-muted"},Uo=N({__name:"PromptInspector",props:{sessionId:{}},setup(t){const a=t,r=we(),n=$(()=>r.getAnatomy(a.sessionId)),m=$(()=>r.getSections(a.sessionId));return(d,p)=>n.value?(s(),l("div",Bo,[w(Oo,{sections:m.value,"total-tokens":n.value.totalTokenCount},null,8,["sections","total-tokens"]),e("div",qo,[(s(!0),l(L,null,A(m.value,i=>(s(),P(Lo,{key:i.id,section:i,"total-tokens":n.value.totalTokenCount},null,8,["section","total-tokens"]))),128))]),n.value.messages&&n.value.messages.length>0?(s(),l("div",Ho,[p[0]||(p[0]=e("h4",{class:"text-xs font-medium text-text-muted uppercase tracking-wide mb-3"},"Message Breakdown",-1)),e("div",Eo,[(s(!0),l(L,null,A(n.value.messages,(i,u)=>(s(),l("div",{key:u,class:"flex items-center justify-between rounded-lg bg-surface px-3 py-2 text-sm"},[e("div",Vo,[e("span",Wo,c(i.role),1),e("span",Go,c(i.content.slice(0,80))+c(i.content.length>80?"...":""),1)]),e("span",Jo,"~"+c(i.tokenCount)+" tok",1)]))),128))])])):y("",!0)])):(s(),l("div",Ko," No prompt anatomy data available. "))}});function Qo(t,a){if(a.length===0)return t;const r=Ee(a,"__raw"),n=t.split(`
2
+ `);let m=-1;for(let v=n.length-1;v>=0;v--)if(/^\s*return\s+/.test(n[v]??"")){m=v;break}if(m===-1)return`${t}
3
+
4
+ // Optimized: return selected fields only
5
+ const __raw = args
6
+ ${r}`;const d=n[m],i=d.match(/^(\s*)return\s+/)?.[1]??" ";let u=d.replace(/^\s*return\s+/,"").trim(),x=m;if(u.includes("{")&&!ee(u))for(let v=m+1;v<n.length&&(u+=`
7
+ `+n[v],x=v,!ee(u));v++);const b=[`${i}const __raw = ${u.trim()}`,`${i}${r}`].join(`
8
+ `);return[...n.slice(0,m),"",`${i}// Optimized: return selected fields only`,b,...n.slice(x+1)].join(`
9
+ `)}function ee(t){let a=0;for(const r of t)if(r==="{"&&a++,r==="}"&&a--,a<0)return!1;return a===0}const Xo={class:"relative flex h-full w-full max-w-2xl flex-col border-s border-border-default bg-bg-base shadow-xl"},Yo={class:"flex items-center justify-between border-b border-border-default px-5 py-4"},Zo={class:"text-base font-semibold text-text-primary"},en={key:0,class:"flex flex-1 flex-col items-center justify-center gap-4 p-8"},tn={class:"text-sm text-text-secondary"},sn={class:"font-mono text-accent"},on={class:"flex-1 overflow-y-auto"},nn={class:"grid grid-cols-3 gap-0 border-b border-border-default"},rn={class:"col-span-2 border-e border-border-default p-4"},an={class:"max-h-64 overflow-auto rounded-lg border border-border-default bg-surface-raised p-3"},ln={class:"p-4"},dn={class:"mb-2 text-xs font-medium uppercase tracking-wide text-text-muted"},un={key:0,class:"text-xs text-text-muted italic"},cn={key:1,class:"space-y-1"},mn=["title"],pn=["onClick"],xn={class:"border-b border-border-default p-4"},fn={class:"mb-2 flex items-center justify-between"},bn=["value"],vn={class:"space-y-3 p-4"},gn={key:0,class:"rounded-lg bg-warning/10 p-3 text-xs text-warning"},yn={class:"flex items-center justify-end gap-3 border-t border-border-default px-5 py-4"},hn=["disabled"],kn=N({__name:"ResponseOptimizerDrawer",props:{entry:{}},emits:["close"],setup(t,{emit:a}){const r=t,n=a,m=Oe(),d=He(),p=S(new Set),i=S(`${r.entry.functionName}_optimized`),u=S(""),x=S(""),b=S(!1),g=S(!1),v=S(null),k=$(()=>d.findByFunctionName(r.entry.functionName)),T=$(()=>k.value?.implementation.code??""),o=$(()=>Array.from(p.value));V(o,z=>{if(z.length>0){const _=z.map(I=>I.split(".").pop()??I).join(", ");u.value=`Optimized ${r.entry.functionName} returning only: ${_}`}else u.value=""}),V(o,z=>{b.value||(x.value=f(z))});function f(z){return z.length===0?T.value:T.value?Qo(T.value,z):` // No original code found — filtering raw result
10
+ const fullResult = await args
11
+ return {
12
+ ${We(z).map(E=>` ${E.returnKey}: args.${E.jsonPath}`).join(`,
13
+ `)}
14
+ }`}function h(z){const _=new Set(p.value);_.has(z)?_.delete(z):_.add(z),p.value=_}function D(z){const _=new Set(p.value);_.delete(z),p.value=_}function ue(z){x.value=z.target.value,b.value=!0}function ce(){x.value=f(o.value),b.value=!1}function me(){const z=k.value,_=z?JSON.parse(JSON.stringify(z.definition)):{type:"function",function:{name:i.value,description:u.value,parameters:{type:"object",properties:{},required:[]}}};_.function.name=i.value,_.function.description=u.value;const I=d.addTool({definition:_,implementation:{mode:"code",blocks:[],code:x.value},category:z?.category??"custom",optimizedFrom:{originalToolName:r.entry.functionName,selectedPaths:o.value,sampleResponse:r.entry.result}});v.value=I,g.value=!0}function pe(){v.value&&d.selectTool(v.value),m.push("/tools"),n("close")}function q(){n("close")}return(z,_)=>(s(),P(Fe,{to:"body"},[e("div",{class:"fixed inset-0 z-50 flex justify-end",onClick:ie(q,["self"])},[e("div",{class:"absolute inset-0 bg-black/50",onClick:q}),e("div",Xo,[e("div",Yo,[e("h3",Zo," Optimize: "+c(t.entry.functionName),1),e("button",{class:"rounded p-1 text-text-muted hover:bg-surface-overlay hover:text-text-primary transition-colors",onClick:q},[w(C(Re),{class:"h-5 w-5"})])]),g.value?(s(),l("div",en,[_[3]||(_[3]=e("div",{class:"text-4xl"},"✓",-1)),_[4]||(_[4]=e("p",{class:"text-lg font-medium text-text-primary"},"Tool created successfully",-1)),e("p",tn,[e("span",sn,c(i.value),1),_[2]||(_[2]=M(" has been added to your workshop. ",-1))]),e("div",{class:"mt-4 flex gap-3"},[e("button",{class:"rounded-lg border border-border-default px-4 py-2 text-sm text-text-secondary hover:bg-surface-overlay transition-colors",onClick:q}," Stay Here "),e("button",{class:"rounded-lg bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover transition-colors",onClick:pe}," Go to Workshop ")])])):(s(),l(L,{key:1},[e("div",on,[e("div",nn,[e("div",rn,[_[5]||(_[5]=e("div",{class:"mb-2 text-xs font-medium uppercase tracking-wide text-text-muted"}," Response (click fields to select) ",-1)),e("div",an,[w(Ve,{label:"result",value:t.entry.result,path:"","selected-paths":p.value,onTogglePath:h},null,8,["value","selected-paths"])])]),e("div",ln,[e("div",dn," Selected ("+c(p.value.size)+") ",1),p.value.size===0?(s(),l("div",un," Click fields in the tree to select them ")):(s(),l("div",cn,[(s(!0),l(L,null,A(o.value,I=>(s(),l("div",{key:I,class:"flex items-center justify-between rounded px-2 py-1 text-xs font-mono bg-surface-raised"},[e("span",{class:"truncate text-text-secondary",title:I},c(I),9,mn),e("button",{class:"ms-2 flex-shrink-0 text-text-muted hover:text-error transition-colors",onClick:E=>D(I)}," × ",8,pn)]))),128))]))])]),e("div",xn,[e("div",fn,[_[6]||(_[6]=e("span",{class:"text-xs font-medium uppercase tracking-wide text-text-muted"}," Code (editable) ",-1)),b.value?(s(),l("button",{key:0,class:"rounded px-2 py-0.5 text-xs text-accent hover:bg-surface-overlay transition-colors",onClick:ce}," Regenerate ")):y("",!0)]),e("textarea",{value:x.value,onInput:ue,class:"w-full rounded-lg border border-border-default bg-surface-raised p-3 font-mono text-xs text-text-primary placeholder-text-muted focus:border-accent focus:outline-none resize-y",rows:"10",spellcheck:"false",placeholder:"Select fields above to generate code..."},null,40,bn)]),e("div",vn,[e("div",null,[_[7]||(_[7]=e("label",{class:"mb-1 block text-xs font-medium text-text-muted"},"Tool Name",-1)),W(e("input",{"onUpdate:modelValue":_[0]||(_[0]=I=>i.value=I),class:"w-full rounded-lg border border-border-default bg-surface-raised px-3 py-2 text-sm text-text-primary placeholder-text-muted focus:border-accent focus:outline-none"},null,512),[[Z,i.value]])]),e("div",null,[_[8]||(_[8]=e("label",{class:"mb-1 block text-xs font-medium text-text-muted"},"Description",-1)),W(e("input",{"onUpdate:modelValue":_[1]||(_[1]=I=>u.value=I),class:"w-full rounded-lg border border-border-default bg-surface-raised px-3 py-2 text-sm text-text-primary placeholder-text-muted focus:border-accent focus:outline-none",placeholder:"What does this optimized tool return?"},null,512),[[Z,u.value]])]),k.value?y("",!0):(s(),l("div",gn,' Original tool "'+c(t.entry.functionName)+'" not found in workshop. The optimized tool will be created with a blank parameter schema. ',1))])]),e("div",yn,[e("button",{class:"rounded-lg border border-border-default px-4 py-2 text-sm text-text-secondary hover:bg-surface-overlay transition-colors",onClick:q}," Cancel "),e("button",{class:"rounded-lg bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed",disabled:p.value.size===0||!i.value.trim(),onClick:me}," Create Optimized Tool ",8,hn)])],64))])])]))}}),_n={key:0,class:"space-y-4"},$n={class:"flex items-center justify-between"},wn={class:"flex items-center gap-3"},Cn={class:"text-lg font-semibold"},Tn={class:"text-xs text-text-muted"},Mn={class:"flex items-center justify-between"},Sn={class:"relative"},zn={key:1,class:"absolute end-0 top-full z-20 mt-1 w-56 rounded-lg border border-border-default bg-surface-raised shadow-lg py-1"},Nn={class:"mt-4"},Ln={key:0,class:"space-y-4"},An={key:1,class:"flex items-center justify-center py-20 text-text-muted"},Un=N({__name:"SessionPage",props:{id:{}},setup(t){const a=t,r=xe(),n=fe(),m=te(),{t:d}=Be(),p=S("stream"),i=S(!1);function u(){const o=v.value;if(!o)return;const f={session:o,metrics:k.value,tokens:m.getTokens(a.id)};ge(f,`session-${o.id.slice(0,8)}.json`),i.value=!1}function x(){const o=v.value;if(!o)return;const f=k.value,h=["# Session Report — LLMxRay","",`**Model:** ${o.model}`,`**Session ID:** ${o.id}`,`**Status:** ${o.status}`,`**Created:** ${new Date(o.createdAt).toLocaleString()}`];f&&(h.push(""),h.push("## Metrics"),h.push(""),f.tokensPerSecond&&h.push(`- **Speed:** ${f.tokensPerSecond.toFixed(1)} tok/s`),f.ttftMs&&h.push(`- **TTFT:** ${f.ttftMs.toFixed(0)} ms`),f.completionTokenCount&&h.push(`- **Tokens generated:** ${f.completionTokenCount}`),f.promptTokenCount&&h.push(`- **Prompt tokens:** ${f.promptTokenCount}`)),o.prompt&&(h.push(""),h.push("## Prompt"),h.push(""),h.push(o.prompt)),o.outputText&&(h.push(""),h.push("## Response"),h.push(""),h.push(o.outputText)),h.push(""),h.push("---"),h.push("*Generated by LLMxRay — Local LLM Observatory*"),ye(h.join(`
15
+ `),`session-${o.id.slice(0,8)}.md`),i.value=!1}function b(){const o=m.getTokens(a.id);if(o.length===0)return;const f=["Index","Token","Timestamp","Confidence","Logprob","InterTokenLatencyMs"],h=o.map(D=>[String(D.index),D.text,String(D.timestamp),String(D.confidence),String(D.logprob??""),String(D.interTokenLatencyMs)]);he(f,h,`token-stream-${a.id.slice(0,8)}.csv`),i.value=!1}const g=$(()=>[{key:"stream",label:d("session.tabs.stream")},{key:"reasoning",label:d("session.tabs.reasoning")},{key:"introspection",label:d("session.tabs.introspection")},{key:"tools",label:d("session.tabs.tools")},{key:"agent",label:d("session.tabs.agent")},{key:"prompt",label:d("session.tabs.prompt")}]),v=$(()=>r.sessionById(a.id)??null),k=$(()=>n.getMetrics(a.id)),T=S(null);return X(()=>{r.setActiveSession(a.id)}),(o,f)=>(s(),l(L,null,[v.value?(s(),l("div",_n,[e("div",$n,[e("div",wn,[e("h2",Cn,c(v.value.model),1),w(se,{status:v.value.status},null,8,["status"])]),e("div",Tn,c(o.$t("session.sessionId",{id:v.value.id.slice(0,8)})),1)]),e("div",Mn,[w(ke,{tabs:g.value,"active-tab":p.value,"onUpdate:activeTab":f[0]||(f[0]=h=>p.value=h)},null,8,["tabs","active-tab"]),e("div",Sn,[e("button",{class:"flex items-center gap-1 rounded-lg border border-border-default px-2.5 py-1 text-xs text-text-secondary hover:text-text-primary transition-colors",onClick:f[1]||(f[1]=h=>i.value=!i.value)},[w(C(Ge),{class:"h-3.5 w-3.5"}),M(" "+c(o.$t("session.export.title")),1)]),i.value?(s(),l("div",{key:0,class:"fixed inset-0 z-10",onClick:f[2]||(f[2]=h=>i.value=!1)})):y("",!0),i.value?(s(),l("div",zn,[e("button",{class:"w-full px-3 py-2 text-start text-xs text-text-secondary hover:bg-surface-overlay",onClick:u},c(o.$t("session.export.downloadJson")),1),e("button",{class:"w-full px-3 py-2 text-start text-xs text-text-secondary hover:bg-surface-overlay",onClick:x},c(o.$t("session.export.downloadMarkdown")),1),e("button",{class:"w-full px-3 py-2 text-start text-xs text-text-secondary hover:bg-surface-overlay",onClick:b},c(o.$t("session.export.downloadTokenCsv")),1)])):y("",!0)])]),e("div",Nn,[p.value==="stream"?(s(),l("div",Ln,[w(Ce,{"session-id":t.id},null,8,["session-id"]),w(rt,{metrics:k.value},null,8,["metrics"])])):p.value==="reasoning"?(s(),P(kt,{key:1,"session-id":t.id},null,8,["session-id"])):p.value==="introspection"?(s(),P(As,{key:2,"session-id":t.id,"model-name":v.value.model},null,8,["session-id","model-name"])):p.value==="tools"?(s(),P(Ys,{key:3,"session-id":t.id,onOptimize:f[3]||(f[3]=h=>T.value=h)},null,8,["session-id"])):p.value==="agent"?(s(),P(ko,{key:4,"session-id":t.id},null,8,["session-id"])):p.value==="prompt"?(s(),P(Uo,{key:5,"session-id":t.id},null,8,["session-id"])):y("",!0)])])):(s(),l("div",An,c(o.$t("session.notFound")),1)),T.value?(s(),P(kn,{key:2,entry:T.value,onClose:f[4]||(f[4]=h=>T.value=null)},null,8,["entry"])):y("",!0)],64))}});export{Un as default};