nothumanallowed 13.2.71 → 13.2.72

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": "13.2.71",
3
+ "version": "13.2.72",
4
4
  "description": "NotHumanAllowed — 38 AI agents, 80 tools, Studio (visual agentic workflows). Email, calendar, browser automation, screen capture, canvas, cron/heartbeat, Alexandria E2E messaging, GitHub, Notion, Slack, voice chat, free AI (Liara), 28 languages. Zero-dependency CLI.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -2692,9 +2692,10 @@ export async function cmdUI(args) {
2692
2692
 
2693
2693
  // ── Fast keyword-based planning (no LLM call needed for common patterns) ──────
2694
2694
  const taskLow = task.toLowerCase();
2695
+ const hasPdf = !!(body.hasPdf) || /pdf|allegat|catalogo|scheda\s*tecnic|document/i.test(taskLow);
2695
2696
  const hasEmail = /email|mail|inbox|posta/i.test(taskLow);
2696
2697
  const hasCalendar = /calendar|agenda|calendari|eventi|schedule/i.test(taskLow);
2697
- const hasSearch = /cerca|search|notizie|news|ultime|latest|web|internet|tendenz|trend/i.test(taskLow);
2698
+ const hasSearch = /cerca|search|notizie|news|ultime|latest|web|internet|tendenz|trend|acquista|compra|dove\s+trovare|where\s+to\s+buy|similar|simile/i.test(taskLow);
2698
2699
  const hasCanvas = /html|dashboard|visua|report|grafico|chart/i.test(taskLow);
2699
2700
  const hasGitHub = /github|git|issue|pr|pull request/i.test(taskLow);
2700
2701
  const hasSlack = /slack|channel|messag/i.test(taskLow);
