feat(analysis): add bounded memory and call tracing
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import { z } from "zod";
|
||||
|
||||
/** Shared bounded provider search input fields. */
|
||||
export const analysisSearchInput = {
|
||||
pattern: z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(256)
|
||||
.describe("The literal text or bounded regex pattern to search for"),
|
||||
mode: z.enum(["literal", "regex"]).default("literal"),
|
||||
case_sensitive: z.boolean().default(false).describe("Whether to match case"),
|
||||
offset: z.number().int().min(0).default(0),
|
||||
limit: z.number().int().min(1).max(100).default(100),
|
||||
document: z.string().optional().describe("The document name"),
|
||||
};
|
||||
@@ -1,5 +1,16 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const traceLiteralInputSchema = z.object({
|
||||
query: z.string().min(1),
|
||||
case_sensitive: z.boolean().default(false),
|
||||
limit: z.number().int().min(1).max(100).default(20),
|
||||
max_operations: z.number().int().min(1).max(100).default(20),
|
||||
unknown_registry_approved: z
|
||||
.literal(true)
|
||||
.optional()
|
||||
.describe("Explicit approval to record bounded residuals durably"),
|
||||
});
|
||||
|
||||
/** Input schemas shared by MCP registration and enhanced application dispatch. */
|
||||
export const enhancedInputSchemas = {
|
||||
swift_classes: z.object({ pattern: z.string().default("") }),
|
||||
@@ -52,11 +63,18 @@ export const enhancedInputSchemas = {
|
||||
basic_blocks: 0,
|
||||
}),
|
||||
}),
|
||||
trace_feature: z.object({
|
||||
query: z.string().min(1),
|
||||
case_sensitive: z.boolean().default(false),
|
||||
limit: z.number().int().min(1).max(100).default(20),
|
||||
max_operations: z.number().int().min(1).max(100).default(20),
|
||||
trace_feature: traceLiteralInputSchema,
|
||||
find_code_for_string: traceLiteralInputSchema,
|
||||
trace_call_path: z.object({
|
||||
start: z.string().describe("A provider-normalized procedure address"),
|
||||
goal: z
|
||||
.string()
|
||||
.describe("An optional provider-normalized destination address")
|
||||
.optional(),
|
||||
direction: z.enum(["forward", "backward"]).default("forward"),
|
||||
max_depth: z.number().int().min(1).max(10).default(5),
|
||||
max_nodes: z.number().int().min(1).max(500).default(100),
|
||||
max_operations: z.number().int().min(1).max(500).default(100),
|
||||
unknown_registry_approved: z
|
||||
.literal(true)
|
||||
.optional()
|
||||
@@ -66,7 +84,7 @@ export const enhancedInputSchemas = {
|
||||
|
||||
export type EnhancedToolName = keyof typeof enhancedInputSchemas;
|
||||
|
||||
/** Runtime parser for dispatching only the eight closed enhanced names. */
|
||||
/** Runtime parser for dispatching only the closed enhanced names. */
|
||||
export const enhancedToolNameSchema = z.enum([
|
||||
"swift_classes",
|
||||
"get_objc_classes",
|
||||
@@ -78,4 +96,6 @@ export const enhancedToolNameSchema = z.enum([
|
||||
"binary_overview",
|
||||
"analyze_function",
|
||||
"trace_feature",
|
||||
"find_code_for_string",
|
||||
"trace_call_path",
|
||||
]);
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const document = z.string().optional().describe("The document name");
|
||||
const address = z
|
||||
.string()
|
||||
.describe(
|
||||
"A provider-normalized address; default memory uses 0x-prefixed hexadecimal",
|
||||
);
|
||||
|
||||
/** Bounded Hopper memory and file-mapping contracts. */
|
||||
export const HOPPER_MEMORY_TOOL_DEFINITIONS = [
|
||||
{
|
||||
name: "read_bytes",
|
||||
description:
|
||||
"Read at most 4,096 analyzed bytes from one provider-normalized virtual address. The hexadecimal payload reports the exact returned length; incomplete reads remain explicit and unsupported provider APIs return typed capability unavailability.",
|
||||
inputSchema: z.object({
|
||||
address,
|
||||
length: z.number().int().min(1).max(4_096).default(256),
|
||||
document,
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "address_to_file_offset",
|
||||
description:
|
||||
"Map one provider-normalized virtual address to its original nonnegative file offset. Unmapped addresses fail explicitly, and providers without an authoritative mapping API return typed capability unavailability.",
|
||||
inputSchema: z.object({ address, document }),
|
||||
},
|
||||
] as const;
|
||||
Reference in New Issue
Block a user