mirror of
https://github.com/morluto/rea.git
synced 2026-11-14 18:52:48 +00:00
fix(cli): report observe-web-session progress on stderr
MCP passes progress to observeWebSession, but the CLI did not, so a caller of `rea observe-web-session` never saw the armed observation window it must wait for before acting. Three CLI commands also each wrote their own copy of the same stderr progress line. One cliProgress module now owns the stderr progress line and reporter. observe-web-session uses it, as do web runtime, JavaScript application and desktop capture progress. The CDP session also stops reporting readiness once collection is no longer active, so a stopped capture does not invite the external action. Fixes #8141 Supersedes #8149 Based on #8149; the desktop capture copy now shares the line writer too. Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
This commit is contained in:
1 parent
fee267759d
commit
3e95d22dd4
8 files changed
+294
-21
No files matched your search
@@ -42,6 +42,7 @@ import {
|
||||
} from "../cliObservationOptions.js";
|
||||
import { withCommandCancellation } from "./commandCancellation.js";
|
||||
import { finishAnalysisCommand } from "./finishAnalysisCommand.js";
|
||||
import { cliProgressReporter } from "./cliProgress.js";
|
||||
|
||||
/** Register CLI equivalents of the passive browser MCP tools. */
|
||||
export const registerBrowserCommands = (
|
||||
@@ -318,7 +319,12 @@ const registerObservationSession = (
|
||||
),
|
||||
);
|
||||
return await finishAnalysisCommand(
|
||||
() => observeWebSession(provider, parsed.data, { signal }),
|
||||
() =>
|
||||
observeWebSession(provider, parsed.data, {
|
||||
signal,
|
||||
// Report the armed observation on stderr, as MCP does.
|
||||
progress: cliProgressReporter,
|
||||
}),
|
||||
{
|
||||
close: async () => {
|
||||
await provider.close?.();
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import type { ProgressReporter } from "../application/ProgressReporter.js";
|
||||
|
||||
/** Write one progress update as a stderr line, keeping stdout results parseable. */
|
||||
export const writeCliProgressLine = (update: unknown): void => {
|
||||
process.stderr.write(`${JSON.stringify({ rea_progress: update })}\n`);
|
||||
};
|
||||
|
||||
/** CLI counterpart of MCP progress notifications: each update is one stderr line. */
|
||||
export const cliProgressReporter: ProgressReporter = {
|
||||
report: async (update) => {
|
||||
writeCliProgressLine(update);
|
||||
},
|
||||
};
|
||||
@@ -29,6 +29,7 @@ import {
|
||||
import { SessionRequestQueue } from "../desktop/DesktopSessionRequests.js";
|
||||
import { withCommandCancellation } from "./commandCancellation.js";
|
||||
import type { CliInstance } from "./types.js";
|
||||
import { writeCliProgressLine } from "./cliProgress.js";
|
||||
|
||||
/** One coherent view policy; invalid JSON and unknown controls fail at admission. */
|
||||
const viewPolicyOption = z
|
||||
@@ -562,7 +563,7 @@ export const registerDesktopCaptureCommands = (
|
||||
...(event === undefined ? {} : { event }),
|
||||
},
|
||||
};
|
||||
process.stderr.write(`${JSON.stringify(progress)}\n`);
|
||||
writeCliProgressLine(progress.rea_progress);
|
||||
},
|
||||
},
|
||||
signal,
|
||||
|
||||
@@ -12,6 +12,7 @@ import { ProviderCleanupError } from "../domain/providerCleanupError.js";
|
||||
import { analysisInputErrorFromIssues } from "../domain/inputIssueProjection.js";
|
||||
import { javaScriptSourcePathsSchema } from "../domain/javascript/javascriptSourceSelection.js";
|
||||
import { parseCliJsonInput } from "../cliJsonInput.js";
|
||||
import { writeCliProgressLine } from "./cliProgress.js";
|
||||
import { ownCliProcessResource } from "./cliResources.js";
|
||||
|
||||
const OPERATION = "analyze_javascript_application";
|
||||
@@ -115,7 +116,7 @@ export const runCliJavaScriptApplicationAnalysis = async (
|
||||
await import("../application/javascript/JavaScriptApplicationService.js");
|
||||
const progress = createProgressReporter(
|
||||
async (update) => {
|
||||
process.stderr.write(`${JSON.stringify({ rea_progress: update })}\n`);
|
||||
writeCliProgressLine(update);
|
||||
},
|
||||
{ minimumIntervalMs: 0 },
|
||||
);
|
||||
|
||||
@@ -12,16 +12,9 @@ import { logCliCommand } from "../cliLogging.js";
|
||||
import { CLI_COMMANDS } from "../cliCommandNames.js";
|
||||
import { cliDecimalField } from "./options.js";
|
||||
import type { Logger } from "pino";
|
||||
import type { ProgressReporter } from "../application/ProgressReporter.js";
|
||||
import { withCommandCancellation } from "./commandCancellation.js";
|
||||
import { finishAnalysisCommand } from "./finishAnalysisCommand.js";
|
||||
|
||||
/** CLI progress exposes the actual armed point on stderr without corrupting JSON results. */
|
||||
const runtimeProgress: ProgressReporter = {
|
||||
report: async (update) => {
|
||||
process.stderr.write(`${JSON.stringify({ rea_progress: update })}\n`);
|
||||
},
|
||||
};
|
||||
import { cliProgressReporter } from "./cliProgress.js";
|
||||
|
||||
/** Register public equivalents of the two modular website runtime tools. */
|
||||
export const registerWebRuntimeCommands = (
|
||||
@@ -59,7 +52,7 @@ export const registerWebRuntimeCommands = (
|
||||
observation_ms: options.observationMs,
|
||||
...selectedCommandTimeout(options.commandTimeoutMs),
|
||||
},
|
||||
{ progress: runtimeProgress, signal },
|
||||
{ progress: cliProgressReporter, signal },
|
||||
),
|
||||
{
|
||||
close: async () => {
|
||||
|
||||
Reference in new issue
Block a user