@icanbwell/baileyai-chat-ui 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/baileyai-chat-ui.cjs +2 -2
- package/dist/baileyai-chat-ui.css +1 -1
- package/dist/baileyai-chat-ui.js +158 -152
- package/package.json +1 -1
|
@@ -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=S(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 w=200,T=15e4,E=(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>w?`${i.slice(0,w)}…`:i}`:r},
|
|
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=S(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 w=200,T=15e4,E=()=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`bailey-${Date.now()}-${Math.random().toString(36).slice(2)}`,D=(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>w?`${i.slice(0,w)}…`:i}`:r},O=({transport:e,model:t,instructions:n,tools:r=[],toolChoice:i,firstUserMessagePrefix:a,onAssistantMessageComplete:o,idleTimeoutMs:s=T})=>{let[c,u]=(0,l.useState)([]),[d,f]=(0,l.useState)([]),[p,m]=(0,l.useState)(null),[h,g]=(0,l.useState)(`idle`),[_,v]=(0,l.useState)(null),y=(0,l.useRef)(null),b=(0,l.useRef)(``),S=(0,l.useRef)(0),w=(0,l.useRef)([]);(0,l.useEffect)(()=>{w.current=c},[c]);let O=(0,l.useRef)([]),k=(0,l.useRef)(new Map),A=(0,l.useRef)(new Map),j=(0,l.useRef)(null),M=(0,l.useCallback)(()=>{j.current!==null&&(clearTimeout(j.current),j.current=null)},[]),N=(0,l.useCallback)(e=>{M(),j.current=setTimeout(()=>{e.abort(new DOMException(`The assistant took too long to respond. Please try again.`,`TimeoutError`))},s)},[M,s]);(0,l.useEffect)(()=>()=>{y.current?.abort(),M()},[M]);let P=(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=k.current.get(e)??{raw:``,emittedCount:0};n.raw+=t.delta;let{cleanedText:i,matches:a}=x(n.raw),o=i.trim(),s=a.slice(n.emittedCount);if(n.emittedCount=a.length,k.current.set(e,n),A.current.set(e,o),u(t=>t.map(t=>t.id===e?{...t,content:o}:t)),s.length>0){let e=Date.now(),t=S.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=S.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:S.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:S.current}),!0):(r({kind:`raw`,eventType:t.type,raw:JSON.stringify(t),at:Date.now(),turnSentAt:S.current}),!0)},[]),F=(0,l.useCallback)(async s=>{g(`streaming`),v(null);let c=Date.now();S.current=c;let l=E(),d={id:l,role:`assistant`,content:``,streaming:!0,createdAt:c};u(e=>[...e,d]),O.current=[...s,d];let p=s.findIndex(e=>e.role===`user`&&!e.hidden),h=s.map((e,t)=>t===p&&a?{role:e.role,content:`${a}${e.content}`}:{role:e.role,content:e.content});m({model:t,systemPrompt:n,messages:h,tools:r,toolChoice:i,stream:!0,sentAt:c,streamStats:{chunkCount:0,firstChunkAt:null,lastChunkAt:null}});let _=new AbortController;y.current=_,N(_);let b=``,x=null,w=!1,T=!1,j=[],F=(e,t)=>{g(`error`),v(e);let n={kind:`error`,message:e,at:Date.now(),turnSentAt:c,...t};j.push(n),f(e=>[...e,n])},I=(e,t)=>{e.forEach(e=>{if(e.type===`error`){x=e.message;let t={kind:`error`,message:e.message,at:Date.now(),turnSentAt:c};j.push(t),f(e=>[...e,t]);return}e.type===`response.output_text.delta`&&e.delta&&(T=!0),P(l,e,j)&&(w=!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:h,tools:r,toolChoice:i,signal:_.signal,onChunk:e=>{N(_),b+=e;let{events:t,remainder:n,done:r}=C(b);b=n,I(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(b.trim()){let{events:e,done:t}=C(`${b}\n\n`);b=``,I(e,t)}if(x){g(`error`),v(x);return}if(a===void 0||a>=400){F(D(a,s,u),{httpStatus:a,rawBody:s||void 0});return}if(!w){F(`Bailey returned an empty response.`);return}if(!T){F(`Bailey ran some tools but didn't return an answer. Try asking again.`);return}g(`idle`);let d=A.current.get(l)??``;m(e=>e&&e.sentAt===c?{...e,response:{content:d}}:e),o&&await o({id:l,role:`assistant`,content:d,streaming:!1},j)}catch(e){let t=e;if(t?.name===`TimeoutError`){F(t.message,{source:`client-timeout`});return}if(t?.name===`AbortError`){g(`idle`);return}F(t?.message||`Bailey request failed.`)}finally{M();let e=A.current.get(l)??``;k.current.delete(l),A.current.delete(l),u(e=>e.flatMap(e=>e.id===l?e.content?[{...e,streaming:!1}]:[]:[e])),O.current=O.current.flatMap(t=>t.id===l?e?[{...t,content:e,streaming:!1}]:[]:[t])}},[e,t,n,r,i,a,o,P,N,M]),I=(0,l.useCallback)(e=>{w.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;b.current=t;let n={id:E(),role:`user`,content:t,createdAt:Date.now()},r=[...O.current,n];O.current=r,I([...w.current,n]),F(r)},[F,I]),sendHidden:(0,l.useCallback)(e=>{if(h===`streaming`)return;let t=e.trim();if(!t)return;b.current=t;let n={id:E(),role:`user`,content:t,createdAt:Date.now(),hidden:!0},r=[...O.current,n];O.current=r,F(r)},[F,h]),stop:(0,l.useCallback)(()=>{y.current?.abort()},[]),retryLast:(0,l.useCallback)(()=>{if(h===`streaming`||!b.current)return;let e=w.current,t=e[e.length-1],n=t&&t.role===`assistant`?e.slice(0,-1):e;I(n);let r=O.current,i=r[r.length-1],a=i&&i.role===`assistant`?r.slice(0,-1):r;O.current=a,F(a)},[F,I,h]),clearTrace:(0,l.useCallback)(()=>f([]),[]),clearError:(0,l.useCallback)(()=>{v(null),g(e=>e===`error`?`idle`:e)},[]),newChat:(0,l.useCallback)(()=>{y.current?.abort(),I([]),O.current=[],f([]),m(null),g(`idle`),v(null),b.current=``},[I])}};function k(...e){return e.filter(e=>!!(e&&e.trim())).join(`
|
|
10
10
|
|
|
11
|
-
`)}var k=`call_tool`,A=`a tool`;function j(e,t){let n={name:e===k?A: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===k){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 M=5,N=e=>e.type===`text`?e.value??``:(e.children??[]).map(N).join(``),P=e=>{if(e.tagName===`a`&&e.properties?.href)return e.properties.href;for(let t of e.children??[]){let e=P(t);if(e)return e}},F=(e,t)=>(e.children??[]).find(e=>e.tagName===t),I=e=>{let t=N(e),n=P(e);return n?{text:t,href:n}:{text:t}},L=e=>(e.children??[]).filter(e=>e.type===`element`).map(I),R=e=>{if(e.tagName!==`table`)return null;let t=F(e,`thead`),n=t&&F(t,`tr`);return{headers:n?L(n).map(e=>e.text):[],rows:(F(e,`tbody`)?.children??[]).filter(e=>e.tagName===`tr`).map(L)}},z=e=>e.length>5,B='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```',V=[`bar`,`line`,`pie`,`doughnut`,`scatter`],ee=8,te=50,ne=8,re=500,ie=e=>typeof e==`object`&&!!e&&typeof e.x==`number`&&typeof e.y==`number`,ae=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`||!V.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>ee||(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>re||!e.data.every(ie))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`?ne:te;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}}},H={tool_start:`Tool start`,tool_end:`Tool end`,pseudo_tool_call:`Narrated tool call`,progress:`Progress`,info:`Info`,error:`Error`,raw:`Raw event`};function U(e){return e.kind!==`tool_start`&&e.kind!==`tool_end`?null:j(e.name,e.args)}function W(e,t=U(e)){return e.kind===`pseudo_tool_call`?e.name:t?.name??null}function G(e,t=U(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 K(e,t=U(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 q(e){return e.kind===`tool_end`?e.output??null:null}function J(e){return e.kind===`raw`?e.raw:e.kind===`error`?e.rawBody??null:null}function Y(e){switch(e.kind){case`tool_start`:return`Calling ${j(e.name,e.args).name}...`;case`tool_end`:{let t=j(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 X(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 Z(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 oe(e){return e.map((t,n)=>{let r=U(t),i=n===0?t.turnSentAt:e[n-1].at;return{key:`${t.at}-${n}`,kind:t.kind,toolName:W(t,r),isToolStart:t.kind===`tool_start`,failed:t.kind===`tool_end`&&t.isError===!0,time:X(t.at),gapMs:t.at-i,label:t.kind===`tool_end`&&t.isError===!0?`Tool failed`:H[t.kind],summary:G(t,r),argsDetail:K(t,r),outputDetail:q(t),rawDetail:J(t)}})}function se(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 ce(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 le(e){return e.some(e=>e.kind===`tool_end`&&e.isError||e.kind===`error`)}function ue(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:Y(e),toolName:W(e)}))}function de({renderTable:e,renderChart:t}={}){return{a:({href:e,children:t})=>!e||!c.t(e)?(0,p.jsx)(p.Fragment,{children:t}):(0,p.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:t}),table:({node:t,children:n})=>{let r=t&&R(t);if(r&&z(r.rows)&&e){let t=r.rows.map(e=>e.map(e=>e.href&&!c.t(e.href)?{text:e.text}:e));return(0,p.jsx)(p.Fragment,{children:e({headers:r.headers,rows:t})})}return(0,p.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=ae(Array.isArray(e)?e.join(``):String(e??``));if(r)return(0,p.jsx)(p.Fragment,{children:t(r)})}return(0,p.jsx)(`pre`,{children:e})}}}function fe({className:e}){return(0,p.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,className:e,"aria-hidden":`true`,children:(0,p.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 pe({className:e}){return(0,p.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,className:e,"aria-hidden":`true`,children:(0,p.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}function me({className:e}){return(0,p.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:e,"aria-hidden":`true`,children:[(0,p.jsx)(`path`,{d:`M7 17 17 7`}),(0,p.jsx)(`path`,{d:`M9 7h8v8`})]})}function he({className:e}){return(0,p.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:e,"aria-hidden":`true`,children:[(0,p.jsx)(`rect`,{x:`8`,y:`8`,width:`12`,height:`12`,rx:`2`}),(0,p.jsx)(`path`,{d:`M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2`})]})}function ge({className:e}){return(0,p.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:e,"aria-hidden":`true`,children:(0,p.jsx)(`path`,{d:`M5 12.5 9.5 17 19 7`})})}function _e({className:e}){return(0,p.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:e,"aria-hidden":`true`,children:[(0,p.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,p.jsx)(`path`,{d:`M8.5 12.5 11 15l4.5-5.5`})]})}var ve=1500;function ye({markdown:e,className:t,ariaLabel:n=`copy response as markdown`,tooltipDefaultText:r=`Copy as markdown`,tooltipCopiedText:i=`Copied!`}){let[a,o]=(0,l.useState)(!1),[s,c]=(0,l.useState)(!1),u=(0,l.useRef)(null);return(0,l.useEffect)(()=>()=>{u.current!==null&&clearTimeout(u.current)},[]),(0,p.jsx)(f.Provider,{delayDuration:200,children:(0,p.jsxs)(f.Root,{open:a||s,onOpenChange:c,children:[(0,p.jsx)(f.Trigger,{asChild:!0,children:(0,p.jsx)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(e)}catch{}o(!0),u.current!==null&&clearTimeout(u.current),u.current=setTimeout(()=>o(!1),ve)},"aria-label":n,className:`bailey-copy-button${t?` ${t}`:``}`,children:a?(0,p.jsx)(ge,{className:`bailey-copy-icon`}):(0,p.jsx)(he,{className:`bailey-copy-icon`})})}),(0,p.jsx)(f.Portal,{children:(0,p.jsxs)(f.Content,{side:`top`,className:`bailey-tooltip-content`,children:[a?i:r,(0,p.jsx)(f.Arrow,{className:`bailey-tooltip-arrow`})]})})]})})}async function be(e){try{await navigator.clipboard.writeText(e)}catch{}}function xe({text:e,label:t=`Copy`}){return(0,p.jsx)(`button`,{type:`button`,onClick:()=>be(e),className:`bailey-trace-copy-button`,children:t})}function Se(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 Q({label:e,content:t,copyable:n}){return(0,p.jsxs)(`details`,{className:`bailey-trace-disclosure`,children:[(0,p.jsx)(`summary`,{className:`bailey-trace-disclosure-summary`,children:e}),n&&(0,p.jsx)(`div`,{className:`bailey-trace-disclosure-actions`,children:(0,p.jsx)(xe,{text:t})}),(0,p.jsx)(`pre`,{className:`bailey-trace-disclosure-content`,children:t})]})}function $({row:e}){return(0,p.jsxs)(`div`,{className:`bailey-trace-row`,children:[(0,p.jsxs)(`div`,{className:`bailey-trace-row-header`,children:[(0,p.jsx)(`span`,{className:`bailey-trace-row-time`,children:e.time}),(0,p.jsx)(`span`,{className:`bailey-trace-row-gap`,title:`Time since the previous event`,children:Z(e.gapMs)}),(0,p.jsx)(`span`,{className:Se(e),children:e.label}),(0,p.jsx)(`span`,{className:`bailey-trace-row-summary`,children:e.summary})]}),e.argsDetail&&(0,p.jsx)(Q,{label:`args`,content:e.argsDetail}),e.outputDetail&&(0,p.jsx)(Q,{label:`output`,content:e.outputDetail}),e.rawDetail&&(0,p.jsx)(Q,{label:`raw`,content:e.rawDetail})]})}function Ce(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 we({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,p.jsxs)(`div`,{className:`bailey-trace-request-details`,children:[(0,p.jsxs)(`span`,{className:`bailey-trace-request-meta`,children:[`Last request — `,e.model,` · `,new Date(e.sentAt).toLocaleTimeString(),e.requestId?` · ${e.requestId}`:``]}),(0,p.jsx)(`span`,{className:`bailey-trace-request-meta`,children:Ce(e.streamStats,e.sentAt)}),(0,p.jsx)(Q,{label:`System prompt (${e.systemPrompt.length.toLocaleString()} chars)`,content:e.systemPrompt,copyable:!0}),(0,p.jsx)(Q,{label:`Messages (${e.messages.length})`,content:JSON.stringify(e.messages,null,2),copyable:!0}),e.response&&(0,p.jsx)(Q,{label:`Response (${e.response.content.length.toLocaleString()} chars)`,content:e.response.content,copyable:!0}),(0,p.jsx)(Q,{label:`Full payload (JSON)`,content:t,copyable:!0})]})}function Te({events:e,lastRequest:t,onClear:n}){let r=(0,l.useMemo)(()=>oe(e),[e]),i=(0,l.useMemo)(()=>ce(r),[r]),a=(0,l.useMemo)(()=>JSON.stringify(e,null,2),[e]);return(0,p.jsxs)(`div`,{className:`bailey-trace-body`,children:[(0,p.jsxs)(`div`,{className:`bailey-trace-actions-row`,children:[e.length>0&&(0,p.jsx)(xe,{text:a,label:`Copy trace as JSON`}),(0,p.jsx)(`button`,{type:`button`,onClick:n,className:`bailey-trace-copy-button`,children:`Clear`})]}),t&&(0,p.jsx)(we,{request:t}),(0,p.jsx)(`div`,{className:`bailey-trace-rows`,children:i.map((e,t)=>{if(e.type===`single`)return(0,p.jsx)($,{row:e.row},e.row.key);let n=e.rows.filter(e=>e.isToolStart).length;if(n<=1)return(0,p.jsx)(`div`,{className:`bailey-trace-rows`,children:e.rows.map(e=>(0,p.jsx)($,{row:e},e.key))},`group-${t}`);let r=e.rows.filter(e=>e.failed).length;return(0,p.jsxs)(`details`,{className:`bailey-trace-group`,children:[(0,p.jsxs)(`summary`,{className:`bailey-trace-group-summary`,children:[(0,p.jsx)(`strong`,{children:e.toolName}),` × `,n,r>0&&(0,p.jsxs)(`span`,{className:`bailey-trace-group-failed`,children:[` `,r,` failed`]})]}),(0,p.jsx)(`div`,{className:`bailey-trace-rows`,children:e.rows.map(e=>(0,p.jsx)($,{row:e},e.key))})]},`group-${t}`)})})]})}function Ee({events:e,lastRequest:t,onClear:n}){let[r,i]=(0,l.useState)(!1),a=(0,l.useMemo)(()=>le(e),[e]),o=(0,l.useMemo)(()=>se(e),[e]);return e.length===0&&!t?null:(0,p.jsxs)(`div`,{className:`bailey-trace-panel`,children:[(0,p.jsxs)(`div`,{className:`bailey-trace-toggle-row`,children:[(0,p.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,p.jsx)(`span`,{className:a?`bailey-trace-summary bailey-trace-summary-error`:`bailey-trace-summary`,children:o})]}),r&&(0,p.jsx)(Te,{events:e,lastRequest:t,onClear:n})]})}var De=`How can bailey AI help you today?`,Oe=`Reply to bailey AI`,ke={newChatButtonText:`New chat`,newChatAriaLabel:`new chat`,suggestionsTitle:`Suggested for you`,emptyStateMessage:`Ask Bailey a question to get started.`,youLabel:`You`,thinkingHint:`Thinking…`,retryButtonText:`Retry`,dismissErrorAriaLabel:`dismiss error`,sendAriaLabel:`send`,stopButtonText:`Stop`,stopAriaLabel:`stop`,copyButtonAriaLabel:`copy response as markdown`,copyButtonTooltipDefault:`Copy as markdown`,copyButtonTooltipCopied:`Copied!`},Ae=[d.default],je=(0,l.memo)(function({content:e,components:t}){return(0,p.jsx)(`div`,{className:`bailey-markdown-content`,children:(0,p.jsx)(u.default,{remarkPlugins:Ae,components:t,skipHtml:!0,children:e})})});function Me(e,t,n){if(e!==`streaming`)return;let r=t.filter(e=>e.turnSentAt===n?.sentAt);if(r.length!==0)return Y(r[r.length-1])}function Ne(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 Pe({chat:e,placeholder:t,replyPlaceholder:n=Oe,emptyPlaceholder:r,suggestions:i,privacyNote:a,resolveActivityIcon:o,className:s,height:c,width:u,hideDeveloperDetails:d=!1,renderMessageActions:m,renderTable:h,renderChart:g,labels:_,formatMessageTime:v}){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]=(0,l.useState)(``),M={...ke,..._},N=v??Ne,P=(0,l.useRef)(null),F=(0,l.useRef)(null),I=(0,l.useRef)(!0),L=(0,l.useMemo)(()=>de({renderTable:h,renderChart:g}),[h,g]),R=(0,l.useMemo)(()=>Me(S,b,x),[S,b,x]),z=y.length===0,B=t??(z?r??De:n);(0,l.useEffect)(()=>{let e=F.current;if(!e)return;let t=()=>{let t=e.scrollHeight-e.scrollTop-e.clientHeight;I.current=t<60};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]),(0,l.useEffect)(()=>{I.current&&P.current?.scrollIntoView({behavior:S===`streaming`?`auto`:`smooth`,block:`nearest`})},[y,S]);let V=e=>{I.current=!0,w(e)};return(0,p.jsx)(`div`,{className:`bailey-chat-panel${s?` ${s}`:``}`,style:c!==void 0||u!==void 0?{height:c,width:u}:void 0,children:(0,p.jsxs)(`div`,{className:`bailey-chat-panel-inner`,children:[(0,p.jsx)(`div`,{className:`bailey-toolbar-row`,children:(0,p.jsx)(`button`,{type:`button`,onClick:k,disabled:y.length===0,"aria-label":M.newChatAriaLabel,className:`bailey-new-chat-button`,children:M.newChatButtonText})}),(0,p.jsxs)(`div`,{className:`bailey-chat-transcript`,ref:F,children:[z&&(i&&i.length>0?(0,p.jsxs)(`div`,{className:`bailey-suggestions`,children:[(0,p.jsx)(`div`,{className:`bailey-suggestions-title`,children:M.suggestionsTitle}),i.map((e,t)=>(0,p.jsxs)(`button`,{type:`button`,onClick:()=>V(e.value??e.label),className:`bailey-suggestion-card`,children:[(0,p.jsx)(`span`,{children:e.label}),(0,p.jsx)(me,{className:`bailey-suggestion-icon`})]},`${e.label}-${t}`))]}):(0,p.jsx)(`div`,{className:`bailey-empty-state`,children:M.emptyStateMessage})),y.map((e,t)=>{let n=e.role===`assistant`&&t===y.length-1,r=S===`streaming`&&n&&e.content===``,i=e.role===`assistant`&&!r?ue(b,e.createdAt):[],a=i[i.length-1];return(0,p.jsx)(`div`,{className:e.role===`user`?`bailey-message-row bailey-message-row-user`:`bailey-message-row`,children:e.role===`user`?(0,p.jsxs)(`div`,{className:`bailey-user-message`,children:[(0,p.jsxs)(`div`,{className:`bailey-message-meta`,children:[(0,p.jsx)(`span`,{className:`bailey-message-meta-name`,children:M.youLabel}),e.createdAt!==void 0&&(0,p.jsx)(`span`,{children:N(e.createdAt)})]}),(0,p.jsx)(`div`,{className:`bailey-user-bubble`,children:e.content})]}):r?(0,p.jsx)(`div`,{className:`bailey-thinking-hint`,children:R??M.thinkingHint}):(0,p.jsxs)(`div`,{className:`bailey-assistant-message`,children:[a&&(0,p.jsxs)(`div`,{className:`bailey-activity-line`,children:[(0,p.jsx)(`span`,{className:`bailey-activity-icon`,children:o?.(a.toolName)??(0,p.jsx)(_e,{})}),(0,p.jsx)(`span`,{children:a.text})]}),(0,p.jsx)(je,{content:e.content,components:L}),e.streaming&&R&&(0,p.jsx)(`div`,{className:`bailey-streaming-hint`,children:R}),!e.streaming&&(0,p.jsxs)(`div`,{className:`bailey-message-actions`,children:[(0,p.jsx)(ye,{markdown:e.content,ariaLabel:M.copyButtonAriaLabel,tooltipDefaultText:M.copyButtonTooltipDefault,tooltipCopiedText:M.copyButtonTooltipCopied}),m?.(e)]})]})},e.id)}),(0,p.jsx)(`div`,{ref:P})]}),z&&a&&(0,p.jsxs)(`div`,{className:`bailey-privacy-note`,children:[a.text,` `,(0,p.jsx)(`a`,{href:a.linkHref,target:`_blank`,rel:`noreferrer`,children:a.linkLabel})]}),C&&(0,p.jsxs)(`div`,{className:`bailey-error-banner`,role:`alert`,children:[(0,p.jsx)(`span`,{children:C}),(0,p.jsxs)(`div`,{className:`bailey-error-actions`,children:[(0,p.jsx)(`button`,{type:`button`,onClick:E,className:`bailey-retry-button`,children:M.retryButtonText}),(0,p.jsx)(`button`,{type:`button`,onClick:O,"aria-label":M.dismissErrorAriaLabel,className:`bailey-dismiss-button`,children:`✕`})]})]}),!d&&(0,p.jsx)(Ee,{events:b,lastRequest:x,onClear:D}),(0,p.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),!(!A.trim()||S===`streaming`)&&(V(A),j(``))},className:`bailey-input-row`,children:[(0,p.jsx)(`input`,{type:`text`,placeholder:B,"aria-label":B,value:A,onChange:e=>j(e.target.value),disabled:S===`streaming`,className:`bailey-input`}),S===`streaming`?(0,p.jsx)(f.Provider,{delayDuration:200,children:(0,p.jsxs)(f.Root,{children:[(0,p.jsx)(f.Trigger,{asChild:!0,children:(0,p.jsx)(`button`,{type:`button`,onClick:T,"aria-label":M.stopAriaLabel,className:`bailey-stop-button`,children:(0,p.jsx)(pe,{className:`bailey-stop-icon`})})}),(0,p.jsx)(f.Portal,{children:(0,p.jsxs)(f.Content,{side:`top`,className:`bailey-tooltip-content`,children:[M.stopButtonText,(0,p.jsx)(f.Arrow,{className:`bailey-tooltip-arrow`})]})})]})}):(0,p.jsx)(`button`,{type:`submit`,"aria-label":M.sendAriaLabel,disabled:!A.trim(),className:`bailey-send-button`,children:(0,p.jsx)(fe,{className:`bailey-send-icon`})})]})]})})}var Fe=`0.3.1-pre.2`;exports.ActivityIcon=_e,exports.ArrowUpRightIcon=me,exports.BAILEYAI_CHAT_UI_VERSION=Fe,exports.BAILEY_CHART_PROMPT_FRAGMENT=B,exports.BAILEY_TABLE_GRID_ROW_THRESHOLD=M,exports.BaileyChatPanel=Pe,exports.BaileyTracePanel=Ee,exports.CopyMarkdownButton=ye,exports.HeartIcon=fe,exports.TRACE_KIND_LABEL=H,exports.createBaileyMarkdownComponents=de,exports.extractPseudoToolCalls=x,exports.extractTableData=R,exports.formatTraceGap=Z,exports.formatTraceTime=X,exports.hasTraceFailure=le,exports.isSafeMarkdownUrl=c.t,exports.joinInstructions=O,exports.parseBaileyChartSpec=ae,exports.parseSseFrames=C,exports.resolveToolCall=j,exports.shouldUseGrid=z,exports.toActivityLines=ue,exports.toTraceRows=oe,exports.toTraceSegments=ce,exports.traceEventArgsDetail=K,exports.traceEventHint=Y,exports.traceEventOutputDetail=q,exports.traceEventRawDetail=J,exports.traceEventSummary=G,exports.traceEventToolName=W,exports.traceSummaryLine=se,exports.useBaileyChat=D;
|
|
11
|
+
`)}var A=`call_tool`,j=`a tool`;function M(e,t){let n={name:e===A?j: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===A){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 N=5,P=e=>e.type===`text`?e.value??``:(e.children??[]).map(P).join(``),F=e=>{if(e.tagName===`a`&&e.properties?.href)return e.properties.href;for(let t of e.children??[]){let e=F(t);if(e)return e}},I=(e,t)=>(e.children??[]).find(e=>e.tagName===t),L=e=>{let t=P(e),n=F(e);return n?{text:t,href:n}:{text:t}},R=e=>(e.children??[]).filter(e=>e.type===`element`).map(L),z=e=>{if(e.tagName!==`table`)return null;let t=I(e,`thead`),n=t&&I(t,`tr`);return{headers:n?R(n).map(e=>e.text):[],rows:(I(e,`tbody`)?.children??[]).filter(e=>e.tagName===`tr`).map(R)}},B=e=>e.length>5,V='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```',ee=[`bar`,`line`,`pie`,`doughnut`,`scatter`],te=8,ne=50,re=8,ie=500,ae=e=>typeof e==`object`&&!!e&&typeof e.x==`number`&&typeof e.y==`number`,H=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`||!ee.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>te||(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>ie||!e.data.every(ae))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`?re:ne;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}}},U={tool_start:`Tool start`,tool_end:`Tool end`,pseudo_tool_call:`Narrated tool call`,progress:`Progress`,info:`Info`,error:`Error`,raw:`Raw event`};function W(e){return e.kind!==`tool_start`&&e.kind!==`tool_end`?null:M(e.name,e.args)}function G(e,t=W(e)){return e.kind===`pseudo_tool_call`?e.name:t?.name??null}function K(e,t=W(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 q(e,t=W(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 J(e){return e.kind===`tool_end`?e.output??null:null}function oe(e){return e.kind===`raw`?e.raw:e.kind===`error`?e.rawBody??null:null}function Y(e){switch(e.kind){case`tool_start`:return`Calling ${M(e.name,e.args).name}...`;case`tool_end`:{let t=M(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 se(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 ce(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 le(e){return e.map((t,n)=>{let r=W(t),i=n===0?t.turnSentAt:e[n-1].at;return{key:`${t.at}-${n}`,kind:t.kind,toolName:G(t,r),isToolStart:t.kind===`tool_start`,failed:t.kind===`tool_end`&&t.isError===!0,time:se(t.at),gapMs:t.at-i,label:t.kind===`tool_end`&&t.isError===!0?`Tool failed`:U[t.kind],summary:K(t,r),argsDetail:q(t,r),outputDetail:J(t),rawDetail:oe(t)}})}function ue(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 de(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 fe(e){return e.some(e=>e.kind===`tool_end`&&e.isError||e.kind===`error`)}function pe(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:Y(e),toolName:G(e)}))}function me({renderTable:e,renderChart:t}={}){return{a:({href:e,children:t})=>!e||!c.t(e)?(0,p.jsx)(p.Fragment,{children:t}):(0,p.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:t}),table:({node:t,children:n})=>{let r=t&&z(t);if(r&&B(r.rows)&&e){let t=r.rows.map(e=>e.map(e=>e.href&&!c.t(e.href)?{text:e.text}:e));return(0,p.jsx)(p.Fragment,{children:e({headers:r.headers,rows:t})})}return(0,p.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=H(Array.isArray(e)?e.join(``):String(e??``));if(r)return(0,p.jsx)(p.Fragment,{children:t(r)})}return(0,p.jsx)(`pre`,{children:e})}}}function he({className:e}){return(0,p.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,className:e,"aria-hidden":`true`,children:(0,p.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 ge({className:e}){return(0,p.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,className:e,"aria-hidden":`true`,children:(0,p.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}function _e({className:e}){return(0,p.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:e,"aria-hidden":`true`,children:[(0,p.jsx)(`path`,{d:`M7 17 17 7`}),(0,p.jsx)(`path`,{d:`M9 7h8v8`})]})}function ve({className:e}){return(0,p.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:e,"aria-hidden":`true`,children:[(0,p.jsx)(`rect`,{x:`8`,y:`8`,width:`12`,height:`12`,rx:`2`}),(0,p.jsx)(`path`,{d:`M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2`})]})}function ye({className:e}){return(0,p.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:e,"aria-hidden":`true`,children:(0,p.jsx)(`path`,{d:`M5 12.5 9.5 17 19 7`})})}function be({className:e}){return(0,p.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:e,"aria-hidden":`true`,children:[(0,p.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,p.jsx)(`path`,{d:`M8.5 12.5 11 15l4.5-5.5`})]})}var xe=1500;function Se({markdown:e,className:t,ariaLabel:n=`copy response as markdown`,tooltipDefaultText:r=`Copy as markdown`,tooltipCopiedText:i=`Copied!`}){let[a,o]=(0,l.useState)(!1),[s,c]=(0,l.useState)(!1),u=(0,l.useRef)(null);return(0,l.useEffect)(()=>()=>{u.current!==null&&clearTimeout(u.current)},[]),(0,p.jsx)(f.Provider,{delayDuration:200,children:(0,p.jsxs)(f.Root,{open:a||s,onOpenChange:c,children:[(0,p.jsx)(f.Trigger,{asChild:!0,children:(0,p.jsx)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(e)}catch{return}o(!0),u.current!==null&&clearTimeout(u.current),u.current=setTimeout(()=>o(!1),xe)},"aria-label":n,className:`bailey-copy-button${t?` ${t}`:``}`,children:a?(0,p.jsx)(ye,{className:`bailey-copy-icon`}):(0,p.jsx)(ve,{className:`bailey-copy-icon`})})}),(0,p.jsx)(f.Portal,{children:(0,p.jsxs)(f.Content,{side:`top`,className:`bailey-tooltip-content`,children:[a?i:r,(0,p.jsx)(f.Arrow,{className:`bailey-tooltip-arrow`})]})})]})})}async function Ce(e){try{await navigator.clipboard.writeText(e)}catch{}}function X({text:e,label:t=`Copy`}){return(0,p.jsx)(`button`,{type:`button`,onClick:()=>Ce(e),className:`bailey-trace-copy-button`,children:t})}function we(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,p.jsxs)(`details`,{className:`bailey-trace-disclosure`,children:[(0,p.jsx)(`summary`,{className:`bailey-trace-disclosure-summary`,children:e}),n&&(0,p.jsx)(`div`,{className:`bailey-trace-disclosure-actions`,children:(0,p.jsx)(X,{text:t})}),(0,p.jsx)(`pre`,{className:`bailey-trace-disclosure-content`,children:t})]})}function Q({row:e}){return(0,p.jsxs)(`div`,{className:`bailey-trace-row`,children:[(0,p.jsxs)(`div`,{className:`bailey-trace-row-header`,children:[(0,p.jsx)(`span`,{className:`bailey-trace-row-time`,children:e.time}),(0,p.jsx)(`span`,{className:`bailey-trace-row-gap`,title:`Time since the previous event`,children:ce(e.gapMs)}),(0,p.jsx)(`span`,{className:we(e),children:e.label}),(0,p.jsx)(`span`,{className:`bailey-trace-row-summary`,children:e.summary})]}),e.argsDetail&&(0,p.jsx)(Z,{label:`args`,content:e.argsDetail}),e.outputDetail&&(0,p.jsx)(Z,{label:`output`,content:e.outputDetail}),e.rawDetail&&(0,p.jsx)(Z,{label:`raw`,content:e.rawDetail})]})}function Te(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 Ee({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,p.jsxs)(`div`,{className:`bailey-trace-request-details`,children:[(0,p.jsxs)(`span`,{className:`bailey-trace-request-meta`,children:[`Last request — `,e.model,` · `,new Date(e.sentAt).toLocaleTimeString(),e.requestId?` · ${e.requestId}`:``]}),(0,p.jsx)(`span`,{className:`bailey-trace-request-meta`,children:Te(e.streamStats,e.sentAt)}),(0,p.jsx)(Z,{label:`System prompt (${e.systemPrompt.length.toLocaleString()} chars)`,content:e.systemPrompt,copyable:!0}),(0,p.jsx)(Z,{label:`Messages (${e.messages.length})`,content:JSON.stringify(e.messages,null,2),copyable:!0}),e.response&&(0,p.jsx)(Z,{label:`Response (${e.response.content.length.toLocaleString()} chars)`,content:e.response.content,copyable:!0}),(0,p.jsx)(Z,{label:`Full payload (JSON)`,content:t,copyable:!0})]})}function De({events:e,lastRequest:t,onClear:n}){let r=(0,l.useMemo)(()=>le(e),[e]),i=(0,l.useMemo)(()=>de(r),[r]),a=(0,l.useMemo)(()=>JSON.stringify(e,null,2),[e]);return(0,p.jsxs)(`div`,{className:`bailey-trace-body`,children:[(0,p.jsxs)(`div`,{className:`bailey-trace-actions-row`,children:[e.length>0&&(0,p.jsx)(X,{text:a,label:`Copy trace as JSON`}),(0,p.jsx)(`button`,{type:`button`,onClick:n,className:`bailey-trace-copy-button`,children:`Clear`})]}),t&&(0,p.jsx)(Ee,{request:t}),(0,p.jsx)(`div`,{className:`bailey-trace-rows`,children:i.map((e,t)=>{if(e.type===`single`)return(0,p.jsx)(Q,{row:e.row},e.row.key);let n=e.rows.filter(e=>e.isToolStart).length;if(n<=1)return(0,p.jsx)(`div`,{className:`bailey-trace-rows`,children:e.rows.map(e=>(0,p.jsx)(Q,{row:e},e.key))},`group-${t}`);let r=e.rows.filter(e=>e.failed).length;return(0,p.jsxs)(`details`,{className:`bailey-trace-group`,children:[(0,p.jsxs)(`summary`,{className:`bailey-trace-group-summary`,children:[(0,p.jsx)(`strong`,{children:e.toolName}),` × `,n,r>0&&(0,p.jsxs)(`span`,{className:`bailey-trace-group-failed`,children:[` `,r,` failed`]})]}),(0,p.jsx)(`div`,{className:`bailey-trace-rows`,children:e.rows.map(e=>(0,p.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)(()=>fe(e),[e]),o=(0,l.useMemo)(()=>ue(e),[e]);return e.length===0&&!t?null:(0,p.jsxs)(`div`,{className:`bailey-trace-panel`,children:[(0,p.jsxs)(`div`,{className:`bailey-trace-toggle-row`,children:[(0,p.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,p.jsx)(`span`,{className:a?`bailey-trace-summary bailey-trace-summary-error`:`bailey-trace-summary`,children:o})]}),r&&(0,p.jsx)(De,{events:e,lastRequest:t,onClear:n})]})}var Oe=`How can bailey AI help you today?`,ke=`Reply to bailey AI`,Ae={newChatButtonText:`New chat`,newChatAriaLabel:`new chat`,suggestionsTitle:`Suggested for you`,emptyStateMessage:`Ask Bailey a question to get started.`,youLabel:`You`,thinkingHint:`Thinking…`,retryButtonText:`Retry`,dismissErrorAriaLabel:`dismiss error`,sendAriaLabel:`send`,stopButtonText:`Stop`,stopAriaLabel:`stop`,copyButtonAriaLabel:`copy response as markdown`,copyButtonTooltipDefault:`Copy as markdown`,copyButtonTooltipCopied:`Copied!`},je=[d.default],Me=(0,l.memo)(function({content:e,components:t}){return(0,p.jsx)(`div`,{className:`bailey-markdown-content`,children:(0,p.jsx)(u.default,{remarkPlugins:je,components:t,skipHtml:!0,children:e})})});function Ne(e,t,n){if(e!==`streaming`)return;let r=t.filter(e=>e.turnSentAt===n?.sentAt);if(r.length!==0)return Y(r[r.length-1])}function Pe(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 Fe({chat:e,placeholder:t,replyPlaceholder:n=ke,emptyPlaceholder:r,suggestions:i,privacyNote:a,resolveActivityIcon:o,className:s,height:c,width:u,hideDeveloperDetails:d=!1,renderMessageActions:m,renderTable:h,renderChart:g,labels:_,formatMessageTime:v}){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]=(0,l.useState)(``),M={...Ae,..._},N=v??Pe,P=(0,l.useRef)(null),F=(0,l.useRef)(null),I=(0,l.useRef)(!0),L=(0,l.useMemo)(()=>me({renderTable:h,renderChart:g}),[h,g]),R=(0,l.useMemo)(()=>Ne(S,b,x),[S,b,x]),z=y.length===0,B=t??(z?r??Oe:n);(0,l.useEffect)(()=>{let e=F.current;if(!e)return;let t=()=>{let t=e.scrollHeight-e.scrollTop-e.clientHeight;I.current=t<60};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]),(0,l.useEffect)(()=>{I.current&&P.current?.scrollIntoView({behavior:S===`streaming`?`auto`:`smooth`,block:`nearest`})},[y,S]);let V=e=>{I.current=!0,w(e)};return(0,p.jsx)(`div`,{className:`bailey-chat-panel${s?` ${s}`:``}`,style:c!==void 0||u!==void 0?{height:c,width:u}:void 0,children:(0,p.jsxs)(`div`,{className:`bailey-chat-panel-inner`,children:[(0,p.jsx)(`div`,{className:`bailey-toolbar-row`,children:(0,p.jsx)(`button`,{type:`button`,onClick:k,disabled:y.length===0,"aria-label":M.newChatAriaLabel,className:`bailey-new-chat-button`,children:M.newChatButtonText})}),(0,p.jsxs)(`div`,{className:`bailey-chat-transcript`,ref:F,children:[z&&(i&&i.length>0?(0,p.jsxs)(`div`,{className:`bailey-suggestions`,children:[(0,p.jsx)(`div`,{className:`bailey-suggestions-title`,children:M.suggestionsTitle}),i.map((e,t)=>(0,p.jsxs)(`button`,{type:`button`,onClick:()=>V(e.value??e.label),className:`bailey-suggestion-card`,children:[(0,p.jsx)(`span`,{children:e.label}),(0,p.jsx)(_e,{className:`bailey-suggestion-icon`})]},`${e.label}-${t}`))]}):(0,p.jsx)(`div`,{className:`bailey-empty-state`,children:M.emptyStateMessage})),y.map((e,t)=>{let n=e.role===`assistant`&&t===y.length-1,r=S===`streaming`&&n&&e.content===``,i=e.role===`assistant`&&!r?pe(b,e.createdAt):[],a=i[i.length-1];return(0,p.jsx)(`div`,{className:e.role===`user`?`bailey-message-row bailey-message-row-user`:`bailey-message-row`,children:e.role===`user`?(0,p.jsxs)(`div`,{className:`bailey-user-message`,children:[(0,p.jsxs)(`div`,{className:`bailey-message-meta`,children:[(0,p.jsx)(`span`,{className:`bailey-message-meta-name`,children:M.youLabel}),e.createdAt!==void 0&&(0,p.jsx)(`span`,{children:N(e.createdAt)})]}),(0,p.jsx)(`div`,{className:`bailey-user-bubble`,children:e.content})]}):r?(0,p.jsx)(`div`,{className:`bailey-thinking-hint`,children:R??M.thinkingHint}):(0,p.jsxs)(`div`,{className:`bailey-assistant-message`,children:[a&&(0,p.jsxs)(`div`,{className:`bailey-activity-line`,children:[(0,p.jsx)(`span`,{className:`bailey-activity-icon`,children:o?.(a.toolName)??(0,p.jsx)(be,{})}),(0,p.jsx)(`span`,{children:a.text})]}),(0,p.jsx)(Me,{content:e.content,components:L}),e.streaming&&R&&(0,p.jsx)(`div`,{className:`bailey-streaming-hint`,children:R}),!e.streaming&&(0,p.jsxs)(`div`,{className:`bailey-message-actions`,children:[(0,p.jsx)(Se,{markdown:e.content,ariaLabel:M.copyButtonAriaLabel,tooltipDefaultText:M.copyButtonTooltipDefault,tooltipCopiedText:M.copyButtonTooltipCopied}),m?.(e)]})]})},e.id)}),(0,p.jsx)(`div`,{ref:P})]}),z&&a&&(0,p.jsxs)(`div`,{className:`bailey-privacy-note`,children:[a.text,` `,(0,p.jsx)(`a`,{href:a.linkHref,target:`_blank`,rel:`noreferrer`,children:a.linkLabel})]}),C&&(0,p.jsxs)(`div`,{className:`bailey-error-banner`,role:`alert`,children:[(0,p.jsx)(`span`,{children:C}),(0,p.jsxs)(`div`,{className:`bailey-error-actions`,children:[(0,p.jsx)(`button`,{type:`button`,onClick:E,className:`bailey-retry-button`,children:M.retryButtonText}),(0,p.jsx)(`button`,{type:`button`,onClick:O,"aria-label":M.dismissErrorAriaLabel,className:`bailey-dismiss-button`,children:`✕`})]})]}),!d&&(0,p.jsx)($,{events:b,lastRequest:x,onClear:D}),(0,p.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),!(!A.trim()||S===`streaming`)&&(V(A),j(``))},className:`bailey-input-row`,children:[(0,p.jsx)(`input`,{type:`text`,placeholder:B,"aria-label":B,value:A,onChange:e=>j(e.target.value),disabled:S===`streaming`,className:`bailey-input`}),S===`streaming`?(0,p.jsx)(f.Provider,{delayDuration:200,children:(0,p.jsxs)(f.Root,{children:[(0,p.jsx)(f.Trigger,{asChild:!0,children:(0,p.jsx)(`button`,{type:`button`,onClick:T,"aria-label":M.stopAriaLabel,className:`bailey-stop-button`,children:(0,p.jsx)(ge,{className:`bailey-stop-icon`})})}),(0,p.jsx)(f.Portal,{children:(0,p.jsxs)(f.Content,{side:`top`,className:`bailey-tooltip-content`,children:[M.stopButtonText,(0,p.jsx)(f.Arrow,{className:`bailey-tooltip-arrow`})]})})]})}):(0,p.jsx)(`button`,{type:`submit`,"aria-label":M.sendAriaLabel,disabled:!A.trim(),className:`bailey-send-button`,children:(0,p.jsx)(he,{className:`bailey-send-icon`})})]})]})})}var Ie=`0.3.1-pre.2`;exports.ActivityIcon=be,exports.ArrowUpRightIcon=_e,exports.BAILEYAI_CHAT_UI_VERSION=Ie,exports.BAILEY_CHART_PROMPT_FRAGMENT=V,exports.BAILEY_TABLE_GRID_ROW_THRESHOLD=N,exports.BaileyChatPanel=Fe,exports.BaileyTracePanel=$,exports.CopyMarkdownButton=Se,exports.HeartIcon=he,exports.TRACE_KIND_LABEL=U,exports.createBaileyMarkdownComponents=me,exports.extractPseudoToolCalls=x,exports.extractTableData=z,exports.formatTraceGap=ce,exports.formatTraceTime=se,exports.hasTraceFailure=fe,exports.isSafeMarkdownUrl=c.t,exports.joinInstructions=k,exports.parseBaileyChartSpec=H,exports.parseSseFrames=C,exports.resolveToolCall=M,exports.shouldUseGrid=B,exports.toActivityLines=pe,exports.toTraceRows=le,exports.toTraceSegments=de,exports.traceEventArgsDetail=q,exports.traceEventHint=Y,exports.traceEventOutputDetail=J,exports.traceEventRawDetail=oe,exports.traceEventSummary=K,exports.traceEventToolName=G,exports.traceSummaryLine=ue,exports.useBaileyChat=O;
|
|
@@ -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-font-weight: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-border-style:solid;--tw-leading:initial;--tw-space-y-reverse:0}}}@layer theme{.bailey-chat-panel{--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-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;--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;.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{height:calc(var(--spacing) * 9);width:calc(var(--spacing) * 9);--tw-border-style:none;color:var(--color-bailey-error);border-style:none}@media (hover:hover){.bailey-stop-button:hover{background-color:#d32f2f1a}@supports (color:color-mix(in lab, red, red)){.bailey-stop-button:hover{background-color:color-mix(in oklab, var(--color-bailey-error) 10%, transparent)}}}.bailey-stop-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4)}.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{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));background-color:var(--color-bailey-tooltip-bg,#000);color:var(--color-bailey-tooltip-text,#fff);border-radius:.25rem}.bailey-tooltip-arrow{fill:var(--color-bailey-tooltip-bg,#000)}.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-font-weight{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-border-style{syntax:"*";inherits:false;initial-value:solid}@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-font-weight: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-border-style:solid;--tw-leading:initial;--tw-space-y-reverse:0}}}@layer theme{.bailey-chat-panel{--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-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;--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;.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);flex-direction:column;display:flex}.bailey-chat-panel-inner{width:100%;min-height:0;max-width:var(--container-3xl);gap:calc(var(--spacing) * 2);flex-direction:column;flex:1;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{height:calc(var(--spacing) * 9);width:calc(var(--spacing) * 9);--tw-border-style:none;color:var(--color-bailey-error);border-style:none}@media (hover:hover){.bailey-stop-button:hover{background-color:#d32f2f1a}@supports (color:color-mix(in lab, red, red)){.bailey-stop-button:hover{background-color:color-mix(in oklab, var(--color-bailey-error) 10%, transparent)}}}.bailey-stop-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4)}.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{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));background-color:var(--color-bailey-tooltip-bg,#000);color:var(--color-bailey-tooltip-text,#fff);border-radius:.25rem}.bailey-tooltip-arrow{fill:var(--color-bailey-tooltip-bg,#000)}.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-font-weight{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-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}
|
|
3
3
|
/*$vite$:1*/
|
package/dist/baileyai-chat-ui.js
CHANGED
|
@@ -105,38 +105,42 @@ function S(e) {
|
|
|
105
105
|
}
|
|
106
106
|
//#endregion
|
|
107
107
|
//#region src/logic/useBaileyChat.ts
|
|
108
|
-
var C = 200, w = 15e4, T = (e, t, n) => {
|
|
108
|
+
var C = 200, w = 15e4, T = () => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `bailey-${Date.now()}-${Math.random().toString(36).slice(2)}`, E = (e, t, n) => {
|
|
109
109
|
if (e === 401 || e === 403) return "Bailey isn't reachable with your current login.";
|
|
110
110
|
let r = `Bailey request failed (status ${e ?? "network error"}).`, i = (n || t || "").trim();
|
|
111
111
|
return i ? `${r} ${i.length > C ? `${i.slice(0, C)}…` : i}` : r;
|
|
112
|
-
},
|
|
113
|
-
let [f, p] = o([]), [m, h] = o([]), [g, _] = o(null), [v, y] = o("idle"), [x, C] = o(null),
|
|
112
|
+
}, D = ({ transport: e, model: t, instructions: i, tools: s = [], toolChoice: c, firstUserMessagePrefix: l, onAssistantMessageComplete: u, idleTimeoutMs: d = w }) => {
|
|
113
|
+
let [f, p] = o([]), [m, h] = o([]), [g, _] = o(null), [v, y] = o("idle"), [x, C] = o(null), D = a(null), O = a(""), k = a(0), A = a([]);
|
|
114
114
|
r(() => {
|
|
115
|
-
|
|
115
|
+
A.current = f;
|
|
116
116
|
}, [f]);
|
|
117
|
-
let
|
|
118
|
-
|
|
119
|
-
}, []),
|
|
120
|
-
|
|
117
|
+
let j = a([]), M = a(/* @__PURE__ */ new Map()), N = a(/* @__PURE__ */ new Map()), P = a(null), F = n(() => {
|
|
118
|
+
P.current !== null && (clearTimeout(P.current), P.current = null);
|
|
119
|
+
}, []), I = n((e) => {
|
|
120
|
+
F(), P.current = setTimeout(() => {
|
|
121
121
|
e.abort(new DOMException("The assistant took too long to respond. Please try again.", "TimeoutError"));
|
|
122
122
|
}, d);
|
|
123
|
-
}, [
|
|
123
|
+
}, [F, d]);
|
|
124
|
+
r(() => () => {
|
|
125
|
+
D.current?.abort(), F();
|
|
126
|
+
}, [F]);
|
|
127
|
+
let L = n((e, t, n) => {
|
|
124
128
|
let r = (e) => {
|
|
125
129
|
n.push(e), h((t) => [...t, e]);
|
|
126
130
|
};
|
|
127
131
|
if (t.type === "response.output_text.delta") {
|
|
128
132
|
if (!t.delta) return !1;
|
|
129
|
-
let n =
|
|
133
|
+
let n = M.current.get(e) ?? {
|
|
130
134
|
raw: "",
|
|
131
135
|
emittedCount: 0
|
|
132
136
|
};
|
|
133
137
|
n.raw += t.delta;
|
|
134
138
|
let { cleanedText: i, matches: a } = b(n.raw), o = i.trim(), s = a.slice(n.emittedCount);
|
|
135
|
-
if (n.emittedCount = a.length,
|
|
139
|
+
if (n.emittedCount = a.length, M.current.set(e, n), N.current.set(e, o), p((t) => t.map((t) => t.id === e ? {
|
|
136
140
|
...t,
|
|
137
141
|
content: o
|
|
138
142
|
} : t)), s.length > 0) {
|
|
139
|
-
let e = Date.now(), t =
|
|
143
|
+
let e = Date.now(), t = k.current;
|
|
140
144
|
s.forEach((n) => r({
|
|
141
145
|
kind: "pseudo_tool_call",
|
|
142
146
|
name: n.name,
|
|
@@ -150,7 +154,7 @@ var C = 200, w = 15e4, T = (e, t, n) => {
|
|
|
150
154
|
if (t.type === "response.output_item.added" || t.type === "response.output_item.done") {
|
|
151
155
|
let e = t.item;
|
|
152
156
|
if (e.type === "function_call" || e.type === "mcp_call") {
|
|
153
|
-
let n = Date.now(), i =
|
|
157
|
+
let n = Date.now(), i = k.current, a = e.name || "unknown_tool";
|
|
154
158
|
return r(t.type === "response.output_item.added" ? {
|
|
155
159
|
kind: "tool_start",
|
|
156
160
|
name: a,
|
|
@@ -175,31 +179,31 @@ var C = 200, w = 15e4, T = (e, t, n) => {
|
|
|
175
179
|
status: t.status,
|
|
176
180
|
message: t.message,
|
|
177
181
|
at: Date.now(),
|
|
178
|
-
turnSentAt:
|
|
182
|
+
turnSentAt: k.current
|
|
179
183
|
}), !0) : t.type === "response.output_text.done" || t.type === "response.created" || t.type === "response.completed" ? !1 : t.type === "info" ? (r({
|
|
180
184
|
kind: "info",
|
|
181
185
|
message: t.message,
|
|
182
186
|
at: Date.now(),
|
|
183
|
-
turnSentAt:
|
|
187
|
+
turnSentAt: k.current
|
|
184
188
|
}), !0) : (r({
|
|
185
189
|
kind: "raw",
|
|
186
190
|
eventType: t.type,
|
|
187
191
|
raw: JSON.stringify(t),
|
|
188
192
|
at: Date.now(),
|
|
189
|
-
turnSentAt:
|
|
193
|
+
turnSentAt: k.current
|
|
190
194
|
}), !0);
|
|
191
|
-
}, []),
|
|
195
|
+
}, []), R = n(async (n) => {
|
|
192
196
|
y("streaming"), C(null);
|
|
193
197
|
let r = Date.now();
|
|
194
|
-
|
|
195
|
-
let a =
|
|
198
|
+
k.current = r;
|
|
199
|
+
let a = T(), o = {
|
|
196
200
|
id: a,
|
|
197
201
|
role: "assistant",
|
|
198
202
|
content: "",
|
|
199
203
|
streaming: !0,
|
|
200
204
|
createdAt: r
|
|
201
205
|
};
|
|
202
|
-
p((e) => [...e, o]),
|
|
206
|
+
p((e) => [...e, o]), j.current = [...n, o];
|
|
203
207
|
let d = n.findIndex((e) => e.role === "user" && !e.hidden), f = n.map((e, t) => t === d && l ? {
|
|
204
208
|
role: e.role,
|
|
205
209
|
content: `${l}${e.content}`
|
|
@@ -222,8 +226,8 @@ var C = 200, w = 15e4, T = (e, t, n) => {
|
|
|
222
226
|
}
|
|
223
227
|
});
|
|
224
228
|
let m = new AbortController();
|
|
225
|
-
|
|
226
|
-
let g = "", v = null, b = !1, x = !1, w = [],
|
|
229
|
+
D.current = m, I(m);
|
|
230
|
+
let g = "", v = null, b = !1, x = !1, w = [], O = (e, t) => {
|
|
227
231
|
y("error"), C(e);
|
|
228
232
|
let n = {
|
|
229
233
|
kind: "error",
|
|
@@ -233,7 +237,7 @@ var C = 200, w = 15e4, T = (e, t, n) => {
|
|
|
233
237
|
...t
|
|
234
238
|
};
|
|
235
239
|
w.push(n), h((e) => [...e, n]);
|
|
236
|
-
},
|
|
240
|
+
}, A = (e, t) => {
|
|
237
241
|
e.forEach((e) => {
|
|
238
242
|
if (e.type === "error") {
|
|
239
243
|
v = e.message;
|
|
@@ -246,7 +250,7 @@ var C = 200, w = 15e4, T = (e, t, n) => {
|
|
|
246
250
|
w.push(t), h((e) => [...e, t]);
|
|
247
251
|
return;
|
|
248
252
|
}
|
|
249
|
-
e.type === "response.output_text.delta" && e.delta && (x = !0),
|
|
253
|
+
e.type === "response.output_text.delta" && e.delta && (x = !0), L(a, e, w) && (b = !0);
|
|
250
254
|
}), t && p((e) => e.map((e) => e.id === a ? {
|
|
251
255
|
...e,
|
|
252
256
|
streaming: !1
|
|
@@ -261,9 +265,9 @@ var C = 200, w = 15e4, T = (e, t, n) => {
|
|
|
261
265
|
toolChoice: c,
|
|
262
266
|
signal: m.signal,
|
|
263
267
|
onChunk: (e) => {
|
|
264
|
-
|
|
268
|
+
I(m), g += e;
|
|
265
269
|
let { events: t, remainder: n, done: i } = S(g);
|
|
266
|
-
g = n,
|
|
270
|
+
g = n, A(t, i);
|
|
267
271
|
let a = Date.now();
|
|
268
272
|
_((e) => e && e.sentAt === r ? {
|
|
269
273
|
...e,
|
|
@@ -283,29 +287,29 @@ var C = 200, w = 15e4, T = (e, t, n) => {
|
|
|
283
287
|
});
|
|
284
288
|
if (g.trim()) {
|
|
285
289
|
let { events: e, done: t } = S(`${g}\n\n`);
|
|
286
|
-
g = "",
|
|
290
|
+
g = "", A(e, t);
|
|
287
291
|
}
|
|
288
292
|
if (v) {
|
|
289
293
|
y("error"), C(v);
|
|
290
294
|
return;
|
|
291
295
|
}
|
|
292
296
|
if (n === void 0 || n >= 400) {
|
|
293
|
-
|
|
297
|
+
O(E(n, o, l), {
|
|
294
298
|
httpStatus: n,
|
|
295
299
|
rawBody: o || void 0
|
|
296
300
|
});
|
|
297
301
|
return;
|
|
298
302
|
}
|
|
299
303
|
if (!b) {
|
|
300
|
-
|
|
304
|
+
O("Bailey returned an empty response.");
|
|
301
305
|
return;
|
|
302
306
|
}
|
|
303
307
|
if (!x) {
|
|
304
|
-
|
|
308
|
+
O("Bailey ran some tools but didn't return an answer. Try asking again.");
|
|
305
309
|
return;
|
|
306
310
|
}
|
|
307
311
|
y("idle");
|
|
308
|
-
let d =
|
|
312
|
+
let d = N.current.get(a) ?? "";
|
|
309
313
|
_((e) => e && e.sentAt === r ? {
|
|
310
314
|
...e,
|
|
311
315
|
response: { content: d }
|
|
@@ -318,21 +322,21 @@ var C = 200, w = 15e4, T = (e, t, n) => {
|
|
|
318
322
|
} catch (e) {
|
|
319
323
|
let t = e;
|
|
320
324
|
if (t?.name === "TimeoutError") {
|
|
321
|
-
|
|
325
|
+
O(t.message, { source: "client-timeout" });
|
|
322
326
|
return;
|
|
323
327
|
}
|
|
324
328
|
if (t?.name === "AbortError") {
|
|
325
329
|
y("idle");
|
|
326
330
|
return;
|
|
327
331
|
}
|
|
328
|
-
|
|
332
|
+
O(t?.message || "Bailey request failed.");
|
|
329
333
|
} finally {
|
|
330
|
-
|
|
331
|
-
let e =
|
|
332
|
-
|
|
334
|
+
F();
|
|
335
|
+
let e = N.current.get(a) ?? "";
|
|
336
|
+
M.current.delete(a), N.current.delete(a), p((e) => e.flatMap((e) => e.id === a ? e.content ? [{
|
|
333
337
|
...e,
|
|
334
338
|
streaming: !1
|
|
335
|
-
}] : [] : [e])),
|
|
339
|
+
}] : [] : [e])), j.current = j.current.flatMap((t) => t.id === a ? e ? [{
|
|
336
340
|
...t,
|
|
337
341
|
content: e,
|
|
338
342
|
streaming: !1
|
|
@@ -346,11 +350,11 @@ var C = 200, w = 15e4, T = (e, t, n) => {
|
|
|
346
350
|
c,
|
|
347
351
|
l,
|
|
348
352
|
u,
|
|
353
|
+
L,
|
|
349
354
|
I,
|
|
350
|
-
F
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
k.current = e, p(e);
|
|
355
|
+
F
|
|
356
|
+
]), z = n((e) => {
|
|
357
|
+
A.current = e, p(e);
|
|
354
358
|
}, []);
|
|
355
359
|
return {
|
|
356
360
|
messages: f,
|
|
@@ -361,41 +365,41 @@ var C = 200, w = 15e4, T = (e, t, n) => {
|
|
|
361
365
|
send: n((e) => {
|
|
362
366
|
let t = e.trim();
|
|
363
367
|
if (!t) return;
|
|
364
|
-
|
|
368
|
+
O.current = t;
|
|
365
369
|
let n = {
|
|
366
|
-
id:
|
|
370
|
+
id: T(),
|
|
367
371
|
role: "user",
|
|
368
372
|
content: t,
|
|
369
373
|
createdAt: Date.now()
|
|
370
|
-
}, r = [...
|
|
371
|
-
|
|
372
|
-
}, [
|
|
374
|
+
}, r = [...j.current, n];
|
|
375
|
+
j.current = r, z([...A.current, n]), R(r);
|
|
376
|
+
}, [R, z]),
|
|
373
377
|
sendHidden: n((e) => {
|
|
374
378
|
if (v === "streaming") return;
|
|
375
379
|
let t = e.trim();
|
|
376
380
|
if (!t) return;
|
|
377
|
-
|
|
381
|
+
O.current = t;
|
|
378
382
|
let n = {
|
|
379
|
-
id:
|
|
383
|
+
id: T(),
|
|
380
384
|
role: "user",
|
|
381
385
|
content: t,
|
|
382
386
|
createdAt: Date.now(),
|
|
383
387
|
hidden: !0
|
|
384
|
-
}, r = [...
|
|
385
|
-
|
|
386
|
-
}, [
|
|
388
|
+
}, r = [...j.current, n];
|
|
389
|
+
j.current = r, R(r);
|
|
390
|
+
}, [R, v]),
|
|
387
391
|
stop: n(() => {
|
|
388
|
-
|
|
392
|
+
D.current?.abort();
|
|
389
393
|
}, []),
|
|
390
394
|
retryLast: n(() => {
|
|
391
|
-
if (v === "streaming" || !
|
|
392
|
-
let e =
|
|
393
|
-
|
|
394
|
-
let r =
|
|
395
|
-
|
|
395
|
+
if (v === "streaming" || !O.current) return;
|
|
396
|
+
let e = A.current, t = e[e.length - 1], n = t && t.role === "assistant" ? e.slice(0, -1) : e;
|
|
397
|
+
z(n);
|
|
398
|
+
let r = j.current, i = r[r.length - 1], a = i && i.role === "assistant" ? r.slice(0, -1) : r;
|
|
399
|
+
j.current = a, R(a);
|
|
396
400
|
}, [
|
|
397
|
-
L,
|
|
398
401
|
R,
|
|
402
|
+
z,
|
|
399
403
|
v
|
|
400
404
|
]),
|
|
401
405
|
clearTrace: n(() => h([]), []),
|
|
@@ -403,21 +407,21 @@ var C = 200, w = 15e4, T = (e, t, n) => {
|
|
|
403
407
|
C(null), y((e) => e === "error" ? "idle" : e);
|
|
404
408
|
}, []),
|
|
405
409
|
newChat: n(() => {
|
|
406
|
-
|
|
407
|
-
}, [
|
|
410
|
+
D.current?.abort(), z([]), j.current = [], h([]), _(null), y("idle"), C(null), O.current = "";
|
|
411
|
+
}, [z])
|
|
408
412
|
};
|
|
409
413
|
};
|
|
410
414
|
//#endregion
|
|
411
415
|
//#region src/utils/prompt.ts
|
|
412
|
-
function
|
|
416
|
+
function O(...e) {
|
|
413
417
|
return e.filter((e) => !!(e && e.trim())).join("\n\n");
|
|
414
418
|
}
|
|
415
419
|
//#endregion
|
|
416
420
|
//#region src/utils/toolCalls.ts
|
|
417
|
-
var
|
|
418
|
-
function
|
|
421
|
+
var k = "call_tool", A = "a tool";
|
|
422
|
+
function j(e, t) {
|
|
419
423
|
let n = {
|
|
420
|
-
name: e ===
|
|
424
|
+
name: e === k ? A : e,
|
|
421
425
|
args: null,
|
|
422
426
|
viaCallTool: !1
|
|
423
427
|
};
|
|
@@ -430,7 +434,7 @@ function A(e, t) {
|
|
|
430
434
|
}
|
|
431
435
|
if (typeof r != "object" || !r) return n;
|
|
432
436
|
let i = r;
|
|
433
|
-
if (e ===
|
|
437
|
+
if (e === k) {
|
|
434
438
|
let e = typeof i.name == "string" ? i.name : void 0;
|
|
435
439
|
if (!e) return n;
|
|
436
440
|
let t = i.arguments;
|
|
@@ -448,32 +452,32 @@ function A(e, t) {
|
|
|
448
452
|
}
|
|
449
453
|
//#endregion
|
|
450
454
|
//#region src/utils/table.ts
|
|
451
|
-
var
|
|
455
|
+
var M = 5, N = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map(N).join(""), P = (e) => {
|
|
452
456
|
if (e.tagName === "a" && e.properties?.href) return e.properties.href;
|
|
453
457
|
for (let t of e.children ?? []) {
|
|
454
|
-
let e =
|
|
458
|
+
let e = P(t);
|
|
455
459
|
if (e) return e;
|
|
456
460
|
}
|
|
457
|
-
},
|
|
458
|
-
let t =
|
|
461
|
+
}, F = (e, t) => (e.children ?? []).find((e) => e.tagName === t), I = (e) => {
|
|
462
|
+
let t = N(e), n = P(e);
|
|
459
463
|
return n ? {
|
|
460
464
|
text: t,
|
|
461
465
|
href: n
|
|
462
466
|
} : { text: t };
|
|
463
|
-
},
|
|
467
|
+
}, L = (e) => (e.children ?? []).filter((e) => e.type === "element").map(I), R = (e) => {
|
|
464
468
|
if (e.tagName !== "table") return null;
|
|
465
|
-
let t =
|
|
469
|
+
let t = F(e, "thead"), n = t && F(t, "tr");
|
|
466
470
|
return {
|
|
467
|
-
headers: n ?
|
|
468
|
-
rows: (
|
|
471
|
+
headers: n ? L(n).map((e) => e.text) : [],
|
|
472
|
+
rows: (F(e, "tbody")?.children ?? []).filter((e) => e.tagName === "tr").map(L)
|
|
469
473
|
};
|
|
470
|
-
},
|
|
474
|
+
}, z = (e) => e.length > 5, B = "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```", ee = [
|
|
471
475
|
"bar",
|
|
472
476
|
"line",
|
|
473
477
|
"pie",
|
|
474
478
|
"doughnut",
|
|
475
479
|
"scatter"
|
|
476
|
-
], V = 8, H = 50, U = 8, W = 500,
|
|
480
|
+
], V = 8, H = 50, U = 8, W = 500, te = (e) => typeof e == "object" && !!e && typeof e.x == "number" && typeof e.y == "number", ne = (e) => {
|
|
477
481
|
let t;
|
|
478
482
|
try {
|
|
479
483
|
t = JSON.parse(e);
|
|
@@ -482,7 +486,7 @@ var j = 5, M = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
|
|
|
482
486
|
}
|
|
483
487
|
if (typeof t != "object" || !t) return null;
|
|
484
488
|
let n = t;
|
|
485
|
-
if (typeof n.type != "string" || !
|
|
489
|
+
if (typeof n.type != "string" || !ee.includes(n.type)) return null;
|
|
486
490
|
let r = n.type;
|
|
487
491
|
if (n.title !== void 0 && typeof n.title != "string") return null;
|
|
488
492
|
let i = n.title;
|
|
@@ -492,7 +496,7 @@ var j = 5, M = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
|
|
|
492
496
|
for (let e of a.datasets) if (typeof e != "object" || !e || typeof e.label != "string" || !Array.isArray(e.data)) return null;
|
|
493
497
|
let o = a.datasets;
|
|
494
498
|
if (r === "scatter") {
|
|
495
|
-
for (let e of o) if (e.data.length < 1 || e.data.length > W || !e.data.every(
|
|
499
|
+
for (let e of o) if (e.data.length < 1 || e.data.length > W || !e.data.every(te)) return null;
|
|
496
500
|
return {
|
|
497
501
|
type: r,
|
|
498
502
|
title: i,
|
|
@@ -511,7 +515,7 @@ var j = 5, M = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
|
|
|
511
515
|
datasets: o
|
|
512
516
|
}
|
|
513
517
|
};
|
|
514
|
-
},
|
|
518
|
+
}, re = {
|
|
515
519
|
tool_start: "Tool start",
|
|
516
520
|
tool_end: "Tool end",
|
|
517
521
|
pseudo_tool_call: "Narrated tool call",
|
|
@@ -520,13 +524,13 @@ var j = 5, M = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
|
|
|
520
524
|
error: "Error",
|
|
521
525
|
raw: "Raw event"
|
|
522
526
|
};
|
|
523
|
-
function
|
|
524
|
-
return e.kind !== "tool_start" && e.kind !== "tool_end" ? null :
|
|
527
|
+
function G(e) {
|
|
528
|
+
return e.kind !== "tool_start" && e.kind !== "tool_end" ? null : j(e.name, e.args);
|
|
525
529
|
}
|
|
526
|
-
function
|
|
530
|
+
function K(e, t = G(e)) {
|
|
527
531
|
return e.kind === "pseudo_tool_call" ? e.name : t?.name ?? null;
|
|
528
532
|
}
|
|
529
|
-
function
|
|
533
|
+
function q(e, t = G(e)) {
|
|
530
534
|
switch (e.kind) {
|
|
531
535
|
case "tool_start": return t.viaCallTool ? `${t.name} (via call_tool)` : t.name;
|
|
532
536
|
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" : ""}`;
|
|
@@ -537,20 +541,20 @@ function ne(e, t = K(e)) {
|
|
|
537
541
|
case "raw": return `Unrecognized event: ${e.eventType}`;
|
|
538
542
|
}
|
|
539
543
|
}
|
|
540
|
-
function
|
|
544
|
+
function J(e, t = G(e)) {
|
|
541
545
|
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;
|
|
542
546
|
}
|
|
543
|
-
function
|
|
547
|
+
function Y(e) {
|
|
544
548
|
return e.kind === "tool_end" ? e.output ?? null : null;
|
|
545
549
|
}
|
|
546
|
-
function
|
|
550
|
+
function X(e) {
|
|
547
551
|
return e.kind === "raw" ? e.raw : e.kind === "error" ? e.rawBody ?? null : null;
|
|
548
552
|
}
|
|
549
|
-
function
|
|
553
|
+
function Z(e) {
|
|
550
554
|
switch (e.kind) {
|
|
551
|
-
case "tool_start": return `Calling ${
|
|
555
|
+
case "tool_start": return `Calling ${j(e.name, e.args).name}...`;
|
|
552
556
|
case "tool_end": {
|
|
553
|
-
let t =
|
|
557
|
+
let t = j(e.name, e.args).name;
|
|
554
558
|
return e.isError ? `${t} failed` : `${t} returned`;
|
|
555
559
|
}
|
|
556
560
|
case "pseudo_tool_call": return `${e.name} (written as text, not called)`;
|
|
@@ -574,20 +578,20 @@ function ae(e) {
|
|
|
574
578
|
}
|
|
575
579
|
function oe(e) {
|
|
576
580
|
return e.map((t, n) => {
|
|
577
|
-
let r =
|
|
581
|
+
let r = G(t), i = n === 0 ? t.turnSentAt : e[n - 1].at;
|
|
578
582
|
return {
|
|
579
583
|
key: `${t.at}-${n}`,
|
|
580
584
|
kind: t.kind,
|
|
581
|
-
toolName:
|
|
585
|
+
toolName: K(t, r),
|
|
582
586
|
isToolStart: t.kind === "tool_start",
|
|
583
587
|
failed: t.kind === "tool_end" && t.isError === !0,
|
|
584
588
|
time: ie(t.at),
|
|
585
589
|
gapMs: t.at - i,
|
|
586
|
-
label: t.kind === "tool_end" && t.isError === !0 ? "Tool failed" :
|
|
587
|
-
summary:
|
|
588
|
-
argsDetail:
|
|
589
|
-
outputDetail:
|
|
590
|
-
rawDetail:
|
|
590
|
+
label: t.kind === "tool_end" && t.isError === !0 ? "Tool failed" : re[t.kind],
|
|
591
|
+
summary: q(t, r),
|
|
592
|
+
argsDetail: J(t, r),
|
|
593
|
+
outputDetail: Y(t),
|
|
594
|
+
rawDetail: X(t)
|
|
591
595
|
};
|
|
592
596
|
});
|
|
593
597
|
}
|
|
@@ -620,8 +624,8 @@ function le(e) {
|
|
|
620
624
|
function ue(e, t) {
|
|
621
625
|
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) => ({
|
|
622
626
|
key: `${e.at}-${t}`,
|
|
623
|
-
text:
|
|
624
|
-
toolName:
|
|
627
|
+
text: Z(e),
|
|
628
|
+
toolName: K(e)
|
|
625
629
|
}));
|
|
626
630
|
}
|
|
627
631
|
//#endregion
|
|
@@ -635,8 +639,8 @@ function de({ renderTable: t, renderChart: n } = {}) {
|
|
|
635
639
|
children: n
|
|
636
640
|
}),
|
|
637
641
|
table: ({ node: n, children: r }) => {
|
|
638
|
-
let i = n &&
|
|
639
|
-
if (i &&
|
|
642
|
+
let i = n && R(n);
|
|
643
|
+
if (i && z(i.rows) && t) {
|
|
640
644
|
let n = i.rows.map((t) => t.map((t) => t.href && !e(t.href) ? { text: t.text } : t));
|
|
641
645
|
return /* @__PURE__ */ d(u, { children: t({
|
|
642
646
|
headers: i.headers,
|
|
@@ -648,7 +652,7 @@ function de({ renderTable: t, renderChart: n } = {}) {
|
|
|
648
652
|
pre: ({ children: e }) => {
|
|
649
653
|
let t = (Array.isArray(e) ? e[0] : e)?.props;
|
|
650
654
|
if ((t?.className?.split(" ") ?? []).includes("language-chartjs") && n) {
|
|
651
|
-
let e = t?.children, r =
|
|
655
|
+
let e = t?.children, r = ne(Array.isArray(e) ? e.join("") : String(e ?? ""));
|
|
652
656
|
if (r) return /* @__PURE__ */ d(u, { children: n(r) });
|
|
653
657
|
}
|
|
654
658
|
return /* @__PURE__ */ d("pre", { children: e });
|
|
@@ -681,7 +685,7 @@ function pe({ className: e }) {
|
|
|
681
685
|
})
|
|
682
686
|
});
|
|
683
687
|
}
|
|
684
|
-
function
|
|
688
|
+
function me({ className: e }) {
|
|
685
689
|
return /* @__PURE__ */ f("svg", {
|
|
686
690
|
viewBox: "0 0 24 24",
|
|
687
691
|
fill: "none",
|
|
@@ -694,7 +698,7 @@ function Z({ className: e }) {
|
|
|
694
698
|
children: [/* @__PURE__ */ d("path", { d: "M7 17 17 7" }), /* @__PURE__ */ d("path", { d: "M9 7h8v8" })]
|
|
695
699
|
});
|
|
696
700
|
}
|
|
697
|
-
function
|
|
701
|
+
function he({ className: e }) {
|
|
698
702
|
return /* @__PURE__ */ f("svg", {
|
|
699
703
|
viewBox: "0 0 24 24",
|
|
700
704
|
fill: "none",
|
|
@@ -713,7 +717,7 @@ function me({ className: e }) {
|
|
|
713
717
|
}), /* @__PURE__ */ d("path", { d: "M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2" })]
|
|
714
718
|
});
|
|
715
719
|
}
|
|
716
|
-
function
|
|
720
|
+
function ge({ className: e }) {
|
|
717
721
|
return /* @__PURE__ */ d("svg", {
|
|
718
722
|
viewBox: "0 0 24 24",
|
|
719
723
|
fill: "none",
|
|
@@ -726,7 +730,7 @@ function he({ className: e }) {
|
|
|
726
730
|
children: /* @__PURE__ */ d("path", { d: "M5 12.5 9.5 17 19 7" })
|
|
727
731
|
});
|
|
728
732
|
}
|
|
729
|
-
function
|
|
733
|
+
function _e({ className: e }) {
|
|
730
734
|
return /* @__PURE__ */ f("svg", {
|
|
731
735
|
viewBox: "0 0 24 24",
|
|
732
736
|
fill: "none",
|
|
@@ -745,8 +749,8 @@ function ge({ className: e }) {
|
|
|
745
749
|
}
|
|
746
750
|
//#endregion
|
|
747
751
|
//#region src/ui/CopyMarkdownButton.tsx
|
|
748
|
-
var
|
|
749
|
-
function
|
|
752
|
+
var ve = 1500;
|
|
753
|
+
function ye({ markdown: e, className: t, ariaLabel: n = "copy response as markdown", tooltipDefaultText: i = "Copy as markdown", tooltipCopiedText: s = "Copied!" }) {
|
|
750
754
|
let [c, u] = o(!1), [p, m] = o(!1), h = a(null);
|
|
751
755
|
return r(() => () => {
|
|
752
756
|
h.current !== null && clearTimeout(h.current);
|
|
@@ -762,12 +766,14 @@ function ve({ markdown: e, className: t, ariaLabel: n = "copy response as markdo
|
|
|
762
766
|
onClick: async () => {
|
|
763
767
|
try {
|
|
764
768
|
await navigator.clipboard.writeText(e);
|
|
765
|
-
} catch {
|
|
766
|
-
|
|
769
|
+
} catch {
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
u(!0), h.current !== null && clearTimeout(h.current), h.current = setTimeout(() => u(!1), ve);
|
|
767
773
|
},
|
|
768
774
|
"aria-label": n,
|
|
769
775
|
className: `bailey-copy-button${t ? ` ${t}` : ""}`,
|
|
770
|
-
children: d(c ?
|
|
776
|
+
children: d(c ? ge : he, { className: "bailey-copy-icon" })
|
|
771
777
|
})
|
|
772
778
|
}), /* @__PURE__ */ d(l.Portal, { children: /* @__PURE__ */ f(l.Content, {
|
|
773
779
|
side: "top",
|
|
@@ -779,20 +785,20 @@ function ve({ markdown: e, className: t, ariaLabel: n = "copy response as markdo
|
|
|
779
785
|
}
|
|
780
786
|
//#endregion
|
|
781
787
|
//#region src/ui/BaileyTracePanel.tsx
|
|
782
|
-
async function
|
|
788
|
+
async function be(e) {
|
|
783
789
|
try {
|
|
784
790
|
await navigator.clipboard.writeText(e);
|
|
785
791
|
} catch {}
|
|
786
792
|
}
|
|
787
|
-
function
|
|
793
|
+
function xe({ text: e, label: t = "Copy" }) {
|
|
788
794
|
return /* @__PURE__ */ d("button", {
|
|
789
795
|
type: "button",
|
|
790
|
-
onClick: () =>
|
|
796
|
+
onClick: () => be(e),
|
|
791
797
|
className: "bailey-trace-copy-button",
|
|
792
798
|
children: t
|
|
793
799
|
});
|
|
794
800
|
}
|
|
795
|
-
function
|
|
801
|
+
function Se(e) {
|
|
796
802
|
if (e.failed || e.kind === "error") return "bailey-trace-chip bailey-trace-chip-error";
|
|
797
803
|
switch (e.kind) {
|
|
798
804
|
case "tool_start": return "bailey-trace-chip bailey-trace-chip-info";
|
|
@@ -811,7 +817,7 @@ function Q({ label: e, content: t, copyable: n }) {
|
|
|
811
817
|
}),
|
|
812
818
|
n && /* @__PURE__ */ d("div", {
|
|
813
819
|
className: "bailey-trace-disclosure-actions",
|
|
814
|
-
children: /* @__PURE__ */ d(
|
|
820
|
+
children: /* @__PURE__ */ d(xe, { text: t })
|
|
815
821
|
}),
|
|
816
822
|
/* @__PURE__ */ d("pre", {
|
|
817
823
|
className: "bailey-trace-disclosure-content",
|
|
@@ -837,7 +843,7 @@ function $({ row: e }) {
|
|
|
837
843
|
children: ae(e.gapMs)
|
|
838
844
|
}),
|
|
839
845
|
/* @__PURE__ */ d("span", {
|
|
840
|
-
className:
|
|
846
|
+
className: Se(e),
|
|
841
847
|
children: e.label
|
|
842
848
|
}),
|
|
843
849
|
/* @__PURE__ */ d("span", {
|
|
@@ -861,13 +867,13 @@ function $({ row: e }) {
|
|
|
861
867
|
]
|
|
862
868
|
});
|
|
863
869
|
}
|
|
864
|
-
function
|
|
870
|
+
function Ce(e, t) {
|
|
865
871
|
if (e.chunkCount === 0) return "Streamed: no chunks received";
|
|
866
872
|
if (e.chunkCount === 1 || e.firstChunkAt === null) return "Streamed: 1 chunk (not incremental)";
|
|
867
873
|
let n = e.firstChunkAt - t, r = (e.lastChunkAt ?? e.firstChunkAt) - e.firstChunkAt;
|
|
868
874
|
return `Streamed: ${e.chunkCount} chunks · first chunk after ${n}ms · spread over ${(r / 1e3).toFixed(1)}s`;
|
|
869
875
|
}
|
|
870
|
-
function
|
|
876
|
+
function we({ request: e }) {
|
|
871
877
|
let t = i(() => JSON.stringify({
|
|
872
878
|
model: e.model,
|
|
873
879
|
instructions: e.systemPrompt,
|
|
@@ -891,7 +897,7 @@ function Ce({ request: e }) {
|
|
|
891
897
|
}),
|
|
892
898
|
/* @__PURE__ */ d("span", {
|
|
893
899
|
className: "bailey-trace-request-meta",
|
|
894
|
-
children:
|
|
900
|
+
children: Ce(e.streamStats, e.sentAt)
|
|
895
901
|
}),
|
|
896
902
|
/* @__PURE__ */ d(Q, {
|
|
897
903
|
label: `System prompt (${e.systemPrompt.length.toLocaleString()} chars)`,
|
|
@@ -916,14 +922,14 @@ function Ce({ request: e }) {
|
|
|
916
922
|
]
|
|
917
923
|
});
|
|
918
924
|
}
|
|
919
|
-
function
|
|
925
|
+
function Te({ events: e, lastRequest: t, onClear: n }) {
|
|
920
926
|
let r = i(() => oe(e), [e]), a = i(() => ce(r), [r]), o = i(() => JSON.stringify(e, null, 2), [e]);
|
|
921
927
|
return /* @__PURE__ */ f("div", {
|
|
922
928
|
className: "bailey-trace-body",
|
|
923
929
|
children: [
|
|
924
930
|
/* @__PURE__ */ f("div", {
|
|
925
931
|
className: "bailey-trace-actions-row",
|
|
926
|
-
children: [e.length > 0 && /* @__PURE__ */ d(
|
|
932
|
+
children: [e.length > 0 && /* @__PURE__ */ d(xe, {
|
|
927
933
|
text: o,
|
|
928
934
|
label: "Copy trace as JSON"
|
|
929
935
|
}), /* @__PURE__ */ d("button", {
|
|
@@ -933,7 +939,7 @@ function we({ events: e, lastRequest: t, onClear: n }) {
|
|
|
933
939
|
children: "Clear"
|
|
934
940
|
})]
|
|
935
941
|
}),
|
|
936
|
-
t && /* @__PURE__ */ d(
|
|
942
|
+
t && /* @__PURE__ */ d(we, { request: t }),
|
|
937
943
|
/* @__PURE__ */ d("div", {
|
|
938
944
|
className: "bailey-trace-rows",
|
|
939
945
|
children: a.map((e, t) => {
|
|
@@ -971,7 +977,7 @@ function we({ events: e, lastRequest: t, onClear: n }) {
|
|
|
971
977
|
]
|
|
972
978
|
});
|
|
973
979
|
}
|
|
974
|
-
function
|
|
980
|
+
function Ee({ events: e, lastRequest: t, onClear: n }) {
|
|
975
981
|
let [r, a] = o(!1), s = i(() => le(e), [e]), c = i(() => se(e), [e]);
|
|
976
982
|
return e.length === 0 && !t ? null : /* @__PURE__ */ f("div", {
|
|
977
983
|
className: "bailey-trace-panel",
|
|
@@ -993,7 +999,7 @@ function Te({ events: e, lastRequest: t, onClear: n }) {
|
|
|
993
999
|
className: s ? "bailey-trace-summary bailey-trace-summary-error" : "bailey-trace-summary",
|
|
994
1000
|
children: c
|
|
995
1001
|
})]
|
|
996
|
-
}), r && /* @__PURE__ */ d(
|
|
1002
|
+
}), r && /* @__PURE__ */ d(Te, {
|
|
997
1003
|
events: e,
|
|
998
1004
|
lastRequest: t,
|
|
999
1005
|
onClear: n
|
|
@@ -1002,7 +1008,7 @@ function Te({ events: e, lastRequest: t, onClear: n }) {
|
|
|
1002
1008
|
}
|
|
1003
1009
|
//#endregion
|
|
1004
1010
|
//#region src/ui/BaileyChatPanel.tsx
|
|
1005
|
-
var
|
|
1011
|
+
var De = "How can bailey AI help you today?", Oe = "Reply to bailey AI", ke = {
|
|
1006
1012
|
newChatButtonText: "New chat",
|
|
1007
1013
|
newChatAriaLabel: "new chat",
|
|
1008
1014
|
suggestionsTitle: "Suggested for you",
|
|
@@ -1017,41 +1023,41 @@ var Ee = "How can bailey AI help you today?", De = "Reply to bailey AI", Oe = {
|
|
|
1017
1023
|
copyButtonAriaLabel: "copy response as markdown",
|
|
1018
1024
|
copyButtonTooltipDefault: "Copy as markdown",
|
|
1019
1025
|
copyButtonTooltipCopied: "Copied!"
|
|
1020
|
-
},
|
|
1026
|
+
}, Ae = [c], je = t(function({ content: e, components: t }) {
|
|
1021
1027
|
return /* @__PURE__ */ d("div", {
|
|
1022
1028
|
className: "bailey-markdown-content",
|
|
1023
1029
|
children: /* @__PURE__ */ d(s, {
|
|
1024
|
-
remarkPlugins:
|
|
1030
|
+
remarkPlugins: Ae,
|
|
1025
1031
|
components: t,
|
|
1026
1032
|
skipHtml: !0,
|
|
1027
1033
|
children: e
|
|
1028
1034
|
})
|
|
1029
1035
|
});
|
|
1030
1036
|
});
|
|
1031
|
-
function
|
|
1037
|
+
function Me(e, t, n) {
|
|
1032
1038
|
if (e !== "streaming") return;
|
|
1033
1039
|
let r = t.filter((e) => e.turnSentAt === n?.sentAt);
|
|
1034
|
-
if (r.length !== 0) return
|
|
1040
|
+
if (r.length !== 0) return Z(r[r.length - 1]);
|
|
1035
1041
|
}
|
|
1036
|
-
function
|
|
1042
|
+
function Ne(e) {
|
|
1037
1043
|
let t = new Date(e), n = t.toDateString() === (/* @__PURE__ */ new Date()).toDateString(), r = t.toLocaleTimeString([], {
|
|
1038
1044
|
hour: "numeric",
|
|
1039
1045
|
minute: "2-digit"
|
|
1040
1046
|
});
|
|
1041
1047
|
return n ? `Today ${r}` : `${t.toLocaleDateString()} ${r}`;
|
|
1042
1048
|
}
|
|
1043
|
-
function
|
|
1049
|
+
function Pe({ chat: e, placeholder: t, replyPlaceholder: n = Oe, emptyPlaceholder: s, suggestions: c, privacyNote: u, resolveActivityIcon: p, className: m, height: h, width: g, hideDeveloperDetails: _ = !1, renderMessageActions: v, renderTable: y, renderChart: b, labels: x, formatMessageTime: S }) {
|
|
1044
1050
|
let { messages: C, traceEvents: w, lastRequest: T, status: E, error: D, send: O, stop: k, retryLast: A, clearTrace: j, clearError: M, newChat: N } = e, [P, F] = o(""), I = {
|
|
1045
|
-
...
|
|
1051
|
+
...ke,
|
|
1046
1052
|
...x
|
|
1047
|
-
}, L = S ??
|
|
1053
|
+
}, L = S ?? Ne, R = a(null), z = a(null), B = a(!0), ee = i(() => de({
|
|
1048
1054
|
renderTable: y,
|
|
1049
1055
|
renderChart: b
|
|
1050
|
-
}), [y, b]),
|
|
1056
|
+
}), [y, b]), V = i(() => Me(E, w, T), [
|
|
1051
1057
|
E,
|
|
1052
1058
|
w,
|
|
1053
1059
|
T
|
|
1054
|
-
]),
|
|
1060
|
+
]), H = C.length === 0, U = t ?? (H ? s ?? De : n);
|
|
1055
1061
|
r(() => {
|
|
1056
1062
|
let e = z.current;
|
|
1057
1063
|
if (!e) return;
|
|
@@ -1066,7 +1072,7 @@ function Ne({ chat: e, placeholder: t, replyPlaceholder: n = De, emptyPlaceholde
|
|
|
1066
1072
|
block: "nearest"
|
|
1067
1073
|
});
|
|
1068
1074
|
}, [C, E]);
|
|
1069
|
-
let
|
|
1075
|
+
let W = (e) => {
|
|
1070
1076
|
B.current = !0, O(e);
|
|
1071
1077
|
};
|
|
1072
1078
|
return /* @__PURE__ */ d("div", {
|
|
@@ -1093,16 +1099,16 @@ function Ne({ chat: e, placeholder: t, replyPlaceholder: n = De, emptyPlaceholde
|
|
|
1093
1099
|
className: "bailey-chat-transcript",
|
|
1094
1100
|
ref: z,
|
|
1095
1101
|
children: [
|
|
1096
|
-
|
|
1102
|
+
H && (c && c.length > 0 ? /* @__PURE__ */ f("div", {
|
|
1097
1103
|
className: "bailey-suggestions",
|
|
1098
1104
|
children: [/* @__PURE__ */ d("div", {
|
|
1099
1105
|
className: "bailey-suggestions-title",
|
|
1100
1106
|
children: I.suggestionsTitle
|
|
1101
1107
|
}), c.map((e, t) => /* @__PURE__ */ f("button", {
|
|
1102
1108
|
type: "button",
|
|
1103
|
-
onClick: () =>
|
|
1109
|
+
onClick: () => W(e.value ?? e.label),
|
|
1104
1110
|
className: "bailey-suggestion-card",
|
|
1105
|
-
children: [/* @__PURE__ */ d("span", { children: e.label }), /* @__PURE__ */ d(
|
|
1111
|
+
children: [/* @__PURE__ */ d("span", { children: e.label }), /* @__PURE__ */ d(me, { className: "bailey-suggestion-icon" })]
|
|
1106
1112
|
}, `${e.label}-${t}`))]
|
|
1107
1113
|
}) : /* @__PURE__ */ d("div", {
|
|
1108
1114
|
className: "bailey-empty-state",
|
|
@@ -1126,7 +1132,7 @@ function Ne({ chat: e, placeholder: t, replyPlaceholder: n = De, emptyPlaceholde
|
|
|
1126
1132
|
})]
|
|
1127
1133
|
}) : r ? /* @__PURE__ */ d("div", {
|
|
1128
1134
|
className: "bailey-thinking-hint",
|
|
1129
|
-
children:
|
|
1135
|
+
children: V ?? I.thinkingHint
|
|
1130
1136
|
}) : /* @__PURE__ */ f("div", {
|
|
1131
1137
|
className: "bailey-assistant-message",
|
|
1132
1138
|
children: [
|
|
@@ -1134,20 +1140,20 @@ function Ne({ chat: e, placeholder: t, replyPlaceholder: n = De, emptyPlaceholde
|
|
|
1134
1140
|
className: "bailey-activity-line",
|
|
1135
1141
|
children: [/* @__PURE__ */ d("span", {
|
|
1136
1142
|
className: "bailey-activity-icon",
|
|
1137
|
-
children: p?.(a.toolName) ?? /* @__PURE__ */ d(
|
|
1143
|
+
children: p?.(a.toolName) ?? /* @__PURE__ */ d(_e, {})
|
|
1138
1144
|
}), /* @__PURE__ */ d("span", { children: a.text })]
|
|
1139
1145
|
}),
|
|
1140
|
-
/* @__PURE__ */ d(
|
|
1146
|
+
/* @__PURE__ */ d(je, {
|
|
1141
1147
|
content: e.content,
|
|
1142
|
-
components:
|
|
1148
|
+
components: ee
|
|
1143
1149
|
}),
|
|
1144
|
-
e.streaming &&
|
|
1150
|
+
e.streaming && V && /* @__PURE__ */ d("div", {
|
|
1145
1151
|
className: "bailey-streaming-hint",
|
|
1146
|
-
children:
|
|
1152
|
+
children: V
|
|
1147
1153
|
}),
|
|
1148
1154
|
!e.streaming && /* @__PURE__ */ f("div", {
|
|
1149
1155
|
className: "bailey-message-actions",
|
|
1150
|
-
children: [/* @__PURE__ */ d(
|
|
1156
|
+
children: [/* @__PURE__ */ d(ye, {
|
|
1151
1157
|
markdown: e.content,
|
|
1152
1158
|
ariaLabel: I.copyButtonAriaLabel,
|
|
1153
1159
|
tooltipDefaultText: I.copyButtonTooltipDefault,
|
|
@@ -1161,7 +1167,7 @@ function Ne({ chat: e, placeholder: t, replyPlaceholder: n = De, emptyPlaceholde
|
|
|
1161
1167
|
/* @__PURE__ */ d("div", { ref: R })
|
|
1162
1168
|
]
|
|
1163
1169
|
}),
|
|
1164
|
-
|
|
1170
|
+
H && u && /* @__PURE__ */ f("div", {
|
|
1165
1171
|
className: "bailey-privacy-note",
|
|
1166
1172
|
children: [
|
|
1167
1173
|
u.text,
|
|
@@ -1193,20 +1199,20 @@ function Ne({ chat: e, placeholder: t, replyPlaceholder: n = De, emptyPlaceholde
|
|
|
1193
1199
|
})]
|
|
1194
1200
|
})]
|
|
1195
1201
|
}),
|
|
1196
|
-
!_ && /* @__PURE__ */ d(
|
|
1202
|
+
!_ && /* @__PURE__ */ d(Ee, {
|
|
1197
1203
|
events: w,
|
|
1198
1204
|
lastRequest: T,
|
|
1199
1205
|
onClear: j
|
|
1200
1206
|
}),
|
|
1201
1207
|
/* @__PURE__ */ f("form", {
|
|
1202
1208
|
onSubmit: (e) => {
|
|
1203
|
-
e.preventDefault(), !(!P.trim() || E === "streaming") && (
|
|
1209
|
+
e.preventDefault(), !(!P.trim() || E === "streaming") && (W(P), F(""));
|
|
1204
1210
|
},
|
|
1205
1211
|
className: "bailey-input-row",
|
|
1206
1212
|
children: [/* @__PURE__ */ d("input", {
|
|
1207
1213
|
type: "text",
|
|
1208
|
-
placeholder:
|
|
1209
|
-
"aria-label":
|
|
1214
|
+
placeholder: U,
|
|
1215
|
+
"aria-label": U,
|
|
1210
1216
|
value: P,
|
|
1211
1217
|
onChange: (e) => F(e.target.value),
|
|
1212
1218
|
disabled: E === "streaming",
|
|
@@ -1241,6 +1247,6 @@ function Ne({ chat: e, placeholder: t, replyPlaceholder: n = De, emptyPlaceholde
|
|
|
1241
1247
|
}
|
|
1242
1248
|
//#endregion
|
|
1243
1249
|
//#region src/index.ts
|
|
1244
|
-
var
|
|
1250
|
+
var Fe = "0.3.1-pre.2";
|
|
1245
1251
|
//#endregion
|
|
1246
|
-
export {
|
|
1252
|
+
export { _e as ActivityIcon, me as ArrowUpRightIcon, Fe as BAILEYAI_CHAT_UI_VERSION, B as BAILEY_CHART_PROMPT_FRAGMENT, M as BAILEY_TABLE_GRID_ROW_THRESHOLD, Pe as BaileyChatPanel, Ee as BaileyTracePanel, ye as CopyMarkdownButton, fe as HeartIcon, re as TRACE_KIND_LABEL, de as createBaileyMarkdownComponents, b as extractPseudoToolCalls, R as extractTableData, ae as formatTraceGap, ie as formatTraceTime, le as hasTraceFailure, e as isSafeMarkdownUrl, O as joinInstructions, ne as parseBaileyChartSpec, S as parseSseFrames, j as resolveToolCall, z as shouldUseGrid, ue as toActivityLines, oe as toTraceRows, ce as toTraceSegments, J as traceEventArgsDetail, Z as traceEventHint, Y as traceEventOutputDetail, X as traceEventRawDetail, q as traceEventSummary, K as traceEventToolName, se as traceSummaryLine, D as useBaileyChat };
|