nothumanallowed 13.5.142 → 13.5.144

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.5.142",
3
+ "version": "13.5.144",
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": {
@@ -5776,7 +5776,7 @@ Per leggere un file (se hai bisogno di piu contesto):
5776
5776
 
5777
5777
  REGOLE CRITICHE:
5778
5778
  - Spiega SEMPRE in linguaggio naturale cosa stai facendo PRIMA dei blocchi tool
5779
- - ${autofix ? 'MODALITA AUTO-FIX: il file incriminato è già incluso qui sotto. Riscrivilo COMPLETAMENTE con "write" — è più affidabile di "edit" quando il file ha già subito modifiche. REGOLE CRITICHE PER IL FIX: (1) SyntaxError "Unexpected token \';\'" in helmet/CSP = stai usando punto-e-virgola invece di virgola negli oggetti JS — usa VIRGOLE. (2) "Cannot find module \'./redis\'" = rimuovi il require e usa solo i moduli in package.json. (3) NON aggiungere require() di moduli non in package.json. Includi il contenuto COMPLETO del file nel campo "content".' : 'Usa "edit" (old/new) quando possibile, "write" solo per file nuovi o riscritture complete'}
5779
+ - ${autofix ? 'MODALITA AUTO-FIX: il file incriminato è già incluso qui sotto. Riscrivilo COMPLETAMENTE con "write" — è più affidabile di "edit" quando il file ha già subito modifiche. REGOLE CRITICHE PER IL FIX: (1) SyntaxError "Unexpected token \';\'" in helmet/CSP = stai usando punto-e-virgola invece di virgola negli oggetti JS — usa VIRGOLE. (2) "Cannot find module \'./redis\'" = rimuovi il require e usa solo i moduli in package.json. (3) NON aggiungere require() di moduli non in package.json. (4) SyntaxError "Unexpected identifier" con nomi spezzati tipo "create Transport" o "SMTP _HOST" o "trans porter" = c\'è uno SPAZIO nel mezzo di un nome di variabile/metodo/property — unisci le parole: createTransport, SMTP_HOST, transporter. (5) "nodemailer.createTransporter is not a function" = il metodo corretto di nodemailer e\' createTransport (senza r finale). Includi il contenuto COMPLETO del file nel campo "content".' : 'Usa "edit" (old/new) quando possibile, "write" solo per file nuovi o riscritture complete'}
5780
5780
  - old_string deve essere ESATTO come appare nel file (copy-paste)
5781
5781
  - Non inventare moduli npm: usa solo quelli in package.json o standard Node.js
5782
5782
  - Dopo ogni fix spiega brevemente cosa hai cambiato e perche
@@ -5834,7 +5834,7 @@ REGOLE CRITICHE:
5834
5834
  _inTool = false;
5835
5835
  }
5836
5836
  }
5837
- }, { max_tokens: 4096 });
5837
+ }, { max_tokens: 8192 });
5838
5838
  // Flush any remaining visible text after stream ends
5839
5839
  if (!_inTool && _toolBuf.trim()) sendEv({ type: 'text', token: _toolBuf });
5840
5840
  }
@@ -5854,18 +5854,35 @@ REGOLE CRITICHE:
5854
5854
  }
5855
5855
 
5856
5856
  // Parse and execute tool calls from response
