nothumanallowed 13.5.73 → 13.5.75
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/commands/ui.mjs +18 -6
- package/src/services/web-ui.mjs +54 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nothumanallowed",
|
|
3
|
-
"version": "13.5.
|
|
3
|
+
"version": "13.5.75",
|
|
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/commands/ui.mjs
CHANGED
|
@@ -4278,10 +4278,11 @@ module.exports = { get, set, del, exists };
|
|
|
4278
4278
|
fs.mkdirSync(path.join(sandboxDir, 'server', 'services'), { recursive: true });
|
|
4279
4279
|
fs.writeFileSync(path.join(sandboxDir, 'server', 'services', 'cache.js'), cacheShim, 'utf8');
|
|
4280
4280
|
|
|
4281
|
-
// Errors middleware shim —
|
|
4281
|
+
// Errors middleware shim — always overwrite to ensure complete exports
|
|
4282
4282
|
const errorsShim = `
|
|
4283
4283
|
// NHA WebCraft Sandbox — middleware/errors shim
|
|
4284
4284
|
class AppError extends Error { constructor(message, statusCode) { super(message); this.statusCode = statusCode || 500; this.isOperational = true; } }
|
|
4285
|
+
function notFoundHandler(req, res, next) { res.status(404).json({ error: 'Not found: ' + req.originalUrl }); }
|
|
4285
4286
|
function errorHandler(err, req, res, next) {
|
|
4286
4287
|
var code = err.statusCode || err.status || 500;
|
|
4287
4288
|
var msg = (process.env.NODE_ENV !== 'production' || err.isOperational) ? err.message : 'Internal Server Error';
|
|
@@ -4290,11 +4291,11 @@ function errorHandler(err, req, res, next) {
|
|
|
4290
4291
|
module.exports = errorHandler;
|
|
4291
4292
|
module.exports.AppError = AppError;
|
|
4292
4293
|
module.exports.errorHandler = errorHandler;
|
|
4294
|
+
module.exports.notFoundHandler = notFoundHandler;
|
|
4293
4295
|
`;
|
|
4294
4296
|
fs.mkdirSync(path.join(sandboxDir, 'server', 'middleware'), { recursive: true });
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
}
|
|
4297
|
+
// Always overwrite — older shim versions may be missing exports like notFoundHandler
|
|
4298
|
+
fs.writeFileSync(path.join(sandboxDir, 'server', 'middleware', 'errors.js'), errorsShim, 'utf8');
|
|
4298
4299
|
|
|
4299
4300
|
// Models shim — LLM often generates require('../models/User') etc. that don't exist
|
|
4300
4301
|
// Create a generic User model shim backed by the in-memory DB shim
|
|
@@ -4528,21 +4529,32 @@ module.exports = { validateEmail, sanitizeText, validatePassword, validateUserna
|
|
|
4528
4529
|
global._wcSandboxDir = sandboxDir;
|
|
4529
4530
|
|
|
4530
4531
|
let _lastMissingModule = null;
|
|
4532
|
+
let _lastCrashError = null;
|
|
4531
4533
|
proc.stdout.on('data', d => { const l = d.toString().trim(); if (l) sendLog(' [server] ' + l); });
|
|
4532
4534
|
proc.stderr.on('data', d => {
|
|
4533
4535
|
const raw = d.toString();
|
|
4534
|
-
//
|
|
4536
|
+
// MODULE_NOT_FOUND
|
|
4535
4537
|
const modMatch = raw.match(/Cannot find module '([^']+)'/);
|
|
4536
4538
|
if (modMatch) {
|
|
4537
4539
|
const missingMod = modMatch[1];
|
|
4538
4540
|
_lastMissingModule = missingMod;
|
|
4541
|
+
_lastCrashError = "Cannot find module '" + missingMod + "'";
|
|
4539
4542
|
sendLog(' ❌ Modulo mancante: ' + missingMod);
|
|
4540
|
-
// Store error for auto-fix agent — will be picked up by frontend
|
|
4541
4543
|
if (!global._wcAutoFixQueue) global._wcAutoFixQueue = [];
|
|
4542
4544
|
global._wcAutoFixQueue.push({ type: 'module_not_found', module: missingMod, dir: sandboxDir, ts: Date.now() });
|
|
4543
4545
|
sendLog(' 🤖 Avvio auto-fix...');
|
|
4544
4546
|
return;
|
|
4545
4547
|
}
|
|
4548
|
+
// TypeError / SyntaxError / ReferenceError — capture for autofix
|
|
4549
|
+
const crashMatch = raw.match(/^(TypeError|SyntaxError|ReferenceError|Error):\s+(.+)/m);
|
|
4550
|
+
if (crashMatch) {
|
|
4551
|
+
_lastCrashError = crashMatch[1] + ': ' + crashMatch[2].trim();
|
|
4552
|
+
sendLog(' ❌ ' + _lastCrashError);
|
|
4553
|
+
if (!global._wcAutoFixQueue) global._wcAutoFixQueue = [];
|
|
4554
|
+
global._wcAutoFixQueue.push({ type: 'crash_error', error: _lastCrashError, dir: sandboxDir, ts: Date.now() });
|
|
4555
|
+
sendLog(' 🤖 Avvio auto-fix...');
|
|
4556
|
+
return;
|
|
4557
|
+
}
|
|
4546
4558
|
// Skip node internals noise
|
|
4547
4559
|
const l = raw.trim();
|
|
4548
4560
|
if (!l || l.startsWith('at ') || l.startsWith('(node:') || l === '^') return;
|
package/src/services/web-ui.mjs
CHANGED
|
@@ -7353,6 +7353,9 @@ function wcStartAutoFixPoller() {
|
|
|
7353
7353
|
if (item.type === 'module_not_found' && _wcAutoFixAttempts < 3) {
|
|
7354
7354
|
_wcAutoFixAttempts++;
|
|
7355
7355
|
wcTriggerAutoFix(item.module);
|
|
7356
|
+
} else if (item.type === 'crash_error' && _wcAutoFixAttempts < 3) {
|
|
7357
|
+
_wcAutoFixAttempts++;
|
|
7358
|
+
wcTriggerCrashFix(item.error);
|
|
7356
7359
|
}
|
|
7357
7360
|
});
|
|
7358
7361
|
}).catch(function(){});
|
|
@@ -7409,6 +7412,53 @@ async function wcTriggerAutoFix(missingModule) {
|
|
|
7409
7412
|
renderWebCraft(document.getElementById('content'));
|
|
7410
7413
|
wcScrollChatToBottom();
|
|
7411
7414
|
}
|
|
7415
|
+
async function wcTriggerCrashFix(errorMsg) {
|
|
7416
|
+
if (wcChatRunning) return;
|
|
7417
|
+
var fixMsg = 'AUTO-FIX: ' + errorMsg + String.fromCharCode(10) + 'Il server Express ha crashato con questo errore. Analizza tutti i file del progetto, individua la causa e correggi il codice. Modifica i file necessari usando i tool disponibili.';
|
|
7418
|
+
wcChat.push({ role: 'user', text: '\uD83E\uDD16 Auto-fix crash: ' + errorMsg });
|
|
7419
|
+
wcChatRunning = true;
|
|
7420
|
+
renderWebCraft(document.getElementById('content'));
|
|
7421
|
+
wcScrollChatToBottom();
|
|
7422
|
+
|
|
7423
|
+
try {
|
|
7424
|
+
var r = await fetch(API + '/api/studio/webcraft/agent', {
|
|
7425
|
+
method: 'POST',
|
|
7426
|
+
headers: { 'Content-Type': 'application/json' },
|
|
7427
|
+
body: JSON.stringify({ projectName: wcState.projectName, message: fixMsg, autofix: true })
|
|
7428
|
+
});
|
|
7429
|
+
if (!r.ok) { wcChatRunning = false; renderWebCraft(document.getElementById('content')); return; }
|
|
7430
|
+
|
|
7431
|
+
var agentMsg = { role: 'agent', text: '', tools: [] };
|
|
7432
|
+
wcChat.push(agentMsg);
|
|
7433
|
+
var reader4 = r.body.getReader();
|
|
7434
|
+
var dec4 = new TextDecoder();
|
|
7435
|
+
var buf4 = '';
|
|
7436
|
+
while (true) {
|
|
7437
|
+
var res4 = await reader4.read();
|
|
7438
|
+
if (res4.done) break;
|
|
7439
|
+
buf4 += dec4.decode(res4.value, { stream: true });
|
|
7440
|
+
var parts4 = buf4.split(String.fromCharCode(10)+String.fromCharCode(10));
|
|
7441
|
+
buf4 = parts4.pop();
|
|
7442
|
+
for (var pi4 = 0; pi4 < parts4.length; pi4++) {
|
|
7443
|
+
var line4 = parts4[pi4].replace(/^data: /, '').trim();
|
|
7444
|
+
if (!line4) continue;
|
|
7445
|
+
try {
|
|
7446
|
+
var ev4 = JSON.parse(line4);
|
|
7447
|
+
if (ev4.type === 'text') { agentMsg.text += ev4.token; }
|
|
7448
|
+
else if (ev4.type === 'tool') { agentMsg.tools.push({ op: ev4.op, path: ev4.path, result: ev4.result, oldSnippet: ev4.oldSnippet || '', newSnippet: ev4.newSnippet || '' }); }
|
|
7449
|
+
else if (ev4.type === 'done') { wcChatRunning = false; if (ev4.changed) { wcReloadProjectFiles(); } }
|
|
7450
|
+
else if (ev4.type === 'restart_sandbox') { wcStartSandbox(); }
|
|
7451
|
+
else if (ev4.type === 'error') { agentMsg.text += String.fromCharCode(10)+'Errore: '+ev4.msg; wcChatRunning = false; }
|
|
7452
|
+
} catch(_) {}
|
|
7453
|
+
}
|
|
7454
|
+
}
|
|
7455
|
+
} catch(_) {}
|
|
7456
|
+
|
|
7457
|
+
wcChatRunning = false;
|
|
7458
|
+
renderWebCraft(document.getElementById('content'));
|
|
7459
|
+
wcScrollChatToBottom();
|
|
7460
|
+
}
|
|
7461
|
+
|
|
7412
7462
|
var _wcPhaseKeys = ['files','shims','pkg','env','deps','install','start'];
|
|
7413
7463
|
function wcTogglePhase(idx) { var k = _wcPhaseKeys[idx]; if (k) { wcSandboxExpanded[k] = !wcSandboxExpanded[k]; renderWebCraft(document.getElementById('content')); } }
|
|
7414
7464
|
|
|
@@ -7822,7 +7872,9 @@ async function wcGenerate() {
|
|
|
7822
7872
|
renderWebCraft(document.getElementById('content'));
|
|
7823
7873
|
} catch(e) {
|
|
7824
7874
|
if (e && e.name === 'AbortError') break;
|
|
7825
|
-
wcState.generatedFiles.push({ name: fp.name, content: '// Error generating this file: ' + e.message, lang: fp.lang });
|
|
7875
|
+
wcState.generatedFiles.push({ name: fp.name, content: '// Error generating this file: ' + (e.message || 'unknown error'), lang: fp.lang });
|
|
7876
|
+
if (fi === 0) wcState.activeFile = 0;
|
|
7877
|
+
renderWebCraft(document.getElementById('content'));
|
|
7826
7878
|
}
|
|
7827
7879
|
}
|
|
7828
7880
|
|
|
@@ -7886,7 +7938,7 @@ function wcSandboxPanelHtml() {
|
|
|
7886
7938
|
'<div style="display:flex;gap:8px;align-items:flex-start"><span style="color:var(--green);flex-shrink:0">3.</span><span>Il server Express parte su una porta locale casuale</span></div>' +
|
|
7887
7939
|
'<div style="display:flex;gap:8px;align-items:flex-start"><span style="color:var(--green);flex-shrink:0">4.</span><span>DB in-memory (no PostgreSQL richiesto) — i dati si azzerano al riavvio</span></div>' +
|
|
7888
7940
|
'</div>' +
|
|
7889
|
-
'<div style="margin-top:12px;padding:8px 10px;background:var(--amberdim);border:1px solid var(--amber3);border-radius:6px;font-size:10px;color:var(--amber)">⚠ Solo locale — nessun dato esce dal tuo
|
|
7941
|
+
'<div style="margin-top:12px;padding:8px 10px;background:var(--amberdim);border:1px solid var(--amber3);border-radius:6px;font-size:10px;color:var(--amber)">⚠ Solo locale — nessun dato esce dal tuo dispositivo</div>' +
|
|
7890
7942
|
'</div>' +
|
|
7891
7943
|
'</div>';
|
|
7892
7944
|
}
|