nothumanallowed 13.5.99 → 13.5.101

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/commands/ui.mjs +37 -25
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nothumanallowed",
3
- "version": "13.5.99",
3
+ "version": "13.5.101",
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": {
@@ -4128,6 +4128,32 @@ ${completedHeadings ? `## SECTIONS ALREADY WRITTEN (headings only):\n${completed
4128
4128
  const sendReady = (port, dir) => res.write(`data: ${JSON.stringify({ type: 'ready', port, dir })}\n\n`);
4129
4129
  const sendError = (msg) => res.write(`data: ${JSON.stringify({ type: 'error', msg })}\n\n`);
4130
4130
 
4131
+ // Helper: write sandbox log to skills/ dir — defined before try so catch can use it
4132
+ const writeSandboxLog = (sandboxDirArg, freePortArg, extraLines, isError) => {
4133
+ try {
4134
+ const _nl = '\n';
4135
+ const _now = new Date();
4136
+ const _pad = n => String(n).padStart(2,'0');
4137
+ const logTs = _now.getFullYear()+'-'+_pad(_now.getMonth()+1)+'-'+_pad(_now.getDate())+' '+_pad(_now.getHours())+':'+_pad(_now.getMinutes())+':'+_pad(_now.getSeconds());
4138
+ const logName = projName + '-latest.log';
4139
+ const logsDir = path.join(sandboxDirArg, 'skills');
4140
+ fs.mkdirSync(logsDir, { recursive: true });
4141
+ const oldLogs = fs.readdirSync(logsDir).filter(f => f.endsWith('.log') && f.startsWith(projName + '-') && f !== logName);
4142
+ oldLogs.forEach(f => { try { fs.unlinkSync(path.join(logsDir, f)); } catch(_) {} });
4143
+ const title = isError ? '# Sandbox Log — ' + projName + ' [ERRORE]' : '# Sandbox Log — ' + projName;
4144
+ const logContent = title + _nl + 'Avviato: ' + logTs + _nl + 'Porta: ' + (freePortArg || '?') + _nl + _nl + _sbLogLines.join(_nl) + (extraLines ? _nl + _nl + extraLines : '');
4145
+ fs.writeFileSync(path.join(logsDir, logName), logContent, 'utf8');
4146
+ const idxPath = path.join(logsDir, '_index.json');
4147
+ let idx = {};
4148
+ try { idx = JSON.parse(fs.readFileSync(idxPath, 'utf8')); } catch(_) {}
4149
+ idx[logName] = 'log';
4150
+ fs.writeFileSync(idxPath, JSON.stringify(idx), 'utf8');
4151
+ } catch(_) {}
4152
+ };
4153
+
4154
+ let _sandboxDir = null;
4155
+ let _freePort = null;
4156
+
4131
4157
  try {
4132
4158
  // Kill previous sandbox if running
4133
4159
  if (global._wcSandboxProc) {
@@ -4136,6 +4162,7 @@ ${completedHeadings ? `## SECTIONS ALREADY WRITTEN (headings only):\n${completed
4136
4162
  }
4137
4163
 
4138
4164
  const sandboxDir = path.join(os.homedir(), '.nha', 'webcraft', projName);
4165
+ _sandboxDir = sandboxDir;
4139
4166
  sendLog(`📁 Percorso sandbox: ${sandboxDir}`);
4140
4167
  fs.mkdirSync(sandboxDir, { recursive: true });
4141
4168
 