@@ -2726,13 +2727,23 @@ export async function cmdUI(args) {
2726
2727
  // Build plan directly from keywords — reliable, fast, no SENTINEL risk
2727
2728
  const buildKeywordPlan = () => {
2728
2729
  const steps = [];
2730
+ // PDF attachment: always read document first to extract specs/data before any web search
2731
+ if (hasPdf) {
2732
+ const pdfName = body.pdfName || 'documento allegato';
2733
+ steps.push({icon:'\u{1F4C4}',agent:'DocumentReaderAgent',label:it?'Leggi documento':'Read document',prompt:`Extract all technical specifications, model numbers, part codes, product names, manufacturer, dimensions, ratings, and any other key data from the attached document "${pdfName}". List every technical detail precisely.`});
2734
+ }
2729
2735
  if (hasEmail) steps.push({icon:'\u{1F4E7}',agent:'EmailAgent', label:it?'Controlla email':'Check emails', prompt:'Read the latest unread emails and identify urgent items, deadlines, and required actions'});
2730
2736
  if (hasCalendar) steps.push({icon:'\u{1F4C5}',agent:'CalendarAgent', label:it?'Rivedi calendario':'Review calendar', prompt:'Check today\'s events and identify any scheduling conflicts or important meetings'});
2731
2737
  if (hasGitHub) steps.push({icon:'\u{1F4BB}',agent:'GitHubAgent', label:'GitHub', prompt:'Read open issues and pull requests, identify what needs attention'});
2732
2738
  if (hasSlack) steps.push({icon:'\u{1F4AC}',agent:'SlackAgent', label:'Slack', prompt:'Check recent Slack messages and identify important conversations'});
2733
2739
  if (hasNotion) steps.push({icon:'\u{1F4DD}',agent:'NotionAgent', label:'Notion', prompt:'Search Notion for relevant pages and notes'});
2734
- if (hasSearch || hasReputation || (!hasEmail && !hasCalendar && !hasGitHub && !hasSlack)) {
2735
- steps.push({icon:'\u{1F50D}',agent:'WebSearchAgent',label:it?'Ricerca web':'Web search',prompt:searchQuery});
2740
+ // When PDF is present: always search web (to find where to buy, similar products etc.)
2741
+ // The search query will be refined at runtime using the extracted PDF specs as context
2742
+ if (hasPdf || hasSearch || hasReputation || (!hasEmail && !hasCalendar && !hasGitHub && !hasSlack)) {
2743
+ const searchPrompt = hasPdf
2744
+ ? (it ? 'Usando le specifiche tecniche estratte dal documento (codice prodotto, modello, costruttore, caratteristiche), cerca online dove acquistare il prodotto o articoli equivalenti. Usa i codici esatti dal documento come query di ricerca.' : 'Using the technical specifications extracted from the document (product code, model, manufacturer, specs), search online for where to buy this product or equivalent alternatives. Use exact codes from the document as search queries.')
2745
+ : searchQuery;
2746
+ steps.push({icon:'\u{1F50D}',agent:'WebSearchAgent',label:it?'Ricerca web':'Web search',prompt:searchPrompt});
2736
2747
  }
2737
2748
  // Specialist agents — can stack multiple
2738
2749
  if (hasSecurity) steps.push({icon:'\u{1F6E1}',agent:'cassandra', label:it?'CASSANDRA \u2014 Rischi sicurezza':'CASSANDRA \u2014 Security risks', prompt:'Analyze the collected data and identify security risks, vulnerabilities and concrete recommendations'});
@@ -2758,7 +2769,7 @@ export async function cmdUI(args) {
2758
2769
 
2759
2770
  // Use keyword plan directly — only fall back to LLM for genuinely ambiguous tasks
2760
2771
  const keywordSteps = buildKeywordPlan();
2761
- const taskIsComplex = !hasEmail && !hasCalendar && !hasSearch && !hasGitHub && !hasSlack && !hasBriefing && !hasStrategy && !hasReputation && !hasCode && !hasWriting && !hasData && keywordSteps.length <= 1;
2772
+ const taskIsComplex = !hasPdf && !hasEmail && !hasCalendar && !hasSearch && !hasGitHub && !hasSlack && !hasBriefing && !hasStrategy && !hasReputation && !hasCode && !hasWriting && !hasData && keywordSteps.length <= 1;
2762
2773
 
2763
2774
  try {
2764
2775
  let steps;
@@ -2840,7 +2851,41 @@ export async function cmdUI(args) {
2840
2851
  let toolData = '';
2841
2852
 
2842
2853
  // ── Fetch REAL data for each agent type ──────────────────────
2843
- if (agent === 'EmailAgent') {
2854
+ if (agent === 'DocumentReaderAgent') {
2855
+ // Extract text from attached PDF and return it as the step output.
2856
+ // This becomes context for all subsequent steps (WebSearchAgent etc.)
2857
+ sendToken('[Reading attached document...] ');
2858
+ if (stepPdfBase64) {
2859
+ try {
2860
+ const b64 = stepPdfBase64.includes(',') ? stepPdfBase64.split(',')[1] : stepPdfBase64;
2861
+ const pdfBuffer = Buffer.from(b64, 'base64');
2862
+ const extracted = extractTextFromPdf(pdfBuffer);
2863
+ if (extracted && extracted.length > 20) {
2864
+ toolData = `## Document: ${stepPdfName || 'attached'}\n\n${extracted.slice(0, 20000)}`;
2865
+ } else {
2866
+ // Fallback: ask vision model to describe/OCR the document
2867
+ sendToken('[No text found — using vision OCR...] ');
2868
+ try {
2869
+ const visionText = await callLLMVision(config, stepPdfBase64, 'application/pdf',
2870
+ `Extract ALL text, technical specifications, model numbers, part codes, product names, manufacturer details, dimensions, ratings, and any other data from this document. List every detail exactly as printed.`);
2871
+ toolData = `## Document (OCR): ${stepPdfName || 'attached'}\n\n${visionText}`;
2872
+ } catch (ve) {
2873
+ toolData = `Could not extract text from document: ${ve.message}`;
2874
+ }
2875
+ }
2876
+ } catch (e) { toolData = `Document read failed: ${e.message}`; }
2877
+ } else {
2878
+ toolData = 'No document attached.';
2879
+ }
2880
+ // Stream the extracted content as the step output directly — no LLM rewrite needed
2881
+ sendToken(toolData);
2882
+ clearInterval(keepalive);
2883
+ sendEvent({ done: true, usage: { input: 0, output: Math.ceil(toolData.length / 4) } });
2884
+ res.end();
2885
+ logRequest(method, pathname, 200, Date.now() - start);
2886
+ return;
2887
+
2888
+ } else if (agent === 'EmailAgent') {
2844
2889
  sendToken('[Reading emails...] ');
2845
2890
  try {
2846
2891
  const emails = await withTimeout(getUnreadImportant(config, 10), 'EmailAgent');
@@ -2863,7 +2908,23 @@ export async function cmdUI(args) {
2863
2908
  try {
2864
2909
  // Extract a concise search query from the step prompt
2865
2910
  let searchQuery = stepPrompt;
2866
- if (searchQuery.length > 120) {
2911
+
2912
+ // If context contains extracted PDF data, extract the best search query from it:
2913
+ // product codes, model numbers, part numbers etc. are better search terms than the task text.
2914
+ if (context && context.length > 50) {
2915
+ // Look for product codes: alphanumeric codes, e.g. 321k63, VFD-001, 4WE6D6X
2916
+ const codeMatch = context.match(/\b([A-Z0-9]{2,}[-\/]?[A-Z0-9]{2,}(?:[-\/][A-Z0-9]+)*)\b/g);
2917
+ const productCodes = codeMatch ? [...new Set(codeMatch)].slice(0, 3) : [];
2918
+ // Also grab manufacturer name if present
2919
+ const mfrMatch = context.match(/(?:Marca|Marchio|Manufacturer|Brand|Produttore|Costruttore)[:\s]+([A-Za-z0-9 &]{2,40})/i);
2920
+ const mfr = mfrMatch ? mfrMatch[1].trim() : '';
2921
+ if (productCodes.length > 0) {
2922
+ searchQuery = (mfr ? mfr + ' ' : '') + productCodes.join(' ') + ' buy acquista distributore';
2923
+ sendToken(`[Search query from document: "${searchQuery}"] `);
2924
+ }
2925
+ }
2926
+
2927
+ if (searchQuery.length > 120 && !context) {
2867
2928
  const keywordMatch = searchQuery.match(/(?:cerca|search|find|ricerca|notizie su|news about|latest on|aggiornamenti su)\s+(.{5,80}?)(?:\s+(?:e|and|per|for|poi|then)|$)/i);
2868
2929
  if (keywordMatch) {
2869
2930
  searchQuery = keywordMatch[1].trim();
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 = '13.2.71';
8
+ export const VERSION = '13.2.72';
9
9
  export const BASE_URL = 'https://nothumanallowed.com/cli';
10
10
  export const API_BASE = 'https://nothumanallowed.com/api/v1';
11
11
 
@@ -3532,7 +3532,13 @@ async function runStudio() {
3532
3532
  var taskForPlan = studioState.attachmentContext
3533
3533
  ? task + nl + nl + '[User has attached a file: ' + studioState.attachmentName + '. Agents will receive the full content.]'
3534
3534
  : task;
3535
- var planRes = await apiPost('/api/studio/plan', {task: taskForPlan});
3535
+ // Include PDF info in plan request so server can add DocumentReaderAgent step
3536
+ var planBody = {task: taskForPlan};
3537
+ if (studioState.attachmentContext && studioState.attachmentContext.indexOf('[ATTACHED PDF:') === 0) {
3538
+ planBody.hasPdf = true;
3539
+ planBody.pdfName = studioState.attachmentName || 'document.pdf';
3540
+ }
3541
+ var planRes = await apiPost('/api/studio/plan', planBody);
3536
3542
  if (!planRes || !planRes.steps || !planRes.steps.length) {
3537
3543
  studioLog('Studio', '&#9888;', 'Could not plan workflow. Check your LLM provider config.', 'error');
3538
3544
  studioState.running = false;