mirror of
https://github.com/morluto/rea.git
synced 2026-12-03 21:46:01 +00:00
observe_web_execution returned complete script sources inline. On a local page loading rxjs, openpgp and isomorphic-git in Chromium 156, the complete observation was 1,888,024 bytes of structured content, nearly all source text. observe_web_execution now takes detail and joins the agent result budget. Omitted, an observation that fits delivery.agent_result_budget_bytes is inline and a larger one is retained behind its summary, which pages through the web-execution view. On that page the default reply was 7,458 bytes. detail summary retains the observation through the shared retained summary binding. rea observe-web-execution uses the shared CLI Evidence delivery. The real-browser verifiers request the complete observation they assert on. BREAKING CHANGE: an observe_web_execution call that omits detail on an observation above the agent result budget now returns the retained summary. Pass detail: "complete" (--detail complete) for the previous shape. Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
118 lines
3.8 KiB
TypeScript
118 lines
3.8 KiB
TypeScript
import type { CliInstance } from "./types.js";
|
|
import type { Logger } from "pino";
|
|
|
|
import type { WebRuntimeService } from "../application/WebRuntimeService.js";
|
|
import type { ExecutionOptions } from "../ports/AnalysisProvider.js";
|
|
import { createWebRuntimeService } from "../composition/webRuntime.js";
|
|
import { WEB_RUNTIME_TOOL_CONTRACTS } from "../contracts/webRuntimeToolContracts.js";
|
|
import type { AnalysisError } from "../domain/analysisErrorBase.js";
|
|
import type { Evidence } from "../domain/evidence.js";
|
|
import type { Result } from "../domain/result.js";
|
|
import { browserTargetProjection } from "./browserContractCommands.js";
|
|
import { deliverCliAnalysisEvidence } from "./analysisEvidenceDelivery.js";
|
|
import { cliProgressReporter } from "./cliProgress.js";
|
|
import { contractNamed } from "./contractCliDescription.js";
|
|
import {
|
|
registerContractCommand,
|
|
type ContractCommandContext,
|
|
} from "./contractCommand.js";
|
|
import { finishAnalysisCommand } from "./finishAnalysisCommand.js";
|
|
import { projectCliAnalysisResult } from "./projectCliAnalysisResult.js";
|
|
|
|
const targetFields = {
|
|
...browserTargetProjection.fields,
|
|
cdp_endpoint: {
|
|
name: "endpoint",
|
|
description: "Existing loopback browser CDP endpoint",
|
|
},
|
|
target_id: {
|
|
description: "Selected page target ID from list-browser-targets",
|
|
},
|
|
} as const;
|
|
|
|
/** Register public equivalents of the two modular website runtime tools. */
|
|
export const registerWebRuntimeCommands = (
|
|
cli: CliInstance,
|
|
logger: Logger,
|
|
): void => {
|
|
registerContractCommand(
|
|
cli,
|
|
logger,
|
|
contractNamed(WEB_RUNTIME_TOOL_CONTRACTS, "observe_web_execution"),
|
|
{
|
|
description:
|
|
"Observe precise page execution; resets counters and temporarily disables optimization",
|
|
positionals: browserTargetProjection.positionals,
|
|
fields: {
|
|
...targetFields,
|
|
observation_ms: { description: "Observation duration in milliseconds" },
|
|
},
|
|
evidenceDelivery: true,
|
|
},
|
|
async (input, { operation, signal, delivery }) => {
|
|
// Delivery fields select the reply; the observation takes the rest.
|
|
const service = createWebRuntimeService();
|
|
return deliverCliAnalysisEvidence({
|
|
...delivery!,
|
|
run: () =>
|
|
service.observe(input, { signal, progress: cliProgressReporter }),
|
|
service: {
|
|
close: async () => {
|
|
await service.provider.close?.();
|
|
},
|
|
},
|
|
providerId: service.provider.identity().id,
|
|
operation,
|
|
signal,
|
|
});
|
|
},
|
|
);
|
|
registerContractCommand(
|
|
cli,
|
|
logger,
|
|
contractNamed(WEB_RUNTIME_TOOL_CONTRACTS, "inspect_web_event_listeners"),
|
|
{
|
|
description:
|
|
"Inspect native listener source locations on the first main-document CSS match",
|
|
positionals: [...browserTargetProjection.positionals, "selector"],
|
|
fields: {
|
|
...targetFields,
|
|
selector: {
|
|
description:
|
|
"Native CSS selector; inspect the first main-document match",
|
|
},
|
|
},
|
|
},
|
|
throughWebRuntime((service, input, options) =>
|
|
service.inspect(input, options),
|
|
),
|
|
);
|
|
};
|
|
|
|
/**
|
|
* Run one web runtime operation with a disposable service, whose contract
|
|
* parse admits the input, and await its provider's close.
|
|
*/
|
|
const throughWebRuntime =
|
|
(
|
|
run: (
|
|
service: WebRuntimeService,
|
|
input: unknown,
|
|
options: ExecutionOptions,
|
|
) => Promise<Result<Evidence, AnalysisError>>,
|
|
) =>
|
|
async (input: unknown, { operation, signal }: ContractCommandContext) => {
|
|
const service = createWebRuntimeService();
|
|
return finishAnalysisCommand(
|
|
() => run(service, input, { signal }),
|
|
{
|
|
close: async () => {
|
|
await service.provider.close?.();
|
|
},
|
|
},
|
|
service.provider.identity().id,
|
|
operation,
|
|
signal,
|
|
).then(projectCliAnalysisResult);
|
|
};
|