nothumanallowed 14.1.4 → 14.1.5

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": "14.1.4",
3
+ "version": "14.1.5",
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": {
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 = '14.1.4';
8
+ export const VERSION = '14.1.5';
9
9
  export const BASE_URL = 'https://nothumanallowed.com/cli';
10
10
  export const API_BASE = 'https://nothumanallowed.com/api/v1';
11
11
 
@@ -275,12 +275,59 @@ export function register(router) {
275
275
  a.params = { url: 'https://' + a.params.query.trim() };
276
276
  }
277
277
  }
278
+ // Auto-detect email reading intent — force imap_list if LLM didn't emit the tool
279
+ const wantsReadEmail = /\b(leggi|read|mostra|lista|ultime?|recenti?|email|mail|inbox|posta)\b.*\b(email|mail|messag|inbox|posta)\b|\b(email|mail)\b.*\b(leggi|read|mostra|lista|ultime?|recenti?)\b/i.test(msg);
280
+ if (wantsReadEmail && !actions.some(a => a.action?.startsWith('imap_') || a.action === 'list_emails')) {
281
+ try {
282
+ const { listAccounts: _la } = await import('../../services/email-db.mjs');
283
+ const imapAccs = _la();
284
+ if (imapAccs.length > 0) {
285
+ const firstAcc = imapAccs[0];
286
+ const limitMatch = msg.match(/\b(\d+)\b/);
287
+ const limit = limitMatch ? Math.min(parseInt(limitMatch[1]), 20) : 5;
288
+ actions.push({ action: 'imap_list', params: { accountId: firstAcc.id, limit } });
289
+ }
290
+ } catch { /* fallback to LLM response */ }
291
+ }
278
292
 
279
293
  for (const { action, params } of actions) {
280
294
  if (action === 'web_search' && wantsScreenshot) params.screenshot = true;
281
295
  sse('tool', { action, status: 'executing' });
282
296
  try {
283
297
  const result = await executeTool(action, params, config);
298
+
299
+ // ── Screenshot result handling ───────────────────────────────────
300
+ if (result && typeof result === 'object' && result.__screenshot) {
301
+ // Copy file to ~/.nha/screenshots/ so the UI can load it via /api/screenshots/
302
+ let screenshotUrl = null;
303
+ try {
304
+ const ssDir = path.join(os.homedir(), '.nha', 'screenshots');
305
+ if (!fs.existsSync(ssDir)) fs.mkdirSync(ssDir, { recursive: true });
306
+ const filename = `screenshot-${Date.now()}.png`;
307
+ const destPath = path.join(ssDir, filename);
308
+ if (result.path && fs.existsSync(result.path)) {
309
+ fs.copyFileSync(result.path, destPath);
310
+ screenshotUrl = `/api/screenshots/${filename}`;
311
+ } else if (result.base64) {
312
+ fs.writeFileSync(destPath, Buffer.from(result.base64, 'base64'));
313
+ screenshotUrl = `/api/screenshots/${filename}`;
314
+ }
315
+ } catch { /* fallback — no image shown */ }
316
+
317
+ // Vision analysis — LLM describes what's in the screenshot
318
+ let visionDescription = 'Screenshot captured.';
319
+ if (result.base64) {
320
+ try {
321
+ visionDescription = await callLLMVision(config, 'You are a helpful assistant describing a screenshot.', result.question || 'Describe EXACTLY and ONLY what you see in this screenshot.', { base64: result.base64, mediaType: 'image/png' });
322
+ } catch { /* keep default description */ }
323
+ }
324
+
325
+ toolResults.push({ action, result: visionDescription });
326
+ sse('tool', { action, status: 'done', result: visionDescription.slice(0, 500) });
327
+ if (screenshotUrl) sse('screenshot', { url: screenshotUrl });
328
+ continue;
329
+ }
330
+
284
331
  let resultStr = typeof result === 'object' ? JSON.stringify(result) : String(result);
285
332
  if ((action === 'web_search' || action === 'fetch_url') && resultStr.includes('<')) {
286
333
  resultStr = resultStr