MCPcopy Create free account
hub / github.com/microsoft/Webwright / normalizeObservation

Function normalizeObservation

assets/compare_trajectory/app.js:326–348  ·  view source on GitHub ↗
(message)

Source from the content-addressed store, hash-verified

324}
325
326function normalizeObservation(message) {
327 const extra = message && message.extra ? message.extra : {};
328 if (extra.observation && typeof extra.observation === 'object') {
329 return {
330 output: String(extra.observation.command_output || ''),
331 exitCode: typeof extra.observation.returncode === 'number' ? extra.observation.returncode : parseExitCode(extra.observation.command_output || ''),
332 command: String(extra.observation.command || ''),
333 success: extra.observation.success
334 };
335 }
336 const text = contentToText(message.content);
337 if (!/^Observation:/i.test(text)) {
338 return null;
339 }
340 const outputMatch = text.match(/Command output:\n([\s\S]*)$/i);
341 const commandMatch = text.match(/Command:\s*([^\n]+)/i);
342 return {
343 output: outputMatch ? outputMatch[1].trim() : text,
344 exitCode: parseExitCode(text),
345 command: commandMatch ? commandMatch[1].trim() : '',
346 success: /Status:\s*ok/i.test(text)
347 };
348}
349
350function stripSessionMarkup(text) {
351 return String(text || '')

Callers 1

normalizeTrajectoryFunction · 0.85

Calls 2

parseExitCodeFunction · 0.85
contentToTextFunction · 0.85

Tested by

no test coverage detected