@icanbwell/baileyai-chat-ui 0.3.3 → 0.4.0

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.
@@ -6,6 +6,6 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
6
6
 
7
7
  `),n=t.pop()??``,r=[],i=!1;for(let e of t){let t=e.split(`
8
8
  `).filter(e=>e.length>0),n=`message`,a=[];for(let e of t)e.startsWith(`event:`)?n=e.slice(6).trim():e.startsWith(`data:`)&&a.push(e.slice(5).trim());if(a.length===0)continue;let o=a.join(`
9
- `);if(o===`[DONE]`){i=!0;continue}let s;try{s=JSON.parse(o)}catch{s=void 0}let c=s;if(n===`error`){let e=typeof c?.message==`string`?c.message:o;r.push({type:`error`,message:e})}else if(c?.type===`response.output_text.delta`&&typeof c.delta==`string`){let e=y(c.delta);e&&r.push({type:`response.output_text.delta`,delta:e})}else c&&typeof c.type==`string`?r.push(c):n!==`message`&&r.push({type:`info`,message:`${n}: ${o}`})}return{events:r,remainder:n,done:i}}var x=200,S=15e4,C=(e,t,n)=>{if(e===401||e===403)return`Bailey isn't reachable with your current login.`;let r=`Bailey request failed (status ${e??`network error`}).`,i=(n||t||``).trim();return i?`${r} ${i.length>x?`${i.slice(0,x)}…`:i}`:r},w=({transport:e,model:t,instructions:n,tools:r=[],toolChoice:i,firstUserMessagePrefix:a,onAssistantMessageComplete:o,idleTimeoutMs:s=S})=>{let[c,u]=(0,l.useState)([]),[d,f]=(0,l.useState)([]),[p,m]=(0,l.useState)(null),[h,g]=(0,l.useState)(`idle`),[_,y]=(0,l.useState)(null),x=(0,l.useRef)(null),w=(0,l.useRef)(``),T=(0,l.useRef)(0),E=(0,l.useRef)([]);(0,l.useEffect)(()=>{E.current=c},[c]);let D=(0,l.useRef)(new Map),O=(0,l.useRef)(new Map),k=(0,l.useRef)(null),A=(0,l.useCallback)(()=>{k.current!==null&&(clearTimeout(k.current),k.current=null)},[]),j=(0,l.useCallback)(e=>{A(),k.current=setTimeout(()=>{e.abort(new DOMException(`The assistant took too long to respond. Please try again.`,`TimeoutError`))},s)},[A,s]),M=(0,l.useCallback)((e,t,n)=>{let r=e=>{n.push(e),f(t=>[...t,e])};if(t.type===`response.output_text.delta`){if(!t.delta)return!1;let n=D.current.get(e)??{raw:``,emittedCount:0};n.raw+=t.delta;let{cleanedText:i,matches:a}=v(n.raw),o=i.trim(),s=a.slice(n.emittedCount);if(n.emittedCount=a.length,D.current.set(e,n),O.current.set(e,o),u(t=>t.map(t=>t.id===e?{...t,content:o}:t)),s.length>0){let e=Date.now(),t=T.current;s.forEach(n=>r({kind:`pseudo_tool_call`,name:n.name,args:n.args,at:e,turnSentAt:t}))}return!0}if(t.type===`response.output_item.added`||t.type===`response.output_item.done`){let e=t.item;if(e.type===`function_call`||e.type===`mcp_call`){let n=Date.now(),i=T.current,a=e.name||`unknown_tool`;return r(t.type===`response.output_item.added`?{kind:`tool_start`,name:a,args:e.arguments,at:n,turnSentAt:i}:{kind:`tool_end`,name:a,args:e.arguments,at:n,turnSentAt:i,output:e.output,isError:e.is_error,runtimeSeconds:e.runtime_seconds}),!0}return!1}return t.type===`task.progress`?(r({kind:`progress`,status:t.status,message:t.message,at:Date.now(),turnSentAt:T.current}),!0):t.type===`response.output_text.done`||t.type===`response.created`||t.type===`response.completed`?!1:t.type===`info`?(r({kind:`info`,message:t.message,at:Date.now(),turnSentAt:T.current}),!0):(r({kind:`raw`,eventType:t.type,raw:JSON.stringify(t),at:Date.now(),turnSentAt:T.current}),!0)},[]),N=(0,l.useCallback)(async s=>{g(`streaming`),y(null);let c=crypto.randomUUID();u(e=>[...e,{id:c,role:`assistant`,content:``,streaming:!0}]);let l=Date.now();T.current=l;let d=s.map((e,t)=>t===0&&e.role===`user`&&a?{role:e.role,content:`${a}${e.content}`}:{role:e.role,content:e.content});m({model:t,systemPrompt:n,messages:d,tools:r,toolChoice:i,stream:!0,sentAt:l,streamStats:{chunkCount:0,firstChunkAt:null,lastChunkAt:null}});let p=new AbortController;x.current=p,j(p);let h=``,_=null,v=!1,S=!1,w=[],E=(e,t)=>{g(`error`),y(e);let n={kind:`error`,message:e,at:Date.now(),turnSentAt:l,...t};w.push(n),f(e=>[...e,n])},k=(e,t)=>{e.forEach(e=>{if(e.type===`error`){_=e.message;let t={kind:`error`,message:e.message,at:Date.now(),turnSentAt:l};w.push(t),f(e=>[...e,t]);return}e.type===`response.output_text.delta`&&e.delta&&(S=!0),M(c,e,w)&&(v=!0)}),t&&u(e=>e.map(e=>e.id===c?{...e,streaming:!1}:e))};try{let{status:a,text:s,errorMessage:u}=await e.streamChat({model:t,instructions:n,input:d,tools:r,toolChoice:i,signal:p.signal,onChunk:e=>{j(p),h+=e;let{events:t,remainder:n,done:r}=b(h);h=n,k(t,r);let i=Date.now();m(e=>e&&e.sentAt===l?{...e,streamStats:{chunkCount:e.streamStats.chunkCount+1,firstChunkAt:e.streamStats.firstChunkAt??i,lastChunkAt:i}}:e)},onRequestId:e=>{m(t=>t&&t.sentAt===l?{...t,requestId:e}:t)}});if(h.trim()){let{events:e,done:t}=b(`${h}\n\n`);h=``,k(e,t)}if(_){g(`error`),y(_);return}if(a===void 0||a>=400){E(C(a,s,u),{httpStatus:a,rawBody:s||void 0});return}if(!v){E(`Bailey returned an empty response.`);return}if(!S){E(`Bailey ran some tools but didn't return an answer. Try asking again.`);return}g(`idle`);let f=O.current.get(c)??``;m(e=>e&&e.sentAt===l?{...e,response:{content:f}}:e),o&&await o({id:c,role:`assistant`,content:f,streaming:!1},w)}catch(e){let t=e;if(t?.name===`TimeoutError`){E(t.message,{source:`client-timeout`});return}if(t?.name===`AbortError`){g(`idle`);return}E(t?.message||`Bailey request failed.`)}finally{A(),D.current.delete(c),O.current.delete(c),u(e=>e.flatMap(e=>e.id===c?e.content?[{...e,streaming:!1}]:[]:[e]))}},[e,t,n,r,i,a,o,M,j,A]),P=(0,l.useCallback)(e=>{E.current=e,u(e)},[]);return{messages:c,traceEvents:d,lastRequest:p,status:h,error:_,send:(0,l.useCallback)(e=>{let t=e.trim();if(!t)return;w.current=t;let n=[...E.current,{id:crypto.randomUUID(),role:`user`,content:t}];P(n),N(n)},[N,P]),stop:(0,l.useCallback)(()=>{x.current?.abort()},[]),retryLast:(0,l.useCallback)(()=>{if(!w.current)return;let e=E.current,t=e[e.length-1],n=t&&t.role===`assistant`?e.slice(0,-1):e;P(n),N(n)},[N,P]),clearTrace:(0,l.useCallback)(()=>f([]),[]),clearError:(0,l.useCallback)(()=>{y(null),g(e=>e===`error`?`idle`:e)},[]),newChat:(0,l.useCallback)(()=>{x.current?.abort(),P([]),f([]),m(null),g(`idle`),y(null),w.current=``},[P])}};function T(...e){return e.filter(e=>!!(e&&e.trim())).join(`
9
+ `);if(o===`[DONE]`){i=!0;continue}let s;try{s=JSON.parse(o)}catch{s=void 0}let c=s;if(n===`error`){let e=typeof c?.message==`string`?c.message:o;r.push({type:`error`,message:e})}else if(c?.type===`response.output_text.delta`&&typeof c.delta==`string`){let e=y(c.delta);e&&r.push({type:`response.output_text.delta`,delta:e})}else c&&typeof c.type==`string`?r.push(c):n!==`message`&&r.push({type:`info`,message:`${n}: ${o}`})}return{events:r,remainder:n,done:i}}var x=200,S=15e4,C=(e,t,n)=>{if(e===401||e===403)return`Bailey isn't reachable with your current login.`;let r=`Bailey request failed (status ${e??`network error`}).`,i=(n||t||``).trim();return i?`${r} ${i.length>x?`${i.slice(0,x)}…`:i}`:r},w=({transport:e,model:t,instructions:n,tools:r=[],toolChoice:i,firstUserMessagePrefix:a,onAssistantMessageComplete:o,idleTimeoutMs:s=S})=>{let[c,u]=(0,l.useState)([]),[d,f]=(0,l.useState)([]),[p,m]=(0,l.useState)(null),[h,g]=(0,l.useState)(`idle`),[_,y]=(0,l.useState)(null),x=(0,l.useRef)(null),w=(0,l.useRef)(``),T=(0,l.useRef)(0),E=(0,l.useRef)([]);(0,l.useEffect)(()=>{E.current=c},[c]);let D=(0,l.useRef)(new Map),O=(0,l.useRef)(new Map),k=(0,l.useRef)(null),A=(0,l.useCallback)(()=>{k.current!==null&&(clearTimeout(k.current),k.current=null)},[]),j=(0,l.useCallback)(e=>{A(),k.current=setTimeout(()=>{e.abort(new DOMException(`The assistant took too long to respond. Please try again.`,`TimeoutError`))},s)},[A,s]),M=(0,l.useCallback)((e,t,n)=>{let r=e=>{n.push(e),f(t=>[...t,e])};if(t.type===`response.output_text.delta`){if(!t.delta)return!1;let n=D.current.get(e)??{raw:``,emittedCount:0};n.raw+=t.delta;let{cleanedText:i,matches:a}=v(n.raw),o=i.trim(),s=a.slice(n.emittedCount);if(n.emittedCount=a.length,D.current.set(e,n),O.current.set(e,o),u(t=>t.map(t=>t.id===e?{...t,content:o}:t)),s.length>0){let e=Date.now(),t=T.current;s.forEach(n=>r({kind:`pseudo_tool_call`,name:n.name,args:n.args,at:e,turnSentAt:t}))}return!0}if(t.type===`response.output_item.added`||t.type===`response.output_item.done`){let e=t.item;if(e.type===`function_call`||e.type===`mcp_call`){let n=Date.now(),i=T.current,a=e.name||`unknown_tool`;return r(t.type===`response.output_item.added`?{kind:`tool_start`,name:a,args:e.arguments,at:n,turnSentAt:i}:{kind:`tool_end`,name:a,args:e.arguments,at:n,turnSentAt:i,output:e.output,isError:e.is_error,runtimeSeconds:e.runtime_seconds}),!0}return!1}return t.type===`task.progress`?(r({kind:`progress`,status:t.status,message:t.message,at:Date.now(),turnSentAt:T.current}),!0):t.type===`response.output_text.done`||t.type===`response.created`||t.type===`response.completed`?!1:t.type===`info`?(r({kind:`info`,message:t.message,at:Date.now(),turnSentAt:T.current}),!0):(r({kind:`raw`,eventType:t.type,raw:JSON.stringify(t),at:Date.now(),turnSentAt:T.current}),!0)},[]),N=(0,l.useCallback)(async s=>{g(`streaming`),y(null);let c=Date.now();T.current=c;let l=crypto.randomUUID();u(e=>[...e,{id:l,role:`assistant`,content:``,streaming:!0,createdAt:c}]);let d=s.map((e,t)=>t===0&&e.role===`user`&&a?{role:e.role,content:`${a}${e.content}`}:{role:e.role,content:e.content});m({model:t,systemPrompt:n,messages:d,tools:r,toolChoice:i,stream:!0,sentAt:c,streamStats:{chunkCount:0,firstChunkAt:null,lastChunkAt:null}});let p=new AbortController;x.current=p,j(p);let h=``,_=null,v=!1,S=!1,w=[],E=(e,t)=>{g(`error`),y(e);let n={kind:`error`,message:e,at:Date.now(),turnSentAt:c,...t};w.push(n),f(e=>[...e,n])},k=(e,t)=>{e.forEach(e=>{if(e.type===`error`){_=e.message;let t={kind:`error`,message:e.message,at:Date.now(),turnSentAt:c};w.push(t),f(e=>[...e,t]);return}e.type===`response.output_text.delta`&&e.delta&&(S=!0),M(l,e,w)&&(v=!0)}),t&&u(e=>e.map(e=>e.id===l?{...e,streaming:!1}:e))};try{let{status:a,text:s,errorMessage:u}=await e.streamChat({model:t,instructions:n,input:d,tools:r,toolChoice:i,signal:p.signal,onChunk:e=>{j(p),h+=e;let{events:t,remainder:n,done:r}=b(h);h=n,k(t,r);let i=Date.now();m(e=>e&&e.sentAt===c?{...e,streamStats:{chunkCount:e.streamStats.chunkCount+1,firstChunkAt:e.streamStats.firstChunkAt??i,lastChunkAt:i}}:e)},onRequestId:e=>{m(t=>t&&t.sentAt===c?{...t,requestId:e}:t)}});if(h.trim()){let{events:e,done:t}=b(`${h}\n\n`);h=``,k(e,t)}if(_){g(`error`),y(_);return}if(a===void 0||a>=400){E(C(a,s,u),{httpStatus:a,rawBody:s||void 0});return}if(!v){E(`Bailey returned an empty response.`);return}if(!S){E(`Bailey ran some tools but didn't return an answer. Try asking again.`);return}g(`idle`);let f=O.current.get(l)??``;m(e=>e&&e.sentAt===c?{...e,response:{content:f}}:e),o&&await o({id:l,role:`assistant`,content:f,streaming:!1},w)}catch(e){let t=e;if(t?.name===`TimeoutError`){E(t.message,{source:`client-timeout`});return}if(t?.name===`AbortError`){g(`idle`);return}E(t?.message||`Bailey request failed.`)}finally{A(),D.current.delete(l),O.current.delete(l),u(e=>e.flatMap(e=>e.id===l?e.content?[{...e,streaming:!1}]:[]:[e]))}},[e,t,n,r,i,a,o,M,j,A]),P=(0,l.useCallback)(e=>{E.current=e,u(e)},[]);return{messages:c,traceEvents:d,lastRequest:p,status:h,error:_,send:(0,l.useCallback)(e=>{let t=e.trim();if(!t)return;w.current=t;let n=[...E.current,{id:crypto.randomUUID(),role:`user`,content:t,createdAt:Date.now()}];P(n),N(n)},[N,P]),stop:(0,l.useCallback)(()=>{x.current?.abort()},[]),retryLast:(0,l.useCallback)(()=>{if(!w.current)return;let e=E.current,t=e[e.length-1],n=t&&t.role===`assistant`?e.slice(0,-1):e;P(n),N(n)},[N,P]),clearTrace:(0,l.useCallback)(()=>f([]),[]),clearError:(0,l.useCallback)(()=>{y(null),g(e=>e===`error`?`idle`:e)},[]),newChat:(0,l.useCallback)(()=>{x.current?.abort(),P([]),f([]),m(null),g(`idle`),y(null),w.current=``},[P])}};function T(...e){return e.filter(e=>!!(e&&e.trim())).join(`
10
10
 
