mirror of
https://github.com/morluto/rea.git
synced 2026-11-10 00:36:35 +00:00
* fix(browser): keep negative script columns Chrome reports Chrome reported a Debugger.scriptParsed event with startColumn -60 and endColumn -15 for an inline script in WordPress's helper frame. CDP declares these columns as plain integers, but REA's admission required min(0), so one script failed the whole observe-web-execution run with unreadable_output. CDP resource columns now share one representation, cdpResourceColumnSchema, for script start/end columns, initiator call frames, parser initiators and event listeners. Positions on a script's first line include its start column, so keeping the reported values keeps the documented script-relative conversion consistent. The domain contract and web runtime docs state that a negative column does not locate a column in the resource. Fixes #8674 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(browser): apply the CDP column policy to passive capture inspect_web_page and discover_webmcp_tools still read CDP columns through cdpSourceCoordinates, whose own >= 0 check turned a negative column into null and reported invalid_protocol_value. WebMCP discovery also dropped the tool's whole registration_source. cdpResourceColumnSchema now lives with the domain's CDP observation schemas. Runtime admission, the passive coordinate helper and the runtime, console, initiator and WebMCP output schemas all use it. Lines keep their non-negative rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
68 lines
2.1 KiB
TypeScript
68 lines
2.1 KiB
TypeScript
import { z } from "zod";
|
|
import { webTextArtifactSchema } from "./webContentArtifact.js";
|
|
|
|
/**
|
|
* Zero-based UTF-16 column in a resource, as CDP reports it. CDP declares
|
|
* columns as plain integers. Chrome reports a negative start column for some
|
|
* inline scripts, and positions on a script's first line include that start
|
|
* column, so a negative column is kept as reported. It does not locate a
|
|
* column in the resource.
|
|
*/
|
|
export const cdpResourceColumnSchema = z.int();
|
|
|
|
/** Structural DOM facts shared by passive web and Electron observations. */
|
|
export const cdpDomNodeSchema = z.object({
|
|
index: z.number().int().min(0),
|
|
parent_index: z.number().int().min(-1),
|
|
node_type: z.number().int().min(0),
|
|
node_name: z.string(),
|
|
node_value_length: z
|
|
.number()
|
|
.int()
|
|
.min(0)
|
|
.describe("Length in the enclosing DOM snapshot's node_value_length_unit."),
|
|
attribute_names: z.array(z.string()),
|
|
});
|
|
|
|
/** Unit applies to every retained node; historical omission remains unknown. */
|
|
export const cdpDomSnapshotSchema = z.object({
|
|
total_nodes: z.int().min(0),
|
|
node_value_length_unit: z
|
|
.enum(["utf16-code-units", "utf8-bytes"])
|
|
.describe(
|
|
"Unit for all node_value_length values; absent in historical captures means unknown.",
|
|
)
|
|
.exactOptional(),
|
|
nodes: z.array(cdpDomNodeSchema),
|
|
});
|
|
|
|
/** Captured text or an explicit reason why source is unavailable. */
|
|
export const cdpScriptSourceSchema = z.discriminatedUnion("included", [
|
|
z.object({ included: z.literal(false), reason: z.string() }),
|
|
z.object({
|
|
included: z.literal(true),
|
|
artifact: webTextArtifactSchema,
|
|
}),
|
|
]);
|
|
|
|
/** Producer script declarations; unavailable facts remain null. */
|
|
export const cdpScriptMetadataSchema = z.object({
|
|
cdp_hash: z
|
|
.string()
|
|
.nullable()
|
|
.describe("Producer-reported script hash; null when unavailable."),
|
|
length: z
|
|
.number()
|
|
.int()
|
|
.min(0)
|
|
.nullable()
|
|
.describe("Producer-reported script length; null when unavailable."),
|
|
is_module: z
|
|
.boolean()
|
|
.nullable()
|
|
.describe(
|
|
"Producer-reported module classification; null when unavailable.",
|
|
),
|
|
language: z.string().nullable(),
|
|
});
|