nothumanallowed 13.5.52 → 13.5.54

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.52",
3
+ "version": "13.5.54",
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": {
@@ -4369,9 +4369,36 @@ module.exports = { get, set, del, exists };
4369
4369
  walkDir(sandboxDir, '');
4370
4370
  }
4371
4371
 
4372
- const fileContext = allFiles.map(f => `### FILE: ${f.name}\n\`\`\`\n${f.content}\n\`\`\``).join('\n\n');
4373
4372
  const fileList = allFiles.map(f => f.name).join('\n');
4374
4373
 
4374
+ // Smart file selection: include only relevant files to avoid overflowing context window.
4375
+ // Always include: package.json, server/index.js, .env.example (structure/deps context).
4376
+ // Also include: any file whose name appears in the user message, plus error-related files.
4377
+ const msgLower = (message || '').toLowerCase();
4378
+ const alwaysInclude = ['package.json', 'server/index.js', '.env.example'];
4379
+ const relevantFiles = allFiles.filter(f => {
4380
+ const nameLower = f.name.toLowerCase();
4381
+ if (alwaysInclude.some(a => nameLower.endsWith(a))) return true;
4382
+ // Include if file name or path fragment mentioned in message
4383
+ const parts = f.name.split('/');
4384
+ if (parts.some(p => msgLower.includes(p.replace(/\.[^.]+$/, '').toLowerCase()))) return true;
4385
+ // Include server JS files if message mentions "error", "errore", "fix", "crash", "module"
4386
+ if (/errore|error|fix|crash|module|require|import/i.test(message) && f.name.startsWith('server/') && f.name.endsWith('.js')) return true;
4387
+ return false;
4388
+ });
4389
+ // Cap total context at ~24KB to stay within 7B model limits
4390
+ let contextBudget = 24 * 1024;
4391
+ const selectedFiles = [];
4392
+ for (const f of relevantFiles) {
4393
+ if (contextBudget <= 0) break;
4394
+ selectedFiles.push(f);
4395
+ contextBudget -= f.content.length;
4396
+ }
4397
+ const fileContext = selectedFiles.map(f => `### FILE: ${f.name}\n\`\`\`\n${f.content}\n\`\`\``).join('\n\n');
4398
+ const includedNote = selectedFiles.length < allFiles.length
4399
+ ? `\n(Showing ${selectedFiles.length}/${allFiles.length} files most relevant to the request. Ask to read others explicitly.)`
4400
+ : '';
4401
+
4375
4402
  // Build attachment context (images/PDF)
4376
4403
  const attachCtx = (attachments || []).map((a, i) => `[Allegato ${i+1}: ${a.name || 'file'}, type=${a.mimeType}]`).join('\n');
4377
4404
 
