lwazi 1.9.4 → 1.9.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lwazi",
3
- "version": "1.9.4",
3
+ "version": "1.9.5",
4
4
  "description": "Lwazi is an AI assistant for Laravel. Install with one command to add an AI assistant to your Laravel app.",
5
5
  "main": "bin/lwazi.js",
6
6
  "bin": {
@@ -111,7 +111,7 @@ let lwaziContextId=@json($contextId ?? null);
111
111
  let lwaziApiUrl=@json($lwaziApiUrl);
112
112
  function toggleLwazi(){lwaziOpen=!lwaziOpen;document.getElementById('lwazi-window').classList.toggle('open',lwaziOpen);document.getElementById('lwazi-toggle').classList.toggle('open',lwaziOpen);if(lwaziOpen)setTimeout(()=>document.getElementById('lwazi-input').focus(),300)}
113
113
  function sendLwazi(){let i=document.getElementById('lwazi-input'),m=i.value.trim();if(!m)return;addLwazi(m,'user');i.value='';document.getElementById('lwazi-typing').classList.add('active');let c=document.getElementById('lwazi-messages');c.scrollTop=c.scrollHeight;let p={message:m};if(lwaziContextId!==null&&lwaziContextId!==''){p[lwaziContextKey]=lwaziContextId;}fetch(lwaziApiUrl+'/chat',{method:'POST',headers:{'Content-Type':'application/json','X-CSRF-TOKEN':'{{ csrf_token() }}'},body:JSON.stringify(p)}).then(r=>{if(!r.ok){return r.text().then(t=>{try{const e=JSON.parse(t);throw new Error(e.error||'HTTP '+r.status)}catch(e){throw new Error('HTTP '+r.status+': '+t.substring(0,100))}})}return r.json()}).then(d=>{document.getElementById('lwazi-typing').classList.remove('active');d.success?addLwazi(d.response,'assistant'):addLwazi('Error: '+d.error,'assistant')}).catch(e=>{document.getElementById('lwazi-typing').classList.remove('active');console.error('Lwazi error:',e);addLwazi('Error: '+e.message,'assistant')})}
114
- function linkify(text){let escaped=text.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");let urlRegex=/((https?:\/\/[^\s]+)|(\B\/[a-zA-Z0-9\-._~!$&'()*+,;=:@\/%?#]+))/g;return escaped.replace(urlRegex,function(url){let trailing="";while(/[).,!?;:]+$/.test(url)){trailing=url.slice(-1)+trailing;url=url.slice(0,-1);}return '<a href="'+url+'" target="_blank" rel="noopener noreferrer">'+url+"</a>"+trailing;});}
114
+ function linkify(text){let escaped=text.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");escaped=escaped.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>');let urlRegex=/((https?:\/\/[^\s]+)|(\B\/[a-zA-Z0-9\-._~!$&'()*+,;=:@\/%?#]+))/g;return escaped.replace(urlRegex,function(url){let trailing="";while(/[).,!?;:]+$/.test(url)){trailing=url.slice(-1)+trailing;url=url.slice(0,-1);}return '<a href="'+url+'" target="_blank" rel="noopener noreferrer">'+url+"</a>"+trailing;});}
115
115
  function addLwazi(t,r){let c=document.getElementById('lwazi-messages'),d=document.createElement('div');d.className='lwazi-msg lwazi-msg-'+r;d.innerHTML=linkify(t);c.appendChild(d);c.scrollTop=c.scrollHeight}
116
116
  </script>
117
117
  </div>