nothumanallowed 11.0.2 → 11.0.4

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": "nothumanallowed",
3
- "version": "11.0.2",
3
+ "version": "11.0.4",
4
4
  "description": "NotHumanAllowed — 38 AI agents, 53 tools. Email, calendar, browser automation, screen capture, canvas, cron/heartbeat, GitHub, Notion, Slack, voice chat, 28 languages. Zero-dependency CLI.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/constants.mjs CHANGED
@@ -5,7 +5,7 @@ import { fileURLToPath } from 'url';
5
5
  const __filename = fileURLToPath(import.meta.url);
6
6
  const __dirname = path.dirname(__filename);
7
7
 
8
- export const VERSION = '11.0.2';
8
+ export const VERSION = '11.0.4';
9
9
  export const BASE_URL = 'https://nothumanallowed.com/cli';
10
10
  export const API_BASE = 'https://nothumanallowed.com/api/v1';
11
11
 
@@ -730,56 +730,35 @@ function retryMsg(i){
730
730
  var userMsg=chatHistory[i-1];
731
731
  if(!userMsg||userMsg.role!=='user')return;
732
732
 
733
- // Keep the old response just re-stream a new one
734
- // The old response stays in the tree as a sibling branch
735
- chatHistory[i]={role:'assistant',content:'Generating alternative...'};
733
+ // Replace the assistant response at position i and re-stream using the full sendChat flow
734
+ // The old response is saved as a fork branch in the tree
735
+ chatHistory.splice(i); // remove from i onwards
736
736
  renderMessages();
737
-
738
- // Stream a new response for the same user message
739
- chatStreaming=true;
740
- chatAbortController=new AbortController();
741
- var streamIdx=i;
742
- var allHistory=chatHistory.slice(0,i-1).map(function(m){return{role:m.role,content:(m.content||'')};});
743
- var payload={message:userMsg.content,history:allHistory,conversationId:activeConvId,isRetry:true};
744
-
745
- fetch(API+'/api/chat/stream',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(payload),signal:chatAbortController.signal}).then(function(response){
746
- if(!response.ok||!response.body){chatHistory[streamIdx].content='Error: retry failed';endStreaming();renderMessages();return;}
747
- var reader=response.body.getReader();var decoder=new TextDecoder();var buffer='';var currentEvent='';
748
- function pump(){
749
- reader.read().then(function(result){
750
- if(result.done){endStreaming();renderMessages();return;}
751
- buffer+=decoder.decode(result.value,{stream:true});
752
- var lines=buffer.split('\\n');buffer=lines.pop()||'';
753
- for(var li=0;li<lines.length;li++){
754
- var line=lines[li];
755
- if(line.startsWith('event: ')){currentEvent=line.slice(7).trim();continue;}
756
- if(!line.startsWith('data: '))continue;
757
- try{
758
- var data=JSON.parse(line.slice(6));
759
- if(currentEvent==='token'&&data.content){
760
- if(chatHistory[streamIdx].content==='Generating alternative...')chatHistory[streamIdx].content='';
761
- chatHistory[streamIdx].content+=data.content;
762
- var el=document.getElementById('chatMessages');
763
- if(el){var msgs=el.querySelectorAll('.msg');var last=msgs[streamIdx];if(last){var bub=last.querySelector('.msg__bubble');if(bub)bub.textContent=chatHistory[streamIdx].content;}el.scrollTop=el.scrollHeight;}
764
- }
765
- if(currentEvent==='tool_synthesis'){chatHistory[streamIdx].content='';renderMessages();}
766
- if(currentEvent==='done'){endStreaming();if(data.content)chatHistory[streamIdx].content=data.content;renderMessages();loadConvList();}
767
- if(currentEvent==='error'){endStreaming();chatHistory[streamIdx].content='Error: '+(data.message||'Unknown');renderMessages();}
768
- }catch(e){}
769
- }
770
- pump();
771
- }).catch(function(e){endStreaming();if(e.name!=='AbortError'){chatHistory[streamIdx].content='Error: '+e.message;renderMessages();}});
772
- }
773
- pump();
774
- }).catch(function(e){endStreaming();chatHistory[streamIdx].content='Error: '+e.message;renderMessages();});
737
+ // Put the user message in the input and trigger sendChat with retry flag
738
+ var inp=document.getElementById('chatInput');
739
+ if(inp){inp.value=userMsg.content;}
740
+ // Remove the duplicate user message that sendChat will add
741
+ chatHistory.pop(); // remove the user message (sendChat will re-add it)
742
+ window._nhaRetryMode=true;
743
+ sendChat();
775
744
  }
