nothumanallowed 13.5.123 → 13.5.125

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.123",
3
+ "version": "13.5.125",
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": {
@@ -613,7 +613,7 @@ export async function cmdChat(args) {
613
613
  terminal: true,
614
614
  });
615
615
 
616
- const systemPrompt = buildSystemPrompt('NHA Chat', CHAT_PERSONA, config, initialContext);
616
+ const systemPrompt = await buildSystemPrompt('NHA Chat', CHAT_PERSONA, config, initialContext);
617
617
 
618
618
  rl.on('close', () => {
619
619
  console.log(`\n ${D}Session ended. Goodbye.${NC}\n`);
@@ -257,7 +257,23 @@ export async function cmdUI(args) {
257
257
  `You help the user manage their emails, calendar, tasks, GitHub issues, Notion pages, and Slack channels through natural conversation. ` +
258
258
  `Be concise, helpful, and proactive. When presenting data, format it clearly. ` +
259
259
  `Never output raw JSON to the user.`;
260
- const chatSystemPrompt = buildSystemPrompt('NHA UI', UI_PERSONA, config);
260
+ const chatSystemPrompt = await buildSystemPrompt('NHA UI', UI_PERSONA, config);
261
+
262
+ // Returns a live IMAP accounts block to append to any system prompt
263
+ async function getImapAccountsContext() {
264
+ try {
265
+ const { listAccounts } = await import('../services/email-db.mjs');
266
+ const accs = listAccounts();
267
+ if (!accs.length) return '';
268
+ let ctx = '\n\n--- IMAP EMAIL ACCOUNTS (custom, already configured) ---\n';
269
+ ctx += 'Use these accountIds directly in imap_* tools — do NOT call imap_accounts() first.\n';
270
+ for (const a of accs) {
271
+ ctx += `accountId: "${a.id}" | email: ${a.email_address} | name: "${a.display_name}" | status: ${a.sync_status}\n`;
272
+ }
273
+ ctx += 'When the user mentions their company name, email domain, or display name, map it to the correct accountId above.';
274
+ return ctx;
275
+ } catch { return ''; }
276
+ }
261
277
 
262
278
  // ── Route Handlers ──────────────────────────────────────────────────────
263
279
 
@@ -1817,13 +1833,17 @@ export async function cmdUI(args) {
1817
1833
  parts.push(`[User] ${body.message}`);
1818
1834
  let userMessage = parts.join('\n\n');
1819
1835
 
1820
- // Inject episodic memory context into the system prompt
1836
+ // Inject episodic memory + live IMAP accounts into the system prompt
1821
1837
  const basePrompt = effectiveSystemPrompt || chatSystemPrompt;
1822
1838
  let enrichedSystemPrompt = basePrompt;
1823
1839
  try {
1824
1840
  const memCtx = buildMemoryContext('chat', body.message);
1825
1841
  if (memCtx) enrichedSystemPrompt = basePrompt + memCtx;
1826
1842
  } catch { /* memory unavailable */ }
1843
+ try {
1844
+ const imapCtx = await getImapAccountsContext();
1845
+ if (imapCtx) enrichedSystemPrompt += imapCtx;
1846
+ } catch { /* imap context unavailable */ }
1827
1847
 
1828
1848
  // Handle image attachment — vision API
1829
1849
  if (body.imageBase64 && body.imageMimeType) {
@@ -2277,6 +2297,7 @@ export async function cmdUI(args) {
2277
2297
  const basePrompt = effectiveSystemPrompt || chatSystemPrompt;
2278
2298
  let enrichedPrompt = basePrompt;
2279
2299
  try { const m = buildMemoryContext('chat', effectiveMsg); if (m) enrichedPrompt = basePrompt + m; } catch {}
2300
+ try { const ic = await getImapAccountsContext(); if (ic) enrichedPrompt += ic; } catch {}
2280
2301
 
2281
2302
  // Build message with rolling context window:
2282
2303
  // - Recent messages (last 6): full content up to 2000 chars
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.123';
8
+ export const VERSION = '13.5.125';
9
9
  export const BASE_URL = 'https://nothumanallowed.com/cli';
10
10
  export const API_BASE = 'https://nothumanallowed.com/api/v1';
11
11
 
@@ -379,13 +379,14 @@ TOOLS:
379
379
  --- IMAP EMAIL (custom accounts) ---
380
380
 
381
381
  64. imap_list(accountId: string, labelId?: string, search?: string, limit?: number)
382
- List emails from a custom IMAP account stored in local DB. Use imap_accounts() to get accountId.
383
- labelId is optional pass the label id to filter (e.g. inbox system label). search is full-text.
382
+ List emails from a custom IMAP account. accountId is known from the IMAP ACCOUNTS section above — use it directly.
383
+ search does full-text match on subject, from_address, from_name, body. Use it to filter by sender name/domain.
384
+ Example: search="zeli" finds all emails from *@zeli.it or with "zeli" in subject/body.
384
385
  Returns: [{id, subject, from_address, from_name, internal_date, body_preview, is_read, is_starred}]
385
386
 
386
387
  65. imap_accounts()
387
- List all configured IMAP accounts. Returns [{id, type, email_address, display_name, sync_status}].
388
- Use the id from here as accountId in other imap_* tools.
388
+ List all configured IMAP accounts. NOTE: accounts are already listed in the IMAP ACCOUNTS section above.
389
+ Only call this if you need to refresh or the section is missing.
389
390
 
390
391
  66. imap_read(messageId: string)
391
392
  Read a full email message from the local DB by its id. Returns subject, from, to, body_text, body_html, attachments.
@@ -414,8 +415,9 @@ TOOLS:
414
415
  Use imap_read() to get the threadId from a message.
415
416
 
416
417
  73. imap_search(accountId: string, query: string, limit?: number)
417
- Full-text search across all synced emails (subject, body, from, to). Returns matching messages.
418
- query is a plain text string. limit defaults to 20.
418
+ Full-text search across all synced emails (subject, body_preview, from_address, from_name).
419
+ query is a plain text string use sender name, domain, or keyword.
420
+ Examples: "zeli" finds emails from *@zeli.it. "fattura" finds emails with that word. limit defaults to 20.
419
421
 
420
422
  74. imap_mark_starred(messageId: string, isStarred?: boolean)
421
423
  Star or unstar a message locally. Default isStarred=true.
@@ -730,7 +732,7 @@ function driveIcon(type) {
730
732
  * @param {string} [initialContext] — optional preloaded context (today's events, etc.)
731
733
  * @returns {string}
732
734
  */
733
- export function buildSystemPrompt(persona, personaDescription, config, initialContext) {
735
+ export async function buildSystemPrompt(persona, personaDescription, config, initialContext) {
734
736
  const today = new Date().toISOString().split('T')[0];
735
737
  const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
736
738
 
@@ -774,6 +776,22 @@ export function buildSystemPrompt(persona, personaDescription, config, initialCo
774
776
  }
775
777
  }
776
778
 
779
+ // Inject IMAP accounts so the AI knows accountIds without calling imap_accounts()
780
+ try {
781
+ const { listAccounts } = await import('./email-db.mjs').catch(() => ({ listAccounts: null }));
782
+ if (listAccounts) {
783
+ const imapAccounts = listAccounts();
784
+ if (imapAccounts.length > 0) {
785
+ prompt += `\n\n--- IMAP EMAIL ACCOUNTS (custom, already configured) ---\n`;
786
+ prompt += `Use these accountIds directly — do NOT call imap_accounts() first.\n`;
787
+ for (const a of imapAccounts) {
788
+ prompt += `accountId: "${a.id}" | email: ${a.email_address} | name: "${a.display_name}" | status: ${a.sync_status}\n`;
789
+ }
790
+ prompt += `When the user mentions their company name, email domain, or display name, map it to the correct accountId above.`;
791
+ }
792
+ }
793
+ } catch {}
794
+
777
795
  if (initialContext) {
778
796
  prompt += `\n\n--- CURRENT CONTEXT (fetched at session start) ---\n${initialContext}`;
779
797
  }