feat: add passive website reverse engineering

This commit is contained in:
N0zoM1z0
2026-07-14 12:27:13 +08:00
parent a699fdd6a5
commit 2c1ceabbf1
71 changed files with 5279 additions and 80 deletions
+92
View File
@@ -0,0 +1,92 @@
import type { ToolContract } from "./toolContracts.js";
import { evidenceSchema } from "../domain/evidence.js";
import {
browserTargetListSchema,
inspectWebPageInputSchema,
listBrowserTargetsInputSchema,
webPageInspectionSchema,
} from "../domain/browserObservation.js";
const evidenceResult = (schema: typeof browserTargetListSchema) =>
evidenceSchema
.omit({ normalized_result: true })
.extend({ normalized_result: schema });
const listOutputSchema = evidenceResult(browserTargetListSchema);
const inspectionOutputSchema = evidenceSchema
.omit({ normalized_result: true })
.extend({ normalized_result: webPageInspectionSchema });
const endpoint = "http://127.0.0.1:9222";
const origin = "https://app.example.test";
/** Origin-scoped, passive browser reverse-engineering contracts. */
export const BROWSER_TOOL_CONTRACTS = [
{
name: "list_browser_targets",
description:
"List bounded page targets from an approved user-owned loopback Chrome DevTools Protocol endpoint. Only targets whose current URL matches an approved exact origin are returned; URL credentials, query values, and fragments are redacted.",
kind: "browser-provider",
inputSchema: listBrowserTargetsInputSchema,
outputSchema: listOutputSchema,
annotations: {
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
openWorldHint: true,
},
examples: [
{
title: "List approved browser page targets",
input: {
cdp_endpoint: endpoint,
allowed_origins: [origin],
approved: true,
offset: 0,
limit: 100,
},
},
],
},
{
name: "inspect_web_page",
description:
"Passively inspect one approved page target through CDP without evaluating JavaScript, navigating, clicking, closing, or mutating the page. Returns bounded DOM structure, accessibility, scripts, resources, attach-window network and console metadata, workers, and redacted storage inventory as Evidence v2.",
kind: "browser-provider",
inputSchema: inspectWebPageInputSchema,
outputSchema: inspectionOutputSchema,
annotations: {
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
openWorldHint: true,
},
examples: [
{
title: "Inspect one approved browser page",
input: {
cdp_endpoint: endpoint,
allowed_origins: [origin],
approved: true,
target_id: "TARGET_ID_FROM_LIST_BROWSER_TARGETS",
observation_ms: 500,
include_script_sources: false,
include_storage_keys: false,
limits: {
max_frames: 200,
max_dom_nodes: 2_000,
max_ax_nodes: 2_000,
max_scripts: 200,
max_resources: 2_000,
max_workers: 500,
max_storage_keys: 1_000,
max_script_source_bytes: 1_048_576,
max_total_script_source_bytes: 4_194_304,
max_network_events: 1_000,
max_console_events: 200,
max_websocket_events: 500,
},
},
},
],
},
] as const satisfies readonly ToolContract[];
+2
View File
@@ -36,6 +36,7 @@ const scopeSchema = z
roots: z.array(z.string()),
executables: z.array(z.string()),
environment_names: z.array(z.string()),
origins: z.array(z.string()).optional(),
network: z.enum(["none", "loopback", "external"]),
mount: z.boolean(),
})
@@ -45,6 +46,7 @@ const missingScopeSchema = z
roots: z.array(z.string()).optional(),
executables: z.array(z.string()).optional(),
environment_names: z.array(z.string()).optional(),
origins: z.array(z.string()).optional(),
network: z.enum(["none", "loopback", "external"]).optional(),
mount: z.literal(true).optional(),
})
+1
View File
@@ -22,6 +22,7 @@ export type ToolKind =
| "enhanced"
| "native-provider"
| "artifact-provider"
| "browser-provider"
| "session";
/** Single source of truth for a public MCP tool. */
+3 -5
View File
@@ -26,6 +26,7 @@ import {
import { TOOL_EXAMPLE_OVERRIDES } from "./toolContractExamples.js";
import { NATIVE_TOOL_CONTRACTS } from "./nativeToolContracts.js";
import { ARTIFACT_TOOL_CONTRACTS } from "./artifactToolContracts.js";
import { BROWSER_TOOL_CONTRACTS } from "./browserToolContracts.js";
import {
closeBinaryInputSchema,
openBinaryInputSchema,
@@ -512,15 +513,12 @@ export const SESSION_TOOL_CONTRACTS = [
),
] as const satisfies readonly ToolContract[];
/**
* Complete ordered public inventory used by registration and verification.
* Keep this collection at 68 tools unless a deliberate contract change updates
* snapshots, package verification, and real-Hopper verification together.
*/
/** Complete ordered public inventory used by registration and verification. */
export const TOOL_CONTRACTS = [
...OFFICIAL_TOOL_CONTRACTS,
...ENHANCED_TOOL_CONTRACTS,
...NATIVE_TOOL_CONTRACTS,
...ARTIFACT_TOOL_CONTRACTS,
...BROWSER_TOOL_CONTRACTS,
...SESSION_TOOL_CONTRACTS,
] as const;