Preserve observed terminal-call sites and callee flags across function views, raw bridge responses, Evidence, and snapshot replay. Version analysis profiles so older unqualified results cannot be reused. Qualify Ghidra function extents without changing external no-return flags or claiming recovery of excluded code. Validation: 76 focused tests, check:fast, docs:check, formatting, and the full Ghidra 12.1.4 host lane pass. Real CLI and all five stdio MCP function views retain the terminal-call evidence; returning puts calls remain unflagged. The reported stripped Rust ELF and Windows host remain unverified. Fixes #1658
46 lines
2.2 KiB
TypeScript
46 lines
2.2 KiB
TypeScript
import { jsonObjectSchema } from "../domain/jsonValue.js";
|
|
import { enhancedInputSchemas } from "./enhancedInputs.js";
|
|
import { TOOL_EXAMPLE_OVERRIDES } from "./toolContractExamples.js";
|
|
import type { ToolContract } from "./toolContractTypes.js";
|
|
import { toolContractMetadata } from "./toolEffects.js";
|
|
import { enhancedOutputSchemas } from "./toolOutputSchemaGroups.js";
|
|
import { requireOutputSchema } from "./toolOutputSchemaPrimitives.js";
|
|
|
|
type FunctionWorkflowName = "analyze_function" | "inspect_native_api";
|
|
|
|
const functionWorkflow = <Name extends FunctionWorkflowName>(
|
|
name: Name,
|
|
description: string,
|
|
) => {
|
|
const inputSchema = enhancedInputSchemas[name];
|
|
const outputSchema = requireOutputSchema(enhancedOutputSchemas, name);
|
|
return {
|
|
name,
|
|
...toolContractMetadata(name),
|
|
description,
|
|
kind: "enhanced",
|
|
inputSchema,
|
|
outputSchema,
|
|
examples: [
|
|
{
|
|
title: `Example ${name.replaceAll("_", " ")} request`,
|
|
input: jsonObjectSchema.parse(
|
|
inputSchema.parse(TOOL_EXAMPLE_OVERRIDES[name] ?? {}),
|
|
),
|
|
},
|
|
],
|
|
} satisfies ToolContract<Name, typeof inputSchema, typeof outputSchema>;
|
|
};
|
|
|
|
/** Function dossier and native API reconstruction workflow contracts. */
|
|
export const FUNCTION_WORKFLOW_TOOL_CONTRACTS = [
|
|
functionWorkflow(
|
|
"analyze_function",
|
|
"Build a dossier for one native function identified by symbol or provider-returned address. Returns identity with complete inclusive analyzed body ranges or explicit unknown, provider-specific pseudocode and assembly, comments, calls, references, referenced strings/names, local CFG blocks, and available native API boundary observations. Ghidra terminal-call assumptions that may cut the analyzed body are reported in limitations with available callee identities.",
|
|
),
|
|
functionWorkflow(
|
|
"inspect_native_api",
|
|
"Analyze a native API boundary in one function identified by symbol or provider-returned address. Returns confidence, evidence, jump-table dispatch/data/case mappings, separately evidenced default targets, unsupported branches, and residual unknowns. Null case values mean unresolved cases, never a known default.",
|
|
),
|
|
] as const satisfies readonly ToolContract[];
|