neoagent 2.1.18-beta.41 → 2.1.18-beta.42

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.
@@ -35,6 +35,13 @@ function jsString(value) {
35
35
  return JSON.stringify(String(value ?? ''));
36
36
  }
37
37
 
38
+ function buildIsolatedEvaluationExpression(script) {
39
+ const source = String(script ?? 'undefined');
40
+ // Match the host browser controller: keep each arbitrary snippet inside its
41
+ // own scope so repeated browser_evaluate calls cannot collide on const/let.
42
+ return `(() => eval(${JSON.stringify(source)}))()`;
43
+ }
44
+
38
45
  function keyCodeFor(key) {
39
46
  const normalized = String(key || '').trim();
40
47
  const map = {
@@ -277,7 +284,7 @@ export function createBrowserProtocol(chromeApi) {
277
284
  return evalJs(expression);
278
285
  }
279
286
  case COMMANDS.EVALUATE: {
280
- const value = await evalJs(String(payload.script || 'undefined'));
287
+ const value = await evalJs(buildIsolatedEvaluationExpression(payload.script));
281
288
  return { result: typeof value === 'object' ? JSON.stringify(value) : String(value) };
282
289
  }
283
290
  case COMMANDS.SCREENSHOT:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neoagent",
3
- "version": "2.1.18-beta.41",
3
+ "version": "2.1.18-beta.42",
4
4
  "description": "Proactive personal AI agent with no limits",
5
5
  "license": "MIT",
6
6
  "main": "server/index.js",
@@ -37,6 +37,6 @@ _flutter.buildConfig = {"engineRevision":"425cfb54d01a9472b3e81d9e76fd63a4a44cfb
37
37
 
38
38
  _flutter.loader.load({
39
39
  serviceWorkerSettings: {
40
- serviceWorkerVersion: "3254712906" /* Flutter's service worker is deprecated and will be removed in a future Flutter release. */
40
+ serviceWorkerVersion: "2927259959" /* Flutter's service worker is deprecated and will be removed in a future Flutter release. */
41
41
  }
42
42
  });
@@ -61,6 +61,13 @@ function sleep(ms) {
61
61
  return new Promise(r => setTimeout(r, ms));
62
62
  }
63
63
 
64
+ function buildIsolatedEvaluationExpression(script) {
65
+ const source = String(script || 'undefined');
66
+ // Evaluate each snippet inside a fresh function scope so repeated calls do not
67
+ // leak top-level const/let bindings into later browser_evaluate steps.
68
+ return `(() => eval(${JSON.stringify(source)}))()`;
69
+ }
70
+
64
71
  class BrowserController {
65
72
  constructor(options = {}) {
66
73
  this.io = options.io || null;
@@ -501,7 +508,7 @@ class BrowserController {
501
508
  async evaluate(script) {
502
509
  const page = await this.ensurePage();
503
510
  try {
504
- const result = await page.evaluate(script);
511
+ const result = await page.evaluate(buildIsolatedEvaluationExpression(script));
505
512
  return { result: typeof result === 'object' ? JSON.stringify(result) : String(result) };
506
513
  } catch (err) {
507
514
  return { error: err.message };
@@ -558,4 +565,4 @@ class BrowserController {
558
565
  }
559
566
  }
560
567
 
561
- module.exports = { BrowserController, resolveBrowserExecutablePath };
568
+ module.exports = { BrowserController, resolveBrowserExecutablePath, buildIsolatedEvaluationExpression };