nothumanallowed 13.5.125 → 13.5.127

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.125",
3
+ "version": "13.5.127",
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": {
@@ -57,9 +57,11 @@
57
57
  "check-bundle": "node check-bundle.mjs"
58
58
  },
59
59
  "dependencies": {
60
- "better-sqlite3": "^12.9.0",
61
60
  "imapflow": "^1.3.3",
62
61
  "mailparser": "^3.9.8",
63
62
  "ws": "^8.18.0"
63
+ },
64
+ "optionalDependencies": {
65
+ "better-sqlite3": "^12.9.0"
64
66
  }
65
67
  }
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.125';
8
+ export const VERSION = '13.5.127';
9
9
  export const BASE_URL = 'https://nothumanallowed.com/cli';
10
10
  export const API_BASE = 'https://nothumanallowed.com/api/v1';
11
11
 
@@ -6,7 +6,6 @@
6
6
  * Nothing is ever written back to the IMAP server.
7
7
  */
8
8
 
9
- import Database from 'better-sqlite3';
10
9
  import { createHash, randomUUID } from 'crypto';
11
10
  import { mkdirSync } from 'fs';
12
11
  import { join } from 'path';
@@ -17,13 +16,26 @@ const DB_PATH = join(NHA_DIR, 'email.db');
17
16
 
18
17
  let _db = null;
19
18
 
19
+ // Lazy-load better-sqlite3 so NHA works on platforms where it can't be compiled (Android/Termux)
20
+ let _Database = null;
21
+ try {
22
+ const mod = await import('better-sqlite3');
23
+ _Database = mod.default || mod;
24
+ } catch {
25
+ // better-sqlite3 not available (e.g. Android/Termux without build tools)
26
+ // IMAP email features will be disabled; all other NHA features work normally
27
+ }
28
+
29
+ export const SQLITE_AVAILABLE = !!_Database;
30
+
20
31
  export function getDb() {
32
+ if (!_Database) throw new Error('Email features are not available on this platform. better-sqlite3 requires native compilation (not supported on Android/Termux). All other NHA features work normally.');
21
33
  if (_db && _db.open) return _db;
22
34
  mkdirSync(NHA_DIR, { recursive: true });
23
- _db = new Database(DB_PATH);
35
+ _db = new _Database(DB_PATH);
24
36
  _db.pragma('journal_mode = WAL');
25
37
  _db.pragma('foreign_keys = ON');
26
- _db.pragma('cache_size = -8000'); // 8MB
38
+ _db.pragma('cache_size = -8000');
27
39
  initSchema(_db);
28
40
  return _db;
29
41
  }
@@ -961,9 +961,17 @@ export async function executeTool(action, params, config) {
961
961
  const { listMessages: imapListMessages } = await import('./email-db.mjs');
962
962
  const result = imapListMessages(params.accountId, params.labelId || null, params.limit || 20, 0, params.search || null);
963
963
  if (!result.messages.length) return 'No messages found.';
964
- return result.messages.map(m =>
965
- `[${m.id}] ${m.is_read ? '' : '[UNREAD] '}From: ${m.from_name || m.from_address} | ${m.subject} | ${(m.internal_date || '').slice(0, 10)}\n Preview: ${(m.body_preview || '').slice(0, 120)}`
966
- ).join('\n\n') + `\n\n(${result.total} total)`;
964
+ const rows = result.messages.map((m, i) => {
965
+ const date = (m.internal_date || '').slice(0, 10);
966
+ const time = (m.internal_date || '').slice(11, 16);
967
+ const from = m.from_name ? `${m.from_name} <${m.from_address}>` : m.from_address;
968
+ const status = m.is_read ? '✓' : '● UNREAD';
969
+ const star = m.is_starred ? ' ★' : '';
970
+ const attach = m.has_attachments ? ' 📎' : '';
971
+ const preview = (m.body_preview || '').slice(0, 150);
972
+ return `${i + 1}. ${status}${star}${attach}\n ID: ${m.id}\n From: ${from}\n Subject: ${m.subject || '(no subject)'}\n Date: ${date} ${time}\n Preview: ${preview}`;
973
+ });
974
+ return `Found ${result.total} messages (showing ${result.messages.length}):\n\n` + rows.join('\n\n---\n\n');
967
975
  }
968
976
 
969
977
  case 'imap_read': {