@icanbwell/baileyai-chat-ui 0.2.1-pre.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # @icanbwell/baileyai-chat-ui
2
+
3
+ Shared React chat UI and streaming logic for Bailey, the icanbwell AI assistant. Built on [Radix UI](https://www.radix-ui.com/) primitives and [Tailwind CSS](https://tailwindcss.com/) v4, shipped as pre-compiled CSS so consuming apps don't need a Tailwind build step of their own.
4
+
5
+ ## Install
6
+
7
+ This package is published to GitHub Packages under the `@icanbwell` scope. Configure your project's `.npmrc` (or `.yarnrc.yml`) to resolve `@icanbwell/*` from `https://npm.pkg.github.com`, then:
8
+
9
+ ```bash
10
+ yarn add @icanbwell/baileyai-chat-ui
11
+ ```
12
+
13
+ Peer dependencies: `react` and `react-dom` (`^19.0.0`).
14
+
15
+ This package assumes a bundler-based consumer (Vite, webpack, etc.) — some dependencies are externalized from the built bundle and resolved via your app's own bundler, not safe to `require()` directly under plain Node.
16
+
17
+ ## Usage
18
+
19
+ Import the compiled stylesheet once, anywhere in your app's entry point:
20
+
21
+ ```ts
22
+ import '@icanbwell/baileyai-chat-ui/styles.css';
23
+ ```
24
+
25
+ Then implement `BaileyChatTransport` — the package owns SSE parsing and chat state, your app owns auth/networking:
26
+
27
+ ```tsx
28
+ import { useBaileyChat, BaileyChatPanel, type BaileyChatTransport } from '@icanbwell/baileyai-chat-ui';
29
+
30
+ const transport: BaileyChatTransport = {
31
+ async streamChat({ model, instructions, input, tools, toolChoice, signal, onChunk, onRequestId }) {
32
+ const response = await fetch('/api/bailey/chat', {
33
+ method: 'POST',
34
+ headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${getAuthToken()}` },
35
+ body: JSON.stringify({ model, instructions, input, tools, toolChoice, stream: true }),
36
+ signal,
37
+ });
38
+ const requestId = response.headers.get('x-request-id');
39
+ if (requestId) {
40
+ onRequestId?.(requestId);
41
+ }
42
+ const reader = response.body!.getReader();
43
+ const decoder = new TextDecoder();
44
+ while (true) {
45
+ const { done, value } = await reader.read();
46
+ if (done) break;
47
+ onChunk(decoder.decode(value, { stream: true }));
48
+ }
49
+ return { status: response.status, text: response.ok ? '' : await response.text() };
50
+ },
51
+ };
52
+
53
+ function BaileyChat() {
54
+ const chat = useBaileyChat({ transport, model: 'bailey-default', instructions: 'You are Bailey...' });
55
+ return <BaileyChatPanel chat={chat} />;
56
+ }
57
+ ```
58
+
59
+ ## Rendering tables and charts
60
+
61
+ Bailey can return large markdown tables or `chartjs` code blocks. By default these render as plain HTML (a `<table>`, or the package's default code-block styling for chart specs) — pass `renderTable`/`renderChart` to `BaileyChatPanel` to plug in your own grid/chart library instead:
62
+
63
+ ```tsx
64
+ <BaileyChatPanel
65
+ chat={chat}
66
+ renderTable={({ headers, rows }) => <MyDataGrid headers={headers} rows={rows} />}
67
+ renderChart={(spec) => <MyChartComponent spec={spec} />}
68
+ />
69
+ ```
70
+
71
+ `renderTable` only fires once a table exceeds `BAILEY_TABLE_GRID_ROW_THRESHOLD` rows (5); smaller tables always render as plain HTML. `renderChart` fires for any fenced ` ```chartjs ` block that parses as a valid `BaileyChartSpec` — see `BAILEY_CHART_PROMPT_FRAGMENT` for the exact contract to compose into your system prompt via `joinInstructions`.
72
+
73
+ Pass stable function references for both props (defined outside the render body, or wrapped in `useCallback`) rather than a new inline arrow every render — they're a dependency of the internal markdown component registry, and a fresh reference on every render defeats the per-message memoization that keeps re-renders cheap during streaming.
74
+
75
+ ## Theming
76
+
77
+ The package ships CSS custom properties with sensible defaults; override any of them from your app's own CSS to match your brand:
78
+
79
+ ```css
80
+ :root {
81
+ --color-bailey-accent: #4f46e5;
82
+ --color-bailey-bubble-bg: #e8e8e8;
83
+ --color-bailey-text: #000000;
84
+ --color-bailey-error: #d32f2f;
85
+ --color-bailey-border: #e5e5e5;
86
+ --color-bailey-surface: #ffffff;
87
+ --color-bailey-surface-muted: #f9fafb;
88
+ --color-bailey-text-secondary: #6b6b6b;
89
+ --color-bailey-tooltip-bg: #000000;
90
+ --color-bailey-tooltip-text: #ffffff;
91
+ }
92
+ ```
93
+
94
+ The package's own `styles.css` deliberately skips Tailwind's Preflight reset, so it coexists with a host app's own base styles (e.g. MUI's `CssBaseline`) without a global collision.
95
+
96
+ ## Development
97
+
98
+ ```bash
99
+ yarn install
100
+ yarn dev # local Vite dev harness at dev/, streams a canned response (incl. a tool call) for manual UI testing
101
+ yarn test
102
+ yarn typecheck
103
+ yarn lint
104
+ yarn build
105
+ ```
@@ -0,0 +1,11 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("react"),l=require("react-markdown");l=s(l,1);let u=require("remark-gfm");u=s(u,1);let d=require("react/jsx-runtime"),f=require("@radix-ui/react-tooltip");f=s(f,1);var p=/<(search_tools|call_tool)>([\s\S]*?)<\/\1>/g,m=/<name>([\s\S]*?)<\/name>/,h=/<arguments>([\s\S]*?)<\/arguments>/;function g(e){let t=m.exec(e)?.[1]?.trim()||`unknown_tool`,n=h.exec(e)?.[1]?.trim();return n?{name:t,args:n}:{name:t}}function _(e){let t=[],n=e.replace(p,(e,n,r)=>(t.push(n===`call_tool`?g(r):{name:`search_tools`,args:r.trim()}),``));return t.length===0?{cleanedText:n,matches:t}:{cleanedText:n.replace(/\n{3,}/g,`
2
+
3
+ `),matches:t}}function v(e){if(!e.startsWith(`data: `))return e;let t=``;for(let n of e.split(`
4
+ `)){if(!n.startsWith(`data: `))continue;let e=n.slice(6);if(e===`[DONE]`)break;try{let n=JSON.parse(e);n?.type===`response.output_text.delta`&&n.delta&&(t+=n.delta)}catch{}}return t||null}function y(e){let t=e.replace(/\r\n/g,`
5
+ `).split(`
6
+
7
+ `),n=t.pop()??``,r=[],i=!1;for(let e of t){let t=e.split(`
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=v(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 b=200,x=15e4,S=(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>b?`${i.slice(0,b)}…`:i}`:r},C=({transport:e,model:t,instructions:n,tools:r=[],toolChoice:i,firstUserMessagePrefix:a,onAssistantMessageComplete:o,idleTimeoutMs:s=x})=>{let[l,u]=(0,c.useState)([]),[d,f]=(0,c.useState)([]),[p,m]=(0,c.useState)(null),[h,g]=(0,c.useState)(`idle`),[v,b]=(0,c.useState)(null),C=(0,c.useRef)(null),w=(0,c.useRef)(``),T=(0,c.useRef)(0),E=(0,c.useRef)([]);(0,c.useEffect)(()=>{E.current=l},[l]);let D=(0,c.useRef)(new Map),O=(0,c.useRef)(new Map),k=(0,c.useRef)(null),A=(0,c.useCallback)(()=>{k.current!==null&&(clearTimeout(k.current),k.current=null)},[]),j=(0,c.useCallback)(e=>{A(),k.current=setTimeout(()=>{e.abort(new DOMException(`The assistant took too long to respond. Please try again.`,`TimeoutError`))},s)},[A,s]),M=(0,c.useCallback)((e,t,n)=>{let r=e=>{n.push(e),f(t=>[...t,e])};if(t.type===`response.output_text.delta`){if(!t.delta)return!1;let n=D.current.get(e)??{raw:``,emittedCount:0};n.raw+=t.delta;let{cleanedText:i,matches:a}=_(n.raw),o=i.trim(),s=a.slice(n.emittedCount);if(n.emittedCount=a.length,D.current.set(e,n),O.current.set(e,o),u(t=>t.map(t=>t.id===e?{...t,content:o}:t)),s.length>0){let e=Date.now(),t=T.current;s.forEach(n=>r({kind:`pseudo_tool_call`,name:n.name,args:n.args,at:e,turnSentAt:t}))}return!0}if(t.type===`response.output_item.added`||t.type===`response.output_item.done`){let e=t.item;if(e.type===`function_call`||e.type===`mcp_call`){let n=Date.now(),i=T.current,a=e.name||`unknown_tool`;return r(t.type===`response.output_item.added`?{kind:`tool_start`,name:a,args:e.arguments,at:n,turnSentAt:i}:{kind:`tool_end`,name:a,args:e.arguments,at:n,turnSentAt:i,output:e.output,isError:e.is_error,runtimeSeconds:e.runtime_seconds}),!0}return!1}return t.type===`task.progress`?(r({kind:`progress`,status:t.status,message:t.message,at:Date.now(),turnSentAt:T.current}),!0):t.type===`response.output_text.done`||t.type===`response.created`||t.type===`response.completed`?!1:t.type===`info`?(r({kind:`info`,message:t.message,at:Date.now(),turnSentAt:T.current}),!0):(r({kind:`raw`,eventType:t.type,raw:JSON.stringify(t),at:Date.now(),turnSentAt:T.current}),!0)},[]),N=(0,c.useCallback)(async s=>{g(`streaming`),b(null);let c=crypto.randomUUID();u(e=>[...e,{id:c,role:`assistant`,content:``,streaming:!0}]);let l=Date.now();T.current=l;let d=s.map((e,t)=>t===0&&e.role===`user`&&a?{role:e.role,content:`${a}${e.content}`}:{role:e.role,content:e.content});m({model:t,systemPrompt:n,messages:d,tools:r,toolChoice:i,stream:!0,sentAt:l,streamStats:{chunkCount:0,firstChunkAt:null,lastChunkAt:null}});let p=new AbortController;C.current=p,j(p);let h=``,_=null,v=!1,x=!1,w=[],E=(e,t)=>{g(`error`),b(e);let n={kind:`error`,message:e,at:Date.now(),turnSentAt:l,...t};w.push(n),f(e=>[...e,n])},k=(e,t)=>{e.forEach(e=>{if(e.type===`error`){_=e.message;let t={kind:`error`,message:e.message,at:Date.now(),turnSentAt:l};w.push(t),f(e=>[...e,t]);return}e.type===`response.output_text.delta`&&e.delta&&(x=!0),M(c,e,w)&&(v=!0)}),t&&u(e=>e.map(e=>e.id===c?{...e,streaming:!1}:e))};try{let{status:a,text:s,errorMessage:u}=await e.streamChat({model:t,instructions:n,input:d,tools:r,toolChoice:i,signal:p.signal,onChunk:e=>{j(p),h+=e;let{events:t,remainder:n,done:r}=y(h);h=n,k(t,r);let i=Date.now();m(e=>e&&e.sentAt===l?{...e,streamStats:{chunkCount:e.streamStats.chunkCount+1,firstChunkAt:e.streamStats.firstChunkAt??i,lastChunkAt:i}}:e)},onRequestId:e=>{m(t=>t&&t.sentAt===l?{...t,requestId:e}:t)}});if(h.trim()){let{events:e,done:t}=y(`${h}\n\n`);h=``,k(e,t)}if(_){g(`error`),b(_);return}if(a===void 0||a>=400){E(S(a,s,u),{httpStatus:a,rawBody:s||void 0});return}if(!v){E(`Bailey returned an empty response.`);return}if(!x){E(`Bailey ran some tools but didn't return an answer. Try asking again.`);return}g(`idle`);let f=O.current.get(c)??``;m(e=>e&&e.sentAt===l?{...e,response:{content:f}}:e),o&&await o({id:c,role:`assistant`,content:f,streaming:!1},w)}catch(e){let t=e;if(t?.name===`TimeoutError`){E(t.message,{source:`client-timeout`});return}if(t?.name===`AbortError`){g(`idle`);return}E(t?.message||`Bailey request failed.`)}finally{A(),D.current.delete(c),O.current.delete(c),u(e=>e.flatMap(e=>e.id===c?e.content?[{...e,streaming:!1}]:[]:[e]))}},[e,t,n,r,i,a,o,M,j,A]);return{messages:l,traceEvents:d,lastRequest:p,status:h,error:v,send:(0,c.useCallback)(e=>{let t=e.trim();if(!t)return;w.current=t;let n=[...E.current,{id:crypto.randomUUID(),role:`user`,content:t}];E.current=n,u(n),N(n)},[N]),stop:(0,c.useCallback)(()=>{C.current?.abort()},[]),retryLast:(0,c.useCallback)(()=>{if(!w.current)return;let e=E.current,t=e[e.length-1],n=t&&t.role===`assistant`?e.slice(0,-1):e;E.current=n,u(n),N(n)},[N]),clearTrace:(0,c.useCallback)(()=>f([]),[]),clearError:(0,c.useCallback)(()=>{b(null),g(e=>e===`error`?`idle`:e)},[])}};function w(...e){return e.filter(e=>!!(e&&e.trim())).join(`
10
+
11
+ `)}var T=`call_tool`,E=`a tool`;function D(e,t){let n={name:e===T?E: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===T){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 O=/^(https?|mailto):/i,k=e=>e.replace(/[\t\n\r]/g,``).trim(),A=e=>{let t=k(e);return!/^[a-z][a-z0-9+.-]*:/i.test(t)||O.test(t)},j=5,M=e=>e.type===`text`?e.value??``:(e.children??[]).map(M).join(``),N=e=>{if(e.tagName===`a`&&e.properties?.href)return e.properties.href;for(let t of e.children??[]){let e=N(t);if(e)return e}},P=(e,t)=>(e.children??[]).find(e=>e.tagName===t),ee=e=>{let t=M(e),n=N(e);return n?{text:t,href:n}:{text:t}},te=e=>(e.children??[]).filter(e=>e.type===`element`).map(ee),ne=e=>{if(e.tagName!==`table`)return null;let t=P(e,`thead`),n=t&&P(t,`tr`);return{headers:n?te(n).map(e=>e.text):[],rows:(P(e,`tbody`)?.children??[]).filter(e=>e.tagName===`tr`).map(te)}},re=e=>e.length>5,ie='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```',ae=[`bar`,`line`,`pie`,`doughnut`,`scatter`],oe=8,se=50,ce=8,le=500,ue=e=>typeof e==`object`&&!!e&&typeof e.x==`number`&&typeof e.y==`number`,F=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`||!ae.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>oe||(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>le||!e.data.every(ue))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`?ce:se;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}}},I={tool_start:`Tool start`,tool_end:`Tool end`,pseudo_tool_call:`Narrated tool call`,progress:`Progress`,info:`Info`,error:`Error`,raw:`Raw event`};function L(e){return e.kind!==`tool_start`&&e.kind!==`tool_end`?null:D(e.name,e.args)}function R(e,t=L(e)){return e.kind===`pseudo_tool_call`?e.name:t?.name??null}function z(e,t=L(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 B(e,t=L(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 V(e){return e.kind===`tool_end`?e.output??null:null}function H(e){return e.kind===`raw`?e.raw:e.kind===`error`?e.rawBody??null:null}function U(e){switch(e.kind){case`tool_start`:return`Calling ${D(e.name,e.args).name}...`;case`tool_end`:{let t=D(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 de(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 W(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 G(e){return e.map((t,n)=>{let r=L(t),i=n===0?t.turnSentAt:e[n-1].at;return{key:`${t.at}-${n}`,kind:t.kind,toolName:R(t,r),isToolStart:t.kind===`tool_start`,failed:t.kind===`tool_end`&&t.isError===!0,time:de(t.at),gapMs:t.at-i,label:t.kind===`tool_end`&&t.isError===!0?`Tool failed`:I[t.kind],summary:z(t,r),argsDetail:B(t,r),outputDetail:V(t),rawDetail:H(t)}})}function K(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 q(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 J(e){return e.some(e=>e.kind===`tool_end`&&e.isError||e.kind===`error`)}function Y({renderTable:e,renderChart:t}={}){return{a:({href:e,children:t})=>!e||!A(e)?(0,d.jsx)(d.Fragment,{children:t}):(0,d.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:t}),table:({node:t,children:n})=>{let r=t&&ne(t);if(r&&re(r.rows)&&e){let t=r.rows.map(e=>e.map(e=>e.href&&!A(e.href)?{text:e.text}:e));return(0,d.jsx)(d.Fragment,{children:e({headers:r.headers,rows:t})})}return(0,d.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=F(Array.isArray(e)?e.join(``):String(e??``));if(r)return(0,d.jsx)(d.Fragment,{children:t(r)})}return(0,d.jsx)(`pre`,{children:e})}}}var fe=1500;function X({markdown:e,className:t}){let[n,r]=(0,c.useState)(!1),[i,a]=(0,c.useState)(!1),o=(0,c.useRef)(null);return(0,c.useEffect)(()=>()=>{o.current!==null&&clearTimeout(o.current)},[]),(0,d.jsx)(f.Provider,{delayDuration:200,children:(0,d.jsxs)(f.Root,{open:n||i,onOpenChange:a,children:[(0,d.jsx)(f.Trigger,{asChild:!0,children:(0,d.jsx)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(e)}catch{}r(!0),o.current!==null&&clearTimeout(o.current),o.current=setTimeout(()=>r(!1),fe)},"aria-label":`copy response as markdown`,className:`bailey-copy-button${t?` ${t}`:``}`,children:n?`✓`:`⧉`})}),(0,d.jsx)(f.Portal,{children:(0,d.jsxs)(f.Content,{side:`top`,className:`bailey-tooltip-content`,children:[n?`Copied!`:`Copy as markdown`,(0,d.jsx)(f.Arrow,{className:`bailey-tooltip-arrow`})]})})]})})}async function pe(e){try{await navigator.clipboard.writeText(e)}catch{}}function me({text:e,label:t=`Copy`}){return(0,d.jsx)(`button`,{type:`button`,onClick:()=>pe(e),className:`bailey-trace-copy-button`,children:t})}function he(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,d.jsxs)(`details`,{className:`bailey-trace-disclosure`,children:[(0,d.jsx)(`summary`,{className:`bailey-trace-disclosure-summary`,children:e}),n&&(0,d.jsx)(`div`,{className:`bailey-trace-disclosure-actions`,children:(0,d.jsx)(me,{text:t})}),(0,d.jsx)(`pre`,{className:`bailey-trace-disclosure-content`,children:t})]})}function Q({row:e}){return(0,d.jsxs)(`div`,{className:`bailey-trace-row`,children:[(0,d.jsxs)(`div`,{className:`bailey-trace-row-header`,children:[(0,d.jsx)(`span`,{className:`bailey-trace-row-time`,children:e.time}),(0,d.jsx)(`span`,{className:`bailey-trace-row-gap`,title:`Time since the previous event`,children:W(e.gapMs)}),(0,d.jsx)(`span`,{className:he(e),children:e.label}),(0,d.jsx)(`span`,{className:`bailey-trace-row-summary`,children:e.summary})]}),e.argsDetail&&(0,d.jsx)(Z,{label:`args`,content:e.argsDetail}),e.outputDetail&&(0,d.jsx)(Z,{label:`output`,content:e.outputDetail}),e.rawDetail&&(0,d.jsx)(Z,{label:`raw`,content:e.rawDetail})]})}function ge(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 _e({request:e}){let t=(0,c.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,d.jsxs)(`div`,{className:`bailey-trace-request-details`,children:[(0,d.jsxs)(`span`,{className:`bailey-trace-request-meta`,children:[`Last request — `,e.model,` · `,new Date(e.sentAt).toLocaleTimeString(),e.requestId?` · ${e.requestId}`:``]}),(0,d.jsx)(`span`,{className:`bailey-trace-request-meta`,children:ge(e.streamStats,e.sentAt)}),(0,d.jsx)(Z,{label:`System prompt (${e.systemPrompt.length.toLocaleString()} chars)`,content:e.systemPrompt,copyable:!0}),(0,d.jsx)(Z,{label:`Messages (${e.messages.length})`,content:JSON.stringify(e.messages,null,2),copyable:!0}),e.response&&(0,d.jsx)(Z,{label:`Response (${e.response.content.length.toLocaleString()} chars)`,content:e.response.content,copyable:!0}),(0,d.jsx)(Z,{label:`Full payload (JSON)`,content:t,copyable:!0})]})}function ve({events:e,lastRequest:t,onClear:n}){let r=(0,c.useMemo)(()=>G(e),[e]),i=(0,c.useMemo)(()=>q(r),[r]),a=(0,c.useMemo)(()=>JSON.stringify(e,null,2),[e]);return(0,d.jsxs)(`div`,{className:`bailey-trace-body`,children:[(0,d.jsxs)(`div`,{className:`bailey-trace-actions-row`,children:[e.length>0&&(0,d.jsx)(me,{text:a,label:`Copy trace as JSON`}),(0,d.jsx)(`button`,{type:`button`,onClick:n,className:`bailey-trace-copy-button`,children:`Clear`})]}),t&&(0,d.jsx)(_e,{request:t}),(0,d.jsx)(`div`,{className:`bailey-trace-rows`,children:i.map((e,t)=>{if(e.type===`single`)return(0,d.jsx)(Q,{row:e.row},e.row.key);let n=e.rows.filter(e=>e.isToolStart).length;if(n<=1)return(0,d.jsx)(`div`,{className:`bailey-trace-rows`,children:e.rows.map(e=>(0,d.jsx)(Q,{row:e},e.key))},`group-${t}`);let r=e.rows.filter(e=>e.failed).length;return(0,d.jsxs)(`details`,{className:`bailey-trace-group`,children:[(0,d.jsxs)(`summary`,{className:`bailey-trace-group-summary`,children:[(0,d.jsx)(`strong`,{children:e.toolName}),` × `,n,r>0&&(0,d.jsxs)(`span`,{className:`bailey-trace-group-failed`,children:[` `,r,` failed`]})]}),(0,d.jsx)(`div`,{className:`bailey-trace-rows`,children:e.rows.map(e=>(0,d.jsx)(Q,{row:e},e.key))})]},`group-${t}`)})})]})}function $({events:e,lastRequest:t,onClear:n}){let[r,i]=(0,c.useState)(!1),a=(0,c.useMemo)(()=>J(e),[e]),o=(0,c.useMemo)(()=>K(e),[e]);return e.length===0&&!t?null:(0,d.jsxs)(`div`,{className:`bailey-trace-panel`,children:[(0,d.jsxs)(`div`,{className:`bailey-trace-toggle-row`,children:[(0,d.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,d.jsx)(`span`,{className:a?`bailey-trace-summary bailey-trace-summary-error`:`bailey-trace-summary`,children:o})]}),r&&(0,d.jsx)(ve,{events:e,lastRequest:t,onClear:n})]})}var ye=[u.default],be=(0,c.memo)(function({content:e,components:t}){return(0,d.jsx)(`div`,{className:`bailey-markdown-content`,children:(0,d.jsx)(l.default,{remarkPlugins:ye,components:t,children:e})})});function xe(e,t,n){if(e!==`streaming`)return;let r=t.filter(e=>e.turnSentAt===n?.sentAt);if(r.length!==0)return U(r[r.length-1])}function Se({chat:e,placeholder:t=`Send a message…`,className:n,renderMessageActions:r,renderTable:i,renderChart:a}){let{messages:o,traceEvents:s,lastRequest:l,status:u,error:f,send:p,stop:m,retryLast:h,clearTrace:g,clearError:_}=e,[v,y]=(0,c.useState)(``),b=(0,c.useRef)(null),x=(0,c.useMemo)(()=>Y({renderTable:i,renderChart:a}),[i,a]),S=(0,c.useMemo)(()=>xe(u,s,l),[u,s,l]);return(0,c.useEffect)(()=>{b.current?.scrollIntoView({behavior:`smooth`,block:`nearest`})},[o]),(0,d.jsxs)(`div`,{className:`bailey-chat-panel${n?` ${n}`:``}`,children:[(0,d.jsxs)(`div`,{className:`bailey-chat-transcript`,children:[o.length===0&&(0,d.jsx)(`div`,{className:`bailey-empty-state`,children:`Ask Bailey a question to get started.`}),o.map((e,t)=>{let n=e.role===`assistant`&&t===o.length-1,i=u===`streaming`&&n&&e.content===``;return(0,d.jsx)(`div`,{className:e.role===`user`?`bailey-message-row bailey-message-row-user`:`bailey-message-row`,children:e.role===`user`?(0,d.jsx)(`div`,{className:`bailey-user-bubble`,children:e.content}):i?(0,d.jsx)(`div`,{className:`bailey-thinking-hint`,children:S??`Thinking…`}):(0,d.jsxs)(`div`,{className:`bailey-assistant-message`,children:[(0,d.jsx)(be,{content:e.content,components:x}),e.streaming&&S&&(0,d.jsx)(`div`,{className:`bailey-streaming-hint`,children:S}),!e.streaming&&(0,d.jsxs)(`div`,{className:`bailey-message-actions`,children:[(0,d.jsx)(X,{markdown:e.content}),r?.(e)]})]})},e.id)}),(0,d.jsx)(`div`,{ref:b})]}),f&&(0,d.jsxs)(`div`,{className:`bailey-error-banner`,role:`alert`,children:[(0,d.jsx)(`span`,{children:f}),(0,d.jsxs)(`div`,{className:`bailey-error-actions`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:h,className:`bailey-retry-button`,children:`Retry`}),(0,d.jsx)(`button`,{type:`button`,onClick:_,"aria-label":`dismiss error`,className:`bailey-dismiss-button`,children:`✕`})]})]}),(0,d.jsx)($,{events:s,lastRequest:l,onClear:g}),(0,d.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),!(!v.trim()||u===`streaming`)&&(p(v),y(``))},className:`bailey-input-row`,children:[(0,d.jsx)(`input`,{type:`text`,placeholder:t,"aria-label":t,value:v,onChange:e=>y(e.target.value),disabled:u===`streaming`,className:`bailey-input`}),u===`streaming`?(0,d.jsx)(`button`,{type:`button`,onClick:m,"aria-label":`stop`,className:`bailey-stop-button`,children:`Stop`}):(0,d.jsx)(`button`,{type:`submit`,"aria-label":`send`,disabled:!v.trim(),className:`bailey-send-button`,children:`Send`})]})]})}var Ce=`0.2.1-pre.0`;exports.BAILEYAI_CHAT_UI_VERSION=Ce,exports.BAILEY_CHART_PROMPT_FRAGMENT=ie,exports.BAILEY_TABLE_GRID_ROW_THRESHOLD=j,exports.BaileyChatPanel=Se,exports.BaileyTracePanel=$,exports.CopyMarkdownButton=X,exports.TRACE_KIND_LABEL=I,exports.createBaileyMarkdownComponents=Y,exports.extractPseudoToolCalls=_,exports.extractTableData=ne,exports.formatTraceGap=W,exports.formatTraceTime=de,exports.hasTraceFailure=J,exports.isSafeMarkdownUrl=A,exports.joinInstructions=w,exports.parseBaileyChartSpec=F,exports.parseSseFrames=y,exports.resolveToolCall=D,exports.shouldUseGrid=re,exports.toTraceRows=G,exports.toTraceSegments=q,exports.traceEventArgsDetail=B,exports.traceEventHint=U,exports.traceEventOutputDetail=V,exports.traceEventRawDetail=H,exports.traceEventSummary=z,exports.traceEventToolName=R,exports.traceSummaryLine=K,exports.useBaileyChat=C;
@@ -0,0 +1,3 @@
1
+ /*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
2
+ @layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-font-weight:initial;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-leading:initial;--tw-space-y-reverse:0}}}@layer theme{:root,:host{--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-100:oklch(93.6% .032 17.717);--color-green-100:oklch(96.2% .044 156.743);--color-green-700:oklch(52.7% .154 150.069);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-700:oklch(48.8% .243 264.376);--color-purple-100:oklch(94.6% .033 307.174);--color-purple-700:oklch(49.6% .265 301.924);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-700:oklch(37.3% .034 259.733);--color-black:#000;--color-white:#fff;--spacing:.25rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--font-weight-medium:500;--font-weight-semibold:600;--leading-relaxed:1.625;--radius-md:.375rem;--radius-2xl:1rem;--color-bailey-accent:#4f46e5;--color-bailey-bubble-bg:#e8e8e8;--color-bailey-error:#d32f2f;--color-bailey-border:#e5e5e5;--color-bailey-surface:#fff;--color-bailey-surface-muted:#f9fafb;--color-bailey-text:#000;--color-bailey-text-secondary:#6b6b6b;--color-bailey-tooltip-bg:#000;--color-bailey-tooltip-text:#fff}}@layer utilities{.collapse{visibility:collapse}.invisible{visibility:hidden}.visible{visibility:visible}.fixed{position:fixed}.relative{position:relative}.static{position:static}.container{width:100%}@media (width>=40rem){.container{max-width:40rem}}@media (width>=48rem){.container{max-width:48rem}}@media (width>=64rem){.container{max-width:64rem}}@media (width>=80rem){.container{max-width:80rem}}@media (width>=96rem){.container{max-width:96rem}}.my-2{margin-block:calc(var(--spacing) * 2)}.my-3{margin-block:calc(var(--spacing) * 3)}.mt-1{margin-top:var(--spacing)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mb-1{margin-bottom:var(--spacing)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.ml-1{margin-left:var(--spacing)}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.inline{display:inline}.table{display:table}.table-cell{display:table-cell}.h-\[600px\]{height:600px}.h-full{height:100%}.max-h-48{max-height:calc(var(--spacing) * 48)}.max-h-80{max-height:calc(var(--spacing) * 80)}.min-h-0{min-height:0}.w-full{width:100%}.max-w-\[75\%\]{max-width:75%}.flex-1{flex:1}.border-collapse{border-collapse:collapse}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.cursor-pointer{cursor:pointer}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-start{justify-content:flex-start}.gap-1{gap:var(--spacing)}.gap-2{gap:calc(var(--spacing) * 2)}.overflow-auto{overflow:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-md{border-radius:var(--radius-md)}.border{border-style:var(--tw-border-style);border-width:1px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-bailey-border{border-color:var(--color-bailey-border)}.border-bailey-error{border-color:var(--color-bailey-error)}.border-gray-200{border-color:var(--color-gray-200)}.bg-bailey-accent{background-color:var(--color-bailey-accent)}.bg-bailey-bubble-bg{background-color:var(--color-bailey-bubble-bg)}.bg-bailey-surface-muted{background-color:var(--color-bailey-surface-muted)}.bg-bailey-tooltip-bg{background-color:var(--color-bailey-tooltip-bg)}.bg-black{background-color:var(--color-black)}.bg-blue-100{background-color:var(--color-blue-100)}.bg-gray-50{background-color:var(--color-gray-50)}.bg-gray-200{background-color:var(--color-gray-200)}.bg-green-100{background-color:var(--color-green-100)}.bg-purple-100{background-color:var(--color-purple-100)}.bg-red-100{background-color:var(--color-red-100)}.fill-black{fill:var(--color-black)}.p-0{padding:0}.p-1{padding:var(--spacing)}.p-2{padding:calc(var(--spacing) * 2)}.px-1{padding-inline:var(--spacing)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.py-0{padding-block:0}.py-1{padding-block:var(--spacing)}.py-2{padding-block:calc(var(--spacing) * 2)}.pl-3{padding-left:calc(var(--spacing) * 3)}.pl-5{padding-left:calc(var(--spacing) * 5)}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[0\.7rem\]{font-size:.7rem}.text-\[0\.65rem\]{font-size:.65rem}.text-\[0\.85em\]{font-size:.85em}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.break-all{word-break:break-all}.whitespace-pre-wrap{white-space:pre-wrap}.text-bailey-accent{color:var(--color-bailey-accent)}.text-bailey-error{color:var(--color-bailey-error)}.text-bailey-text-secondary{color:var(--color-bailey-text-secondary)}.text-bailey-tooltip-text{color:var(--color-bailey-tooltip-text)}.text-black{color:var(--color-black)}.text-blue-700{color:var(--color-blue-700)}.text-gray-400{color:var(--color-gray-400)}.text-green-700{color:var(--color-green-700)}.text-white{color:var(--color-white)}.italic{font-style:italic}.underline{text-decoration-line:underline}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}@media (hover:hover){.hover\:text-bailey-text:hover{color:var(--color-bailey-text)}.hover\:text-black:hover{color:var(--color-black)}}}.bailey-chat-panel{flex-direction:column;height:100%;display:flex}.bailey-chat-transcript{min-height:0;padding:calc(var(--spacing) * 2);flex:1;overflow-y:auto}.bailey-message-row{margin-bottom:calc(var(--spacing) * 3);justify-content:flex-start;display:flex}.bailey-message-row-user{justify-content:flex-end}.bailey-user-bubble{border-radius:var(--radius-2xl);background-color:var(--color-bailey-bubble-bg);max-width:75%;padding-inline:calc(var(--spacing) * 4);padding-block:calc(var(--spacing) * 2);white-space:pre-wrap;color:var(--color-bailey-text)}.bailey-assistant-message{width:100%;padding-inline:var(--spacing)}.bailey-thinking-hint{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary);font-style:italic}.bailey-streaming-hint{margin-top:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);font-style:italic;display:block}.bailey-message-actions{margin-top:var(--spacing);align-items:center;gap:var(--spacing);display:flex}.bailey-empty-state{height:100%;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary);justify-content:center;align-items:center;display:flex}.bailey-error-banner{margin-bottom:calc(var(--spacing) * 2);justify-content:space-between;align-items:center;gap:calc(var(--spacing) * 2);border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-error);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);color:var(--color-bailey-error);display:flex}.bailey-retry-button{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium);text-decoration-line:underline}.bailey-error-actions{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.bailey-dismiss-button{color:var(--color-bailey-error)}@media (hover:hover){.bailey-dismiss-button:hover{opacity:.7}}.bailey-input-row{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.bailey-input{border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);flex:1}.bailey-input:disabled{opacity:.5}.bailey-send-button,.bailey-stop-button{border-radius:var(--radius-md);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}:is(.bailey-send-button,.bailey-stop-button):disabled{opacity:.5}.bailey-send-button{background-color:var(--color-bailey-accent);color:var(--color-white)}.bailey-stop-button{border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-error);color:var(--color-bailey-error)}.bailey-copy-button{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary)}@media (hover:hover){.bailey-copy-button:hover{color:var(--color-bailey-text)}}.bailey-tooltip-content{background-color:var(--color-bailey-tooltip-bg);padding-inline:calc(var(--spacing) * 2);padding-block:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-tooltip-text);border-radius:.25rem}.bailey-tooltip-arrow{fill:var(--color-bailey-tooltip-bg)}.bailey-markdown-content table{border-collapse:collapse;width:100%;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.bailey-markdown-content th{background-color:var(--color-bailey-surface-muted);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);text-align:left;--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content td{border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);vertical-align:top}.bailey-markdown-content tr:nth-child(2n){background-color:var(--color-bailey-surface-muted)}.bailey-markdown-content{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.bailey-markdown-content>:first-child{margin-top:0}.bailey-markdown-content>:last-child{margin-bottom:0}.bailey-markdown-content p{margin-block:calc(var(--spacing) * 2)}.bailey-markdown-content h1{margin-top:calc(var(--spacing) * 4);margin-bottom:calc(var(--spacing) * 2);font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content h2{margin-top:calc(var(--spacing) * 4);margin-bottom:calc(var(--spacing) * 2);font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content h3{margin-top:calc(var(--spacing) * 3);margin-bottom:calc(var(--spacing) * 1.5);font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content h4,.bailey-markdown-content h5,.bailey-markdown-content h6{margin-top:calc(var(--spacing) * 3);margin-bottom:calc(var(--spacing) * 1.5);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content ul{margin-block:calc(var(--spacing) * 2);list-style-type:disc}:where(.bailey-markdown-content ul>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}.bailey-markdown-content ul{padding-left:calc(var(--spacing) * 5)}.bailey-markdown-content ol{margin-block:calc(var(--spacing) * 2);list-style-type:decimal}:where(.bailey-markdown-content ol>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}.bailey-markdown-content ol{padding-left:calc(var(--spacing) * 5)}.bailey-markdown-content a{color:var(--color-bailey-accent);text-underline-offset:2px;text-decoration-line:underline}.bailey-markdown-content code{background-color:var(--color-bailey-surface-muted);padding-inline:var(--spacing);padding-block:calc(var(--spacing) * .5);font-family:var(--font-mono);border-radius:.25rem;font-size:.85em}.bailey-markdown-content pre{margin-block:calc(var(--spacing) * 2);border-radius:var(--radius-md);background-color:var(--color-bailey-surface-muted);padding:calc(var(--spacing) * 2);overflow-x:auto}.bailey-markdown-content pre code{background-color:#0000;padding:0}.bailey-markdown-content blockquote{margin-block:calc(var(--spacing) * 2);border-left-style:var(--tw-border-style);border-left-width:2px;border-color:var(--color-bailey-border);padding-left:calc(var(--spacing) * 3);color:var(--color-bailey-text-secondary);font-style:italic}.bailey-markdown-content hr{margin-block:calc(var(--spacing) * 3);border-color:var(--color-bailey-border)}.bailey-trace-panel{margin-bottom:calc(var(--spacing) * 2)}.bailey-trace-toggle-row{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.bailey-trace-toggle{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary)}.bailey-trace-toggle-error{color:var(--color-bailey-error)}.bailey-trace-summary{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary)}.bailey-trace-summary-error{color:var(--color-bailey-error)}.bailey-trace-body{margin-top:var(--spacing);max-height:calc(var(--spacing) * 80);overflow-y:auto}.bailey-trace-actions-row{justify-content:flex-end;gap:calc(var(--spacing) * 3);display:flex}.bailey-trace-copy-button{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary)}@media (hover:hover){.bailey-trace-copy-button:hover{color:var(--color-bailey-text)}}.bailey-trace-request-details{margin-bottom:var(--spacing);border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);padding:calc(var(--spacing) * 2)}.bailey-trace-request-meta{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);display:block}.bailey-trace-rows{gap:var(--spacing);flex-direction:column;display:flex}.bailey-trace-row{border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 2);padding-block:var(--spacing);font-family:var(--font-mono);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.bailey-trace-row-header{align-items:center;gap:calc(var(--spacing) * 2);flex-wrap:wrap;display:flex}.bailey-trace-row-time{color:var(--color-bailey-text-secondary)}.bailey-trace-row-gap{color:var(--color-gray-400)}.bailey-trace-row-summary{word-break:break-all}.bailey-trace-chip{padding-inline:calc(var(--spacing) * 1.5);padding-block:calc(var(--spacing) * .5);--tw-font-weight:var(--font-weight-semibold);font-size:.65rem;font-weight:var(--font-weight-semibold);border-radius:.25rem}.bailey-trace-chip-default{background-color:var(--color-gray-200);color:var(--color-gray-700)}.bailey-trace-chip-info{background-color:var(--color-blue-100);color:var(--color-blue-700)}.bailey-trace-chip-success{background-color:var(--color-green-100);color:var(--color-green-700)}.bailey-trace-chip-secondary{background-color:var(--color-purple-100);color:var(--color-purple-700)}.bailey-trace-chip-error{background-color:var(--color-red-100);color:var(--color-bailey-error)}.bailey-trace-disclosure{margin-top:var(--spacing)}.bailey-trace-disclosure-summary{cursor:pointer;color:var(--color-bailey-text-secondary);font-size:.7rem}.bailey-trace-disclosure-actions{margin-top:var(--spacing);justify-content:flex-end;display:flex}.bailey-trace-disclosure-content{margin-top:var(--spacing);max-height:calc(var(--spacing) * 48);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface-muted);padding:calc(var(--spacing) * 1.5);word-break:break-all;white-space:pre-wrap;border-radius:.25rem;font-size:.7rem;overflow:auto}.bailey-trace-group{border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 2);padding-block:var(--spacing)}.bailey-trace-group-summary{cursor:pointer;font-family:var(--font-mono);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.bailey-trace-group-failed{margin-left:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-error)}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-leading{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}
3
+ /*$vite$:1*/