776
745
  function editMsg(i){
777
746
  if(chatHistory[i].role!=='user')return;
778
747
  var inp=document.getElementById('chatInput');if(!inp)return;
779
- inp.value=chatHistory[i].content;inp.focus();
780
- // Truncate to before this message new message creates a branch
781
- chatHistory=chatHistory.slice(0,i);
782
- renderMessages();
748
+ // Put text in input but DON'T delete anything yet
749
+ // User can press Esc to cancel or Enter to send (which creates a branch)
750
+ inp.value=chatHistory[i].content;
751
+ inp.focus();
752
+ // Mark that we're editing — sendChat will handle truncation
753
+ window._nhaEditIndex=i;
754
+ // Listen for Esc to cancel
755
+ inp.onkeydown=function(e){
756
+ if(e.key==='Escape'){
757
+ inp.value='';
758
+ window._nhaEditIndex=null;
759
+ inp.onkeydown=function(ev){if(ev.key==='Enter'&&!ev.shiftKey){ev.preventDefault();sendChat();}};
760
+ }
761
+ };
783
762
  }
784
763
  function navigateFork(nodeId,dir){
785
764
  if(!activeConvId)return;
@@ -794,6 +773,17 @@ function sendChat(){
794
773
  if(!msg&&!hasAttach)return;
795
774
  if(chatStreaming)return;
796
775
 
776
+ var isRetry=!!window._nhaRetryMode;
777
+ window._nhaRetryMode=false;
778
+
779
+ // Handle edit mode — truncate history to edit point before adding
780
+ if(window._nhaEditIndex!=null){
781
+ chatHistory=chatHistory.slice(0,window._nhaEditIndex);
782
+ window._nhaEditIndex=null;
783
+ // Reset keydown handler
784
+ inp.onkeydown=function(e){if(e.key==='Enter'&&!e.shiftKey){e.preventDefault();sendChat();}};
785
+ }
786
+
797
787
  var displayMsg=msg;
798
788
  if(chatAttachedFile)displayMsg=(msg?msg+' ':'')+'[File: '+chatAttachedFile.name+']';
799
789
  if(chatAttachedImage)displayMsg=(msg?msg+' ':'')+'[Image: '+chatAttachedImage.name+']';
@@ -832,7 +822,7 @@ function sendChat(){
832
822
  renderMessages();
833
823
  var streamIdx=chatHistory.length-1;
834
824
  var allHistory=chatHistory.slice(0,-1).map(function(m){return{role:m.role,content:(m.content||'').replace(/!\\[Screenshot\\]\\(data:image\\/[^)]+\\)/g,'[Screenshot taken]')};});
835
- var payload={message:msg,history:allHistory,conversationId:activeConvId};
825
+ var payload={message:msg,history:allHistory,conversationId:activeConvId,isRetry:isRetry};
836
826
 
837
827
  fetch(API+'/api/chat/stream',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(payload),signal:chatAbortController.signal}).then(function(response){
838
828
  if(!response.ok||!response.body){chatHistory[streamIdx].content='Error: connection failed';endStreaming();renderMessages();return;}
@@ -886,7 +876,7 @@ function sendChat(){
886
876
  if(data.markers.indexOf('[CANVAS_CLEAR]')!==-1)closeCanvas();
887
877
  }
888
878
  if(currentEvent==='tool_synthesis'){chatHistory[streamIdx].content='';renderMessages();}
889
- if(currentEvent==='done'){endStreaming();if(data.content)chatHistory[streamIdx].content=data.content;var ssf=data.screenshotFiles||[];for(var fi=0;fi<ssf.length;fi++){chatHistory[streamIdx].content+='\\n![Screenshot](/api/screenshots/'+ssf[fi]+')\\n';}var bt=data.browserThumbs||[];if(bt.length>0){var cd=getConvCanvasData();for(var bti=0;bti<bt.length;bti++){var exists=cd.browsers.some(function(b){return b.file===bt[bti].file;});if(!exists)cd.browsers.push({file:bt[bti].file,url:bt[bti].url,ts:new Date().toLocaleTimeString()});}browserIdx=cd.browsers.length-1;saveCanvasData();}renderMessages();loadConvList();}
879
+ if(currentEvent==='done'){endStreaming();if(data.content)chatHistory[streamIdx].content=data.content;var ssf=data.screenshotFiles||[];for(var fi=0;fi<ssf.length;fi++){chatHistory[streamIdx].content+='\\n![Screenshot](/api/screenshots/'+ssf[fi]+')\\n';}var bt=data.browserThumbs||[];if(bt.length>0){var cd=getConvCanvasData();for(var bti=0;bti<bt.length;bti++){var exists=cd.browsers.some(function(b){return b.file===bt[bti].file;});if(!exists)cd.browsers.push({file:bt[bti].file,url:bt[bti].url,ts:new Date().toLocaleTimeString()});}browserIdx=cd.browsers.length-1;saveCanvasData();}renderMessages();loadConvList();if(activeConvId){setTimeout(function(){loadConv(activeConvId);},500);}}
890
880
  if(currentEvent==='error'){endStreaming();chatHistory[streamIdx].content='Error: '+(data.message||'Unknown');renderMessages();}
891
881
  }catch(e){}
892
882
  }