5857
- // Sanitize JSON from LLM: replace literal newlines inside JSON strings with \n
5858
- // Models often write multiline strings without escaping, which breaks JSON.parse
5857
+ // Sanitize JSON from LLM: replace literal newlines and invalid escape sequences inside JSON strings
5858
+ // Models often write multiline strings without escaping, or use \s \d \w in regex inside content
5859
5859
  const sanitizeToolJson = (raw) => {
5860
- // Replace literal CR/LF inside JSON string values with escaped versions
5861
- // Strategy: walk char by char, track if we're inside a JSON string
5860
+ // Valid JSON escape chars after backslash: " \ / b f n r t u
5861
+ const validEscapes = new Set(['"', '\\', '/', 'b', 'f', 'n', 'r', 't', 'u']);
5862
5862
  let out = '';
5863
5863
  let inStr = false;
5864
5864
  let escaped = false;
5865
5865
  for (let ci = 0; ci < raw.length; ci++) {
5866
5866
  const ch = raw[ci];
5867
- if (escaped) { out += ch; escaped = false; continue; }
5868
- if (ch === '\\') { out += ch; escaped = true; continue; }
5867
+ if (escaped) {
5868
+ escaped = false;
5869
+ // If this is not a valid JSON escape char, double the backslash
5870
+ if (!validEscapes.has(ch)) {
5871
+ out += '\\\\' + ch;
5872
+ } else {
5873
+ out += ch;
5874
+ }
5875
+ continue;
5876
+ }
5877
+ if (ch === '\\') {
5878
+ if (inStr) {
5879
+ escaped = true;
5880
+ out += ch;
5881
+ } else {
5882
+ out += ch;
5883
+ }
5884
+ continue;
5885
+ }
5869
5886
  if (ch === '"') { inStr = !inStr; out += ch; continue; }
5870
5887
  if (inStr && (ch === '\n' || ch === '\r')) {
5871
5888
  out += ch === '\n' ? '\\n' : '\\r';
@@ -5937,7 +5954,7 @@ REGOLE CRITICHE:
5937
5954
  const fallbackSys = `Sei un esperto di Node.js. Riscrivi il seguente file correggendo questo problema: ${message.slice(0, 500)}
5938
5955
  Rispondi SOLO con il contenuto completo del file corretto, senza markdown fence, senza spiegazioni.`;
5939
5956
  const fallbackUser = `FILE: ${toolCall.path}\n\`\`\`\n${content}\n\`\`\``;
5940
- const newContent = await callLLM(config, fallbackSys, fallbackUser, { max_tokens: 4096 });
5957
+ const newContent = await callLLM(config, fallbackSys, fallbackUser, { max_tokens: 8192 });
5941
5958
  const cleaned = newContent.replace(/^```[\w]*\n?/m, '').replace(/\n?```\s*$/m, '').trim();
5942
5959
  if (cleaned && cleaned.length > 20) {
5943
5960
  fs.writeFileSync(fp, cleaned, 'utf8');
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.5.142';
8
+ export const VERSION = '13.5.144';
9
9
  export const BASE_URL = 'https://nothumanallowed.com/cli';
10
10
  export const API_BASE = 'https://nothumanallowed.com/api/v1';
11
11
 
@@ -574,6 +574,41 @@ RULES:
574
574
  - API TIP: For npm package info, use fetch_url with the registry API: fetch_url("https://registry.npmjs.org/PACKAGE/latest") for version/description, and fetch_url("https://api.npmjs.org/downloads/point/last-week/PACKAGE") for weekly downloads. These are JSON APIs, much more reliable than scraping the npm website.
575
575
  `.trim();
576
576
 
577
+ // ── Liara compact system prompt ───────────────────────────────────────────────
578
+ // Used ONLY when provider === 'nha'. Liara already knows tool signatures from
579
+ // LoRA training — no verbose descriptions needed. Dynamic values (today, tz,
580
+ // language, profile, imap accounts) are still injected at runtime below.
581
+ export const LIARA_TOOL_DEFINITIONS = `You are Liara, the NHA personal AI assistant.
582
+ Today: {{TODAY}} | Timezone: {{TIMEZONE}} | Language: {{LANGUAGE}}
583
+
584
+ When the user's request requires an action, output one or more fenced JSON blocks:
585
+ \`\`\`json
586
+ {"action": "<tool_name>", "params": { ... }}
587
+ \`\`\`
588
+ Multiple blocks allowed for chaining. Include natural text before/between/after blocks.
589
+ Never output a JSON block as a suggestion — every block executes immediately.
590
+
591
+ AVAILABLE TOOLS:
592
+ gmail_list · gmail_read · gmail_send · gmail_draft · gmail_reply · gmail_mark_read · gmail_mark_unread · gmail_archive · gmail_delete · gmail_send_attach
593
+ imap_accounts · imap_list · imap_read · imap_send · imap_sync · imap_labels · imap_mark_read · imap_reply · imap_thread · imap_search · imap_mark_starred · imap_trash · imap_draft · imap_send_template · imap_bulk_send
594
+ calendar_today · calendar_tomorrow · calendar_upcoming · calendar_week · calendar_create · calendar_move · calendar_find · calendar_update · schedule_meeting · schedule_draft_email
595
+ task_list · task_add · task_done · task_move · task_delete · task_clear · task_edit
596
+ contact_search · contact_add · contact_update · contact_delete
597
+ gtask_list · gtask_add · gtask_complete
598
+ note_add · note_list
599
+ github_issues · github_prs · github_notifications · github_create_issue
600
+ notion_search · notion_page
601
+ slack_channels · slack_messages · slack_send
602
+ web_search · fetch_url
603
+ browser_open · browser_screenshot · browser_click · browser_type · browser_extract · browser_js · browser_wait · browser_scroll · browser_key · browser_close
604
+ cron_add · cron_list · cron_remove
605
+ screen_capture · screen_analyze
606
+ canvas_render · canvas_clear
607
+ collab_send · collab_read
608
+ file_list · file_read · file_write · file_info · file_search
609
+ drive_list · drive_read · drive_upload · drive_update · drive_delete · drive_info · drive_folder · drive_download
610
+ maps_directions · notify_remind · birthdays_upcoming · birthday_add · execute_code`.trim();
611
+
577
612
  // ── Action Parser ────────────────────────────────────────────────────────────
578
613
 
579
614
  /**
@@ -749,7 +784,13 @@ export async function buildSystemPrompt(persona, personaDescription, config, ini
749
784
  };
750
785
  const language = config?.language || LANG_MAP[langCode] || 'English';
751
786
 
752
- let prompt = TOOL_DEFINITIONS
787
+ // Liara (provider 'nha') uses the compact prompt tool signatures are
788
+ // already baked into the LoRA weights, no verbose descriptions needed.
789
+ // All other providers get the full TOOL_DEFINITIONS with descriptions.
790
+ const isLiara = config?.llm?.provider === 'nha';
791
+ const baseDefinitions = isLiara ? LIARA_TOOL_DEFINITIONS : TOOL_DEFINITIONS;
792
+
793
+ let prompt = baseDefinitions
753
794
  .replace('{{TODAY}}', today)
754
795
  .replace('{{TIMEZONE}}', tz)
755
796
  .replace(/\{\{LANGUAGE\}\}/g, language);