@@ -4405,23 +4432,37 @@ REGOLE CRITICHE:
4405
4432
  - Se usi immagini allegate, descrivile e usale come contesto per il fix`;
4406
4433
 
4407
4434
  const userMsg = message + (attachCtx ? '\n\nAllegati:\n' + attachCtx : '') +
4408
- '\n\n--- CONTENUTO FILE ---\n' + fileContext;
4435
+ '\n\n--- CONTENUTO FILE ---' + includedNote + '\n' + fileContext;
4409
4436
 
4410
4437
  // Call LLM - stream tokens
4411
4438
  let fullResponse = '';
4412
4439
  const visionAttachments = (attachments || []).filter(a => a.base64 && (a.mimeType || '').startsWith('image/'));
4413
4440
 
4414
- if (visionAttachments.length > 0) {
4415
- // Use vision call for first image attachment
4416
- const { callLLMVision } = await import('../services/llm.mjs');
4417
- const va = visionAttachments[0];
4418
- fullResponse = await callLLMVision(config, systemPrompt, userMsg, { base64: va.base64, mimeType: va.mimeType });
4419
- sendEv({ type: 'text', token: fullResponse });
4420
- } else {
4421
- await callLLMStream(config, systemPrompt, userMsg, (token) => {
4422
- fullResponse += token;
4423
- sendEv({ type: 'text', token });
4424
- }, { max_tokens: 4096 });
4441
+ try {
4442
+ if (visionAttachments.length > 0) {
4443
+ const { callLLMVision } = await import('../services/llm.mjs');
4444
+ const va = visionAttachments[0];
4445
+ fullResponse = await callLLMVision(config, systemPrompt, userMsg, { base64: va.base64, mimeType: va.mimeType });
4446
+ sendEv({ type: 'text', token: fullResponse });
4447
+ } else {
4448
+ await callLLMStream(config, systemPrompt, userMsg, (token) => {
4449
+ fullResponse += token;
4450
+ sendEv({ type: 'text', token });
4451
+ }, { max_tokens: 4096 });
4452
+ }
4453
+ } catch (llmErr) {
4454
+ const errMsg = llmErr.message || String(llmErr);
4455
+ // Surface a clean message instead of raw HTML
4456
+ if (errMsg.includes('502') || errMsg.includes('Bad Gateway')) {
4457
+ sendEv({ type: 'text', token: 'Liara non disponibile al momento (502). Riprova tra qualche secondo, oppure configura una tua API key con: nha config set provider anthropic && nha config set key sk-...' });
4458
+ } else if (errMsg.includes('429') || errMsg.includes('rate limit')) {
4459
+ sendEv({ type: 'text', token: 'Rate limit raggiunto su Liara (max 3 auto-fix per 5 minuti con il piano free). Attendi qualche minuto o usa una tua API key.' });
4460
+ } else {
4461
+ sendEv({ type: 'text', token: 'Errore LLM: ' + errMsg.slice(0, 200) });
4462
+ }
4463
+ sendEv({ type: 'done', changed: false, toolCount: 0 });
4464
+ res.end();
4465
+ return;
4425
4466
  }
4426
4467
 
4427
4468
  // Parse and execute tool calls from response
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.52';
8
+ export const VERSION = '13.5.54';
9
9
  export const BASE_URL = 'https://nothumanallowed.com/cli';
10
10
  export const API_BASE = 'https://nothumanallowed.com/api/v1';
11
11
 
@@ -6316,12 +6316,7 @@ function renderWebCraft(el) {
6316
6316
  '<div style="display:flex;flex-direction:column;height:100%">' +
6317
6317
  wcExHtml +
6318
6318
  '<div style="display:flex;gap:14px;align-items:flex-start;flex:1;min-height:0">' +
6319
- '<div style="width:280px;flex-shrink:0;display:flex;flex-direction:column;gap:10px;overflow-y:auto;height:100%">' +
6320
- '<div style="background:var(--bg2);border:1px solid var(--border);border-radius:10px;padding:14px">' +
6321
- '<div style="font-size:10px;color:var(--dim);text-transform:uppercase;letter-spacing:.8px;margin-bottom:8px">'+t('wc_project')+'</div>' +
6322
- '<input id="wcProjectName" placeholder="'+t('wc_project_name')+'" value="'+wcEsc(wcState.projectName)+'" oninput="wcState.projectName=this.value" style="width:100%;padding:8px 10px;font-size:12px;border-radius:6px;border:1px solid var(--border2);background:var(--bg3);color:var(--text);margin-bottom:8px;box-sizing:border-box">' +
6323
- '<textarea id="wcDesc" placeholder="'+t('wc_desc')+'" rows="4" oninput="wcState.description=this.value" style="width:100%;padding:8px 10px;font-size:12px;border-radius:6px;border:1px solid var(--border2);background:var(--bg3);color:var(--text);resize:vertical;box-sizing:border-box;line-height:1.5">'+wcEsc(wcState.description)+'</textarea>' +
6324
- '</div>' +
6319
+ '<div style="width:240px;flex-shrink:0;display:flex;flex-direction:column;gap:10px;overflow-y:auto;height:100%">' +
6325
6320
  '<div style="background:var(--bg2);border:1px solid var(--border);border-radius:10px;padding:14px">' +
6326
6321
  '<div style="font-size:10px;color:var(--dim);text-transform:uppercase;letter-spacing:.8px;margin-bottom:10px">'+t('wc_blocks')+'</div>' +
6327
6322
  ['auth','cookieBanner','securityMiddleware','emailVerification'].map(function(b){
@@ -6341,9 +6336,9 @@ function renderWebCraft(el) {
6341
6336
  '<div id="wcFieldsList">'+authFieldsHtml+'</div>' +
6342
6337
  '<div style="font-size:9px;color:var(--dim);margin-top:4px">'+t('wc_required_hint')+'</div>' +
6343
6338
  '</div>' +
6344
- '<button id="wcRunBtn" onclick="wcGenerate()" style="width:100%;padding:12px;background:var(--green3);border:none;border-radius:8px;color:var(--bg);font-size:13px;font-weight:700;cursor:pointer;letter-spacing:.2px"'+(wcState.running?' disabled':'')+'>'+
6345
- (wcState.running ? '&#9203; '+t('wc_generating')+'...' : '&#9654; '+t('wc_generate')) +
6346
- '</button>' +
6339
+ (wcState.running ?
6340
+ '<div style="width:100%;padding:11px;background:var(--bg3);border:1px solid var(--border);border-radius:8px;color:var(--dim);font-size:12px;text-align:center">&#9203; '+t('wc_generating')+'...</div>'
6341
+ : '') +
6347
6342
  (wcState.generatedFiles.length > 0 && !wcState.running ?
6348
6343
  '<button onclick="wcDownloadZip()" style="width:100%;padding:10px;background:var(--bg3);border:1px solid var(--border2);border-radius:8px;color:var(--text);font-size:12px;font-weight:600;cursor:pointer">&#8681; '+t('wc_download')+'</button>' +
6349
6344
  '<button onclick="wcStartSandbox()" id="wcSandboxBtn" style="width:100%;padding:10px;background:var(--bg3);border:1px solid var(--green3);border-radius:8px;color:var(--green);font-size:12px;font-weight:600;cursor:pointer">&#9654; '+t('wc_sandbox_start')+'</button>'
@@ -6442,9 +6437,17 @@ function wcChatPanelHtml() {
6442
6437
  '</div>';
6443
6438
  }
6444
6439
 
6445
- var sendBtnLabel = hasProject ? (wcState.running ? '&#9203;' : '&#9654;') : '&#9654; Genera';
6440
+ var sendBtnLabel = wcState.running ? '&#9203;' : (hasProject ? '&#9654;' : '&#9654; Genera');
6446
6441
  var inputDisabled = wcChatRunning || wcState.running;
6447
6442
 
6443
+ // Project name row — shown only when no project yet
6444
+ var projNameRow = !hasProject
6445
+ ? '<div style="display:flex;align-items:center;gap:8px;padding:6px 12px 0">' +
6446
+ '<span style="font-size:10px;color:var(--dim);white-space:nowrap">Nome progetto:</span>' +
6447
+ '<input id="wcProjectName" placeholder="MioProgetto" value="'+wcEsc(wcState.projectName)+'" oninput="wcState.projectName=this.value" style="flex:1;padding:4px 8px;font-size:11px;border-radius:5px;border:1px solid var(--border2);background:var(--bg3);color:var(--text)">' +
6448
+ '</div>'
6449
+ : '<div style="padding:4px 12px 0;font-size:10px;color:var(--dim)">&#128196; <strong style="color:var(--green)">'+wcEsc(wcState.projectName)+'</strong> &mdash; scrivi per modificare o migliorare il progetto</div>';
6450
+
6448
6451
  return '<div style="border-top:1px solid var(--border);background:var(--bg2);flex-shrink:0;display:flex;flex-direction:column">' +
6449
6452
  // Messages
6450
6453
  '<div id="wcChatMessages" style="max-height:160px;overflow-y:auto;padding:6px 0">' +
@@ -6452,8 +6455,10 @@ function wcChatPanelHtml() {
6452
6455
  '</div>' +
6453
6456
  // Attachments
6454
6457
  attachPreview +
6458
+ // Project name (only pre-generation)
6459
+ projNameRow +
6455
6460
  // Input row
6456
- '<div style="display:flex;align-items:flex-end;gap:8px;padding:8px 12px;border-top:1px solid var(--border)">' +
6461
+ '<div style="display:flex;align-items:flex-end;gap:8px;padding:8px 12px">' +
6457
6462
  '<label style="cursor:pointer;color:var(--dim);font-size:16px;flex-shrink:0;padding-bottom:2px" title="Allega immagine o PDF">' +
6458
6463
  '&#128206;' +
6459
6464
  '<input type="file" id="wcFileInput" multiple accept="image/*,.pdf" style="display:none" onchange="wcHandleFileAttach(this)">' +
@@ -6497,7 +6502,8 @@ async function wcChatSend() {
6497
6502
  if (!hasProject) {
6498
6503
  if (!msg || msg.length < 5) { alert(t('wc_describe_first')); return; }
6499
6504
  var projNameEl = document.getElementById('wcProjectName');
6500
- if (projNameEl && projNameEl.value) wcState.projectName = projNameEl.value;
6505
+ if (projNameEl && projNameEl.value.trim()) wcState.projectName = projNameEl.value.trim();
6506
+ if (!wcState.projectName) wcState.projectName = 'MyProject';
6501
6507
  wcState.description = msg;
6502
6508
  if (inputEl) inputEl.value = '';
6503
6509
  wcGenerate();
@@ -6748,9 +6754,9 @@ function wcSetFile(i) { wcState.activeFile = i; renderWebCraft(document.getEleme
6748
6754
 
6749
6755
  async function wcGenerate() {
6750
6756
  if (wcState.running) return;
6751
- var desc = (document.getElementById('wcDesc')||{}).value || wcState.description;
6752
- var projName = (document.getElementById('wcProjectName')||{}).value || wcState.projectName || 'myproject';
6753
- if (!desc || desc.length < 10) { alert(t('wc_describe_first')); return; }
6757
+ var desc = wcState.description;
6758
+ var projName = wcState.projectName || 'myproject';
6759
+ if (!desc || desc.length < 5) { alert(t('wc_describe_first')); return; }
6754
6760
  wcState.description = desc;
6755
6761
  wcState.projectName = projName;
6756
6762
  wcState.running = true;