Files
reverse-engineering-anything/src/contracts/javascript/javascriptRuntimeObservationToolContracts.ts
T
morluto 717333ce9b refactor(contracts): declare each tool's effect audit on its contract (#11305)
* refactor(contracts): declare each tool's effect audit on its contract

Every public tool's effects lived in a 255-entry TOOL_EFFECT_AUDIT table in
toolEffects.ts, keyed by name and looked up again by toolContractMetadata,
the capability inventory (toolSessionEffects) and tests (TOOL_EFFECTS).

toolContractMetadata(name, audit) now takes the audit from the contract
declaration, and the contract carries both the provider-wide effects and
the session effects. The inventory reads contract.sessionEffects. The
table, TOOL_EFFECTS and toolSessionEffects are removed; toolEffects.ts
keeps the effect type, the shared presets and annotation derivation.

Effects, session effects, annotations and titles are byte-identical for all
255 contracts.

* test(contracts): read focused effect expectations from their contract family
2026-11-16 03:50:32 +08:00

62 lines
2.6 KiB
TypeScript

import type { ToolContract } from "../toolContractTypes.js";
import {
toolContractMetadata,
browserEvidenceEffects,
} from "../toolEffects.js";
import { evidenceResultOf } from "../toolOutputSchemaPrimitives.js";
import {
javascriptRuntimeObservationSchema,
javascriptRuntimeTargetListSchema,
listJavaScriptRuntimeTargetsInputSchema,
observeJavaScriptRuntimeInputSchema,
} from "../../domain/javascript/javascriptRuntimeObservation.js";
const endpoint = "http://127.0.0.1:9229";
/** Passive Node/Electron V8 Inspector discovery and observation contracts. */
export const JAVASCRIPT_RUNTIME_OBSERVATION_TOOL_CONTRACTS = [
{
name: "list_javascript_runtime_targets",
cli: true,
...toolContractMetadata(
"list_javascript_runtime_targets",
browserEvidenceEffects,
),
description:
"List every eligible Node/Electron V8 Inspector target from an explicit literal-loopback endpoint. Node discovery file locations that cannot be verified are preserved as unresolved reported URLs; they do not prove filesystem identity. Listing does not attach to targets.",
kind: "runtime-provider",
inputSchema: listJavaScriptRuntimeTargetsInputSchema,
outputSchema: evidenceResultOf(javascriptRuntimeTargetListSchema),
examples: [
{
title: "List Node Inspector targets",
input: {
inspector_endpoint: endpoint,
},
},
],
},
{
name: "observe_javascript_runtime",
cli: true,
...toolContractMetadata(
"observe_javascript_runtime",
browserEvidenceEffects,
),
description:
"Passively observe loaded-script and execution-context metadata on one loopback Node/Electron V8 Inspector target, selected by inspector_endpoint and target_id. Presence/attachability and file locations are rechecked; verified file paths stay separate from reported URLs, including distinct query/fragment identities. Parse failures are counted separately from malformed events. REA does not read source, evaluate, pause/resume or instrument execution; imports, EventEmitter activity and Electron IPC remain unknown. Use reconcile_javascript_runtime with static application Evidence. The selected endpoint exposes every target it serves to this tool.",
kind: "runtime-provider",
inputSchema: observeJavaScriptRuntimeInputSchema,
outputSchema: evidenceResultOf(javascriptRuntimeObservationSchema),
examples: [
{
title: "Observe one Node runtime",
input: {
inspector_endpoint: endpoint,
target_id: "TARGET_ID_FROM_LIST_JAVASCRIPT_RUNTIME_TARGETS",
},
},
],
},
] as const satisfies readonly ToolContract[];