nothumanallowed 16.0.39 → 16.0.40
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/webcraft.mjs +50 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nothumanallowed",
|
|
3
|
-
"version": "16.0.
|
|
3
|
+
"version": "16.0.40",
|
|
4
4
|
"description": "Local AI assistant: 80 tools (Gmail, Calendar, Drive, GitHub, Slack, browser, code, files), 38 agents, visual workflows (Studio, AWF, WebCraft). Install with `npm i -g nothumanallowed`, run with `nha ui`. Free tier built-in (Liara), no API key required. Your data stays on your PC — OAuth tokens local, no cloud. Open-source MIT.",
|
|
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 = '16.0.
|
|
8
|
+
export const VERSION = '16.0.40';
|
|
9
9
|
export const BASE_URL = 'https://nothumanallowed.com/cli';
|
|
10
10
|
export const API_BASE = 'https://nothumanallowed.com/api/v1';
|
|
11
11
|
|
|
@@ -4198,6 +4198,56 @@ function _patchEntry(projectDir, entryFile, shimDir, port) {
|
|
|
4198
4198
|
` } catch(e) {}`,
|
|
4199
4199
|
` return _origEnd.apply(this, arguments);`,
|
|
4200
4200
|
`};`,
|
|
4201
|
+
`// Monkey-patch Express to neutralize next(falsy) — common LLM bug where`,
|
|
4202
|
+
`// middleware calls next(err) with err === undefined for EVERY request,`,
|
|
4203
|
+
`// causing 500 on all routes including static files. Express treats any`,
|
|
4204
|
+
`// truthy first arg as an error; if it's falsy (null/undefined/0/''),`,
|
|
4205
|
+
`// it's semantically equivalent to next() per Express docs. We rewrite.`,
|
|
4206
|
+
`(function() {`,
|
|
4207
|
+
` const Module = require('module');`,
|
|
4208
|
+
` const _origLoad = Module._load;`,
|
|
4209
|
+
` function wrapMiddleware(fn) {`,
|
|
4210
|
+
` if (typeof fn !== 'function' || fn.length !== 3) return fn;`,
|
|
4211
|
+
` const wrapped = function(req, res, next) {`,
|
|
4212
|
+
` const safeNext = function(err) {`,
|
|
4213
|
+
` if (err === undefined || err === null || err === false || err === 0) return next();`,
|
|
4214
|
+
` return next(err);`,
|
|
4215
|
+
` };`,
|
|
4216
|
+
` try { return fn.call(this, req, res, safeNext); }`,
|
|
4217
|
+
` catch (e) { return next(e); }`,
|
|
4218
|
+
` };`,
|
|
4219
|
+
` wrapped._nhaWrapped = true;`,
|
|
4220
|
+
` return wrapped;`,
|
|
4221
|
+
` }`,
|
|
4222
|
+
` function patchExpressApp(express) {`,
|
|
4223
|
+
` if (!express || express._nhaPatched) return express;`,
|
|
4224
|
+
` try {`,
|
|
4225
|
+
` // express() returns an app; patch app.use to wrap middleware`,
|
|
4226
|
+
` const _origExpress = express;`,
|
|
4227
|
+
` const factory = function(...args) {`,
|
|
4228
|
+
` const app = _origExpress.apply(this, args);`,
|
|
4229
|
+
` if (app && typeof app.use === 'function' && !app._nhaUseWrapped) {`,
|
|
4230
|
+
` const _origUse = app.use;`,
|
|
4231
|
+
` app.use = function(...uArgs) {`,
|
|
4232
|
+
` const mapped = uArgs.map(a => (typeof a === 'function' && a.length === 3 && !a._nhaWrapped) ? wrapMiddleware(a) : a);`,
|
|
4233
|
+
` return _origUse.apply(this, mapped);`,
|
|
4234
|
+
` };`,
|
|
4235
|
+
` app._nhaUseWrapped = true;`,
|
|
4236
|
+
` }`,
|
|
4237
|
+
` return app;`,
|
|
4238
|
+
` };`,
|
|
4239
|
+
` // Preserve static props: Router, json(), urlencoded(), etc.`,
|
|
4240
|
+
` Object.assign(factory, _origExpress);`,
|
|
4241
|
+
` factory._nhaPatched = true;`,
|
|
4242
|
+
` return factory;`,
|
|
4243
|
+
` } catch { return express; }`,
|
|
4244
|
+
` }`,
|
|
4245
|
+
` Module._load = function(name, parent, isMain) {`,
|
|
4246
|
+
` const result = _origLoad.call(this, name, parent, isMain);`,
|
|
4247
|
+
` if (name === 'express') return patchExpressApp(result);`,
|
|
4248
|
+
` return result;`,
|
|
4249
|
+
` };`,
|
|
4250
|
+
`})();`,
|
|
4201
4251
|
`// Strip headers that break sandbox iframe preview:`,
|
|
4202
4252
|
`// - X-Frame-Options: blocks iframe embedding entirely`,
|
|
4203
4253
|
`// - X-Content-Type-Options: nosniff: when LLM references /js/*.js files`,
|