nothumanallowed 8.9.1 → 9.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nothumanallowed",
3
- "version": "8.9.1",
3
+ "version": "9.0.0",
4
4
  "description": "NotHumanAllowed — 38 AI agents + unified productivity suite. Gmail, Calendar, Drive, Contacts, Tasks, GitHub, Notion, Slack, voice chat, smart scheduler. Zero-dependency CLI.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -754,7 +754,7 @@ export async function cmdUI(args) {
754
754
  parts.push(`${prefix} ${turn.content}`);
755
755
  }
756
756
  parts.push(`[User] ${body.message}`);
757
- const userMessage = parts.join('\n\n');
757
+ let userMessage = parts.join('\n\n');
758
758
 
759
759
  // Inject episodic memory context into the system prompt
760
760
  const basePrompt = effectiveSystemPrompt || chatSystemPrompt;
@@ -837,7 +837,62 @@ export async function cmdUI(args) {
837
837
  }
838
838
  }
839
839
 
840
- // Handle file attachment
840
+ // Handle PDF attachment — send as document to Claude (native PDF support)
841
+ if (body.pdfBase64 && body.pdfName) {
842
+ try {
843
+ const provider = config.llm.provider || 'anthropic';
844
+ const apiKey = config.llm.apiKey;
845
+ const model = config.llm.model;
846
+ const pdfPrompt = body.message || `Read and analyze this PDF document "${body.pdfName}". Extract all text content, summarize key information.`;
847
+ let pdfResponse = '';
848
+
849
+ if (provider === 'anthropic') {
850
+ const r = await fetch('https://api.anthropic.com/v1/messages', {
851
+ method: 'POST',
852
+ headers: { 'Content-Type': 'application/json', 'x-api-key': apiKey, 'anthropic-version': '2023-06-01' },
853
+ body: JSON.stringify({
854
+ model: model || 'claude-sonnet-4-20250514', max_tokens: 8192, system: enrichedSystemPrompt,
855
+ messages: [{ role: 'user', content: [
856
+ { type: 'document', source: { type: 'base64', media_type: 'application/pdf', data: body.pdfBase64 } },
857
+ { type: 'text', text: pdfPrompt },
858
+ ]}],
859
+ }),
860
+ });
861
+ if (!r.ok) throw new Error(`Anthropic ${r.status}: ${(await r.text()).slice(0, 200)}`);
862
+ const d = await r.json();
863
+ pdfResponse = d.content?.[0]?.text || '';
864
+ } else if (provider === 'gemini') {
865
+ const m = model || 'gemini-2.0-flash';
866
+ const r = await fetch(`https://generativelanguage.googleapis.com/v1beta/models/${m}:generateContent?key=${apiKey}`, {
867
+ method: 'POST',
868
+ headers: { 'Content-Type': 'application/json' },
869
+ body: JSON.stringify({
870
+ system_instruction: { parts: [{ text: enrichedSystemPrompt }] },
871
+ contents: [{ parts: [
872
+ { inline_data: { mime_type: 'application/pdf', data: body.pdfBase64 } },
873
+ { text: pdfPrompt },
874
+ ]}],
875
+ generationConfig: { maxOutputTokens: 8192 },
876
+ }),
877
+ });
878
+ if (!r.ok) throw new Error(`Gemini ${r.status}`);
879
+ const d = await r.json();
880
+ pdfResponse = d.candidates?.[0]?.content?.parts?.[0]?.text || '';
881
+ } else {
882
+ pdfResponse = `PDF reading requires Anthropic (Claude) or Gemini. Your provider "${provider}" does not support native PDF documents.`;
883
+ }
884
+
885
+ sendJSON(res, 200, { response: pdfResponse });
886
+ logRequest(method, pathname, 200, Date.now() - start);
887
+ return;
888
+ } catch (e) {
889
+ sendJSON(res, 200, { response: null, error: `PDF error: ${e.message}` });
890
+ logRequest(method, pathname, 200, Date.now() - start);
891
+ return;
892
+ }
893
+ }
894
+
895
+ // Handle text file attachment
841
896
  if (body.fileContent && body.fileName) {
842
897
  const filePrompt = body.message
843
898
  ? `User asks about file "${body.fileName}": ${body.message}\n\nFile content:\n${body.fileContent.slice(0, 8000)}`
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 = '8.9.1';
8
+ export const VERSION = '9.0.0';
9
9
  export const BASE_URL = 'https://nothumanallowed.com/cli';
10
10
  export const API_BASE = 'https://nothumanallowed.com/api/v1';
11
11
 
@@ -340,14 +340,28 @@ var chatAttachedImage=null;
340
340
 
341
341
  function handleChatFile(input){
342
342
  var file=input.files&&input.files[0];if(!file)return;
343
- var reader=new FileReader();
344
- reader.onload=function(e){
345
- chatAttachedFile={name:file.name,size:file.size,content:e.target.result};
346
- chatAttachedImage=null;
347
- document.getElementById('chatAttachInfo').style.display='';
348
- document.getElementById('chatAttachName').textContent='📎 '+file.name+' ('+Math.round(file.size/1024)+' KB)';
349
- };
350
- reader.readAsText(file);
343
+ var isPDF=file.name.toLowerCase().endsWith('.pdf')||file.type==='application/pdf';
344
+ if(isPDF){
345
+ // PDF: read as base64 and send as document to LLM
346
+ var reader=new FileReader();
347
+ reader.onload=function(e){
348
+ var base64=e.target.result.split(',')[1];
349
+ chatAttachedFile={name:file.name,size:file.size,content:null,base64:base64,mimeType:'application/pdf',isPDF:true};
350
+ chatAttachedImage=null;
351
+ document.getElementById('chatAttachInfo').style.display='';
352
+ document.getElementById('chatAttachName').textContent='📎 '+file.name+' ('+Math.round(file.size/1024)+' KB)';
353
+ };
354
+ reader.readAsDataURL(file);
355
+ }else{
356
+ var reader=new FileReader();
357
+ reader.onload=function(e){
358
+ chatAttachedFile={name:file.name,size:file.size,content:e.target.result};
359
+ chatAttachedImage=null;
360
+ document.getElementById('chatAttachInfo').style.display='';
361
+ document.getElementById('chatAttachName').textContent='📎 '+file.name+' ('+Math.round(file.size/1024)+' KB)';
362
+ };
363
+ reader.readAsText(file);
364
+ }
351
365
  }
352
366
 
353
367
  function handleChatImage(input){
@@ -385,7 +399,13 @@ function sendChat(){
385
399
  chatHistory.push({role:'assistant',content:'Thinking...'});renderMessages();
386
400
 
387
401
  var payload={message:msg||'Analyze this attachment',history:chatHistory.slice(0,-1)};
388
- if(chatAttachedFile){payload.fileContent=chatAttachedFile.content;payload.fileName=chatAttachedFile.name;}
402
+ if(chatAttachedFile){
403
+ if(chatAttachedFile.isPDF&&chatAttachedFile.base64){
404
+ payload.pdfBase64=chatAttachedFile.base64;payload.pdfName=chatAttachedFile.name;
405
+ }else{
406
+ payload.fileContent=chatAttachedFile.content;payload.fileName=chatAttachedFile.name;
407
+ }
408
+ }
389
409
  if(chatAttachedImage){payload.imageBase64=chatAttachedImage.base64;payload.imageMimeType=chatAttachedImage.mimeType;payload.imageName=chatAttachedImage.name;}
390
410
  clearChatAttach();
391
411