11
- `)}var E=`call_tool`,D=`a tool`;function O(e,t){let n={name:e===E?D:e,args:null,viaCallTool:!1};if(!t)return n;let r;try{r=JSON.parse(t)}catch{return n}if(typeof r!=`object`||!r)return n;let i=r;if(e===E){let e=typeof i.name==`string`?i.name:void 0;if(!e)return n;let t=i.arguments;return{name:e,args:typeof t==`object`&&t?t:null,viaCallTool:!0}}return{name:e,args:i,viaCallTool:!1}}var k=5,A=e=>e.type===`text`?e.value??``:(e.children??[]).map(A).join(``),j=e=>{if(e.tagName===`a`&&e.properties?.href)return e.properties.href;for(let t of e.children??[]){let e=j(t);if(e)return e}},M=(e,t)=>(e.children??[]).find(e=>e.tagName===t),N=e=>{let t=A(e),n=j(e);return n?{text:t,href:n}:{text:t}},P=e=>(e.children??[]).filter(e=>e.type===`element`).map(N),F=e=>{if(e.tagName!==`table`)return null;let t=M(e,`thead`),n=t&&M(t,`tr`);return{headers:n?P(n).map(e=>e.text):[],rows:(M(e,`tbody`)?.children??[]).filter(e=>e.tagName===`tr`).map(P)}},ee=e=>e.length>5,te='When a chart would help answer a question (e.g. plotting a trend over time), include a fenced code block tagged `chartjs` containing a JSON object with this exact shape: {"type": "bar" | "line" | "pie" | "doughnut" | "scatter", "title"?: string, "data": {"labels": string[], "datasets": [{"label": string, "data": number[]}]}}. For "scatter" charts, omit "labels" and give each dataset "data" as an array of {"x": number, "y": number} points instead of a number array. "pie" and "doughnut" charts must have exactly one dataset. Do not include any other fields (no "options", no colors) — the app handles styling. Example:\n```chartjs\n{"type": "line", "title": "BP readings", "data": {"labels": ["Jul 14", "Jul 21", "Jul 28"], "datasets": [{"label": "Systolic", "data": [120, 118, 122]}]}}\n```',ne=[`bar`,`line`,`pie`,`doughnut`,`scatter`],re=8,ie=50,ae=8,oe=500,se=e=>typeof e==`object`&&!!e&&typeof e.x==`number`&&typeof e.y==`number`,I=e=>{let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t)return null;let n=t;if(typeof n.type!=`string`||!ne.includes(n.type))return null;let r=n.type;if(n.title!==void 0&&typeof n.title!=`string`)return null;let i=n.title;if(typeof n.data!=`object`||n.data===null)return null;let a=n.data;if(!Array.isArray(a.datasets)||a.datasets.length<1||a.datasets.length>re||(r===`pie`||r===`doughnut`)&&a.datasets.length!==1)return null;for(let e of a.datasets)if(typeof e!=`object`||!e||typeof e.label!=`string`||!Array.isArray(e.data))return null;let o=a.datasets;if(r===`scatter`){for(let e of o)if(e.data.length<1||e.data.length>oe||!e.data.every(se))return null;return{type:r,title:i,data:{datasets:o}}}if(!Array.isArray(a.labels)||!a.labels.every(e=>typeof e==`string`))return null;let s=a.labels,c=r===`pie`||r===`doughnut`?ae:ie;if(s.length<1||s.length>c)return null;for(let e of o)if(e.data.length!==s.length||!e.data.every(e=>typeof e==`number`))return null;return{type:r,title:i,data:{labels:s,datasets:o}}},L={tool_start:`Tool start`,tool_end:`Tool end`,pseudo_tool_call:`Narrated tool call`,progress:`Progress`,info:`Info`,error:`Error`,raw:`Raw event`};function R(e){return e.kind!==`tool_start`&&e.kind!==`tool_end`?null:O(e.name,e.args)}function z(e,t=R(e)){return e.kind===`pseudo_tool_call`?e.name:t?.name??null}function B(e,t=R(e)){switch(e.kind){case`tool_start`:return t.viaCallTool?`${t.name} (via call_tool)`:t.name;case`tool_end`:return`${t.viaCallTool?`${t.name} (via call_tool)`:t.name}${e.runtimeSeconds===void 0?``:` — ${e.runtimeSeconds.toFixed(2)}s`}${e.isError?` — failed`:``}`;case`pseudo_tool_call`:return`${e.name} — written as text, not actually called`;case`progress`:return e.message?`${e.status} — ${e.message}`:e.status;case`info`:return e.message;case`error`:return e.httpStatus?`${e.message} (HTTP ${e.httpStatus})`:e.message;case`raw`:return`Unrecognized event: ${e.eventType}`}}function V(e,t=R(e)){return e.kind===`tool_start`||e.kind===`tool_end`?t.args?JSON.stringify(t.args,null,2):e.args??null:e.kind===`pseudo_tool_call`?e.args??null:null}function H(e){return e.kind===`tool_end`?e.output??null:null}function U(e){return e.kind===`raw`?e.raw:e.kind===`error`?e.rawBody??null:null}function W(e){switch(e.kind){case`tool_start`:return`Calling ${O(e.name,e.args).name}...`;case`tool_end`:{let t=O(e.name,e.args).name;return e.isError?`${t} failed`:`${t} returned`}case`pseudo_tool_call`:return`${e.name} (written as text, not called)`;case`progress`:return e.message??e.status;case`info`:return e.message;case`error`:return e.source===`client-timeout`?`Timed out: ${e.message}`:`Error: ${e.message}`;case`raw`:return`Unrecognized event: ${e.eventType}`}}function G(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}:${String(t.getSeconds()).padStart(2,`0`)}.${String(t.getMilliseconds()).padStart(3,`0`)}`}function K(e){if(e<=0)return`+0ms`;if(e<1e3)return`+${Math.round(e)}ms`;let t=e/1e3;if(t<60)return`+${t.toFixed(1)}s`;let n=Math.floor(t/60),r=Math.round(t%60);return`+${n}m${String(r).padStart(2,`0`)}s`}function q(e){return e.map((t,n)=>{let r=R(t),i=n===0?t.turnSentAt:e[n-1].at;return{key:`${t.at}-${n}`,kind:t.kind,toolName:z(t,r),isToolStart:t.kind===`tool_start`,failed:t.kind===`tool_end`&&t.isError===!0,time:G(t.at),gapMs:t.at-i,label:t.kind===`tool_end`&&t.isError===!0?`Tool failed`:L[t.kind],summary:B(t,r),argsDetail:V(t,r),outputDetail:H(t),rawDetail:U(t)}})}function J(e){let t=e.filter(e=>e.kind===`tool_end`),n=t.filter(e=>e.kind===`tool_end`&&e.isError),r=e.filter(e=>e.kind===`error`),i=[];return t.length>0&&i.push(`${t.length} tool call${t.length===1?``:`s`}`+(n.length>0?`, ${n.length} failed`:``)),r.length>0&&i.push(`${r.length} stream error${r.length===1?``:`s`}`),i.join(` · `)}function Y(e){let t=[];for(let n of e){let e=t[t.length-1];if(n.toolName&&e?.type===`group`&&e.toolName===n.toolName){e.rows.push(n);continue}t.push(n.toolName?{type:`group`,toolName:n.toolName,rows:[n]}:{type:`single`,row:n})}return t}function ce(e){return e.some(e=>e.kind===`tool_end`&&e.isError||e.kind===`error`)}function le({renderTable:e,renderChart:t}={}){return{a:({href:e,children:t})=>!e||!c.t(e)?(0,f.jsx)(f.Fragment,{children:t}):(0,f.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:t}),table:({node:t,children:n})=>{let r=t&&F(t);if(r&&ee(r.rows)&&e){let t=r.rows.map(e=>e.map(e=>e.href&&!c.t(e.href)?{text:e.text}:e));return(0,f.jsx)(f.Fragment,{children:e({headers:r.headers,rows:t})})}return(0,f.jsx)(`table`,{children:n})},pre:({children:e})=>{let n=(Array.isArray(e)?e[0]:e)?.props;if((n?.className?.split(` `)??[]).includes(`language-chartjs`)&&t){let e=n?.children,r=I(Array.isArray(e)?e.join(``):String(e??``));if(r)return(0,f.jsx)(f.Fragment,{children:t(r)})}return(0,f.jsx)(`pre`,{children:e})}}}var ue=1500;function de({markdown:e,className:t}){let[n,r]=(0,l.useState)(!1),[i,a]=(0,l.useState)(!1),o=(0,l.useRef)(null);return(0,l.useEffect)(()=>()=>{o.current!==null&&clearTimeout(o.current)},[]),(0,f.jsx)(p.Provider,{delayDuration:200,children:(0,f.jsxs)(p.Root,{open:n||i,onOpenChange:a,children:[(0,f.jsx)(p.Trigger,{asChild:!0,children:(0,f.jsx)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(e)}catch{}r(!0),o.current!==null&&clearTimeout(o.current),o.current=setTimeout(()=>r(!1),ue)},"aria-label":`copy response as markdown`,className:`bailey-copy-button${t?` ${t}`:``}`,children:n?`✓`:`⧉`})}),(0,f.jsx)(p.Portal,{children:(0,f.jsxs)(p.Content,{side:`top`,className:`bailey-tooltip-content`,children:[n?`Copied!`:`Copy as markdown`,(0,f.jsx)(p.Arrow,{className:`bailey-tooltip-arrow`})]})})]})})}async function fe(e){try{await navigator.clipboard.writeText(e)}catch{}}function X({text:e,label:t=`Copy`}){return(0,f.jsx)(`button`,{type:`button`,onClick:()=>fe(e),className:`bailey-trace-copy-button`,children:t})}function pe(e){if(e.failed||e.kind===`error`)return`bailey-trace-chip bailey-trace-chip-error`;switch(e.kind){case`tool_start`:return`bailey-trace-chip bailey-trace-chip-info`;case`tool_end`:return`bailey-trace-chip bailey-trace-chip-success`;case`progress`:return`bailey-trace-chip bailey-trace-chip-secondary`;default:return`bailey-trace-chip bailey-trace-chip-default`}}function Z({label:e,content:t,copyable:n}){return(0,f.jsxs)(`details`,{className:`bailey-trace-disclosure`,children:[(0,f.jsx)(`summary`,{className:`bailey-trace-disclosure-summary`,children:e}),n&&(0,f.jsx)(`div`,{className:`bailey-trace-disclosure-actions`,children:(0,f.jsx)(X,{text:t})}),(0,f.jsx)(`pre`,{className:`bailey-trace-disclosure-content`,children:t})]})}function Q({row:e}){return(0,f.jsxs)(`div`,{className:`bailey-trace-row`,children:[(0,f.jsxs)(`div`,{className:`bailey-trace-row-header`,children:[(0,f.jsx)(`span`,{className:`bailey-trace-row-time`,children:e.time}),(0,f.jsx)(`span`,{className:`bailey-trace-row-gap`,title:`Time since the previous event`,children:K(e.gapMs)}),(0,f.jsx)(`span`,{className:pe(e),children:e.label}),(0,f.jsx)(`span`,{className:`bailey-trace-row-summary`,children:e.summary})]}),e.argsDetail&&(0,f.jsx)(Z,{label:`args`,content:e.argsDetail}),e.outputDetail&&(0,f.jsx)(Z,{label:`output`,content:e.outputDetail}),e.rawDetail&&(0,f.jsx)(Z,{label:`raw`,content:e.rawDetail})]})}function me(e,t){if(e.chunkCount===0)return`Streamed: no chunks received`;if(e.chunkCount===1||e.firstChunkAt===null)return`Streamed: 1 chunk (not incremental)`;let n=e.firstChunkAt-t,r=(e.lastChunkAt??e.firstChunkAt)-e.firstChunkAt;return`Streamed: ${e.chunkCount} chunks · first chunk after ${n}ms · spread over ${(r/1e3).toFixed(1)}s`}function he({request:e}){let t=(0,l.useMemo)(()=>JSON.stringify({model:e.model,instructions:e.systemPrompt,input:e.messages,stream:e.stream,tools:e.tools,toolChoice:e.toolChoice},null,2),[e]);return(0,f.jsxs)(`div`,{className:`bailey-trace-request-details`,children:[(0,f.jsxs)(`span`,{className:`bailey-trace-request-meta`,children:[`Last request — `,e.model,` · `,new Date(e.sentAt).toLocaleTimeString(),e.requestId?` · ${e.requestId}`:``]}),(0,f.jsx)(`span`,{className:`bailey-trace-request-meta`,children:me(e.streamStats,e.sentAt)}),(0,f.jsx)(Z,{label:`System prompt (${e.systemPrompt.length.toLocaleString()} chars)`,content:e.systemPrompt,copyable:!0}),(0,f.jsx)(Z,{label:`Messages (${e.messages.length})`,content:JSON.stringify(e.messages,null,2),copyable:!0}),e.response&&(0,f.jsx)(Z,{label:`Response (${e.response.content.length.toLocaleString()} chars)`,content:e.response.content,copyable:!0}),(0,f.jsx)(Z,{label:`Full payload (JSON)`,content:t,copyable:!0})]})}function ge({events:e,lastRequest:t,onClear:n}){let r=(0,l.useMemo)(()=>q(e),[e]),i=(0,l.useMemo)(()=>Y(r),[r]),a=(0,l.useMemo)(()=>JSON.stringify(e,null,2),[e]);return(0,f.jsxs)(`div`,{className:`bailey-trace-body`,children:[(0,f.jsxs)(`div`,{className:`bailey-trace-actions-row`,children:[e.length>0&&(0,f.jsx)(X,{text:a,label:`Copy trace as JSON`}),(0,f.jsx)(`button`,{type:`button`,onClick:n,className:`bailey-trace-copy-button`,children:`Clear`})]}),t&&(0,f.jsx)(he,{request:t}),(0,f.jsx)(`div`,{className:`bailey-trace-rows`,children:i.map((e,t)=>{if(e.type===`single`)return(0,f.jsx)(Q,{row:e.row},e.row.key);let n=e.rows.filter(e=>e.isToolStart).length;if(n<=1)return(0,f.jsx)(`div`,{className:`bailey-trace-rows`,children:e.rows.map(e=>(0,f.jsx)(Q,{row:e},e.key))},`group-${t}`);let r=e.rows.filter(e=>e.failed).length;return(0,f.jsxs)(`details`,{className:`bailey-trace-group`,children:[(0,f.jsxs)(`summary`,{className:`bailey-trace-group-summary`,children:[(0,f.jsx)(`strong`,{children:e.toolName}),` × `,n,r>0&&(0,f.jsxs)(`span`,{className:`bailey-trace-group-failed`,children:[` `,r,` failed`]})]}),(0,f.jsx)(`div`,{className:`bailey-trace-rows`,children:e.rows.map(e=>(0,f.jsx)(Q,{row:e},e.key))})]},`group-${t}`)})})]})}function $({events:e,lastRequest:t,onClear:n}){let[r,i]=(0,l.useState)(!1),a=(0,l.useMemo)(()=>ce(e),[e]),o=(0,l.useMemo)(()=>J(e),[e]);return e.length===0&&!t?null:(0,f.jsxs)(`div`,{className:`bailey-trace-panel`,children:[(0,f.jsxs)(`div`,{className:`bailey-trace-toggle-row`,children:[(0,f.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),"aria-expanded":r,className:a?`bailey-trace-toggle bailey-trace-toggle-error`:`bailey-trace-toggle`,children:[a&&!r?`⚠ `:``,r?`Hide details`:`Show details`,` (`,e.length,`)`]}),o&&(0,f.jsx)(`span`,{className:a?`bailey-trace-summary bailey-trace-summary-error`:`bailey-trace-summary`,children:o})]}),r&&(0,f.jsx)(ge,{events:e,lastRequest:t,onClear:n})]})}var _e=[d.default],ve=(0,l.memo)(function({content:e,components:t}){return(0,f.jsx)(`div`,{className:`bailey-markdown-content`,children:(0,f.jsx)(u.default,{remarkPlugins:_e,components:t,children:e})})});function ye(e,t,n){if(e!==`streaming`)return;let r=t.filter(e=>e.turnSentAt===n?.sentAt);if(r.length!==0)return W(r[r.length-1])}function be({chat:e,placeholder:t=`Send a message…`,className:n,renderMessageActions:r,renderTable:i,renderChart:a}){let{messages:o,traceEvents:s,lastRequest:c,status:u,error:d,send:p,stop:m,retryLast:h,clearTrace:g,clearError:_,newChat:v}=e,[y,b]=(0,l.useState)(``),x=(0,l.useRef)(null),S=(0,l.useMemo)(()=>le({renderTable:i,renderChart:a}),[i,a]),C=(0,l.useMemo)(()=>ye(u,s,c),[u,s,c]);return(0,l.useEffect)(()=>{x.current?.scrollIntoView({behavior:`smooth`,block:`nearest`})},[o]),(0,f.jsxs)(`div`,{className:`bailey-chat-panel${n?` ${n}`:``}`,children:[(0,f.jsx)(`div`,{className:`bailey-toolbar-row`,children:(0,f.jsx)(`button`,{type:`button`,onClick:v,disabled:o.length===0,"aria-label":`new chat`,className:`bailey-new-chat-button`,children:`New chat`})}),(0,f.jsxs)(`div`,{className:`bailey-chat-transcript`,children:[o.length===0&&(0,f.jsx)(`div`,{className:`bailey-empty-state`,children:`Ask Bailey a question to get started.`}),o.map((e,t)=>{let n=e.role===`assistant`&&t===o.length-1,i=u===`streaming`&&n&&e.content===``;return(0,f.jsx)(`div`,{className:e.role===`user`?`bailey-message-row bailey-message-row-user`:`bailey-message-row`,children:e.role===`user`?(0,f.jsx)(`div`,{className:`bailey-user-bubble`,children:e.content}):i?(0,f.jsx)(`div`,{className:`bailey-thinking-hint`,children:C??`Thinking…`}):(0,f.jsxs)(`div`,{className:`bailey-assistant-message`,children:[(0,f.jsx)(ve,{content:e.content,components:S}),e.streaming&&C&&(0,f.jsx)(`div`,{className:`bailey-streaming-hint`,children:C}),!e.streaming&&(0,f.jsxs)(`div`,{className:`bailey-message-actions`,children:[(0,f.jsx)(de,{markdown:e.content}),r?.(e)]})]})},e.id)}),(0,f.jsx)(`div`,{ref:x})]}),d&&(0,f.jsxs)(`div`,{className:`bailey-error-banner`,role:`alert`,children:[(0,f.jsx)(`span`,{children:d}),(0,f.jsxs)(`div`,{className:`bailey-error-actions`,children:[(0,f.jsx)(`button`,{type:`button`,onClick:h,className:`bailey-retry-button`,children:`Retry`}),(0,f.jsx)(`button`,{type:`button`,onClick:_,"aria-label":`dismiss error`,className:`bailey-dismiss-button`,children:`✕`})]})]}),(0,f.jsx)($,{events:s,lastRequest:c,onClear:g}),(0,f.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),!(!y.trim()||u===`streaming`)&&(p(y),b(``))},className:`bailey-input-row`,children:[(0,f.jsx)(`input`,{type:`text`,placeholder:t,"aria-label":t,value:y,onChange:e=>b(e.target.value),disabled:u===`streaming`,className:`bailey-input`}),u===`streaming`?(0,f.jsx)(`button`,{type:`button`,onClick:m,"aria-label":`stop`,className:`bailey-stop-button`,children:`Stop`}):(0,f.jsx)(`button`,{type:`submit`,"aria-label":`send`,disabled:!y.trim(),className:`bailey-send-button`,children:`Send`})]})]})}var xe=`0.3.1-pre.1`;exports.BAILEYAI_CHAT_UI_VERSION=xe,exports.BAILEY_CHART_PROMPT_FRAGMENT=te,exports.BAILEY_TABLE_GRID_ROW_THRESHOLD=k,exports.BaileyChatPanel=be,exports.BaileyTracePanel=$,exports.CopyMarkdownButton=de,exports.TRACE_KIND_LABEL=L,exports.createBaileyMarkdownComponents=le,exports.extractPseudoToolCalls=v,exports.extractTableData=F,exports.formatTraceGap=K,exports.formatTraceTime=G,exports.hasTraceFailure=ce,exports.isSafeMarkdownUrl=c.t,exports.joinInstructions=T,exports.parseBaileyChartSpec=I,exports.parseSseFrames=b,exports.resolveToolCall=O,exports.shouldUseGrid=ee,exports.toTraceRows=q,exports.toTraceSegments=Y,exports.traceEventArgsDetail=V,exports.traceEventHint=W,exports.traceEventOutputDetail=H,exports.traceEventRawDetail=U,exports.traceEventSummary=B,exports.traceEventToolName=z,exports.traceSummaryLine=J,exports.useBaileyChat=w;
11
+ `)}var E=`call_tool`,D=`a tool`;function O(e,t){let n={name:e===E?D:e,args:null,viaCallTool:!1};if(!t)return n;let r;try{r=JSON.parse(t)}catch{return n}if(typeof r!=`object`||!r)return n;let i=r;if(e===E){let e=typeof i.name==`string`?i.name:void 0;if(!e)return n;let t=i.arguments;return{name:e,args:typeof t==`object`&&t?t:null,viaCallTool:!0}}return{name:e,args:i,viaCallTool:!1}}var k=5,A=e=>e.type===`text`?e.value??``:(e.children??[]).map(A).join(``),j=e=>{if(e.tagName===`a`&&e.properties?.href)return e.properties.href;for(let t of e.children??[]){let e=j(t);if(e)return e}},M=(e,t)=>(e.children??[]).find(e=>e.tagName===t),N=e=>{let t=A(e),n=j(e);return n?{text:t,href:n}:{text:t}},P=e=>(e.children??[]).filter(e=>e.type===`element`).map(N),F=e=>{if(e.tagName!==`table`)return null;let t=M(e,`thead`),n=t&&M(t,`tr`);return{headers:n?P(n).map(e=>e.text):[],rows:(M(e,`tbody`)?.children??[]).filter(e=>e.tagName===`tr`).map(P)}},I=e=>e.length>5,ee='When a chart would help answer a question (e.g. plotting a trend over time), include a fenced code block tagged `chartjs` containing a JSON object with this exact shape: {"type": "bar" | "line" | "pie" | "doughnut" | "scatter", "title"?: string, "data": {"labels": string[], "datasets": [{"label": string, "data": number[]}]}}. For "scatter" charts, omit "labels" and give each dataset "data" as an array of {"x": number, "y": number} points instead of a number array. "pie" and "doughnut" charts must have exactly one dataset. Do not include any other fields (no "options", no colors) — the app handles styling. Example:\n```chartjs\n{"type": "line", "title": "BP readings", "data": {"labels": ["Jul 14", "Jul 21", "Jul 28"], "datasets": [{"label": "Systolic", "data": [120, 118, 122]}]}}\n```',te=[`bar`,`line`,`pie`,`doughnut`,`scatter`],ne=8,re=50,ie=8,ae=500,oe=e=>typeof e==`object`&&!!e&&typeof e.x==`number`&&typeof e.y==`number`,L=e=>{let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t)return null;let n=t;if(typeof n.type!=`string`||!te.includes(n.type))return null;let r=n.type;if(n.title!==void 0&&typeof n.title!=`string`)return null;let i=n.title;if(typeof n.data!=`object`||n.data===null)return null;let a=n.data;if(!Array.isArray(a.datasets)||a.datasets.length<1||a.datasets.length>ne||(r===`pie`||r===`doughnut`)&&a.datasets.length!==1)return null;for(let e of a.datasets)if(typeof e!=`object`||!e||typeof e.label!=`string`||!Array.isArray(e.data))return null;let o=a.datasets;if(r===`scatter`){for(let e of o)if(e.data.length<1||e.data.length>ae||!e.data.every(oe))return null;return{type:r,title:i,data:{datasets:o}}}if(!Array.isArray(a.labels)||!a.labels.every(e=>typeof e==`string`))return null;let s=a.labels,c=r===`pie`||r===`doughnut`?ie:re;if(s.length<1||s.length>c)return null;for(let e of o)if(e.data.length!==s.length||!e.data.every(e=>typeof e==`number`))return null;return{type:r,title:i,data:{labels:s,datasets:o}}},R={tool_start:`Tool start`,tool_end:`Tool end`,pseudo_tool_call:`Narrated tool call`,progress:`Progress`,info:`Info`,error:`Error`,raw:`Raw event`};function z(e){return e.kind!==`tool_start`&&e.kind!==`tool_end`?null:O(e.name,e.args)}function B(e,t=z(e)){return e.kind===`pseudo_tool_call`?e.name:t?.name??null}function V(e,t=z(e)){switch(e.kind){case`tool_start`:return t.viaCallTool?`${t.name} (via call_tool)`:t.name;case`tool_end`:return`${t.viaCallTool?`${t.name} (via call_tool)`:t.name}${e.runtimeSeconds===void 0?``:` — ${e.runtimeSeconds.toFixed(2)}s`}${e.isError?` — failed`:``}`;case`pseudo_tool_call`:return`${e.name} — written as text, not actually called`;case`progress`:return e.message?`${e.status} — ${e.message}`:e.status;case`info`:return e.message;case`error`:return e.httpStatus?`${e.message} (HTTP ${e.httpStatus})`:e.message;case`raw`:return`Unrecognized event: ${e.eventType}`}}function H(e,t=z(e)){return e.kind===`tool_start`||e.kind===`tool_end`?t.args?JSON.stringify(t.args,null,2):e.args??null:e.kind===`pseudo_tool_call`?e.args??null:null}function U(e){return e.kind===`tool_end`?e.output??null:null}function W(e){return e.kind===`raw`?e.raw:e.kind===`error`?e.rawBody??null:null}function G(e){switch(e.kind){case`tool_start`:return`Calling ${O(e.name,e.args).name}...`;case`tool_end`:{let t=O(e.name,e.args).name;return e.isError?`${t} failed`:`${t} returned`}case`pseudo_tool_call`:return`${e.name} (written as text, not called)`;case`progress`:return e.message??e.status;case`info`:return e.message;case`error`:return e.source===`client-timeout`?`Timed out: ${e.message}`:`Error: ${e.message}`;case`raw`:return`Unrecognized event: ${e.eventType}`}}function K(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}:${String(t.getSeconds()).padStart(2,`0`)}.${String(t.getMilliseconds()).padStart(3,`0`)}`}function q(e){if(e<=0)return`+0ms`;if(e<1e3)return`+${Math.round(e)}ms`;let t=e/1e3;if(t<60)return`+${t.toFixed(1)}s`;let n=Math.floor(t/60),r=Math.round(t%60);return`+${n}m${String(r).padStart(2,`0`)}s`}function J(e){return e.map((t,n)=>{let r=z(t),i=n===0?t.turnSentAt:e[n-1].at;return{key:`${t.at}-${n}`,kind:t.kind,toolName:B(t,r),isToolStart:t.kind===`tool_start`,failed:t.kind===`tool_end`&&t.isError===!0,time:K(t.at),gapMs:t.at-i,label:t.kind===`tool_end`&&t.isError===!0?`Tool failed`:R[t.kind],summary:V(t,r),argsDetail:H(t,r),outputDetail:U(t),rawDetail:W(t)}})}function Y(e){let t=e.filter(e=>e.kind===`tool_end`),n=t.filter(e=>e.kind===`tool_end`&&e.isError),r=e.filter(e=>e.kind===`error`),i=[];return t.length>0&&i.push(`${t.length} tool call${t.length===1?``:`s`}`+(n.length>0?`, ${n.length} failed`:``)),r.length>0&&i.push(`${r.length} stream error${r.length===1?``:`s`}`),i.join(` · `)}function X(e){let t=[];for(let n of e){let e=t[t.length-1];if(n.toolName&&e?.type===`group`&&e.toolName===n.toolName){e.rows.push(n);continue}t.push(n.toolName?{type:`group`,toolName:n.toolName,rows:[n]}:{type:`single`,row:n})}return t}function se(e){return e.some(e=>e.kind===`tool_end`&&e.isError||e.kind===`error`)}function ce(e,t){return t===void 0?[]:e.filter(e=>e.turnSentAt===t&&(e.kind===`tool_end`||e.kind===`pseudo_tool_call`||e.kind===`progress`)).map((e,t)=>({key:`${e.at}-${t}`,text:G(e),toolName:B(e)}))}function le({renderTable:e,renderChart:t}={}){return{a:({href:e,children:t})=>!e||!c.t(e)?(0,f.jsx)(f.Fragment,{children:t}):(0,f.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:t}),table:({node:t,children:n})=>{let r=t&&F(t);if(r&&I(r.rows)&&e){let t=r.rows.map(e=>e.map(e=>e.href&&!c.t(e.href)?{text:e.text}:e));return(0,f.jsx)(f.Fragment,{children:e({headers:r.headers,rows:t})})}return(0,f.jsx)(`table`,{children:n})},pre:({children:e})=>{let n=(Array.isArray(e)?e[0]:e)?.props;if((n?.className?.split(` `)??[]).includes(`language-chartjs`)&&t){let e=n?.children,r=L(Array.isArray(e)?e.join(``):String(e??``));if(r)return(0,f.jsx)(f.Fragment,{children:t(r)})}return(0,f.jsx)(`pre`,{children:e})}}}function ue({className:e}){return(0,f.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,className:e,"aria-hidden":`true`,children:(0,f.jsx)(`path`,{d:`M12 20.3s-7.6-4.7-10-9.4C.4 7.7 1.7 4 5.2 3.1c2.2-.6 4.4.4 5.5 2.2 1.2-1.8 3.4-2.8 5.6-2.2 3.5.9 4.8 4.6 3.2 7.8-2.4 4.7-10 9.4-10 9.4z`})})}function de({className:e}){return(0,f.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:e,"aria-hidden":`true`,children:[(0,f.jsx)(`path`,{d:`M7 17 17 7`}),(0,f.jsx)(`path`,{d:`M9 7h8v8`})]})}function fe({className:e}){return(0,f.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:e,"aria-hidden":`true`,children:[(0,f.jsx)(`rect`,{x:`8`,y:`8`,width:`12`,height:`12`,rx:`2`}),(0,f.jsx)(`path`,{d:`M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2`})]})}function pe({className:e}){return(0,f.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:e,"aria-hidden":`true`,children:(0,f.jsx)(`path`,{d:`M5 12.5 9.5 17 19 7`})})}function me({className:e}){return(0,f.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:e,"aria-hidden":`true`,children:[(0,f.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,f.jsx)(`path`,{d:`M8.5 12.5 11 15l4.5-5.5`})]})}var he=1500;function ge({markdown:e,className:t}){let[n,r]=(0,l.useState)(!1),[i,a]=(0,l.useState)(!1),o=(0,l.useRef)(null);return(0,l.useEffect)(()=>()=>{o.current!==null&&clearTimeout(o.current)},[]),(0,f.jsx)(p.Provider,{delayDuration:200,children:(0,f.jsxs)(p.Root,{open:n||i,onOpenChange:a,children:[(0,f.jsx)(p.Trigger,{asChild:!0,children:(0,f.jsx)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(e)}catch{}r(!0),o.current!==null&&clearTimeout(o.current),o.current=setTimeout(()=>r(!1),he)},"aria-label":`copy response as markdown`,className:`bailey-copy-button${t?` ${t}`:``}`,children:n?(0,f.jsx)(pe,{className:`bailey-copy-icon`}):(0,f.jsx)(fe,{className:`bailey-copy-icon`})})}),(0,f.jsx)(p.Portal,{children:(0,f.jsxs)(p.Content,{side:`top`,className:`bailey-tooltip-content`,children:[n?`Copied!`:`Copy as markdown`,(0,f.jsx)(p.Arrow,{className:`bailey-tooltip-arrow`})]})})]})})}async function _e(e){try{await navigator.clipboard.writeText(e)}catch{}}function ve({text:e,label:t=`Copy`}){return(0,f.jsx)(`button`,{type:`button`,onClick:()=>_e(e),className:`bailey-trace-copy-button`,children:t})}function ye(e){if(e.failed||e.kind===`error`)return`bailey-trace-chip bailey-trace-chip-error`;switch(e.kind){case`tool_start`:return`bailey-trace-chip bailey-trace-chip-info`;case`tool_end`:return`bailey-trace-chip bailey-trace-chip-success`;case`progress`:return`bailey-trace-chip bailey-trace-chip-secondary`;default:return`bailey-trace-chip bailey-trace-chip-default`}}function Z({label:e,content:t,copyable:n}){return(0,f.jsxs)(`details`,{className:`bailey-trace-disclosure`,children:[(0,f.jsx)(`summary`,{className:`bailey-trace-disclosure-summary`,children:e}),n&&(0,f.jsx)(`div`,{className:`bailey-trace-disclosure-actions`,children:(0,f.jsx)(ve,{text:t})}),(0,f.jsx)(`pre`,{className:`bailey-trace-disclosure-content`,children:t})]})}function Q({row:e}){return(0,f.jsxs)(`div`,{className:`bailey-trace-row`,children:[(0,f.jsxs)(`div`,{className:`bailey-trace-row-header`,children:[(0,f.jsx)(`span`,{className:`bailey-trace-row-time`,children:e.time}),(0,f.jsx)(`span`,{className:`bailey-trace-row-gap`,title:`Time since the previous event`,children:q(e.gapMs)}),(0,f.jsx)(`span`,{className:ye(e),children:e.label}),(0,f.jsx)(`span`,{className:`bailey-trace-row-summary`,children:e.summary})]}),e.argsDetail&&(0,f.jsx)(Z,{label:`args`,content:e.argsDetail}),e.outputDetail&&(0,f.jsx)(Z,{label:`output`,content:e.outputDetail}),e.rawDetail&&(0,f.jsx)(Z,{label:`raw`,content:e.rawDetail})]})}function be(e,t){if(e.chunkCount===0)return`Streamed: no chunks received`;if(e.chunkCount===1||e.firstChunkAt===null)return`Streamed: 1 chunk (not incremental)`;let n=e.firstChunkAt-t,r=(e.lastChunkAt??e.firstChunkAt)-e.firstChunkAt;return`Streamed: ${e.chunkCount} chunks · first chunk after ${n}ms · spread over ${(r/1e3).toFixed(1)}s`}function xe({request:e}){let t=(0,l.useMemo)(()=>JSON.stringify({model:e.model,instructions:e.systemPrompt,input:e.messages,stream:e.stream,tools:e.tools,toolChoice:e.toolChoice},null,2),[e]);return(0,f.jsxs)(`div`,{className:`bailey-trace-request-details`,children:[(0,f.jsxs)(`span`,{className:`bailey-trace-request-meta`,children:[`Last request — `,e.model,` · `,new Date(e.sentAt).toLocaleTimeString(),e.requestId?` · ${e.requestId}`:``]}),(0,f.jsx)(`span`,{className:`bailey-trace-request-meta`,children:be(e.streamStats,e.sentAt)}),(0,f.jsx)(Z,{label:`System prompt (${e.systemPrompt.length.toLocaleString()} chars)`,content:e.systemPrompt,copyable:!0}),(0,f.jsx)(Z,{label:`Messages (${e.messages.length})`,content:JSON.stringify(e.messages,null,2),copyable:!0}),e.response&&(0,f.jsx)(Z,{label:`Response (${e.response.content.length.toLocaleString()} chars)`,content:e.response.content,copyable:!0}),(0,f.jsx)(Z,{label:`Full payload (JSON)`,content:t,copyable:!0})]})}function Se({events:e,lastRequest:t,onClear:n}){let r=(0,l.useMemo)(()=>J(e),[e]),i=(0,l.useMemo)(()=>X(r),[r]),a=(0,l.useMemo)(()=>JSON.stringify(e,null,2),[e]);return(0,f.jsxs)(`div`,{className:`bailey-trace-body`,children:[(0,f.jsxs)(`div`,{className:`bailey-trace-actions-row`,children:[e.length>0&&(0,f.jsx)(ve,{text:a,label:`Copy trace as JSON`}),(0,f.jsx)(`button`,{type:`button`,onClick:n,className:`bailey-trace-copy-button`,children:`Clear`})]}),t&&(0,f.jsx)(xe,{request:t}),(0,f.jsx)(`div`,{className:`bailey-trace-rows`,children:i.map((e,t)=>{if(e.type===`single`)return(0,f.jsx)(Q,{row:e.row},e.row.key);let n=e.rows.filter(e=>e.isToolStart).length;if(n<=1)return(0,f.jsx)(`div`,{className:`bailey-trace-rows`,children:e.rows.map(e=>(0,f.jsx)(Q,{row:e},e.key))},`group-${t}`);let r=e.rows.filter(e=>e.failed).length;return(0,f.jsxs)(`details`,{className:`bailey-trace-group`,children:[(0,f.jsxs)(`summary`,{className:`bailey-trace-group-summary`,children:[(0,f.jsx)(`strong`,{children:e.toolName}),` × `,n,r>0&&(0,f.jsxs)(`span`,{className:`bailey-trace-group-failed`,children:[` `,r,` failed`]})]}),(0,f.jsx)(`div`,{className:`bailey-trace-rows`,children:e.rows.map(e=>(0,f.jsx)(Q,{row:e},e.key))})]},`group-${t}`)})})]})}function $({events:e,lastRequest:t,onClear:n}){let[r,i]=(0,l.useState)(!1),a=(0,l.useMemo)(()=>se(e),[e]),o=(0,l.useMemo)(()=>Y(e),[e]);return e.length===0&&!t?null:(0,f.jsxs)(`div`,{className:`bailey-trace-panel`,children:[(0,f.jsxs)(`div`,{className:`bailey-trace-toggle-row`,children:[(0,f.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),"aria-expanded":r,className:a?`bailey-trace-toggle bailey-trace-toggle-error`:`bailey-trace-toggle`,children:[a&&!r?`⚠ `:``,r?`Hide details`:`Show details`,` (`,e.length,`)`]}),o&&(0,f.jsx)(`span`,{className:a?`bailey-trace-summary bailey-trace-summary-error`:`bailey-trace-summary`,children:o})]}),r&&(0,f.jsx)(Se,{events:e,lastRequest:t,onClear:n})]})}var Ce=`How can bailey AI help you today?`,we=`Reply to bailey AI`,Te=[d.default],Ee=(0,l.memo)(function({content:e,components:t}){return(0,f.jsx)(`div`,{className:`bailey-markdown-content`,children:(0,f.jsx)(u.default,{remarkPlugins:Te,components:t,children:e})})});function De(e,t,n){if(e!==`streaming`)return;let r=t.filter(e=>e.turnSentAt===n?.sentAt);if(r.length!==0)return G(r[r.length-1])}function Oe(e){let t=new Date(e),n=t.toDateString()===new Date().toDateString(),r=t.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`});return n?`Today ${r}`:`${t.toLocaleDateString()} ${r}`}function ke({chat:e,placeholder:t,replyPlaceholder:n=we,suggestions:r,privacyNote:i,resolveActivityIcon:a,className:o,height:s,width:c,hideDeveloperDetails:u=!1,renderMessageActions:d,renderTable:p,renderChart:m}){let{messages:h,traceEvents:g,lastRequest:_,status:v,error:y,send:b,stop:x,retryLast:S,clearTrace:C,clearError:w,newChat:T}=e,[E,D]=(0,l.useState)(``),O=(0,l.useRef)(null),k=(0,l.useMemo)(()=>le({renderTable:p,renderChart:m}),[p,m]),A=(0,l.useMemo)(()=>De(v,g,_),[v,g,_]),j=h.length===0,M=t??(j?Ce:n);return(0,l.useEffect)(()=>{O.current?.scrollIntoView({behavior:`smooth`,block:`nearest`})},[h]),(0,f.jsx)(`div`,{className:`bailey-chat-panel${o?` ${o}`:``}`,style:s!==void 0||c!==void 0?{height:s,width:c}:void 0,children:(0,f.jsxs)(`div`,{className:`bailey-chat-panel-inner`,children:[(0,f.jsx)(`div`,{className:`bailey-toolbar-row`,children:(0,f.jsx)(`button`,{type:`button`,onClick:T,disabled:h.length===0,"aria-label":`new chat`,className:`bailey-new-chat-button`,children:`New chat`})}),(0,f.jsxs)(`div`,{className:`bailey-chat-transcript`,children:[j&&(r&&r.length>0?(0,f.jsxs)(`div`,{className:`bailey-suggestions`,children:[(0,f.jsx)(`div`,{className:`bailey-suggestions-title`,children:`Suggested for you`}),r.map((e,t)=>(0,f.jsxs)(`button`,{type:`button`,onClick:()=>b(e.value??e.label),className:`bailey-suggestion-card`,children:[(0,f.jsx)(`span`,{children:e.label}),(0,f.jsx)(de,{className:`bailey-suggestion-icon`})]},`${e.label}-${t}`))]}):(0,f.jsx)(`div`,{className:`bailey-empty-state`,children:`Ask Bailey a question to get started.`})),h.map((e,t)=>{let n=e.role===`assistant`&&t===h.length-1,r=v===`streaming`&&n&&e.content===``,i=e.role===`assistant`&&!r?ce(g,e.createdAt):[],o=i[i.length-1];return(0,f.jsx)(`div`,{className:e.role===`user`?`bailey-message-row bailey-message-row-user`:`bailey-message-row`,children:e.role===`user`?(0,f.jsxs)(`div`,{className:`bailey-user-message`,children:[(0,f.jsxs)(`div`,{className:`bailey-message-meta`,children:[(0,f.jsx)(`span`,{className:`bailey-message-meta-name`,children:`You`}),e.createdAt!==void 0&&(0,f.jsx)(`span`,{children:Oe(e.createdAt)})]}),(0,f.jsx)(`div`,{className:`bailey-user-bubble`,children:e.content})]}):r?(0,f.jsx)(`div`,{className:`bailey-thinking-hint`,children:A??`Thinking…`}):(0,f.jsxs)(`div`,{className:`bailey-assistant-message`,children:[o&&(0,f.jsxs)(`div`,{className:`bailey-activity-line`,children:[(0,f.jsx)(`span`,{className:`bailey-activity-icon`,children:a?.(o.toolName)??(0,f.jsx)(me,{})}),(0,f.jsx)(`span`,{children:o.text})]}),(0,f.jsx)(Ee,{content:e.content,components:k}),e.streaming&&A&&(0,f.jsx)(`div`,{className:`bailey-streaming-hint`,children:A}),!e.streaming&&(0,f.jsxs)(`div`,{className:`bailey-message-actions`,children:[(0,f.jsx)(ge,{markdown:e.content}),d?.(e)]})]})},e.id)}),(0,f.jsx)(`div`,{ref:O})]}),j&&i&&(0,f.jsxs)(`div`,{className:`bailey-privacy-note`,children:[i.text,` `,(0,f.jsx)(`a`,{href:i.linkHref,target:`_blank`,rel:`noreferrer`,children:i.linkLabel})]}),y&&(0,f.jsxs)(`div`,{className:`bailey-error-banner`,role:`alert`,children:[(0,f.jsx)(`span`,{children:y}),(0,f.jsxs)(`div`,{className:`bailey-error-actions`,children:[(0,f.jsx)(`button`,{type:`button`,onClick:S,className:`bailey-retry-button`,children:`Retry`}),(0,f.jsx)(`button`,{type:`button`,onClick:w,"aria-label":`dismiss error`,className:`bailey-dismiss-button`,children:`✕`})]})]}),!u&&(0,f.jsx)($,{events:g,lastRequest:_,onClear:C}),(0,f.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),!(!E.trim()||v===`streaming`)&&(b(E),D(``))},className:`bailey-input-row`,children:[(0,f.jsx)(`input`,{type:`text`,placeholder:M,"aria-label":M,value:E,onChange:e=>D(e.target.value),disabled:v===`streaming`,className:`bailey-input`}),v===`streaming`?(0,f.jsx)(`button`,{type:`button`,onClick:x,"aria-label":`stop`,className:`bailey-stop-button`,children:`Stop`}):(0,f.jsx)(`button`,{type:`submit`,"aria-label":`send`,disabled:!E.trim(),className:`bailey-send-button`,children:(0,f.jsx)(ue,{className:`bailey-send-icon`})})]})]})})}var Ae=`0.3.1-pre.2`;exports.ActivityIcon=me,exports.ArrowUpRightIcon=de,exports.BAILEYAI_CHAT_UI_VERSION=Ae,exports.BAILEY_CHART_PROMPT_FRAGMENT=ee,exports.BAILEY_TABLE_GRID_ROW_THRESHOLD=k,exports.BaileyChatPanel=ke,exports.BaileyTracePanel=$,exports.CopyMarkdownButton=ge,exports.HeartIcon=ue,exports.TRACE_KIND_LABEL=R,exports.createBaileyMarkdownComponents=le,exports.extractPseudoToolCalls=v,exports.extractTableData=F,exports.formatTraceGap=q,exports.formatTraceTime=K,exports.hasTraceFailure=se,exports.isSafeMarkdownUrl=c.t,exports.joinInstructions=T,exports.parseBaileyChartSpec=L,exports.parseSseFrames=b,exports.resolveToolCall=O,exports.shouldUseGrid=I,exports.toActivityLines=ce,exports.toTraceRows=J,exports.toTraceSegments=X,exports.traceEventArgsDetail=H,exports.traceEventHint=G,exports.traceEventOutputDetail=U,exports.traceEventRawDetail=W,exports.traceEventSummary=V,exports.traceEventToolName=B,exports.traceSummaryLine=Y,exports.useBaileyChat=w;
@@ -1,3 +1,3 @@
1
1
  /*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
2
- @layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-font-weight:initial;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-leading:initial;--tw-space-y-reverse:0}}}@layer theme{:root,:host{--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-100:oklch(93.6% .032 17.717);--color-green-100:oklch(96.2% .044 156.743);--color-green-700:oklch(52.7% .154 150.069);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-700:oklch(48.8% .243 264.376);--color-purple-100:oklch(94.6% .033 307.174);--color-purple-700:oklch(49.6% .265 301.924);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-700:oklch(37.3% .034 259.733);--color-black:#000;--color-white:#fff;--spacing:.25rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--font-weight-medium:500;--font-weight-semibold:600;--leading-relaxed:1.625;--radius-md:.375rem;--radius-2xl:1rem;--color-bailey-accent:#4f46e5;--color-bailey-bubble-bg:#e8e8e8;--color-bailey-error:#d32f2f;--color-bailey-border:#e5e5e5;--color-bailey-surface:#fff;--color-bailey-surface-muted:#f9fafb;--color-bailey-text:#000;--color-bailey-text-secondary:#6b6b6b;--color-bailey-tooltip-bg:#000;--color-bailey-tooltip-text:#fff}}@layer utilities{.collapse{visibility:collapse}.invisible{visibility:hidden}.visible{visibility:visible}.fixed{position:fixed}.relative{position:relative}.static{position:static}.container{width:100%}@media (width>=40rem){.container{max-width:40rem}}@media (width>=48rem){.container{max-width:48rem}}@media (width>=64rem){.container{max-width:64rem}}@media (width>=80rem){.container{max-width:80rem}}@media (width>=96rem){.container{max-width:96rem}}.my-2{margin-block:calc(var(--spacing) * 2)}.my-3{margin-block:calc(var(--spacing) * 3)}.mt-1{margin-top:var(--spacing)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mb-1{margin-bottom:var(--spacing)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.ml-1{margin-left:var(--spacing)}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.inline{display:inline}.table{display:table}.table-cell{display:table-cell}.h-\[600px\]{height:600px}.h-full{height:100%}.max-h-48{max-height:calc(var(--spacing) * 48)}.max-h-80{max-height:calc(var(--spacing) * 80)}.min-h-0{min-height:0}.w-full{width:100%}.max-w-\[75\%\]{max-width:75%}.flex-1{flex:1}.border-collapse{border-collapse:collapse}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.cursor-pointer{cursor:pointer}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-start{justify-content:flex-start}.gap-1{gap:var(--spacing)}.gap-2{gap:calc(var(--spacing) * 2)}.overflow-auto{overflow:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-md{border-radius:var(--radius-md)}.border{border-style:var(--tw-border-style);border-width:1px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-bailey-border{border-color:var(--color-bailey-border)}.border-bailey-error{border-color:var(--color-bailey-error)}.border-gray-200{border-color:var(--color-gray-200)}.bg-bailey-accent{background-color:var(--color-bailey-accent)}.bg-bailey-bubble-bg{background-color:var(--color-bailey-bubble-bg)}.bg-bailey-surface-muted{background-color:var(--color-bailey-surface-muted)}.bg-bailey-tooltip-bg{background-color:var(--color-bailey-tooltip-bg)}.bg-black{background-color:var(--color-black)}.bg-blue-100{background-color:var(--color-blue-100)}.bg-gray-50{background-color:var(--color-gray-50)}.bg-gray-200{background-color:var(--color-gray-200)}.bg-green-100{background-color:var(--color-green-100)}.bg-purple-100{background-color:var(--color-purple-100)}.bg-red-100{background-color:var(--color-red-100)}.fill-black{fill:var(--color-black)}.p-0{padding:0}.p-1{padding:var(--spacing)}.p-2{padding:calc(var(--spacing) * 2)}.px-1{padding-inline:var(--spacing)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.py-0{padding-block:0}.py-1{padding-block:var(--spacing)}.py-2{padding-block:calc(var(--spacing) * 2)}.pl-3{padding-left:calc(var(--spacing) * 3)}.pl-5{padding-left:calc(var(--spacing) * 5)}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[0\.7rem\]{font-size:.7rem}.text-\[0\.65rem\]{font-size:.65rem}.text-\[0\.85em\]{font-size:.85em}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.break-all{word-break:break-all}.whitespace-pre-wrap{white-space:pre-wrap}.text-bailey-accent{color:var(--color-bailey-accent)}.text-bailey-error{color:var(--color-bailey-error)}.text-bailey-text-secondary{color:var(--color-bailey-text-secondary)}.text-bailey-tooltip-text{color:var(--color-bailey-tooltip-text)}.text-black{color:var(--color-black)}.text-blue-700{color:var(--color-blue-700)}.text-gray-400{color:var(--color-gray-400)}.text-green-700{color:var(--color-green-700)}.text-white{color:var(--color-white)}.italic{font-style:italic}.underline{text-decoration-line:underline}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}@media (hover:hover){.hover\:text-bailey-text:hover{color:var(--color-bailey-text)}.hover\:text-black:hover{color:var(--color-black)}}}.bailey-chat-panel{flex-direction:column;height:100%;display:flex}.bailey-toolbar-row{justify-content:flex-end;display:flex}.bailey-new-chat-button{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary)}@media (hover:hover){.bailey-new-chat-button:hover{color:var(--color-bailey-text)}}.bailey-new-chat-button:disabled{opacity:.5}.bailey-chat-transcript{min-height:0;padding:calc(var(--spacing) * 2);flex:1;overflow-y:auto}.bailey-message-row{margin-bottom:calc(var(--spacing) * 3);justify-content:flex-start;display:flex}.bailey-message-row-user{justify-content:flex-end}.bailey-user-bubble{border-radius:var(--radius-2xl);background-color:var(--color-bailey-bubble-bg);max-width:75%;padding-inline:calc(var(--spacing) * 4);padding-block:calc(var(--spacing) * 2);white-space:pre-wrap;color:var(--color-bailey-text)}.bailey-assistant-message{width:100%;padding-inline:var(--spacing)}.bailey-thinking-hint{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary);font-style:italic}.bailey-streaming-hint{margin-top:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);font-style:italic;display:block}.bailey-message-actions{margin-top:var(--spacing);align-items:center;gap:var(--spacing);display:flex}.bailey-empty-state{height:100%;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary);justify-content:center;align-items:center;display:flex}.bailey-error-banner{margin-bottom:calc(var(--spacing) * 2);justify-content:space-between;align-items:center;gap:calc(var(--spacing) * 2);border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-error);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);color:var(--color-bailey-error);display:flex}.bailey-retry-button{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium);text-decoration-line:underline}.bailey-error-actions{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.bailey-dismiss-button{color:var(--color-bailey-error)}@media (hover:hover){.bailey-dismiss-button:hover{opacity:.7}}.bailey-input-row{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.bailey-input{border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);flex:1}.bailey-input:disabled{opacity:.5}.bailey-send-button,.bailey-stop-button{border-radius:var(--radius-md);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}:is(.bailey-send-button,.bailey-stop-button):disabled{opacity:.5}.bailey-send-button{background-color:var(--color-bailey-accent);color:var(--color-white)}.bailey-stop-button{border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-error);color:var(--color-bailey-error)}.bailey-copy-button{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary)}@media (hover:hover){.bailey-copy-button:hover{color:var(--color-bailey-text)}}.bailey-tooltip-content{background-color:var(--color-bailey-tooltip-bg);padding-inline:calc(var(--spacing) * 2);padding-block:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-tooltip-text);border-radius:.25rem}.bailey-tooltip-arrow{fill:var(--color-bailey-tooltip-bg)}.bailey-markdown-content table{border-collapse:collapse;width:100%;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.bailey-markdown-content th{background-color:var(--color-bailey-surface-muted);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);text-align:left;--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content td{border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);vertical-align:top}.bailey-markdown-content tr:nth-child(2n){background-color:var(--color-bailey-surface-muted)}.bailey-markdown-content{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.bailey-markdown-content>:first-child{margin-top:0}.bailey-markdown-content>:last-child{margin-bottom:0}.bailey-markdown-content p{margin-block:calc(var(--spacing) * 2)}.bailey-markdown-content h1{margin-top:calc(var(--spacing) * 4);margin-bottom:calc(var(--spacing) * 2);font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content h2{margin-top:calc(var(--spacing) * 4);margin-bottom:calc(var(--spacing) * 2);font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content h3{margin-top:calc(var(--spacing) * 3);margin-bottom:calc(var(--spacing) * 1.5);font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content h4,.bailey-markdown-content h5,.bailey-markdown-content h6{margin-top:calc(var(--spacing) * 3);margin-bottom:calc(var(--spacing) * 1.5);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content ul{margin-block:calc(var(--spacing) * 2);list-style-type:disc}:where(.bailey-markdown-content ul>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}.bailey-markdown-content ul{padding-left:calc(var(--spacing) * 5)}.bailey-markdown-content ol{margin-block:calc(var(--spacing) * 2);list-style-type:decimal}:where(.bailey-markdown-content ol>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}.bailey-markdown-content ol{padding-left:calc(var(--spacing) * 5)}.bailey-markdown-content a{color:var(--color-bailey-accent);text-underline-offset:2px;text-decoration-line:underline}.bailey-markdown-content code{background-color:var(--color-bailey-surface-muted);padding-inline:var(--spacing);padding-block:calc(var(--spacing) * .5);font-family:var(--font-mono);border-radius:.25rem;font-size:.85em}.bailey-markdown-content pre{margin-block:calc(var(--spacing) * 2);border-radius:var(--radius-md);background-color:var(--color-bailey-surface-muted);padding:calc(var(--spacing) * 2);overflow-x:auto}.bailey-markdown-content pre code{background-color:#0000;padding:0}.bailey-markdown-content blockquote{margin-block:calc(var(--spacing) * 2);border-left-style:var(--tw-border-style);border-left-width:2px;border-color:var(--color-bailey-border);padding-left:calc(var(--spacing) * 3);color:var(--color-bailey-text-secondary);font-style:italic}.bailey-markdown-content hr{margin-block:calc(var(--spacing) * 3);border-color:var(--color-bailey-border)}.bailey-trace-panel{margin-bottom:calc(var(--spacing) * 2)}.bailey-trace-toggle-row{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.bailey-trace-toggle{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary)}.bailey-trace-toggle-error{color:var(--color-bailey-error)}.bailey-trace-summary{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary)}.bailey-trace-summary-error{color:var(--color-bailey-error)}.bailey-trace-body{margin-top:var(--spacing);max-height:calc(var(--spacing) * 80);overflow-y:auto}.bailey-trace-actions-row{justify-content:flex-end;gap:calc(var(--spacing) * 3);display:flex}.bailey-trace-copy-button{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary)}@media (hover:hover){.bailey-trace-copy-button:hover{color:var(--color-bailey-text)}}.bailey-trace-request-details{margin-bottom:var(--spacing);border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);padding:calc(var(--spacing) * 2)}.bailey-trace-request-meta{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);display:block}.bailey-trace-rows{gap:var(--spacing);flex-direction:column;display:flex}.bailey-trace-row{border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 2);padding-block:var(--spacing);font-family:var(--font-mono);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.bailey-trace-row-header{align-items:center;gap:calc(var(--spacing) * 2);flex-wrap:wrap;display:flex}.bailey-trace-row-time{color:var(--color-bailey-text-secondary)}.bailey-trace-row-gap{color:var(--color-gray-400)}.bailey-trace-row-summary{word-break:break-all}.bailey-trace-chip{padding-inline:calc(var(--spacing) * 1.5);padding-block:calc(var(--spacing) * .5);--tw-font-weight:var(--font-weight-semibold);font-size:.65rem;font-weight:var(--font-weight-semibold);border-radius:.25rem}.bailey-trace-chip-default{background-color:var(--color-gray-200);color:var(--color-gray-700)}.bailey-trace-chip-info{background-color:var(--color-blue-100);color:var(--color-blue-700)}.bailey-trace-chip-success{background-color:var(--color-green-100);color:var(--color-green-700)}.bailey-trace-chip-secondary{background-color:var(--color-purple-100);color:var(--color-purple-700)}.bailey-trace-chip-error{background-color:var(--color-red-100);color:var(--color-bailey-error)}.bailey-trace-disclosure{margin-top:var(--spacing)}.bailey-trace-disclosure-summary{cursor:pointer;color:var(--color-bailey-text-secondary);font-size:.7rem}.bailey-trace-disclosure-actions{margin-top:var(--spacing);justify-content:flex-end;display:flex}.bailey-trace-disclosure-content{margin-top:var(--spacing);max-height:calc(var(--spacing) * 48);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface-muted);padding:calc(var(--spacing) * 1.5);word-break:break-all;white-space:pre-wrap;border-radius:.25rem;font-size:.7rem;overflow:auto}.bailey-trace-group{border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 2);padding-block:var(--spacing)}.bailey-trace-group-summary{cursor:pointer;font-family:var(--font-mono);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.bailey-trace-group-failed{margin-left:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-error)}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-leading{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}
2
+ @layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-font-weight:initial;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-leading:initial;--tw-space-y-reverse:0}}}@layer theme{:root,:host{--font-sans:"Inter", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-100:oklch(93.6% .032 17.717);--color-green-100:oklch(96.2% .044 156.743);--color-green-700:oklch(52.7% .154 150.069);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-700:oklch(48.8% .243 264.376);--color-purple-100:oklch(94.6% .033 307.174);--color-purple-700:oklch(49.6% .265 301.924);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-700:oklch(37.3% .034 259.733);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-3xl:48rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--font-weight-medium:500;--font-weight-semibold:600;--leading-relaxed:1.625;--radius-md:.375rem;--radius-2xl:1rem;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--color-bailey-accent:#4f46e5;--color-bailey-bubble-bg:#fff;--color-bailey-error:#d32f2f;--color-bailey-border:#e5e5e5;--color-bailey-surface:#fff;--color-bailey-surface-muted:#f9fafb;--color-bailey-text:#000;--color-bailey-text-secondary:#6b6b6b;--color-bailey-tooltip-bg:#000;--color-bailey-tooltip-text:#fff;--color-bailey-page-bg:#eceef4;--color-bailey-heart:#16a34a}}@layer utilities{.collapse{visibility:collapse}.invisible{visibility:hidden}.visible{visibility:visible}.fixed{position:fixed}.relative{position:relative}.static{position:static}.container{width:100%}@media (width>=40rem){.container{max-width:40rem}}@media (width>=48rem){.container{max-width:48rem}}@media (width>=64rem){.container{max-width:64rem}}@media (width>=80rem){.container{max-width:80rem}}@media (width>=96rem){.container{max-width:96rem}}.my-2{margin-block:calc(var(--spacing) * 2)}.my-3{margin-block:calc(var(--spacing) * 3)}.mt-1{margin-top:var(--spacing)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mb-1{margin-bottom:var(--spacing)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.ml-1{margin-left:var(--spacing)}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.inline{display:inline}.table{display:table}.table-cell{display:table-cell}.h-\[600px\]{height:600px}.h-full{height:100%}.max-h-48{max-height:calc(var(--spacing) * 48)}.max-h-80{max-height:calc(var(--spacing) * 80)}.min-h-0{min-height:0}.w-full{width:100%}.max-w-\[75\%\]{max-width:75%}.flex-1{flex:1}.border-collapse{border-collapse:collapse}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.cursor-pointer{cursor:pointer}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-start{justify-content:flex-start}.gap-1{gap:var(--spacing)}.gap-2{gap:calc(var(--spacing) * 2)}.overflow-auto{overflow:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-md{border-radius:var(--radius-md)}.border{border-style:var(--tw-border-style);border-width:1px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-bailey-border{border-color:var(--color-bailey-border)}.border-bailey-error{border-color:var(--color-bailey-error)}.border-gray-200{border-color:var(--color-gray-200)}.bg-bailey-accent{background-color:var(--color-bailey-accent)}.bg-bailey-bubble-bg{background-color:var(--color-bailey-bubble-bg)}.bg-bailey-surface-muted{background-color:var(--color-bailey-surface-muted)}.bg-bailey-tooltip-bg{background-color:var(--color-bailey-tooltip-bg)}.bg-black{background-color:var(--color-black)}.bg-blue-100{background-color:var(--color-blue-100)}.bg-gray-50{background-color:var(--color-gray-50)}.bg-gray-200{background-color:var(--color-gray-200)}.bg-green-100{background-color:var(--color-green-100)}.bg-purple-100{background-color:var(--color-purple-100)}.bg-red-100{background-color:var(--color-red-100)}.fill-black{fill:var(--color-black)}.p-0{padding:0}.p-1{padding:var(--spacing)}.p-2{padding:calc(var(--spacing) * 2)}.px-1{padding-inline:var(--spacing)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.py-0{padding-block:0}.py-1{padding-block:var(--spacing)}.py-2{padding-block:calc(var(--spacing) * 2)}.pl-3{padding-left:calc(var(--spacing) * 3)}.pl-5{padding-left:calc(var(--spacing) * 5)}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[0\.7rem\]{font-size:.7rem}.text-\[0\.65rem\]{font-size:.65rem}.text-\[0\.85em\]{font-size:.85em}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.break-all{word-break:break-all}.whitespace-pre-wrap{white-space:pre-wrap}.text-bailey-accent{color:var(--color-bailey-accent)}.text-bailey-error{color:var(--color-bailey-error)}.text-bailey-text-secondary{color:var(--color-bailey-text-secondary)}.text-bailey-tooltip-text{color:var(--color-bailey-tooltip-text)}.text-black{color:var(--color-black)}.text-blue-700{color:var(--color-blue-700)}.text-gray-400{color:var(--color-gray-400)}.text-green-700{color:var(--color-green-700)}.text-white{color:var(--color-white)}.italic{font-style:italic}.underline{text-decoration-line:underline}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}@media (hover:hover){.hover\:text-bailey-text:hover{color:var(--color-bailey-text)}.hover\:text-black:hover{color:var(--color-black)}}}.bailey-chat-panel{box-sizing:border-box;background-color:var(--color-bailey-page-bg);height:100%;padding:calc(var(--spacing) * 3);font-family:var(--font-sans)}.bailey-chat-panel-inner{width:100%;height:100%;max-width:var(--container-3xl);gap:calc(var(--spacing) * 2);flex-direction:column;margin-inline:auto;display:flex;overflow-y:auto}.bailey-toolbar-row{justify-content:flex-end;display:flex}.bailey-new-chat-button{cursor:pointer;appearance:none;--tw-border-style:none;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-accent);background-color:#0000;border-style:none}@media (hover:hover){.bailey-new-chat-button:hover{text-decoration-line:underline}}.bailey-new-chat-button:disabled{cursor:default;opacity:.5;text-decoration-line:none}.bailey-chat-transcript{min-height:0;padding:calc(var(--spacing) * 2);padding-bottom:calc(var(--spacing) * 4);flex:1;overflow-y:auto}.bailey-message-row{margin-bottom:calc(var(--spacing) * 3);justify-content:flex-start;display:flex}.bailey-message-row-user{justify-content:flex-end}.bailey-user-message{flex-direction:column;align-items:flex-end;max-width:75%;display:flex}.bailey-message-meta{margin-bottom:var(--spacing);align-items:center;gap:calc(var(--spacing) * 2);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);display:flex}.bailey-message-meta-name{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium);color:var(--color-bailey-text)}.bailey-user-bubble{border-radius:var(--radius-2xl);background-color:var(--color-bailey-bubble-bg);max-width:100%;padding-inline:calc(var(--spacing) * 4);padding-block:calc(var(--spacing) * 2);white-space:pre-wrap;color:var(--color-bailey-text);--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.bailey-assistant-message{width:100%;padding-inline:var(--spacing)}.bailey-thinking-hint{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary);font-style:italic}.bailey-streaming-hint{margin-top:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);font-style:italic;display:block}.bailey-message-actions{margin-top:var(--spacing);align-items:center;gap:var(--spacing);display:flex}.bailey-empty-state{height:100%;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary);justify-content:center;align-items:center;display:flex}.bailey-suggestions{gap:calc(var(--spacing) * 3);padding:calc(var(--spacing) * 2);flex-direction:column;display:flex}.bailey-suggestions-title{padding-inline:var(--spacing);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);color:var(--color-bailey-text)}.bailey-suggestion-card{cursor:pointer;appearance:none;justify-content:space-between;align-items:center;gap:calc(var(--spacing) * 2);border-radius:var(--radius-2xl);--tw-border-style:none;background-color:var(--color-bailey-surface);padding-inline:calc(var(--spacing) * 4);padding-block:calc(var(--spacing) * 3);text-align:left;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text);--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);transition-property:box-shadow;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration));border-style:none;display:flex}@media (hover:hover){.bailey-suggestion-card:hover{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a), 0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}}.bailey-suggestion-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4);color:var(--color-bailey-text-secondary);flex-shrink:0}.bailey-privacy-note{padding-inline:calc(var(--spacing) * 4);text-align:center;font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary)}.bailey-privacy-note a{color:var(--color-bailey-text-secondary);text-decoration-line:underline}.bailey-activity-line{margin-bottom:calc(var(--spacing) * 2);align-items:center;gap:calc(var(--spacing) * 2);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary);display:flex}.bailey-activity-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4);color:var(--color-bailey-accent);flex-shrink:0}.bailey-error-banner{margin-bottom:calc(var(--spacing) * 2);justify-content:space-between;align-items:center;gap:calc(var(--spacing) * 2);border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-error);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);color:var(--color-bailey-error);display:flex}.bailey-retry-button{cursor:pointer;appearance:none;--tw-border-style:none;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium);background-color:#0000;border-style:none;text-decoration-line:underline}.bailey-error-actions{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.bailey-dismiss-button{cursor:pointer;appearance:none;--tw-border-style:none;color:var(--color-bailey-error);background-color:#0000;border-style:none}@media (hover:hover){.bailey-dismiss-button:hover{opacity:.7}}.bailey-input-row{align-items:center;gap:calc(var(--spacing) * 2);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);padding-inline:calc(var(--spacing) * 2);padding-block:calc(var(--spacing) * 1.5);--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);border-radius:2147483647px;display:flex}.bailey-input-row:focus-within{border-color:var(--color-bailey-accent)}.bailey-input{--tw-border-style:none;min-width:0;padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);--tw-outline-style:none;background-color:#0000;border-style:none;outline-style:none;flex:1}.bailey-input:disabled{opacity:.5}.bailey-send-button,.bailey-stop-button{cursor:pointer;appearance:none;background-color:#0000;border-radius:2147483647px;flex-shrink:0;justify-content:center;align-items:center;display:flex}:is(.bailey-send-button,.bailey-stop-button):disabled{cursor:default;opacity:.4}.bailey-send-button{height:calc(var(--spacing) * 9);width:calc(var(--spacing) * 9);--tw-border-style:none;color:var(--color-bailey-heart);border-style:none}@media (hover:hover){.bailey-send-button:hover{background-color:#16a34a1a}@supports (color:color-mix(in lab, red, red)){.bailey-send-button:hover{background-color:color-mix(in oklab, var(--color-bailey-heart) 10%, transparent)}}}.bailey-send-icon{height:calc(var(--spacing) * 5);width:calc(var(--spacing) * 5)}.bailey-stop-button{border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-error);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium);color:var(--color-bailey-error)}.bailey-copy-button{height:calc(var(--spacing) * 7);width:calc(var(--spacing) * 7);cursor:pointer;appearance:none;--tw-border-style:none;color:var(--color-bailey-text-secondary);background-color:#0000;border-style:none;border-radius:2147483647px;justify-content:center;align-items:center;display:flex}@media (hover:hover){.bailey-copy-button:hover{background-color:#0000000d}@supports (color:color-mix(in lab, red, red)){.bailey-copy-button:hover{background-color:color-mix(in oklab, var(--color-black) 5%, transparent)}}.bailey-copy-button:hover{color:var(--color-bailey-text)}}.bailey-copy-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4)}.bailey-tooltip-content{background-color:var(--color-bailey-tooltip-bg);padding-inline:calc(var(--spacing) * 2);padding-block:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-tooltip-text);border-radius:.25rem}.bailey-tooltip-arrow{fill:var(--color-bailey-tooltip-bg)}.bailey-markdown-content table{border-collapse:collapse;width:100%;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.bailey-markdown-content th{background-color:var(--color-bailey-surface-muted);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);text-align:left;--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content td{border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);vertical-align:top}.bailey-markdown-content tr:nth-child(2n){background-color:var(--color-bailey-surface-muted)}.bailey-markdown-content{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.bailey-markdown-content>:first-child{margin-top:0}.bailey-markdown-content>:last-child{margin-bottom:0}.bailey-markdown-content p{margin-block:calc(var(--spacing) * 2)}.bailey-markdown-content h1{margin-top:calc(var(--spacing) * 4);margin-bottom:calc(var(--spacing) * 2);font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content h2{margin-top:calc(var(--spacing) * 4);margin-bottom:calc(var(--spacing) * 2);font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content h3{margin-top:calc(var(--spacing) * 3);margin-bottom:calc(var(--spacing) * 1.5);font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content h4,.bailey-markdown-content h5,.bailey-markdown-content h6{margin-top:calc(var(--spacing) * 3);margin-bottom:calc(var(--spacing) * 1.5);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content ul{margin-block:calc(var(--spacing) * 2);list-style-type:disc}:where(.bailey-markdown-content ul>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}.bailey-markdown-content ul{padding-left:calc(var(--spacing) * 5)}.bailey-markdown-content ol{margin-block:calc(var(--spacing) * 2);list-style-type:decimal}:where(.bailey-markdown-content ol>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}.bailey-markdown-content ol{padding-left:calc(var(--spacing) * 5)}.bailey-markdown-content a{color:var(--color-bailey-accent);text-underline-offset:2px;text-decoration-line:underline}.bailey-markdown-content code{background-color:var(--color-bailey-surface-muted);padding-inline:var(--spacing);padding-block:calc(var(--spacing) * .5);font-family:var(--font-mono);border-radius:.25rem;font-size:.85em}.bailey-markdown-content pre{margin-block:calc(var(--spacing) * 2);border-radius:var(--radius-md);background-color:var(--color-bailey-surface-muted);padding:calc(var(--spacing) * 2);overflow-x:auto}.bailey-markdown-content pre code{background-color:#0000;padding:0}.bailey-markdown-content blockquote{margin-block:calc(var(--spacing) * 2);border-left-style:var(--tw-border-style);border-left-width:2px;border-color:var(--color-bailey-border);padding-left:calc(var(--spacing) * 3);color:var(--color-bailey-text-secondary);font-style:italic}.bailey-markdown-content hr{margin-block:calc(var(--spacing) * 3);border-color:var(--color-bailey-border)}.bailey-trace-panel{margin-bottom:calc(var(--spacing) * 2)}.bailey-trace-toggle-row{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.bailey-trace-toggle{cursor:pointer;appearance:none;--tw-border-style:none;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-accent);background-color:#0000;border-style:none}@media (hover:hover){.bailey-trace-toggle:hover{text-decoration-line:underline}}.bailey-trace-toggle-error{color:var(--color-bailey-error)}.bailey-trace-summary{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary)}.bailey-trace-summary-error{color:var(--color-bailey-error)}.bailey-trace-body{margin-top:var(--spacing);max-height:calc(var(--spacing) * 80);overflow-y:auto}.bailey-trace-actions-row{justify-content:flex-end;gap:calc(var(--spacing) * 3);display:flex}.bailey-trace-copy-button{cursor:pointer;appearance:none;--tw-border-style:none;font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-accent);background-color:#0000;border-style:none;text-decoration-line:underline}@media (hover:hover){.bailey-trace-copy-button:hover{text-decoration-line:none}}.bailey-trace-request-details{margin-bottom:var(--spacing);border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);padding:calc(var(--spacing) * 2)}.bailey-trace-request-meta{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);display:block}.bailey-trace-rows{gap:var(--spacing);flex-direction:column;display:flex}.bailey-trace-row{border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 2);padding-block:var(--spacing);font-family:var(--font-mono);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.bailey-trace-row-header{align-items:center;gap:calc(var(--spacing) * 2);flex-wrap:wrap;display:flex}.bailey-trace-row-time{color:var(--color-bailey-text-secondary)}.bailey-trace-row-gap{color:var(--color-gray-400)}.bailey-trace-row-summary{word-break:break-all}.bailey-trace-chip{padding-inline:calc(var(--spacing) * 1.5);padding-block:calc(var(--spacing) * .5);--tw-font-weight:var(--font-weight-semibold);font-size:.65rem;font-weight:var(--font-weight-semibold);border-radius:.25rem}.bailey-trace-chip-default{background-color:var(--color-gray-200);color:var(--color-gray-700)}.bailey-trace-chip-info{background-color:var(--color-blue-100);color:var(--color-blue-700)}.bailey-trace-chip-success{background-color:var(--color-green-100);color:var(--color-green-700)}.bailey-trace-chip-secondary{background-color:var(--color-purple-100);color:var(--color-purple-700)}.bailey-trace-chip-error{background-color:var(--color-red-100);color:var(--color-bailey-error)}.bailey-trace-disclosure{margin-top:var(--spacing)}.bailey-trace-disclosure-summary{cursor:pointer;color:var(--color-bailey-text-secondary);font-size:.7rem}.bailey-trace-disclosure-actions{margin-top:var(--spacing);justify-content:flex-end;display:flex}.bailey-trace-disclosure-content{margin-top:var(--spacing);max-height:calc(var(--spacing) * 48);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface-muted);padding:calc(var(--spacing) * 1.5);word-break:break-all;white-space:pre-wrap;border-radius:.25rem;font-size:.7rem;overflow:auto}.bailey-trace-group{border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 2);padding-block:var(--spacing)}.bailey-trace-group-summary{cursor:pointer;font-family:var(--font-mono);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.bailey-trace-group-failed{margin-left:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-error)}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-leading{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}
3
3
  /*$vite$:1*/
@@ -170,15 +170,16 @@ var b = 200, x = 15e4, S = (e, t, n) => {
170
170
  }), !0);
171
171
  }, []), I = n(async (n) => {
172
172
  C("streaming"), T(null);
173
- let r = crypto.randomUUID();
173
+ let r = Date.now();
174
+ O.current = r;
175
+ let a = crypto.randomUUID();
174
176
  p((e) => [...e, {
175
- id: r,
177
+ id: a,
176
178
  role: "assistant",
177
179
  content: "",
178
- streaming: !0
180
+ streaming: !0,
181
+ createdAt: r
179
182
  }]);
180
- let a = Date.now();
181
- O.current = a;
182
183
  let o = n.map((e, t) => t === 0 && e.role === "user" && l ? {
183
184
  role: e.role,
184
185
  content: `${l}${e.content}`
@@ -193,7 +194,7 @@ var b = 200, x = 15e4, S = (e, t, n) => {
193
194
  tools: s,
194
195
  toolChoice: c,
195
196
  stream: !0,
196
- sentAt: a,
197
+ sentAt: r,
197
198
  streamStats: {
198
199
  chunkCount: 0,
199
200
  firstChunkAt: null,
@@ -208,7 +209,7 @@ var b = 200, x = 15e4, S = (e, t, n) => {
208
209
  kind: "error",
209
210
  message: e,
210
211
  at: Date.now(),
211
- turnSentAt: a,
212
+ turnSentAt: r,
212
213
  ...t
213
214
  };
214
215
  b.push(n), h((e) => [...e, n]);
@@ -220,13 +221,13 @@ var b = 200, x = 15e4, S = (e, t, n) => {
220
221
  kind: "error",
221
222
  message: e.message,
222
223
  at: Date.now(),
223
- turnSentAt: a
224
+ turnSentAt: r
224
225
  };
225
226
  b.push(t), h((e) => [...e, t]);
226
227
  return;
227
228
  }
228
- e.type === "response.output_text.delta" && e.delta && (_ = !0), F(r, e, b) && (g = !0);
229
- }), t && p((e) => e.map((e) => e.id === r ? {
229
+ e.type === "response.output_text.delta" && e.delta && (_ = !0), F(a, e, b) && (g = !0);
230
+ }), t && p((e) => e.map((e) => e.id === a ? {
230
231
  ...e,
231
232
  streaming: !1
232
233
  } : e));
@@ -241,20 +242,20 @@ var b = 200, x = 15e4, S = (e, t, n) => {
241
242
  signal: d.signal,
242
243
  onChunk: (e) => {
243
244
  P(d), f += e;
244
- let { events: t, remainder: n, done: r } = y(f);
245
- f = n, w(t, r);
246
- let i = Date.now();
247
- v((e) => e && e.sentAt === a ? {
245
+ let { events: t, remainder: n, done: i } = y(f);
246
+ f = n, w(t, i);
247
+ let a = Date.now();
248
+ v((e) => e && e.sentAt === r ? {
248
249
  ...e,
249
250
  streamStats: {
250
251
  chunkCount: e.streamStats.chunkCount + 1,
251
- firstChunkAt: e.streamStats.firstChunkAt ?? i,
252
- lastChunkAt: i
252
+ firstChunkAt: e.streamStats.firstChunkAt ?? a,
253
+ lastChunkAt: a
253
254
  }
254
255
  } : e);
255
256
  },
256
257
  onRequestId: (e) => {
257
- v((t) => t && t.sentAt === a ? {
258
+ v((t) => t && t.sentAt === r ? {
258
259
  ...t,
259
260
  requestId: e
260
261
  } : t);
@@ -284,12 +285,12 @@ var b = 200, x = 15e4, S = (e, t, n) => {
284
285
  return;
285
286
  }
286
287
  C("idle");
287
- let h = j.current.get(r) ?? "";
288
- v((e) => e && e.sentAt === a ? {
288
+ let h = j.current.get(a) ?? "";
289
+ v((e) => e && e.sentAt === r ? {
289
290
  ...e,
290
291
  response: { content: h }
291
292
  } : e), u && await u({
292
- id: r,
293
+ id: a,
293
294
  role: "assistant",
294
295
  content: h,
295
296
  streaming: !1
@@ -306,7 +307,7 @@ var b = 200, x = 15e4, S = (e, t, n) => {
306
307
  }
307
308
  x(t?.message || "Bailey request failed.");
308
309
  } finally {
309
- N(), A.current.delete(r), j.current.delete(r), p((e) => e.flatMap((e) => e.id === r ? e.content ? [{
310
+ N(), A.current.delete(a), j.current.delete(a), p((e) => e.flatMap((e) => e.id === a ? e.content ? [{
310
311
  ...e,
311
312
  streaming: !1
312
313
  }] : [] : [e]));
@@ -338,7 +339,8 @@ var b = 200, x = 15e4, S = (e, t, n) => {
338
339
  let n = [...k.current, {
339
340
  id: crypto.randomUUID(),
340
341
  role: "user",
341
- content: t
342
+ content: t,
343
+ createdAt: Date.now()
342
344
  }];
343
345
  L(n), I(n);
344
346
  }, [I, L]),
@@ -425,7 +427,7 @@ var O = 5, k = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
425
427
  "pie",
426
428
  "doughnut",
427
429
  "scatter"
428
- ], ee = 8, te = 50, ne = 8, re = 500, ie = (e) => typeof e == "object" && !!e && typeof e.x == "number" && typeof e.y == "number", R = (e) => {
430
+ ], ee = 8, te = 50, ne = 8, re = 500, ie = (e) => typeof e == "object" && !!e && typeof e.x == "number" && typeof e.y == "number", ae = (e) => {
429
431
  let t;
430
432
  try {
431
433
  t = JSON.parse(e);
@@ -463,7 +465,7 @@ var O = 5, k = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
463
465
  datasets: o
464
466
  }
465
467
  };
466
- }, z = {
468
+ }, R = {
467
469
  tool_start: "Tool start",
468
470
  tool_end: "Tool end",
469
471
  pseudo_tool_call: "Narrated tool call",
@@ -472,13 +474,13 @@ var O = 5, k = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
472
474
  error: "Error",
473
475
  raw: "Raw event"
474
476
  };
475
- function B(e) {
477
+ function z(e) {
476
478
  return e.kind !== "tool_start" && e.kind !== "tool_end" ? null : D(e.name, e.args);
477
479
  }
478
- function V(e, t = B(e)) {
480
+ function B(e, t = z(e)) {
479
481
  return e.kind === "pseudo_tool_call" ? e.name : t?.name ?? null;
480
482
  }
481
- function H(e, t = B(e)) {
483
+ function V(e, t = z(e)) {
482
484
  switch (e.kind) {
483
485
  case "tool_start": return t.viaCallTool ? `${t.name} (via call_tool)` : t.name;
484
486
  case "tool_end": return `${t.viaCallTool ? `${t.name} (via call_tool)` : t.name}${e.runtimeSeconds === void 0 ? "" : ` — ${e.runtimeSeconds.toFixed(2)}s`}${e.isError ? " — failed" : ""}`;
@@ -489,16 +491,16 @@ function H(e, t = B(e)) {
489
491
  case "raw": return `Unrecognized event: ${e.eventType}`;
490
492
  }
491
493
  }
492
- function U(e, t = B(e)) {
494
+ function H(e, t = z(e)) {
493
495
  return e.kind === "tool_start" || e.kind === "tool_end" ? t.args ? JSON.stringify(t.args, null, 2) : e.args ?? null : e.kind === "pseudo_tool_call" ? e.args ?? null : null;
494
496
  }
495
- function W(e) {
497
+ function U(e) {
496
498
  return e.kind === "tool_end" ? e.output ?? null : null;
497
499
  }
498
- function G(e) {
500
+ function W(e) {
499
501
  return e.kind === "raw" ? e.raw : e.kind === "error" ? e.rawBody ?? null : null;
500
502
  }
501
- function K(e) {
503
+ function G(e) {
502
504
  switch (e.kind) {
503
505
  case "tool_start": return `Calling ${D(e.name, e.args).name}...`;
504
506
  case "tool_end": {
@@ -512,11 +514,11 @@ function K(e) {
512
514
  case "raw": return `Unrecognized event: ${e.eventType}`;
513
515
  }
514
516
  }
515
- function q(e) {
517
+ function K(e) {
516
518
  let t = new Date(e);
517
519
  return `${String(t.getHours()).padStart(2, "0")}:${String(t.getMinutes()).padStart(2, "0")}:${String(t.getSeconds()).padStart(2, "0")}.${String(t.getMilliseconds()).padStart(3, "0")}`;
518
520
  }
519
- function J(e) {
521
+ function q(e) {
520
522
  if (e <= 0) return "+0ms";
521
523
  if (e < 1e3) return `+${Math.round(e)}ms`;
522
524
  let t = e / 1e3;
@@ -524,30 +526,30 @@ function J(e) {
524
526
  let n = Math.floor(t / 60), r = Math.round(t % 60);
525
527
  return `+${n}m${String(r).padStart(2, "0")}s`;
526
528
  }
527
- function Y(e) {
529
+ function J(e) {
528
530
  return e.map((t, n) => {
529
- let r = B(t), i = n === 0 ? t.turnSentAt : e[n - 1].at;
531
+ let r = z(t), i = n === 0 ? t.turnSentAt : e[n - 1].at;
530
532
  return {
531
533
  key: `${t.at}-${n}`,
532
534
  kind: t.kind,
533
- toolName: V(t, r),
535
+ toolName: B(t, r),
534
536
  isToolStart: t.kind === "tool_start",
535
537
  failed: t.kind === "tool_end" && t.isError === !0,
536
- time: q(t.at),
538
+ time: K(t.at),
537
539
  gapMs: t.at - i,
538
- label: t.kind === "tool_end" && t.isError === !0 ? "Tool failed" : z[t.kind],
539
- summary: H(t, r),
540
- argsDetail: U(t, r),
541
- outputDetail: W(t),
542
- rawDetail: G(t)
540
+ label: t.kind === "tool_end" && t.isError === !0 ? "Tool failed" : R[t.kind],
541
+ summary: V(t, r),
542
+ argsDetail: H(t, r),
543
+ outputDetail: U(t),
544
+ rawDetail: W(t)
543
545
  };
544
546
  });
545
547
  }
546
- function X(e) {
548
+ function Y(e) {
547
549
  let t = e.filter((e) => e.kind === "tool_end"), n = t.filter((e) => e.kind === "tool_end" && e.isError), r = e.filter((e) => e.kind === "error"), i = [];
548
550
  return t.length > 0 && i.push(`${t.length} tool call${t.length === 1 ? "" : "s"}` + (n.length > 0 ? `, ${n.length} failed` : "")), r.length > 0 && i.push(`${r.length} stream error${r.length === 1 ? "" : "s"}`), i.join(" · ");
549
551
  }
550
- function ae(e) {
552
+ function X(e) {
551
553
  let t = [];
552
554
  for (let n of e) {
553
555
  let e = t[t.length - 1];
@@ -569,9 +571,16 @@ function ae(e) {
569
571
  function oe(e) {
570
572
  return e.some((e) => e.kind === "tool_end" && e.isError || e.kind === "error");
571
573
  }
574
+ function se(e, t) {
575
+ return t === void 0 ? [] : e.filter((e) => e.turnSentAt === t && (e.kind === "tool_end" || e.kind === "pseudo_tool_call" || e.kind === "progress")).map((e, t) => ({
576
+ key: `${e.at}-${t}`,
577
+ text: G(e),
578
+ toolName: B(e)
579
+ }));
580
+ }
572
581
  //#endregion
573
582
  //#region src/ui/markdown.tsx
574
- function se({ renderTable: t, renderChart: n } = {}) {
583
+ function ce({ renderTable: t, renderChart: n } = {}) {
575
584
  return {
576
585
  a: ({ href: t, children: n }) => !t || !e(t) ? /* @__PURE__ */ u(l, { children: n }) : /* @__PURE__ */ u("a", {
577
586
  href: t,
@@ -593,7 +602,7 @@ function se({ renderTable: t, renderChart: n } = {}) {
593
602
  pre: ({ children: e }) => {
594
603
  let t = (Array.isArray(e) ? e[0] : e)?.props;
595
604
  if ((t?.className?.split(" ") ?? []).includes("language-chartjs") && n) {
596
- let e = t?.children, r = R(Array.isArray(e) ? e.join("") : String(e ?? ""));
605
+ let e = t?.children, r = ae(Array.isArray(e) ? e.join("") : String(e ?? ""));
597
606
  if (r) return /* @__PURE__ */ u(l, { children: n(r) });
598
607
  }
599
608
  return /* @__PURE__ */ u("pre", { children: e });
@@ -601,9 +610,82 @@ function se({ renderTable: t, renderChart: n } = {}) {
601
610
  };
602
611
  }
603
612
  //#endregion
613
+ //#region src/ui/icons.tsx
614
+ function le({ className: e }) {
615
+ return /* @__PURE__ */ u("svg", {
616
+ viewBox: "0 0 24 24",
617
+ fill: "currentColor",
618
+ className: e,
619
+ "aria-hidden": "true",
620
+ children: /* @__PURE__ */ u("path", { d: "M12 20.3s-7.6-4.7-10-9.4C.4 7.7 1.7 4 5.2 3.1c2.2-.6 4.4.4 5.5 2.2 1.2-1.8 3.4-2.8 5.6-2.2 3.5.9 4.8 4.6 3.2 7.8-2.4 4.7-10 9.4-10 9.4z" })
621
+ });
622
+ }
623
+ function ue({ className: e }) {
624
+ return /* @__PURE__ */ d("svg", {
625
+ viewBox: "0 0 24 24",
626
+ fill: "none",
627
+ stroke: "currentColor",
628
+ strokeWidth: 2,
629
+ strokeLinecap: "round",
630
+ strokeLinejoin: "round",
631
+ className: e,
632
+ "aria-hidden": "true",
633
+ children: [/* @__PURE__ */ u("path", { d: "M7 17 17 7" }), /* @__PURE__ */ u("path", { d: "M9 7h8v8" })]
634
+ });
635
+ }
636
+ function de({ className: e }) {
637
+ return /* @__PURE__ */ d("svg", {
638
+ viewBox: "0 0 24 24",
639
+ fill: "none",
640
+ stroke: "currentColor",
641
+ strokeWidth: 2,
642
+ strokeLinecap: "round",
643
+ strokeLinejoin: "round",
644
+ className: e,
645
+ "aria-hidden": "true",
646
+ children: [/* @__PURE__ */ u("rect", {
647
+ x: "8",
648
+ y: "8",
649
+ width: "12",
650
+ height: "12",
651
+ rx: "2"
652
+ }), /* @__PURE__ */ u("path", { d: "M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2" })]
653
+ });
654
+ }
655
+ function fe({ className: e }) {
656
+ return /* @__PURE__ */ u("svg", {
657
+ viewBox: "0 0 24 24",
658
+ fill: "none",
659
+ stroke: "currentColor",
660
+ strokeWidth: 2,
661
+ strokeLinecap: "round",
662
+ strokeLinejoin: "round",
663
+ className: e,
664
+ "aria-hidden": "true",
665
+ children: /* @__PURE__ */ u("path", { d: "M5 12.5 9.5 17 19 7" })
666
+ });
667
+ }
668
+ function pe({ className: e }) {
669
+ return /* @__PURE__ */ d("svg", {
670
+ viewBox: "0 0 24 24",
671
+ fill: "none",
672
+ stroke: "currentColor",
673
+ strokeWidth: 2,
674
+ strokeLinecap: "round",
675
+ strokeLinejoin: "round",
676
+ className: e,
677
+ "aria-hidden": "true",
678
+ children: [/* @__PURE__ */ u("circle", {
679
+ cx: "12",
680
+ cy: "12",
681
+ r: "9"
682
+ }), /* @__PURE__ */ u("path", { d: "M8.5 12.5 11 15l4.5-5.5" })]
683
+ });
684
+ }
685
+ //#endregion
604
686
  //#region src/ui/CopyMarkdownButton.tsx
605
- var ce = 1500;
606
- function le({ markdown: e, className: t }) {
687
+ var me = 1500;
688
+ function he({ markdown: e, className: t }) {
607
689
  let [n, i] = o(!1), [s, c] = o(!1), l = a(null);
608
690
  return r(() => () => {
609
691
  l.current !== null && clearTimeout(l.current);
@@ -620,11 +702,11 @@ function le({ markdown: e, className: t }) {
620
702
  try {
621
703
  await navigator.clipboard.writeText(e);
622
704
  } catch {}
623
- i(!0), l.current !== null && clearTimeout(l.current), l.current = setTimeout(() => i(!1), ce);
705
+ i(!0), l.current !== null && clearTimeout(l.current), l.current = setTimeout(() => i(!1), me);
624
706
  },
625
707
  "aria-label": "copy response as markdown",
626
708
  className: `bailey-copy-button${t ? ` ${t}` : ""}`,
627
- children: n ? "✓" : "⧉"
709
+ children: u(n ? fe : de, { className: "bailey-copy-icon" })
628
710
  })
629
711
  }), /* @__PURE__ */ u(f.Portal, { children: /* @__PURE__ */ d(f.Content, {
630
712
  side: "top",
@@ -636,20 +718,20 @@ function le({ markdown: e, className: t }) {
636
718
  }
637
719
  //#endregion
638
720
  //#region src/ui/BaileyTracePanel.tsx
639
- async function ue(e) {
721
+ async function ge(e) {
640
722
  try {
641
723
  await navigator.clipboard.writeText(e);
642
724
  } catch {}
643
725
  }
644
- function de({ text: e, label: t = "Copy" }) {
726
+ function _e({ text: e, label: t = "Copy" }) {
645
727
  return /* @__PURE__ */ u("button", {
646
728
  type: "button",
647
- onClick: () => ue(e),
729
+ onClick: () => ge(e),
648
730
  className: "bailey-trace-copy-button",
649
731
  children: t
650
732
  });
651
733
  }
652
- function fe(e) {
734
+ function ve(e) {
653
735
  if (e.failed || e.kind === "error") return "bailey-trace-chip bailey-trace-chip-error";
654
736
  switch (e.kind) {
655
737
  case "tool_start": return "bailey-trace-chip bailey-trace-chip-info";
@@ -668,7 +750,7 @@ function Z({ label: e, content: t, copyable: n }) {
668
750
  }),
669
751
  n && /* @__PURE__ */ u("div", {
670
752
  className: "bailey-trace-disclosure-actions",
671
- children: /* @__PURE__ */ u(de, { text: t })
753
+ children: /* @__PURE__ */ u(_e, { text: t })
672
754
  }),
673
755
  /* @__PURE__ */ u("pre", {
674
756
  className: "bailey-trace-disclosure-content",
@@ -691,10 +773,10 @@ function Q({ row: e }) {
691
773
  /* @__PURE__ */ u("span", {
692
774
  className: "bailey-trace-row-gap",
693
775
  title: "Time since the previous event",
694
- children: J(e.gapMs)
776
+ children: q(e.gapMs)
695
777
  }),
696
778
  /* @__PURE__ */ u("span", {
697
- className: fe(e),
779
+ className: ve(e),
698
780
  children: e.label
699
781
  }),
700
782
  /* @__PURE__ */ u("span", {
@@ -718,13 +800,13 @@ function Q({ row: e }) {
718
800
  ]
719
801
  });
720
802
  }
721
- function pe(e, t) {
803
+ function ye(e, t) {
722
804
  if (e.chunkCount === 0) return "Streamed: no chunks received";
723
805
  if (e.chunkCount === 1 || e.firstChunkAt === null) return "Streamed: 1 chunk (not incremental)";
724
806
  let n = e.firstChunkAt - t, r = (e.lastChunkAt ?? e.firstChunkAt) - e.firstChunkAt;
725
807
  return `Streamed: ${e.chunkCount} chunks · first chunk after ${n}ms · spread over ${(r / 1e3).toFixed(1)}s`;
726
808
  }
727
- function me({ request: e }) {
809
+ function be({ request: e }) {
728
810
  let t = i(() => JSON.stringify({
729
811
  model: e.model,
730
812
  instructions: e.systemPrompt,
@@ -748,7 +830,7 @@ function me({ request: e }) {
748
830
  }),
749
831
  /* @__PURE__ */ u("span", {
750
832
  className: "bailey-trace-request-meta",
751
- children: pe(e.streamStats, e.sentAt)
833
+ children: ye(e.streamStats, e.sentAt)
752
834
  }),
753
835
  /* @__PURE__ */ u(Z, {
754
836
  label: `System prompt (${e.systemPrompt.length.toLocaleString()} chars)`,
@@ -773,14 +855,14 @@ function me({ request: e }) {
773
855
  ]
774
856
  });
775
857
  }
776
- function he({ events: e, lastRequest: t, onClear: n }) {
777
- let r = i(() => Y(e), [e]), a = i(() => ae(r), [r]), o = i(() => JSON.stringify(e, null, 2), [e]);
858
+ function xe({ events: e, lastRequest: t, onClear: n }) {
859
+ let r = i(() => J(e), [e]), a = i(() => X(r), [r]), o = i(() => JSON.stringify(e, null, 2), [e]);
778
860
  return /* @__PURE__ */ d("div", {
779
861
  className: "bailey-trace-body",
780
862
  children: [
781
863
  /* @__PURE__ */ d("div", {
782
864
  className: "bailey-trace-actions-row",
783
- children: [e.length > 0 && /* @__PURE__ */ u(de, {
865
+ children: [e.length > 0 && /* @__PURE__ */ u(_e, {
784
866
  text: o,
785
867
  label: "Copy trace as JSON"
786
868
  }), /* @__PURE__ */ u("button", {
@@ -790,7 +872,7 @@ function he({ events: e, lastRequest: t, onClear: n }) {
790
872
  children: "Clear"
791
873
  })]
792
874
  }),
793
- t && /* @__PURE__ */ u(me, { request: t }),
875
+ t && /* @__PURE__ */ u(be, { request: t }),
794
876
  /* @__PURE__ */ u("div", {
795
877
  className: "bailey-trace-rows",
796
878
  children: a.map((e, t) => {
@@ -829,7 +911,7 @@ function he({ events: e, lastRequest: t, onClear: n }) {
829
911
  });
830
912
  }
831
913
  function $({ events: e, lastRequest: t, onClear: n }) {
832
- let [r, a] = o(!1), s = i(() => oe(e), [e]), c = i(() => X(e), [e]);
914
+ let [r, a] = o(!1), s = i(() => oe(e), [e]), c = i(() => Y(e), [e]);
833
915
  return e.length === 0 && !t ? null : /* @__PURE__ */ d("div", {
834
916
  className: "bailey-trace-panel",
835
917
  children: [/* @__PURE__ */ d("div", {
@@ -850,7 +932,7 @@ function $({ events: e, lastRequest: t, onClear: n }) {
850
932
  className: s ? "bailey-trace-summary bailey-trace-summary-error" : "bailey-trace-summary",
851
933
  children: c
852
934
  })]
853
- }), r && /* @__PURE__ */ u(he, {
935
+ }), r && /* @__PURE__ */ u(xe, {
854
936
  events: e,
855
937
  lastRequest: t,
856
938
  onClear: n
@@ -859,144 +941,198 @@ function $({ events: e, lastRequest: t, onClear: n }) {
859
941
  }
860
942
  //#endregion
861
943
  //#region src/ui/BaileyChatPanel.tsx
862
- var ge = [c], _e = t(function({ content: e, components: t }) {
944
+ var Se = "How can bailey AI help you today?", Ce = "Reply to bailey AI", we = [c], Te = t(function({ content: e, components: t }) {
863
945
  return /* @__PURE__ */ u("div", {
864
946
  className: "bailey-markdown-content",
865
947
  children: /* @__PURE__ */ u(s, {
866
- remarkPlugins: ge,
948
+ remarkPlugins: we,
867
949
  components: t,
868
950
  children: e
869
951
  })
870
952
  });
871
953
  });
872
- function ve(e, t, n) {
954
+ function Ee(e, t, n) {
873
955
  if (e !== "streaming") return;
874
956
  let r = t.filter((e) => e.turnSentAt === n?.sentAt);
875
- if (r.length !== 0) return K(r[r.length - 1]);
876
- }
877
- function ye({ chat: e, placeholder: t = "Send a message…", className: n, renderMessageActions: s, renderTable: c, renderChart: l }) {
878
- let { messages: f, traceEvents: p, lastRequest: m, status: h, error: g, send: _, stop: v, retryLast: y, clearTrace: b, clearError: x, newChat: S } = e, [C, w] = o(""), T = a(null), E = i(() => se({
879
- renderTable: c,
880
- renderChart: l
881
- }), [c, l]), D = i(() => ve(h, p, m), [
882
- h,
883
- p,
884
- m
885
- ]);
957
+ if (r.length !== 0) return G(r[r.length - 1]);
958
+ }
959
+ function De(e) {
960
+ let t = new Date(e), n = t.toDateString() === (/* @__PURE__ */ new Date()).toDateString(), r = t.toLocaleTimeString([], {
961
+ hour: "numeric",
962
+ minute: "2-digit"
963
+ });
964
+ return n ? `Today ${r}` : `${t.toLocaleDateString()} ${r}`;
965
+ }
966
+ function Oe({ chat: e, placeholder: t, replyPlaceholder: n = Ce, suggestions: s, privacyNote: c, resolveActivityIcon: l, className: f, height: p, width: m, hideDeveloperDetails: h = !1, renderMessageActions: g, renderTable: _, renderChart: v }) {
967
+ let { messages: y, traceEvents: b, lastRequest: x, status: S, error: C, send: w, stop: T, retryLast: E, clearTrace: D, clearError: O, newChat: k } = e, [A, j] = o(""), M = a(null), N = i(() => ce({
968
+ renderTable: _,
969
+ renderChart: v
970
+ }), [_, v]), P = i(() => Ee(S, b, x), [
971
+ S,
972
+ b,
973
+ x
974
+ ]), F = y.length === 0, I = t ?? (F ? Se : n);
886
975
  return r(() => {
887
- T.current?.scrollIntoView({
976
+ M.current?.scrollIntoView({
888
977
  behavior: "smooth",
889
978
  block: "nearest"
890
979
  });
891
- }, [f]), /* @__PURE__ */ d("div", {
892
- className: `bailey-chat-panel${n ? ` ${n}` : ""}`,
893
- children: [
894
- /* @__PURE__ */ u("div", {
895
- className: "bailey-toolbar-row",
896
- children: /* @__PURE__ */ u("button", {
897
- type: "button",
898
- onClick: S,
899
- disabled: f.length === 0,
900
- "aria-label": "new chat",
901
- className: "bailey-new-chat-button",
902
- children: "New chat"
903
- })
904
- }),
905
- /* @__PURE__ */ d("div", {
906
- className: "bailey-chat-transcript",
907
- children: [
908
- f.length === 0 && /* @__PURE__ */ u("div", {
909
- className: "bailey-empty-state",
910
- children: "Ask Bailey a question to get started."
911
- }),
912
- f.map((e, t) => {
913
- let n = e.role === "assistant" && t === f.length - 1, r = h === "streaming" && n && e.content === "";
914
- return /* @__PURE__ */ u("div", {
915
- className: e.role === "user" ? "bailey-message-row bailey-message-row-user" : "bailey-message-row",
916
- children: e.role === "user" ? /* @__PURE__ */ u("div", {
917
- className: "bailey-user-bubble",
918
- children: e.content
919
- }) : r ? /* @__PURE__ */ u("div", {
920
- className: "bailey-thinking-hint",
921
- children: D ?? "Thinking…"
922
- }) : /* @__PURE__ */ d("div", {
923
- className: "bailey-assistant-message",
924
- children: [
925
- /* @__PURE__ */ u(_e, {
926
- content: e.content,
927
- components: E
928
- }),
929
- e.streaming && D && /* @__PURE__ */ u("div", {
930
- className: "bailey-streaming-hint",
931
- children: D
932
- }),
933
- !e.streaming && /* @__PURE__ */ d("div", {
934
- className: "bailey-message-actions",
935
- children: [/* @__PURE__ */ u(le, { markdown: e.content }), s?.(e)]
936
- })
937
- ]
938
- })
939
- }, e.id);
940
- }),
941
- /* @__PURE__ */ u("div", { ref: T })
942
- ]
943
- }),
944
- g && /* @__PURE__ */ d("div", {
945
- className: "bailey-error-banner",
946
- role: "alert",
947
- children: [/* @__PURE__ */ u("span", { children: g }), /* @__PURE__ */ d("div", {
948
- className: "bailey-error-actions",
949
- children: [/* @__PURE__ */ u("button", {
980
+ }, [y]), /* @__PURE__ */ u("div", {
981
+ className: `bailey-chat-panel${f ? ` ${f}` : ""}`,
982
+ style: p !== void 0 || m !== void 0 ? {
983
+ height: p,
984
+ width: m
985
+ } : void 0,
986
+ children: /* @__PURE__ */ d("div", {
987
+ className: "bailey-chat-panel-inner",
988
+ children: [
989
+ /* @__PURE__ */ u("div", {
990
+ className: "bailey-toolbar-row",
991
+ children: /* @__PURE__ */ u("button", {
950
992
  type: "button",
951
- onClick: y,
952
- className: "bailey-retry-button",
953
- children: "Retry"
954
- }), /* @__PURE__ */ u("button", {
993
+ onClick: k,
994
+ disabled: y.length === 0,
995
+ "aria-label": "new chat",
996
+ className: "bailey-new-chat-button",
997
+ children: "New chat"
998
+ })
999
+ }),
1000
+ /* @__PURE__ */ d("div", {
1001
+ className: "bailey-chat-transcript",
1002
+ children: [
1003
+ F && (s && s.length > 0 ? /* @__PURE__ */ d("div", {
1004
+ className: "bailey-suggestions",
1005
+ children: [/* @__PURE__ */ u("div", {
1006
+ className: "bailey-suggestions-title",
1007
+ children: "Suggested for you"
1008
+ }), s.map((e, t) => /* @__PURE__ */ d("button", {
1009
+ type: "button",
1010
+ onClick: () => w(e.value ?? e.label),
1011
+ className: "bailey-suggestion-card",
1012
+ children: [/* @__PURE__ */ u("span", { children: e.label }), /* @__PURE__ */ u(ue, { className: "bailey-suggestion-icon" })]
1013
+ }, `${e.label}-${t}`))]
1014
+ }) : /* @__PURE__ */ u("div", {
1015
+ className: "bailey-empty-state",
1016
+ children: "Ask Bailey a question to get started."
1017
+ })),
1018
+ y.map((e, t) => {
1019
+ let n = e.role === "assistant" && t === y.length - 1, r = S === "streaming" && n && e.content === "", i = e.role === "assistant" && !r ? se(b, e.createdAt) : [], a = i[i.length - 1];
1020
+ return /* @__PURE__ */ u("div", {
1021
+ className: e.role === "user" ? "bailey-message-row bailey-message-row-user" : "bailey-message-row",
1022
+ children: e.role === "user" ? /* @__PURE__ */ d("div", {
1023
+ className: "bailey-user-message",
1024
+ children: [/* @__PURE__ */ d("div", {
1025
+ className: "bailey-message-meta",
1026
+ children: [/* @__PURE__ */ u("span", {
1027
+ className: "bailey-message-meta-name",
1028
+ children: "You"
1029
+ }), e.createdAt !== void 0 && /* @__PURE__ */ u("span", { children: De(e.createdAt) })]
1030
+ }), /* @__PURE__ */ u("div", {
1031
+ className: "bailey-user-bubble",
1032
+ children: e.content
1033
+ })]
1034
+ }) : r ? /* @__PURE__ */ u("div", {
1035
+ className: "bailey-thinking-hint",
1036
+ children: P ?? "Thinking…"
1037
+ }) : /* @__PURE__ */ d("div", {
1038
+ className: "bailey-assistant-message",
1039
+ children: [
1040
+ a && /* @__PURE__ */ d("div", {
1041
+ className: "bailey-activity-line",
1042
+ children: [/* @__PURE__ */ u("span", {
1043
+ className: "bailey-activity-icon",
1044
+ children: l?.(a.toolName) ?? /* @__PURE__ */ u(pe, {})
1045
+ }), /* @__PURE__ */ u("span", { children: a.text })]
1046
+ }),
1047
+ /* @__PURE__ */ u(Te, {
1048
+ content: e.content,
1049
+ components: N
1050
+ }),
1051
+ e.streaming && P && /* @__PURE__ */ u("div", {
1052
+ className: "bailey-streaming-hint",
1053
+ children: P
1054
+ }),
1055
+ !e.streaming && /* @__PURE__ */ d("div", {
1056
+ className: "bailey-message-actions",
1057
+ children: [/* @__PURE__ */ u(he, { markdown: e.content }), g?.(e)]
1058
+ })
1059
+ ]
1060
+ })
1061
+ }, e.id);
1062
+ }),
1063
+ /* @__PURE__ */ u("div", { ref: M })
1064
+ ]
1065
+ }),
1066
+ F && c && /* @__PURE__ */ d("div", {
1067
+ className: "bailey-privacy-note",
1068
+ children: [
1069
+ c.text,
1070
+ " ",
1071
+ /* @__PURE__ */ u("a", {
1072
+ href: c.linkHref,
1073
+ target: "_blank",
1074
+ rel: "noreferrer",
1075
+ children: c.linkLabel
1076
+ })
1077
+ ]
1078
+ }),
1079
+ C && /* @__PURE__ */ d("div", {
1080
+ className: "bailey-error-banner",
1081
+ role: "alert",
1082
+ children: [/* @__PURE__ */ u("span", { children: C }), /* @__PURE__ */ d("div", {
1083
+ className: "bailey-error-actions",
1084
+ children: [/* @__PURE__ */ u("button", {
1085
+ type: "button",
1086
+ onClick: E,
1087
+ className: "bailey-retry-button",
1088
+ children: "Retry"
1089
+ }), /* @__PURE__ */ u("button", {
1090
+ type: "button",
1091
+ onClick: O,
1092
+ "aria-label": "dismiss error",
1093
+ className: "bailey-dismiss-button",
1094
+ children: "✕"
1095
+ })]
1096
+ })]
1097
+ }),
1098
+ !h && /* @__PURE__ */ u($, {
1099
+ events: b,
1100
+ lastRequest: x,
1101
+ onClear: D
1102
+ }),
1103
+ /* @__PURE__ */ d("form", {
1104
+ onSubmit: (e) => {
1105
+ e.preventDefault(), !(!A.trim() || S === "streaming") && (w(A), j(""));
1106
+ },
1107
+ className: "bailey-input-row",
1108
+ children: [/* @__PURE__ */ u("input", {
1109
+ type: "text",
1110
+ placeholder: I,
1111
+ "aria-label": I,
1112
+ value: A,
1113
+ onChange: (e) => j(e.target.value),
1114
+ disabled: S === "streaming",
1115
+ className: "bailey-input"
1116
+ }), S === "streaming" ? /* @__PURE__ */ u("button", {
955
1117
  type: "button",
956
- onClick: x,
957
- "aria-label": "dismiss error",
958
- className: "bailey-dismiss-button",
959
- children: "✕"
1118
+ onClick: T,
1119
+ "aria-label": "stop",
1120
+ className: "bailey-stop-button",
1121
+ children: "Stop"
1122
+ }) : /* @__PURE__ */ u("button", {
1123
+ type: "submit",
1124
+ "aria-label": "send",
1125
+ disabled: !A.trim(),
1126
+ className: "bailey-send-button",
1127
+ children: /* @__PURE__ */ u(le, { className: "bailey-send-icon" })
960
1128
  })]
961
- })]
962
- }),
963
- /* @__PURE__ */ u($, {
964
- events: p,
965
- lastRequest: m,
966
- onClear: b
967
- }),
968
- /* @__PURE__ */ d("form", {
969
- onSubmit: (e) => {
970
- e.preventDefault(), !(!C.trim() || h === "streaming") && (_(C), w(""));
971
- },
972
- className: "bailey-input-row",
973
- children: [/* @__PURE__ */ u("input", {
974
- type: "text",
975
- placeholder: t,
976
- "aria-label": t,
977
- value: C,
978
- onChange: (e) => w(e.target.value),
979
- disabled: h === "streaming",
980
- className: "bailey-input"
981
- }), h === "streaming" ? /* @__PURE__ */ u("button", {
982
- type: "button",
983
- onClick: v,
984
- "aria-label": "stop",
985
- className: "bailey-stop-button",
986
- children: "Stop"
987
- }) : /* @__PURE__ */ u("button", {
988
- type: "submit",
989
- "aria-label": "send",
990
- disabled: !C.trim(),
991
- className: "bailey-send-button",
992
- children: "Send"
993
- })]
994
- })
995
- ]
1129
+ })
1130
+ ]
1131
+ })
996
1132
  });
997
1133
  }
998
1134
  //#endregion
999
1135
  //#region src/index.ts
1000
- var be = "0.3.1-pre.1";
1136
+ var ke = "0.3.1-pre.2";
1001
1137
  //#endregion
1002
- export { be as BAILEYAI_CHAT_UI_VERSION, I as BAILEY_CHART_PROMPT_FRAGMENT, O as BAILEY_TABLE_GRID_ROW_THRESHOLD, ye as BaileyChatPanel, $ as BaileyTracePanel, le as CopyMarkdownButton, z as TRACE_KIND_LABEL, se as createBaileyMarkdownComponents, _ as extractPseudoToolCalls, P as extractTableData, J as formatTraceGap, q as formatTraceTime, oe as hasTraceFailure, e as isSafeMarkdownUrl, w as joinInstructions, R as parseBaileyChartSpec, y as parseSseFrames, D as resolveToolCall, F as shouldUseGrid, Y as toTraceRows, ae as toTraceSegments, U as traceEventArgsDetail, K as traceEventHint, W as traceEventOutputDetail, G as traceEventRawDetail, H as traceEventSummary, V as traceEventToolName, X as traceSummaryLine, C as useBaileyChat };
1138
+ export { pe as ActivityIcon, ue as ArrowUpRightIcon, ke as BAILEYAI_CHAT_UI_VERSION, I as BAILEY_CHART_PROMPT_FRAGMENT, O as BAILEY_TABLE_GRID_ROW_THRESHOLD, Oe as BaileyChatPanel, $ as BaileyTracePanel, he as CopyMarkdownButton, le as HeartIcon, R as TRACE_KIND_LABEL, ce as createBaileyMarkdownComponents, _ as extractPseudoToolCalls, P as extractTableData, q as formatTraceGap, K as formatTraceTime, oe as hasTraceFailure, e as isSafeMarkdownUrl, w as joinInstructions, ae as parseBaileyChartSpec, y as parseSseFrames, D as resolveToolCall, F as shouldUseGrid, se as toActivityLines, J as toTraceRows, X as toTraceSegments, H as traceEventArgsDetail, G as traceEventHint, U as traceEventOutputDetail, W as traceEventRawDetail, V as traceEventSummary, B as traceEventToolName, Y as traceSummaryLine, C as useBaileyChat };
package/dist/index.d.ts CHANGED
@@ -2,6 +2,20 @@ import { Components } from 'react-markdown';
2
2
  import { JSX } from 'react';
3
3
  import { ReactNode } from 'react';
4
4
 
5
+ export declare function ActivityIcon({ className }: {
6
+ className?: string;
7
+ }): JSX.Element;
8
+
9
+ export declare interface ActivityLine {
10
+ key: string;
11
+ text: string;
12
+ toolName: string | null;
13
+ }
14
+
15
+ export declare function ArrowUpRightIcon({ className }: {
16
+ className?: string;
17
+ }): JSX.Element;
18
+
5
19
  export declare const BAILEY_CHART_PROMPT_FRAGMENT: string;
6
20
 
7
21
  export declare const BAILEY_TABLE_GRID_ROW_THRESHOLD = 5;
@@ -32,12 +46,39 @@ export declare interface BaileyChatInputMessage {
32
46
  content: string;
33
47
  }
34
48
 
35
- export declare function BaileyChatPanel({ chat, placeholder, className, renderMessageActions, renderTable, renderChart, }: BaileyChatPanelProps): JSX.Element;
49
+ export declare function BaileyChatPanel({ chat, placeholder, replyPlaceholder, suggestions, privacyNote, resolveActivityIcon, className, height, width, hideDeveloperDetails, renderMessageActions, renderTable, renderChart, }: BaileyChatPanelProps): JSX.Element;
36
50
 
37
51
  export declare interface BaileyChatPanelProps extends BaileyMarkdownRenderers {
38
52
  chat: UseBaileyChatResult;
53
+ /** Overrides the input's placeholder in BOTH the empty and reply states, taking priority
54
+ * over emptyPlaceholder/replyPlaceholder below. Omit to get the state-appropriate default. */
39
55
  placeholder?: string;
56
+ /** Placeholder shown once the conversation has started; ignored if `placeholder` is set. */
57
+ replyPlaceholder?: string;
58
+ /** Suggested prompts shown ("Suggested for you") in the empty state before any message has
59
+ * been sent. Clicking one calls chat.send(value ?? label). Omit to keep the plain
60
+ * "Ask Bailey a question to get started." empty state. */
61
+ suggestions?: BaileySuggestion[];
62
+ /** A short privacy/compliance note rendered above the input, empty state only. No default —
63
+ * the exact copy/link is host-specific, so nothing is shown unless a host supplies one. */
64
+ privacyNote?: BaileyPrivacyNote;
65
+ /** Customizes the icon shown next to an inline activity line (e.g. "Checking your vitals.")
66
+ * based on the tool/event name — defaults to a single generic icon for every line, rather
67
+ * than guessing a per-tool glyph mapping. */
68
+ resolveActivityIcon?: (toolName: string | null) => ReactNode;
40
69
  className?: string;
70
+ /** Explicit panel height (number is treated as px, e.g. 600 or '600px' or '100vh'). Applied
71
+ * as an inline style, which wins over the default `h-full` CSS class regardless of whether
72
+ * a host has its own Tailwind build — so a host can size the panel without needing to
73
+ * produce a matching utility class of its own. Omit to keep sizing to 100% of the parent. */
74
+ height?: number | string;
75
+ /** Explicit panel width, same semantics as `height`. Omit to size to the parent's width. */
76
+ width?: number | string;
77
+ /** Hides the developer-facing "Show details" trace panel (tool call args/output, raw
78
+ * request/response payloads) entirely — for a host that wants Bailey's chat experience
79
+ * without exposing that debugging surface to end users. Defaults to false (shown), matching
80
+ * today's behavior. */
81
+ hideDeveloperDetails?: boolean;
41
82
  /** Renders next to the built-in copy button for a completed assistant message — a static,
42
83
  * per-message extension point for a host action (e.g. "regenerate", feedback buttons).
43
84
  * Content-derived actions (e.g. baileyai-skills-service's save-as-skill artifact UI) are a
@@ -99,6 +140,9 @@ export declare interface BaileyMessage {
99
140
  role: 'user' | 'assistant';
100
141
  content: string;
101
142
  streaming?: boolean;
143
+ /** When this message was created, stamped by useBaileyChat. Optional so hosts constructing
144
+ * BaileyMessage objects by hand (e.g. tests, seed data) aren't forced to supply it. */
145
+ createdAt?: number;
102
146
  }
103
147
 
104
148
  export declare interface BaileyOutputItem {
@@ -110,6 +154,12 @@ export declare interface BaileyOutputItem {
110
154
  runtime_seconds?: number;
111
155
  }
112
156
 
157
+ export declare interface BaileyPrivacyNote {
158
+ text: string;
159
+ linkLabel: string;
160
+ linkHref: string;
161
+ }
162
+
113
163
  export declare type BaileyStreamEvent = {
114
164
  type: 'response.output_text.delta';
115
165
  delta: string;
@@ -143,6 +193,13 @@ export declare interface BaileyStreamStats {
143
193
  lastChunkAt: number | null;
144
194
  }
145
195
 
196
+ export declare interface BaileySuggestion {
197
+ /** Shown on the suggestion card. */
198
+ label: string;
199
+ /** Sent to chat.send() when the card is clicked — defaults to `label` when omitted. */
200
+ value?: string;
201
+ }
202
+
146
203
  export declare interface BaileyTableCell {
147
204
  text: string;
148
205
  href?: string;
@@ -245,6 +302,10 @@ export declare interface HastNode {
245
302
 
246
303
  export declare function hasTraceFailure(events: BaileyTraceEvent[]): boolean;
247
304
 
305
+ export declare function HeartIcon({ className }: {
306
+ className?: string;
307
+ }): JSX.Element;
308
+
248
309
  export declare const isSafeMarkdownUrl: (href: string) => boolean;
249
310
 
250
311
  export declare function joinInstructions(...parts: Array<string | undefined | null | false>): string;
@@ -279,6 +340,8 @@ export declare function resolveToolCall(name: string, argsJson: string | undefin
279
340
 
280
341
  export declare const shouldUseGrid: (rows: BaileyTableCell[][]) => boolean;
281
342
 
343
+ export declare function toActivityLines(events: BaileyTraceEvent[], turnSentAt: number | undefined): ActivityLine[];
344
+
282
345
  export declare function toTraceRows(events: BaileyTraceEvent[]): TraceRow[];
283
346
 
284
347
  export declare function toTraceSegments(rows: TraceRow[]): TraceSegment[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icanbwell/baileyai-chat-ui",
3
- "version": "0.3.3",
3
+ "version": "0.4.0",
4
4
  "description": "Shared React chat UI and streaming logic for Bailey, the icanbwell AI assistant",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {