nothumanallowed 14.1.52 → 14.1.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 +1 -1
- package/src/constants.mjs +1 -1
- package/src/server/routes/config.mjs +30 -6
- package/src/server/routes/email.mjs +99 -0
- package/src/server/routes/integrations.mjs +7 -4
- package/src/services/llm.mjs +1 -48
- package/src/ui-dist/assets/index-BcWtbWUs.css +1 -0
- package/src/ui-dist/assets/index-HtvUYbQA.js +684 -0
- package/src/ui-dist/index.html +2 -2
- package/src/ui-dist/assets/index-B88PlySv.js +0 -684
- package/src/ui-dist/assets/index-BRTO-LWg.css +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nothumanallowed",
|
|
3
|
-
"version": "14.1.
|
|
3
|
+
"version": "14.1.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": {
|
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.
|
|
8
|
+
export const VERSION = '14.1.54';
|
|
9
9
|
export const BASE_URL = 'https://nothumanallowed.com/cli';
|
|
10
10
|
export const API_BASE = 'https://nothumanallowed.com/api/v1';
|
|
11
11
|
|
|
@@ -51,9 +51,30 @@ export function register(router) {
|
|
|
51
51
|
const { promisify } = await import('util');
|
|
52
52
|
const execAsync = promisify(exec);
|
|
53
53
|
|
|
54
|
-
//
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
// Detect the package manager and global prefix to handle permissions correctly
|
|
55
|
+
let cmd = 'npm install -g nothumanallowed@latest';
|
|
56
|
+
|
|
57
|
+
// On macOS/Linux, check if we need special handling for permission
|
|
58
|
+
if (process.platform !== 'win32') {
|
|
59
|
+
try {
|
|
60
|
+
// Check if npm global dir is writable by current user
|
|
61
|
+
const { stdout: prefix } = await execAsync('npm config get prefix', { timeout: 5000 });
|
|
62
|
+
const globalDir = prefix.trim();
|
|
63
|
+
await fs.promises.access(path.join(globalDir, 'lib'), fs.constants.W_OK);
|
|
64
|
+
} catch {
|
|
65
|
+
// Global dir not writable — return error with clear instructions
|
|
66
|
+
sendJSON(res, 200, {
|
|
67
|
+
success: false,
|
|
68
|
+
error: 'EACCES: permission denied',
|
|
69
|
+
message: 'Permission denied. Run: sudo npm install -g nothumanallowed@latest'
|
|
70
|
+
});
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const { stdout, stderr } = await execAsync(cmd, {
|
|
76
|
+
timeout: 120_000,
|
|
77
|
+
env: { ...process.env, NODE_ENV: 'production' },
|
|
57
78
|
});
|
|
58
79
|
|
|
59
80
|
sendJSON(res, 200, {
|
|
@@ -63,10 +84,13 @@ export function register(router) {
|
|
|
63
84
|
stderr: stderr.trim()
|
|
64
85
|
});
|
|
65
86
|
} catch (e) {
|
|
66
|
-
|
|
87
|
+
const isPermission = e.message?.includes('EACCES') || e.message?.includes('permission denied');
|
|
88
|
+
sendJSON(res, 200, {
|
|
67
89
|
success: false,
|
|
68
|
-
error: e.message,
|
|
69
|
-
message:
|
|
90
|
+
error: isPermission ? 'EACCES: permission denied' : e.message,
|
|
91
|
+
message: isPermission
|
|
92
|
+
? 'Permission denied. Run: sudo npm install -g nothumanallowed@latest'
|
|
93
|
+
: 'Update failed. Try running: npm install -g nothumanallowed@latest'
|
|
70
94
|
});
|
|
71
95
|
}
|
|
72
96
|
});
|
|
@@ -9,6 +9,92 @@ import { loadConfig } from '../../config.mjs';
|
|
|
9
9
|
import { NHA_DIR } from '../../constants.mjs';
|
|
10
10
|
import { getUnreadImportant, getMessage, listMessages, getTodayEmails, sendEmail, createDraft } from '../../services/mail-router.mjs';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Persist a single Gmail API message to the local SQLite DB.
|
|
14
|
+
* Non-blocking — errors are caught and logged, never thrown to the caller.
|
|
15
|
+
*/
|
|
16
|
+
async function persistGmailMessageToDb(config, msg) {
|
|
17
|
+
if (!msg || !msg.id) return;
|
|
18
|
+
|
|
19
|
+
const { SQLITE_AVAILABLE, getDb, ensureGoogleAccount, upsertFolder } = await import('../../services/email-db.mjs');
|
|
20
|
+
if (!SQLITE_AVAILABLE) return;
|
|
21
|
+
|
|
22
|
+
const db = getDb();
|
|
23
|
+
|
|
24
|
+
// Determine the user's email from config
|
|
25
|
+
let accountEmail = 'gmail@account';
|
|
26
|
+
try {
|
|
27
|
+
accountEmail = config.google?.email || config.email || accountEmail;
|
|
28
|
+
} catch {}
|
|
29
|
+
// Fallback: extract from 'to' field
|
|
30
|
+
if (accountEmail === 'gmail@account' && msg.to) {
|
|
31
|
+
const match = msg.to.match(/<(.+?)>$/);
|
|
32
|
+
accountEmail = match ? match[1] : msg.to;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Ensure Google account exists
|
|
36
|
+
const googleAccount = ensureGoogleAccount({
|
|
37
|
+
id: 'google',
|
|
38
|
+
display_name: 'Gmail',
|
|
39
|
+
email_address: accountEmail,
|
|
40
|
+
imap_host: 'gmail.googleapis.com',
|
|
41
|
+
imap_port: 993,
|
|
42
|
+
is_active: 1
|
|
43
|
+
});
|
|
44
|
+
if (!googleAccount) return;
|
|
45
|
+
|
|
46
|
+
// Determine folder from labels
|
|
47
|
+
let folderKey = 'INBOX';
|
|
48
|
+
if (msg.labels && Array.isArray(msg.labels)) {
|
|
49
|
+
if (msg.labels.includes('SENT')) folderKey = 'SENT';
|
|
50
|
+
else if (msg.labels.includes('DRAFT')) folderKey = 'DRAFTS';
|
|
51
|
+
else if (msg.labels.includes('SPAM')) folderKey = 'SPAM';
|
|
52
|
+
else if (msg.labels.includes('TRASH')) folderKey = 'TRASH';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const folderMap = {
|
|
56
|
+
'INBOX': { name: 'Inbox', type: 'inbox' },
|
|
57
|
+
'SENT': { name: 'Sent', type: 'sent' },
|
|
58
|
+
'DRAFTS': { name: 'Drafts', type: 'drafts' },
|
|
59
|
+
'SPAM': { name: 'Spam', type: 'spam' },
|
|
60
|
+
'TRASH': { name: 'Trash', type: 'trash' },
|
|
61
|
+
};
|
|
62
|
+
const folderInfo = folderMap[folderKey] || { name: 'Inbox', type: 'inbox' };
|
|
63
|
+
const folderId = upsertFolder(googleAccount.id, folderKey, folderInfo.name, folderInfo.type, 1, 0);
|
|
64
|
+
if (!folderId) return;
|
|
65
|
+
|
|
66
|
+
// Extract email/name from "Name <email>" format
|
|
67
|
+
const fromEmail = msg.from ? (msg.from.match(/<(.+?)>$/)?.[1] || msg.from) : '';
|
|
68
|
+
const fromName = msg.from ? (msg.from.match(/^(.+?)\s*<.+>$/)?.[1]?.replace(/['"]/g, '') || '') : '';
|
|
69
|
+
|
|
70
|
+
// Insert or replace message
|
|
71
|
+
db.prepare(`
|
|
72
|
+
INSERT OR REPLACE INTO email_messages
|
|
73
|
+
(id, account_id, folder_id, imap_folder_path, uid, message_id, thread_id,
|
|
74
|
+
subject, from_address, from_name, to_addresses, body_text, body_html, body_preview,
|
|
75
|
+
internal_date, has_attachments, source)
|
|
76
|
+
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|
|
77
|
+
`).run(
|
|
78
|
+
msg.id, googleAccount.id, folderId, folderKey,
|
|
79
|
+
Date.now() + (Math.random() * 1000 | 0),
|
|
80
|
+
msg.id, msg.threadId || msg.id,
|
|
81
|
+
msg.subject || '(no subject)',
|
|
82
|
+
fromEmail, fromName,
|
|
83
|
+
msg.to || '',
|
|
84
|
+
msg.body || '', msg.bodyHtml || '',
|
|
85
|
+
msg.snippet || '',
|
|
86
|
+
new Date(msg.date || Date.now()).toISOString(),
|
|
87
|
+
(msg.attachments && msg.attachments.length > 0) ? 1 : 0,
|
|
88
|
+
'gmail_api'
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
// Persist read/starred state
|
|
92
|
+
db.prepare(`
|
|
93
|
+
INSERT OR REPLACE INTO email_message_state (message_id, is_read, is_starred)
|
|
94
|
+
VALUES (?, ?, ?)
|
|
95
|
+
`).run(msg.id, msg.isUnread ? 0 : 1, msg.isImportant ? 1 : 0);
|
|
96
|
+
}
|
|
97
|
+
|
|
12
98
|
export function register(router) {
|
|
13
99
|
// ── Gmail ──────────────────────────────────────────────────────────────
|
|
14
100
|
|
|
@@ -50,6 +136,13 @@ export function register(router) {
|
|
|
50
136
|
: folder;
|
|
51
137
|
const emails = await getAllEmails(config, gmailFolder, limit + offset);
|
|
52
138
|
sendJSON(res, 200, { emails: emails.slice(offset, offset + limit), total: emails.length });
|
|
139
|
+
|
|
140
|
+
// Persist fetched emails to local SQLite DB (fire-and-forget, non-blocking)
|
|
141
|
+
setImmediate(() => {
|
|
142
|
+
for (const msg of emails) {
|
|
143
|
+
persistGmailMessageToDb(config, msg).catch(() => {});
|
|
144
|
+
}
|
|
145
|
+
});
|
|
53
146
|
} catch (providerErr) {
|
|
54
147
|
if (providerErr.message?.includes('No mail provider') || providerErr.message?.includes('token')) {
|
|
55
148
|
try {
|
|
@@ -90,6 +183,12 @@ export function register(router) {
|
|
|
90
183
|
try {
|
|
91
184
|
const msg = await getMessage(config, msgId);
|
|
92
185
|
console.log('[EMAIL READ SUCCESS] Gmail API returned:', JSON.stringify(msg, null, 2).slice(0, 500));
|
|
186
|
+
|
|
187
|
+
// Persist to local SQLite DB for offline/local-first access
|
|
188
|
+
persistGmailMessageToDb(config, msg).catch(e =>
|
|
189
|
+
console.warn('[EMAIL READ] Failed to persist to DB:', e.message)
|
|
190
|
+
);
|
|
191
|
+
|
|
93
192
|
sendJSON(res, 200, { message: msg });
|
|
94
193
|
} catch (providerErr) {
|
|
95
194
|
// Gmail API failed — fall back to local IMAP DB
|
|
@@ -24,12 +24,15 @@ export function register(router) {
|
|
|
24
24
|
|
|
25
25
|
router.get('/api/github', async (req, res) => {
|
|
26
26
|
try {
|
|
27
|
-
const {
|
|
27
|
+
const { listNotificationsRaw } = await import('../../services/github.mjs');
|
|
28
28
|
const config = loadConfig();
|
|
29
|
-
|
|
29
|
+
const notifications = await listNotificationsRaw(config);
|
|
30
|
+
sendJSON(res, 200, { notifications: Array.isArray(notifications) ? notifications : [] });
|
|
30
31
|
} catch (e) {
|
|
31
|
-
if (e.message?.includes('token') || e.message?.includes('not configured')
|
|
32
|
-
|
|
32
|
+
if (e.message?.includes('token') || e.message?.includes('not configured') || e.message?.includes('401')) {
|
|
33
|
+
return sendJSON(res, 200, { notifications: [], error: 'GitHub token not configured or expired. Run: nha config set github-token YOUR_PAT' });
|
|
34
|
+
}
|
|
35
|
+
sendJSON(res, 200, { notifications: [], error: e.message });
|
|
33
36
|
}
|
|
34
37
|
});
|
|
35
38
|
|
package/src/services/llm.mjs
CHANGED
|
@@ -1112,26 +1112,12 @@ function parseSSEText(text, format, onToken) {
|
|
|
1112
1112
|
}
|
|
1113
1113
|
}
|
|
1114
1114
|
if (out) {
|
|
1115
|
-
chunkCount++;
|
|
1116
|
-
if (chunkCount <= 3) process.stderr.write(`[QWEN3 CHUNK ${chunkCount}] len=${out.length} repr=${JSON.stringify(out.slice(0,60))}\n`);
|
|
1117
|
-
// Detect HTML output on first meaningful token
|
|
1118
|
-
if (!isHtmlOutput && (out.includes('<div') || out.includes('<!DOCTYPE') || out.includes('<html'))) {
|
|
1119
|
-
isHtmlOutput = true;
|
|
1120
|
-
}
|
|
1121
|
-
if (!isHtmlOutput) {
|
|
1122
|
-
out = fixQwen3Markdown(out);
|
|
1123
|
-
const insideTag = fullText.lastIndexOf('<') > fullText.lastIndexOf('>');
|
|
1124
|
-
if (fullText && out && !insideTag && !/[\s\n]$/.test(fullText) && !/^[\s\n.,;:!?)\]}'">]/.test(out)) {
|
|
1125
|
-
out = ' ' + out;
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
1115
|
fullText += out;
|
|
1129
1116
|
if (onToken) onToken(out);
|
|
1130
1117
|
}
|
|
1131
1118
|
}
|
|
1132
1119
|
} catch {}
|
|
1133
1120
|
}
|
|
1134
|
-
process.stderr.write(`[QWEN3 TOTAL CHUNKS] ${chunkCount}, fullText len=${fullText.length}\n`);
|
|
1135
1121
|
return fullText;
|
|
1136
1122
|
}
|
|
1137
1123
|
|
|
@@ -1143,11 +1129,6 @@ async function streamSSEWithCallback(res, format, onToken) {
|
|
|
1143
1129
|
let fullText = '';
|
|
1144
1130
|
let thinkBuf = ''; // accumulates <think>...</think> content to suppress
|
|
1145
1131
|
let inThink = false;
|
|
1146
|
-
let isHtmlOutput = false;
|
|
1147
|
-
|
|
1148
|
-
// BPE REPAIR STREAMING: accumula parole fino a punctuation, ripara, e invia token per token
|
|
1149
|
-
let bpeBuffer = '';
|
|
1150
|
-
let lastSentPos = 0;
|
|
1151
1132
|
|
|
1152
1133
|
while (true) {
|
|
1153
1134
|
const { done, value } = await reader.read();
|
|
@@ -1193,36 +1174,8 @@ async function streamSSEWithCallback(res, format, onToken) {
|
|
|
1193
1174
|
}
|
|
1194
1175
|
}
|
|
1195
1176
|
if (out) {
|
|
1196
|
-
if (!isHtmlOutput && (out.includes('<div') || out.includes('<!DOCTYPE') || out.includes('<html'))) {
|
|
1197
|
-
isHtmlOutput = true;
|
|
1198
|
-
}
|
|
1199
|
-
if (!isHtmlOutput) {
|
|
1200
|
-
out = fixQwen3Markdown(out);
|
|
1201
|
-
const insideTag2 = fullText.lastIndexOf('<') > fullText.lastIndexOf('>');
|
|
1202
|
-
if (fullText && out && !insideTag2 && !/[\s\n]$/.test(fullText) && !/^[\s\n.,;:!?)\]}'">]/.test(out)) {
|
|
1203
|
-
out = ' ' + out;
|
|
1204
|
-
}
|
|
1205
|
-
}
|
|
1206
1177
|
fullText += out;
|
|
1207
|
-
|
|
1208
|
-
// BPE REPAIR STREAMING: accumula nel buffer e invia token riparati progressivamente
|
|
1209
|
-
bpeBuffer += out;
|
|
1210
|
-
|
|
1211
|
-
// Quando raggiungiamo un punto di stop naturale (punteggiatura), ripara il buffer
|
|
1212
|
-
if (/[.!?;:\n]/.test(out)) {
|
|
1213
|
-
const repairedBuffer = fixQwen3BPE(bpeBuffer);
|
|
1214
|
-
|
|
1215
|
-
// Invia solo la parte nuova (dalla posizione precedente)
|
|
1216
|
-
const newPart = repairedBuffer.slice(lastSentPos);
|
|
1217
|
-
if (newPart && onToken) {
|
|
1218
|
-
onToken(newPart);
|
|
1219
|
-
}
|
|
1220
|
-
|
|
1221
|
-
lastSentPos = repairedBuffer.length;
|
|
1222
|
-
} else {
|
|
1223
|
-
// Per output senza punteggiatura, invia token originali
|
|
1224
|
-
if (onToken) onToken(out);
|
|
1225
|
-
}
|
|
1178
|
+
if (onToken) onToken(out);
|
|
1226
1179
|
}
|
|
1227
1180
|
}
|
|
1228
1181
|
} catch {}
|