fix(hopper): add bounded analysis recovery
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
import { z } from "zod";
|
||||
|
||||
/** Provider-neutral input for one bounded raw function-instruction window. */
|
||||
export const functionInstructionInputSchema = z.object({
|
||||
procedure: z.string().describe("The procedure name or address"),
|
||||
offset: z.number().int().min(0).max(100_000).default(0),
|
||||
limit: z.number().int().min(1).max(500).default(64),
|
||||
document: z.string().optional().describe("The document name"),
|
||||
});
|
||||
@@ -17,6 +17,7 @@ export const TOOL_EXAMPLE_OVERRIDES: Readonly<
|
||||
procedure_callees: { procedure: "main" },
|
||||
procedure_callers: { procedure: "main" },
|
||||
procedure_info: { procedure: "main" },
|
||||
read_function_instructions: { procedure: "main" },
|
||||
procedure_references: { procedure: "main" },
|
||||
procedure_pseudo_code: { procedure: "main" },
|
||||
resolve_containing_procedure: { address: "0x1000" },
|
||||
|
||||
@@ -37,6 +37,7 @@ import {
|
||||
import type { ToolContract, ToolExample } from "./toolContractTypes.js";
|
||||
import { toolContractMetadata } from "./toolEffects.js";
|
||||
import { binarySessionInputSchema } from "./sessionStatusContract.js";
|
||||
import { functionInstructionInputSchema } from "./functionInstructionContract.js";
|
||||
|
||||
export { binarySessionInputSchema } from "./sessionStatusContract.js";
|
||||
|
||||
@@ -240,6 +241,11 @@ export const OFFICIAL_TOOL_CONTRACTS = [
|
||||
"Return bounded metadata for one procedure identified by symbol or address: entrypoint, signature, locals, size, and block count. Follow with decompilation or assembly for behavior.",
|
||||
z.object({ procedure, document }),
|
||||
),
|
||||
official(
|
||||
"read_function_instructions",
|
||||
"Read one offset-paginated window of raw instructions for an analyzed procedure without decompilation, caller discovery, or whole-program string/name scans. Use this fast path for instruction-level orientation; follow next_offset when truncated.",
|
||||
functionInstructionInputSchema,
|
||||
),
|
||||
official(
|
||||
"procedure_references",
|
||||
"Return a bounded set of raw incoming or outgoing reference edges for one procedure. Endpoint procedures are resolved only from provider containment; Ghidra preserves observed reference kinds while providers without kind authority mark them unavailable.",
|
||||
|
||||
@@ -60,6 +60,7 @@ export const TOOL_EFFECTS: Readonly<Record<string, ToolEffects>> = {
|
||||
procedure_callees: evidence,
|
||||
procedure_callers: evidence,
|
||||
procedure_info: evidence,
|
||||
read_function_instructions: evidence,
|
||||
procedure_references: evidence,
|
||||
procedure_pseudo_code: evidence,
|
||||
resolve_containing_procedure: evidence,
|
||||
|
||||
@@ -6,7 +6,10 @@ import {
|
||||
} from "../domain/processCapture.js";
|
||||
import { evidenceBundleSchema } from "../domain/evidenceBundle.js";
|
||||
import { residualUnknownSchema } from "../domain/residualUnknown.js";
|
||||
import { referenceKindSchema } from "../domain/hopperValues.js";
|
||||
import {
|
||||
functionInstructionWindowSchema,
|
||||
referenceKindSchema,
|
||||
} from "../domain/hopperValues.js";
|
||||
import {
|
||||
demangleSwiftSchema,
|
||||
inspectMachoSchema,
|
||||
@@ -39,6 +42,7 @@ import { replayMachineRunOutputSchema } from "../domain/replayMachineRun.js";
|
||||
import { analysisErrorProjectionSchema } from "./errorSchemas.js";
|
||||
import {
|
||||
addressList,
|
||||
analysisActivity,
|
||||
addressedEntry,
|
||||
bounded,
|
||||
containingProcedureResolution,
|
||||
@@ -82,6 +86,7 @@ export const officialOutputSchemas: Readonly<Record<string, z.ZodObject>> = {
|
||||
procedure_callees: resultOf(addressList),
|
||||
procedure_callers: resultOf(addressList),
|
||||
procedure_info: procedureInfoOutput,
|
||||
read_function_instructions: resultOf(functionInstructionWindowSchema),
|
||||
procedure_references: resultOf(
|
||||
z.object({
|
||||
procedure: procedureIdentity,
|
||||
@@ -297,6 +302,7 @@ export const sessionOutputSchemas: Readonly<Record<string, z.ZodObject>> = {
|
||||
reasons: z.array(z.string()),
|
||||
remediation: z.string().nullable(),
|
||||
}),
|
||||
analysis_activity: analysisActivity,
|
||||
recommended_actions: z.array(z.string()),
|
||||
}),
|
||||
z.object({
|
||||
|
||||
@@ -140,6 +140,25 @@ const analysisRun = z
|
||||
})
|
||||
.nullable();
|
||||
|
||||
export const analysisActivity = z.object({
|
||||
status: z.enum(["not_observed", "idle", "busy", "timed_out_busy"]),
|
||||
providers: z.array(
|
||||
z.object({
|
||||
provider: providerIdentity,
|
||||
active: z
|
||||
.object({
|
||||
request_id: z.number().int().min(1),
|
||||
operation: z.string().min(1),
|
||||
elapsed_ms: z.number().int().min(0),
|
||||
timeout_ms: z.number().int().min(0),
|
||||
caller_state: z.enum(["waiting", "timed_out", "cancelled"]),
|
||||
})
|
||||
.nullable(),
|
||||
queued_requests: z.number().int().min(0),
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
||||
const providerRejectionCode: z.ZodType<ProviderRejectionCode> = z.enum(
|
||||
PROVIDER_REJECTION_CODES,
|
||||
);
|
||||
@@ -225,6 +244,7 @@ export const sessionProvider = z.object({
|
||||
providers: z.array(providerIdentity),
|
||||
capabilities: z.array(providerCapability),
|
||||
analysis_run: analysisRun,
|
||||
analysis_activity: analysisActivity,
|
||||
analysis_provider_binding: z
|
||||
.object({
|
||||
provider: providerIdentity,
|
||||
|
||||
Reference in New Issue
Block a user