@@ -4420,6 +4447,13 @@ module.exports = { validateEmail, sanitizeText, validatePassword, validateUserna
4420
4447
  [/require\(['"]\.\/config\/database['"]\)/g, "require('./db')"],
4421
4448
  [/require\(['"]\.\.\/config\/db['"]\)/g, "require('../db')"],
4422
4449
  [/require\(['"]\.\/config\/db['"]\)/g, "require('./db')"],
4450
+ // redis utils — LLM generates custom utils/redis or config/redis wrappers
4451
+ [/require\(['"]\.\.\/utils\/redis['"]\)/g, "require('../services/cache')"],
4452
+ [/require\(['"]\.\/utils\/redis['"]\)/g, "require('../services/cache')"],
4453
+ [/require\(['"]\.\.\/config\/redis['"]\)/g, "require('../services/cache')"],
4454
+ [/require\(['"]\.\/config\/redis['"]\)/g, "require('../services/cache')"],
4455
+ [/require\(['"]\.\.\/services\/redis['"]\)/g, "require('../services/cache')"],
4456
+ [/require\(['"]\.\/services\/redis['"]\)/g, "require('../services/cache')"],
4423
4457
  // email utils: LLM puts utils/email but file is in services/email
4424
4458
  [/require\(['"]\.\.\/utils\/email['"]\)/g, "require('../services/email')"],
4425
4459
  [/require\(['"]\.\/utils\/email['"]\)/g, "require('./services/email')"],
@@ -4546,6 +4580,7 @@ module.exports = { validateEmail, sanitizeText, validatePassword, validateUserna
4546
4580
  const srv = netMod.createServer();
4547
4581
  srv.listen(0, '127.0.0.1', () => { const p = srv.address().port; srv.close(() => resolve(p)); });
4548
4582
  });
4583
+ _freePort = freePort;
4549
4584
 
4550
4585
  // Patch PORT in .env
4551
4586
  fs.writeFileSync(path.join(sandboxDir, '.env'), envContent.replace('PORT=0', `PORT=${freePort}`), 'utf8');
@@ -4596,29 +4631,6 @@ module.exports = { validateEmail, sanitizeText, validatePassword, validateUserna
4596
4631
  sendLog(' [server] ' + l);
4597
4632
  });
4598
4633
 
4599
- // Helper: write sandbox log to skills/ dir (called on both success and error)
4600
- const writeSandboxLog = (extraLines, isError) => {
4601
- try {
4602
- const _nl = '\n';
4603
- const _now = new Date();
4604
- const _pad = n => String(n).padStart(2,'0');
4605
- const logTs = _now.getFullYear()+'-'+_pad(_now.getMonth()+1)+'-'+_pad(_now.getDate())+' '+_pad(_now.getHours())+':'+_pad(_now.getMinutes())+':'+_pad(_now.getSeconds());
4606
- const logName = projName + '-latest.log';
4607
- const logsDir = path.join(sandboxDir, 'skills');
4608
- fs.mkdirSync(logsDir, { recursive: true });
4609
- const oldLogs = fs.readdirSync(logsDir).filter(f => f.endsWith('.log') && f.startsWith(projName + '-') && f !== logName);
4610
- oldLogs.forEach(f => { try { fs.unlinkSync(path.join(logsDir, f)); } catch(_) {} });
4611
- const title = isError ? '# Sandbox Log — ' + projName + ' [ERRORE]' : '# Sandbox Log — ' + projName;
4612
- const logContent = title + _nl + 'Avviato: ' + logTs + _nl + 'Porta: ' + freePort + _nl + _nl + _sbLogLines.join(_nl) + (extraLines ? _nl + _nl + extraLines : '');
4613
- fs.writeFileSync(path.join(logsDir, logName), logContent, 'utf8');
4614
- const idxPath = path.join(logsDir, '_index.json');
4615
- let idx = {};
4616
- try { idx = JSON.parse(fs.readFileSync(idxPath, 'utf8')); } catch(_) {}
4617
- idx[logName] = 'log';
4618
- fs.writeFileSync(idxPath, JSON.stringify(idx), 'utf8');
4619
- } catch(_) {}
4620
- };
4621
-
4622
4634
  // Wait for server to be ready (max 10s)
4623
4635
  await new Promise((resolve, reject) => {
4624
4636
  let attempts = 0;
@@ -4635,11 +4647,11 @@ module.exports = { validateEmail, sanitizeText, validatePassword, validateUserna
4635
4647
  });
4636
4648
 
4637
4649
  sendLog(`✅ Sandbox pronta!`);
4638
- writeSandboxLog(null, false);
4650
+ writeSandboxLog(sandboxDir, freePort, null, false);
4639
4651
 
4640
4652
  sendReady(freePort, sandboxDir);
4641
4653
  } catch (e) {
4642
- writeSandboxLog('❌ ERRORE: ' + e.message, true);
4654
+ if (_sandboxDir) writeSandboxLog(_sandboxDir, _freePort, '❌ ERRORE: ' + e.message, true);
4643
4655
  sendError(e.message);
4644
4656
  }
4645
4657
  res.end();