From 9b49d92cb8871ec4b2f5862f7088ba892e556b19 Mon Sep 17 00:00:00 2001 From: bendtherules Date: Mon, 27 Apr 2026 16:41:07 +0530 Subject: [PATCH] fix(evaluate): use engine262 inspect() for console output Replace naive manual .stringValue()/.value fallback with engine262's inspect() function so console.log outputs readable strings instead of raw engine262 internal objects. Closes #5 --- src/agent-tools/evaluateInEngine262.runner.mjs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/agent-tools/evaluateInEngine262.runner.mjs b/src/agent-tools/evaluateInEngine262.runner.mjs index 1087ca1..f1a6918 100644 --- a/src/agent-tools/evaluateInEngine262.runner.mjs +++ b/src/agent-tools/evaluateInEngine262.runner.mjs @@ -25,6 +25,7 @@ process.stdin.on("end", async () => { const Value = engine.Value; const skipDebugger = engine.skipDebugger; const ask262Debug = engine.ask262Debug; + const inspect = engine.inspect; // Reset state ask262Debug.reset(); @@ -87,19 +88,8 @@ process.stdin.on("end", async () => { for (const method of consoleMethods) { const fn = CreateBuiltinFunction( (args) => { - const jsValues = args.map((arg) => { - if (arg && typeof arg === "object") { - const strVal = arg.stringValue; - if (typeof strVal === "function") { - return strVal.call(arg); - } - const value = arg.value; - if (value !== undefined) { - return value; - } - } - return arg; - }); + // Use engine262's inspect() to convert Values to readable JS strings + const jsValues = args.map((arg) => inspect(arg)); consoleOutput.push({ method, values: jsValues }); return Value("undefined"); },