dewee-webchat 0.1.0 → 0.1.1

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 CHANGED
@@ -65,7 +65,7 @@ Create a scoped key with the Dewee CLI: `dewee api-keys create --name "website c
65
65
 
66
66
  ```html
67
67
  <script
68
- src="https://webchat-cdn.dewee.sh/dewee-webchat@0.1.0/dewee-webchat.js"
68
+ src="https://webchat-cdn.dewee.sh/dewee-webchat@0.1.1/dewee-webchat.js"
69
69
  data-endpoint="/api/dewee"
70
70
  data-title="Support"
71
71
  data-suggestions="What do you do?|Pricing?"
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  HEADER_GATEWAY_TOKEN,
3
3
  HEADER_GATEWAY_URL
4
- } from "./chunk-MKTHKYLY.js";
4
+ } from "./chunk-WD6V3TAX.js";
5
5
 
6
6
  // src/widget/api-client.ts
7
7
  var ApiError = class extends Error {
@@ -449,6 +449,8 @@ button { font: inherit; color: inherit; background: none; border: 0; cursor: poi
449
449
  @media (max-width: 520px) {
450
450
  :host(:not([data-mode="inline"])) .panel { inset: 0; width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
451
451
  :host([data-open]:not([data-mode="inline"])) .launcher { display: none; }
452
+ :host(:not([data-mode="inline"])) .head { padding-top: max(14px, env(safe-area-inset-top)); }
453
+ :host(:not([data-mode="inline"])) .composer { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
452
454
  }
453
455
 
454
456
  /* ---------- header ---------- */
@@ -466,7 +468,7 @@ button { font: inherit; color: inherit; background: none; border: 0; cursor: poi
466
468
  .who { flex: 1; min-width: 0; }
467
469
  .title { font-weight: 650; font-size: 15px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
468
470
  .subtitle { font-size: 12px; color: var(--dw-muted); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
469
- .dot { width: 7px; height: 7px; border-radius: 50%; background: #22c58b; box-shadow: 0 0 0 3px color-mix(in srgb, #22c58b 22%, transparent); }
471
+ .dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: #22c58b; box-shadow: 0 0 0 3px color-mix(in srgb, #22c58b 22%, transparent); }
470
472
  .agent-select {
471
473
  font: inherit; font-size: 12px; color: var(--dw-muted); background: transparent; border: 0;
472
474
  padding: 0 14px 0 0; margin: 0; max-width: 170px; cursor: pointer; appearance: none; field-sizing: content; text-overflow: ellipsis;
@@ -576,7 +578,7 @@ details > summary svg.ic { width: 14px; height: 14px; flex: none; }
576
578
  .box:focus-within { border-color: var(--dw-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dw-accent) 16%, transparent); }
577
579
  textarea {
578
580
  flex: 1; resize: none; border: 0; outline: 0; background: transparent; color: var(--dw-fg);
579
- font: inherit; font-size: 14.5px; line-height: 1.5; max-height: 140px; padding: 6px 0; min-height: 34px;
581
+ font: inherit; font-size: 16px; line-height: 1.45; max-height: 140px; padding: 5px 0; min-height: 34px;
580
582
  }
581
583
  textarea::placeholder { color: var(--dw-muted); }
582
584
  .send {
@@ -591,6 +593,10 @@ textarea::placeholder { color: var(--dw-muted); }
591
593
  .foot a:hover { color: var(--dw-accent); }
592
594
  .challenge:empty { display: none; }
593
595
  .challenge { display: flex; justify-content: center; padding: 8px 0; }
596
+ /* iOS zooms into any focused field under 16px; keep touch-device fields at 16px. */
597
+ @media (pointer: coarse) {
598
+ .agent-select { font-size: 16px; max-width: 200px; }
599
+ }
594
600
  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
595
601
  `
596
602
  );
@@ -1,7 +1,7 @@
1
1
  // src/protocol.ts
2
2
  var HEADER_GATEWAY_URL = "x-dewee-gateway-url";
3
3
  var HEADER_GATEWAY_TOKEN = "x-dewee-gateway-token";
4
- var VERSION = "0.1.0";
4
+ var VERSION = "0.1.1";
5
5
 
6
6
  export {
7
7
  HEADER_GATEWAY_URL,
@@ -82,6 +82,8 @@ button { font: inherit; color: inherit; background: none; border: 0; cursor: poi
82
82
  @media (max-width: 520px) {
83
83
  :host(:not([data-mode="inline"])) .panel { inset: 0; width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
84
84
  :host([data-open]:not([data-mode="inline"])) .launcher { display: none; }
85
+ :host(:not([data-mode="inline"])) .head { padding-top: max(14px, env(safe-area-inset-top)); }
86
+ :host(:not([data-mode="inline"])) .composer { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
85
87
  }
86
88
 
87
89
  /* ---------- header ---------- */
@@ -99,7 +101,7 @@ button { font: inherit; color: inherit; background: none; border: 0; cursor: poi
99
101
  .who { flex: 1; min-width: 0; }
100
102
  .title { font-weight: 650; font-size: 15px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
101
103
  .subtitle { font-size: 12px; color: var(--dw-muted); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
102
- .dot { width: 7px; height: 7px; border-radius: 50%; background: #22c58b; box-shadow: 0 0 0 3px color-mix(in srgb, #22c58b 22%, transparent); }
104
+ .dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: #22c58b; box-shadow: 0 0 0 3px color-mix(in srgb, #22c58b 22%, transparent); }
103
105
  .agent-select {
104
106
  font: inherit; font-size: 12px; color: var(--dw-muted); background: transparent; border: 0;
105
107
  padding: 0 14px 0 0; margin: 0; max-width: 170px; cursor: pointer; appearance: none; field-sizing: content; text-overflow: ellipsis;
@@ -209,7 +211,7 @@ details > summary svg.ic { width: 14px; height: 14px; flex: none; }
209
211
  .box:focus-within { border-color: var(--dw-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dw-accent) 16%, transparent); }
210
212
  textarea {
211
213
  flex: 1; resize: none; border: 0; outline: 0; background: transparent; color: var(--dw-fg);
212
- font: inherit; font-size: 14.5px; line-height: 1.5; max-height: 140px; padding: 6px 0; min-height: 34px;
214
+ font: inherit; font-size: 16px; line-height: 1.45; max-height: 140px; padding: 5px 0; min-height: 34px;
213
215
  }
214
216
  textarea::placeholder { color: var(--dw-muted); }
215
217
  .send {
@@ -224,8 +226,12 @@ textarea::placeholder { color: var(--dw-muted); }
224
226
  .foot a:hover { color: var(--dw-accent); }
225
227
  .challenge:empty { display: none; }
226
228
  .challenge { display: flex; justify-content: center; padding: 8px 0; }
229
+ /* iOS zooms into any focused field under 16px; keep touch-device fields at 16px. */
230
+ @media (pointer: coarse) {
231
+ .agent-select { font-size: 16px; max-width: 200px; }
232
+ }
227
233
  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
228
- `;var q=["show-reasoning","show-tool-calls","allow-agent-switch","open","persist","hide-branding","launcher-avatar"],$=["endpoint","agent","title","subtitle","greeting","intro","placeholder","suggestions","avatar","position","mode","theme","accent-color","locale","gateway-url","gateway-token","width","height","z-index",...q],O=i=>i.replace(/-([a-z])/g,(r,e)=>e.toUpperCase()),Y=i=>i!==null&&!/^(false|0|off|no)$/i.test(i),V=()=>{let i=crypto.getRandomValues(new Uint8Array(9));return Array.from(i,r=>"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"[r&63]).join("")},G=i=>i.replace(/^mcp_[^_]+(?:_[^_]+)*?__/,"").replace(/_/g," "),M={get(i){try{return localStorage.getItem(i)}catch{return null}},set(i,r){try{localStorage.setItem(i,r)}catch{}}},Z=null;function Q(){return Z??(Z=new Promise((i,r)=>{if(window.turnstile)return i();let e=document.createElement("script");e.src="https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit",e.async=!0,e.onload=()=>i(),e.onerror=()=>r(new Error("Could not load Turnstile")),document.head.appendChild(e)}))}var X=typeof HTMLElement>"u"?class{}:HTMLElement,E=class extends X{constructor(){super();l(this,"root");l(this,"overrides",{});l(this,"api",null);l(this,"apiKey","");l(this,"server",null);l(this,"agentId","");l(this,"conversationId","");l(this,"messages",[]);l(this,"running",null);l(this,"activated",!1);l(this,"strings",L());l(this,"mql",null);l(this,"els");l(this,"onScheme",()=>this.applyTheme());l(this,"pendingFrame",0);l(this,"following",!0);this.root=this.attachShadow({mode:"open"})}static get observedAttributes(){return $}get config(){let e={endpoint:"/api/dewee"};for(let t of $){let n=this.getAttribute(t);n!==null&&(q.includes(t)?e[O(t)]=Y(n):t==="suggestions"?e.suggestions=n.trim().startsWith("[")?ee(n,[]):n.split("|").map(s=>s.trim()).filter(Boolean):t==="z-index"?e.zIndex=Number(n):e[O(t)]=n)}return{...e,...this.overrides}}configure(e){this.overrides={...this.overrides,...e},this.els&&this.applyConfig()}open(){this.config.mode!=="inline"&&(this.setAttribute("data-open",""),this.removeAttribute("data-unread"),this.els.launcher.setAttribute("aria-expanded","true"),this.activate(),setTimeout(()=>this.els.input.focus(),120),this.emit("dewee:open"))}close(){this.config.mode!=="inline"&&(this.removeAttribute("data-open"),this.els.launcher.setAttribute("aria-expanded","false"),this.emit("dewee:close"))}toggle(){this.hasAttribute("data-open")?this.close():this.open()}async send(e){let t=e.trim();if(!t||this.running)return;this.config.mode!=="inline"&&!this.hasAttribute("data-open")&&this.open(),await this.activate(),this.els.input.value="",this.autosize(),this.pushMessage({role:"user",content:t});let n={role:"assistant",content:"",status:"streaming",startedAt:Date.now()};this.pushMessage(n),this.setRunning(new AbortController),this.emit("dewee:send",{message:t,agent:this.agentId,conversationId:this.conversationId});try{await this.client().chat({message:t,agent:this.agentId,conversationId:this.conversationId},s=>this.onStreamEvent(n,s),this.running.signal),n.status==="streaming"&&(n.status="done")}catch(s){s.name==="AbortError"?(n.status="done",n.content||(n.content=`_${this.strings.stopped}_`)):(n.status="error",this.showError(n,s))}finally{this.finishThinking(n),this.updateMessage(n),this.setRunning(null),n.status==="done"&&(this.emit("dewee:reply",{content:n.content,agent:this.agentId,conversationId:this.conversationId}),this.config.mode!=="inline"&&!this.hasAttribute("data-open")&&this.setAttribute("data-unread",""))}}stop(){this.running?.abort()}newConversation(){this.stop(),this.conversationId=V(),this.config.persist!==!1&&M.set(this.convKey(),this.conversationId),this.messages=[],this.renderLog(),this.els.input.focus()}connectedCallback(){this.els||this.renderShell(),this.applyConfig(),(this.config.mode==="inline"||this.config.open)&&(this.config.mode!=="inline"?this.open():this.activate())}disconnectedCallback(){this.stop(),this.mql?.removeEventListener("change",this.onScheme)}attributeChangedCallback(){this.els&&this.applyConfig()}emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}client(){let e=this.config,t=[e.endpoint,e.gatewayUrl,e.gatewayToken].join("|");return(!this.api||t!==this.apiKey)&&(this.apiKey=t,this.api=new y({endpoint:e.endpoint,gatewayUrl:e.gatewayUrl,gatewayToken:e.gatewayToken,turnstile:n=>this.challenge(n)})),this.api}convKey(){return`dewee-webchat:conv:${this.config.endpoint}:${this.config.gatewayUrl||""}:${this.agentId}`}applyTheme(){let e=this.config.theme||"light",t=e==="dark"||e==="auto"&&!!this.mql?.matches;this.setAttribute("data-theme",t?"dark":"light")}applyConfig(){let e=this.config;this.strings=L(e.locale);let t=this.strings;this.setAttribute("data-position",e.position||"bottom-right"),this.setAttribute("data-mode",e.mode||"floating"),e.theme==="auto"&&!this.mql&&(this.mql=matchMedia("(prefers-color-scheme: dark)"),this.mql.addEventListener("change",this.onScheme)),this.applyTheme();let n=(o,a)=>a!==void 0&&a!==""?this.style.setProperty(o,String(a)):this.style.removeProperty(o);n("--dw-accent",e.accentColor),n("--dw-width",e.width),n("--dw-height",e.height),n("--dw-z",e.zIndex);let s=this.els;if(s.title.textContent=e.title||t.title,s.avatar.replaceChildren(),e.avatar){let o=document.createElement("img");o.src=e.avatar,o.alt="",s.avatar.appendChild(o)}else s.avatar.textContent=(e.title||t.title).trim().charAt(0).toUpperCase();if(s.launcher.innerHTML=e.avatar&&e.launcherAvatar?"":m.chat,e.avatar&&e.launcherAvatar){let o=document.createElement("img");o.src=e.avatar,o.alt="",s.launcher.appendChild(o)}s.launcher.insertAdjacentHTML("beforeend",'<span class="badge"></span>'),s.launcher.setAttribute("aria-label",t.open),s.close.setAttribute("aria-label",t.close),s.close.title=t.close,s.newChat.setAttribute("aria-label",t.newChat),s.newChat.title=t.newChat,s.input.placeholder=e.placeholder||t.placeholder,s.foot.hidden=!!e.hideBranding,s.foot.querySelector(".by").textContent=t.poweredBy+" ",this.renderSubtitle(),this.updateSendButton(),this.activated&&this.api&&this.apiKey!==[e.endpoint,e.gatewayUrl,e.gatewayToken].join("|")?(this.activated=!1,this.server=null,this.activate()):this.activated&&e.agent&&e.agent!==this.agentId&&this.server?this.switchAgent(e.agent):this.activated&&this.renderLog()}renderShell(){this.root.innerHTML=`
234
+ `;var q=["show-reasoning","show-tool-calls","allow-agent-switch","open","persist","hide-branding","launcher-avatar"],$=["endpoint","agent","title","subtitle","greeting","intro","placeholder","suggestions","avatar","position","mode","theme","accent-color","locale","gateway-url","gateway-token","width","height","z-index",...q],O=i=>i.replace(/-([a-z])/g,(r,e)=>e.toUpperCase()),Y=i=>i!==null&&!/^(false|0|off|no)$/i.test(i),V=()=>{let i=crypto.getRandomValues(new Uint8Array(9));return Array.from(i,r=>"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"[r&63]).join("")},G=i=>i.replace(/^mcp_[^_]+(?:_[^_]+)*?__/,"").replace(/_/g," "),S={get(i){try{return localStorage.getItem(i)}catch{return null}},set(i,r){try{localStorage.setItem(i,r)}catch{}}},Z=null;function Q(){return Z??(Z=new Promise((i,r)=>{if(window.turnstile)return i();let e=document.createElement("script");e.src="https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit",e.async=!0,e.onload=()=>i(),e.onerror=()=>r(new Error("Could not load Turnstile")),document.head.appendChild(e)}))}var X=typeof HTMLElement>"u"?class{}:HTMLElement,E=class extends X{constructor(){super();l(this,"root");l(this,"overrides",{});l(this,"api",null);l(this,"apiKey","");l(this,"server",null);l(this,"agentId","");l(this,"conversationId","");l(this,"messages",[]);l(this,"running",null);l(this,"activated",!1);l(this,"strings",L());l(this,"mql",null);l(this,"els");l(this,"onScheme",()=>this.applyTheme());l(this,"pendingFrame",0);l(this,"following",!0);this.root=this.attachShadow({mode:"open"})}static get observedAttributes(){return $}get config(){let e={endpoint:"/api/dewee"};for(let t of $){let n=this.getAttribute(t);n!==null&&(q.includes(t)?e[O(t)]=Y(n):t==="suggestions"?e.suggestions=n.trim().startsWith("[")?ee(n,[]):n.split("|").map(s=>s.trim()).filter(Boolean):t==="z-index"?e.zIndex=Number(n):e[O(t)]=n)}return{...e,...this.overrides}}configure(e){this.overrides={...this.overrides,...e},this.els&&this.applyConfig()}open(){this.config.mode!=="inline"&&(this.setAttribute("data-open",""),this.removeAttribute("data-unread"),this.els.launcher.setAttribute("aria-expanded","true"),this.activate(),setTimeout(()=>this.els.input.focus(),120),this.emit("dewee:open"))}close(){this.config.mode!=="inline"&&(this.removeAttribute("data-open"),this.els.launcher.setAttribute("aria-expanded","false"),this.emit("dewee:close"))}toggle(){this.hasAttribute("data-open")?this.close():this.open()}async send(e){let t=e.trim();if(!t||this.running)return;this.config.mode!=="inline"&&!this.hasAttribute("data-open")&&this.open(),await this.activate(),this.els.input.value="",this.autosize(),this.pushMessage({role:"user",content:t});let n={role:"assistant",content:"",status:"streaming",startedAt:Date.now()};this.pushMessage(n),this.setRunning(new AbortController),this.emit("dewee:send",{message:t,agent:this.agentId,conversationId:this.conversationId});try{await this.client().chat({message:t,agent:this.agentId,conversationId:this.conversationId},s=>this.onStreamEvent(n,s),this.running.signal),n.status==="streaming"&&(n.status="done")}catch(s){s.name==="AbortError"?(n.status="done",n.content||(n.content=`_${this.strings.stopped}_`)):(n.status="error",this.showError(n,s))}finally{this.finishThinking(n),this.updateMessage(n),this.setRunning(null),n.status==="done"&&(this.emit("dewee:reply",{content:n.content,agent:this.agentId,conversationId:this.conversationId}),this.config.mode!=="inline"&&!this.hasAttribute("data-open")&&this.setAttribute("data-unread",""))}}stop(){this.running?.abort()}newConversation(){this.stop(),this.conversationId=V(),this.config.persist!==!1&&S.set(this.convKey(),this.conversationId),this.messages=[],this.renderLog(),this.els.input.focus()}connectedCallback(){this.els||this.renderShell(),this.applyConfig(),(this.config.mode==="inline"||this.config.open)&&(this.config.mode!=="inline"?this.open():this.activate())}disconnectedCallback(){this.stop(),this.mql?.removeEventListener("change",this.onScheme)}attributeChangedCallback(){this.els&&this.applyConfig()}emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}client(){let e=this.config,t=[e.endpoint,e.gatewayUrl,e.gatewayToken].join("|");return(!this.api||t!==this.apiKey)&&(this.apiKey=t,this.api=new y({endpoint:e.endpoint,gatewayUrl:e.gatewayUrl,gatewayToken:e.gatewayToken,turnstile:n=>this.challenge(n)})),this.api}convKey(){return`dewee-webchat:conv:${this.config.endpoint}:${this.config.gatewayUrl||""}:${this.agentId}`}applyTheme(){let e=this.config.theme||"light",t=e==="dark"||e==="auto"&&!!this.mql?.matches;this.setAttribute("data-theme",t?"dark":"light")}applyConfig(){let e=this.config;this.strings=L(e.locale);let t=this.strings;this.setAttribute("data-position",e.position||"bottom-right"),this.setAttribute("data-mode",e.mode||"floating"),e.theme==="auto"&&!this.mql&&(this.mql=matchMedia("(prefers-color-scheme: dark)"),this.mql.addEventListener("change",this.onScheme)),this.applyTheme();let n=(o,a)=>a!==void 0&&a!==""?this.style.setProperty(o,String(a)):this.style.removeProperty(o);n("--dw-accent",e.accentColor),n("--dw-width",e.width),n("--dw-height",e.height),n("--dw-z",e.zIndex);let s=this.els;if(s.title.textContent=e.title||t.title,s.avatar.replaceChildren(),e.avatar){let o=document.createElement("img");o.src=e.avatar,o.alt="",s.avatar.appendChild(o)}else s.avatar.textContent=(e.title||t.title).trim().charAt(0).toUpperCase();if(s.launcher.innerHTML=e.avatar&&e.launcherAvatar?"":m.chat,e.avatar&&e.launcherAvatar){let o=document.createElement("img");o.src=e.avatar,o.alt="",s.launcher.appendChild(o)}s.launcher.insertAdjacentHTML("beforeend",'<span class="badge"></span>'),s.launcher.setAttribute("aria-label",t.open),s.close.setAttribute("aria-label",t.close),s.close.title=t.close,s.newChat.setAttribute("aria-label",t.newChat),s.newChat.title=t.newChat,s.input.placeholder=e.placeholder||t.placeholder,s.foot.hidden=!!e.hideBranding,s.foot.querySelector(".by").textContent=t.poweredBy+" ",this.renderSubtitle(),this.updateSendButton(),this.activated&&this.api&&this.apiKey!==[e.endpoint,e.gatewayUrl,e.gatewayToken].join("|")?(this.activated=!1,this.server=null,this.activate()):this.activated&&e.agent&&e.agent!==this.agentId&&this.server?this.switchAgent(e.agent):this.activated&&this.renderLog()}renderShell(){this.root.innerHTML=`
229
235
  <style>${N}</style>
230
236
  <button class="launcher" part="launcher" aria-expanded="false" aria-haspopup="dialog"></button>
231
237
  <section class="panel" part="panel" role="dialog" aria-label="Chat">
@@ -247,6 +253,6 @@ textarea::placeholder { color: var(--dw-muted); }
247
253
  </div>
248
254
  <div class="foot"><span><span class="by"></span><a href="https://dewee.sh" target="_blank" rel="noopener">dewee</a></span><span class="meta"></span></div>
249
255
  </form>
250
- </section>`;let e=n=>this.root.querySelector(n);this.els={launcher:e(".launcher"),panel:e(".panel"),log:e(".log"),title:e(".title"),subtitle:e(".subtitle"),status:e(".status"),avatar:e(".avatar"),select:e(".agent-select"),input:e("textarea"),send:e(".send"),newChat:e(".new"),close:e(".close"),foot:e(".foot")};let t=this.els;t.launcher.addEventListener("click",()=>this.toggle()),t.close.addEventListener("click",()=>this.close()),t.log.addEventListener("scroll",()=>{this.following=this.nearBottom()},{passive:!0}),t.newChat.addEventListener("click",()=>this.newConversation()),t.select.addEventListener("change",()=>this.switchAgent(t.select.value)),e("form").addEventListener("submit",n=>{n.preventDefault(),this.running?this.stop():this.send(t.input.value)}),t.input.addEventListener("keydown",n=>{n.key==="Enter"&&!n.shiftKey&&!n.isComposing&&n.keyCode!==229&&(n.preventDefault(),this.running||this.send(t.input.value))}),t.input.addEventListener("input",()=>{this.autosize(),this.updateSendButton()}),t.panel.addEventListener("keydown",n=>{n.key==="Escape"&&this.close()})}autosize(){let e=this.els.input;e.style.height="auto",e.style.height=Math.min(e.scrollHeight,140)+"px"}updateSendButton(){let e=this.els.send;e.innerHTML=this.running?m.stop:m.send,e.setAttribute("aria-label",this.running?this.strings.stop:this.strings.send),e.title=e.getAttribute("aria-label"),e.disabled=!this.running&&!this.els.input.value.trim()}setRunning(e){this.running=e,this.updateSendButton()}renderSubtitle(){let e=this.els,t=this.config,n=this.server?.agents??[],s=t.allowAgentSwitch!==!1&&!!this.server?.allowAgentSwitch&&n.length>1;e.select.hidden=!s,e.status.hidden=s,s&&(e.select.replaceChildren(...n.map(a=>new Option(a.name||a.id,a.id,!1,a.id===this.agentId))),e.select.setAttribute("aria-label","Agent"));let o=n.find(a=>a.id===this.agentId);e.status.textContent=t.subtitle||(o?.name&&o.name!==t.title?`${this.strings.online} \xB7 ${o.name}`:this.strings.online)}async activate(){if(!this.activated){this.activated=!0,this.renderLog();try{this.server=await this.client().getConfig(!0),this.els.input.maxLength=this.server.maxMessageLength;let e=this.config.agent,t=n=>!!n&&(this.server.agents.length===0||this.server.agents.some(s=>s.id===n));this.agentId=t(e)?e:this.server.defaultAgent||this.server.agents[0]?.id||e||"",await this.loadConversation()}catch(e){this.activated=!1,this.renderLog(),this.showError(null,e)}this.renderSubtitle(),this.emit("dewee:ready",{agent:this.agentId,config:this.server})}}async switchAgent(e){e!==this.agentId&&(this.stop(),this.agentId=e,this.renderSubtitle(),await this.loadConversation())}async loadConversation(){let e=this.config.persist!==!1,t=e?M.get(this.convKey()):null;if(this.conversationId=t||V(),e&&!t&&M.set(this.convKey(),this.conversationId),this.messages=[],this.renderLog(),!!t)try{let n=await this.client().history(this.agentId,this.conversationId);this.messages=n.map(s=>({...s,status:"done"})),this.renderLog()}catch{}}renderLog(){let e=this.els.log;e.replaceChildren(),this.messages.length||e.appendChild(this.renderWelcome());for(let t of this.messages)e.appendChild(this.renderMessage(t));e.scrollTop=e.scrollHeight}renderWelcome(){let e=this.config,t=this.strings,n=document.createElement("div");n.className="welcome";let s=document.createElement("h2");s.textContent=e.greeting||t.greeting;let o=document.createElement("p");if(o.textContent=e.intro||t.greetingBody,n.append(s,o),e.suggestions?.length){let a=document.createElement("div");a.className="suggestions";for(let g of e.suggestions){let p=document.createElement("button");p.className="chip",p.type="button",p.textContent=g,p.addEventListener("click",()=>this.send(g)),a.appendChild(p)}n.appendChild(a)}return n}pushMessage(e){this.messages.length||this.els.log.replaceChildren(),this.messages.push(e),this.els.log.appendChild(this.renderMessage(e)),this.scrollToBottom(!0)}renderMessage(e){let t=document.createElement("div");t.className=`msg ${e.role}${e.status==="error"?" error":""}`;let n=document.createElement("div");n.className="bubble",t.appendChild(n);let s=document.createElement("div");s.className="trace";let o=document.createElement("div");return o.className=e.role==="assistant"?"md":"",e.role==="assistant"&&n.appendChild(s),n.appendChild(o),e.view={root:t,trace:s,md:o,tools:new Map},this.updateMessage(e),t}updateMessage(e){let t=e.view;if(!t)return;let n=this.config;if(e.role==="user"){t.md.textContent=e.content;return}if(t.root.classList.toggle("error",e.status==="error"),n.showReasoning!==!1&&e.thinking){t.thinking||(t.thinking=document.createElement("details"),t.thinking.className="thinking",t.thinking.innerHTML='<summary></summary><div class="thinking-body"></div>',t.trace.prepend(t.thinking));let o=e.status==="streaming"&&!e.thinkingMs,a=o?this.strings.thinking:e.thinkingMs?this.strings.thoughtFor(Math.max(1,Math.round(e.thinkingMs/1e3))):this.strings.reasoning,g=t.thinking.querySelector("summary");g.innerHTML=`${o?'<span class="spin"></span>':m.brain}<span></span>${m.down.replace("<svg",'<svg class="chev"')}`,g.querySelector("span:not(.spin)").textContent=a,t.thinking.querySelector(".thinking-body").textContent=e.thinking}else t.thinking&&(t.thinking.remove(),t.thinking=void 0);if(n.showToolCalls!==!1)for(let o of e.toolCalls??[])this.renderTool(t,o);else t.tools.forEach(o=>o.remove()),t.tools.clear();t.trace.hidden=!t.trace.childElementCount,e.status==="streaming"&&!e.content?t.md.innerHTML=`<span class="typing" aria-label="${this.strings.thinking}"><i></i><i></i><i></i></span>`:(t.md.replaceChildren(k(document,e.content)),t.md.classList.toggle("cursor",e.status==="streaming"))}renderTool(e,t){let n=e.tools.get(t.id);n||(n=document.createElement("details"),n.className="tool",n.innerHTML=`<summary><span class="lead"></span><span class="tool-name"></span><span class="tool-state"></span>${m.down.replace("<svg",'<svg class="chev"')}</summary><div class="tool-body"></div>`,e.tools.set(t.id,n),e.trace.appendChild(n)),n.dataset.status=t.status,n.querySelector(".lead").innerHTML=t.status==="running"?'<span class="spin"></span>':m.tool;let s=n.querySelector(".tool-name");s.textContent=G(t.name),s.setAttribute("title",t.name),n.querySelector(".tool-state").textContent=t.status==="running"?this.strings.toolRunning:t.status==="error"?this.strings.toolError:this.strings.toolDone;let o=n.querySelector(".tool-body");o.replaceChildren();let a=(g,p)=>{if(p==null||p==="")return;let f=document.createElement("div");f.className="label",f.textContent=g;let h=document.createElement("pre");h.textContent=typeof p=="string"?te(p):JSON.stringify(p,null,2),o.append(f,h)};a(this.strings.args,t.arguments),a(this.strings.result,t.result)}onStreamEvent(e,t){switch(t.type){case"start":t.conversationId&&t.conversationId!==this.conversationId&&(this.conversationId=t.conversationId,this.config.persist!==!1&&M.set(this.convKey(),t.conversationId));break;case"thinking":e.thinking=(e.thinking||"")+t.text;break;case"delta":this.finishThinking(e),e.content+=t.text;break;case"tool_call":this.finishThinking(e),(e.toolCalls??(e.toolCalls=[])).push({id:t.id,name:t.name,arguments:t.arguments,status:"running"});break;case"tool_result":{let n=e.toolCalls?.find(s=>s.id===t.id)??(e.toolCalls??(e.toolCalls=[]))[e.toolCalls.push({id:t.id,name:t.name,status:"running"})-1];n.status=t.isError?"error":"done",n.result=t.result,n.isError=t.isError;break}case"done":this.finishThinking(e),t.content&&t.content.length>=e.content.length&&(e.content=t.content),e.status="done";break;case"error":e.status="error",this.showError(e,new w(t.message,500,t.code));break}this.scheduleUpdate(e)}scheduleUpdate(e){this.pendingFrame||(this.pendingFrame=requestAnimationFrame(()=>{this.pendingFrame=0,this.updateMessage(e),this.following&&this.scrollToBottom(!0)}))}finishThinking(e){e.thinking&&!e.thinkingMs&&e.startedAt&&(e.thinkingMs=Date.now()-e.startedAt)}nearBottom(){let e=this.els.log;return e.scrollHeight-e.scrollTop-e.clientHeight<96}scrollToBottom(e=!1){let t=this.els.log;(e||this.nearBottom())&&(t.scrollTop=t.scrollHeight,this.following=!0)}showError(e,t){let n=t.message||this.strings.errorGeneric;if(this.emit("dewee:error",{message:n,code:t.code}),e){e.content=e.content?`${e.content}
256
+ </section>`;let e=n=>this.root.querySelector(n);this.els={launcher:e(".launcher"),panel:e(".panel"),log:e(".log"),title:e(".title"),subtitle:e(".subtitle"),status:e(".status"),avatar:e(".avatar"),select:e(".agent-select"),input:e("textarea"),send:e(".send"),newChat:e(".new"),close:e(".close"),foot:e(".foot")};let t=this.els;t.launcher.addEventListener("click",()=>this.toggle()),t.close.addEventListener("click",()=>this.close()),t.log.addEventListener("scroll",()=>{this.following=this.nearBottom()},{passive:!0}),t.newChat.addEventListener("click",()=>this.newConversation()),t.select.addEventListener("change",()=>this.switchAgent(t.select.value)),e("form").addEventListener("submit",n=>{n.preventDefault(),this.running?this.stop():this.send(t.input.value)}),t.input.addEventListener("keydown",n=>{n.key==="Enter"&&!n.shiftKey&&!n.isComposing&&n.keyCode!==229&&(n.preventDefault(),this.running||this.send(t.input.value))}),t.input.addEventListener("input",()=>{this.autosize(),this.updateSendButton()}),t.panel.addEventListener("keydown",n=>{n.key==="Escape"&&this.close()})}autosize(){let e=this.els.input;e.style.height="auto",e.style.height=Math.min(e.scrollHeight,140)+"px"}updateSendButton(){let e=this.els.send;e.innerHTML=this.running?m.stop:m.send,e.setAttribute("aria-label",this.running?this.strings.stop:this.strings.send),e.title=e.getAttribute("aria-label"),e.disabled=!this.running&&!this.els.input.value.trim()}setRunning(e){this.running=e,this.updateSendButton()}renderSubtitle(){let e=this.els,t=this.config,n=this.server?.agents??[],s=t.allowAgentSwitch!==!1&&!!this.server?.allowAgentSwitch&&n.length>1;e.select.hidden=!s,e.status.hidden=s,s&&(e.select.replaceChildren(...n.map(a=>new Option(a.name||a.id,a.id,!1,a.id===this.agentId))),e.select.setAttribute("aria-label","Agent"));let o=n.find(a=>a.id===this.agentId);e.status.textContent=t.subtitle||(o?.name&&o.name!==t.title?`${this.strings.online} \xB7 ${o.name}`:this.strings.online)}async activate(){if(!this.activated){this.activated=!0,this.renderLog();try{this.server=await this.client().getConfig(!0),this.els.input.maxLength=this.server.maxMessageLength;let e=this.config.agent,t=n=>!!n&&(this.server.agents.length===0||this.server.agents.some(s=>s.id===n));this.agentId=t(e)?e:this.server.defaultAgent||this.server.agents[0]?.id||e||"",await this.loadConversation()}catch(e){this.activated=!1,this.renderLog(),this.showError(null,e)}this.renderSubtitle(),this.emit("dewee:ready",{agent:this.agentId,config:this.server})}}async switchAgent(e){e!==this.agentId&&(this.stop(),this.agentId=e,this.renderSubtitle(),await this.loadConversation())}async loadConversation(){let e=this.config.persist!==!1,t=e?S.get(this.convKey()):null;if(this.conversationId=t||V(),e&&!t&&S.set(this.convKey(),this.conversationId),this.messages=[],this.renderLog(),!!t)try{let n=await this.client().history(this.agentId,this.conversationId);this.messages=n.map(s=>({...s,status:"done"})),this.renderLog()}catch{}}renderLog(){let e=this.els.log;e.replaceChildren(),this.messages.length||e.appendChild(this.renderWelcome());for(let t of this.messages)e.appendChild(this.renderMessage(t));e.scrollTop=e.scrollHeight}renderWelcome(){let e=this.config,t=this.strings,n=document.createElement("div");n.className="welcome";let s=document.createElement("h2");s.textContent=e.greeting||t.greeting;let o=document.createElement("p");if(o.textContent=e.intro||t.greetingBody,n.append(s,o),e.suggestions?.length){let a=document.createElement("div");a.className="suggestions";for(let g of e.suggestions){let p=document.createElement("button");p.className="chip",p.type="button",p.textContent=g,p.addEventListener("click",()=>this.send(g)),a.appendChild(p)}n.appendChild(a)}return n}pushMessage(e){this.messages.length||this.els.log.replaceChildren(),this.messages.push(e),this.els.log.appendChild(this.renderMessage(e)),this.scrollToBottom(!0)}renderMessage(e){let t=document.createElement("div");t.className=`msg ${e.role}${e.status==="error"?" error":""}`;let n=document.createElement("div");n.className="bubble",t.appendChild(n);let s=document.createElement("div");s.className="trace";let o=document.createElement("div");return o.className=e.role==="assistant"?"md":"",e.role==="assistant"&&n.appendChild(s),n.appendChild(o),e.view={root:t,trace:s,md:o,tools:new Map},this.updateMessage(e),t}updateMessage(e){let t=e.view;if(!t)return;let n=this.config;if(e.role==="user"){t.md.textContent=e.content;return}if(t.root.classList.toggle("error",e.status==="error"),n.showReasoning!==!1&&e.thinking){t.thinking||(t.thinking=document.createElement("details"),t.thinking.className="thinking",t.thinking.innerHTML='<summary></summary><div class="thinking-body"></div>',t.trace.prepend(t.thinking));let o=e.status==="streaming"&&!e.thinkingMs,a=o?this.strings.thinking:e.thinkingMs?this.strings.thoughtFor(Math.max(1,Math.round(e.thinkingMs/1e3))):this.strings.reasoning,g=t.thinking.querySelector("summary");g.innerHTML=`${o?'<span class="spin"></span>':m.brain}<span></span>${m.down.replace("<svg",'<svg class="chev"')}`,g.querySelector("span:not(.spin)").textContent=a,t.thinking.querySelector(".thinking-body").textContent=e.thinking}else t.thinking&&(t.thinking.remove(),t.thinking=void 0);if(n.showToolCalls!==!1)for(let o of e.toolCalls??[])this.renderTool(t,o);else t.tools.forEach(o=>o.remove()),t.tools.clear();t.trace.hidden=!t.trace.childElementCount,e.status==="streaming"&&!e.content?t.md.innerHTML=`<span class="typing" aria-label="${this.strings.thinking}"><i></i><i></i><i></i></span>`:(t.md.replaceChildren(k(document,e.content)),t.md.classList.toggle("cursor",e.status==="streaming"))}renderTool(e,t){let n=e.tools.get(t.id);n||(n=document.createElement("details"),n.className="tool",n.innerHTML=`<summary><span class="lead"></span><span class="tool-name"></span><span class="tool-state"></span>${m.down.replace("<svg",'<svg class="chev"')}</summary><div class="tool-body"></div>`,e.tools.set(t.id,n),e.trace.appendChild(n)),n.dataset.status=t.status,n.querySelector(".lead").innerHTML=t.status==="running"?'<span class="spin"></span>':m.tool;let s=n.querySelector(".tool-name");s.textContent=G(t.name),s.setAttribute("title",t.name),n.querySelector(".tool-state").textContent=t.status==="running"?this.strings.toolRunning:t.status==="error"?this.strings.toolError:this.strings.toolDone;let o=n.querySelector(".tool-body");o.replaceChildren();let a=(g,p)=>{if(p==null||p==="")return;let f=document.createElement("div");f.className="label",f.textContent=g;let h=document.createElement("pre");h.textContent=typeof p=="string"?te(p):JSON.stringify(p,null,2),o.append(f,h)};a(this.strings.args,t.arguments),a(this.strings.result,t.result)}onStreamEvent(e,t){switch(t.type){case"start":t.conversationId&&t.conversationId!==this.conversationId&&(this.conversationId=t.conversationId,this.config.persist!==!1&&S.set(this.convKey(),t.conversationId));break;case"thinking":e.thinking=(e.thinking||"")+t.text;break;case"delta":this.finishThinking(e),e.content+=t.text;break;case"tool_call":this.finishThinking(e),(e.toolCalls??(e.toolCalls=[])).push({id:t.id,name:t.name,arguments:t.arguments,status:"running"});break;case"tool_result":{let n=e.toolCalls?.find(s=>s.id===t.id)??(e.toolCalls??(e.toolCalls=[]))[e.toolCalls.push({id:t.id,name:t.name,status:"running"})-1];n.status=t.isError?"error":"done",n.result=t.result,n.isError=t.isError;break}case"done":this.finishThinking(e),t.content&&t.content.length>=e.content.length&&(e.content=t.content),e.status="done";break;case"error":e.status="error",this.showError(e,new w(t.message,500,t.code));break}this.scheduleUpdate(e)}scheduleUpdate(e){this.pendingFrame||(this.pendingFrame=requestAnimationFrame(()=>{this.pendingFrame=0,this.updateMessage(e),this.following&&this.scrollToBottom(!0)}))}finishThinking(e){e.thinking&&!e.thinkingMs&&e.startedAt&&(e.thinkingMs=Date.now()-e.startedAt)}nearBottom(){let e=this.els.log;return e.scrollHeight-e.scrollTop-e.clientHeight<96}scrollToBottom(e=!1){let t=this.els.log;(e||this.nearBottom())&&(t.scrollTop=t.scrollHeight,this.following=!0)}showError(e,t){let n=t.message||this.strings.errorGeneric;if(this.emit("dewee:error",{message:n,code:t.code}),e){e.content=e.content?`${e.content}
251
257
 
252
- > \u26A0\uFE0F ${n}`:`\u26A0\uFE0F ${n}`,e.status="error",this.updateMessage(e);return}let s=document.createElement("div");s.className="msg error",s.innerHTML='<div class="bubble"></div>',s.firstElementChild.textContent=`\u26A0\uFE0F ${n}`,this.els.log.appendChild(s)}async challenge(e){await Q();let t=document.createElement("div");t.slot="challenge",this.appendChild(t);try{return await new Promise((n,s)=>{window.turnstile.render(t,{sitekey:e,appearance:"interaction-only",theme:this.getAttribute("data-theme")==="dark"?"dark":"light",callback:n,"error-callback":()=>s(new w("Verification failed",403,"turnstile_failed"))})})}finally{t.remove()}}};function ee(i,r){try{return JSON.parse(i)}catch{return r}}function te(i){let r=i.trim();if(!/^[[{]/.test(r))return i;try{return JSON.stringify(JSON.parse(r),null,2)}catch{return i}}function H(i="dewee-chat"){typeof window>"u"||!window.customElements||customElements.get(i)||customElements.define(i,class extends E{})}function ne(i={},r){H();let e=document.createElement("dewee-chat");return e.configure(i),((typeof r=="string"?document.querySelector(r):r)??document.body).appendChild(e),e}H();var ie=document.currentScript,S=ie?.dataset;if(S&&S.endpoint&&S.autoMount!=="false"){let i=()=>{let r=document.createElement("dewee-chat");for(let[e,t]of Object.entries(S))e==="autoMount"||t===void 0||r.setAttribute(e.replace(/[A-Z]/g,n=>"-"+n.toLowerCase()),t);document.body.appendChild(r)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",i):i()}window.DeweeWebchat=I;})();
258
+ > \u26A0\uFE0F ${n}`:`\u26A0\uFE0F ${n}`,e.status="error",this.updateMessage(e);return}let s=document.createElement("div");s.className="msg error",s.innerHTML='<div class="bubble"></div>',s.firstElementChild.textContent=`\u26A0\uFE0F ${n}`,this.els.log.appendChild(s)}async challenge(e){await Q();let t=document.createElement("div");t.slot="challenge",this.appendChild(t);try{return await new Promise((n,s)=>{window.turnstile.render(t,{sitekey:e,appearance:"interaction-only",theme:this.getAttribute("data-theme")==="dark"?"dark":"light",callback:n,"error-callback":()=>s(new w("Verification failed",403,"turnstile_failed"))})})}finally{t.remove()}}};function ee(i,r){try{return JSON.parse(i)}catch{return r}}function te(i){let r=i.trim();if(!/^[[{]/.test(r))return i;try{return JSON.stringify(JSON.parse(r),null,2)}catch{return i}}function H(i="dewee-chat"){typeof window>"u"||!window.customElements||customElements.get(i)||customElements.define(i,class extends E{})}function ne(i={},r){H();let e=document.createElement("dewee-chat");return e.configure(i),((typeof r=="string"?document.querySelector(r):r)??document.body).appendChild(e),e}H();var ie=document.currentScript,M=ie?.dataset;if(M&&M.endpoint&&M.autoMount!=="false"){let i=()=>{let r=document.createElement("dewee-chat");for(let[e,t]of Object.entries(M))e==="autoMount"||t===void 0||r.setAttribute(e.replace(/[A-Z]/g,n=>"-"+n.toLowerCase()),t);document.body.appendChild(r)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",i):i()}window.DeweeWebchat=I;})();
package/dist/index.js CHANGED
@@ -5,8 +5,8 @@ import {
5
5
  defineDeweeChat,
6
6
  mount,
7
7
  renderMarkdown
8
- } from "./chunk-RGAYYTL7.js";
9
- import "./chunk-MKTHKYLY.js";
8
+ } from "./chunk-D4JM2FOB.js";
9
+ import "./chunk-WD6V3TAX.js";
10
10
  export {
11
11
  ApiClient,
12
12
  ApiError,
package/dist/react.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  defineDeweeChat
3
- } from "./chunk-RGAYYTL7.js";
4
- import "./chunk-MKTHKYLY.js";
3
+ } from "./chunk-D4JM2FOB.js";
4
+ import "./chunk-WD6V3TAX.js";
5
5
 
6
6
  // src/react.ts
7
7
  import { createElement, forwardRef, useEffect, useImperativeHandle, useRef } from "react";
package/dist/server.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  HEADER_GATEWAY_TOKEN,
3
3
  HEADER_GATEWAY_URL,
4
4
  VERSION
5
- } from "./chunk-MKTHKYLY.js";
5
+ } from "./chunk-WD6V3TAX.js";
6
6
 
7
7
  // src/server/gateway-client.ts
8
8
  var GatewayError = class extends Error {
package/dist/vue.d.ts CHANGED
@@ -110,7 +110,7 @@ declare const DeweeChat: vue.DefineComponent<vue.ExtractPropTypes<{
110
110
  };
111
111
  }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
112
112
  [key: string]: any;
113
- }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("open" | "close" | "error" | "send" | "ready" | "reply")[], "open" | "close" | "error" | "send" | "ready" | "reply", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
113
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("open" | "ready" | "send" | "reply" | "error" | "close")[], "open" | "ready" | "send" | "reply" | "error" | "close", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
114
114
  endpoint: {
115
115
  type: PropType<any>;
116
116
  default: undefined;
@@ -216,11 +216,11 @@ declare const DeweeChat: vue.DefineComponent<vue.ExtractPropTypes<{
216
216
  default: undefined;
217
217
  };
218
218
  }>> & Readonly<{
219
+ onOpen?: ((...args: any[]) => any) | undefined;
219
220
  onReady?: ((...args: any[]) => any) | undefined;
220
221
  onSend?: ((...args: any[]) => any) | undefined;
221
222
  onReply?: ((...args: any[]) => any) | undefined;
222
223
  onError?: ((...args: any[]) => any) | undefined;
223
- onOpen?: ((...args: any[]) => any) | undefined;
224
224
  onClose?: ((...args: any[]) => any) | undefined;
225
225
  }>, {
226
226
  endpoint: any;
package/dist/vue.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  defineDeweeChat
3
- } from "./chunk-RGAYYTL7.js";
4
- import "./chunk-MKTHKYLY.js";
3
+ } from "./chunk-D4JM2FOB.js";
4
+ import "./chunk-WD6V3TAX.js";
5
5
 
6
6
  // src/vue.ts
7
7
  import { defineComponent, h, onMounted, ref, watch } from "vue";
package/package.json CHANGED
@@ -1,99 +1,99 @@
1
- {
2
- "name": "dewee-webchat",
3
- "version": "0.1.0",
4
- "description": "Embeddable chat widget for Dewee AI agents — web component, React/Vue/Astro wrappers and a secure backend handler (Workers, Next.js, Node, Bun, Deno).",
5
- "license": "MIT",
6
- "type": "module",
7
- "author": "NextLevelBuilder <hi@nextlevelbuilder.io>",
8
- "homepage": "https://webchat.dewee.sh",
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/nextlevelbuilder/dewee-webchat.git",
12
- "directory": "packages/dewee-webchat"
13
- },
14
- "bugs": "https://github.com/nextlevelbuilder/dewee-webchat/issues",
15
- "keywords": [
16
- "dewee",
17
- "goclaw",
18
- "ai",
19
- "agent",
20
- "chatbot",
21
- "chat-widget",
22
- "web-component",
23
- "react",
24
- "vue",
25
- "astro",
26
- "nextjs",
27
- "cloudflare-workers"
28
- ],
29
- "sideEffects": [
30
- "./dist/index.js",
31
- "./dist/dewee-webchat.js",
32
- "./dist/chunk-*.js"
33
- ],
34
- "main": "./dist/index.js",
35
- "module": "./dist/index.js",
36
- "types": "./dist/index.d.ts",
37
- "unpkg": "./dist/dewee-webchat.js",
38
- "jsdelivr": "./dist/dewee-webchat.js",
39
- "exports": {
40
- ".": {
41
- "types": "./dist/index.d.ts",
42
- "import": "./dist/index.js"
43
- },
44
- "./server": {
45
- "types": "./dist/server.d.ts",
46
- "import": "./dist/server.js"
47
- },
48
- "./react": {
49
- "types": "./dist/react.d.ts",
50
- "import": "./dist/react.js"
51
- },
52
- "./vue": {
53
- "types": "./dist/vue.d.ts",
54
- "import": "./dist/vue.js"
55
- },
56
- "./astro": "./astro/DeweeChat.astro",
57
- "./cdn": "./dist/dewee-webchat.js",
58
- "./package.json": "./package.json"
59
- },
60
- "files": [
61
- "dist",
62
- "astro",
63
- "README.md",
64
- "LICENSE"
65
- ],
66
- "scripts": {
67
- "build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsup",
68
- "dev": "tsup --watch",
69
- "test": "vitest run",
70
- "typecheck": "tsc --noEmit"
71
- },
72
- "peerDependencies": {
73
- "react": ">=18",
74
- "vue": ">=3.3"
75
- },
76
- "peerDependenciesMeta": {
77
- "react": {
78
- "optional": true
79
- },
80
- "vue": {
81
- "optional": true
82
- }
83
- },
84
- "devDependencies": {
85
- "@types/node": "^22.15.0",
86
- "@types/react": "^19.1.0",
87
- "@types/ws": "^8.18.2",
88
- "happy-dom": "^18.0.1",
89
- "react": "^19.1.0",
90
- "tsup": "^8.5.0",
91
- "typescript": "^5.9.2",
92
- "vitest": "^3.2.4",
93
- "vue": "^3.5.18",
94
- "ws": "^8.22.0"
95
- },
96
- "engines": {
97
- "node": ">=20"
98
- }
99
- }
1
+ {
2
+ "name": "dewee-webchat",
3
+ "version": "0.1.1",
4
+ "description": "Embeddable chat widget for Dewee AI agents — web component, React/Vue/Astro wrappers and a secure backend handler (Workers, Next.js, Node, Bun, Deno).",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "author": "NextLevelBuilder <hi@nextlevelbuilder.io>",
8
+ "homepage": "https://webchat.dewee.sh",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/nextlevelbuilder/dewee-webchat.git",
12
+ "directory": "packages/dewee-webchat"
13
+ },
14
+ "bugs": "https://github.com/nextlevelbuilder/dewee-webchat/issues",
15
+ "keywords": [
16
+ "dewee",
17
+ "goclaw",
18
+ "ai",
19
+ "agent",
20
+ "chatbot",
21
+ "chat-widget",
22
+ "web-component",
23
+ "react",
24
+ "vue",
25
+ "astro",
26
+ "nextjs",
27
+ "cloudflare-workers"
28
+ ],
29
+ "sideEffects": [
30
+ "./dist/index.js",
31
+ "./dist/dewee-webchat.js",
32
+ "./dist/chunk-*.js"
33
+ ],
34
+ "main": "./dist/index.js",
35
+ "module": "./dist/index.js",
36
+ "types": "./dist/index.d.ts",
37
+ "unpkg": "./dist/dewee-webchat.js",
38
+ "jsdelivr": "./dist/dewee-webchat.js",
39
+ "exports": {
40
+ ".": {
41
+ "types": "./dist/index.d.ts",
42
+ "import": "./dist/index.js"
43
+ },
44
+ "./server": {
45
+ "types": "./dist/server.d.ts",
46
+ "import": "./dist/server.js"
47
+ },
48
+ "./react": {
49
+ "types": "./dist/react.d.ts",
50
+ "import": "./dist/react.js"
51
+ },
52
+ "./vue": {
53
+ "types": "./dist/vue.d.ts",
54
+ "import": "./dist/vue.js"
55
+ },
56
+ "./astro": "./astro/DeweeChat.astro",
57
+ "./cdn": "./dist/dewee-webchat.js",
58
+ "./package.json": "./package.json"
59
+ },
60
+ "files": [
61
+ "dist",
62
+ "astro",
63
+ "README.md",
64
+ "LICENSE"
65
+ ],
66
+ "scripts": {
67
+ "build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsup",
68
+ "dev": "tsup --watch",
69
+ "test": "vitest run",
70
+ "typecheck": "tsc --noEmit"
71
+ },
72
+ "peerDependencies": {
73
+ "react": ">=18",
74
+ "vue": ">=3.3"
75
+ },
76
+ "peerDependenciesMeta": {
77
+ "react": {
78
+ "optional": true
79
+ },
80
+ "vue": {
81
+ "optional": true
82
+ }
83
+ },
84
+ "devDependencies": {
85
+ "@types/node": "^22.15.0",
86
+ "@types/react": "^19.1.0",
87
+ "@types/ws": "^8.18.2",
88
+ "happy-dom": "^18.0.1",
89
+ "react": "^19.1.0",
90
+ "tsup": "^8.5.0",
91
+ "typescript": "^5.9.2",
92
+ "vitest": "^3.2.4",
93
+ "vue": "^3.5.18",
94
+ "ws": "^8.22.0"
95
+ },
96
+ "engines": {
97
+ "node": ">=20"
98
+ }
99
+ }