vanilla-agent 1.20.0 → 1.22.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/README.md +87 -0
- package/dist/index.cjs +24 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +608 -6
- package/dist/index.d.ts +608 -6
- package/dist/index.global.js +44 -44
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +23 -23
- package/dist/index.js.map +1 -1
- package/dist/install.global.js +1 -1
- package/dist/install.global.js.map +1 -1
- package/dist/widget.css +467 -5
- package/package.json +1 -1
- package/src/client.ts +215 -1
- package/src/components/launcher.ts +10 -1
- package/src/components/message-bubble.ts +208 -4
- package/src/components/messages.ts +10 -3
- package/src/defaults.ts +32 -0
- package/src/index.ts +20 -4
- package/src/install.ts +69 -7
- package/src/postprocessors.ts +124 -6
- package/src/session.ts +77 -1
- package/src/styles/widget.css +467 -5
- package/src/types.ts +487 -0
- package/src/ui.ts +40 -5
package/dist/install.global.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var SiteAgentInstaller=(()=>{(function(){"use strict";if(window.__siteAgentInstallerLoaded)return;window.__siteAgentInstallerLoaded=!0;let n=window.siteAgentConfig||{},
|
|
1
|
+
"use strict";var SiteAgentInstaller=(()=>{(function(){"use strict";if(window.__siteAgentInstallerLoaded)return;window.__siteAgentInstallerLoaded=!0;let c=(()=>{let e=document.currentScript;if(!e)return{};let t={},i=e.getAttribute("data-travrse-token");i&&(t.clientToken=i);let o=e.getAttribute("data-flow-id");o&&(t.flowId=o);let l=e.getAttribute("data-api-url");return l&&(t.apiUrl=l),t})(),n={...window.siteAgentConfig||{},...c},d=n.version||"latest",g=n.cdn||"jsdelivr",f=n.autoInit!==!1,u=()=>{if(n.cssUrl&&n.jsUrl)return{cssUrl:n.cssUrl,jsUrl:n.jsUrl};let t=`/npm/vanilla-agent@${d}/dist`;return g==="unpkg"?{cssUrl:`https://unpkg.com${t}/widget.css`,jsUrl:`https://unpkg.com${t}/index.global.js`}:{cssUrl:`https://cdn.jsdelivr.net${t}/widget.css`,jsUrl:`https://cdn.jsdelivr.net${t}/index.global.js`}},{cssUrl:r,jsUrl:s}=u(),w=()=>!!document.head.querySelector("link[data-vanilla-agent]")||!!document.head.querySelector('link[href*="widget.css"]'),p=()=>!!window.AgentWidget,A=()=>new Promise((e,t)=>{if(w()){e();return}let i=document.createElement("link");i.rel="stylesheet",i.href=r,i.setAttribute("data-vanilla-agent","true"),i.onload=()=>e(),i.onerror=()=>t(new Error(`Failed to load CSS from ${r}`)),document.head.appendChild(i)}),m=()=>new Promise((e,t)=>{if(p()){e();return}let i=document.createElement("script");i.src=s,i.async=!0,i.onload=()=>e(),i.onerror=()=>t(new Error(`Failed to load JS from ${s}`)),document.head.appendChild(i)}),C=()=>{if(!window.AgentWidget||!window.AgentWidget.initAgentWidget){console.warn("AgentWidget not available. Make sure the script loaded successfully.");return}let e=n.target||"body",t={...n.config};if(n.apiUrl&&!t.apiUrl&&(t.apiUrl=n.apiUrl),n.clientToken&&!t.clientToken&&(t.clientToken=n.clientToken),n.flowId&&!t.flowId&&(t.flowId=n.flowId),!(!(t.apiUrl||t.clientToken)&&Object.keys(t).length===0))try{window.AgentWidget.initAgentWidget({target:e,config:t})}catch(o){console.error("Failed to initialize AgentWidget:",o)}},a=async()=>{try{await A(),await m(),f&&(n.config||n.apiUrl||n.clientToken)&&setTimeout(C,0)}catch(e){console.error("Failed to install AgentWidget:",e)}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",a):a()})();})();
|
|
2
2
|
//# sourceMappingURL=install.global.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/install.ts"],"sourcesContent":["/**\n * Standalone installer script for easy script tag installation\n * This script automatically loads CSS and JS, then initializes the widget\n * if configuration is provided via window.siteAgentConfig\n */\n\ninterface SiteAgentInstallConfig {\n version?: string;\n cdn?: \"unpkg\" | \"jsdelivr\";\n cssUrl?: string;\n jsUrl?: string;\n target?: string | HTMLElement;\n config?: any;\n autoInit?: boolean;\n}\n\ndeclare global {\n interface Window {\n siteAgentConfig?: SiteAgentInstallConfig;\n AgentWidget?: any;\n }\n}\n\n(function() {\n \"use strict\";\n\n // Prevent double installation\n if ((window as any).__siteAgentInstallerLoaded) {\n return;\n }\n (window as any).__siteAgentInstallerLoaded = true;\n\n const config: SiteAgentInstallConfig = window.siteAgentConfig || {};\n const version = config.version || \"latest\";\n const cdn = config.cdn || \"jsdelivr\";\n const autoInit = config.autoInit !== false; // Default to true\n\n // Determine CDN base URL\n const getCdnBase = () => {\n if (config.cssUrl && config.jsUrl) {\n return { cssUrl: config.cssUrl, jsUrl: config.jsUrl };\n }\n \n const packageName = \"vanilla-agent\";\n const basePath = `/npm/${packageName}@${version}/dist`;\n \n if (cdn === \"unpkg\") {\n return {\n cssUrl: `https://unpkg.com${basePath}/widget.css`,\n jsUrl: `https://unpkg.com${basePath}/index.global.js`\n };\n } else {\n return {\n cssUrl: `https://cdn.jsdelivr.net${basePath}/widget.css`,\n jsUrl: `https://cdn.jsdelivr.net${basePath}/index.global.js`\n };\n }\n };\n\n const { cssUrl, jsUrl } = getCdnBase();\n\n // Check if CSS is already loaded\n const isCssLoaded = () => {\n return !!document.head.querySelector('link[data-vanilla-agent]') ||\n !!document.head.querySelector(`link[href*=\"widget.css\"]`);\n };\n\n // Check if JS is already loaded\n const isJsLoaded = () => {\n return !!(window as any).AgentWidget;\n };\n\n // Load CSS\n const loadCSS = (): Promise<void> => {\n return new Promise((resolve, reject) => {\n if (isCssLoaded()) {\n resolve();\n return;\n }\n\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = cssUrl;\n link.setAttribute(\"data-vanilla-agent\", \"true\");\n link.onload = () => resolve();\n link.onerror = () => reject(new Error(`Failed to load CSS from ${cssUrl}`));\n document.head.appendChild(link);\n });\n };\n\n // Load JS\n const loadJS = (): Promise<void> => {\n return new Promise((resolve, reject) => {\n if (isJsLoaded()) {\n resolve();\n return;\n }\n\n const script = document.createElement(\"script\");\n script.src = jsUrl;\n script.async = true;\n script.onload = () => resolve();\n script.onerror = () => reject(new Error(`Failed to load JS from ${jsUrl}`));\n document.head.appendChild(script);\n });\n };\n\n // Initialize widget\n const initWidget = () => {\n if (!window.AgentWidget || !window.AgentWidget.initAgentWidget) {\n console.warn(\"AgentWidget not available. Make sure the script loaded successfully.\");\n return;\n }\n\n const target = config.target || \"body\";\n // Merge
|
|
1
|
+
{"version":3,"sources":["../src/install.ts"],"sourcesContent":["/**\n * Standalone installer script for easy script tag installation\n * This script automatically loads CSS and JS, then initializes the widget\n * if configuration is provided via window.siteAgentConfig\n */\n\ninterface SiteAgentInstallConfig {\n version?: string;\n cdn?: \"unpkg\" | \"jsdelivr\";\n cssUrl?: string;\n jsUrl?: string;\n target?: string | HTMLElement;\n config?: any;\n autoInit?: boolean;\n // Client token mode options (can also be set via data attributes)\n clientToken?: string;\n flowId?: string;\n apiUrl?: string;\n}\n\ndeclare global {\n interface Window {\n siteAgentConfig?: SiteAgentInstallConfig;\n AgentWidget?: any;\n }\n}\n\n(function() {\n \"use strict\";\n\n // Prevent double installation\n if ((window as any).__siteAgentInstallerLoaded) {\n return;\n }\n (window as any).__siteAgentInstallerLoaded = true;\n\n /**\n * Read configuration from data attributes on the current script tag.\n * Supports: data-travrse-token, data-flow-id, data-api-url\n */\n const getConfigFromScript = (): Partial<SiteAgentInstallConfig> => {\n // Try to get the current script element\n const script = document.currentScript as HTMLScriptElement | null;\n if (!script) return {};\n\n const scriptConfig: Partial<SiteAgentInstallConfig> = {};\n\n // Client token from data attribute (primary method for client token mode)\n const token = script.getAttribute('data-travrse-token');\n if (token) {\n scriptConfig.clientToken = token;\n }\n\n // Optional flow ID\n const flowId = script.getAttribute('data-flow-id');\n if (flowId) {\n scriptConfig.flowId = flowId;\n }\n\n // Optional API URL override\n const apiUrl = script.getAttribute('data-api-url');\n if (apiUrl) {\n scriptConfig.apiUrl = apiUrl;\n }\n\n return scriptConfig;\n };\n\n // Get config from script attributes (must be called synchronously during script execution)\n const scriptConfig = getConfigFromScript();\n\n // Merge script attributes with window config (script attributes take precedence)\n const windowConfig: SiteAgentInstallConfig = window.siteAgentConfig || {};\n const config: SiteAgentInstallConfig = { ...windowConfig, ...scriptConfig };\n \n const version = config.version || \"latest\";\n const cdn = config.cdn || \"jsdelivr\";\n const autoInit = config.autoInit !== false; // Default to true\n\n // Determine CDN base URL\n const getCdnBase = () => {\n if (config.cssUrl && config.jsUrl) {\n return { cssUrl: config.cssUrl, jsUrl: config.jsUrl };\n }\n \n const packageName = \"vanilla-agent\";\n const basePath = `/npm/${packageName}@${version}/dist`;\n \n if (cdn === \"unpkg\") {\n return {\n cssUrl: `https://unpkg.com${basePath}/widget.css`,\n jsUrl: `https://unpkg.com${basePath}/index.global.js`\n };\n } else {\n return {\n cssUrl: `https://cdn.jsdelivr.net${basePath}/widget.css`,\n jsUrl: `https://cdn.jsdelivr.net${basePath}/index.global.js`\n };\n }\n };\n\n const { cssUrl, jsUrl } = getCdnBase();\n\n // Check if CSS is already loaded\n const isCssLoaded = () => {\n return !!document.head.querySelector('link[data-vanilla-agent]') ||\n !!document.head.querySelector(`link[href*=\"widget.css\"]`);\n };\n\n // Check if JS is already loaded\n const isJsLoaded = () => {\n return !!(window as any).AgentWidget;\n };\n\n // Load CSS\n const loadCSS = (): Promise<void> => {\n return new Promise((resolve, reject) => {\n if (isCssLoaded()) {\n resolve();\n return;\n }\n\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = cssUrl;\n link.setAttribute(\"data-vanilla-agent\", \"true\");\n link.onload = () => resolve();\n link.onerror = () => reject(new Error(`Failed to load CSS from ${cssUrl}`));\n document.head.appendChild(link);\n });\n };\n\n // Load JS\n const loadJS = (): Promise<void> => {\n return new Promise((resolve, reject) => {\n if (isJsLoaded()) {\n resolve();\n return;\n }\n\n const script = document.createElement(\"script\");\n script.src = jsUrl;\n script.async = true;\n script.onload = () => resolve();\n script.onerror = () => reject(new Error(`Failed to load JS from ${jsUrl}`));\n document.head.appendChild(script);\n });\n };\n\n // Initialize widget\n const initWidget = () => {\n if (!window.AgentWidget || !window.AgentWidget.initAgentWidget) {\n console.warn(\"AgentWidget not available. Make sure the script loaded successfully.\");\n return;\n }\n\n const target = config.target || \"body\";\n // Merge top-level config options into widget config\n const widgetConfig = { ...config.config };\n \n // Merge apiUrl from top-level config into widget config if present\n if (config.apiUrl && !widgetConfig.apiUrl) {\n widgetConfig.apiUrl = config.apiUrl;\n }\n \n // Merge clientToken from top-level config into widget config if present\n if (config.clientToken && !widgetConfig.clientToken) {\n widgetConfig.clientToken = config.clientToken;\n }\n \n // Merge flowId from top-level config into widget config if present\n if (config.flowId && !widgetConfig.flowId) {\n widgetConfig.flowId = config.flowId;\n }\n\n // Only initialize if we have either apiUrl OR clientToken (or other config)\n const hasApiConfig = widgetConfig.apiUrl || widgetConfig.clientToken;\n if (!hasApiConfig && Object.keys(widgetConfig).length === 0) {\n return;\n }\n\n try {\n window.AgentWidget.initAgentWidget({\n target,\n config: widgetConfig\n });\n } catch (error) {\n console.error(\"Failed to initialize AgentWidget:\", error);\n }\n };\n\n // Main installation flow\n const install = async () => {\n try {\n await loadCSS();\n await loadJS();\n \n // Auto-init if we have config OR apiUrl OR clientToken\n const shouldAutoInit = autoInit && (\n config.config || \n config.apiUrl || \n config.clientToken\n );\n \n if (shouldAutoInit) {\n // Wait a tick to ensure AgentWidget is fully initialized\n setTimeout(initWidget, 0);\n }\n } catch (error) {\n console.error(\"Failed to install AgentWidget:\", error);\n }\n };\n\n // Start installation\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", install);\n } else {\n install();\n }\n})();\n\n"],"mappings":"2CA2BC,UAAW,CACV,aAGA,GAAK,OAAe,2BAClB,OAED,OAAe,2BAA6B,GAmC7C,IAAMA,GA7BsB,IAAuC,CAEjE,IAAMC,EAAS,SAAS,cACxB,GAAI,CAACA,EAAQ,MAAO,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AQ,CAEZ,GAAG","names":["scriptConfig","script","token","flowId","apiUrl","config","version","cdn","autoInit","getCdnBase","basePath","cssUrl","jsUrl","isCssLoaded","isJsLoaded","loadCSS","resolve","reject","link","loadJS","initWidget","target","widgetConfig","error","install"]}
|
package/dist/widget.css
CHANGED
|
@@ -6,6 +6,16 @@
|
|
|
6
6
|
all: initial;
|
|
7
7
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
|
|
8
8
|
line-height: 1.5;
|
|
9
|
+
|
|
10
|
+
/* Theme-aware markdown variables - inherit from theme colors set by JavaScript */
|
|
11
|
+
--cw-md-code-block-bg: var(--cw-container, #f3f4f6);
|
|
12
|
+
--cw-md-code-block-border-color: var(--cw-border, #e5e7eb);
|
|
13
|
+
--cw-md-inline-code-bg: var(--cw-container, #f3f4f6);
|
|
14
|
+
--cw-md-table-border-color: var(--cw-border, #e5e7eb);
|
|
15
|
+
--cw-md-table-header-bg: var(--cw-container, #f8fafc);
|
|
16
|
+
--cw-md-hr-color: var(--cw-divider, #e5e7eb);
|
|
17
|
+
--cw-md-blockquote-border-color: var(--cw-accent, #3b82f6);
|
|
18
|
+
--cw-md-blockquote-text-color: var(--cw-muted, #6b7280);
|
|
9
19
|
}
|
|
10
20
|
|
|
11
21
|
#vanilla-agent-root * {
|
|
@@ -86,6 +96,71 @@
|
|
|
86
96
|
--cw-radius-lg: 1.5rem;
|
|
87
97
|
--cw-launcher-radius: 9999px;
|
|
88
98
|
--cw-button-radius: 9999px;
|
|
99
|
+
|
|
100
|
+
/* Markdown Header Variables */
|
|
101
|
+
--cw-md-h1-size: 1.5rem;
|
|
102
|
+
--cw-md-h1-weight: 700;
|
|
103
|
+
--cw-md-h1-margin: 1rem 0 0.5rem;
|
|
104
|
+
--cw-md-h1-line-height: 1.25;
|
|
105
|
+
--cw-md-h2-size: 1.25rem;
|
|
106
|
+
--cw-md-h2-weight: 700;
|
|
107
|
+
--cw-md-h2-margin: 0.875rem 0 0.5rem;
|
|
108
|
+
--cw-md-h2-line-height: 1.3;
|
|
109
|
+
--cw-md-h3-size: 1.125rem;
|
|
110
|
+
--cw-md-h3-weight: 600;
|
|
111
|
+
--cw-md-h3-margin: 0.75rem 0 0.375rem;
|
|
112
|
+
--cw-md-h3-line-height: 1.4;
|
|
113
|
+
--cw-md-h4-size: 1rem;
|
|
114
|
+
--cw-md-h4-weight: 600;
|
|
115
|
+
--cw-md-h4-margin: 0.625rem 0 0.25rem;
|
|
116
|
+
--cw-md-h4-line-height: 1.5;
|
|
117
|
+
--cw-md-h5-size: 0.875rem;
|
|
118
|
+
--cw-md-h5-weight: 600;
|
|
119
|
+
--cw-md-h5-margin: 0.5rem 0 0.25rem;
|
|
120
|
+
--cw-md-h5-line-height: 1.5;
|
|
121
|
+
--cw-md-h6-size: 0.75rem;
|
|
122
|
+
--cw-md-h6-weight: 600;
|
|
123
|
+
--cw-md-h6-margin: 0.5rem 0 0.25rem;
|
|
124
|
+
--cw-md-h6-line-height: 1.5;
|
|
125
|
+
|
|
126
|
+
/* Markdown Table Variables (defaults - theme-aware values set on #vanilla-agent-root) */
|
|
127
|
+
--cw-md-table-border-color: #e5e7eb;
|
|
128
|
+
--cw-md-table-header-bg: #f8fafc;
|
|
129
|
+
--cw-md-table-header-weight: 600;
|
|
130
|
+
--cw-md-table-cell-padding: 0.5rem 0.75rem;
|
|
131
|
+
--cw-md-table-border-radius: 0.375rem;
|
|
132
|
+
|
|
133
|
+
/* Markdown Horizontal Rule Variables (defaults - theme-aware values set on #vanilla-agent-root) */
|
|
134
|
+
--cw-md-hr-color: #e5e7eb;
|
|
135
|
+
--cw-md-hr-height: 1px;
|
|
136
|
+
--cw-md-hr-margin: 1rem 0;
|
|
137
|
+
|
|
138
|
+
/* Markdown Blockquote Variables (defaults - theme-aware values set on #vanilla-agent-root) */
|
|
139
|
+
--cw-md-blockquote-border-color: #3b82f6;
|
|
140
|
+
--cw-md-blockquote-border-width: 3px;
|
|
141
|
+
--cw-md-blockquote-padding: 0.5rem 1rem;
|
|
142
|
+
--cw-md-blockquote-margin: 0.5rem 0;
|
|
143
|
+
--cw-md-blockquote-bg: transparent;
|
|
144
|
+
--cw-md-blockquote-text-color: #6b7280;
|
|
145
|
+
--cw-md-blockquote-font-style: italic;
|
|
146
|
+
|
|
147
|
+
/* Markdown Code Block Variables (defaults - theme-aware values set on #vanilla-agent-root) */
|
|
148
|
+
--cw-md-code-block-bg: #f3f4f6;
|
|
149
|
+
--cw-md-code-block-border-color: #e5e7eb;
|
|
150
|
+
--cw-md-code-block-text-color: inherit;
|
|
151
|
+
--cw-md-code-block-padding: 0.75rem;
|
|
152
|
+
--cw-md-code-block-border-radius: 0.375rem;
|
|
153
|
+
--cw-md-code-block-font-size: 0.875rem;
|
|
154
|
+
|
|
155
|
+
/* Markdown Inline Code Variables (defaults - theme-aware values set on #vanilla-agent-root) */
|
|
156
|
+
--cw-md-inline-code-bg: #f3f4f6;
|
|
157
|
+
--cw-md-inline-code-padding: 0.125rem 0.375rem;
|
|
158
|
+
--cw-md-inline-code-border-radius: 0.25rem;
|
|
159
|
+
--cw-md-inline-code-font-size: 0.875em;
|
|
160
|
+
|
|
161
|
+
/* Markdown Strong/Em Variables */
|
|
162
|
+
--cw-md-strong-weight: 600;
|
|
163
|
+
--cw-md-em-style: italic;
|
|
89
164
|
}
|
|
90
165
|
|
|
91
166
|
.tvw-rounded-xl {
|
|
@@ -803,13 +878,14 @@ form:focus-within textarea {
|
|
|
803
878
|
word-wrap: break-word;
|
|
804
879
|
word-break: break-word;
|
|
805
880
|
white-space: pre-wrap;
|
|
806
|
-
background-color:
|
|
807
|
-
|
|
808
|
-
|
|
881
|
+
background-color: var(--cw-md-code-block-bg);
|
|
882
|
+
color: var(--cw-md-code-block-text-color);
|
|
883
|
+
padding: var(--cw-md-code-block-padding);
|
|
884
|
+
border-radius: var(--cw-md-code-block-border-radius);
|
|
809
885
|
margin: 0.5rem 0;
|
|
810
|
-
font-size:
|
|
886
|
+
font-size: var(--cw-md-code-block-font-size);
|
|
811
887
|
line-height: 1.5;
|
|
812
|
-
border: 1px solid
|
|
888
|
+
border: 1px solid var(--cw-md-code-block-border-color);
|
|
813
889
|
}
|
|
814
890
|
|
|
815
891
|
.vanilla-message-bubble code {
|
|
@@ -938,3 +1014,389 @@ form:focus-within textarea {
|
|
|
938
1014
|
margin: 0.25rem 0;
|
|
939
1015
|
padding-left: 0.25rem;
|
|
940
1016
|
}
|
|
1017
|
+
|
|
1018
|
+
/* ============================================
|
|
1019
|
+
Markdown Header Styles
|
|
1020
|
+
============================================ */
|
|
1021
|
+
.vanilla-message-bubble h1 {
|
|
1022
|
+
font-size: var(--cw-md-h1-size);
|
|
1023
|
+
font-weight: var(--cw-md-h1-weight);
|
|
1024
|
+
margin: var(--cw-md-h1-margin);
|
|
1025
|
+
line-height: var(--cw-md-h1-line-height);
|
|
1026
|
+
color: inherit;
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
.vanilla-message-bubble h2 {
|
|
1030
|
+
font-size: var(--cw-md-h2-size);
|
|
1031
|
+
font-weight: var(--cw-md-h2-weight);
|
|
1032
|
+
margin: var(--cw-md-h2-margin);
|
|
1033
|
+
line-height: var(--cw-md-h2-line-height);
|
|
1034
|
+
color: inherit;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
.vanilla-message-bubble h3 {
|
|
1038
|
+
font-size: var(--cw-md-h3-size);
|
|
1039
|
+
font-weight: var(--cw-md-h3-weight);
|
|
1040
|
+
margin: var(--cw-md-h3-margin);
|
|
1041
|
+
line-height: var(--cw-md-h3-line-height);
|
|
1042
|
+
color: inherit;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
.vanilla-message-bubble h4 {
|
|
1046
|
+
font-size: var(--cw-md-h4-size);
|
|
1047
|
+
font-weight: var(--cw-md-h4-weight);
|
|
1048
|
+
margin: var(--cw-md-h4-margin);
|
|
1049
|
+
line-height: var(--cw-md-h4-line-height);
|
|
1050
|
+
color: inherit;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
.vanilla-message-bubble h5 {
|
|
1054
|
+
font-size: var(--cw-md-h5-size);
|
|
1055
|
+
font-weight: var(--cw-md-h5-weight);
|
|
1056
|
+
margin: var(--cw-md-h5-margin);
|
|
1057
|
+
line-height: var(--cw-md-h5-line-height);
|
|
1058
|
+
color: inherit;
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
.vanilla-message-bubble h6 {
|
|
1062
|
+
font-size: var(--cw-md-h6-size);
|
|
1063
|
+
font-weight: var(--cw-md-h6-weight);
|
|
1064
|
+
margin: var(--cw-md-h6-margin);
|
|
1065
|
+
line-height: var(--cw-md-h6-line-height);
|
|
1066
|
+
color: inherit;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
/* Remove top margin on first heading */
|
|
1070
|
+
.vanilla-message-bubble h1:first-child,
|
|
1071
|
+
.vanilla-message-bubble h2:first-child,
|
|
1072
|
+
.vanilla-message-bubble h3:first-child,
|
|
1073
|
+
.vanilla-message-bubble h4:first-child,
|
|
1074
|
+
.vanilla-message-bubble h5:first-child,
|
|
1075
|
+
.vanilla-message-bubble h6:first-child {
|
|
1076
|
+
margin-top: 0;
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
/* ============================================
|
|
1080
|
+
Markdown Table Styles
|
|
1081
|
+
============================================ */
|
|
1082
|
+
.vanilla-message-bubble table {
|
|
1083
|
+
width: 100%;
|
|
1084
|
+
border-collapse: collapse;
|
|
1085
|
+
margin: 0.5rem 0;
|
|
1086
|
+
font-size: 0.875rem;
|
|
1087
|
+
overflow: hidden;
|
|
1088
|
+
border-radius: var(--cw-md-table-border-radius);
|
|
1089
|
+
border: 1px solid var(--cw-md-table-border-color);
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
.vanilla-message-bubble thead {
|
|
1093
|
+
background-color: var(--cw-md-table-header-bg);
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
.vanilla-message-bubble th {
|
|
1097
|
+
font-weight: var(--cw-md-table-header-weight);
|
|
1098
|
+
text-align: left;
|
|
1099
|
+
padding: var(--cw-md-table-cell-padding);
|
|
1100
|
+
border-bottom: 1px solid var(--cw-md-table-border-color);
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
.vanilla-message-bubble td {
|
|
1104
|
+
padding: var(--cw-md-table-cell-padding);
|
|
1105
|
+
border-bottom: 1px solid var(--cw-md-table-border-color);
|
|
1106
|
+
text-align: left;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
.vanilla-message-bubble tr:last-child td {
|
|
1110
|
+
border-bottom: none;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
.vanilla-message-bubble tbody tr:nth-child(even) {
|
|
1114
|
+
background-color: rgba(0, 0, 0, 0.02);
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
/* ============================================
|
|
1118
|
+
Markdown Horizontal Rule Styles
|
|
1119
|
+
============================================ */
|
|
1120
|
+
.vanilla-message-bubble hr {
|
|
1121
|
+
border: none;
|
|
1122
|
+
height: var(--cw-md-hr-height);
|
|
1123
|
+
background-color: var(--cw-md-hr-color);
|
|
1124
|
+
margin: var(--cw-md-hr-margin);
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
/* ============================================
|
|
1128
|
+
Markdown Blockquote Styles
|
|
1129
|
+
============================================ */
|
|
1130
|
+
.vanilla-message-bubble blockquote {
|
|
1131
|
+
border-left: var(--cw-md-blockquote-border-width) solid var(--cw-md-blockquote-border-color);
|
|
1132
|
+
padding: var(--cw-md-blockquote-padding);
|
|
1133
|
+
margin: var(--cw-md-blockquote-margin);
|
|
1134
|
+
background-color: var(--cw-md-blockquote-bg);
|
|
1135
|
+
color: var(--cw-md-blockquote-text-color);
|
|
1136
|
+
font-style: var(--cw-md-blockquote-font-style);
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
.vanilla-message-bubble blockquote p {
|
|
1140
|
+
margin: 0;
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
.vanilla-message-bubble blockquote p + p {
|
|
1144
|
+
margin-top: 0.5rem;
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
/* Nested blockquotes */
|
|
1148
|
+
.vanilla-message-bubble blockquote blockquote {
|
|
1149
|
+
margin-left: 0.5rem;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
/* ============================================
|
|
1153
|
+
Markdown Inline Code Styles (not in pre)
|
|
1154
|
+
============================================ */
|
|
1155
|
+
.vanilla-message-bubble code:not(pre code) {
|
|
1156
|
+
background-color: var(--cw-md-inline-code-bg);
|
|
1157
|
+
padding: var(--cw-md-inline-code-padding);
|
|
1158
|
+
border-radius: var(--cw-md-inline-code-border-radius);
|
|
1159
|
+
font-size: var(--cw-md-inline-code-font-size);
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
/* ============================================
|
|
1163
|
+
Markdown Strong/Emphasis Styles
|
|
1164
|
+
============================================ */
|
|
1165
|
+
.vanilla-message-bubble strong,
|
|
1166
|
+
.vanilla-message-bubble b {
|
|
1167
|
+
font-weight: var(--cw-md-strong-weight);
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
.vanilla-message-bubble em,
|
|
1171
|
+
.vanilla-message-bubble i {
|
|
1172
|
+
font-style: var(--cw-md-em-style);
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
/* ============================================
|
|
1176
|
+
User Message Markdown Overrides
|
|
1177
|
+
Ensure styles work in user bubbles too
|
|
1178
|
+
============================================ */
|
|
1179
|
+
.vanilla-message-user-bubble h1,
|
|
1180
|
+
.vanilla-message-user-bubble h2,
|
|
1181
|
+
.vanilla-message-user-bubble h3,
|
|
1182
|
+
.vanilla-message-user-bubble h4,
|
|
1183
|
+
.vanilla-message-user-bubble h5,
|
|
1184
|
+
.vanilla-message-user-bubble h6 {
|
|
1185
|
+
color: inherit;
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
.vanilla-message-user-bubble table {
|
|
1189
|
+
border-color: rgba(255, 255, 255, 0.3);
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
.vanilla-message-user-bubble th,
|
|
1193
|
+
.vanilla-message-user-bubble td {
|
|
1194
|
+
border-color: rgba(255, 255, 255, 0.3);
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
.vanilla-message-user-bubble thead {
|
|
1198
|
+
background-color: rgba(255, 255, 255, 0.1);
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
.vanilla-message-user-bubble tbody tr:nth-child(even) {
|
|
1202
|
+
background-color: rgba(255, 255, 255, 0.05);
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
.vanilla-message-user-bubble hr {
|
|
1206
|
+
background-color: rgba(255, 255, 255, 0.3);
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
.vanilla-message-user-bubble blockquote {
|
|
1210
|
+
border-left-color: rgba(255, 255, 255, 0.5);
|
|
1211
|
+
color: inherit;
|
|
1212
|
+
opacity: 0.9;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
.vanilla-message-user-bubble code:not(pre code) {
|
|
1216
|
+
background-color: rgba(255, 255, 255, 0.2);
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
/* ============================================
|
|
1220
|
+
Message Action Buttons (Copy, Upvote, Downvote)
|
|
1221
|
+
============================================ */
|
|
1222
|
+
|
|
1223
|
+
/* Make message bubble position relative for overlay positioning */
|
|
1224
|
+
.vanilla-message-bubble {
|
|
1225
|
+
position: relative;
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
/* Fade-in animation for action buttons */
|
|
1229
|
+
@keyframes tvw-message-actions-fade-in {
|
|
1230
|
+
from {
|
|
1231
|
+
opacity: 0;
|
|
1232
|
+
}
|
|
1233
|
+
to {
|
|
1234
|
+
opacity: 1;
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
/* Base action bar styles */
|
|
1239
|
+
.tvw-message-actions {
|
|
1240
|
+
display: flex;
|
|
1241
|
+
align-items: center;
|
|
1242
|
+
gap: 0.25rem;
|
|
1243
|
+
margin-top: 0.5rem;
|
|
1244
|
+
padding-top: 0.5rem;
|
|
1245
|
+
border-top: 1px solid var(--cw-divider, #f1f5f9);
|
|
1246
|
+
/* Fade in when first shown (for "always" visibility) */
|
|
1247
|
+
animation: tvw-message-actions-fade-in 0.3s ease-out;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
/* Action bar alignment */
|
|
1251
|
+
.tvw-message-actions-left {
|
|
1252
|
+
justify-content: flex-start;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
.tvw-message-actions-center {
|
|
1256
|
+
justify-content: center;
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
.tvw-message-actions-right {
|
|
1260
|
+
justify-content: flex-end;
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
/* Hover visibility mode - overlay on desktop */
|
|
1264
|
+
@media (hover: hover) {
|
|
1265
|
+
.tvw-message-actions-hover {
|
|
1266
|
+
/* Hidden by default */
|
|
1267
|
+
opacity: 0;
|
|
1268
|
+
pointer-events: none;
|
|
1269
|
+
transition: opacity 0.15s ease-in-out;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
/* Pill layout - compact floating pill */
|
|
1273
|
+
.tvw-message-actions-hover.tvw-message-actions-pill {
|
|
1274
|
+
position: absolute;
|
|
1275
|
+
bottom: 0.5rem;
|
|
1276
|
+
margin-top: 0;
|
|
1277
|
+
padding: 0.25rem;
|
|
1278
|
+
border-top: none;
|
|
1279
|
+
width: fit-content;
|
|
1280
|
+
background-color: var(--cw-surface, #ffffff);
|
|
1281
|
+
border: 1px solid var(--cw-divider, #f1f5f9);
|
|
1282
|
+
border-radius: var(--cw-radius-md, 0.75rem);
|
|
1283
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
/* Pill layout - position based on alignment */
|
|
1287
|
+
.tvw-message-actions-hover.tvw-message-actions-pill.tvw-message-actions-left {
|
|
1288
|
+
left: 0.75rem;
|
|
1289
|
+
right: auto;
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
.tvw-message-actions-hover.tvw-message-actions-pill.tvw-message-actions-center {
|
|
1293
|
+
left: 50%;
|
|
1294
|
+
right: auto;
|
|
1295
|
+
transform: translateX(-50%);
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
.tvw-message-actions-hover.tvw-message-actions-pill.tvw-message-actions-right {
|
|
1299
|
+
right: 0.75rem;
|
|
1300
|
+
left: auto;
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
/* Row layout - full-width bar at bottom */
|
|
1304
|
+
.tvw-message-actions-hover.tvw-message-actions-row {
|
|
1305
|
+
position: absolute;
|
|
1306
|
+
bottom: 0;
|
|
1307
|
+
left: 0;
|
|
1308
|
+
right: 0;
|
|
1309
|
+
margin-top: 0;
|
|
1310
|
+
padding: 0.5rem 0.75rem;
|
|
1311
|
+
border-top: none;
|
|
1312
|
+
background: linear-gradient(
|
|
1313
|
+
to top,
|
|
1314
|
+
var(--cw-surface, #ffffff) 70%,
|
|
1315
|
+
transparent
|
|
1316
|
+
);
|
|
1317
|
+
border-radius: 0 0 var(--cw-radius-lg, 1.5rem) var(--cw-radius-lg, 1.5rem);
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
.vanilla-message-bubble:hover .tvw-message-actions-hover,
|
|
1321
|
+
.vanilla-message-bubble:focus-within .tvw-message-actions-hover {
|
|
1322
|
+
opacity: 1;
|
|
1323
|
+
pointer-events: auto;
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
/* On touch devices (no hover support), show inline and always visible */
|
|
1328
|
+
@media (hover: none) {
|
|
1329
|
+
.tvw-message-actions-hover {
|
|
1330
|
+
/* Keep normal flow positioning on mobile */
|
|
1331
|
+
position: static;
|
|
1332
|
+
opacity: 1;
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
/* Action button base styles */
|
|
1337
|
+
.tvw-message-action-btn {
|
|
1338
|
+
display: inline-flex;
|
|
1339
|
+
align-items: center;
|
|
1340
|
+
justify-content: center;
|
|
1341
|
+
width: 28px;
|
|
1342
|
+
height: 28px;
|
|
1343
|
+
padding: 0;
|
|
1344
|
+
border: none;
|
|
1345
|
+
border-radius: 6px;
|
|
1346
|
+
background-color: transparent;
|
|
1347
|
+
color: var(--cw-muted, #6b7280);
|
|
1348
|
+
cursor: pointer;
|
|
1349
|
+
transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
.tvw-message-action-btn:hover {
|
|
1353
|
+
background-color: var(--cw-container, #f8fafc);
|
|
1354
|
+
color: var(--cw-primary, #111827);
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
.tvw-message-action-btn:active {
|
|
1358
|
+
transform: scale(0.95);
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
.tvw-message-action-btn:focus {
|
|
1362
|
+
outline: none;
|
|
1363
|
+
box-shadow: 0 0 0 2px var(--cw-accent, #1d4ed8);
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
.tvw-message-action-btn:focus:not(:focus-visible) {
|
|
1367
|
+
box-shadow: none;
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
.tvw-message-action-btn:focus-visible {
|
|
1371
|
+
box-shadow: 0 0 0 2px var(--cw-accent, #1d4ed8);
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
/* Active state (voted) */
|
|
1375
|
+
.tvw-message-action-btn.tvw-message-action-active {
|
|
1376
|
+
background-color: var(--cw-accent, #1d4ed8);
|
|
1377
|
+
color: #ffffff;
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
.tvw-message-action-btn.tvw-message-action-active:hover {
|
|
1381
|
+
background-color: var(--cw-accent, #1d4ed8);
|
|
1382
|
+
color: #ffffff;
|
|
1383
|
+
opacity: 0.9;
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
/* Success state (after copy) */
|
|
1387
|
+
.tvw-message-action-btn.tvw-message-action-success {
|
|
1388
|
+
background-color: #10b981;
|
|
1389
|
+
color: #ffffff;
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
.tvw-message-action-btn.tvw-message-action-success:hover {
|
|
1393
|
+
background-color: #10b981;
|
|
1394
|
+
color: #ffffff;
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
/* Icon styling within buttons */
|
|
1398
|
+
.tvw-message-action-btn svg {
|
|
1399
|
+
width: 14px;
|
|
1400
|
+
height: 14px;
|
|
1401
|
+
flex-shrink: 0;
|
|
1402
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vanilla-agent",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.0",
|
|
4
4
|
"description": "Themeable, plugable streaming agent widget for websites, in plain JS with support for voice input and reasoning / tool output.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|