@recombine-ai/bosun 0.20.2 → 0.20.4

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 (107) hide show
  1. package/build/_app/immutable/assets/{0.970vvoDj.css → 0.CdQBFG7k.css} +1 -1
  2. package/build/_app/immutable/assets/0.CdQBFG7k.css.br +0 -0
  3. package/build/_app/immutable/assets/0.CdQBFG7k.css.gz +0 -0
  4. package/build/_app/immutable/chunks/{BOZLjogl.js → 3WccBUkK.js} +1 -1
  5. package/build/_app/immutable/chunks/3WccBUkK.js.br +0 -0
  6. package/build/_app/immutable/chunks/3WccBUkK.js.gz +0 -0
  7. package/build/_app/immutable/chunks/B5p_twg4.js +1 -0
  8. package/build/_app/immutable/chunks/B5p_twg4.js.br +0 -0
  9. package/build/_app/immutable/chunks/B5p_twg4.js.gz +0 -0
  10. package/build/_app/immutable/chunks/BMZ3nmcQ.js +1 -0
  11. package/build/_app/immutable/chunks/BMZ3nmcQ.js.br +2 -0
  12. package/build/_app/immutable/chunks/BMZ3nmcQ.js.gz +0 -0
  13. package/build/_app/immutable/chunks/C9p6yGAG.js +3 -0
  14. package/build/_app/immutable/chunks/C9p6yGAG.js.br +0 -0
  15. package/build/_app/immutable/chunks/C9p6yGAG.js.gz +0 -0
  16. package/build/_app/immutable/entry/{app.Nx0-kikH.js → app.BTQrdm9G.js} +2 -2
  17. package/build/_app/immutable/entry/app.BTQrdm9G.js.br +0 -0
  18. package/build/_app/immutable/entry/app.BTQrdm9G.js.gz +0 -0
  19. package/build/_app/immutable/entry/start.Ls0_A8q0.js +1 -0
  20. package/build/_app/immutable/entry/start.Ls0_A8q0.js.br +0 -0
  21. package/build/_app/immutable/entry/start.Ls0_A8q0.js.gz +0 -0
  22. package/build/_app/immutable/nodes/{0.B5_ukjYU.js → 0.8n1R6Sfx.js} +1 -1
  23. package/build/_app/immutable/nodes/0.8n1R6Sfx.js.br +0 -0
  24. package/build/_app/immutable/nodes/0.8n1R6Sfx.js.gz +0 -0
  25. package/build/_app/immutable/nodes/{1.BnET9__M.js → 1.VY0dUXdC.js} +1 -1
  26. package/build/_app/immutable/nodes/1.VY0dUXdC.js.br +3 -0
  27. package/build/_app/immutable/nodes/1.VY0dUXdC.js.gz +0 -0
  28. package/build/_app/immutable/nodes/{16.C0hAGH9Y.js → 16.DbzAOHBQ.js} +1 -1
  29. package/build/_app/immutable/nodes/16.DbzAOHBQ.js.br +0 -0
  30. package/build/_app/immutable/nodes/16.DbzAOHBQ.js.gz +0 -0
  31. package/build/_app/immutable/nodes/17.DueeZkqc.js +11 -0
  32. package/build/_app/immutable/nodes/17.DueeZkqc.js.br +0 -0
  33. package/build/_app/immutable/nodes/17.DueeZkqc.js.gz +0 -0
  34. package/build/_app/immutable/nodes/{2.0cl8Jw4o.js → 2.hazKP8jr.js} +2 -2
  35. package/build/_app/immutable/nodes/2.hazKP8jr.js.br +0 -0
  36. package/build/_app/immutable/nodes/2.hazKP8jr.js.gz +0 -0
  37. package/build/_app/immutable/nodes/{3.CxkjPmTD.js → 3.DUnb-wiO.js} +1 -1
  38. package/build/_app/immutable/nodes/3.DUnb-wiO.js.br +0 -0
  39. package/build/_app/immutable/nodes/3.DUnb-wiO.js.gz +0 -0
  40. package/build/_app/immutable/nodes/{4.h7GzNdQ-.js → 4.D8bBp4vF.js} +1 -1
  41. package/build/_app/immutable/nodes/4.D8bBp4vF.js.br +0 -0
  42. package/build/_app/immutable/nodes/4.D8bBp4vF.js.gz +0 -0
  43. package/build/_app/immutable/nodes/{6.MjSRR3jo.js → 6.DYttyFcS.js} +1 -1
  44. package/build/_app/immutable/nodes/6.DYttyFcS.js.br +0 -0
  45. package/build/_app/immutable/nodes/6.DYttyFcS.js.gz +0 -0
  46. package/build/_app/immutable/nodes/8.BESB58-w.js +2 -0
  47. package/build/_app/immutable/nodes/8.BESB58-w.js.br +0 -0
  48. package/build/_app/immutable/nodes/8.BESB58-w.js.gz +0 -0
  49. package/build/_app/immutable/nodes/{9.BFI7-HIR.js → 9.DGMSOk75.js} +1 -1
  50. package/build/_app/immutable/nodes/9.DGMSOk75.js.br +0 -0
  51. package/build/_app/immutable/nodes/9.DGMSOk75.js.gz +0 -0
  52. package/build/_app/version.json +1 -1
  53. package/build/_app/version.json.br +0 -0
  54. package/build/_app/version.json.gz +0 -0
  55. package/build/index.html +10 -10
  56. package/build/index.html.br +0 -0
  57. package/build/index.html.gz +0 -0
  58. package/dist/index.js +25 -6
  59. package/dist/index.js.map +2 -2
  60. package/dist/types/backend/roleplay/conversation-store.d.ts +3 -2
  61. package/dist/types/backend/roleplay/router.d.ts +1 -1
  62. package/dist/types/backend/roleplay/variants.d.ts +1 -1
  63. package/dist/types/backend/server.d.ts +5 -5
  64. package/dist/types/backend/tests/router.d.ts +4 -4
  65. package/dist/types/lib/conversation.d.ts +3 -1
  66. package/dist/types/lib/tests/pii-sanitized-test-draft.d.ts +1 -1
  67. package/package.json +1 -1
  68. package/build/_app/immutable/assets/0.970vvoDj.css.br +0 -0
  69. package/build/_app/immutable/assets/0.970vvoDj.css.gz +0 -0
  70. package/build/_app/immutable/chunks/BOZLjogl.js.br +0 -2
  71. package/build/_app/immutable/chunks/BOZLjogl.js.gz +0 -0
  72. package/build/_app/immutable/chunks/Byx1piFp.js +0 -3
  73. package/build/_app/immutable/chunks/Byx1piFp.js.br +0 -0
  74. package/build/_app/immutable/chunks/Byx1piFp.js.gz +0 -0
  75. package/build/_app/immutable/chunks/jbAfpNOj.js +0 -1
  76. package/build/_app/immutable/chunks/jbAfpNOj.js.br +0 -0
  77. package/build/_app/immutable/chunks/jbAfpNOj.js.gz +0 -0
  78. package/build/_app/immutable/chunks/vxN0p6wG.js +0 -1
  79. package/build/_app/immutable/chunks/vxN0p6wG.js.br +0 -2
  80. package/build/_app/immutable/chunks/vxN0p6wG.js.gz +0 -0
  81. package/build/_app/immutable/entry/app.Nx0-kikH.js.br +0 -0
  82. package/build/_app/immutable/entry/app.Nx0-kikH.js.gz +0 -0
  83. package/build/_app/immutable/entry/start.t9PGFpmm.js +0 -1
  84. package/build/_app/immutable/entry/start.t9PGFpmm.js.br +0 -1
  85. package/build/_app/immutable/entry/start.t9PGFpmm.js.gz +0 -0
  86. package/build/_app/immutable/nodes/0.B5_ukjYU.js.br +0 -0
  87. package/build/_app/immutable/nodes/0.B5_ukjYU.js.gz +0 -0
  88. package/build/_app/immutable/nodes/1.BnET9__M.js.br +0 -0
  89. package/build/_app/immutable/nodes/1.BnET9__M.js.gz +0 -0
  90. package/build/_app/immutable/nodes/16.C0hAGH9Y.js.br +0 -0
  91. package/build/_app/immutable/nodes/16.C0hAGH9Y.js.gz +0 -0
  92. package/build/_app/immutable/nodes/17.DHifdmRv.js +0 -10
  93. package/build/_app/immutable/nodes/17.DHifdmRv.js.br +0 -0
  94. package/build/_app/immutable/nodes/17.DHifdmRv.js.gz +0 -0
  95. package/build/_app/immutable/nodes/2.0cl8Jw4o.js.br +0 -0
  96. package/build/_app/immutable/nodes/2.0cl8Jw4o.js.gz +0 -0
  97. package/build/_app/immutable/nodes/3.CxkjPmTD.js.br +0 -0
  98. package/build/_app/immutable/nodes/3.CxkjPmTD.js.gz +0 -0
  99. package/build/_app/immutable/nodes/4.h7GzNdQ-.js.br +0 -0
  100. package/build/_app/immutable/nodes/4.h7GzNdQ-.js.gz +0 -0
  101. package/build/_app/immutable/nodes/6.MjSRR3jo.js.br +0 -0
  102. package/build/_app/immutable/nodes/6.MjSRR3jo.js.gz +0 -0
  103. package/build/_app/immutable/nodes/8.BCatMgwB.js +0 -2
  104. package/build/_app/immutable/nodes/8.BCatMgwB.js.br +0 -0
  105. package/build/_app/immutable/nodes/8.BCatMgwB.js.gz +0 -0
  106. package/build/_app/immutable/nodes/9.BFI7-HIR.js.br +0 -0
  107. package/build/_app/immutable/nodes/9.BFI7-HIR.js.gz +0 -0
@@ -1 +1 @@
1
- import{B as e,Dt as t,E as n,F as r,G as i,I as a,L as o,N as s,Nt as c,O as l,Ot as u,Pt as d,V as f,X as p,_ as m,a as h,at as g,dt as _,et as v,gt as y,h as b,it as x,j as S,k as C,m as w,ot as T,p as ee,pt as E,r as D,rt as O,st as k,tt as te,v as ne,w as re,x as ie,y as A,z as j}from"../chunks/CPCsWwEy.js";import{t as M}from"../chunks/jbAfpNOj.js";import"../chunks/xihTtKlq.js";import{t as ae}from"../chunks/DDZ8GqHh.js";import{t as N}from"../chunks/BOZLjogl.js";import"../chunks/vxN0p6wG.js";import{t as P}from"../chunks/6OCsQ6r7.js";import{t as F}from"../chunks/Cf3l6QEG.js";import{n as oe,t as se}from"../chunks/BJqZY8o2.js";import{t as I}from"../chunks/BP0Xadq7.js";import{t as ce}from"../chunks/DWoqp3ac.js";import{t as le}from"../chunks/D_MTg6YY.js";import{t as ue}from"../chunks/D3fLfD-Y.js";import{t as de}from"../chunks/UZ6smZpJ.js";import{a as fe,c as pe,i as me,n as he,o as ge,r as _e,s as ve,t as ye}from"../chunks/CCtAgMW8.js";var L=o(`<p class="text-sm text-rc-gray-200">There are no more analytics fields to filter.</p>`),be=o(`<option> </option>`),R=o(`<label class="flex flex-col gap-1.5 text-sm text-rc-gray-200"><span>Value</span> <!> <span class="text-xs text-rc-gray-400"> </span></label>`),z=o(`<label class="flex cursor-pointer items-center gap-3 rounded px-3 py-2 text-sm text-rc-gray-100"><input type="checkbox" class="h-4 w-4 rounded border-rc-gray-500 bg-rc-gray-800 text-rc-green-200 focus:ring-1 focus:ring-rc-green-200/40 focus:ring-offset-0"/> <span class="min-w-0 flex-1 break-words"> </span> <span class="ml-auto text-[calc(0.875rem-1pt)] tabular-nums text-rc-gray-400"> </span></label>`),B=o(`<fieldset class="flex flex-col gap-1.5"><legend class="mb-1 text-sm text-rc-gray-200">Values</legend> <div class="rc-scroll max-h-72 overflow-y-auto rounded-lg border border-rc-gray-600 bg-rc-gray-900 p-1"></div></fieldset>`),V=o(`<label class="flex flex-col gap-1.5 text-sm text-rc-gray-200"><span>Field</span> <select class="rounded-lg border border-rc-gray-500 bg-rc-gray-900 px-3 py-2 text-rc-gray-100 focus:border-rc-gray-400 focus:outline-none focus:ring-0"></select></label> <!>`,1),H=o(`<div class="flex flex-col gap-4"><!></div>`),xe=o(`<!> <!>`,1);function Se(e,n){u(n,!0);let o=h(n,`open`,15,!1),p=E(``),m=E(k([])),w=E(``),D=!1,O=y(()=>n.fields.find(e=>e.key===i(p))),re=y(()=>(i(O)?.variantCount??0)>50),ie=y(()=>{let e=i(O),t=String(i(w)).trim();if(!(!e||!t)){if(e.type===`number`){let e=Number(t);return Number.isFinite(e)?e:void 0}return e.type===`boolean`?t.toLowerCase()===`true`||t.toLowerCase()!==`false`&&void 0:t}}),M=y(()=>!!i(O)&&(i(re)?i(ie)!==void 0:i(m).length>0));te(()=>{let e=o();e&&!D&&(_(p,n.fields[0]?.key??``,!0),_(m,[],!0),_(w,``)),D=e});function ae(e){_(p,e.currentTarget.value,!0),_(m,[],!0),_(w,``)}function N(e,t){return typeof e==typeof t&&e===t}function F(e){return i(m).some(t=>N(t,e))}function oe(e){_(m,F(e)?i(m).filter(t=>!N(t,e)):[...i(m),e],!0)}function se(e){return typeof e==`boolean`?e?`Yes`:`No`:String(e)}function ce(){let e=i(O);!e||!i(M)||(n.onAdd({key:e.key,type:e.type,values:i(re)?[i(ie)]:i(m)}),o(!1))}I(e,{title:`Add analytics filter`,class:`!max-w-lg`,get open(){return o()},set open(e){o(e)},children:e=>{var t=H(),o=x(t),c=e=>{var t=L();r(e,t)},u=e=>{var t=V(),o=g(t),c=T(x(o),2);l(c,21,()=>n.fields,C,(e,t)=>{var n=be(),a=x(n,!0);d(n);var o={};v(()=>{s(a,i(t).key),o!==(o=i(t).key)&&(n.value=(n.__value=i(t).key)??``)}),r(e,n)}),d(c);var u;ne(c),d(o);var m=T(o,2),h=e=>{var t=a(),n=g(t),o=e=>{var t=R(),n=T(x(t),2);{let e=y(()=>i(O).type===`number`?`number`:`text`);ue(n,{get type(){return i(e)},class:`w-full !border-rc-gray-500 !bg-rc-gray-900 !py-2`,onkeydown:e=>{e.key===`Enter`&&i(M)&&ce()},get value(){return i(w)},set value(e){_(w,e,!0)}})}var a=T(n,2),o=x(a);d(a),d(t),v(()=>s(o,`This field has ${i(O).variantCount??``} distinct values.`)),r(e,t)},c=e=>{var t=B(),n=T(x(t),2);l(n,21,()=>i(O).values,C,(e,t)=>{var n=z(),a=x(n);ee(a);var o=T(a,2),c=x(o,!0);d(o);var l=T(o,2),u=x(l,!0);d(l),d(n),v((e,n)=>{b(a,e),s(c,n),s(u,i(t).count)},[()=>F(i(t).value),()=>se(i(t).value)]),f(`change`,a,()=>oe(i(t).value)),r(e,n)}),d(n),d(t),r(e,t)};S(n,e=>{i(re)?e(o):e(c,-1)}),r(e,t)};S(m,e=>{i(O)&&e(h)}),v(()=>{u!==(u=i(p))&&(c.value=(c.__value=i(p))??``,A(c,i(p)))}),f(`change`,c,ae),r(e,t)};S(o,e=>{n.fields.length===0?e(c):e(u,-1)}),d(t),r(e,t)},footer:e=>{var t=xe(),n=g(t);P(n,{variant:`secondary`,onclick:()=>o(!1),children:(e,t)=>{c();var n=j(`Cancel`);r(e,n)},$$slots:{default:!0}});var a=T(n,2);{let e=y(()=>!i(M));P(a,{onclick:ce,get disabled(){return i(e)},children:(e,t)=>{c();var n=j(`Add filter`);r(e,n)},$$slots:{default:!0}})}r(e,t)},$$slots:{default:!0,footer:!0}}),t()}e([`change`]);var Ce=o(`<!> <!>`,1),we=o(`<option> </option>`),Te=o(`<button type="button" aria-label="Clear search" class="absolute right-2 top-1/2 flex -translate-y-1/2 items-center justify-center rounded p-1 text-rc-gray-200 hover:bg-rc-gray-600 hover:text-rc-gray-100 focus:outline-none"><!></button>`),Ee=o(`<div class="flex max-w-80 items-center gap-1 rounded-lg border border-rc-gray-500 bg-rc-gray-700 py-1 pl-3 pr-1 text-sm text-rc-gray-100"><span class="truncate"> </span> <button type="button" class="flex-none rounded p-1 text-rc-gray-300 hover:bg-rc-gray-600 hover:text-rc-gray-100"><!></button></div>`),De=o(`<p class="py-8 text-center text-rc-gray-200">Loading...</p>`),Oe=o(`<p class="py-8 text-center text-rc-gray-300">No conversations found</p>`),ke=o(`<span class="text-rc-gray-200">, Agent Id:</span> <span class="text-rc-green-200"> </span>`,1),Ae=o(`<li><div class="flex w-full flex-col gap-2"><div class="flex w-full items-center justify-between"><div class="text-gray-300"> </div> <div class="flex items-center gap-2"><span class="text-xs text-rc-gray-300"> </span> <span class="font-semibold text-rc-gray-100"> </span></div></div> <div class="flex items-center justify-between gap-4"><div class="text-sm"><span class="text-rc-gray-200">Conversation Id:</span> <span class="text-rc-green-200"> </span> <!></div> <p class="text-sm text-gray-400"> </p></div></div></li>`),je=o(`<ul class="space-y-2"></ul>`),Me=o(`<div class="flex h-screen"><!> <div class="flex h-full min-w-0 flex-1 flex-col bg-rc-gray-980 pb-3 pr-4 pt-2"><nav class="flex flex-none flex-col bg-rc-gray-980"><div class="flex items-center justify-center"><!></div> <div class="flex flex-wrap items-center gap-4"><div class="flex-1"><label class="block"><div class="flex gap-2"><select class="select svelte-1uk1thp" aria-label="Telescope source"><!></select> <div class="relative"><!><!></div> <!> <!> <!></div></label></div> <div class="hidden items-center gap-2"><div class="text-rc-gray-200">Sort:</div> <!></div> <div class="hidden items-center gap-2"><div class="text-rc-gray-200">Page size:</div> <select class="rounded-sm border border-rc-gray-300 bg-rc-gray-700 p-2 pr-8 text-rc-gray-100"><option>5</option><option>10</option><option>20</option><option>50</option></select></div> <div class="flex items-center gap-3"><div class="flex items-center gap-2"><!> <!> <div class="text-sm text-rc-gray-200"> </div></div></div> <div class="ml-auto whitespace-nowrap text-sm"><span class="text-gray-400">API Mode:</span> <span class="font-semibold text-rc-green-200"> </span></div></div></nav> <main class="flex flex-1 overflow-hidden"><div class="flex h-full w-1/3 flex-col"><div class="flex-none border-b border-rc-gray-300/40 p-4"><h2 class="text-lg font-semibold text-rc-gray-100">Conversations</h2></div> <div class="rc-scroll min-h-0 flex-1 overflow-scroll px-3 py-4"><!></div></div> <div class="flex h-full w-2/3 flex-col bg-rc-gray-980"><!></div></main></div></div> <!>`,1);function U(e,o){u(o,!0);let b=new ve,ee=E(k([])),ne=E(void 0),A=E(null),I=y(()=>(N.url.searchParams.get(`agent`)??``).trim()),L=E(``),be=E(20),R=E(`20`),z=E(!0),B=E(k([])),V=E(null),H=E(!1),xe=E(null),U=E(k([])),W=E(``),Ne=E(!1),Pe=E(null),Fe=E(!1),Ie=E(null),Le=E(k([])),G=E(k([])),K=E(!1),q=E(null),Re=E(!1),J=0,Y=0,ze=y(()=>i(Le).filter(e=>!i(G).some(t=>t.key===e.key))),Be=E(null),Ve=y(()=>JSON.stringify([i(I),i(W),i(G)])),X=y(()=>i(Be)===i(Ve)?i(ne):void 0),He=y(()=>i(X)?.items.length??0),Ue=h(o,`useMock`,3,!1),{onError:We}=ae();function Ge(e){return new Date(e).toLocaleString()}function Ke(e){return new Date(e).toLocaleTimeString()}function qe(e){let t=Math.round(e),n=Math.floor(t/60),r=t%60;return`${n}:${String(r).padStart(2,`0`)}`}function Je(){J+=1,Y+=1,_(A,null),_(ne,void 0),_(Be,null),_(Le,[],!0),_(G,[],!0),_(B,[],!0),_(V,null),_(H,!0),_(K,!0),_(q,null),_(Re,!1)}function Ye(e=i(I)){let t=new URLSearchParams;e&&t.set(`agent`,e),i(W)&&t.set(ye,i(W));let n=t.toString();return n?`?${n}`:``}function Z(e=i(I)){return`${i(gt)}/conversations${Ye(e)}`}let Xe=y(()=>N.url.pathname.split(`/`).at(-1)===`latency`?`latency`:`traces`);function Ze(e,t=i(Xe),n=i(I)){return`${i(gt)}/conversations/${encodeURIComponent(e)}/${t}${Ye(n)}`}async function Qe(e,t=i(be),n,r,a=i(G)){return Ue()?de.fetchConversations(t,e,n??void 0):b.getConversations({phoneNumber:e,agentId:r,analyticsFilters:a,limit:Number(t),lastConversationId:n??void 0})}async function Q(){_(B,[],!0),_(V,null),await nt()}async function $e(){_(Ne,!0),_(Pe,null);try{if(_(U,await pe(),!0),!i(U).length)throw Error(`No sources returned`);let e=_e(N.url),t=fe(i(U),e,he());if(!t)throw Error(`No sources returned`);if(_(W,t,!0),me(t),b.setSourceId(t),e!==t){let e=ge(N.url,t);await M(`${e.pathname}${e.search}`,{replaceState:!0})}}catch(e){console.error(`Failed to load Telescope sources:`,e),_(Pe,e?.message??`Failed to load Telescope sources`,!0),_(U,[],!0),_(W,``),b.setSourceId(void 0)}finally{_(Ne,!1)}}async function et(e){let t=e.target.value;_(W,t,!0),me(t),b.setSourceId(t),Je(),await M(Z()),await Promise.all([rt(),Q()])}async function tt(){try{_(ee,await ce.agents.catalog.query(),!0)}catch(e){let t=e instanceof Error?e.message:e?String(e):`Unknown error`;console.error(`Failed to load agents:`,e),We(`Failed to load agents: ${t}`)}}async function nt(){let e=++J,t=i(G).map(e=>({...e,values:[...e.values]})),n=i(I),r=JSON.stringify([n,i(W),t]);_(H,!0),_(xe,null);try{let a=await Qe(i(L)||void 0,i(be),i(V)??void 0,n||void 0,t);if(e!==J||r!==i(Ve))return;let o=Array.isArray(a.items)?a.items.slice():[];_(ne,{limit:a.limit,items:o,lastConversationId:a.lastConversationId},!0),_(Be,r,!0),_(V,a.lastConversationId??null,!0)}catch(t){if(e!==J||r!==i(Ve))return;_(xe,`Conversations could not be loaded for this selection.`),We(i(xe)),console.error(`Load page error:`,t)}finally{e===J&&_(H,!1)}}async function rt(){let e=++Y;if(_(K,!0),_(q,null),_(Le,[],!0),Ue()){_(K,!1);return}if(!i(I)){_(q,`Select an agent to add filters.`),_(K,!1);return}try{let t=await b.getAnalyticsFields(i(I));if(e!==Y)return;_(Le,t.items,!0)}catch(t){if(e!==Y)return;_(q,`Filters are unavailable for this selection.`),console.error(`Failed to load analytics fields:`,t)}finally{e===Y&&_(K,!1)}}function it(e){_(G,[...i(G),e],!0),Q()}function at(e){_(G,i(G).filter(t=>t.key!==e),!0),Q()}function ot(e){return typeof e==`boolean`?e?`Yes`:`No`:String(e)}function st(e){return`${e.key}: ${e.values.map(ot).join(`, `)}`}async function ct(){i(X)?.lastConversationId&&(i(B).push(i(X).lastConversationId),_(V,i(X).lastConversationId,!0),await nt())}async function lt(){i(B).length&&(i(B).pop(),_(V,i(B).length?i(B)[i(B).length-1]:null,!0),await nt())}function ut(){_(z,!i(z)),i(X)?.items&&i(X).items.sort((e,t)=>i(z)?t.createdAt-e.createdAt:e.createdAt-t.createdAt)}async function dt(e,t){if(t?.stopPropagation(),N.params.conversationId&&N.params.conversationId===e.conversationId||!N.params.conversationId&&i(A)?.conversationId===e.conversationId){_(A,null),await M(Z());return}_(A,e,!0),await M(Ze(e.conversationId))}function ft(e){let t=e.target.value;_(R,t,!0),_(be,parseInt(i(R),10)||20,!0)}async function pt(){await Q()}async function mt(e){e?.preventDefault(),e?.stopPropagation(),_(L,``),_(B,[],!0),_(V,null),await Q()}let ht=y(()=>{let e=N.url.pathname.split(`/`)[1];return e===`traces`?`view`:e}),gt=y(()=>N.url.pathname.startsWith(`/view`)?`/view`:`/traces`);function _t({value:e}){if(e!==i(ht)){if(e===`edit`)return i(I)?M(`/edit/${encodeURIComponent(i(I))}/roleplay`):M(`/edit`);if(e===`view`)return M(Z());M(`/`+e)}}async function vt(e,t){t?.stopPropagation(),e!==i(I)&&(Je(),await M(Z(e)))}async function yt(e){e?.stopPropagation(),i(I)&&(Je(),await M(Z(``)))}te(()=>{let e=i(I);i(Fe)&&e!==i(Ie)&&(_(Ie,e,!0),Je(),Promise.all([rt(),Q()]))}),D(()=>{(async()=>{await Promise.all([tt(),$e()]),await Promise.all([rt(),Q()]),_(Ie,i(I),!0),_(Fe,!0)})()});var bt=Me();re(`1uk1thp`,e=>{p(()=>{O.title=`Bosun: Telescope`})});var xt=g(bt),St=x(xt);le(St,{get agents(){return i(ee)},get currentAgent(){return i(I)},onAgentClick:vt,showAllAgentsOption:!0,onAllAgentsClick:yt,className:`flex-none`});var Ct=T(St,2),wt=x(Ct),Tt=x(wt),Et=x(Tt);oe(Et,{get value(){return i(ht)},ariaLabel:`Top tabs`,onChange:_t,children:(e,t)=>{var n=Ce(),i=g(n);se(i,{value:`edit`,children:(e,t)=>{c();var n=j(`Edit`);r(e,n)},$$slots:{default:!0}});var a=T(i,2);se(a,{value:`view`,children:(e,t)=>{c();var n=j(`View`);r(e,n)},$$slots:{default:!0}}),r(e,n)},$$slots:{default:!0}}),d(Tt);var Dt=T(Tt,2),Ot=x(Dt),kt=x(Ot),At=x(kt),$=x(At),jt=x($),Mt=e=>{var t=a(),n=g(t);l(n,17,()=>i(U),C,(e,t)=>{var n=we(),a=x(n,!0);d(n);var o={};v(()=>{s(a,i(t).label),o!==(o=i(t).id)&&(n.value=(n.__value=i(t).id)??``)}),r(e,n)}),r(e,t)},Nt=e=>{var t=we(),n=x(t,!0);d(t),t.value=t.__value=``,v(()=>s(n,i(Ne)?`Loading…`:`No sources`)),r(e,t)};S(jt,e=>{i(U).length?e(Mt):e(Nt,-1)}),d($);var Pt=T($,2),Ft=x(Pt);ue(Ft,{class:`w-56 rounded-r-none !border !border-rc-gray-500 !p-2 !pr-8 hover:border-rc-gray-400`,placeholder:`Search by phone...`,onkeydown:e=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),pt())},get value(){return i(L)},set value(e){_(L,e,!0)}});var It=T(Ft),Lt=e=>{var t=Te(),n=x(t);F(n,{name:`close`,width:18,height:18}),d(t),f(`click`,t,mt),r(e,t)};S(It,e=>{i(L)&&e(Lt)}),d(Pt);var Rt=T(Pt,2);P(Rt,{onclick:pt,children:(e,t)=>{c();var n=j(`Search`);r(e,n)},$$slots:{default:!0}});var zt=T(Rt,2);l(zt,17,()=>i(G),e=>e.key,(e,t)=>{var n=Ee(),a=x(n),o=x(a,!0);d(a);var c=T(a,2),l=x(c);F(l,{name:`close`,width:16,height:16,class:`relative top-px`}),d(c),d(n),v((e,r)=>{w(n,`title`,e),s(o,r),w(c,`aria-label`,`Remove ${i(t).key} filter`)},[()=>st(i(t)),()=>st(i(t))]),f(`click`,c,()=>at(i(t).key)),r(e,n)});var Bt=T(zt,2),Vt=e=>{P(e,{variant:`secondary`,title:`Add analytics filter`,onclick:()=>_(Re,!0),children:(e,t)=>{c();var n=j(`Add filter`);r(e,n)},$$slots:{default:!0}})};S(Bt,e=>{!i(K)&&!i(q)&&i(ze).length>0&&e(Vt)}),d(At),d(kt),d(Ot);var Ht=T(Ot,2),Ut=T(x(Ht),2);P(Ut,{onclick:ut,children:(e,t)=>{c();var n=j();v(()=>s(n,i(z)?`Newest first`:`Oldest first`)),r(e,n)},$$slots:{default:!0}}),d(Ht);var Wt=T(Ht,2),Gt=T(x(Wt),2),Kt=x(Gt);Kt.value=Kt.__value=`5`;var qt=T(Kt);qt.value=qt.__value=`10`;var Jt=T(qt);Jt.value=Jt.__value=`20`;var Yt=T(Jt);Yt.value=Yt.__value=`50`,d(Gt),d(Wt);var Xt=T(Wt,2),Zt=x(Xt),Qt=x(Zt);{let e=y(()=>i(B).length===0&&!i(V));P(Qt,{onclick:lt,get disabled(){return i(e)},children:(e,t)=>{c();var n=j(`Prev`);r(e,n)},$$slots:{default:!0}})}var $t=T(Qt,2);{let e=y(()=>!i(X)?.items.length);P($t,{onclick:ct,get disabled(){return i(e)},children:(e,t)=>{c();var n=j(`Next`);r(e,n)},$$slots:{default:!0}})}var en=T($t,2),tn=x(en);d(en),d(Zt),d(Xt);var nn=T(Xt,2),rn=T(x(nn),2),an=x(rn,!0);d(rn),d(nn),d(Dt),d(wt);var on=T(wt,2),sn=x(on),cn=T(x(sn),2),ln=x(cn),un=e=>{var t=De();r(e,t)},dn=e=>{var t=Oe();r(e,t)},fn=e=>{var t=je();l(t,21,()=>i(X).items,C,(e,t)=>{var n=Ae(),a=x(n),o=x(a),c=x(o),l=x(c);d(c);var u=T(c,2),p=x(u),m=x(p,!0);d(p);var h=T(p,2),_=x(h,!0);d(h),d(u),d(o);var y=T(o,2),b=x(y),C=T(x(b),2),ee=x(C,!0);d(C);var E=T(C,2),D=e=>{var n=ke(),a=T(g(n),2),o=x(a,!0);d(a),v(()=>s(o,i(t).agentId)),r(e,n)};S(E,e=>{!i(I)&&i(t).agentId&&e(D)}),d(b);var O=T(b,2),k=x(O);d(O),d(y),d(a),d(n),v((e,r,a)=>{ie(n,1,`cursor-pointer rounded-lg p-3 transition-colors ${(N.params.conversationId?i(t).conversationId===N.params.conversationId:i(t).conversationId===i(A)?.conversationId)?`bg-rc-gray-600`:`bg-rc-gray-700 hover:bg-rc-gray-650`}`,`svelte-1uk1thp`),w(n,`aria-selected`,N.params.conversationId?i(t).conversationId===N.params.conversationId:i(t).conversationId===i(A)?.conversationId),s(l,`${e??``} – ${r??``}`),s(m,i(t).medium),s(_,i(t).phoneNumber),s(ee,i(t).conversationId),s(k,`Duration: ${a??``}`)},[()=>Ge(i(t).createdAt-(i(t).duration??0)*1e3),()=>Ke(i(t).createdAt),()=>qe(i(t).duration??0)]),f(`click`,n,e=>dt(i(t),e)),r(e,n)}),d(t),r(e,t)};S(ln,e=>{i(H)?e(un):i(X)?.items?.length?e(fn,-1):e(dn,1)}),d(cn),d(sn);var pn=T(sn,2),mn=x(pn);n(mn,()=>o.children),d(pn),d(on),d(Ct),d(xt),Se(T(xt,2),{get fields(){return i(ze)},onAdd:it,get open(){return i(Re)},set open(e){_(Re,e,!0)}}),v(()=>{$.disabled=i(Ne)||!i(U).length,w($,`title`,i(Pe)??`Telescope source`),s(tn,`Items: ${i(He)??``}`),s(an,Ue()?`Mock (local)`:`Live`)}),f(`change`,$,et),m($,()=>i(W),e=>_(W,e)),f(`change`,Gt,ft),m(Gt,()=>i(R),e=>_(R,e)),f(`click`,pn,e=>e.stopPropagation()),r(e,bt),t()}e([`change`,`click`]);export{U as component};
1
+ import{B as e,Dt as t,E as n,F as r,G as i,I as a,L as o,N as s,Nt as c,O as l,Ot as u,Pt as d,V as f,X as p,_ as m,a as h,at as g,dt as _,et as v,gt as y,h as b,it as x,j as S,k as C,m as w,ot as T,p as ee,pt as E,r as D,rt as O,st as k,tt as te,v as ne,w as re,x as ie,y as A,z as j}from"../chunks/CPCsWwEy.js";import{t as M}from"../chunks/B5p_twg4.js";import"../chunks/xihTtKlq.js";import{t as ae}from"../chunks/DDZ8GqHh.js";import{t as N}from"../chunks/3WccBUkK.js";import"../chunks/BMZ3nmcQ.js";import{t as P}from"../chunks/6OCsQ6r7.js";import{t as F}from"../chunks/Cf3l6QEG.js";import{n as oe,t as se}from"../chunks/BJqZY8o2.js";import{t as I}from"../chunks/BP0Xadq7.js";import{t as ce}from"../chunks/DWoqp3ac.js";import{t as le}from"../chunks/D_MTg6YY.js";import{t as ue}from"../chunks/D3fLfD-Y.js";import{t as de}from"../chunks/UZ6smZpJ.js";import{a as fe,c as pe,i as me,n as he,o as ge,r as _e,s as ve,t as ye}from"../chunks/CCtAgMW8.js";var L=o(`<p class="text-sm text-rc-gray-200">There are no more analytics fields to filter.</p>`),be=o(`<option> </option>`),R=o(`<label class="flex flex-col gap-1.5 text-sm text-rc-gray-200"><span>Value</span> <!> <span class="text-xs text-rc-gray-400"> </span></label>`),z=o(`<label class="flex cursor-pointer items-center gap-3 rounded px-3 py-2 text-sm text-rc-gray-100"><input type="checkbox" class="h-4 w-4 rounded border-rc-gray-500 bg-rc-gray-800 text-rc-green-200 focus:ring-1 focus:ring-rc-green-200/40 focus:ring-offset-0"/> <span class="min-w-0 flex-1 break-words"> </span> <span class="ml-auto text-[calc(0.875rem-1pt)] tabular-nums text-rc-gray-400"> </span></label>`),B=o(`<fieldset class="flex flex-col gap-1.5"><legend class="mb-1 text-sm text-rc-gray-200">Values</legend> <div class="rc-scroll max-h-72 overflow-y-auto rounded-lg border border-rc-gray-600 bg-rc-gray-900 p-1"></div></fieldset>`),V=o(`<label class="flex flex-col gap-1.5 text-sm text-rc-gray-200"><span>Field</span> <select class="rounded-lg border border-rc-gray-500 bg-rc-gray-900 px-3 py-2 text-rc-gray-100 focus:border-rc-gray-400 focus:outline-none focus:ring-0"></select></label> <!>`,1),H=o(`<div class="flex flex-col gap-4"><!></div>`),xe=o(`<!> <!>`,1);function Se(e,n){u(n,!0);let o=h(n,`open`,15,!1),p=E(``),m=E(k([])),w=E(``),D=!1,O=y(()=>n.fields.find(e=>e.key===i(p))),re=y(()=>(i(O)?.variantCount??0)>50),ie=y(()=>{let e=i(O),t=String(i(w)).trim();if(!(!e||!t)){if(e.type===`number`){let e=Number(t);return Number.isFinite(e)?e:void 0}return e.type===`boolean`?t.toLowerCase()===`true`||t.toLowerCase()!==`false`&&void 0:t}}),M=y(()=>!!i(O)&&(i(re)?i(ie)!==void 0:i(m).length>0));te(()=>{let e=o();e&&!D&&(_(p,n.fields[0]?.key??``,!0),_(m,[],!0),_(w,``)),D=e});function ae(e){_(p,e.currentTarget.value,!0),_(m,[],!0),_(w,``)}function N(e,t){return typeof e==typeof t&&e===t}function F(e){return i(m).some(t=>N(t,e))}function oe(e){_(m,F(e)?i(m).filter(t=>!N(t,e)):[...i(m),e],!0)}function se(e){return typeof e==`boolean`?e?`Yes`:`No`:String(e)}function ce(){let e=i(O);!e||!i(M)||(n.onAdd({key:e.key,type:e.type,values:i(re)?[i(ie)]:i(m)}),o(!1))}I(e,{title:`Add analytics filter`,class:`!max-w-lg`,get open(){return o()},set open(e){o(e)},children:e=>{var t=H(),o=x(t),c=e=>{var t=L();r(e,t)},u=e=>{var t=V(),o=g(t),c=T(x(o),2);l(c,21,()=>n.fields,C,(e,t)=>{var n=be(),a=x(n,!0);d(n);var o={};v(()=>{s(a,i(t).key),o!==(o=i(t).key)&&(n.value=(n.__value=i(t).key)??``)}),r(e,n)}),d(c);var u;ne(c),d(o);var m=T(o,2),h=e=>{var t=a(),n=g(t),o=e=>{var t=R(),n=T(x(t),2);{let e=y(()=>i(O).type===`number`?`number`:`text`);ue(n,{get type(){return i(e)},class:`w-full !border-rc-gray-500 !bg-rc-gray-900 !py-2`,onkeydown:e=>{e.key===`Enter`&&i(M)&&ce()},get value(){return i(w)},set value(e){_(w,e,!0)}})}var a=T(n,2),o=x(a);d(a),d(t),v(()=>s(o,`This field has ${i(O).variantCount??``} distinct values.`)),r(e,t)},c=e=>{var t=B(),n=T(x(t),2);l(n,21,()=>i(O).values,C,(e,t)=>{var n=z(),a=x(n);ee(a);var o=T(a,2),c=x(o,!0);d(o);var l=T(o,2),u=x(l,!0);d(l),d(n),v((e,n)=>{b(a,e),s(c,n),s(u,i(t).count)},[()=>F(i(t).value),()=>se(i(t).value)]),f(`change`,a,()=>oe(i(t).value)),r(e,n)}),d(n),d(t),r(e,t)};S(n,e=>{i(re)?e(o):e(c,-1)}),r(e,t)};S(m,e=>{i(O)&&e(h)}),v(()=>{u!==(u=i(p))&&(c.value=(c.__value=i(p))??``,A(c,i(p)))}),f(`change`,c,ae),r(e,t)};S(o,e=>{n.fields.length===0?e(c):e(u,-1)}),d(t),r(e,t)},footer:e=>{var t=xe(),n=g(t);P(n,{variant:`secondary`,onclick:()=>o(!1),children:(e,t)=>{c();var n=j(`Cancel`);r(e,n)},$$slots:{default:!0}});var a=T(n,2);{let e=y(()=>!i(M));P(a,{onclick:ce,get disabled(){return i(e)},children:(e,t)=>{c();var n=j(`Add filter`);r(e,n)},$$slots:{default:!0}})}r(e,t)},$$slots:{default:!0,footer:!0}}),t()}e([`change`]);var Ce=o(`<!> <!>`,1),we=o(`<option> </option>`),Te=o(`<button type="button" aria-label="Clear search" class="absolute right-2 top-1/2 flex -translate-y-1/2 items-center justify-center rounded p-1 text-rc-gray-200 hover:bg-rc-gray-600 hover:text-rc-gray-100 focus:outline-none"><!></button>`),Ee=o(`<div class="flex max-w-80 items-center gap-1 rounded-lg border border-rc-gray-500 bg-rc-gray-700 py-1 pl-3 pr-1 text-sm text-rc-gray-100"><span class="truncate"> </span> <button type="button" class="flex-none rounded p-1 text-rc-gray-300 hover:bg-rc-gray-600 hover:text-rc-gray-100"><!></button></div>`),De=o(`<p class="py-8 text-center text-rc-gray-200">Loading...</p>`),Oe=o(`<p class="py-8 text-center text-rc-gray-300">No conversations found</p>`),ke=o(`<span class="text-rc-gray-200">, Agent Id:</span> <span class="text-rc-green-200"> </span>`,1),Ae=o(`<li><div class="flex w-full flex-col gap-2"><div class="flex w-full items-center justify-between"><div class="text-gray-300"> </div> <div class="flex items-center gap-2"><span class="text-xs text-rc-gray-300"> </span> <span class="font-semibold text-rc-gray-100"> </span></div></div> <div class="flex items-center justify-between gap-4"><div class="text-sm"><span class="text-rc-gray-200">Conversation Id:</span> <span class="text-rc-green-200"> </span> <!></div> <p class="text-sm text-gray-400"> </p></div></div></li>`),je=o(`<ul class="space-y-2"></ul>`),Me=o(`<div class="flex h-screen"><!> <div class="flex h-full min-w-0 flex-1 flex-col bg-rc-gray-980 pb-3 pr-4 pt-2"><nav class="flex flex-none flex-col bg-rc-gray-980"><div class="flex items-center justify-center"><!></div> <div class="flex flex-wrap items-center gap-4"><div class="flex-1"><label class="block"><div class="flex gap-2"><select class="select svelte-1uk1thp" aria-label="Telescope source"><!></select> <div class="relative"><!><!></div> <!> <!> <!></div></label></div> <div class="hidden items-center gap-2"><div class="text-rc-gray-200">Sort:</div> <!></div> <div class="hidden items-center gap-2"><div class="text-rc-gray-200">Page size:</div> <select class="rounded-sm border border-rc-gray-300 bg-rc-gray-700 p-2 pr-8 text-rc-gray-100"><option>5</option><option>10</option><option>20</option><option>50</option></select></div> <div class="flex items-center gap-3"><div class="flex items-center gap-2"><!> <!> <div class="text-sm text-rc-gray-200"> </div></div></div> <div class="ml-auto whitespace-nowrap text-sm"><span class="text-gray-400">API Mode:</span> <span class="font-semibold text-rc-green-200"> </span></div></div></nav> <main class="flex flex-1 overflow-hidden"><div class="flex h-full w-1/3 flex-col"><div class="flex-none border-b border-rc-gray-300/40 p-4"><h2 class="text-lg font-semibold text-rc-gray-100">Conversations</h2></div> <div class="rc-scroll min-h-0 flex-1 overflow-scroll px-3 py-4"><!></div></div> <div class="flex h-full w-2/3 flex-col bg-rc-gray-980"><!></div></main></div></div> <!>`,1);function U(e,o){u(o,!0);let b=new ve,ee=E(k([])),ne=E(void 0),A=E(null),I=y(()=>(N.url.searchParams.get(`agent`)??``).trim()),L=E(``),be=E(20),R=E(`20`),z=E(!0),B=E(k([])),V=E(null),H=E(!1),xe=E(null),U=E(k([])),W=E(``),Ne=E(!1),Pe=E(null),Fe=E(!1),Ie=E(null),Le=E(k([])),G=E(k([])),K=E(!1),q=E(null),Re=E(!1),J=0,Y=0,ze=y(()=>i(Le).filter(e=>!i(G).some(t=>t.key===e.key))),Be=E(null),Ve=y(()=>JSON.stringify([i(I),i(W),i(G)])),X=y(()=>i(Be)===i(Ve)?i(ne):void 0),He=y(()=>i(X)?.items.length??0),Ue=h(o,`useMock`,3,!1),{onError:We}=ae();function Ge(e){return new Date(e).toLocaleString()}function Ke(e){return new Date(e).toLocaleTimeString()}function qe(e){let t=Math.round(e),n=Math.floor(t/60),r=t%60;return`${n}:${String(r).padStart(2,`0`)}`}function Je(){J+=1,Y+=1,_(A,null),_(ne,void 0),_(Be,null),_(Le,[],!0),_(G,[],!0),_(B,[],!0),_(V,null),_(H,!0),_(K,!0),_(q,null),_(Re,!1)}function Ye(e=i(I)){let t=new URLSearchParams;e&&t.set(`agent`,e),i(W)&&t.set(ye,i(W));let n=t.toString();return n?`?${n}`:``}function Z(e=i(I)){return`${i(gt)}/conversations${Ye(e)}`}let Xe=y(()=>N.url.pathname.split(`/`).at(-1)===`latency`?`latency`:`traces`);function Ze(e,t=i(Xe),n=i(I)){return`${i(gt)}/conversations/${encodeURIComponent(e)}/${t}${Ye(n)}`}async function Qe(e,t=i(be),n,r,a=i(G)){return Ue()?de.fetchConversations(t,e,n??void 0):b.getConversations({phoneNumber:e,agentId:r,analyticsFilters:a,limit:Number(t),lastConversationId:n??void 0})}async function Q(){_(B,[],!0),_(V,null),await nt()}async function $e(){_(Ne,!0),_(Pe,null);try{if(_(U,await pe(),!0),!i(U).length)throw Error(`No sources returned`);let e=_e(N.url),t=fe(i(U),e,he());if(!t)throw Error(`No sources returned`);if(_(W,t,!0),me(t),b.setSourceId(t),e!==t){let e=ge(N.url,t);await M(`${e.pathname}${e.search}`,{replaceState:!0})}}catch(e){console.error(`Failed to load Telescope sources:`,e),_(Pe,e?.message??`Failed to load Telescope sources`,!0),_(U,[],!0),_(W,``),b.setSourceId(void 0)}finally{_(Ne,!1)}}async function et(e){let t=e.target.value;_(W,t,!0),me(t),b.setSourceId(t),Je(),await M(Z()),await Promise.all([rt(),Q()])}async function tt(){try{_(ee,await ce.agents.catalog.query(),!0)}catch(e){let t=e instanceof Error?e.message:e?String(e):`Unknown error`;console.error(`Failed to load agents:`,e),We(`Failed to load agents: ${t}`)}}async function nt(){let e=++J,t=i(G).map(e=>({...e,values:[...e.values]})),n=i(I),r=JSON.stringify([n,i(W),t]);_(H,!0),_(xe,null);try{let a=await Qe(i(L)||void 0,i(be),i(V)??void 0,n||void 0,t);if(e!==J||r!==i(Ve))return;let o=Array.isArray(a.items)?a.items.slice():[];_(ne,{limit:a.limit,items:o,lastConversationId:a.lastConversationId},!0),_(Be,r,!0),_(V,a.lastConversationId??null,!0)}catch(t){if(e!==J||r!==i(Ve))return;_(xe,`Conversations could not be loaded for this selection.`),We(i(xe)),console.error(`Load page error:`,t)}finally{e===J&&_(H,!1)}}async function rt(){let e=++Y;if(_(K,!0),_(q,null),_(Le,[],!0),Ue()){_(K,!1);return}if(!i(I)){_(q,`Select an agent to add filters.`),_(K,!1);return}try{let t=await b.getAnalyticsFields(i(I));if(e!==Y)return;_(Le,t.items,!0)}catch(t){if(e!==Y)return;_(q,`Filters are unavailable for this selection.`),console.error(`Failed to load analytics fields:`,t)}finally{e===Y&&_(K,!1)}}function it(e){_(G,[...i(G),e],!0),Q()}function at(e){_(G,i(G).filter(t=>t.key!==e),!0),Q()}function ot(e){return typeof e==`boolean`?e?`Yes`:`No`:String(e)}function st(e){return`${e.key}: ${e.values.map(ot).join(`, `)}`}async function ct(){i(X)?.lastConversationId&&(i(B).push(i(X).lastConversationId),_(V,i(X).lastConversationId,!0),await nt())}async function lt(){i(B).length&&(i(B).pop(),_(V,i(B).length?i(B)[i(B).length-1]:null,!0),await nt())}function ut(){_(z,!i(z)),i(X)?.items&&i(X).items.sort((e,t)=>i(z)?t.createdAt-e.createdAt:e.createdAt-t.createdAt)}async function dt(e,t){if(t?.stopPropagation(),N.params.conversationId&&N.params.conversationId===e.conversationId||!N.params.conversationId&&i(A)?.conversationId===e.conversationId){_(A,null),await M(Z());return}_(A,e,!0),await M(Ze(e.conversationId))}function ft(e){let t=e.target.value;_(R,t,!0),_(be,parseInt(i(R),10)||20,!0)}async function pt(){await Q()}async function mt(e){e?.preventDefault(),e?.stopPropagation(),_(L,``),_(B,[],!0),_(V,null),await Q()}let ht=y(()=>{let e=N.url.pathname.split(`/`)[1];return e===`traces`?`view`:e}),gt=y(()=>N.url.pathname.startsWith(`/view`)?`/view`:`/traces`);function _t({value:e}){if(e!==i(ht)){if(e===`edit`)return i(I)?M(`/edit/${encodeURIComponent(i(I))}/roleplay`):M(`/edit`);if(e===`view`)return M(Z());M(`/`+e)}}async function vt(e,t){t?.stopPropagation(),e!==i(I)&&(Je(),await M(Z(e)))}async function yt(e){e?.stopPropagation(),i(I)&&(Je(),await M(Z(``)))}te(()=>{let e=i(I);i(Fe)&&e!==i(Ie)&&(_(Ie,e,!0),Je(),Promise.all([rt(),Q()]))}),D(()=>{(async()=>{await Promise.all([tt(),$e()]),await Promise.all([rt(),Q()]),_(Ie,i(I),!0),_(Fe,!0)})()});var bt=Me();re(`1uk1thp`,e=>{p(()=>{O.title=`Bosun: Telescope`})});var xt=g(bt),St=x(xt);le(St,{get agents(){return i(ee)},get currentAgent(){return i(I)},onAgentClick:vt,showAllAgentsOption:!0,onAllAgentsClick:yt,className:`flex-none`});var Ct=T(St,2),wt=x(Ct),Tt=x(wt),Et=x(Tt);oe(Et,{get value(){return i(ht)},ariaLabel:`Top tabs`,onChange:_t,children:(e,t)=>{var n=Ce(),i=g(n);se(i,{value:`edit`,children:(e,t)=>{c();var n=j(`Edit`);r(e,n)},$$slots:{default:!0}});var a=T(i,2);se(a,{value:`view`,children:(e,t)=>{c();var n=j(`View`);r(e,n)},$$slots:{default:!0}}),r(e,n)},$$slots:{default:!0}}),d(Tt);var Dt=T(Tt,2),Ot=x(Dt),kt=x(Ot),At=x(kt),$=x(At),jt=x($),Mt=e=>{var t=a(),n=g(t);l(n,17,()=>i(U),C,(e,t)=>{var n=we(),a=x(n,!0);d(n);var o={};v(()=>{s(a,i(t).label),o!==(o=i(t).id)&&(n.value=(n.__value=i(t).id)??``)}),r(e,n)}),r(e,t)},Nt=e=>{var t=we(),n=x(t,!0);d(t),t.value=t.__value=``,v(()=>s(n,i(Ne)?`Loading…`:`No sources`)),r(e,t)};S(jt,e=>{i(U).length?e(Mt):e(Nt,-1)}),d($);var Pt=T($,2),Ft=x(Pt);ue(Ft,{class:`w-56 rounded-r-none !border !border-rc-gray-500 !p-2 !pr-8 hover:border-rc-gray-400`,placeholder:`Search by phone...`,onkeydown:e=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),pt())},get value(){return i(L)},set value(e){_(L,e,!0)}});var It=T(Ft),Lt=e=>{var t=Te(),n=x(t);F(n,{name:`close`,width:18,height:18}),d(t),f(`click`,t,mt),r(e,t)};S(It,e=>{i(L)&&e(Lt)}),d(Pt);var Rt=T(Pt,2);P(Rt,{onclick:pt,children:(e,t)=>{c();var n=j(`Search`);r(e,n)},$$slots:{default:!0}});var zt=T(Rt,2);l(zt,17,()=>i(G),e=>e.key,(e,t)=>{var n=Ee(),a=x(n),o=x(a,!0);d(a);var c=T(a,2),l=x(c);F(l,{name:`close`,width:16,height:16,class:`relative top-px`}),d(c),d(n),v((e,r)=>{w(n,`title`,e),s(o,r),w(c,`aria-label`,`Remove ${i(t).key} filter`)},[()=>st(i(t)),()=>st(i(t))]),f(`click`,c,()=>at(i(t).key)),r(e,n)});var Bt=T(zt,2),Vt=e=>{P(e,{variant:`secondary`,title:`Add analytics filter`,onclick:()=>_(Re,!0),children:(e,t)=>{c();var n=j(`Add filter`);r(e,n)},$$slots:{default:!0}})};S(Bt,e=>{!i(K)&&!i(q)&&i(ze).length>0&&e(Vt)}),d(At),d(kt),d(Ot);var Ht=T(Ot,2),Ut=T(x(Ht),2);P(Ut,{onclick:ut,children:(e,t)=>{c();var n=j();v(()=>s(n,i(z)?`Newest first`:`Oldest first`)),r(e,n)},$$slots:{default:!0}}),d(Ht);var Wt=T(Ht,2),Gt=T(x(Wt),2),Kt=x(Gt);Kt.value=Kt.__value=`5`;var qt=T(Kt);qt.value=qt.__value=`10`;var Jt=T(qt);Jt.value=Jt.__value=`20`;var Yt=T(Jt);Yt.value=Yt.__value=`50`,d(Gt),d(Wt);var Xt=T(Wt,2),Zt=x(Xt),Qt=x(Zt);{let e=y(()=>i(B).length===0&&!i(V));P(Qt,{onclick:lt,get disabled(){return i(e)},children:(e,t)=>{c();var n=j(`Prev`);r(e,n)},$$slots:{default:!0}})}var $t=T(Qt,2);{let e=y(()=>!i(X)?.items.length);P($t,{onclick:ct,get disabled(){return i(e)},children:(e,t)=>{c();var n=j(`Next`);r(e,n)},$$slots:{default:!0}})}var en=T($t,2),tn=x(en);d(en),d(Zt),d(Xt);var nn=T(Xt,2),rn=T(x(nn),2),an=x(rn,!0);d(rn),d(nn),d(Dt),d(wt);var on=T(wt,2),sn=x(on),cn=T(x(sn),2),ln=x(cn),un=e=>{var t=De();r(e,t)},dn=e=>{var t=Oe();r(e,t)},fn=e=>{var t=je();l(t,21,()=>i(X).items,C,(e,t)=>{var n=Ae(),a=x(n),o=x(a),c=x(o),l=x(c);d(c);var u=T(c,2),p=x(u),m=x(p,!0);d(p);var h=T(p,2),_=x(h,!0);d(h),d(u),d(o);var y=T(o,2),b=x(y),C=T(x(b),2),ee=x(C,!0);d(C);var E=T(C,2),D=e=>{var n=ke(),a=T(g(n),2),o=x(a,!0);d(a),v(()=>s(o,i(t).agentId)),r(e,n)};S(E,e=>{!i(I)&&i(t).agentId&&e(D)}),d(b);var O=T(b,2),k=x(O);d(O),d(y),d(a),d(n),v((e,r,a)=>{ie(n,1,`cursor-pointer rounded-lg p-3 transition-colors ${(N.params.conversationId?i(t).conversationId===N.params.conversationId:i(t).conversationId===i(A)?.conversationId)?`bg-rc-gray-600`:`bg-rc-gray-700 hover:bg-rc-gray-650`}`,`svelte-1uk1thp`),w(n,`aria-selected`,N.params.conversationId?i(t).conversationId===N.params.conversationId:i(t).conversationId===i(A)?.conversationId),s(l,`${e??``} – ${r??``}`),s(m,i(t).medium),s(_,i(t).phoneNumber),s(ee,i(t).conversationId),s(k,`Duration: ${a??``}`)},[()=>Ge(i(t).createdAt-(i(t).duration??0)*1e3),()=>Ke(i(t).createdAt),()=>qe(i(t).duration??0)]),f(`click`,n,e=>dt(i(t),e)),r(e,n)}),d(t),r(e,t)};S(ln,e=>{i(H)?e(un):i(X)?.items?.length?e(fn,-1):e(dn,1)}),d(cn),d(sn);var pn=T(sn,2),mn=x(pn);n(mn,()=>o.children),d(pn),d(on),d(Ct),d(xt),Se(T(xt,2),{get fields(){return i(ze)},onAdd:it,get open(){return i(Re)},set open(e){_(Re,e,!0)}}),v(()=>{$.disabled=i(Ne)||!i(U).length,w($,`title`,i(Pe)??`Telescope source`),s(tn,`Items: ${i(He)??``}`),s(an,Ue()?`Mock (local)`:`Live`)}),f(`change`,$,et),m($,()=>i(W),e=>_(W,e)),f(`change`,Gt,ft),m(Gt,()=>i(R),e=>_(R,e)),f(`click`,pn,e=>e.stopPropagation()),r(e,bt),t()}e([`change`,`click`]);export{U as component};
@@ -1 +1 @@
1
- import{B as e,Dt as t,E as n,F as r,G as i,L as a,Nt as o,Ot as s,Pt as c,V as l,at as u,gt as d,it as f,ot as p,z as m}from"../chunks/CPCsWwEy.js";import{t as h}from"../chunks/jbAfpNOj.js";import"../chunks/xihTtKlq.js";import{t as g}from"../chunks/BOZLjogl.js";import"../chunks/vxN0p6wG.js";import{n as _,t as v}from"../chunks/BJqZY8o2.js";import{r as y}from"../chunks/DkJi5BM4.js";var b=a(`<!> <!>`,1),x=a(`<div class="flex h-full min-h-0 flex-col bg-rc-gray-980"><div class="flex-none border-b border-rc-gray-300/40 px-4 pt-3"><!></div> <div class="min-h-0 flex-1"><!></div></div>`);function S(e,a){s(a,!0),y();let S=d(()=>g.url.pathname.split(`/`).at(-1)===`latency`?`latency`:`traces`),C=d(()=>g.url.pathname.startsWith(`/view`)?`/view`:`/traces`);function w(e){let t=g.params.conversationId??``,n=g.url.search;return`${i(C)}/conversations/${encodeURIComponent(t)}/${e}${n}`}function T({value:e}){(e===`traces`||e===`latency`)&&e!==i(S)&&h(w(e))}var E=x(),D=f(E),O=f(D);_(O,{get value(){return i(S)},ariaLabel:`View conversation tabs`,onChange:T,children:(e,t)=>{var n=b(),i=u(n);v(i,{value:`traces`,children:(e,t)=>{o();var n=m(`Traces`);r(e,n)},$$slots:{default:!0}});var a=p(i,2);v(a,{value:`latency`,children:(e,t)=>{o();var n=m(`Latency`);r(e,n)},$$slots:{default:!0}}),r(e,n)},$$slots:{default:!0}}),c(D);var k=p(D,2),A=f(k);n(A,()=>a.children),c(k),c(E),l(`click`,E,e=>e.stopPropagation()),r(e,E),t()}e([`click`]);export{S as component};
1
+ import{B as e,Dt as t,E as n,F as r,G as i,L as a,Nt as o,Ot as s,Pt as c,V as l,at as u,gt as d,it as f,ot as p,z as m}from"../chunks/CPCsWwEy.js";import{t as h}from"../chunks/B5p_twg4.js";import"../chunks/xihTtKlq.js";import{t as g}from"../chunks/3WccBUkK.js";import"../chunks/BMZ3nmcQ.js";import{n as _,t as v}from"../chunks/BJqZY8o2.js";import{r as y}from"../chunks/DkJi5BM4.js";var b=a(`<!> <!>`,1),x=a(`<div class="flex h-full min-h-0 flex-col bg-rc-gray-980"><div class="flex-none border-b border-rc-gray-300/40 px-4 pt-3"><!></div> <div class="min-h-0 flex-1"><!></div></div>`);function S(e,a){s(a,!0),y();let S=d(()=>g.url.pathname.split(`/`).at(-1)===`latency`?`latency`:`traces`),C=d(()=>g.url.pathname.startsWith(`/view`)?`/view`:`/traces`);function w(e){let t=g.params.conversationId??``,n=g.url.search;return`${i(C)}/conversations/${encodeURIComponent(t)}/${e}${n}`}function T({value:e}){(e===`traces`||e===`latency`)&&e!==i(S)&&h(w(e))}var E=x(),D=f(E),O=f(D);_(O,{get value(){return i(S)},ariaLabel:`View conversation tabs`,onChange:T,children:(e,t)=>{var n=b(),i=u(n);v(i,{value:`traces`,children:(e,t)=>{o();var n=m(`Traces`);r(e,n)},$$slots:{default:!0}});var a=p(i,2);v(a,{value:`latency`,children:(e,t)=>{o();var n=m(`Latency`);r(e,n)},$$slots:{default:!0}}),r(e,n)},$$slots:{default:!0}}),c(D);var k=p(D,2),A=f(k);n(A,()=>a.children),c(k),c(E),l(`click`,E,e=>e.stopPropagation()),r(e,E),t()}e([`click`]);export{S as component};
@@ -1 +1 @@
1
- import{Dt as e,F as t,G as n,L as r,Nt as i,Ot as a,Pt as o,X as s,at as c,dt as l,gt as u,it as d,ot as f,pt as p,r as m,rt as h,st as g,tt as _,w as v,z as y}from"../chunks/CPCsWwEy.js";import{t as b}from"../chunks/jbAfpNOj.js";import"../chunks/xihTtKlq.js";import{t as x}from"../chunks/DDZ8GqHh.js";import{t as S}from"../chunks/BOZLjogl.js";import"../chunks/vxN0p6wG.js";import{n as C,t as w}from"../chunks/BJqZY8o2.js";import{t as T}from"../chunks/DWoqp3ac.js";import{t as E}from"../chunks/D_MTg6YY.js";var D=r(`<!> <!>`,1),O=r(`<div class="flex h-screen"><!> <div class="flex h-full min-w-0 flex-1 flex-col bg-rc-gray-980 pb-3 pr-4 pt-2"><nav class="flex flex-none items-center justify-center bg-rc-gray-980"><!></nav> <main class="flex-1 pr-80 pt-40"><div class="flex h-full items-start justify-center text-rc-gray-200">Select an agent on the left panel to start editing</div></main></div></div>`);function k(r,k){a(k,!0);let{onAgentSelect:A,onError:j}=x(),M=p(g([])),N=p(!1),P=u(()=>S.url.pathname.split(`/`)[1]);function F({value:e}){if(e!==n(P)){if(e===`edit`)return b(`/edit`);if(e===`view`)return b(`/view`);b(`/`+e)}}function I(e){A(e)}_(()=>{n(N)||S.url.pathname===`/edit`&&n(M).length&&(l(N,!0),A(n(M)[0].id))}),m(async()=>{try{l(M,await T.agents.catalog.query(),!0)}catch(e){let t=e instanceof Error?e.message:e?String(e):`Unknown error`;console.error(`Failed to load agents:`,e),j(`Failed to load agents: ${t}`)}});var L=O();v(`17v3h6h`,e=>{s(()=>{h.title=`Bosun: Edit`})});var R=d(L);E(R,{className:`flex-none`,get agents(){return n(M)},currentAgent:``,onAgentClick:I});var z=f(R,2),B=d(z),V=d(B);C(V,{get value(){return n(P)},ariaLabel:`Top tabs`,onChange:F,children:(e,n)=>{var r=D(),a=c(r);w(a,{value:`edit`,children:(e,n)=>{i();var r=y(`Edit`);t(e,r)},$$slots:{default:!0}});var o=f(a,2);w(o,{value:`view`,children:(e,n)=>{i();var r=y(`View`);t(e,r)},$$slots:{default:!0}}),t(e,r)},$$slots:{default:!0}}),o(B),i(2),o(z),o(L),t(r,L),e()}export{k as component};
1
+ import{Dt as e,F as t,G as n,L as r,Nt as i,Ot as a,Pt as o,X as s,at as c,dt as l,gt as u,it as d,ot as f,pt as p,r as m,rt as h,st as g,tt as _,w as v,z as y}from"../chunks/CPCsWwEy.js";import{t as b}from"../chunks/B5p_twg4.js";import"../chunks/xihTtKlq.js";import{t as x}from"../chunks/DDZ8GqHh.js";import{t as S}from"../chunks/3WccBUkK.js";import"../chunks/BMZ3nmcQ.js";import{n as C,t as w}from"../chunks/BJqZY8o2.js";import{t as T}from"../chunks/DWoqp3ac.js";import{t as E}from"../chunks/D_MTg6YY.js";var D=r(`<!> <!>`,1),O=r(`<div class="flex h-screen"><!> <div class="flex h-full min-w-0 flex-1 flex-col bg-rc-gray-980 pb-3 pr-4 pt-2"><nav class="flex flex-none items-center justify-center bg-rc-gray-980"><!></nav> <main class="flex-1 pr-80 pt-40"><div class="flex h-full items-start justify-center text-rc-gray-200">Select an agent on the left panel to start editing</div></main></div></div>`);function k(r,k){a(k,!0);let{onAgentSelect:A,onError:j}=x(),M=p(g([])),N=p(!1),P=u(()=>S.url.pathname.split(`/`)[1]);function F({value:e}){if(e!==n(P)){if(e===`edit`)return b(`/edit`);if(e===`view`)return b(`/view`);b(`/`+e)}}function I(e){A(e)}_(()=>{n(N)||S.url.pathname===`/edit`&&n(M).length&&(l(N,!0),A(n(M)[0].id))}),m(async()=>{try{l(M,await T.agents.catalog.query(),!0)}catch(e){let t=e instanceof Error?e.message:e?String(e):`Unknown error`;console.error(`Failed to load agents:`,e),j(`Failed to load agents: ${t}`)}});var L=O();v(`17v3h6h`,e=>{s(()=>{h.title=`Bosun: Edit`})});var R=d(L);E(R,{className:`flex-none`,get agents(){return n(M)},currentAgent:``,onAgentClick:I});var z=f(R,2),B=d(z),V=d(B);C(V,{get value(){return n(P)},ariaLabel:`Top tabs`,onChange:F,children:(e,n)=>{var r=D(),a=c(r);w(a,{value:`edit`,children:(e,n)=>{i();var r=y(`Edit`);t(e,r)},$$slots:{default:!0}});var o=f(a,2);w(o,{value:`view`,children:(e,n)=>{i();var r=y(`View`);t(e,r)},$$slots:{default:!0}}),t(e,r)},$$slots:{default:!0}}),o(B),i(2),o(z),o(L),t(r,L),e()}export{k as component};
@@ -0,0 +1,2 @@
1
+ import{B as e,Dt as t,E as n,F as r,G as i,H as a,I as o,L as s,N as c,Nt as l,O as u,Ot as d,Pt as f,S as p,V as m,a as h,at as g,b as _,dt as v,et as y,gt as b,it as x,j as S,k as C,l as w,m as ee,ot as T,pt as E,r as te,st as D,tt as O,x as k,z as A}from"../chunks/CPCsWwEy.js";import"../chunks/xihTtKlq.js";import{r as j,t as M}from"../chunks/oarl--hZ.js";import{t as N}from"../chunks/6OCsQ6r7.js";import{t as P}from"../chunks/Cf3l6QEG.js";import{t as F}from"../chunks/DWoqp3ac.js";import{t as ne}from"../chunks/B9YnyJ2j.js";import{c as re,i as I,o as ie,s as L}from"../chunks/By9tvIIw.js";import{r as R}from"../chunks/BOHUKGg_.js";import{t as ae}from"../chunks/D3fLfD-Y.js";import{a as oe,i as se,n as ce,o as le,r as ue,t as de}from"../chunks/C9p6yGAG.js";var z=s(`<span class="min-w-0 flex-1 truncate text-left"> </span> <!>`,1),B=s(`<div class="flex items-start gap-2"><div class="min-w-0"><div class="truncate p-1 text-sm text-rc-gray-300 group-hover:text-rc-gray-200"> </div> <div> </div></div></div>`),V=s(`<div class="mt-1 max-h-96 w-max min-w-full max-w-[min(26rem,90vw)] overflow-y-auto overflow-x-hidden rounded-lg border border-rc-gray-110 bg-rc-gray-930 backdrop-blur-2xl" role="listbox"></div>`),H=s(`<div><!> <!></div>`);function fe(e,n){d(n,!0);let a=h(n,`class`,3,``),o=E(!1),s=E(null),l=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function p(){v(o,!i(o))}function m(e){n.onSelect(e),v(o,!1)}function _(e){return(e.lastMessage??``).trim()||`No messages`}function S(e,t=50,n=`…`){if(!e)return``;if(e.length<=t)return e;let r=e.slice(0,t+1),i=Math.max(r.lastIndexOf(` `),r.lastIndexOf(`\xA0`),r.lastIndexOf(` `),r.lastIndexOf(`
2
+ `),r.lastIndexOf(`\r`));return(i>0?r.slice(0,i):e.slice(0,t)).trimEnd()+n}function w(e){e.key===`ArrowDown`&&!i(o)?(v(o,!0),e.preventDefault()):e.key===`ArrowUp`&&i(o)&&(v(o,!1),e.preventDefault())}function ee(e){let t=e.getDate(),n=l[e.getMonth()],r=e.getHours(),i=r>=12?`PM`:`AM`;r%=12,r===0&&(r=12);let a=String(e.getMinutes()).padStart(2,`0`),o=new Date,s=e.getFullYear();return`${t} ${n}${s===o.getFullYear()?``:` ${s}`}, ${r}:${a} ${i}`}function te(e){return ee(new Date(e.createdAt))}let D=b(()=>n.conversations.find(e=>e.conversationId===n.currentConversationId)??null),O=b(()=>i(D)?te(i(D)):`History`);var A=H(),j=x(A);N(j,{variant:`ghost`,get"aria-expanded"(){return i(o)},"aria-haspopup":`listbox`,"aria-controls":`history-dropdown`,onclick:p,onkeydown:w,class:`inline-flex w-40 items-center rounded-lg border border-transparent !bg-rc-gray-700 !px-3 !pb-1 !pt-[5px] text-rc-gray-200 hover:border hover:border-rc-gray-500 focus:outline-none focus:ring-0`,get el(){return i(s)},set el(e){v(s,e,!0)},children:(e,t)=>{var n=z(),a=g(n),s=x(a,!0);f(a);var l=T(a,2);{let e=b(()=>`size-7 shrink-0 text-rc-gray-500 transition-transform duration-200 `+(i(o)?`rotate-180`:``));P(l,{name:`chevron-down`,get class(){return i(e)}})}y(()=>c(s,i(O))),r(e,n)},$$slots:{default:!0}});var M=T(j,2);le(M,{id:`history-dropdown`,get open(){return i(o)},onClose:()=>v(o,!1),get anchorEl(){return i(s)},placement:`bottom-start`,offset:[0,1],children:e=>{var t=V();u(t,21,()=>n.conversations,C,(e,t)=>{{let a=b(()=>i(t).conversationId===n.currentConversationId);N(e,{variant:`ghost`,size:`small`,role:`option`,get"aria-selected"(){return i(a)},onclick:()=>m(i(t).conversationId),class:`group w-full rounded-none border-b border-rc-gray-110 py-2 pr-3 text-left backdrop-blur-2xl last:border-b-0 hover:bg-rc-gray-700 focus:bg-rc-gray-400`,children:(e,a)=>{var o=B(),s=x(o),l=x(s),u=x(l,!0);f(l);var d=T(l,2),p=x(d,!0);f(d),f(s),f(o),y((e,r)=>{c(u,e),k(d,1,`truncate p-1 text-base font-semibold `+(i(t).conversationId===n.currentConversationId?`text-rc-green-200`:`text-rc-gray-100`)),c(p,r)},[()=>te(i(t)),()=>S(_(i(t)))]),r(e,o)},$$slots:{default:!0}})}}),f(t),r(e,t)},$$slots:{default:!0}}),f(A),y(()=>k(A,1,`relative ${a()}`)),r(e,A),t()}var U=s(`<dialog class="dialog m-auto bg-transparent p-0 text-rc-gray-100 shadow-md svelte-jby388"><!> <!></dialog>`);function pe(e,i){d(i,!0);let a,o=h(i,`showCloseButton`,3,!1),s=h(i,`onClose`,3,()=>{}),c=h(i,`onOpen`,3,()=>{}),u=h(i,`isOpen`,3,!1);O(()=>{u()?(console.log(`show`),a?.showModal(),c()()):a?.open&&(console.log(`close`),a.close())});function p(){s()()}te(()=>(a.addEventListener(`close`,p),()=>{a.removeEventListener(`close`,p)}));function g(e){e.target===a&&a.close()}var _=U(),v=x(_);n(v,()=>i.children);var y=T(v,2),b=e=>{N(e,{variant:`ghost`,onclick:()=>a.close(),class:`absolute right-2 top-2`,children:(e,t)=>{l();var n=A(`✕`);r(e,n)},$$slots:{default:!0}})};S(y,e=>{o()&&e(b)}),f(_),w(_,e=>a=e,()=>a),m(`mousedown`,_,g),r(e,_),t()}e([`mousedown`]);function me(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n.text,r=n.lastSeen,i=n.uses;if(typeof e!=`string`||typeof r!=`number`||!Number.isFinite(r)||typeof i!=`number`||!Number.isFinite(i))continue;let a=e.trim();a&&t.push({text:a,lastSeen:r,uses:i})}return t.sort((e,t)=>t.lastSeen-e.lastSeen),t}function he(e,t,n=2e3){let r=t.trim();if(!r)return e;let i=(e[0]?.lastSeen??0)+1,a=e.findIndex(e=>e.text===r),o;if(a!==-1){let t=e[a];o=[{text:t.text,lastSeen:i,uses:(t.uses??0)+1},...e.slice(0,a),...e.slice(a+1)]}else o=[{text:r,lastSeen:i,uses:1},...e];return o.length>n?o.slice(0,n):o}function ge(e,t,n=2e3){if(!t.length)return e;if(!e.length)return t;let r=e[0]?.lastSeen??0,i=(t[0]?.lastSeen??0)>r?t:t.map((e,n)=>({...e,lastSeen:r+(t.length-n)})),a=new Map;for(let t of e)a.set(t.text,t);for(let e of i){let t=a.get(e.text);if(!t){a.set(e.text,e);continue}a.set(e.text,{text:e.text,lastSeen:Math.max(t.lastSeen,e.lastSeen),uses:t.uses+e.uses})}return Array.from(a.values()).sort((e,t)=>t.lastSeen-e.lastSeen).slice(0,n)}function _e(e,t,n=5){if(!t.length)return[];let r=e.trim().toLowerCase(),i=W(e,!1).text,a=/\s$/u.test(e);if(!W(e,!0).text)return[];let o=[];for(let e of t){let t=W(e.text);if(!t.text||e.text.trim().toLowerCase()===r)continue;let n=G(t,e.text,i,a);n&&o.push({item:e,match:n})}return o.sort((e,t)=>e.match.kindRank===t.match.kindRank?e.match.span===t.match.span?e.match.start===t.match.start?e.item.lastSeen===t.item.lastSeen?e.item.uses===t.item.uses?e.item.text.length-t.item.text.length:t.item.uses-e.item.uses:t.item.lastSeen-e.item.lastSeen:e.match.start-t.match.start:e.match.span-t.match.span:e.match.kindRank-t.match.kindRank),o.slice(0,n).map(e=>({text:e.item.text,prefixEndIndex:e.match.prefixEndIndex,segments:be(e.item.text,e.match.ranges)}))}function W(e,t=!0){let n=[],r=[];for(let t=0;t<e.length;t++){let i=ve(e[t]);if(i===` `){if(!n.length)continue;let e=n.length-1;if(n[e]===` `){r[e][1]=t+1;continue}}n.push(i),r.push([t,t+1])}return t&&n[n.length-1]===` `&&(n.pop(),r.pop()),{text:n.join(``),ranges:r}}function ve(e){if(/\s/u.test(e))return` `;try{return/[\p{P}\p{S}]/u.test(e)?` `:e.toLowerCase()}catch{return/[^a-z0-9\s]/i.test(e)?` `:e.toLowerCase()}}function G(e,t,n,r){if(!e.text)return null;if(e.text.startsWith(n)){let e=Y(t,n,r)??t.length,i=Math.max(0,Math.min(t.length,e));return{kindRank:0,start:0,span:n.length,ranges:[[0,i]],prefixEndIndex:i}}let i=e.text.indexOf(n);return i===-1?null:{kindRank:q(e.text,i,n.length),start:i,span:n.length,ranges:J(e,i,i+n.length),prefixEndIndex:t.length}}function ye(e,t){return t<=0||e[t-1]===` `}function K(e,t){return t>=e.length||e[t]===` `}function q(e,t,n){let r=ye(e,t),i=K(e,t+n);return r&&i?1:r?2:3}function J(e,t,n){let r=Math.max(0,Math.min(e.ranges.length,t)),i=Math.max(r,Math.min(e.ranges.length,n));return xe(e.ranges.slice(r,i))}function Y(e,t,n){if(!t)return null;let r=``,i=!0;for(let a=0;a<e.length;a++){let o=e[a],s;if(/\s/u.test(o))s=` `;else try{s=/[\p{P}\p{S}]/u.test(o)?` `:o.toLowerCase()}catch{s=/[^a-z0-9\s]/i.test(o)?` `:o.toLowerCase()}if(s===` `){if(i)continue;r+=` `,i=!0}else r+=s,i=!1;if(r.length===t.length){if(r!==t)return null;let i=a+1;if(n&&t.endsWith(` `)){let t=i;for(;t<e.length;){let n=e[t];if(/\s/u.test(n)){t+=1;continue}try{if(/[\p{P}\p{S}]/u.test(n)){t+=1;continue}}catch{if(/[^a-z0-9\s]/i.test(n)){t+=1;continue}}break}i=t}return i}if(r.length>t.length)return null}return null}function be(e,t){let n=xe(t);if(!n.length)return[{text:e,matched:!1}];let r=[],i=0;for(let[t,a]of n)t>i&&r.push({text:e.slice(i,t),matched:!1}),r.push({text:e.slice(t,a),matched:!0}),i=a;return i<e.length&&r.push({text:e.slice(i),matched:!1}),r.filter(e=>e.text.length>0)}function xe(e){if(!e.length)return[];let t=e.map(([e,t])=>[Math.max(0,e),Math.max(0,t)]).filter(([e,t])=>t>e).sort((e,t)=>e[0]-t[0]||e[1]-t[1]);if(!t.length)return[];let n=[[t[0][0],t[0][1]]];for(let e=1;e<t.length;e++){let[r,i]=t[e],a=n[n.length-1];if(r<=a[1]){a[1]=Math.max(a[1],i);continue}n.push([r,i])}return n}var Se=s(`<form><h2 class="text-l mb-4 text-gray-300">Image URL</h2> <!> <!></form>`),Ce=s(`<div class="my-2 flex w-full justify-center"><div class="rounded-full border border-rc-gray-650 bg-rc-gray-800/40 px-3 py-1 text-xs text-rc-gray-200"> </div></div>`),we=s(`<div class="rounded-lg border border-rc-green-450 bg-transparent px-3 py-2 text-sm text-rc-gray-300">Generating 9 more variants…</div>`),Te=s(`<div class="rounded-lg border border-red-500/70 bg-red-950/20 px-3 py-2 text-sm text-red-200"> </div>`),Ee=s(`<button type="button"><div class="whitespace-pre-line break-words"> </div></button>`),De=s(`<div class="ml-7 mt-2 flex flex-col gap-2"><!> <!> <!></div>`),Oe=s(`<!> <div class="log-element"><div><!></div> <!></div>`,1),ke=s(`<div class="absolute bottom-2 left-2 right-2 z-10 flex items-center gap-3 rounded-lg border border-rc-green-450 bg-rc-gray-930/90 px-3 py-3 font-semibold text-rc-gray-100 shadow-inner-white-soft backdrop-blur-3xl"><span>Choose a variant above to continue</span> <button type="button" class="rounded border-0 bg-transparent px-1 py-0.5 text-rc-gray-300 transition-colors hover:bg-rc-gray-900 hover:text-rc-gray-100 focus:outline-none focus-visible:outline-none disabled:cursor-wait disabled:opacity-50">Regenerate</button> <button type="button" class="rounded border-0 bg-transparent px-1 py-0.5 text-rc-gray-300 transition-colors hover:bg-rc-gray-900 hover:text-rc-gray-100 focus:outline-none focus-visible:outline-none">Cancel</button></div>`),Ae=s(`<div class="absolute bottom-16 left-2 right-2 z-20 rounded-lg border border-red-500/60 bg-red-950/90 px-3 py-2 text-sm text-red-100 shadow-lg" role="alert"> </div>`),je=s(`<span> </span>`),Me=s(`<button type="button" role="option" tabindex="-1"></button>`),Ne=s(`<div class="absolute bottom-full left-0 right-0 mb-1 max-h-60 overflow-y-auto rounded-lg border border-rc-gray-110 bg-rc-gray-930 shadow-inner-white-soft backdrop-blur-2xl" role="listbox"></div>`),Pe=s(`<div class="pointer-events-none absolute inset-0 z-10 overflow-hidden rounded-lg" aria-hidden="true"><div class="whitespace-pre text-rc-gray-400/70"><span class="invisible"> </span><span> </span></div></div>`),Fe=s(`<!> <form><fieldset class="absolute bottom-2 left-2 right-2 z-10 flex gap-2 disabled:opacity-35"><div class="relative flex-1"><!> <!> <button type="button" class="absolute bottom-0 left-3 top-0 z-20 inline-flex items-center border-r border-rc-gray-500/70 bg-transparent pr-2 text-base font-semibold leading-6 text-rc-gray-300 transition-colors duration-75 hover:text-rc-gray-300 focus:outline-none focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"> </button> <!></div> <!> <!></fieldset></form>`,1),Ie=s(`<div class="rc-scroll min-h-0 flex-1 overflow-y-auto pr-1"></div> <!>`,1),Le=s(`<!> <!>`,1);function X(e,n){d(n,!0);let s=h(n,`promptEditProposalId`,3,null),te=h(n,`analyzeDisabled`,3,!1),M=h(n,`variantSourceTrace`,3,null),R=h(n,`variantChoices`,19,()=>[]),le=h(n,`variantLoading`,3,!1),z=h(n,`variantApplyingId`,3,null),B=h(n,`variantError`,3,null),V=D(new Set),H=E(``),fe=E(``),U=E(``),W,ve=E(!1),G=E(null),ye=E(``),K=E(!1),q=E(`user`),J=E(null),Y=E(D([])),be=E(null),xe=E(!1),X=E(!1),Z=E(null),Q=b(()=>_e(i(H),i(Y))),Re=b(()=>i(Z)==null?null:i(Q)[i(Z)]??null),ze=b(()=>i(Re)?i(Re).text.slice(i(Re).prefixEndIndex):``),Be=b(()=>!M()&&!i(U)&&i(H).trim().length===0);O(()=>{if(typeof window>`u`)return;if(!i(G)){v(ye,``);return}let e=window.getComputedStyle(i(G)),t=`calc(${e.paddingTop} + ${e.borderTopWidth})`,n=`calc(${e.paddingRight} + ${e.borderRightWidth})`,r=`calc(${e.paddingBottom} + ${e.borderBottomWidth})`,a=`calc(${e.paddingLeft} + ${e.borderLeftWidth})`;v(ye,[`padding:${t} ${n} ${r} ${a}`,`font:${e.font}`,`letter-spacing:${e.letterSpacing}`,`line-height:${e.lineHeight}`,`text-indent:${e.textIndent}`,`text-transform:${e.textTransform}`,`text-align:${e.textAlign}`,`box-sizing:${e.boxSizing}`].join(`;`),!0)}),O(()=>{i(Z)!=null&&i(Z)>=i(Q).length&&v(Z,null)});let Ve=b(()=>M()||!i(xe)||i(X)?!1:i(Q).length>0);function He(e){v(H,e.text,!0),v(Z,null),v(X,!0)}function Ue(){v(xe,!0),v(X,!1)}function We(){v(xe,!1),v(Z,null),v(X,!1)}function Ge(){v(Z,null),v(X,!1)}function Ke(e){if(e.key===`Escape`){i(Ve)&&e.preventDefault(),v(X,!0),v(Z,null);return}if(e.key===`ArrowUp`||e.key===`ArrowDown`){if(!i(Q).length)return;i(X)&&v(X,!1),e.preventDefault();let t=i(Q).length-1;if(i(Z)===null)v(Z,e.key===`ArrowUp`?t:0,!0);else{let n=e.key===`ArrowUp`?-1:1;v(Z,Math.max(0,Math.min(t,i(Z)+n)),!0)}return}if(e.key===`Enter`||e.key===`Tab`&&!e.shiftKey){if(i(Z)===null)return;let t=i(Q)[i(Z)];if(!t)return;e.preventDefault(),He(t);return}}let qe=null,Je=!1,Ye=0;function Xe(){typeof window>`u`||W&&(!Je&&V.has(W)||(qe??=requestAnimationFrame(()=>{if(qe=null,!W||!Je&&V.has(W))return;let e=W.scrollHeight-(W.scrollTop+W.clientHeight),t=Je||e>W.clientHeight?`auto`:`smooth`;W.scrollTo({top:W.scrollHeight,behavior:t}),Je=!1})))}O(()=>{let e=I.length;e===0&&Ye>0&&(Je=!0,W&&V.delete(W)),Ye=e,e>0&&Xe()});function Ze(e){e.scrollTop+e.clientHeight+200>e.scrollHeight?V.delete(e):V.add(e)}function Qe(e){i(K)||(i(H).trim().length>0||i(U))&&(v(Y,he(i(Y),i(H)),!0),n.onmessage({sender:e,text:i(H),imageUrl:i(U)}),v(U,``),v(H,``),v(q,`user`),v(X,!1),v(Z,null))}function $e(e){e.preventDefault(),Qe(i(q))}function et(){v(q,i(q)===`system`?`user`:`system`,!0),requestAnimationFrame(()=>i(G)?.focus())}function tt(e){e.preventDefault(),v(U,i(fe),!0),v(fe,``),v(ve,!1)}function nt(e){return e&&typeof e.renderedPrompt==`string`?e.renderedPrompt:null}function rt(e,t){for(let n=t-1;n>=0;n--){let t=e[n];if(re(t)&&ne(t.name)&&nt(t))return t}for(let n=t-1;n>=0;n--){let t=e[n];if(re(t)&&t.name===`prewarm`&&nt(t))return t}return null}function it(e){return(e.eventName===`received-message`||e.eventName===`llm-handler-stream-requested`)&&!String(e.content??``).trim()?!1:e.eventName===`received-message`||e.eventName===`llm-handler-stream-requested`||e.eventName===`finished-main-streaming-step`||e.eventName===`sent-message`||e.eventName===`transfer-requested`||e.eventName===`hangup-requested`}function at(e){return!!(n.agentId&&n.agentId.trim())&&e.eventName!==`transfer-requested`&&(e.eventName===`finished-main-streaming-step`||e.eventName===`sent-message`)}function ot(e){return e.role===`user`||e.eventName===`received-message`||e.eventName===`llm-handler-stream-requested`}function st(e){let t=String(e??``).trim();return!t||/^\[image\]\s+/.test(t)?``:t}function ct(e){let t=e?.bosunInputMessageSender;return t===`system`?`system`:t===`user`?`user`:e.role===`system`?`system`:`user`}function lt(e){if(!n.onRevertToState)return;let t=e?.bosunPrevStateId,r=typeof t==`string`&&t.trim().length>0?t:null;n.onRevertToState(r);let a=typeof e?.bosunUserMessage==`string`?e.bosunUserMessage:e.content;v(H,st(a),!0),v(q,ct(e),!0),v(X,!1),v(Z,null),requestAnimationFrame(()=>{try{i(G)?.focus(),i(G)?.select()}catch{}})}function ut(){n.agentType===`text`?v(ve,!0):n.agentType===`voice`&&n.onHangup?.()}let dt=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function ft(e){if(typeof e!=`number`||!Number.isFinite(e))return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function pt(e){if(typeof e!=`number`||!Number.isFinite(e))return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:`${t.getDate()} ${dt[t.getMonth()]} ${t.getFullYear()}`}let $=b(()=>I.filter(e=>ie(e)||re(e)?!0:L(e)?it(e):!1)),mt=b(()=>I.findLast(e=>L(e))?.eventName===`hangup-requested`),ht=b(()=>{let e=i($).map((e,t)=>({entry:e,index:t})).reverse().find(({entry:e,index:t})=>!L(e)||!at(e)?!1:i($).slice(0,t).some(e=>L(e)&&ot(e)));return e&&L(e.entry)?e.entry:null}),gt=b(()=>{let e=i(ht);if(!e)return null;try{let t=_t(e);return{model:t.model,stringifiedConversation:t.stringifiedConversation,response:t.response}}catch{return null}});function _t(e){if(!(n.agentId??``).trim())throw Error(`Agent id is not available; cannot analyze`);let t=I.indexOf(e);if(t===-1)throw Error(`Could not locate trace in chat history`);let r=ue(I,t,{requireRenderedPrompt:!0});if(!r)throw Error(`Could not find main step trace for this message`);let i=typeof r.renderedPrompt==`string`?r.renderedPrompt:``;if(!i.trim())throw Error(`Main step rendered prompt is missing`);let a=typeof r.stringifiedConversation==`string`&&r.stringifiedConversation.trim()?r.stringifiedConversation:se(I,t)??``,o=String(e?.content??``);if(!o.trim())throw Error(`Message content is missing`);let s=typeof r?.model==`string`?String(r.model):void 0,c=e?.createdAt;return{trace:e,stepTrace:r,renderedPrompt:i,stringifiedConversation:a,response:o,model:s,createdAt:typeof c==`number`&&Number.isFinite(c)?c:void 0}}function vt(e){if(n.onAnalyzeTrace)try{v(J,null),n.onAnalyzeTrace(_t(e))}catch(e){console.error(e),v(J,e instanceof Error?e.message:String(e),!0)}}function yt(e){if(n.onRegenerateTrace)try{v(J,null),n.onRegenerateTrace(e)}catch(e){console.error(e),v(J,e instanceof Error?e.message:String(e),!0)}}async function bt(){if(i(K))return;let e=i(gt);if(e){v(X,!0),v(Z,null),v(K,!0);try{let t=await F.agents.generateUserResponse.mutate(e);v(H,t.text,!0),v(X,!0),v(Z,null),requestAnimationFrame(()=>{try{i(G)?.focus(),i(G)?.setSelectionRange(t.text.length,t.text.length)}catch{}})}catch(e){console.error(`Failed to generate suggested user response`,e)}finally{v(K,!1)}}}O(()=>{if(typeof window>`u`)return;let e=(n.agentId??``).trim();if(!e||e===i(be))return;v(be,e,!0),v(Y,[],!0);let t=e,r=e;F.agents.userMessageHistory.query({agentId:t}).then(e=>{if(i(be)!==r)return;let t=me(e);v(Y,ge(t,i(Y)),!0),v(Z,null)}).catch(e=>{console.error(`Failed to load user message history`,e),i(be)===r&&(v(Y,[],!0),v(Z,null))})}),O(()=>{let e=M(),t=R().length,n=le(),r=B(),i=z();!e&&!t&&!n&&!r&&!i||Xe()});var xt=Le(),St=g(xt);pe(St,{get isOpen(){return i(ve)},onClose:()=>v(ve,!1),showCloseButton:!0,children:(e,t)=>{j(e,{class:`p-4`,children:(e,t)=>{var n=Se(),o=T(x(n),2);ae(o,{class:`mb-2 w-80`,get value(){return i(fe)},set value(e){v(fe,e,!0)}});var s=T(o,2);N(s,{variant:`secondary`,type:`submit`,class:`ml-2 p-2`,children:(e,t)=>{l();var n=A(`Attach`);r(e,n)},$$slots:{default:!0}}),f(n),a(`submit`,n,tt),r(e,n)},$$slots:{default:!0}})},$$slots:{default:!0}});var Ct=T(St,2);j(Ct,{get class(){return`relative flex min-h-0 flex-col p-2 pb-16 ${n.class??``}`},children:(e,t)=>{var l=Ie(),d=g(l);u(d,21,()=>i($),C,(e,t,a)=>{let o=b(()=>ft(i(t).createdAt)),l=b(()=>a>0?ft(i($)[a-1].createdAt):null),d=b(()=>pt(i(t).createdAt));var p=Oe(),h=g(p),_=e=>{var t=Ce(),n=x(t),a=x(n,!0);f(n),f(t),y(()=>c(a,i(d))),r(e,t)};S(h,e=>{i(o)&&i(d)&&i(o)!==i(l)&&e(_)});var v=T(h,2),C=x(v),w=x(C),ee=e=>{oe(e,{get trace(){return i(t)}})},E=b(()=>ie(i(t))),D=e=>{{let r=b(()=>ue(i($),a)),o=b(()=>n.onAnalyzeTrace?vt:void 0),c=b(()=>n.onRegenerateTrace?yt:void 0),l=b(()=>n.onRevertToState?lt:void 0),u=b(()=>!!n.onSeeVariants&&!M()&&i(t)===i(ht)),d=b(()=>M()&&i(t)===M()?`source`:`none`),f=b(()=>z()===null&&M()&&i(t)===M()?n.onChooseOriginalVariant:void 0),p=b(()=>!!M()&&i(t)===M());ce(e,{testCreationMode:`direct`,get trace(){return i(t)},get context(){return n.context},get agentId(){return n.agentId},get promptEditProposalId(){return s()},get testSourceStep(){return i(r)},get testEntries(){return i($)},get analyzeDisabled(){return te()},get onAnalyze(){return i(o)},get onRegenerate(){return i(c)},get onRevert(){return i(l)},get showSeeVariants(){return i(u)},get onSeeVariants(){return n.onSeeVariants},get variantSelectionState(){return i(d)},get onSelectInVariantMode(){return i(f)},get suppressActionRow(){return i(p)}})}},O=b(()=>L(i(t))),A=e=>{{let r=b(()=>se(i($),a)),o=b(()=>ne(i(t).name)?rt(i($),a):null);de(e,{testCreationMode:`direct`,get trace(){return i(t)},get agentId(){return n.agentId},get promptEditProposalId(){return s()},get fallbackConversation(){return i(r)},get runtimeContext(){return n.context},get compareTrace(){return i(o)}})}},j=b(()=>re(i(t)));S(w,e=>{i(E)?e(ee):i(O)?e(D,1):i(j)&&e(A,2)}),f(C);var N=T(C,2),P=e=>{var t=De(),a=x(t),o=e=>{var t=we();r(e,t)};S(a,e=>{le()&&e(o)});var s=T(a,2),l=e=>{var t=Te(),n=x(t,!0);f(t),y(()=>c(n,B())),r(e,t)};S(s,e=>{B()&&e(l)});var d=T(s,2);u(d,17,R,e=>e.id,(e,t)=>{var a=Ee(),o=x(a),s=x(o,!0);f(o),f(a),y(()=>{a.disabled=z()!==null,k(a,1,`w-full max-w-[83%] cursor-pointer rounded-lg border border-rc-green-450 bg-transparent p-2 pt-1 text-left text-rc-gray-100 backdrop-blur-md transition-colors hover:bg-rc-green-700 focus:outline-none focus-visible:outline-none disabled:cursor-wait disabled:opacity-70 ${z()===i(t).id?`bg-rc-green-700`:``}`),c(s,i(t).text)}),m(`click`,a,()=>n.onChooseVariant?.(i(t).id)),r(e,a)}),f(t),r(e,t)};S(N,e=>{M()&&i(t)===M()&&e(P)}),f(v),r(e,p)}),f(d),w(d,e=>W=e,()=>W);var h=T(d,2),E=e=>{var t=ke(),i=T(x(t),2),a=T(i,2);f(t),y(()=>i.disabled=!n.onRegenerateVariants||le()||z()!==null),m(`click`,i,()=>n.onRegenerateVariants?.()),m(`click`,a,()=>n.onCancelVariants?.()),r(e,t)},D=e=>{var t=Fe(),s=g(t),l=e=>{var t=Ae(),n=x(t,!0);f(t),y(()=>c(n,i(J))),r(e,t)};S(s,e=>{i(J)&&e(l)});var d=T(s,2),h=x(d),w=x(h),E=x(w),te=e=>{var t=Ne();u(t,23,()=>i(Q),e=>e.text,(e,t,n)=>{var a=Me();u(a,21,()=>i(t).segments,C,(e,t)=>{var n=je(),a=x(n,!0);f(n),y(()=>{k(n,1,p(i(t).matched?`text-rc-green-200`:``)),c(a,i(t).text)}),r(e,n)}),f(a),y(()=>{ee(a,`aria-selected`,i(Z)===i(n)),k(a,1,`w-full select-none border-b border-rc-gray-110 px-3 py-2 text-left font-semibold text-rc-gray-100 last:border-b-0 hover:bg-rc-gray-700/70 ${i(Z)===i(n)?`bg-rc-gray-700/70`:``}`)}),m(`mousedown`,a,e=>{e.preventDefault(),He(i(t))}),r(e,a)}),f(t),r(e,t)};S(E,e=>{i(Ve)&&e(te)});var D=T(E,2);{let e=b(()=>i(q)===`system`?`!border-emerald-500 !pl-[5.5rem] hover:!border-emerald-500 focus:!border-emerald-500`:`!pl-[4.25rem]`),t=b(()=>i(K)?`Generating`:`Enter message...`);ae(D,{variant:`chat`,get class(){return`!text-base !leading-6 !duration-75 ${i(e)??``}`},get placeholder(){return i(t)},autocomplete:`off`,get readonly(){return i(K)},onfocus:Ue,onblur:We,oninput:Ge,onkeydown:Ke,get value(){return i(H)},set value(e){v(H,e,!0)},get el(){return i(G)},set el(e){v(G,e,!0)}})}var O=T(D,2),A=x(O,!0);f(O);var j=T(O,2),M=e=>{var t=Pe(),n=x(t),a=x(n),o=x(a,!0);f(a);var s=T(a),l=x(s,!0);f(s),f(n),f(t),y(()=>{_(n,i(ye)),c(o,i(H)),c(l,i(ze))}),r(e,t)};S(j,e=>{i(Z)!==null&&i(ze)&&e(M)}),f(w);var F=T(w,2);{let e=b(()=>i(K)||!n.agentType);N(F,{size:`small`,variant:`secondary`,get disabled(){return i(e)},onclick:ut,children:(e,t)=>{var i=o(),a=g(i),s=e=>{P(e,{name:`paperclip`})},c=e=>{P(e,{name:`hangup`})};S(a,e=>{n.agentType===`text`?e(s):n.agentType===`voice`&&e(c,1)}),r(e,i)},$$slots:{default:!0}})}var ne=T(F,2),re=e=>{{let t=b(()=>i(K)||!i(gt));N(e,{size:`small`,type:`button`,title:`Generate response`,"aria-label":`Generate response`,get disabled(){return i(t)},class:`inline-flex !w-[59px] items-center justify-center !px-0`,onclick:e=>{e.preventDefault(),bt()},children:(e,t)=>{P(e,{name:`sparkles`})},$$slots:{default:!0}})}},I=e=>{{let t=b(()=>i(q)===`system`?`Send as system`:`Send as user`),n=b(()=>i(q)===`system`?`Send as system`:`Send as user`);N(e,{size:`small`,type:`submit`,get title(){return i(t)},get"aria-label"(){return i(n)},get disabled(){return i(K)},class:`inline-flex !w-[59px] items-center justify-center !px-0`,children:(e,t)=>{P(e,{name:`send`})},$$slots:{default:!0}})}};S(ne,e=>{i(Be)?e(re):e(I,-1)}),f(h),f(d),y(()=>{h.disabled=i(mt),ee(O,`title`,i(q)===`system`?`Switch to user`:`Switch to system`),ee(O,`aria-label`,i(q)===`system`?`Switch to user`:`Switch to system`),O.disabled=i(K),c(A,i(q)===`system`?`System`:`User`)}),a(`submit`,d,$e),m(`click`,O,e=>{e.preventDefault(),e.stopPropagation(),et()}),r(e,t)};S(h,e=>{M()?e(E):e(D,-1)}),a(`scroll`,d,e=>Ze(e.target)),r(e,l)},$$slots:{default:!0}}),r(e,xt),t()}e([`click`,`mousedown`]);var Z=s(`<div class="mt-1 w-max overflow-hidden rounded-lg border border-rc-gray-110 bg-rc-gray-930 shadow-inner-white-soft backdrop-blur-2xl" role="listbox"><!> <!> <!></div>`),Q=s(`<div class="flex h-full items-center justify-center text-sm text-rc-gray-300">Connecting…</div>`),Re=s(`<div class="flex h-full items-center justify-center text-sm text-rc-gray-300">Select an agent to start chatting</div>`),ze=s(`<div class="h-full min-h-0 p-2"><!></div>`),Be=s(`<div class="relative flex h-full min-h-0 flex-col"><div class="flex flex-none flex-nowrap items-center gap-2 p-2"><!> <div class="ml-auto flex flex-none flex-nowrap items-center gap-2"><!> <!> <!> <!></div></div> <div class="min-h-0 flex-1"><!></div></div>`);function Ve(e,n){d(n,!0);let{state:a,actions:s}=M(),c=E(!1),u=E(null),p=b(()=>{let e=a.currentStep?.name;return e?Object.values(a.promptEdits).find(t=>t.agentId===a.agentId&&t.step===e)?.id??null:null}),m=E(null),h=null,_=E(!1),y=E(null);b(()=>I.reduce((e,t)=>Math.max(e,ne(t)??0),0)),O(()=>{!I.length&&!R.length&&i(_)&&v(_,!1)});function C(e){let t=(e||``).trim();return t?t.split(`/`).at(-1)??t:`Agent`}function w(e){if(typeof e!=`number`||!Number.isFinite(e))return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}:${String(t.getSeconds()).padStart(2,`0`)}`}async function ee(e){if(i(c))return;v(c,!0);let t=s.openPopover(`analyze`),n=w(e.createdAt),r=n?` • ${n}`:``,o=`Analysis — ${C(a.agentId)}${r}`;try{let n=await F.agents.analyzeTrace.mutate({agentId:a.agentId,traceId:e.trace?.traceId,eventName:e.trace.eventName,createdAt:e.createdAt,model:e.model,renderedPrompt:e.renderedPrompt,stringifiedConversation:e.stringifiedConversation,response:e.response,stepTrace:e.stepTrace});if(a.edit.popover?.requestId!==t)return;s.setHighlightQuotes(n.quotes);let r=null;try{r=JSON.stringify(n.raw,null,2)}catch{r=null}s.setPopoverReady(t,{title:o,quotes:n.quotes,rationales:n.rationales,parallelCalls:n.parallelCalls,raw:r})}catch(e){console.error(e);let n=typeof e?.message==`string`?e.message:(()=>{try{return JSON.stringify(e)}catch{return String(e)}})();s.setPopoverError(t,n||`Failed to analyze this response`,{raw:n})}finally{v(c,!1)}}function te(e){return e?I:I.map(e=>{if(!re(e))return e;let{receivedPrompt:t,renderedPrompt:n,...r}=e;return r})}function D(e){v(m,e,!0),h&&clearTimeout(h),h=window.setTimeout(()=>{v(m,null),h=null},2e3)}async function k(){try{await navigator.clipboard.writeText(JSON.stringify(R,null,2)),D(`logs`)}catch(e){console.error(`Failed to copy logs`,e)}}async function j(e){try{await navigator.clipboard.writeText(JSON.stringify(te(e),null,2)),D(e?`with-prompts`:`without-prompts`)}catch(e){console.error(`Failed to copy traces`,e)}}function P(){L(),s.closePopover(),s.newConversation()}function ne(e){let t=e?.bosunTurn;return typeof t==`number`&&t>0?t:null}function ie(e){L();let t=ne(e);if(!t){console.warn(`Cannot regenerate: this response has no turn metadata`);return}s.regenerateFromTurn(t)}function L(){v(u,null)}async function ae(e){let t=a.conversationId;if(!t)return;let n=s.getPromptOverrides();await s.flushPromptSave(),v(u,{sourceTrace:e,choices:[],loading:!0,applyingId:null,error:null},!0);try{let r=await F.agents.generateVariants.mutate({conversationId:t,promptOverrides:n,count:9});if(!i(u)||i(u).sourceTrace!==e)return;v(u,{...i(u),choices:r,loading:!1,error:null},!0)}catch(t){if(console.error(`Failed to generate variants`,t),!i(u)||i(u).sourceTrace!==e)return;v(u,{...i(u),choices:[],loading:!1,error:typeof t?.message==`string`?t.message:`Failed to generate variants`},!0)}}function oe(e){ae(e)}function se(){s.hangup()}function ce(){let e=i(u)?.sourceTrace;e&&ae(e)}async function ue(e){let t=a.conversationId;if(!i(u)||!t)return;let n=i(u).choices.find(t=>t.id===e);if(n){v(u,{...i(u),applyingId:e,error:null},!0);try{await F.agents.commitVariant.mutate({conversationId:t,entries:n.entries,context:n.context}),L(),s.selectConversation(t)}catch(e){if(console.error(`Failed to apply variant`,e),!i(u))return;v(u,{...i(u),applyingId:null,error:typeof e?.message==`string`?e.message:`Failed to apply variant`},!0)}}}function de(){L()}O(()=>{let e=i(u),t=a.agentId,n=e?.sourceTrace;!e||!n||(!t||!I.includes(n))&&v(u,null)});var z=Be(),B=x(z),V=x(B),H=e=>{fe(e,{get conversations(){return a.conversations},get currentConversationId(){return a.conversationId},class:`ml-9`,onSelect:e=>s.selectConversation(e)})};S(V,e=>{a.conversations.length>0&&e(H)});var U=T(V,2),pe=x(U);{let e=b(()=>!a.context);N(pe,{variant:`secondary`,size:`small`,get disabled(){return i(e)},get"aria-expanded"(){return a.contextPopoverOpen},"aria-haspopup":`dialog`,get onclick(){return s.toggleContextPopover},children:(e,t)=>{l();var n=A(`Show context`);r(e,n)},$$slots:{default:!0}})}var me=T(pe,2);{let e=b(()=>!I.length&&!R.length);N(me,{variant:`secondary`,size:`small`,get disabled(){return i(e)},get"aria-expanded"(){return i(_)},"aria-haspopup":`listbox`,"aria-controls":`roleplay-copy-dropdown`,onclick:e=>{e.stopPropagation(),v(_,!i(_))},get el(){return i(y)},set el(e){v(y,e,!0)},children:(e,t)=>{var n=o(),a=g(n),s=e=>{var t=A(`Copied logs`);r(e,t)},c=e=>{var t=A(`Copied traces (with prompts)`);r(e,t)},l=e=>{var t=A(`Copied traces (without prompts)`);r(e,t)},u=e=>{var t=A(`Copy...`);r(e,t)};S(a,e=>{i(m)===`logs`?e(s):i(m)===`with-prompts`?e(c,1):i(m)===`without-prompts`?e(l,2):e(u,-1)}),r(e,n)},$$slots:{default:!0}})}var he=T(me,2);le(he,{id:`roleplay-copy-dropdown`,get open(){return i(_)},onClose:()=>v(_,!1),get anchorEl(){return i(y)},placement:`bottom-end`,offset:[0,1],children:e=>{var t=Z(),n=x(t);{let e=b(()=>!R.length);N(n,{variant:`ghost`,size:`small`,role:`option`,get disabled(){return i(e)},onclick:e=>{e.stopPropagation(),v(_,!1),k()},class:`block rounded-none border-b border-rc-gray-110 py-2 pr-3 text-left backdrop-blur-2xl hover:bg-rc-gray-700 focus:bg-rc-gray-400`,children:(e,t)=>{l();var n=A(`Copy logs`);r(e,n)},$$slots:{default:!0}})}var a=T(n,2);{let e=b(()=>!I.length);N(a,{variant:`ghost`,size:`small`,role:`option`,get disabled(){return i(e)},onclick:e=>{e.stopPropagation(),v(_,!1),j(!0)},class:`block rounded-none border-b border-rc-gray-110 py-2 pr-3 text-left backdrop-blur-2xl hover:bg-rc-gray-700 focus:bg-rc-gray-400`,children:(e,t)=>{l();var n=A(`Copy traces with prompts`);r(e,n)},$$slots:{default:!0}})}var o=T(a,2);{let e=b(()=>!I.length);N(o,{variant:`ghost`,size:`small`,role:`option`,get disabled(){return i(e)},onclick:e=>{e.stopPropagation(),v(_,!1),j(!1)},class:`block rounded-none py-2 pr-3 text-left backdrop-blur-2xl hover:bg-rc-gray-700 focus:bg-rc-gray-400`,children:(e,t)=>{l();var n=A(`Copy traces without prompts`);r(e,n)},$$slots:{default:!0}})}f(t),r(e,t)},$$slots:{default:!0}});var ge=T(he,2);N(ge,{size:`small`,onclick:P,children:(e,t)=>{l();var n=A(`New chat`);r(e,n)},$$slots:{default:!0}}),f(U),f(B);var _e=T(B,2),W=x(_e),ve=e=>{var t=Q();r(e,t)},G=e=>{var t=Re();r(e,t)},ye=e=>{var t=ze(),n=x(t);{let e=b(()=>i(u)?.sourceTrace??null),t=b(()=>i(u)?.choices??[]),r=b(()=>i(u)?.loading??!1),o=b(()=>i(u)?.applyingId??null),l=b(()=>i(u)?.error??null);X(n,{class:`h-full min-w-0`,context:null,get agentId(){return a.agentId},get promptEditProposalId(){return i(p)},get agentType(){return a.agentType},onmessage:e=>s.sendChatMessage(e),get analyzeDisabled(){return i(c)},onAnalyzeTrace:ee,onRegenerateTrace:ie,onSeeVariants:oe,onHangup:se,get variantSourceTrace(){return i(e)},get variantChoices(){return i(t)},get variantLoading(){return i(r)},get variantApplyingId(){return i(o)},get variantError(){return i(l)},onCancelVariants:L,onRegenerateVariants:ce,onChooseOriginalVariant:de,onChooseVariant:ue})}f(t),r(e,t)};S(W,e=>{!a.wsLoaded||!a.chatReady?e(ve):a.agentId?e(ye,-1):e(G,1)}),f(_e),f(z),r(e,z),t()}export{Ve as component};
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["../chunks/CUZn05nQ.js","../chunks/hePW80VL.js","../chunks/HclGiUj8.js","../chunks/C_yvzB4Z.js","../assets/editor.chSTM-fo.css","../assets/editor.BoJhDcRF.css"])))=>i.map(i=>d[i]);
2
- import{A as e,B as t,D as n,Dt as r,F as i,G as a,I as o,L as s,N as c,Nt as l,O as u,Ot as d,Pt as f,R as p,S as m,V as h,_ as g,a as _,at as v,b as ee,d as y,dt as b,et as x,f as S,g as C,gt as w,it as T,j as E,k as D,l as O,m as k,mt as A,n as j,o as M,ot as N,p as te,pt as P,q as F,r as I,st as L,tt as R,u as ne,w as re,x as z,z as B}from"../chunks/CPCsWwEy.js";import{t as V}from"../chunks/HclGiUj8.js";import"../chunks/xihTtKlq.js";import{t as H}from"../chunks/BOZLjogl.js";import{r as U,t as ie}from"../chunks/oarl--hZ.js";import{t as W}from"../chunks/6OCsQ6r7.js";import{t as ae}from"../chunks/Cf3l6QEG.js";import{n as oe,t as se}from"../chunks/BJqZY8o2.js";import{t as ce}from"../chunks/BP0Xadq7.js";import{i as le,t as ue}from"../chunks/BT98u4gR.js";import{t as G}from"../chunks/DWoqp3ac.js";import{a as de,c as fe,o as pe,r as K,s as me,t as he}from"../chunks/12bfCwgn.js";import{t as ge}from"../chunks/B9YnyJ2j.js";import{t as _e}from"../chunks/D3fLfD-Y.js";import{t as ve}from"../chunks/CL717zGu.js";var ye=/^[a-z0-9]+(-[a-z0-9]+)*$/,be=(e,t,n,r=``)=>{let i=e.split(`:`);if(e.slice(0,1)===`@`){if(i.length<2||i.length>3)return null;r=i.shift().slice(1)}if(i.length>3||!i.length)return null;if(i.length>1){let e=i.pop(),n=i.pop(),a={provider:i.length>0?i[0]:r,prefix:n,name:e};return t&&!xe(a)?null:a}let a=i[0],o=a.split(`-`);if(o.length>1){let e={provider:r,prefix:o.shift(),name:o.join(`-`)};return t&&!xe(e)?null:e}if(n&&r===``){let e={provider:r,prefix:``,name:a};return t&&!xe(e,n)?null:e}return null},xe=(e,t)=>e?!!((t&&e.prefix===``||e.prefix)&&e.name):!1;function Se(e,t){let n=e.icons,r=e.aliases||Object.create(null),i=Object.create(null);function a(e){if(n[e])return i[e]=[];if(!(e in i)){i[e]=null;let t=r[e]&&r[e].parent,n=t&&a(t);n&&(i[e]=[t].concat(n))}return i[e]}return Object.keys(n).concat(Object.keys(r)).forEach(a),i}var Ce=Object.freeze({left:0,top:0,width:16,height:16}),we=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Te=Object.freeze({...Ce,...we}),Ee=Object.freeze({...Te,body:``,hidden:!1});function De(e,t){let n={};!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0);let r=((e.rotate||0)+(t.rotate||0))%4;return r&&(n.rotate=r),n}function Oe(e,t){let n=De(e,t);for(let r in Ee)r in we?r in e&&!(r in n)&&(n[r]=we[r]):r in t?n[r]=t[r]:r in e&&(n[r]=e[r]);return n}function ke(e,t,n){let r=e.icons,i=e.aliases||Object.create(null),a={};function o(e){a=Oe(r[e]||i[e],a)}return o(t),n.forEach(o),Oe(e,a)}function q(e,t){let n=[];if(typeof e!=`object`||typeof e.icons!=`object`)return n;e.not_found instanceof Array&&e.not_found.forEach(e=>{t(e,null),n.push(e)});let r=Se(e);for(let i in r){let a=r[i];a&&(t(i,ke(e,i,a)),n.push(i))}return n}var Ae={provider:``,aliases:{},not_found:{},...Ce};function je(e,t){for(let n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function Me(e){if(typeof e!=`object`||!e)return null;let t=e;if(typeof t.prefix!=`string`||!e.icons||typeof e.icons!=`object`||!je(e,Ae))return null;let n=t.icons;for(let e in n){let t=n[e];if(!e||typeof t.body!=`string`||!je(t,Ee))return null}let r=t.aliases||Object.create(null);for(let e in r){let t=r[e],i=t.parent;if(!e||typeof i!=`string`||!n[i]&&!r[i]||!je(t,Ee))return null}return t}var Ne=Object.create(null);function Pe(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function Fe(e,t){let n=Ne[e]||(Ne[e]=Object.create(null));return n[t]||(n[t]=Pe(e,t))}function J(e,t){return Me(t)?q(t,(t,n)=>{n?e.icons[t]=n:e.missing.add(t)}):[]}function Ie(e,t,n){try{if(typeof n.body==`string`)return e.icons[t]={...n},!0}catch{}return!1}var Le=!1;function Re(e){return typeof e==`boolean`&&(Le=e),Le}function ze(e){let t=typeof e==`string`?be(e,!0,Le):e;if(t){let e=Fe(t.provider,t.prefix),n=t.name;return e.icons[n]||(e.missing.has(n)?null:void 0)}}function Be(e,t){let n=be(e,!0,Le);if(!n)return!1;let r=Fe(n.provider,n.prefix);return t?Ie(r,n.name,t):(r.missing.add(n.name),!0)}function Ve(e,t){if(typeof e!=`object`)return!1;if(typeof t!=`string`&&(t=e.provider||``),Le&&!t&&!e.prefix){let t=!1;return Me(e)&&(e.prefix=``,q(e,(e,n)=>{Be(e,n)&&(t=!0)})),t}let n=e.prefix;return xe({prefix:n,name:`a`})?!!J(Fe(t,n),e):!1}var He=Object.freeze({width:null,height:null}),Ue=Object.freeze({...He,...we}),Y=/(-?[0-9.]*[0-9]+[0-9.]*)/g,We=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function X(e,t,n){if(t===1)return e;if(n||=100,typeof e==`number`)return Math.ceil(e*t*n)/n;if(typeof e!=`string`)return e;let r=e.split(Y);if(r===null||!r.length)return e;let i=[],a=r.shift(),o=We.test(a);for(;;){if(o){let e=parseFloat(a);isNaN(e)?i.push(a):i.push(Math.ceil(e*t*n)/n)}else i.push(a);if(a=r.shift(),a===void 0)return i.join(``);o=!o}}function Ge(e,t=`defs`){let n=``,r=e.indexOf(`<`+t);for(;r>=0;){let i=e.indexOf(`>`,r),a=e.indexOf(`</`+t);if(i===-1||a===-1)break;let o=e.indexOf(`>`,a);if(o===-1)break;n+=e.slice(i+1,a).trim(),e=e.slice(0,r).trim()+e.slice(o+1)}return{defs:n,content:e}}function Ke(e,t){return e?`<defs>`+e+`</defs>`+t:t}function qe(e,t,n){let r=Ge(e);return Ke(r.defs,t+r.content+n)}var Z=e=>e===`unset`||e===`undefined`||e===`none`;function Je(e,t){let n={...Te,...e},r={...Ue,...t},i={left:n.left,top:n.top,width:n.width,height:n.height},a=n.body;[n,r].forEach(e=>{let t=[],n=e.hFlip,r=e.vFlip,o=e.rotate;n?r?o+=2:(t.push(`translate(`+(i.width+i.left).toString()+` `+(0-i.top).toString()+`)`),t.push(`scale(-1 1)`),i.top=i.left=0):r&&(t.push(`translate(`+(0-i.left).toString()+` `+(i.height+i.top).toString()+`)`),t.push(`scale(1 -1)`),i.top=i.left=0);let s;switch(o<0&&(o-=Math.floor(o/4)*4),o%=4,o){case 1:s=i.height/2+i.top,t.unshift(`rotate(90 `+s.toString()+` `+s.toString()+`)`);break;case 2:t.unshift(`rotate(180 `+(i.width/2+i.left).toString()+` `+(i.height/2+i.top).toString()+`)`);break;case 3:s=i.width/2+i.left,t.unshift(`rotate(-90 `+s.toString()+` `+s.toString()+`)`)}o%2==1&&(i.left!==i.top&&(s=i.left,i.left=i.top,i.top=s),i.width!==i.height&&(s=i.width,i.width=i.height,i.height=s)),t.length&&(a=qe(a,`<g transform="`+t.join(` `)+`">`,`</g>`))});let o=r.width,s=r.height,c=i.width,l=i.height,u,d;o===null?(d=s===null?`1em`:s===`auto`?l:s,u=X(d,c/l)):(u=o===`auto`?c:o,d=s===null?X(u,l/c):s===`auto`?l:s);let f={},p=(e,t)=>{Z(t)||(f[e]=t.toString())};p(`width`,u),p(`height`,d);let m=[i.left,i.top,c,l];return f.viewBox=m.join(` `),{attributes:f,viewBox:m,body:a}}var Ye=/\sid="(\S+)"/g,Xe=new Map;function Ze(e){e=e.replace(/[0-9]+$/,``)||`a`;let t=Xe.get(e)||0;return Xe.set(e,t+1),t?`${e}${t}`:e}function Qe(e){let t=[],n;for(;n=Ye.exec(e);)t.push(n[1]);if(!t.length)return e;let r=`suffix`+(Math.random()*16777216|Date.now()).toString(16);return t.forEach(t=>{let n=Ze(t),i=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);e=e.replace(RegExp(`([#;"])(`+i+`)([")]|\\.[a-z])`,`g`),`$1`+n+r+`$3`)}),e=e.replace(new RegExp(r,`g`),``),e}var $e=Object.create(null);function et(e,t){$e[e]=t}function tt(e){return $e[e]||$e[``]}function nt(e){let t;if(typeof e.resources==`string`)t=[e.resources];else if(t=e.resources,!(t instanceof Array)||!t.length)return null;return{resources:t,path:e.path||`/`,maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}for(var rt=Object.create(null),it=[`https://api.simplesvg.com`,`https://api.unisvg.com`],at=[];it.length>0;)it.length===1||Math.random()>.5?at.push(it.shift()):at.push(it.pop());rt[``]=nt({resources:[`https://api.iconify.design`].concat(at)});function Q(e,t){let n=nt(t);return n!==null&&(rt[e]=n,!0)}function $(e){return rt[e]}var ot=(()=>{let e;try{if(e=fetch,typeof e==`function`)return e}catch{}})();function st(e,t){let n=$(e);if(!n)return 0;let r;if(!n.maxURL)r=0;else{let e=0;n.resources.forEach(t=>{e=Math.max(e,t.length)});let i=t+`.json?icons=`;r=n.maxURL-e-n.path.length-i.length}return r}function ct(e){return e===404}var lt=(e,t,n)=>{let r=[],i=st(e,t),a=`icons`,o={type:a,provider:e,prefix:t,icons:[]},s=0;return n.forEach((n,c)=>{s+=n.length+1,s>=i&&c>0&&(r.push(o),o={type:a,provider:e,prefix:t,icons:[]},s=n.length),o.icons.push(n)}),r.push(o),r};function ut(e){if(typeof e==`string`){let t=$(e);if(t)return t.path}return`/`}var dt={prepare:lt,send:(e,t,n)=>{if(!ot){n(`abort`,424);return}let r=ut(t.provider);switch(t.type){case`icons`:{let e=t.prefix,n=t.icons.join(`,`),i=new URLSearchParams({icons:n});r+=e+`.json?`+i.toString();break}case`custom`:{let e=t.uri;r+=e.slice(0,1)===`/`?e.slice(1):e;break}default:n(`abort`,400);return}let i=503;ot(e+r).then(e=>{let t=e.status;if(t!==200){setTimeout(()=>{n(ct(t)?`abort`:`next`,t)});return}return i=501,e.json()}).then(e=>{if(typeof e!=`object`||!e){setTimeout(()=>{e===404?n(`abort`,e):n(`next`,i)});return}setTimeout(()=>{n(`success`,e)})}).catch(()=>{n(`next`,i)})}};function ft(e,t){e.forEach(e=>{let n=e.loaderCallbacks;n&&(e.loaderCallbacks=n.filter(e=>e.id!==t))})}function pt(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;let t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1,r=e.provider,i=e.prefix;t.forEach(t=>{let a=t.icons,o=a.pending.length;a.pending=a.pending.filter(t=>{if(t.prefix!==i)return!0;let o=t.name;if(e.icons[o])a.loaded.push({provider:r,prefix:i,name:o});else if(e.missing.has(o))a.missing.push({provider:r,prefix:i,name:o});else return n=!0,!0;return!1}),a.pending.length!==o&&(n||ft([e],t.id),t.callback(a.loaded.slice(0),a.missing.slice(0),a.pending.slice(0),t.abort))})}))}var mt=0;function ht(e,t,n){let r=mt++,i=ft.bind(null,n,r);if(!t.pending.length)return i;let a={id:r,icons:t,callback:e,abort:i};return n.forEach(e=>{(e.loaderCallbacks||=[]).push(a)}),i}function gt(e){let t={loaded:[],missing:[],pending:[]},n=Object.create(null);e.sort((e,t)=>e.provider===t.provider?e.prefix===t.prefix?e.name.localeCompare(t.name):e.prefix.localeCompare(t.prefix):e.provider.localeCompare(t.provider));let r={provider:``,prefix:``,name:``};return e.forEach(e=>{if(r.name===e.name&&r.prefix===e.prefix&&r.provider===e.provider)return;r=e;let i=e.provider,a=e.prefix,o=e.name,s=n[i]||(n[i]=Object.create(null)),c=s[a]||(s[a]=Fe(i,a)),l;l=o in c.icons?t.loaded:a===``||c.missing.has(o)?t.missing:t.pending;let u={provider:i,prefix:a,name:o};l.push(u)}),t}function _t(e,t=!0,n=!1){let r=[];return e.forEach(e=>{let i=typeof e==`string`?be(e,t,n):e;i&&r.push(i)}),r}var vt={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function yt(e,t,n,r){let i=e.resources.length,a=e.random?Math.floor(Math.random()*i):e.index,o;if(e.random){let t=e.resources.slice(0);for(o=[];t.length>1;){let e=Math.floor(Math.random()*t.length);o.push(t[e]),t=t.slice(0,e).concat(t.slice(e+1))}o=o.concat(t)}else o=e.resources.slice(a).concat(e.resources.slice(0,a));let s=Date.now(),c=`pending`,l=0,u,d=null,f=[],p=[];typeof r==`function`&&p.push(r);function m(){d&&=(clearTimeout(d),null)}function h(){c===`pending`&&(c=`aborted`),m(),f.forEach(e=>{e.status===`pending`&&(e.status=`aborted`)}),f=[]}function g(e,t){t&&(p=[]),typeof e==`function`&&p.push(e)}function _(){return{startTime:s,payload:t,status:c,queriesSent:l,queriesPending:f.length,subscribe:g,abort:h}}function v(){c=`failed`,p.forEach(e=>{e(void 0,u)})}function ee(){f.forEach(e=>{e.status===`pending`&&(e.status=`aborted`)}),f=[]}function y(t,n,r){let i=n!==`success`;switch(f=f.filter(e=>e!==t),c){case`pending`:break;case`failed`:if(i||!e.dataAfterTimeout)return;break;default:return}if(n===`abort`){u=r,v();return}if(i){u=r,f.length||(o.length?b():v());return}if(m(),ee(),!e.random){let n=e.resources.indexOf(t.resource);n!==-1&&n!==e.index&&(e.index=n)}c=`completed`,p.forEach(e=>{e(r)})}function b(){if(c!==`pending`)return;m();let r=o.shift();if(r===void 0){if(f.length){d=setTimeout(()=>{m(),c===`pending`&&(ee(),v())},e.timeout);return}v();return}let i={status:`pending`,resource:r,callback:(e,t)=>{y(i,e,t)}};f.push(i),l++,d=setTimeout(b,e.rotate),n(r,t,i.callback)}return setTimeout(b),_}function bt(e){let t={...vt,...e},n=[];function r(){n=n.filter(e=>e().status===`pending`)}function i(e,i,a){let o=yt(t,e,i,(e,t)=>{r(),a&&a(e,t)});return n.push(o),o}function a(e){return n.find(t=>e(t))||null}return{query:i,find:a,setIndex:e=>{t.index=e},getIndex:()=>t.index,cleanup:r}}function xt(){}var St=Object.create(null);function Ct(e){if(!St[e]){let t=$(e);if(!t)return;St[e]={config:t,redundancy:bt(t)}}return St[e]}function wt(e,t,n){let r,i;if(typeof e==`string`){let t=tt(e);if(!t)return n(void 0,424),xt;i=t.send;let a=Ct(e);a&&(r=a.redundancy)}else{let t=nt(e);if(t){r=bt(t);let n=tt(e.resources?e.resources[0]:``);n&&(i=n.send)}}return!r||!i?(n(void 0,424),xt):r.query(t,i,n)().abort}function Tt(){}function Et(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,pt(e)}))}function Dt(e){let t=[],n=[];return e.forEach(e=>{(e.match(ye)?t:n).push(e)}),{valid:t,invalid:n}}function Ot(e,t,n){function r(){let n=e.pendingIcons;t.forEach(t=>{n&&n.delete(t),e.icons[t]||e.missing.add(t)})}if(n&&typeof n==`object`)try{if(!J(e,n).length){r();return}}catch(e){console.error(e)}r(),Et(e)}function kt(e,t){e instanceof Promise?e.then(e=>{t(e)}).catch(()=>{t(null)}):t(e)}function At(e,t){e.iconsToLoad=e.iconsToLoad?e.iconsToLoad.concat(t).sort():t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;let{provider:t,prefix:n}=e,r=e.iconsToLoad;if(delete e.iconsToLoad,!r||!r.length)return;let i=e.loadIcon;if(e.loadIcons&&(r.length>1||!i)){kt(e.loadIcons(r,n,t),t=>{Ot(e,r,t)});return}if(i){r.forEach(r=>{kt(i(r,n,t),t=>{Ot(e,[r],t?{prefix:n,icons:{[r]:t}}:null)})});return}let{valid:a,invalid:o}=Dt(r);if(o.length&&Ot(e,o,null),!a.length)return;let s=n.match(ye)?tt(t):null;if(!s){Ot(e,a,null);return}s.prepare(t,n,a).forEach(n=>{wt(t,n,t=>{Ot(e,n.icons,t)})})}))}var jt=(e,t)=>{let n=gt(_t(e,!0,Re()));if(!n.pending.length){let e=!0;return t&&setTimeout(()=>{e&&t(n.loaded,n.missing,n.pending,Tt)}),()=>{e=!1}}let r=Object.create(null),i=[],a,o;return n.pending.forEach(e=>{let{provider:t,prefix:n}=e;if(n===o&&t===a)return;a=t,o=n,i.push(Fe(t,n));let s=r[t]||(r[t]=Object.create(null));s[n]||(s[n]=[])}),n.pending.forEach(e=>{let{provider:t,prefix:n,name:i}=e,a=Fe(t,n),o=a.pendingIcons||=new Set;o.has(i)||(o.add(i),r[t][n].push(i))}),i.forEach(e=>{let t=r[e.provider][e.prefix];t.length&&At(e,t)}),t?ht(t,n,i):Tt};function Mt(e,t){let n={...e};for(let e in t){let r=t[e],i=typeof r;e in He?(r===null||r&&(i===`string`||i===`number`))&&(n[e]=r):i===typeof n[e]&&(n[e]=e===`rotate`?r%4:r)}return n}var Nt=/[\s,]+/;function Pt(e,t){t.split(Nt).forEach(t=>{switch(t.trim()){case`horizontal`:e.hFlip=!0;break;case`vertical`:e.vFlip=!0}})}function Ft(e,t=0){let n=e.replace(/^-?[0-9.]*/,``);function r(e){for(;e<0;)e+=4;return e%4}if(n===``){let t=parseInt(e);return isNaN(t)?0:r(t)}if(n!==e){let t=0;switch(n){case`%`:t=25;break;case`deg`:t=90}if(t){let i=parseFloat(e.slice(0,e.length-n.length));return isNaN(i)?0:(i/=t,i%1==0?r(i):0)}}return t}function It(e,t){let n=e.indexOf(`xlink:`)===-1?``:` xmlns:xlink="http://www.w3.org/1999/xlink"`;for(let e in t)n+=` `+e+`="`+t[e]+`"`;return`<svg xmlns="http://www.w3.org/2000/svg"`+n+`>`+e+`</svg>`}function Lt(e){return e.replace(/"/g,`'`).replace(/%/g,`%25`).replace(/#/g,`%23`).replace(/</g,`%3C`).replace(/>/g,`%3E`).replace(/\s+/g,` `)}function Rt(e){return`data:image/svg+xml,`+Lt(e)}function zt(e){return`url("`+Rt(e)+`")`}var Bt={...Ue,inline:!1},Vt={xmlns:`http://www.w3.org/2000/svg`,"xmlns:xlink":`http://www.w3.org/1999/xlink`,"aria-hidden":!0,role:`img`},Ht={display:`inline-block`},Ut={"background-color":`currentColor`},Wt={"background-color":`transparent`},Gt={image:`var(--svg)`,repeat:`no-repeat`,size:`100% 100%`},Kt={"-webkit-mask":Ut,mask:Ut,background:Wt};for(let e in Kt){let t=Kt[e];for(let n in Gt)t[e+`-`+n]=Gt[n]}function qt(e){return e+(e.match(/^[-0-9.]+$/)?`px`:``)}function Jt(e,t){let n=Mt(Bt,t),r=t.mode||`svg`,i=r===`svg`?{...Vt}:{};e.body.indexOf(`xlink:`)===-1&&delete i[`xmlns:xlink`];let a=typeof t.style==`string`?t.style:``;for(let e in t){let r=t[e];if(r!==void 0)switch(e){case`icon`:case`style`:case`onLoad`:case`mode`:case`ssr`:break;case`inline`:case`hFlip`:case`vFlip`:n[e]=r===!0||r===`true`||r===1;break;case`flip`:typeof r==`string`&&Pt(n,r);break;case`color`:a=a+(a.length>0&&a.trim().slice(-1)!==`;`?`;`:``)+`color: `+r+`; `;break;case`rotate`:typeof r==`string`?n[e]=Ft(r):typeof r==`number`&&(n[e]=r);break;case`ariaHidden`:case`aria-hidden`:r!==!0&&r!==`true`&&delete i[`aria-hidden`];break;default:if(e.slice(0,3)===`on:`)break;Bt[e]===void 0&&(i[e]=r)}}let o=Je(e,n),s=o.attributes;if(n.inline&&(a=`vertical-align: -0.125em; `+a),r===`svg`)return Object.assign(i,s),a!==``&&(i.style=a),{svg:!0,attributes:i,body:Qe(o.body)};let{body:c,width:l,height:u}=e,d=r===`mask`||r!==`bg`&&c.indexOf(`currentColor`)!==-1,f={"--svg":zt(It(c,{...s,width:l+``,height:u+``}))},p=e=>{let t=s[e];t&&(f[e]=qt(t))};p(`width`),p(`height`),Object.assign(f,Ht,d?Ut:Wt);let m=``;for(let e in f)m+=e+`: `+f[e]+`;`;return i.style=m+a,{svg:!1,attributes:i}}if(Re(!0),et(``,dt),typeof document<`u`&&typeof window<`u`){let e=window;if(e.IconifyPreload!==void 0){let t=e.IconifyPreload,n=`Invalid IconifyPreload syntax.`;typeof t==`object`&&t&&(t instanceof Array?t:[t]).forEach(e=>{try{(typeof e!=`object`||!e||e instanceof Array||typeof e.icons!=`object`||typeof e.prefix!=`string`||!Ve(e))&&console.error(n)}catch{console.error(n)}})}if(e.IconifyProviders!==void 0){let t=e.IconifyProviders;if(typeof t==`object`&&t)for(let e in t){let n=`IconifyProviders[`+e+`] is invalid.`;try{let r=t[e];if(typeof r!=`object`||!r||r.resources===void 0)continue;Q(e,r)||console.error(n)}catch{console.error(n)}}}}function Yt(){try{return typeof window!=`object`}catch{return!0}}function Xt(e,t,n,r){function i(){t.loading&&=(t.loading.abort(),null)}if(typeof e==`object`&&e&&typeof e.body==`string`)return t.name=``,i(),{data:{...Te,...e}};let a;if(typeof e!=`string`||(a=be(e,!1,!0))===null)return i(),null;let o=ze(a);if(!o)return!Yt()&&(!t.loading||t.loading.name!==e)&&(i(),t.name=``,t.loading={name:e,abort:jt([a],n)}),null;i(),t.name!==e&&(t.name=e,r&&!t.destroyed&&setTimeout(()=>{r(e)}));let s=[`iconify`];return a.prefix!==``&&s.push(`iconify--`+a.prefix),a.provider!==``&&s.push(`iconify--`+a.provider),{data:o,classes:s}}function Zt(e,t){return e?Jt({...Te,...e},t):null}var Qt=new Set([`$$slots`,`$$events`,`$$legacy`]),$t=p(`<svg></svg>`),en=s(`<span></span>`);function tn(e,t){d(t,!0);let s={name:``,loading:null,destroyed:!1},c=M(t,Qt),l=P(0),u=w(()=>(a(l),Xt(t.icon,s,m,t.onload))),p=w(()=>{let e=a(u)?Zt(a(u).data,c):null;return e&&a(u).classes&&c.class===void 0&&(e.attributes.class=(typeof c.class==`string`?c.class+` `:``)+a(u).classes.join(` `)),e});function m(){A(l)}j(()=>{s.destroyed=!0,s.loading&&=(s.loading.abort(),null)});var h=o(),g=v(h),_=e=>{var t=o(),r=v(t),s=e=>{var t=$t();S(t,()=>({...a(p).attributes})),n(t,()=>a(p).body,!0),f(t),i(e,t)},c=e=>{var t=en();S(t,()=>({...a(p).attributes})),i(e,t)};E(r,e=>{a(p).svg?e(s):e(c,-1)}),i(e,t)};E(g,e=>{a(p)&&e(_)}),i(e,h),r()}var nn=s(`<div class="w-full"></div>`);function rn(e,t){d(t,!0);let n=P(null),o=null,s=[],c=null,l=!1,u,f=_(t,`language`,3,`plaintext`),p=_(t,`height`,3,120),m=_(t,`readOnly`,3,!1),h=null,g=P(!1),v=P(!1);function y(e){a(v)||e.stopPropagation()}I(async()=>{if(!u)return;u.addEventListener(`wheel`,y,{capture:!0,passive:!0}),me();let e=await V(()=>import(`../chunks/CUZn05nQ.js`).then(e=>e.t),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url);if(l)return;c=e,pe(e);let r=f()===`json`?`json`:f()===`markdown`?`markdown`:`plaintext`;b(n,e.editor.create(u,{...de(`test-history`),value:t.value??``,language:r,readOnly:m(),domReadOnly:m()}),!0);let i=a(n);if(!i)return;o=i.getModel(),h=K(e,i),h.update(t.highlights??[]),b(g,!0),s.push(i.onDidFocusEditorText(()=>{b(v,!0)})),s.push(i.onDidChangeModelContent(()=>{try{let e=i.getValue();if(e===t.value)return;t.onChange?.(e)}catch(e){console.error(`MiniEditor change error`,e)}})),s.push(i.onDidBlurEditorText(()=>{b(v,!1);try{t.onBlur?.(i.getValue())}catch{}}));let d=i.onDidFocusEditorWidget?.(()=>{b(v,!0)});d&&s.push(d);let p=i.onDidBlurEditorWidget?.(()=>{b(v,!1);try{t.onBlur?.(i.getValue())}catch{}});p&&s.push(p)}),j(()=>{l=!0,b(g,!1);try{u.removeEventListener(`wheel`,y,{capture:!0})}catch{}for(let e of s)try{e.dispose()}catch{}s=[],h?.dispose(),h=null;let e=o;o=null;try{if(a(n)){try{a(n).setModel(null)}catch{}a(n).dispose()}}finally{b(n,null)}try{e?.dispose()}catch{}c=null}),R(()=>{if(!a(n))return;let e=f()===`json`?`json`:f()===`markdown`?`markdown`:`plaintext`,t=a(n).getModel();if(!t||t.getLanguageId()===e)return;let r=!1;return(c?Promise.resolve(c):V(()=>import(`../chunks/CUZn05nQ.js`).then(e=>e.t),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).then(n=>{if(!r)try{n.editor.setModelLanguage(t,e)}catch{}}),()=>{r=!0}}),R(()=>{let e=t.value??``,r=t.highlights??[];!a(n)||!a(g)||(e!==a(n).getValue()&&a(n).setValue(e),h?.update(r))}),R(()=>{a(n)?.updateOptions({readOnly:m(),domReadOnly:m()})});var S=nn();O(S,e=>u=e,()=>u),x(()=>ee(S,`height:${p()}px`)),i(e,S),r()}var an=s(`<button type="button" class="inline-flex items-center text-nowrap rounded border-0 bg-transparent px-1 py-0.5 text-rc-gray-400 transition-colors hover:bg-rc-gray-900 hover:text-rc-gray-200 focus:outline-none focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-rc-gray-400">Fix</button>`),on=s(`<button type="button" class="inline-flex items-center text-nowrap rounded border-0 bg-transparent px-1 py-0.5 text-rc-gray-400 transition-colors hover:bg-rc-gray-900 hover:text-rc-gray-200 focus:outline-none focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-rc-gray-400">Analyze</button>`),sn=s(`<div><div class="mb-1 text-xs text-rc-gray-300"> </div> <div class="whitespace-pre-wrap break-words text-rc-gray-100"> </div></div>`),cn=s(`<div class="flex flex-col gap-3"></div>`),ln=s(`<div class="p-2 text-rc-gray-300">Loading…</div>`),un=s(`<div class="p-2 text-red-400"> </div>`),dn=s(`<div class="flex h-full flex-col gap-2"><div class="grid grid-cols-2 gap-2"><div class="flex items-center justify-start"><!></div> <div class="flex items-center justify-end"><!></div></div> <!></div>`),fn=s(`<div class="h-[55vh]"><!></div>`),pn=s(`<!> <!> <!>`,1),mn=s(`<!> <div class="mt-2 h-[55vh]"><!></div>`,1),hn=s(`<div class="mt-1 flex flex-wrap items-center gap-x-2 gap-y-1"><!> <button type="button" class="inline-flex items-center text-nowrap rounded border-0 bg-transparent px-1 py-0.5 text-rc-gray-400 transition-colors hover:bg-rc-gray-900 hover:text-rc-gray-200 focus:outline-none focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-rc-gray-400"> </button> <!> <button type="button" class="inline-flex items-center text-nowrap rounded border-0 bg-transparent px-1 py-0.5 text-rc-gray-400 transition-colors hover:bg-rc-gray-900 hover:text-rc-gray-200 focus:outline-none focus-visible:outline-none">See variants</button> <button type="button" class="inline-flex items-center text-nowrap rounded border-0 bg-transparent px-1 py-0.5 text-rc-gray-400 transition-colors hover:bg-rc-gray-900 hover:text-rc-gray-200 focus:outline-none focus-visible:outline-none">Prompt</button> <button type="button" class="inline-flex items-center text-nowrap rounded border-0 bg-transparent px-1 py-0.5 text-rc-gray-400 transition-colors hover:bg-rc-gray-900 hover:text-rc-gray-200 focus:outline-none focus-visible:outline-none">Conversation</button> <button type="button" class="inline-flex items-center text-nowrap rounded border-0 bg-transparent px-1 py-0.5 text-rc-gray-400 transition-colors hover:bg-rc-gray-900 hover:text-rc-gray-200 focus:outline-none focus-visible:outline-none">Context</button> <button type="button" class="inline-flex items-center text-nowrap rounded border-0 bg-transparent px-1 py-0.5 text-rc-gray-400 transition-colors hover:bg-rc-gray-900 hover:text-rc-gray-200 focus:outline-none focus-visible:outline-none">Debug</button></div> <!> <!> <!>`,1);function gn(e,t){d(t,!0);let n=_(t,`actionsDisabled`,3,!1),o=_(t,`actionsInert`,3,!1),s=_(t,`addTestDisabled`,3,!1),p=_(t,`showAnalyze`,3,!0),m=_(t,`analyzeDisabled`,3,!1),g=_(t,`fixDisabled`,3,!1),ee=P(!1),y=P(!1),S=P(!1),C=P(`errors`),D=P(`prompt`),O=P(null),k=P(null),A=P(null),M=P(null),te=P(null),F=P(null),I=P(null),R=P(L({prompt:!1,conversation:!1,context:!1,errors:!1,traces:!1,logs:!1})),ne=P(L({prompt:null,conversation:null,context:null,errors:null,traces:null,logs:null})),re=0,V=P(null),H=null,U=P(`idle`),ie=null;function ae(e){try{return{raw:e,formatted:JSON.stringify(JSON.parse(e),null,2)}}catch{return{raw:e,formatted:e}}}async function le(e){return ae(await G.tests.resultEntry.query({agent:e.agent,testId:e.id,resultKey:e.key,timestamp:e.timestamp,index:e.run}))}function ue(e){return e===`prompt`?a(k)!==null&&a(O)!==null:e===`conversation`?a(A)!==null:e===`context`?a(M)!==null:e===`errors`?a(te)!==null:e===`traces`?a(F)!==null:a(I)!==null}async function de(e){if(ue(e)||a(R)[e])return;let n=re;b(R,{...a(R),[e]:!0},!0),b(ne,{...a(ne),[e]:null},!0);try{if(e===`prompt`){let[e,r]=await Promise.all([le(t.links.renderedPrompt),le(t.links.receivedPrompt)]);if(n!==re)return;b(O,e,!0),b(k,r,!0)}else{let r=await le(e===`conversation`?t.links.conversation:e===`context`?t.links.context:e===`errors`?t.links.errors:e===`traces`?t.links.traces:t.links.logs);if(n!==re)return;b(e===`conversation`?A:e===`context`?M:e===`errors`?te:e===`traces`?F:I,r,!0)}}catch(t){if(n!==re)return;console.error(t),b(ne,{...a(ne),[e]:`Failed to load content`},!0)}finally{n===re&&b(R,{...a(R),[e]:!1},!0)}}function fe(){b(O,null),b(k,null),b(A,null),b(M,null),b(te,null),b(F,null),b(I,null),b(R,{prompt:!1,conversation:!1,context:!1,errors:!1,traces:!1,logs:!1},!0),b(ne,{prompt:null,conversation:null,context:null,errors:null,traces:null,logs:null},!0)}function pe(){re+=1,b(C,`errors`),fe(),b(ee,!0),de(`errors`)}function K(e){re+=1,b(D,e,!0),fe(),b(y,!0),de(e)}function me(e){return e===`prompt`?`Prompt`:e===`conversation`?`Conversation`:`Context`}function ge(e){b(C,e,!0),de(e)}async function _e(){if(a(U)!==`adding`){b(U,`adding`);try{await t.onAddTest(),b(U,`added`)}catch(e){console.error(`Failed to add test`,e),b(U,`failed`)}ie&&clearTimeout(ie),ie=window.setTimeout(()=>{b(U,`idle`),ie=null},2500)}}async function ye(e){if(!(!a(k)||!a(O)))try{let t=e===`raw`?a(k).raw:a(O).raw;await navigator.clipboard.writeText(t),b(V,e,!0),H&&clearTimeout(H),H=window.setTimeout(()=>{b(V,null),H=null},2e3)}catch(e){console.error(`Failed to copy prompt`,e)}}j(()=>{re+=1,H&&clearTimeout(H),ie&&clearTimeout(ie)});var be=hn(),xe=v(be),Se=T(xe),Ce=e=>{var r=an();x(()=>{r.inert=o(),r.disabled=n()||g()}),h(`click`,r,function(...e){t.onFix?.apply(this,e)}),i(e,r)};E(Se,e=>{t.onFix&&e(Ce)});var we=N(Se,2),Te=T(we,!0);f(we);var Ee=N(we,2),De=e=>{var n=on();x(()=>n.disabled=m()),h(`click`,n,function(...e){t.onAnalyze?.apply(this,e)}),i(e,n)};E(Ee,e=>{p()&&e(De)});var Oe=N(Ee,2),ke=N(Oe,2),q=N(ke,2),Ae=N(q,2),je=N(Ae,2);f(xe);var Me=N(xe,2),Ne=e=>{{let n=e=>{var n=cn();u(n,21,()=>t.variants,e=>e.index,(e,n)=>{var r=sn(),o=T(r),s=T(o);f(o);var l=N(o,2),u=T(l,!0);f(l),f(r),x(()=>{z(r,1,`rounded-lg border p-3 ${a(n).index===t.runIndex?`border-rc-green-450`:`border-rc-gray-650`} ${a(n).success?`bg-rc-green-700/80`:`bg-rc-gray-900/60`}`),c(s,`Run ${a(n).index??``}${a(n).index===t.runIndex?` • selected`:``}`),c(u,a(n).text||a(n).errors||`—`)}),i(e,r)}),f(n),i(e,n)},r=w(()=>`Variants — ${t.scenario||`Test`}`);ce(e,{get title(){return a(r)},class:`!w-[80vw] !max-w-4xl`,get open(){return a(S)},set open(e){b(S,e,!0)},children:n,$$slots:{default:!0}})}};E(Me,e=>{a(S)&&e(Ne)});var Pe=N(Me,2),Fe=e=>{{let n=e=>{var t=fn(),n=T(t),r=e=>{var t=ln();i(e,t)},o=e=>{var t=un(),n=T(t,!0);f(t),x(()=>c(n,a(ne)[a(D)])),i(e,t)},s=e=>{var t=dn(),n=T(t),r=T(n),o=T(r);{let e=w(()=>!a(k).raw.trim());W(o,{variant:`secondary`,size:`small`,get disabled(){return a(e)},onclick:()=>ye(`raw`),children:(e,t)=>{l();var n=B();x(()=>c(n,a(V)===`raw`?`Copied raw prompt`:`Copy raw prompt`)),i(e,n)},$$slots:{default:!0}})}f(r);var s=N(r,2),u=T(s);{let e=w(()=>!a(O).raw.trim());W(u,{variant:`secondary`,size:`small`,get disabled(){return a(e)},onclick:()=>ye(`rendered`),children:(e,t)=>{l();var n=B();x(()=>c(n,a(V)===`rendered`?`Copied rendered prompt`:`Copy rendered prompt`)),i(e,n)},$$slots:{default:!0}})}f(s),f(n);var d=N(n,2);he(d,{variant:`generic`,get original(){return a(k).formatted},get modified(){return a(O).formatted},language:`markdown`,class:`min-h-0 flex-1`}),f(t),i(e,t)},u=e=>{{let t=w(()=>a(A).formatted||`—`);ve(e,{get value(){return a(t)},language:`text`,class:`h-full`})}},d=e=>{{let t=w(()=>a(M).formatted||`—`);ve(e,{get value(){return a(t)},language:`json`,class:`h-full`})}};E(n,e=>{a(R)[a(D)]?e(r):a(ne)[a(D)]?e(o,1):a(D)===`prompt`&&a(k)&&a(O)?e(s,2):a(D)===`conversation`&&a(A)?e(u,3):a(D)===`context`&&a(M)&&e(d,4)}),f(t),i(e,t)},r=w(()=>`${me(a(D))} — ${t.scenario||`Test`} (run ${t.runIndex})`);ce(e,{get title(){return a(r)},class:`!w-[85vw] !max-w-5xl`,get open(){return a(y)},set open(e){b(y,e,!0)},children:n,$$slots:{default:!0}})}};E(Pe,e=>{a(y)&&e(Fe)});var J=N(Pe,2),Ie=e=>{{let n=e=>{var t=mn(),n=v(t);oe(n,{get value(){return a(C)},ariaLabel:`Test run debug tabs`,onChange:({value:e})=>ge(e),children:(e,t)=>{var n=pn(),r=v(n);se(r,{value:`errors`,class:`px-3`,children:(e,t)=>{l();var n=B(`Errors`);i(e,n)},$$slots:{default:!0}});var a=N(r,2);se(a,{value:`traces`,class:`px-3`,children:(e,t)=>{l();var n=B(`Traces`);i(e,n)},$$slots:{default:!0}});var o=N(a,2);se(o,{value:`logs`,class:`px-3`,children:(e,t)=>{l();var n=B(`Logs`);i(e,n)},$$slots:{default:!0}}),i(e,n)},$$slots:{default:!0}});var r=N(n,2),o=T(r),s=e=>{var t=ln();i(e,t)},u=e=>{var t=un(),n=T(t,!0);f(t),x(()=>c(n,a(ne)[a(C)])),i(e,t)},d=e=>{{let t=w(()=>a(te).formatted||`—`);ve(e,{get value(){return a(t)},language:`text`,class:`h-full`})}},p=e=>{{let t=w(()=>a(F).formatted||`—`);ve(e,{get value(){return a(t)},language:`json`,class:`h-full`})}},m=e=>{{let t=w(()=>a(I).formatted||`—`);ve(e,{get value(){return a(t)},language:`text`,class:`h-full`})}};E(o,e=>{a(R)[a(C)]?e(s):a(ne)[a(C)]?e(u,1):a(C)===`errors`&&a(te)?e(d,2):a(C)===`traces`&&a(F)?e(p,3):a(C)===`logs`&&a(I)&&e(m,4)}),f(r),i(e,t)},r=w(()=>`Debug — ${t.scenario||`Test`} (run ${t.runIndex})`);ce(e,{get title(){return a(r)},class:`!w-[85vw] !max-w-5xl`,get open(){return a(ee)},set open(e){b(ee,e,!0)},children:n,$$slots:{default:!0}})}};E(J,e=>{a(ee)&&e(Ie)}),x(()=>{we.inert=o(),we.disabled=n()||s()||a(U)===`adding`,c(Te,a(U)===`adding`?`Adding…`:a(U)===`added`?`Added`:a(U)===`failed`?`Failed`:`Add test`)}),h(`click`,we,_e),h(`click`,Oe,()=>b(S,!0)),h(`click`,ke,()=>K(`prompt`)),h(`click`,q,()=>K(`conversation`)),h(`click`,Ae,()=>K(`context`)),h(`click`,je,pe),i(e,be),r()}t([`click`]);var _n=`Update the conversation history so it reflects behaviour that is valid under the current prompt. Preserve the test's intent and expected outcome, and make only the smallest necessary changes. Possible roles: "Agent", "User", "System"`;function vn(e,t){return[e.trim()===`LLM`?``:e.trim(),t.trim()].filter(Boolean).join(` `)}function yn(e){let t=vn(e.assertionLabel,e.assertionValue);return`You will be given the context, the conversation and the desired output and assertion about it. First, find why the prompt is not producing the correct result. It's usually one concrete instruction within the relevant section, or a contradiction. Then, change the prompt minimally so this will work, but keeping the prompt clean and comprehensive is more important. Try to provide as general solution as possible. Try to change just one part of the prompt, not multiple parts. Avoid adding exceptions and overrides. Avoid duplicating information that already exists in the prompt.
2
+ import{A as e,B as t,D as n,Dt as r,F as i,G as a,I as o,L as s,N as c,Nt as l,O as u,Ot as d,Pt as f,R as p,S as m,V as h,_ as g,a as _,at as v,b as ee,d as y,dt as b,et as x,f as S,g as C,gt as w,it as T,j as E,k as D,l as O,m as k,mt as A,n as j,o as M,ot as N,p as te,pt as P,q as F,r as I,st as L,tt as R,u as ne,w as re,x as z,z as B}from"../chunks/CPCsWwEy.js";import{t as V}from"../chunks/HclGiUj8.js";import"../chunks/xihTtKlq.js";import{t as H}from"../chunks/3WccBUkK.js";import{r as U,t as ie}from"../chunks/oarl--hZ.js";import{t as W}from"../chunks/6OCsQ6r7.js";import{t as ae}from"../chunks/Cf3l6QEG.js";import{n as oe,t as se}from"../chunks/BJqZY8o2.js";import{t as ce}from"../chunks/BP0Xadq7.js";import{i as le,t as ue}from"../chunks/BT98u4gR.js";import{t as G}from"../chunks/DWoqp3ac.js";import{a as de,c as fe,o as pe,r as K,s as me,t as he}from"../chunks/12bfCwgn.js";import{t as ge}from"../chunks/B9YnyJ2j.js";import{t as _e}from"../chunks/D3fLfD-Y.js";import{t as ve}from"../chunks/CL717zGu.js";var ye=/^[a-z0-9]+(-[a-z0-9]+)*$/,be=(e,t,n,r=``)=>{let i=e.split(`:`);if(e.slice(0,1)===`@`){if(i.length<2||i.length>3)return null;r=i.shift().slice(1)}if(i.length>3||!i.length)return null;if(i.length>1){let e=i.pop(),n=i.pop(),a={provider:i.length>0?i[0]:r,prefix:n,name:e};return t&&!xe(a)?null:a}let a=i[0],o=a.split(`-`);if(o.length>1){let e={provider:r,prefix:o.shift(),name:o.join(`-`)};return t&&!xe(e)?null:e}if(n&&r===``){let e={provider:r,prefix:``,name:a};return t&&!xe(e,n)?null:e}return null},xe=(e,t)=>e?!!((t&&e.prefix===``||e.prefix)&&e.name):!1;function Se(e,t){let n=e.icons,r=e.aliases||Object.create(null),i=Object.create(null);function a(e){if(n[e])return i[e]=[];if(!(e in i)){i[e]=null;let t=r[e]&&r[e].parent,n=t&&a(t);n&&(i[e]=[t].concat(n))}return i[e]}return Object.keys(n).concat(Object.keys(r)).forEach(a),i}var Ce=Object.freeze({left:0,top:0,width:16,height:16}),we=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Te=Object.freeze({...Ce,...we}),Ee=Object.freeze({...Te,body:``,hidden:!1});function De(e,t){let n={};!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0);let r=((e.rotate||0)+(t.rotate||0))%4;return r&&(n.rotate=r),n}function Oe(e,t){let n=De(e,t);for(let r in Ee)r in we?r in e&&!(r in n)&&(n[r]=we[r]):r in t?n[r]=t[r]:r in e&&(n[r]=e[r]);return n}function ke(e,t,n){let r=e.icons,i=e.aliases||Object.create(null),a={};function o(e){a=Oe(r[e]||i[e],a)}return o(t),n.forEach(o),Oe(e,a)}function q(e,t){let n=[];if(typeof e!=`object`||typeof e.icons!=`object`)return n;e.not_found instanceof Array&&e.not_found.forEach(e=>{t(e,null),n.push(e)});let r=Se(e);for(let i in r){let a=r[i];a&&(t(i,ke(e,i,a)),n.push(i))}return n}var Ae={provider:``,aliases:{},not_found:{},...Ce};function je(e,t){for(let n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function Me(e){if(typeof e!=`object`||!e)return null;let t=e;if(typeof t.prefix!=`string`||!e.icons||typeof e.icons!=`object`||!je(e,Ae))return null;let n=t.icons;for(let e in n){let t=n[e];if(!e||typeof t.body!=`string`||!je(t,Ee))return null}let r=t.aliases||Object.create(null);for(let e in r){let t=r[e],i=t.parent;if(!e||typeof i!=`string`||!n[i]&&!r[i]||!je(t,Ee))return null}return t}var Ne=Object.create(null);function Pe(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function Fe(e,t){let n=Ne[e]||(Ne[e]=Object.create(null));return n[t]||(n[t]=Pe(e,t))}function J(e,t){return Me(t)?q(t,(t,n)=>{n?e.icons[t]=n:e.missing.add(t)}):[]}function Ie(e,t,n){try{if(typeof n.body==`string`)return e.icons[t]={...n},!0}catch{}return!1}var Le=!1;function Re(e){return typeof e==`boolean`&&(Le=e),Le}function ze(e){let t=typeof e==`string`?be(e,!0,Le):e;if(t){let e=Fe(t.provider,t.prefix),n=t.name;return e.icons[n]||(e.missing.has(n)?null:void 0)}}function Be(e,t){let n=be(e,!0,Le);if(!n)return!1;let r=Fe(n.provider,n.prefix);return t?Ie(r,n.name,t):(r.missing.add(n.name),!0)}function Ve(e,t){if(typeof e!=`object`)return!1;if(typeof t!=`string`&&(t=e.provider||``),Le&&!t&&!e.prefix){let t=!1;return Me(e)&&(e.prefix=``,q(e,(e,n)=>{Be(e,n)&&(t=!0)})),t}let n=e.prefix;return xe({prefix:n,name:`a`})?!!J(Fe(t,n),e):!1}var He=Object.freeze({width:null,height:null}),Ue=Object.freeze({...He,...we}),Y=/(-?[0-9.]*[0-9]+[0-9.]*)/g,We=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function X(e,t,n){if(t===1)return e;if(n||=100,typeof e==`number`)return Math.ceil(e*t*n)/n;if(typeof e!=`string`)return e;let r=e.split(Y);if(r===null||!r.length)return e;let i=[],a=r.shift(),o=We.test(a);for(;;){if(o){let e=parseFloat(a);isNaN(e)?i.push(a):i.push(Math.ceil(e*t*n)/n)}else i.push(a);if(a=r.shift(),a===void 0)return i.join(``);o=!o}}function Ge(e,t=`defs`){let n=``,r=e.indexOf(`<`+t);for(;r>=0;){let i=e.indexOf(`>`,r),a=e.indexOf(`</`+t);if(i===-1||a===-1)break;let o=e.indexOf(`>`,a);if(o===-1)break;n+=e.slice(i+1,a).trim(),e=e.slice(0,r).trim()+e.slice(o+1)}return{defs:n,content:e}}function Ke(e,t){return e?`<defs>`+e+`</defs>`+t:t}function qe(e,t,n){let r=Ge(e);return Ke(r.defs,t+r.content+n)}var Z=e=>e===`unset`||e===`undefined`||e===`none`;function Je(e,t){let n={...Te,...e},r={...Ue,...t},i={left:n.left,top:n.top,width:n.width,height:n.height},a=n.body;[n,r].forEach(e=>{let t=[],n=e.hFlip,r=e.vFlip,o=e.rotate;n?r?o+=2:(t.push(`translate(`+(i.width+i.left).toString()+` `+(0-i.top).toString()+`)`),t.push(`scale(-1 1)`),i.top=i.left=0):r&&(t.push(`translate(`+(0-i.left).toString()+` `+(i.height+i.top).toString()+`)`),t.push(`scale(1 -1)`),i.top=i.left=0);let s;switch(o<0&&(o-=Math.floor(o/4)*4),o%=4,o){case 1:s=i.height/2+i.top,t.unshift(`rotate(90 `+s.toString()+` `+s.toString()+`)`);break;case 2:t.unshift(`rotate(180 `+(i.width/2+i.left).toString()+` `+(i.height/2+i.top).toString()+`)`);break;case 3:s=i.width/2+i.left,t.unshift(`rotate(-90 `+s.toString()+` `+s.toString()+`)`)}o%2==1&&(i.left!==i.top&&(s=i.left,i.left=i.top,i.top=s),i.width!==i.height&&(s=i.width,i.width=i.height,i.height=s)),t.length&&(a=qe(a,`<g transform="`+t.join(` `)+`">`,`</g>`))});let o=r.width,s=r.height,c=i.width,l=i.height,u,d;o===null?(d=s===null?`1em`:s===`auto`?l:s,u=X(d,c/l)):(u=o===`auto`?c:o,d=s===null?X(u,l/c):s===`auto`?l:s);let f={},p=(e,t)=>{Z(t)||(f[e]=t.toString())};p(`width`,u),p(`height`,d);let m=[i.left,i.top,c,l];return f.viewBox=m.join(` `),{attributes:f,viewBox:m,body:a}}var Ye=/\sid="(\S+)"/g,Xe=new Map;function Ze(e){e=e.replace(/[0-9]+$/,``)||`a`;let t=Xe.get(e)||0;return Xe.set(e,t+1),t?`${e}${t}`:e}function Qe(e){let t=[],n;for(;n=Ye.exec(e);)t.push(n[1]);if(!t.length)return e;let r=`suffix`+(Math.random()*16777216|Date.now()).toString(16);return t.forEach(t=>{let n=Ze(t),i=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);e=e.replace(RegExp(`([#;"])(`+i+`)([")]|\\.[a-z])`,`g`),`$1`+n+r+`$3`)}),e=e.replace(new RegExp(r,`g`),``),e}var $e=Object.create(null);function et(e,t){$e[e]=t}function tt(e){return $e[e]||$e[``]}function nt(e){let t;if(typeof e.resources==`string`)t=[e.resources];else if(t=e.resources,!(t instanceof Array)||!t.length)return null;return{resources:t,path:e.path||`/`,maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}for(var rt=Object.create(null),it=[`https://api.simplesvg.com`,`https://api.unisvg.com`],at=[];it.length>0;)it.length===1||Math.random()>.5?at.push(it.shift()):at.push(it.pop());rt[``]=nt({resources:[`https://api.iconify.design`].concat(at)});function Q(e,t){let n=nt(t);return n!==null&&(rt[e]=n,!0)}function $(e){return rt[e]}var ot=(()=>{let e;try{if(e=fetch,typeof e==`function`)return e}catch{}})();function st(e,t){let n=$(e);if(!n)return 0;let r;if(!n.maxURL)r=0;else{let e=0;n.resources.forEach(t=>{e=Math.max(e,t.length)});let i=t+`.json?icons=`;r=n.maxURL-e-n.path.length-i.length}return r}function ct(e){return e===404}var lt=(e,t,n)=>{let r=[],i=st(e,t),a=`icons`,o={type:a,provider:e,prefix:t,icons:[]},s=0;return n.forEach((n,c)=>{s+=n.length+1,s>=i&&c>0&&(r.push(o),o={type:a,provider:e,prefix:t,icons:[]},s=n.length),o.icons.push(n)}),r.push(o),r};function ut(e){if(typeof e==`string`){let t=$(e);if(t)return t.path}return`/`}var dt={prepare:lt,send:(e,t,n)=>{if(!ot){n(`abort`,424);return}let r=ut(t.provider);switch(t.type){case`icons`:{let e=t.prefix,n=t.icons.join(`,`),i=new URLSearchParams({icons:n});r+=e+`.json?`+i.toString();break}case`custom`:{let e=t.uri;r+=e.slice(0,1)===`/`?e.slice(1):e;break}default:n(`abort`,400);return}let i=503;ot(e+r).then(e=>{let t=e.status;if(t!==200){setTimeout(()=>{n(ct(t)?`abort`:`next`,t)});return}return i=501,e.json()}).then(e=>{if(typeof e!=`object`||!e){setTimeout(()=>{e===404?n(`abort`,e):n(`next`,i)});return}setTimeout(()=>{n(`success`,e)})}).catch(()=>{n(`next`,i)})}};function ft(e,t){e.forEach(e=>{let n=e.loaderCallbacks;n&&(e.loaderCallbacks=n.filter(e=>e.id!==t))})}function pt(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;let t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1,r=e.provider,i=e.prefix;t.forEach(t=>{let a=t.icons,o=a.pending.length;a.pending=a.pending.filter(t=>{if(t.prefix!==i)return!0;let o=t.name;if(e.icons[o])a.loaded.push({provider:r,prefix:i,name:o});else if(e.missing.has(o))a.missing.push({provider:r,prefix:i,name:o});else return n=!0,!0;return!1}),a.pending.length!==o&&(n||ft([e],t.id),t.callback(a.loaded.slice(0),a.missing.slice(0),a.pending.slice(0),t.abort))})}))}var mt=0;function ht(e,t,n){let r=mt++,i=ft.bind(null,n,r);if(!t.pending.length)return i;let a={id:r,icons:t,callback:e,abort:i};return n.forEach(e=>{(e.loaderCallbacks||=[]).push(a)}),i}function gt(e){let t={loaded:[],missing:[],pending:[]},n=Object.create(null);e.sort((e,t)=>e.provider===t.provider?e.prefix===t.prefix?e.name.localeCompare(t.name):e.prefix.localeCompare(t.prefix):e.provider.localeCompare(t.provider));let r={provider:``,prefix:``,name:``};return e.forEach(e=>{if(r.name===e.name&&r.prefix===e.prefix&&r.provider===e.provider)return;r=e;let i=e.provider,a=e.prefix,o=e.name,s=n[i]||(n[i]=Object.create(null)),c=s[a]||(s[a]=Fe(i,a)),l;l=o in c.icons?t.loaded:a===``||c.missing.has(o)?t.missing:t.pending;let u={provider:i,prefix:a,name:o};l.push(u)}),t}function _t(e,t=!0,n=!1){let r=[];return e.forEach(e=>{let i=typeof e==`string`?be(e,t,n):e;i&&r.push(i)}),r}var vt={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function yt(e,t,n,r){let i=e.resources.length,a=e.random?Math.floor(Math.random()*i):e.index,o;if(e.random){let t=e.resources.slice(0);for(o=[];t.length>1;){let e=Math.floor(Math.random()*t.length);o.push(t[e]),t=t.slice(0,e).concat(t.slice(e+1))}o=o.concat(t)}else o=e.resources.slice(a).concat(e.resources.slice(0,a));let s=Date.now(),c=`pending`,l=0,u,d=null,f=[],p=[];typeof r==`function`&&p.push(r);function m(){d&&=(clearTimeout(d),null)}function h(){c===`pending`&&(c=`aborted`),m(),f.forEach(e=>{e.status===`pending`&&(e.status=`aborted`)}),f=[]}function g(e,t){t&&(p=[]),typeof e==`function`&&p.push(e)}function _(){return{startTime:s,payload:t,status:c,queriesSent:l,queriesPending:f.length,subscribe:g,abort:h}}function v(){c=`failed`,p.forEach(e=>{e(void 0,u)})}function ee(){f.forEach(e=>{e.status===`pending`&&(e.status=`aborted`)}),f=[]}function y(t,n,r){let i=n!==`success`;switch(f=f.filter(e=>e!==t),c){case`pending`:break;case`failed`:if(i||!e.dataAfterTimeout)return;break;default:return}if(n===`abort`){u=r,v();return}if(i){u=r,f.length||(o.length?b():v());return}if(m(),ee(),!e.random){let n=e.resources.indexOf(t.resource);n!==-1&&n!==e.index&&(e.index=n)}c=`completed`,p.forEach(e=>{e(r)})}function b(){if(c!==`pending`)return;m();let r=o.shift();if(r===void 0){if(f.length){d=setTimeout(()=>{m(),c===`pending`&&(ee(),v())},e.timeout);return}v();return}let i={status:`pending`,resource:r,callback:(e,t)=>{y(i,e,t)}};f.push(i),l++,d=setTimeout(b,e.rotate),n(r,t,i.callback)}return setTimeout(b),_}function bt(e){let t={...vt,...e},n=[];function r(){n=n.filter(e=>e().status===`pending`)}function i(e,i,a){let o=yt(t,e,i,(e,t)=>{r(),a&&a(e,t)});return n.push(o),o}function a(e){return n.find(t=>e(t))||null}return{query:i,find:a,setIndex:e=>{t.index=e},getIndex:()=>t.index,cleanup:r}}function xt(){}var St=Object.create(null);function Ct(e){if(!St[e]){let t=$(e);if(!t)return;St[e]={config:t,redundancy:bt(t)}}return St[e]}function wt(e,t,n){let r,i;if(typeof e==`string`){let t=tt(e);if(!t)return n(void 0,424),xt;i=t.send;let a=Ct(e);a&&(r=a.redundancy)}else{let t=nt(e);if(t){r=bt(t);let n=tt(e.resources?e.resources[0]:``);n&&(i=n.send)}}return!r||!i?(n(void 0,424),xt):r.query(t,i,n)().abort}function Tt(){}function Et(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,pt(e)}))}function Dt(e){let t=[],n=[];return e.forEach(e=>{(e.match(ye)?t:n).push(e)}),{valid:t,invalid:n}}function Ot(e,t,n){function r(){let n=e.pendingIcons;t.forEach(t=>{n&&n.delete(t),e.icons[t]||e.missing.add(t)})}if(n&&typeof n==`object`)try{if(!J(e,n).length){r();return}}catch(e){console.error(e)}r(),Et(e)}function kt(e,t){e instanceof Promise?e.then(e=>{t(e)}).catch(()=>{t(null)}):t(e)}function At(e,t){e.iconsToLoad=e.iconsToLoad?e.iconsToLoad.concat(t).sort():t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;let{provider:t,prefix:n}=e,r=e.iconsToLoad;if(delete e.iconsToLoad,!r||!r.length)return;let i=e.loadIcon;if(e.loadIcons&&(r.length>1||!i)){kt(e.loadIcons(r,n,t),t=>{Ot(e,r,t)});return}if(i){r.forEach(r=>{kt(i(r,n,t),t=>{Ot(e,[r],t?{prefix:n,icons:{[r]:t}}:null)})});return}let{valid:a,invalid:o}=Dt(r);if(o.length&&Ot(e,o,null),!a.length)return;let s=n.match(ye)?tt(t):null;if(!s){Ot(e,a,null);return}s.prepare(t,n,a).forEach(n=>{wt(t,n,t=>{Ot(e,n.icons,t)})})}))}var jt=(e,t)=>{let n=gt(_t(e,!0,Re()));if(!n.pending.length){let e=!0;return t&&setTimeout(()=>{e&&t(n.loaded,n.missing,n.pending,Tt)}),()=>{e=!1}}let r=Object.create(null),i=[],a,o;return n.pending.forEach(e=>{let{provider:t,prefix:n}=e;if(n===o&&t===a)return;a=t,o=n,i.push(Fe(t,n));let s=r[t]||(r[t]=Object.create(null));s[n]||(s[n]=[])}),n.pending.forEach(e=>{let{provider:t,prefix:n,name:i}=e,a=Fe(t,n),o=a.pendingIcons||=new Set;o.has(i)||(o.add(i),r[t][n].push(i))}),i.forEach(e=>{let t=r[e.provider][e.prefix];t.length&&At(e,t)}),t?ht(t,n,i):Tt};function Mt(e,t){let n={...e};for(let e in t){let r=t[e],i=typeof r;e in He?(r===null||r&&(i===`string`||i===`number`))&&(n[e]=r):i===typeof n[e]&&(n[e]=e===`rotate`?r%4:r)}return n}var Nt=/[\s,]+/;function Pt(e,t){t.split(Nt).forEach(t=>{switch(t.trim()){case`horizontal`:e.hFlip=!0;break;case`vertical`:e.vFlip=!0}})}function Ft(e,t=0){let n=e.replace(/^-?[0-9.]*/,``);function r(e){for(;e<0;)e+=4;return e%4}if(n===``){let t=parseInt(e);return isNaN(t)?0:r(t)}if(n!==e){let t=0;switch(n){case`%`:t=25;break;case`deg`:t=90}if(t){let i=parseFloat(e.slice(0,e.length-n.length));return isNaN(i)?0:(i/=t,i%1==0?r(i):0)}}return t}function It(e,t){let n=e.indexOf(`xlink:`)===-1?``:` xmlns:xlink="http://www.w3.org/1999/xlink"`;for(let e in t)n+=` `+e+`="`+t[e]+`"`;return`<svg xmlns="http://www.w3.org/2000/svg"`+n+`>`+e+`</svg>`}function Lt(e){return e.replace(/"/g,`'`).replace(/%/g,`%25`).replace(/#/g,`%23`).replace(/</g,`%3C`).replace(/>/g,`%3E`).replace(/\s+/g,` `)}function Rt(e){return`data:image/svg+xml,`+Lt(e)}function zt(e){return`url("`+Rt(e)+`")`}var Bt={...Ue,inline:!1},Vt={xmlns:`http://www.w3.org/2000/svg`,"xmlns:xlink":`http://www.w3.org/1999/xlink`,"aria-hidden":!0,role:`img`},Ht={display:`inline-block`},Ut={"background-color":`currentColor`},Wt={"background-color":`transparent`},Gt={image:`var(--svg)`,repeat:`no-repeat`,size:`100% 100%`},Kt={"-webkit-mask":Ut,mask:Ut,background:Wt};for(let e in Kt){let t=Kt[e];for(let n in Gt)t[e+`-`+n]=Gt[n]}function qt(e){return e+(e.match(/^[-0-9.]+$/)?`px`:``)}function Jt(e,t){let n=Mt(Bt,t),r=t.mode||`svg`,i=r===`svg`?{...Vt}:{};e.body.indexOf(`xlink:`)===-1&&delete i[`xmlns:xlink`];let a=typeof t.style==`string`?t.style:``;for(let e in t){let r=t[e];if(r!==void 0)switch(e){case`icon`:case`style`:case`onLoad`:case`mode`:case`ssr`:break;case`inline`:case`hFlip`:case`vFlip`:n[e]=r===!0||r===`true`||r===1;break;case`flip`:typeof r==`string`&&Pt(n,r);break;case`color`:a=a+(a.length>0&&a.trim().slice(-1)!==`;`?`;`:``)+`color: `+r+`; `;break;case`rotate`:typeof r==`string`?n[e]=Ft(r):typeof r==`number`&&(n[e]=r);break;case`ariaHidden`:case`aria-hidden`:r!==!0&&r!==`true`&&delete i[`aria-hidden`];break;default:if(e.slice(0,3)===`on:`)break;Bt[e]===void 0&&(i[e]=r)}}let o=Je(e,n),s=o.attributes;if(n.inline&&(a=`vertical-align: -0.125em; `+a),r===`svg`)return Object.assign(i,s),a!==``&&(i.style=a),{svg:!0,attributes:i,body:Qe(o.body)};let{body:c,width:l,height:u}=e,d=r===`mask`||r!==`bg`&&c.indexOf(`currentColor`)!==-1,f={"--svg":zt(It(c,{...s,width:l+``,height:u+``}))},p=e=>{let t=s[e];t&&(f[e]=qt(t))};p(`width`),p(`height`),Object.assign(f,Ht,d?Ut:Wt);let m=``;for(let e in f)m+=e+`: `+f[e]+`;`;return i.style=m+a,{svg:!1,attributes:i}}if(Re(!0),et(``,dt),typeof document<`u`&&typeof window<`u`){let e=window;if(e.IconifyPreload!==void 0){let t=e.IconifyPreload,n=`Invalid IconifyPreload syntax.`;typeof t==`object`&&t&&(t instanceof Array?t:[t]).forEach(e=>{try{(typeof e!=`object`||!e||e instanceof Array||typeof e.icons!=`object`||typeof e.prefix!=`string`||!Ve(e))&&console.error(n)}catch{console.error(n)}})}if(e.IconifyProviders!==void 0){let t=e.IconifyProviders;if(typeof t==`object`&&t)for(let e in t){let n=`IconifyProviders[`+e+`] is invalid.`;try{let r=t[e];if(typeof r!=`object`||!r||r.resources===void 0)continue;Q(e,r)||console.error(n)}catch{console.error(n)}}}}function Yt(){try{return typeof window!=`object`}catch{return!0}}function Xt(e,t,n,r){function i(){t.loading&&=(t.loading.abort(),null)}if(typeof e==`object`&&e&&typeof e.body==`string`)return t.name=``,i(),{data:{...Te,...e}};let a;if(typeof e!=`string`||(a=be(e,!1,!0))===null)return i(),null;let o=ze(a);if(!o)return!Yt()&&(!t.loading||t.loading.name!==e)&&(i(),t.name=``,t.loading={name:e,abort:jt([a],n)}),null;i(),t.name!==e&&(t.name=e,r&&!t.destroyed&&setTimeout(()=>{r(e)}));let s=[`iconify`];return a.prefix!==``&&s.push(`iconify--`+a.prefix),a.provider!==``&&s.push(`iconify--`+a.provider),{data:o,classes:s}}function Zt(e,t){return e?Jt({...Te,...e},t):null}var Qt=new Set([`$$slots`,`$$events`,`$$legacy`]),$t=p(`<svg></svg>`),en=s(`<span></span>`);function tn(e,t){d(t,!0);let s={name:``,loading:null,destroyed:!1},c=M(t,Qt),l=P(0),u=w(()=>(a(l),Xt(t.icon,s,m,t.onload))),p=w(()=>{let e=a(u)?Zt(a(u).data,c):null;return e&&a(u).classes&&c.class===void 0&&(e.attributes.class=(typeof c.class==`string`?c.class+` `:``)+a(u).classes.join(` `)),e});function m(){A(l)}j(()=>{s.destroyed=!0,s.loading&&=(s.loading.abort(),null)});var h=o(),g=v(h),_=e=>{var t=o(),r=v(t),s=e=>{var t=$t();S(t,()=>({...a(p).attributes})),n(t,()=>a(p).body,!0),f(t),i(e,t)},c=e=>{var t=en();S(t,()=>({...a(p).attributes})),i(e,t)};E(r,e=>{a(p).svg?e(s):e(c,-1)}),i(e,t)};E(g,e=>{a(p)&&e(_)}),i(e,h),r()}var nn=s(`<div class="w-full"></div>`);function rn(e,t){d(t,!0);let n=P(null),o=null,s=[],c=null,l=!1,u,f=_(t,`language`,3,`plaintext`),p=_(t,`height`,3,120),m=_(t,`readOnly`,3,!1),h=null,g=P(!1),v=P(!1);function y(e){a(v)||e.stopPropagation()}I(async()=>{if(!u)return;u.addEventListener(`wheel`,y,{capture:!0,passive:!0}),me();let e=await V(()=>import(`../chunks/CUZn05nQ.js`).then(e=>e.t),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url);if(l)return;c=e,pe(e);let r=f()===`json`?`json`:f()===`markdown`?`markdown`:`plaintext`;b(n,e.editor.create(u,{...de(`test-history`),value:t.value??``,language:r,readOnly:m(),domReadOnly:m()}),!0);let i=a(n);if(!i)return;o=i.getModel(),h=K(e,i),h.update(t.highlights??[]),b(g,!0),s.push(i.onDidFocusEditorText(()=>{b(v,!0)})),s.push(i.onDidChangeModelContent(()=>{try{let e=i.getValue();if(e===t.value)return;t.onChange?.(e)}catch(e){console.error(`MiniEditor change error`,e)}})),s.push(i.onDidBlurEditorText(()=>{b(v,!1);try{t.onBlur?.(i.getValue())}catch{}}));let d=i.onDidFocusEditorWidget?.(()=>{b(v,!0)});d&&s.push(d);let p=i.onDidBlurEditorWidget?.(()=>{b(v,!1);try{t.onBlur?.(i.getValue())}catch{}});p&&s.push(p)}),j(()=>{l=!0,b(g,!1);try{u.removeEventListener(`wheel`,y,{capture:!0})}catch{}for(let e of s)try{e.dispose()}catch{}s=[],h?.dispose(),h=null;let e=o;o=null;try{if(a(n)){try{a(n).setModel(null)}catch{}a(n).dispose()}}finally{b(n,null)}try{e?.dispose()}catch{}c=null}),R(()=>{if(!a(n))return;let e=f()===`json`?`json`:f()===`markdown`?`markdown`:`plaintext`,t=a(n).getModel();if(!t||t.getLanguageId()===e)return;let r=!1;return(c?Promise.resolve(c):V(()=>import(`../chunks/CUZn05nQ.js`).then(e=>e.t),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url)).then(n=>{if(!r)try{n.editor.setModelLanguage(t,e)}catch{}}),()=>{r=!0}}),R(()=>{let e=t.value??``,r=t.highlights??[];!a(n)||!a(g)||(e!==a(n).getValue()&&a(n).setValue(e),h?.update(r))}),R(()=>{a(n)?.updateOptions({readOnly:m(),domReadOnly:m()})});var S=nn();O(S,e=>u=e,()=>u),x(()=>ee(S,`height:${p()}px`)),i(e,S),r()}var an=s(`<button type="button" class="inline-flex items-center text-nowrap rounded border-0 bg-transparent px-1 py-0.5 text-rc-gray-400 transition-colors hover:bg-rc-gray-900 hover:text-rc-gray-200 focus:outline-none focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-rc-gray-400">Fix</button>`),on=s(`<button type="button" class="inline-flex items-center text-nowrap rounded border-0 bg-transparent px-1 py-0.5 text-rc-gray-400 transition-colors hover:bg-rc-gray-900 hover:text-rc-gray-200 focus:outline-none focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-rc-gray-400">Analyze</button>`),sn=s(`<div><div class="mb-1 text-xs text-rc-gray-300"> </div> <div class="whitespace-pre-wrap break-words text-rc-gray-100"> </div></div>`),cn=s(`<div class="flex flex-col gap-3"></div>`),ln=s(`<div class="p-2 text-rc-gray-300">Loading…</div>`),un=s(`<div class="p-2 text-red-400"> </div>`),dn=s(`<div class="flex h-full flex-col gap-2"><div class="grid grid-cols-2 gap-2"><div class="flex items-center justify-start"><!></div> <div class="flex items-center justify-end"><!></div></div> <!></div>`),fn=s(`<div class="h-[55vh]"><!></div>`),pn=s(`<!> <!> <!>`,1),mn=s(`<!> <div class="mt-2 h-[55vh]"><!></div>`,1),hn=s(`<div class="mt-1 flex flex-wrap items-center gap-x-2 gap-y-1"><!> <button type="button" class="inline-flex items-center text-nowrap rounded border-0 bg-transparent px-1 py-0.5 text-rc-gray-400 transition-colors hover:bg-rc-gray-900 hover:text-rc-gray-200 focus:outline-none focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-rc-gray-400"> </button> <!> <button type="button" class="inline-flex items-center text-nowrap rounded border-0 bg-transparent px-1 py-0.5 text-rc-gray-400 transition-colors hover:bg-rc-gray-900 hover:text-rc-gray-200 focus:outline-none focus-visible:outline-none">See variants</button> <button type="button" class="inline-flex items-center text-nowrap rounded border-0 bg-transparent px-1 py-0.5 text-rc-gray-400 transition-colors hover:bg-rc-gray-900 hover:text-rc-gray-200 focus:outline-none focus-visible:outline-none">Prompt</button> <button type="button" class="inline-flex items-center text-nowrap rounded border-0 bg-transparent px-1 py-0.5 text-rc-gray-400 transition-colors hover:bg-rc-gray-900 hover:text-rc-gray-200 focus:outline-none focus-visible:outline-none">Conversation</button> <button type="button" class="inline-flex items-center text-nowrap rounded border-0 bg-transparent px-1 py-0.5 text-rc-gray-400 transition-colors hover:bg-rc-gray-900 hover:text-rc-gray-200 focus:outline-none focus-visible:outline-none">Context</button> <button type="button" class="inline-flex items-center text-nowrap rounded border-0 bg-transparent px-1 py-0.5 text-rc-gray-400 transition-colors hover:bg-rc-gray-900 hover:text-rc-gray-200 focus:outline-none focus-visible:outline-none">Debug</button></div> <!> <!> <!>`,1);function gn(e,t){d(t,!0);let n=_(t,`actionsDisabled`,3,!1),o=_(t,`actionsInert`,3,!1),s=_(t,`addTestDisabled`,3,!1),p=_(t,`showAnalyze`,3,!0),m=_(t,`analyzeDisabled`,3,!1),g=_(t,`fixDisabled`,3,!1),ee=P(!1),y=P(!1),S=P(!1),C=P(`errors`),D=P(`prompt`),O=P(null),k=P(null),A=P(null),M=P(null),te=P(null),F=P(null),I=P(null),R=P(L({prompt:!1,conversation:!1,context:!1,errors:!1,traces:!1,logs:!1})),ne=P(L({prompt:null,conversation:null,context:null,errors:null,traces:null,logs:null})),re=0,V=P(null),H=null,U=P(`idle`),ie=null;function ae(e){try{return{raw:e,formatted:JSON.stringify(JSON.parse(e),null,2)}}catch{return{raw:e,formatted:e}}}async function le(e){return ae(await G.tests.resultEntry.query({agent:e.agent,testId:e.id,resultKey:e.key,timestamp:e.timestamp,index:e.run}))}function ue(e){return e===`prompt`?a(k)!==null&&a(O)!==null:e===`conversation`?a(A)!==null:e===`context`?a(M)!==null:e===`errors`?a(te)!==null:e===`traces`?a(F)!==null:a(I)!==null}async function de(e){if(ue(e)||a(R)[e])return;let n=re;b(R,{...a(R),[e]:!0},!0),b(ne,{...a(ne),[e]:null},!0);try{if(e===`prompt`){let[e,r]=await Promise.all([le(t.links.renderedPrompt),le(t.links.receivedPrompt)]);if(n!==re)return;b(O,e,!0),b(k,r,!0)}else{let r=await le(e===`conversation`?t.links.conversation:e===`context`?t.links.context:e===`errors`?t.links.errors:e===`traces`?t.links.traces:t.links.logs);if(n!==re)return;b(e===`conversation`?A:e===`context`?M:e===`errors`?te:e===`traces`?F:I,r,!0)}}catch(t){if(n!==re)return;console.error(t),b(ne,{...a(ne),[e]:`Failed to load content`},!0)}finally{n===re&&b(R,{...a(R),[e]:!1},!0)}}function fe(){b(O,null),b(k,null),b(A,null),b(M,null),b(te,null),b(F,null),b(I,null),b(R,{prompt:!1,conversation:!1,context:!1,errors:!1,traces:!1,logs:!1},!0),b(ne,{prompt:null,conversation:null,context:null,errors:null,traces:null,logs:null},!0)}function pe(){re+=1,b(C,`errors`),fe(),b(ee,!0),de(`errors`)}function K(e){re+=1,b(D,e,!0),fe(),b(y,!0),de(e)}function me(e){return e===`prompt`?`Prompt`:e===`conversation`?`Conversation`:`Context`}function ge(e){b(C,e,!0),de(e)}async function _e(){if(a(U)!==`adding`){b(U,`adding`);try{await t.onAddTest(),b(U,`added`)}catch(e){console.error(`Failed to add test`,e),b(U,`failed`)}ie&&clearTimeout(ie),ie=window.setTimeout(()=>{b(U,`idle`),ie=null},2500)}}async function ye(e){if(!(!a(k)||!a(O)))try{let t=e===`raw`?a(k).raw:a(O).raw;await navigator.clipboard.writeText(t),b(V,e,!0),H&&clearTimeout(H),H=window.setTimeout(()=>{b(V,null),H=null},2e3)}catch(e){console.error(`Failed to copy prompt`,e)}}j(()=>{re+=1,H&&clearTimeout(H),ie&&clearTimeout(ie)});var be=hn(),xe=v(be),Se=T(xe),Ce=e=>{var r=an();x(()=>{r.inert=o(),r.disabled=n()||g()}),h(`click`,r,function(...e){t.onFix?.apply(this,e)}),i(e,r)};E(Se,e=>{t.onFix&&e(Ce)});var we=N(Se,2),Te=T(we,!0);f(we);var Ee=N(we,2),De=e=>{var n=on();x(()=>n.disabled=m()),h(`click`,n,function(...e){t.onAnalyze?.apply(this,e)}),i(e,n)};E(Ee,e=>{p()&&e(De)});var Oe=N(Ee,2),ke=N(Oe,2),q=N(ke,2),Ae=N(q,2),je=N(Ae,2);f(xe);var Me=N(xe,2),Ne=e=>{{let n=e=>{var n=cn();u(n,21,()=>t.variants,e=>e.index,(e,n)=>{var r=sn(),o=T(r),s=T(o);f(o);var l=N(o,2),u=T(l,!0);f(l),f(r),x(()=>{z(r,1,`rounded-lg border p-3 ${a(n).index===t.runIndex?`border-rc-green-450`:`border-rc-gray-650`} ${a(n).success?`bg-rc-green-700/80`:`bg-rc-gray-900/60`}`),c(s,`Run ${a(n).index??``}${a(n).index===t.runIndex?` • selected`:``}`),c(u,a(n).text||a(n).errors||`—`)}),i(e,r)}),f(n),i(e,n)},r=w(()=>`Variants — ${t.scenario||`Test`}`);ce(e,{get title(){return a(r)},class:`!w-[80vw] !max-w-4xl`,get open(){return a(S)},set open(e){b(S,e,!0)},children:n,$$slots:{default:!0}})}};E(Me,e=>{a(S)&&e(Ne)});var Pe=N(Me,2),Fe=e=>{{let n=e=>{var t=fn(),n=T(t),r=e=>{var t=ln();i(e,t)},o=e=>{var t=un(),n=T(t,!0);f(t),x(()=>c(n,a(ne)[a(D)])),i(e,t)},s=e=>{var t=dn(),n=T(t),r=T(n),o=T(r);{let e=w(()=>!a(k).raw.trim());W(o,{variant:`secondary`,size:`small`,get disabled(){return a(e)},onclick:()=>ye(`raw`),children:(e,t)=>{l();var n=B();x(()=>c(n,a(V)===`raw`?`Copied raw prompt`:`Copy raw prompt`)),i(e,n)},$$slots:{default:!0}})}f(r);var s=N(r,2),u=T(s);{let e=w(()=>!a(O).raw.trim());W(u,{variant:`secondary`,size:`small`,get disabled(){return a(e)},onclick:()=>ye(`rendered`),children:(e,t)=>{l();var n=B();x(()=>c(n,a(V)===`rendered`?`Copied rendered prompt`:`Copy rendered prompt`)),i(e,n)},$$slots:{default:!0}})}f(s),f(n);var d=N(n,2);he(d,{variant:`generic`,get original(){return a(k).formatted},get modified(){return a(O).formatted},language:`markdown`,class:`min-h-0 flex-1`}),f(t),i(e,t)},u=e=>{{let t=w(()=>a(A).formatted||`—`);ve(e,{get value(){return a(t)},language:`text`,class:`h-full`})}},d=e=>{{let t=w(()=>a(M).formatted||`—`);ve(e,{get value(){return a(t)},language:`json`,class:`h-full`})}};E(n,e=>{a(R)[a(D)]?e(r):a(ne)[a(D)]?e(o,1):a(D)===`prompt`&&a(k)&&a(O)?e(s,2):a(D)===`conversation`&&a(A)?e(u,3):a(D)===`context`&&a(M)&&e(d,4)}),f(t),i(e,t)},r=w(()=>`${me(a(D))} — ${t.scenario||`Test`} (run ${t.runIndex})`);ce(e,{get title(){return a(r)},class:`!w-[85vw] !max-w-5xl`,get open(){return a(y)},set open(e){b(y,e,!0)},children:n,$$slots:{default:!0}})}};E(Pe,e=>{a(y)&&e(Fe)});var J=N(Pe,2),Ie=e=>{{let n=e=>{var t=mn(),n=v(t);oe(n,{get value(){return a(C)},ariaLabel:`Test run debug tabs`,onChange:({value:e})=>ge(e),children:(e,t)=>{var n=pn(),r=v(n);se(r,{value:`errors`,class:`px-3`,children:(e,t)=>{l();var n=B(`Errors`);i(e,n)},$$slots:{default:!0}});var a=N(r,2);se(a,{value:`traces`,class:`px-3`,children:(e,t)=>{l();var n=B(`Traces`);i(e,n)},$$slots:{default:!0}});var o=N(a,2);se(o,{value:`logs`,class:`px-3`,children:(e,t)=>{l();var n=B(`Logs`);i(e,n)},$$slots:{default:!0}}),i(e,n)},$$slots:{default:!0}});var r=N(n,2),o=T(r),s=e=>{var t=ln();i(e,t)},u=e=>{var t=un(),n=T(t,!0);f(t),x(()=>c(n,a(ne)[a(C)])),i(e,t)},d=e=>{{let t=w(()=>a(te).formatted||`—`);ve(e,{get value(){return a(t)},language:`text`,class:`h-full`})}},p=e=>{{let t=w(()=>a(F).formatted||`—`);ve(e,{get value(){return a(t)},language:`json`,class:`h-full`})}},m=e=>{{let t=w(()=>a(I).formatted||`—`);ve(e,{get value(){return a(t)},language:`text`,class:`h-full`})}};E(o,e=>{a(R)[a(C)]?e(s):a(ne)[a(C)]?e(u,1):a(C)===`errors`&&a(te)?e(d,2):a(C)===`traces`&&a(F)?e(p,3):a(C)===`logs`&&a(I)&&e(m,4)}),f(r),i(e,t)},r=w(()=>`Debug — ${t.scenario||`Test`} (run ${t.runIndex})`);ce(e,{get title(){return a(r)},class:`!w-[85vw] !max-w-5xl`,get open(){return a(ee)},set open(e){b(ee,e,!0)},children:n,$$slots:{default:!0}})}};E(J,e=>{a(ee)&&e(Ie)}),x(()=>{we.inert=o(),we.disabled=n()||s()||a(U)===`adding`,c(Te,a(U)===`adding`?`Adding…`:a(U)===`added`?`Added`:a(U)===`failed`?`Failed`:`Add test`)}),h(`click`,we,_e),h(`click`,Oe,()=>b(S,!0)),h(`click`,ke,()=>K(`prompt`)),h(`click`,q,()=>K(`conversation`)),h(`click`,Ae,()=>K(`context`)),h(`click`,je,pe),i(e,be),r()}t([`click`]);var _n=`Update the conversation history so it reflects behaviour that is valid under the current prompt. Preserve the test's intent and expected outcome, and make only the smallest necessary changes. Possible roles: "Agent", "User", "System"`;function vn(e,t){return[e.trim()===`LLM`?``:e.trim(),t.trim()].filter(Boolean).join(` `)}function yn(e){let t=vn(e.assertionLabel,e.assertionValue);return`You will be given the context, the conversation and the desired output and assertion about it. First, find why the prompt is not producing the correct result. It's usually one concrete instruction within the relevant section, or a contradiction. Then, change the prompt minimally so this will work, but keeping the prompt clean and comprehensive is more important. Try to provide as general solution as possible. Try to change just one part of the prompt, not multiple parts. Avoid adding exceptions and overrides. Avoid duplicating information that already exists in the prompt.
3
3
 
4
4
  Context:
5
5
  ${e.context.trim()}
@@ -1 +1 @@
1
- {"version":"1789496520453"}
1
+ {"version":"1789661261523"}
Binary file
Binary file
package/build/index.html CHANGED
@@ -4,35 +4,35 @@
4
4
  <meta charset="utf-8" />
5
5
  <link rel="icon" href="/favicon.png" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1" />
7
- <link href="/_app/immutable/entry/start.t9PGFpmm.js" rel="modulepreload">
8
- <link href="/_app/immutable/chunks/jbAfpNOj.js" rel="modulepreload">
7
+ <link href="/_app/immutable/entry/start.Ls0_A8q0.js" rel="modulepreload">
8
+ <link href="/_app/immutable/chunks/B5p_twg4.js" rel="modulepreload">
9
9
  <link href="/_app/immutable/chunks/CPCsWwEy.js" rel="modulepreload">
10
10
  <link href="/_app/immutable/chunks/hePW80VL.js" rel="modulepreload">
11
11
  <link href="/_app/immutable/chunks/Dt-HX3Vu.js" rel="modulepreload">
12
12
  <link href="/_app/immutable/chunks/AvXp07rr.js" rel="modulepreload">
13
- <link href="/_app/immutable/entry/app.Nx0-kikH.js" rel="modulepreload">
13
+ <link href="/_app/immutable/entry/app.BTQrdm9G.js" rel="modulepreload">
14
14
  <link href="/_app/immutable/chunks/HclGiUj8.js" rel="modulepreload">
15
15
  <link href="/_app/immutable/chunks/xihTtKlq.js" rel="modulepreload">
16
- <link href="/_app/immutable/nodes/0.B5_ukjYU.js" rel="modulepreload">
16
+ <link href="/_app/immutable/nodes/0.8n1R6Sfx.js" rel="modulepreload">
17
17
  <link href="/_app/immutable/chunks/DDZ8GqHh.js" rel="modulepreload">
18
- <link href="/_app/immutable/chunks/BOZLjogl.js" rel="modulepreload">
19
- <link href="/_app/immutable/chunks/vxN0p6wG.js" rel="modulepreload">
18
+ <link href="/_app/immutable/chunks/3WccBUkK.js" rel="modulepreload">
19
+ <link href="/_app/immutable/chunks/BMZ3nmcQ.js" rel="modulepreload">
20
20
 
21
- <link href="/_app/immutable/assets/0.970vvoDj.css" rel="stylesheet">
21
+ <link href="/_app/immutable/assets/0.CdQBFG7k.css" rel="stylesheet">
22
22
  </head>
23
23
  <body data-sveltekit-preload-data="hover">
24
24
  <div style="display: contents">
25
25
  <script>
26
26
  {
27
- __sveltekit_1t8j96k = {
27
+ __sveltekit_5x85v6 = {
28
28
  base: ""
29
29
  };
30
30
 
31
31
  const element = document.currentScript.parentElement;
32
32
 
33
33
  Promise.all([
34
- import("/_app/immutable/entry/start.t9PGFpmm.js"),
35
- import("/_app/immutable/entry/app.Nx0-kikH.js")
34
+ import("/_app/immutable/entry/start.Ls0_A8q0.js"),
35
+ import("/_app/immutable/entry/app.BTQrdm9G.js")
36
36
  ]).then(([kit, app]) => {
37
37
  kit.start(app, element);
38
38
  });
Binary file
Binary file
package/dist/index.js CHANGED
@@ -146,6 +146,12 @@ function messageSummary(message) {
146
146
  function lastTurn(conversation) {
147
147
  return conversation.entries.at(-1)?.turn ?? 0;
148
148
  }
149
+ function turnStartContext(entries, turn) {
150
+ for (const entry of entries) {
151
+ if (entry.turn === turn && entry.kind === "context") return entry.payload;
152
+ }
153
+ return null;
154
+ }
149
155
  function conversationMessages(conversation) {
150
156
  return conversation.entries.filter((entry) => entry.kind === "message").map((entry) => entry.payload);
151
157
  }
@@ -222,6 +228,8 @@ async function truncateConversation(ctx, conversationId, fromTurn) {
222
228
  const conversation = await loadConversation(ctx, conversationId);
223
229
  const dropped = conversation.entries.filter((entry) => entry.turn >= fromTurn);
224
230
  conversation.entries = conversation.entries.filter((entry) => entry.turn < fromTurn);
231
+ const startContext = turnStartContext(dropped, fromTurn);
232
+ if (startContext) conversation.context = startContext;
225
233
  await saveConversation(ctx, conversation);
226
234
  const inbound = dropped.find(
227
235
  (entry) => entry.kind === "message" && (entry.payload.sender === "user" || entry.payload.sender === "system")
@@ -521,6 +529,7 @@ async function runTurn(bosun, input) {
521
529
  isTest: false
522
530
  }
523
531
  });
532
+ push("context", normalizeTracePayload(ctx.get() ?? {}));
524
533
  if (input.message) {
525
534
  push("message", input.message);
526
535
  push("conversational-trace", {
@@ -557,6 +566,9 @@ async function runTurn(bosun, input) {
557
566
  await agent.onCallEnd();
558
567
  break;
559
568
  }
569
+ if (isVoiceAgent(agent)) {
570
+ await agent.waitForIdle();
571
+ }
560
572
  conversation.context = ctx.get() ?? {};
561
573
  return conversation;
562
574
  }
@@ -1946,15 +1958,16 @@ async function generateReplyVariants(ctx, props) {
1946
1958
  );
1947
1959
  if (!inbound) throw new Error("Could not reconstruct the input message for variants");
1948
1960
  const history = conversation.entries.filter((entry) => entry.turn < turn);
1961
+ const startContext = turnStartContext(conversation.entries, turn);
1949
1962
  return Promise.all(
1950
1963
  Array.from({ length: count }, async (_, index) => {
1951
1964
  const draft = {
1952
1965
  ...conversation,
1953
- context: props.context ?? conversation.context,
1966
+ context: structuredClone(startContext ?? conversation.context),
1954
1967
  entries: structuredClone(history)
1955
1968
  };
1956
1969
  const produced = [];
1957
- await runTurn(ctx, {
1970
+ const result = await runTurn(ctx, {
1958
1971
  conversation: draft,
1959
1972
  kind: "message",
1960
1973
  message: inbound.payload,
@@ -1964,7 +1977,8 @@ async function generateReplyVariants(ctx, props) {
1964
1977
  return {
1965
1978
  id: `variant-${index + 1}`,
1966
1979
  text: agentReplyText(produced),
1967
- entries: produced
1980
+ entries: produced,
1981
+ context: result.context
1968
1982
  };
1969
1983
  })
1970
1984
  );
@@ -2730,7 +2744,6 @@ function createRolePlayRouter(t2) {
2730
2744
  generateVariants: t2.procedure.input(
2731
2745
  z4.object({
2732
2746
  conversationId: ConversationIdSchema,
2733
- context: z4.record(z4.string(), z4.unknown()).nullable().optional(),
2734
2747
  promptOverrides: z4.record(z4.string(), z4.string().max(1e6)).optional(),
2735
2748
  count: z4.number().int().min(1).max(9).default(9)
2736
2749
  })
@@ -2739,11 +2752,16 @@ function createRolePlayRouter(t2) {
2739
2752
  return generateReplyVariants(ctx, {
2740
2753
  conversation,
2741
2754
  count: input.count,
2742
- context: input.context ?? void 0,
2743
2755
  promptOverrides: input.promptOverrides ?? {}
2744
2756
  });
2745
2757
  }),
2746
- commitVariant: write.input(z4.object({ conversationId: ConversationIdSchema, entries: z4.array(z4.any()) })).mutation(async ({ input, ctx }) => {
2758
+ commitVariant: write.input(
2759
+ z4.object({
2760
+ conversationId: ConversationIdSchema,
2761
+ entries: z4.array(z4.any()),
2762
+ context: z4.record(z4.string(), z4.unknown())
2763
+ })
2764
+ ).mutation(async ({ input, ctx }) => {
2747
2765
  const conversation = await loadConversation(ctx, input.conversationId);
2748
2766
  const turn = lastTurn(conversation);
2749
2767
  if (!turn) throw new Error("This conversation has no reply to replace");
@@ -2753,6 +2771,7 @@ function createRolePlayRouter(t2) {
2753
2771
  turn
2754
2772
  );
2755
2773
  truncated.entries.push(...input.entries);
2774
+ truncated.context = input.context;
2756
2775
  await saveConversation(ctx, truncated);
2757
2776
  return { ok: true };
2758
2777
  }),