refactor: return complete tool results inline
This commit is contained in:
@@ -1,15 +1,12 @@
|
||||
import { z } from "zod";
|
||||
|
||||
/** Shared bounded provider search input fields. */
|
||||
/** Shared 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,4 @@
|
||||
import { applicationVersionComparisonResultSchema } from "../domain/javascriptApplicationVersionComparisonSchemas.js";
|
||||
import { z } from "zod";
|
||||
import { applicationFeatureTraceResultSchema } from "../domain/javascriptFeatureTraceSchemas.js";
|
||||
import { javaScriptSemanticTraceResultSchema } from "../domain/javascriptSemanticTraceSchemas.js";
|
||||
import { javaScriptExportShapeComparisonResultSchema } from "../domain/javascriptExportShapeComparisonSchemas.js";
|
||||
@@ -64,24 +63,7 @@ const reconstructionObligationLedgerOutputSchema = evidenceResultOf(
|
||||
reconstructionObligationLedgerPageSchema,
|
||||
);
|
||||
const reconstructionReadinessOutputSchema = evidenceResultOf(
|
||||
reconstructionReadinessReportSchema
|
||||
.pick({
|
||||
schema: true,
|
||||
schema_version: true,
|
||||
report_id: true,
|
||||
source_digest: true,
|
||||
report_digest: true,
|
||||
status: true,
|
||||
summary: true,
|
||||
metrics: true,
|
||||
})
|
||||
.extend({
|
||||
report_resource_uri: z
|
||||
.string()
|
||||
.regex(
|
||||
/^rea:\/\/evidence\/ev_[a-f0-9]{64}\/reconstruction-readiness-report$/u,
|
||||
),
|
||||
}),
|
||||
reconstructionReadinessReportSchema,
|
||||
);
|
||||
const HASH = "0".repeat(64);
|
||||
const NODE_PREPARATION_EXAMPLE = jsonObjectSchema.parse({
|
||||
@@ -118,14 +100,12 @@ const NODE_PREPARATION_EXAMPLE = jsonObjectSchema.parse({
|
||||
});
|
||||
|
||||
const COVERAGE_WORKSPACE_EXAMPLE = jsonObjectSchema.parse({
|
||||
schema_version: 1,
|
||||
workspace_id: `rcw_${HASH}`,
|
||||
name: "replacement",
|
||||
revision: 1,
|
||||
previous_revision_sha256: null,
|
||||
revision_sha256: HASH,
|
||||
evidence_bundle: {
|
||||
bundle_version: 2,
|
||||
artifacts: [],
|
||||
providers: [],
|
||||
environments: [],
|
||||
@@ -152,7 +132,7 @@ export const APPLICATION_TOOL_CONTRACTS = [
|
||||
name: "trace_application_feature",
|
||||
...toolContractMetadata("trace_application_feature"),
|
||||
description:
|
||||
"Trace a typed literal seed through an authenticated JavaScript Application Graph supplied as full Evidence or an Evidence ID returned earlier in this session. Explicit direction, depth, node, edge, and path bounds apply. Original static, native, passive-runtime, inferred, and unknown authorities remain distinct; native addon handoffs never open a provider or execute the application.",
|
||||
"Trace a typed literal seed through every reachable part of an authenticated JavaScript Application Graph supplied as full Evidence or an Evidence ID returned earlier in this session. Original static, native, passive-runtime, inferred, and unknown authorities remain distinct; native addon handoffs never open a provider or execute the application.",
|
||||
kind: "application",
|
||||
inputSchema: traceApplicationFeatureRequestSchema,
|
||||
outputSchema: traceOutputSchema,
|
||||
@@ -167,7 +147,7 @@ export const APPLICATION_TOOL_CONTRACTS = [
|
||||
name: "trace_javascript_semantics",
|
||||
...toolContractMetadata("trace_javascript_semantics"),
|
||||
description:
|
||||
"Trace bounded static JavaScript data-flow, direct call/return, and closure relations from authenticated analyze_javascript_application v2 Evidence. Queries declare direction and exact node, relation, depth, function, module, and page limits. Dynamic or unsupported semantics remain explicit unknowns; static reachability never claims runtime execution.",
|
||||
"Trace static JavaScript data-flow, direct call/return, and closure relations from the inline Evidence returned by analyze_javascript_application. Dynamic or unsupported semantics remain explicit unknowns; static reachability never claims runtime execution.",
|
||||
kind: "application",
|
||||
inputSchema: traceJavaScriptSemanticsRequestSchema,
|
||||
outputSchema: semanticTraceOutputSchema,
|
||||
@@ -302,7 +282,7 @@ export const APPLICATION_TOOL_CONTRACTS = [
|
||||
name: "execute_node_characterization",
|
||||
...toolContractMetadata("execute_node_characterization"),
|
||||
description:
|
||||
"Recompute and execute one separately approved exact Node characterization plan in the owned controlled-replay boundary. Returns transformation, replay, cleanup, and provider-neutral characterization Evidence v2; stale plans fail before execution.",
|
||||
"Recompute and execute one separately approved exact Node characterization plan in the owned controlled-replay boundary. Returns transformation, replay, cleanup, and provider-neutral characterization Evidence; stale plans fail before execution.",
|
||||
kind: "application",
|
||||
inputSchema: nodeCharacterizationExecutionInputSchema,
|
||||
outputSchema: nodeCharacterizationExecutionOutputSchema,
|
||||
@@ -321,7 +301,7 @@ export const APPLICATION_TOOL_CONTRACTS = [
|
||||
name: "build_reconstruction_obligation_ledger",
|
||||
...toolContractMetadata("build_reconstruction_obligation_ledger"),
|
||||
description:
|
||||
"Generate one deterministic page of a ReconstructionObligationLedger/v1 from an authenticated Evidence v2 bundle, reviewed obligations, and an explicit reconstruction manifest. Static candidates remain candidates; duplicate ownership, missing original or reconstruction cases, missing parser/type, weak verifier authority, unenumerated claims, contradictions, dependencies, and residual unknowns fail closed. Every page carries the same full-ledger closure digest and typed per-obligation diagnostics.",
|
||||
"Generate one deterministic page of a ReconstructionObligationLedger from an authenticated Evidence bundle, reviewed obligations, and an explicit reconstruction manifest. Static candidates remain candidates; duplicate ownership, missing original or reconstruction cases, missing parser/type, weak verifier authority, unenumerated claims, contradictions, dependencies, and residual unknowns fail closed. Every page carries the same full-ledger closure digest and typed per-obligation diagnostics.",
|
||||
kind: "application",
|
||||
inputSchema: reconstructionObligationLedgerInputSchema,
|
||||
outputSchema: reconstructionObligationLedgerOutputSchema,
|
||||
@@ -330,7 +310,6 @@ export const APPLICATION_TOOL_CONTRACTS = [
|
||||
title: "Generate the first obligation-ledger page",
|
||||
input: {
|
||||
evidence_bundle: {
|
||||
bundle_version: 2,
|
||||
artifacts: [],
|
||||
providers: [],
|
||||
environments: [],
|
||||
@@ -341,11 +320,9 @@ export const APPLICATION_TOOL_CONTRACTS = [
|
||||
},
|
||||
reviewed_obligations: [],
|
||||
manifest: {
|
||||
schema_version: 1,
|
||||
bindings: [],
|
||||
contradictions: [],
|
||||
},
|
||||
limits: { max_obligations: 1_000 },
|
||||
page: { offset: 0, limit: 50 },
|
||||
},
|
||||
},
|
||||
|
||||
@@ -15,13 +15,9 @@ const evidenceIdSchema = z
|
||||
const traceApplicationFeatureFacts = {
|
||||
native_observations:
|
||||
traceApplicationFeatureInputSchema.shape.native_observations,
|
||||
native_observation_evidence_ids: z
|
||||
.array(evidenceIdSchema)
|
||||
.max(64)
|
||||
.default([]),
|
||||
native_observation_evidence_ids: z.array(evidenceIdSchema).default([]),
|
||||
seed: traceApplicationFeatureInputSchema.shape.seed,
|
||||
direction: traceApplicationFeatureInputSchema.shape.direction,
|
||||
limits: traceApplicationFeatureInputSchema.shape.limits,
|
||||
} as const;
|
||||
|
||||
/** MCP/CLI trace request accepting full Evidence or a ledger reference. */
|
||||
@@ -51,16 +47,10 @@ export const traceJavaScriptSemanticsRequestSchema = z.union([
|
||||
const compareApplicationVersionsFacts = {
|
||||
left_native_observations:
|
||||
compareApplicationVersionsInputSchema.shape.left_native_observations,
|
||||
left_native_observation_evidence_ids: z
|
||||
.array(evidenceIdSchema)
|
||||
.max(64)
|
||||
.default([]),
|
||||
left_native_observation_evidence_ids: z.array(evidenceIdSchema).default([]),
|
||||
right_native_observations:
|
||||
compareApplicationVersionsInputSchema.shape.right_native_observations,
|
||||
right_native_observation_evidence_ids: z
|
||||
.array(evidenceIdSchema)
|
||||
.max(64)
|
||||
.default([]),
|
||||
right_native_observation_evidence_ids: z.array(evidenceIdSchema).default([]),
|
||||
limits: compareApplicationVersionsInputSchema.shape.limits,
|
||||
unknown_registry_approved:
|
||||
compareApplicationVersionsInputSchema.shape.unknown_registry_approved,
|
||||
|
||||
@@ -7,7 +7,6 @@ const inventory = (digit: string) => {
|
||||
const occurrenceId = `occ_${sha}`;
|
||||
return jsonValueSchema.parse({
|
||||
manifest: {
|
||||
schema_version: 1,
|
||||
manifest_id: `agm_${sha}`,
|
||||
root_artifact_id: artifactId,
|
||||
root_sha256: sha,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { isAbsolute } from "node:path";
|
||||
import { z } from "zod";
|
||||
|
||||
import type { ToolContract } from "./toolContracts.js";
|
||||
@@ -6,53 +5,21 @@ import { artifactOutputSchemas } from "./toolOutputSchemas.js";
|
||||
import { jsonValueSchema } from "../domain/jsonValue.js";
|
||||
import { toolContractMetadata } from "./toolEffects.js";
|
||||
import { requireOutputSchema } from "./toolOutputSchemaPrimitives.js";
|
||||
import { artifactInspectionLimitsSchema } from "../domain/artifactInspection.js";
|
||||
|
||||
const pageInput = {
|
||||
node_offset: z.number().int().min(0).default(0),
|
||||
node_limit: z.number().int().min(1).max(500).default(100),
|
||||
occurrence_offset: z.number().int().min(0).default(0),
|
||||
occurrence_limit: z.number().int().min(1).max(500).default(100),
|
||||
edge_offset: z.number().int().min(0).default(0),
|
||||
edge_limit: z.number().int().min(1).max(500).default(100),
|
||||
};
|
||||
|
||||
const traversalLimitsInput = {
|
||||
max_entries: z.number().int().min(1).max(1_000_000).default(10_000),
|
||||
max_total_bytes: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(Number.MAX_SAFE_INTEGER)
|
||||
.default(1_073_741_824),
|
||||
max_entry_bytes: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(Number.MAX_SAFE_INTEGER)
|
||||
.default(268_435_456),
|
||||
max_compression_ratio: z.number().min(1).max(100_000).default(1_000),
|
||||
max_depth: z.number().int().min(0).max(100).default(20),
|
||||
max_path_bytes: z.number().int().min(1).max(65_535).default(4_096),
|
||||
};
|
||||
|
||||
const integrityInput = {
|
||||
fail: {
|
||||
integrity_policy: z.literal("fail").default("fail"),
|
||||
integrity_continue_approved: z.literal(false).default(false),
|
||||
max_integrity_mismatches: z.number().int().min(1).max(100).default(10),
|
||||
max_integrity_mismatches: z.number().int().min(1).default(10),
|
||||
},
|
||||
continue: {
|
||||
integrity_policy: z.literal("record-and-continue"),
|
||||
integrity_continue_approved: z.literal(true),
|
||||
max_integrity_mismatches: z.number().int().min(1).max(100).default(10),
|
||||
max_integrity_mismatches: z.number().int().min(1).default(10),
|
||||
},
|
||||
} as const;
|
||||
|
||||
const artifactInventoryFacts = {
|
||||
native_mount_approved: z.boolean().default(false),
|
||||
...pageInput,
|
||||
...traversalLimitsInput,
|
||||
} as const;
|
||||
|
||||
/** Exact caller boundary for deterministic artifact inventory. */
|
||||
@@ -64,25 +31,13 @@ export const artifactInventoryInputSchema = z.union([
|
||||
/** Exact caller boundary for approved artifact extraction. */
|
||||
export const artifactExtractionInputSchema = z.object({
|
||||
approved: z.literal(true),
|
||||
output_root: z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(4_096)
|
||||
.refine(isAbsolute, "Extraction output root must be absolute"),
|
||||
occurrence_ids: z
|
||||
.array(z.string().regex(/^occ_[a-f0-9]{64}$/u))
|
||||
.min(1)
|
||||
.max(500),
|
||||
offset: z.number().int().min(0).default(0),
|
||||
limit: z.number().int().min(1).max(500).default(100),
|
||||
...traversalLimitsInput,
|
||||
output_root: z.string().min(1),
|
||||
occurrence_ids: z.array(z.string().regex(/^occ_[a-f0-9]{64}$/u)).min(1),
|
||||
});
|
||||
|
||||
/** Bounded provider-neutral inspection using one atomic inventory substep. */
|
||||
const artifactInspectionFacts = {
|
||||
native_mount_approved: z.boolean().default(false),
|
||||
...artifactInspectionLimitsSchema.shape,
|
||||
...traversalLimitsInput,
|
||||
} as const;
|
||||
export const artifactInspectionInputSchema = z.union([
|
||||
z.object({ ...artifactInspectionFacts, ...integrityInput.fail }),
|
||||
@@ -129,12 +84,12 @@ const artifact = <
|
||||
export const ARTIFACT_TOOL_CONTRACTS = [
|
||||
artifact(
|
||||
"inventory_artifact",
|
||||
"After open_binary binds a local archive, application package, or other artifact—or when one is already active—inventory it as a deterministic, content-addressed artifact graph. This tool accepts no path; in a target-free session open the target first. Returns bounded node and edge pages without extracting or mounting by default.",
|
||||
"After open_binary binds a local archive, application package, or other artifact—or when one is already active—inventory the complete content-addressed artifact graph in one call. This tool accepts no path; in a target-free session open the target first. It does not extract or mount by default.",
|
||||
artifactInventoryInputSchema,
|
||||
),
|
||||
artifact(
|
||||
"inspect_artifact",
|
||||
"After open_binary binds a local archive, application package, or other artifact—or when one is already active—inspect it through one bounded, cancellable inventory substep. This tool accepts no path; in a target-free session open the target first. Returns the full substep Evidence and its ID, observations, derived relationships, hypotheses, contradictions, unexplored branches, limitations, and format-specific next probes. Any substep failure fails the whole call.",
|
||||
"After open_binary binds a local archive, application package, or other artifact—or when one is already active—inspect the complete artifact inventory in one cancellable substep. This tool accepts no path; in a target-free session open the target first. Returns the full substep Evidence, observations, derived relationships, hypotheses, contradictions, unexplored branches, limitations, and format-specific next probes. Any substep failure fails the whole call.",
|
||||
artifactInspectionInputSchema,
|
||||
),
|
||||
artifact(
|
||||
|
||||
@@ -6,7 +6,6 @@ import { browserScenarioCaptureSchema } from "../domain/browserScenarioCapture.j
|
||||
import type { JsonValue } from "../domain/jsonValue.js";
|
||||
|
||||
const example: Record<string, JsonValue> = {
|
||||
schema_version: 1,
|
||||
browser: {
|
||||
mode: "launch",
|
||||
executable_path: "/opt/chromium/chrome",
|
||||
|
||||
@@ -65,7 +65,6 @@ const scenarioArtifacts = {
|
||||
storage: { state: "not_requested" },
|
||||
};
|
||||
const exampleScenarioCapture = () => ({
|
||||
schema_version: 1,
|
||||
browser: {
|
||||
mode: "connect",
|
||||
process_ownership: "external",
|
||||
@@ -121,7 +120,7 @@ export const BROWSER_TOOL_CONTRACTS = [
|
||||
name: "list_browser_targets",
|
||||
...toolContractMetadata("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.",
|
||||
"List every page target from an approved user-owned loopback Chrome DevTools Protocol endpoint whose current URL matches an approved exact origin. URL credentials, query values, and fragments are redacted.",
|
||||
kind: "browser-provider",
|
||||
inputSchema: listBrowserTargetsInputSchema,
|
||||
outputSchema: listOutputSchema,
|
||||
@@ -132,8 +131,6 @@ export const BROWSER_TOOL_CONTRACTS = [
|
||||
cdp_endpoint: endpoint,
|
||||
allowed_origins: [origin],
|
||||
approved: true,
|
||||
offset: 0,
|
||||
limit: 100,
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -58,19 +58,6 @@ const describesObject = (schema: ReturnType<typeof contractJsonSchema>) =>
|
||||
),
|
||||
);
|
||||
|
||||
const emptySchemaPaths = (value: unknown, path = "$"): string[] => {
|
||||
if (Array.isArray(value))
|
||||
return value.flatMap((item, index) =>
|
||||
emptySchemaPaths(item, `${path}[${String(index)}]`),
|
||||
);
|
||||
if (typeof value !== "object" || value === null) return [];
|
||||
const entries = Object.entries(value);
|
||||
if (entries.length === 0) return [path];
|
||||
return entries.flatMap(([key, item]) =>
|
||||
emptySchemaPaths(item, `${path}.${key}`),
|
||||
);
|
||||
};
|
||||
|
||||
describe("tool contract surface", () => {
|
||||
it("advertises complete typed schemas and annotations for every public tool", () => {
|
||||
const contracts = TOOL_CONTRACTS;
|
||||
@@ -90,9 +77,10 @@ describe("tool contract surface", () => {
|
||||
expect(contract.examples).toHaveLength(1);
|
||||
for (const example of contract.examples) {
|
||||
expect(example.title.length).toBeGreaterThan(10);
|
||||
expect(contract.inputSchema.safeParse(example.input).success).toBe(
|
||||
true,
|
||||
);
|
||||
expect(
|
||||
contract.inputSchema.safeParse(example.input).success,
|
||||
`${contract.name}: ${example.title}`,
|
||||
).toBe(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -138,8 +126,7 @@ describe("tool contract surface", () => {
|
||||
{ name: "update_unknown", kind: "session" },
|
||||
{ name: "verify_unknown_resolution", kind: "session" },
|
||||
{ name: "run_replay_machine", kind: "session" },
|
||||
{ name: "snapshot_evidence_bundle", kind: "session" },
|
||||
{ name: "release_evidence_bundle", kind: "session" },
|
||||
{ name: "get_evidence_bundle", kind: "session" },
|
||||
{ name: "get_navigation_context", kind: "session" },
|
||||
{ name: "inspect_address_context", kind: "session" },
|
||||
]);
|
||||
@@ -197,26 +184,4 @@ describe("tool contract surface", () => {
|
||||
expect(contract.description).toMatch(/[.;]/u);
|
||||
}
|
||||
});
|
||||
|
||||
it("publishes no unconstrained output-schema holes across all tools", () => {
|
||||
const contracts = [
|
||||
...OFFICIAL_TOOL_CONTRACTS,
|
||||
...ENHANCED_TOOL_CONTRACTS,
|
||||
...NATIVE_TOOL_CONTRACTS,
|
||||
...ARTIFACT_TOOL_CONTRACTS,
|
||||
...MANAGED_TOOL_CONTRACTS,
|
||||
...MANAGED_WORKFLOW_TOOL_CONTRACTS,
|
||||
...BROWSER_TOOL_CONTRACTS,
|
||||
...BROWSER_SCENARIO_TOOL_CONTRACTS,
|
||||
...ELECTRON_TOOL_CONTRACTS,
|
||||
...JAVASCRIPT_RUNTIME_OBSERVATION_TOOL_CONTRACTS,
|
||||
...APPLICATION_TOOL_CONTRACTS,
|
||||
...SESSION_TOOL_CONTRACTS,
|
||||
];
|
||||
expect(contracts).toHaveLength(TOOL_CONTRACTS.length);
|
||||
for (const contract of contracts) {
|
||||
const schema = contractJsonSchema(contract.outputSchema);
|
||||
expect(emptySchemaPaths(schema), contract.name).toEqual([]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import type { ToolContract } from "./toolContracts.js";
|
||||
import { toolContractMetadata } from "./toolEffects.js";
|
||||
import { evidenceResultOf } from "./toolOutputSchemas.js";
|
||||
@@ -15,11 +13,8 @@ import {
|
||||
} from "../domain/electronActiveObservation.js";
|
||||
import {
|
||||
analyzeJavaScriptApplicationInputSchema,
|
||||
javaScriptApplicationAnalysisResultV1Schema,
|
||||
javascriptApplicationAnalysisResultSchema,
|
||||
} from "../domain/javascriptApplicationAnalysis.js";
|
||||
import { JAVASCRIPT_APPLICATION_NODE_KINDS } from "../domain/javascriptApplicationGraphSchemas.js";
|
||||
import { applicationCoverageSchema } from "../domain/javascriptApplicationEvidenceSchemas.js";
|
||||
import {
|
||||
javascriptRuntimeReconciliationResultSchema,
|
||||
reconcileJavaScriptRuntimeInputSchema,
|
||||
@@ -28,88 +23,8 @@ import { JAVASCRIPT_RUNTIME_RECONCILIATION_EXAMPLE } from "./javascriptRuntimeRe
|
||||
|
||||
const listOutputSchema = evidenceResultOf(electronTargetListSchema);
|
||||
const inspectionOutputSchema = evidenceResultOf(electronPageInspectionSchema);
|
||||
/** MCP-only response selection; analysis identity does not depend on projection. */
|
||||
export const analyzeJavaScriptApplicationToolInputSchema =
|
||||
analyzeJavaScriptApplicationInputSchema.extend({
|
||||
detail: z
|
||||
.enum(["summary", "full"])
|
||||
.default("summary")
|
||||
.describe(
|
||||
"summary returns bounded findings and paged graph resource URIs; full returns the complete graph only when explicitly required",
|
||||
),
|
||||
});
|
||||
|
||||
/** Bounded default projection for agent-facing JavaScript application analysis. */
|
||||
const applicationGraphSummarySchema = z.strictObject({
|
||||
graph_id: z.string().regex(/^jag_[a-f0-9]{64}$/u),
|
||||
node_count: z.number().int().min(0),
|
||||
edge_count: z.number().int().min(0),
|
||||
roots: z.strictObject({
|
||||
items: z.array(z.string().regex(/^jag_node_[a-f0-9]{64}$/u)),
|
||||
total: z.number().int().min(0),
|
||||
truncated: z.boolean(),
|
||||
}),
|
||||
node_kinds: z.array(
|
||||
z.strictObject({
|
||||
kind: z.enum(JAVASCRIPT_APPLICATION_NODE_KINDS),
|
||||
count: z.number().int().min(1),
|
||||
}),
|
||||
),
|
||||
top_findings: z.array(
|
||||
z.strictObject({
|
||||
node_id: z.string().regex(/^jag_node_[a-f0-9]{64}$/u),
|
||||
kind: z.enum(JAVASCRIPT_APPLICATION_NODE_KINDS),
|
||||
label: z.string().nullable(),
|
||||
authority: z.string(),
|
||||
state: z.string(),
|
||||
confidence: z.string(),
|
||||
location: z.json(),
|
||||
}),
|
||||
),
|
||||
coverage: applicationCoverageSchema,
|
||||
limitations: z.array(z.string()),
|
||||
pages: z.strictObject({
|
||||
nodes: z.string().startsWith("rea://evidence/"),
|
||||
edges: z.string().startsWith("rea://evidence/"),
|
||||
page_limit: z.number().int().min(1).max(500),
|
||||
}),
|
||||
});
|
||||
|
||||
const semanticGraphSummarySchema = z.strictObject({
|
||||
graph_id: z.string().regex(/^jsrg_[a-f0-9]{64}$/u),
|
||||
nodes: z.number().int().min(0),
|
||||
relations: z.number().int().min(0),
|
||||
unknown_frontiers: z.number().int().min(0),
|
||||
fingerprints: z.number().int().min(0),
|
||||
coverage: z.enum(["complete", "partial", "unknown", "unavailable"]),
|
||||
query_tool: z.literal("trace_javascript_semantics"),
|
||||
});
|
||||
|
||||
const summaryFields = {
|
||||
unknowns: z.array(z.string().min(1).max(4_096)).max(1_000),
|
||||
graph: applicationGraphSummarySchema,
|
||||
};
|
||||
|
||||
/** Bounded default projection for agent-facing JavaScript application analysis. */
|
||||
export const javascriptApplicationAnalysisSummarySchema = z.discriminatedUnion(
|
||||
"schema_version",
|
||||
[
|
||||
javaScriptApplicationAnalysisResultV1Schema
|
||||
.omit({ graph: true })
|
||||
.extend(summaryFields),
|
||||
javaScriptApplicationAnalysisResultV1Schema.omit({ graph: true }).extend({
|
||||
schema_version: z.literal(2),
|
||||
...summaryFields,
|
||||
semantic_graph: semanticGraphSummarySchema,
|
||||
}),
|
||||
],
|
||||
);
|
||||
|
||||
const applicationOutputSchema = evidenceResultOf(
|
||||
z.union([
|
||||
javascriptApplicationAnalysisSummarySchema,
|
||||
javascriptApplicationAnalysisResultSchema,
|
||||
]),
|
||||
javascriptApplicationAnalysisResultSchema,
|
||||
);
|
||||
const reconciliationOutputSchema = evidenceResultOf(
|
||||
javascriptRuntimeReconciliationResultSchema,
|
||||
@@ -118,7 +33,6 @@ const reconciliationOutputSchema = evidenceResultOf(
|
||||
const endpoint = "http://127.0.0.1:9223";
|
||||
const root = "/Applications/Example.app/Contents/Resources";
|
||||
const activeExample = {
|
||||
schema_version: 1,
|
||||
executable_path: "/Applications/Electron.app/Contents/MacOS/Electron",
|
||||
application_path: "/Applications/Example.app/Contents/Resources/main.js",
|
||||
application_root: "/Applications/Example.app/Contents/Resources",
|
||||
@@ -141,7 +55,7 @@ export const ELECTRON_TOOL_CONTRACTS = [
|
||||
name: "list_electron_targets",
|
||||
...toolContractMetadata("list_electron_targets"),
|
||||
description:
|
||||
"List Electron file:// page targets from an approved user-owned loopback CDP endpoint. Every path is canonicalized and must remain contained by an approved filesystem root, including after symlink resolution.",
|
||||
"List every Electron file:// page target from an approved user-owned loopback CDP endpoint. Every path is canonicalized and must remain contained by an approved filesystem root, including after symlink resolution.",
|
||||
kind: "electron-provider",
|
||||
inputSchema: listElectronTargetsInputSchema,
|
||||
outputSchema: listOutputSchema,
|
||||
@@ -152,8 +66,6 @@ export const ELECTRON_TOOL_CONTRACTS = [
|
||||
cdp_endpoint: endpoint,
|
||||
allowed_file_roots: [root],
|
||||
approved: true,
|
||||
offset: 0,
|
||||
limit: 100,
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -194,19 +106,16 @@ export const ELECTRON_TOOL_CONTRACTS = [
|
||||
name: "analyze_javascript_application",
|
||||
...toolContractMetadata("analyze_javascript_application"),
|
||||
description:
|
||||
"Statically reconstruct one approved local ASAR or extracted JavaScript application without executing it. The default summary returns architecture/security counts, top evidence-backed findings, unknowns, and paged graph resource URIs; request detail=full only when the complete graph must be returned immediately. Identical inputs are deterministic, so do not repeat the call or reread full Evidence without a specific missing detail.",
|
||||
"Reconstruct one local ASAR or extracted JavaScript application as an inline application graph without executing it. Returns all recovered graph nodes, edges, semantic relations, limitations, and coverage.",
|
||||
kind: "electron-provider",
|
||||
inputSchema: analyzeJavaScriptApplicationToolInputSchema,
|
||||
inputSchema: analyzeJavaScriptApplicationInputSchema,
|
||||
outputSchema: applicationOutputSchema,
|
||||
examples: [
|
||||
{
|
||||
title: "Analyze one approved local Electron application",
|
||||
title: "Analyze one local JavaScript application",
|
||||
input: {
|
||||
input_path: "/Applications/Example.app/Contents/Resources/app.asar",
|
||||
format: "auto",
|
||||
approved: true,
|
||||
source_map_read_approved: false,
|
||||
detail: "summary",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -3,8 +3,6 @@ import { z } from "zod";
|
||||
const traceLiteralInputSchema = z.strictObject({
|
||||
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()
|
||||
@@ -19,54 +17,20 @@ export const enhancedInputSchemas = {
|
||||
batch_decompile: z.strictObject({
|
||||
addresses: z
|
||||
.array(z.string().describe("A provider-normalized procedure address"))
|
||||
.max(20)
|
||||
.default([]),
|
||||
}),
|
||||
get_call_graph: z.strictObject({
|
||||
address: z.string().describe("A provider-normalized procedure address"),
|
||||
direction: z.enum(["forward", "backward"]).default("forward"),
|
||||
depth: z.number().int().min(1).max(5).default(2),
|
||||
}),
|
||||
analyze_swift_types: z.strictObject({}),
|
||||
find_xrefs_to_name: z.strictObject({ name: z.string() }),
|
||||
binary_overview: z.strictObject({
|
||||
detail: z.enum(["concise", "detailed"]).default("concise"),
|
||||
limit: z.number().int().min(1).max(50).default(10),
|
||||
}),
|
||||
binary_overview: z.strictObject({}),
|
||||
analyze_function: z.strictObject({
|
||||
procedure: z.string().describe("A procedure name or address"),
|
||||
include_assembly: z.boolean().default(false),
|
||||
limit: z.number().int().min(1).max(500).default(100),
|
||||
max_pseudocode_chars: z.number().int().min(1).max(100_000).default(20_000),
|
||||
max_instructions: z.number().int().min(1).max(5_000).default(500),
|
||||
pseudocode_offset: z.number().int().min(0).default(0),
|
||||
assembly_offset: z.number().int().min(0).default(0),
|
||||
collection_offset: z
|
||||
.strictObject({
|
||||
comments: z.number().int().min(0).default(0),
|
||||
callers: z.number().int().min(0).default(0),
|
||||
callees: z.number().int().min(0).default(0),
|
||||
incoming_references: z.number().int().min(0).default(0),
|
||||
outgoing_references: z.number().int().min(0).default(0),
|
||||
referenced_strings: z.number().int().min(0).default(0),
|
||||
referenced_names: z.number().int().min(0).default(0),
|
||||
basic_blocks: z.number().int().min(0).default(0),
|
||||
})
|
||||
.default({
|
||||
comments: 0,
|
||||
callers: 0,
|
||||
callees: 0,
|
||||
incoming_references: 0,
|
||||
outgoing_references: 0,
|
||||
referenced_strings: 0,
|
||||
referenced_names: 0,
|
||||
basic_blocks: 0,
|
||||
}),
|
||||
}),
|
||||
inspect_native_api: z.strictObject({
|
||||
procedure: z.string().describe("A procedure name or address"),
|
||||
max_pseudocode_chars: z.number().int().min(1).max(100_000).default(20_000),
|
||||
max_instructions: z.number().int().min(1).max(5_000).default(500),
|
||||
unknown_registry_approved: z
|
||||
.literal(true)
|
||||
.optional()
|
||||
@@ -83,13 +47,12 @@ export const enhancedInputSchemas = {
|
||||
.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()
|
||||
.describe("Explicit approval to record bounded residuals durably"),
|
||||
.describe(
|
||||
"Explicit approval to record unresolved provider results durably",
|
||||
),
|
||||
}),
|
||||
} as const;
|
||||
|
||||
|
||||
@@ -2,14 +2,6 @@ import { enhancedInputSchemas } from "./enhancedInputs.js";
|
||||
import { createEvidence } from "../domain/evidence.js";
|
||||
import { jsonValueSchema } from "../domain/jsonValue.js";
|
||||
|
||||
const bounded = <Item>(items: readonly Item[]) => ({
|
||||
items,
|
||||
total: items.length,
|
||||
returned: items.length,
|
||||
truncated: false,
|
||||
next_offset: null,
|
||||
});
|
||||
|
||||
const dossier = (text: string) =>
|
||||
jsonValueSchema.parse({
|
||||
procedure: {
|
||||
@@ -18,23 +10,16 @@ const dossier = (text: string) =>
|
||||
signature: "int main(void)",
|
||||
locals: [],
|
||||
},
|
||||
pseudocode: {
|
||||
text,
|
||||
total_chars: [...text].length,
|
||||
returned_chars: [...text].length,
|
||||
truncated: false,
|
||||
next_offset: null,
|
||||
},
|
||||
assembly: bounded([]),
|
||||
comments: bounded([]),
|
||||
callers: bounded([]),
|
||||
callees: bounded([]),
|
||||
incoming_references: bounded([]),
|
||||
outgoing_references: bounded([]),
|
||||
referenced_strings: bounded([]),
|
||||
referenced_names: bounded([]),
|
||||
basic_blocks: bounded([{ start: "0x1000", end: "0x1001", successors: [] }]),
|
||||
instruction_scan: { scanned: 1, truncated: false },
|
||||
pseudocode: text,
|
||||
assembly: [],
|
||||
comments: [],
|
||||
callers: [],
|
||||
callees: [],
|
||||
incoming_references: [],
|
||||
outgoing_references: [],
|
||||
referenced_strings: [],
|
||||
referenced_names: [],
|
||||
basic_blocks: [{ start: "0x1000", end: "0x1001", successors: [] }],
|
||||
});
|
||||
|
||||
const observe = (digit: string, text: string) =>
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { z } from "zod";
|
||||
|
||||
/** Provider-neutral input for one bounded raw function-instruction window. */
|
||||
/** Provider-neutral input for a function's complete raw instruction list. */
|
||||
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"),
|
||||
});
|
||||
|
||||
@@ -36,10 +36,10 @@ const functionWorkflow = <Name extends FunctionWorkflowName>(
|
||||
export const FUNCTION_WORKFLOW_TOOL_CONTRACTS = [
|
||||
functionWorkflow(
|
||||
"analyze_function",
|
||||
"Preferred bounded analysis for one procedure symbol or address. Returns identity, provider-specific pseudocode, optional assembly, comments, calls, typed-or-explicitly-unavailable references, referenced strings/names, and local CFG blocks with exact truncation metadata. Providers with a structured decompiler model also expose native API boundary types, confidence, evidence, jump-table data/target addresses, and explicit decompiler-artifact labels.",
|
||||
"Return one complete function dossier inline, including identity, provider-specific pseudocode and assembly, comments, calls, references, referenced strings/names, local CFG blocks, and any available native API boundary observations.",
|
||||
),
|
||||
functionWorkflow(
|
||||
"inspect_native_api",
|
||||
"Reconstruct one native function boundary through inspectable substeps. Returns structured inferred return/parameter types with confidence and evidence, jump-table dispatch/data/target mappings, explicit decompiler-artifact labels, unsupported branches, and residual unknowns.",
|
||||
"Reconstruct one native function boundary with structured return/parameter types, confidence, evidence, jump-table dispatch/data/target mappings, unsupported branches, and residual unknowns.",
|
||||
),
|
||||
] as const satisfies readonly ToolContract[];
|
||||
|
||||
@@ -15,7 +15,7 @@ export const HOPPER_MEMORY_TOOL_DEFINITIONS = [
|
||||
"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),
|
||||
length: z.number().int().min(1).default(256),
|
||||
document,
|
||||
}),
|
||||
},
|
||||
|
||||
@@ -11,8 +11,6 @@ import { EMPTY_PROCESS_CAPTURE_EXAMPLE } from "./processCaptureExample.js";
|
||||
const comparison = compareFunctions(
|
||||
FUNCTION_COMPARISON_EXAMPLE.left,
|
||||
FUNCTION_COMPARISON_EXAMPLE.right,
|
||||
0,
|
||||
100,
|
||||
);
|
||||
|
||||
export const FUNCTION_COMPARISON_EVIDENCE = createEvidence(
|
||||
@@ -26,10 +24,8 @@ export const FUNCTION_COMPARISON_EVIDENCE = createEvidence(
|
||||
predicateType: "rea.function-comparison/v1",
|
||||
operation: "compare_functions",
|
||||
parameters: {
|
||||
left_evidence_ids: [FUNCTION_COMPARISON_EXAMPLE.left.evidence_id],
|
||||
right_evidence_ids: [FUNCTION_COMPARISON_EXAMPLE.right.evidence_id],
|
||||
offset: 0,
|
||||
limit: 100,
|
||||
left_evidence_id: FUNCTION_COMPARISON_EXAMPLE.left.evidence_id,
|
||||
right_evidence_id: FUNCTION_COMPARISON_EXAMPLE.right.evidence_id,
|
||||
},
|
||||
result: jsonValueSchema.parse(comparison),
|
||||
confidence: "derived",
|
||||
@@ -49,7 +45,7 @@ const PROCESS_PROVIDER = {
|
||||
const capture = parseProcessCapture(EMPTY_PROCESS_CAPTURE_EXAMPLE);
|
||||
const captureEvidence = (scenario: string) =>
|
||||
createEvidence(undefined, PROCESS_PROVIDER, {
|
||||
predicateType: "rea.process-capture/v4",
|
||||
predicateType: "rea.process-capture",
|
||||
operation: "capture_process_scenario",
|
||||
parameters: { scenario },
|
||||
result: jsonValueSchema.parse(capture),
|
||||
@@ -68,7 +64,7 @@ export const PROCESS_COMPARISON_EVIDENCE = createEvidence(
|
||||
undefined,
|
||||
PROCESS_PROVIDER,
|
||||
{
|
||||
predicateType: "rea.process-comparison/v3",
|
||||
predicateType: "rea.process-comparison",
|
||||
operation: "compare_process_captures",
|
||||
parameters: {
|
||||
left_evidence_id: PROCESS_CAPTURE_REFERENCE.evidence_id,
|
||||
|
||||
@@ -17,7 +17,7 @@ export const JAVASCRIPT_RUNTIME_OBSERVATION_TOOL_CONTRACTS = [
|
||||
name: "list_javascript_runtime_targets",
|
||||
...toolContractMetadata("list_javascript_runtime_targets"),
|
||||
description:
|
||||
"List attachable Node/Electron V8 Inspector targets from one approved literal-loopback endpoint. Only targets inside exact canonical file roots or exact HTTP(S) origins are retained; excluded target locations never enter Evidence.",
|
||||
"List every attachable Node/Electron V8 Inspector target from one approved literal-loopback endpoint. Only targets inside exact canonical file roots or exact HTTP(S) origins are retained; excluded target locations never enter Evidence.",
|
||||
kind: "runtime-provider",
|
||||
inputSchema: listJavaScriptRuntimeTargetsInputSchema,
|
||||
outputSchema: evidenceResultOf(javascriptRuntimeTargetListSchema),
|
||||
@@ -29,8 +29,6 @@ export const JAVASCRIPT_RUNTIME_OBSERVATION_TOOL_CONTRACTS = [
|
||||
allowed_file_roots: [root],
|
||||
allowed_origins: [],
|
||||
approved: true,
|
||||
offset: 0,
|
||||
limit: 100,
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -4,6 +4,11 @@ import {
|
||||
createJavaScriptApplicationNode,
|
||||
} from "../domain/javascriptApplicationGraph.js";
|
||||
import { createWebTextArtifact } from "../domain/webContentArtifact.js";
|
||||
import {
|
||||
createJavaScriptSemanticGraph,
|
||||
createJavaScriptSemanticGraphNode,
|
||||
} from "../domain/javascriptSemanticGraph.js";
|
||||
import { JAVASCRIPT_SEMANTIC_RELATION_FAMILIES } from "../domain/javascriptSemanticGraphSchemas.js";
|
||||
|
||||
const applicationSha256 = "1".repeat(64);
|
||||
const script = createWebTextArtifact(
|
||||
@@ -59,13 +64,51 @@ const asset = createJavaScriptApplicationNode({
|
||||
});
|
||||
const graph = createJavaScriptApplicationGraph({
|
||||
schema: "JavaScriptApplicationGraph",
|
||||
schema_version: 1,
|
||||
root_node_ids: [asset.node_id],
|
||||
nodes: [asset],
|
||||
edges: [],
|
||||
coverage: completeCoverage,
|
||||
limitations: [],
|
||||
});
|
||||
const semanticNode = createJavaScriptSemanticGraphNode({
|
||||
kind: "module",
|
||||
identity: {
|
||||
artifact_sha256: applicationSha256,
|
||||
module_path: "renderer.js",
|
||||
source_range: null,
|
||||
role_key: "example-module",
|
||||
},
|
||||
function_node_id: null,
|
||||
application_node_ids: [asset.node_id],
|
||||
label: "renderer.js",
|
||||
properties: {},
|
||||
evidence: graphEvidence,
|
||||
});
|
||||
const semanticGraph = createJavaScriptSemanticGraph({
|
||||
schema: "JavaScriptSemanticRelationGraph",
|
||||
root_artifact_sha256: applicationSha256,
|
||||
application_graph_id: graph.graph_id,
|
||||
root_node_ids: [semanticNode.node_id],
|
||||
nodes: [semanticNode],
|
||||
relations: [],
|
||||
fingerprints: [],
|
||||
unknowns: [],
|
||||
coverage: {
|
||||
status: "unknown",
|
||||
truncated: false,
|
||||
omitted_nodes: 0,
|
||||
omitted_relations: 0,
|
||||
limits: [],
|
||||
families: JAVASCRIPT_SEMANTIC_RELATION_FAMILIES.map((family) => ({
|
||||
family,
|
||||
status: "unknown" as const,
|
||||
retained_relations: 0,
|
||||
omitted_relations: 0,
|
||||
unknown_ids: [],
|
||||
})),
|
||||
},
|
||||
limitations: ["Semantic relations are unavailable in this minimal example."],
|
||||
});
|
||||
|
||||
const staticEvidence = createEvidence(
|
||||
{ path: inputPath, sha256: applicationSha256, format: "directory" },
|
||||
@@ -75,17 +118,17 @@ const staticEvidence = createEvidence(
|
||||
version: "1",
|
||||
},
|
||||
{
|
||||
predicateType: "rea.javascript-application-analysis/v1",
|
||||
predicateType: "rea.javascript-application-analysis",
|
||||
operation: "analyze_javascript_application",
|
||||
parameters: { approved: true, source_map_read_approved: false },
|
||||
parameters: {},
|
||||
result: {
|
||||
schema_version: 1,
|
||||
input_path: inputPath,
|
||||
format: "directory",
|
||||
root_artifact_sha256: applicationSha256,
|
||||
inventory_manifest_id: `agm_${"2".repeat(64)}`,
|
||||
inventory_graph_sha256: "3".repeat(64),
|
||||
graph,
|
||||
semantic_graph: semanticGraph,
|
||||
summary: {
|
||||
browser_windows: 0,
|
||||
explicit_web_preferences: 0,
|
||||
@@ -116,7 +159,6 @@ const staticEvidence = createEvidence(
|
||||
text_bytes_read: script.bytes,
|
||||
omitted_text_files: 0,
|
||||
limit_omitted_text_files: 0,
|
||||
policy_filtered_text_files: 0,
|
||||
invalid_utf8_files: 0,
|
||||
parsed_javascript_files: 1,
|
||||
visited_ast_nodes: 1,
|
||||
@@ -153,7 +195,6 @@ const runtimeEvidence = createEvidence(
|
||||
source_capture_approved: true,
|
||||
},
|
||||
result: {
|
||||
schema_version: 1,
|
||||
browser: {
|
||||
product: "Electron/example",
|
||||
protocol_version: "1.3",
|
||||
|
||||
@@ -5,28 +5,6 @@ import { managedOutputSchemas } from "./toolOutputSchemas.js";
|
||||
import { toolContractMetadata } from "./toolEffects.js";
|
||||
import { requireOutputSchema } from "./toolOutputSchemaPrimitives.js";
|
||||
|
||||
const managedReadLimits = {
|
||||
max_file_bytes: z
|
||||
.number()
|
||||
.int()
|
||||
.min(4_096)
|
||||
.max(1_073_741_824)
|
||||
.default(268_435_456),
|
||||
max_metadata_bytes: z
|
||||
.number()
|
||||
.int()
|
||||
.min(256)
|
||||
.max(268_435_456)
|
||||
.default(67_108_864),
|
||||
max_table_rows: z.number().int().min(1).max(1_000_000).default(100_000),
|
||||
max_heap_item_bytes: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(16_777_216)
|
||||
.default(1_048_576),
|
||||
};
|
||||
|
||||
/** Exact caller boundary for execution-free PE/CLI triage and identity. */
|
||||
export const managedArtifactInputSchema = z.object({
|
||||
path: z
|
||||
@@ -36,48 +14,13 @@ export const managedArtifactInputSchema = z.object({
|
||||
.describe(
|
||||
"Managed PE/CLI path to open before inspection; omit only when a managed target is already active",
|
||||
),
|
||||
reference_offset: z.number().int().min(0).default(0),
|
||||
reference_limit: z.number().int().min(1).max(500).default(100),
|
||||
resource_offset: z.number().int().min(0).default(0),
|
||||
resource_limit: z.number().int().min(1).max(500).default(100),
|
||||
attribute_offset: z.number().int().min(0).default(0),
|
||||
attribute_limit: z.number().int().min(1).max(500).default(100),
|
||||
...managedReadLimits,
|
||||
});
|
||||
|
||||
/** Exact caller boundary for execution-free metadata/signature/IL inspection. */
|
||||
export const managedMemberInputSchema = z.object({
|
||||
type_offset: z.number().int().min(0).default(0),
|
||||
type_limit: z.number().int().min(1).max(500).default(100),
|
||||
method_offset: z.number().int().min(0).default(0),
|
||||
method_limit: z.number().int().min(1).max(500).default(100),
|
||||
field_offset: z.number().int().min(0).default(0),
|
||||
field_limit: z.number().int().min(1).max(500).default(100),
|
||||
member_ref_offset: z.number().int().min(0).default(0),
|
||||
member_ref_limit: z.number().int().min(1).max(500).default(100),
|
||||
edge_offset: z.number().int().min(0).default(0),
|
||||
edge_limit: z.number().int().min(1).max(1_000).default(250),
|
||||
instruction_anchor_limit: z.number().int().min(0).max(500).default(100),
|
||||
...managedReadLimits,
|
||||
max_method_body_bytes: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(16_777_216)
|
||||
.default(1_048_576),
|
||||
max_method_instructions: z.number().int().min(1).max(100_000).default(10_000),
|
||||
});
|
||||
export const managedMemberInputSchema = z.object({});
|
||||
|
||||
/** Exact caller boundary for execution-free managed/native boundary inspection. */
|
||||
export const managedNativeBoundaryInputSchema = z.object({
|
||||
module_ref_offset: z.number().int().min(0).default(0),
|
||||
module_ref_limit: z.number().int().min(1).max(500).default(100),
|
||||
import_offset: z.number().int().min(0).default(0),
|
||||
import_limit: z.number().int().min(1).max(500).default(100),
|
||||
implementation_offset: z.number().int().min(0).default(0),
|
||||
implementation_limit: z.number().int().min(1).max(500).default(100),
|
||||
...managedReadLimits,
|
||||
});
|
||||
export const managedNativeBoundaryInputSchema = z.object({});
|
||||
|
||||
const outputSchema = requireOutputSchema(
|
||||
managedOutputSchemas,
|
||||
@@ -98,7 +41,7 @@ export const MANAGED_TOOL_CONTRACTS = [
|
||||
name: "inspect_managed_artifact",
|
||||
...toolContractMetadata("inspect_managed_artifact"),
|
||||
description:
|
||||
"Open and classify an explicit managed PE/CLI path, or inspect the active managed target, then inventory exact assembly/module identity, target framework evidence, references, resources, and custom attributes without loading or executing target code. Returns bounded pages and explicit partial or malformed coverage.",
|
||||
"Open and classify an explicit managed PE/CLI path, or inspect the active managed target, then inventory exact assembly/module identity, target framework evidence, references, resources, and custom attributes without loading or executing target code. Returns complete inline inventories when metadata is admitted and explicit partial or malformed coverage otherwise.",
|
||||
kind: "managed-provider",
|
||||
inputSchema: managedArtifactInputSchema,
|
||||
outputSchema,
|
||||
@@ -113,14 +56,14 @@ export const MANAGED_TOOL_CONTRACTS = [
|
||||
name: "inspect_managed_members",
|
||||
...toolContractMetadata("inspect_managed_members"),
|
||||
description:
|
||||
"Inspect bounded PE/CLI metadata members, signatures, raw CIL hashes, limited member-result-v1 decoded-instruction-tuple hashes, separately reported exception regions, call edges, and field-access anchors without loading or executing target code. Metadata tokens are reported as build-local coordinates bound to the artifact SHA-256 and MVID; the v1 tuple hash does not resolve them or fully commit control flow.",
|
||||
"Inspect PE/CLI metadata members, signatures, raw CIL hashes, member-result-v1 decoded-instruction-tuple hashes, separately reported exception regions, call edges, and field-access anchors without loading or executing target code. Metadata tokens are reported as build-local coordinates bound to the artifact SHA-256 and MVID; the v1 tuple hash does not resolve them or fully commit control flow.",
|
||||
kind: "managed-provider",
|
||||
inputSchema: managedMemberInputSchema,
|
||||
outputSchema: memberOutputSchema,
|
||||
examples: [
|
||||
{
|
||||
title: "Example inspect managed members request",
|
||||
input: { method_limit: 25, edge_limit: 100 },
|
||||
input: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -135,7 +78,7 @@ export const MANAGED_TOOL_CONTRACTS = [
|
||||
examples: [
|
||||
{
|
||||
title: "Example inspect managed/native boundary request",
|
||||
input: { import_limit: 50, implementation_limit: 50 },
|
||||
input: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -21,7 +21,6 @@ const emptyManagedMembers = (
|
||||
sha256: string,
|
||||
mvid: string,
|
||||
): ManagedMemberInspection => ({
|
||||
schema_version: 1,
|
||||
artifact: {
|
||||
path: `/examples/${sha256.slice(0, 8)}.dll`,
|
||||
sha256,
|
||||
@@ -47,29 +46,16 @@ const emptyManagedMembers = (
|
||||
requires_artifact_sha256: sha256,
|
||||
requires_mvid: mvid,
|
||||
},
|
||||
types: emptyPage(100),
|
||||
fields: emptyPage(100),
|
||||
methods: emptyPage(100),
|
||||
member_refs: emptyPage(100),
|
||||
call_edges: emptyPage(250),
|
||||
field_accesses: emptyPage(250),
|
||||
types: [],
|
||||
fields: [],
|
||||
methods: [],
|
||||
member_refs: [],
|
||||
call_edges: [],
|
||||
field_accesses: [],
|
||||
coverage: { state: "complete", issues: [] },
|
||||
limitations: [],
|
||||
});
|
||||
|
||||
const emptyPage = <Item>(limit: number) => {
|
||||
const items: Item[] = [];
|
||||
return {
|
||||
items,
|
||||
offset: 0,
|
||||
limit,
|
||||
total: 0,
|
||||
returned: 0,
|
||||
dropped: 0,
|
||||
complete: true,
|
||||
};
|
||||
};
|
||||
|
||||
const evidence = (result: ManagedMemberInspection) =>
|
||||
createEvidence(undefined, MANAGED_STATIC_EXAMPLE_PROVIDER, {
|
||||
operation: "inspect_managed_members",
|
||||
@@ -86,55 +72,50 @@ const runtimeMembers = (): ManagedMemberInspection => {
|
||||
);
|
||||
return {
|
||||
...result,
|
||||
methods: {
|
||||
...result.methods,
|
||||
items: [
|
||||
{
|
||||
token: "0x06000001",
|
||||
row_offset: 128,
|
||||
declaring_type_token: "0x02000001",
|
||||
declaring_type: "Example.Program",
|
||||
name: "Main",
|
||||
rva: 8192,
|
||||
impl_flags: 0,
|
||||
flags: 22,
|
||||
signature: {
|
||||
raw_length: 3,
|
||||
raw_sha256: "3".repeat(64),
|
||||
kind: "method",
|
||||
parse_status: "decoded",
|
||||
calling_convention: "default",
|
||||
generic_parameter_count: 0,
|
||||
parameter_count: 0,
|
||||
return_type: "void",
|
||||
parameter_types: [],
|
||||
field_type: null,
|
||||
issue: null,
|
||||
},
|
||||
body: {
|
||||
status: "present",
|
||||
header_format: "tiny",
|
||||
rva: 8192,
|
||||
file_offset: 512,
|
||||
max_stack: 8,
|
||||
init_locals: false,
|
||||
local_var_sig_token: null,
|
||||
il_size: 1,
|
||||
il_sha256: "4".repeat(64),
|
||||
normalized_il_sha256: "5".repeat(64),
|
||||
instruction_count: 1,
|
||||
decoded_instruction_count: 1,
|
||||
truncated_instructions: 0,
|
||||
opcode_counts: { ret: 1 },
|
||||
anchors: [],
|
||||
exception_regions: [],
|
||||
issue: null,
|
||||
},
|
||||
methods: [
|
||||
{
|
||||
token: "0x06000001",
|
||||
row_offset: 128,
|
||||
declaring_type_token: "0x02000001",
|
||||
declaring_type: "Example.Program",
|
||||
name: "Main",
|
||||
rva: 8192,
|
||||
impl_flags: 0,
|
||||
flags: 22,
|
||||
signature: {
|
||||
raw_length: 3,
|
||||
raw_sha256: "3".repeat(64),
|
||||
kind: "method",
|
||||
parse_status: "decoded",
|
||||
calling_convention: "default",
|
||||
generic_parameter_count: 0,
|
||||
parameter_count: 0,
|
||||
return_type: "void",
|
||||
parameter_types: [],
|
||||
field_type: null,
|
||||
issue: null,
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
returned: 1,
|
||||
},
|
||||
body: {
|
||||
status: "present",
|
||||
header_format: "tiny",
|
||||
rva: 8192,
|
||||
file_offset: 512,
|
||||
max_stack: 8,
|
||||
init_locals: false,
|
||||
local_var_sig_token: null,
|
||||
il_size: 1,
|
||||
il_sha256: "4".repeat(64),
|
||||
normalized_il_sha256: "5".repeat(64),
|
||||
instruction_count: 1,
|
||||
decoded_instruction_count: 1,
|
||||
truncated_instructions: 0,
|
||||
opcode_counts: { ret: 1 },
|
||||
anchors: [],
|
||||
exception_regions: [],
|
||||
issue: null,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
@@ -146,11 +127,6 @@ export const MANAGED_MEMBER_COMPARISON_EXAMPLE = {
|
||||
right: evidence(
|
||||
emptyManagedMembers("1".repeat(64), "ffeeddcc-bbaa-4988-9766-554433221100"),
|
||||
),
|
||||
limits: {
|
||||
max_method_matches: 100,
|
||||
max_field_matches: 50,
|
||||
max_candidates: 25,
|
||||
},
|
||||
};
|
||||
|
||||
const runtimeExampleEvidence = evidence(runtimeMembers());
|
||||
@@ -158,18 +134,10 @@ const runtimeExampleEvidence = evidence(runtimeMembers());
|
||||
/** Minimal valid managed application graph projection request. */
|
||||
export const MANAGED_APPLICATION_GRAPH_EXAMPLE = {
|
||||
managed_members: runtimeExampleEvidence,
|
||||
limits: {
|
||||
max_types: 100,
|
||||
max_methods: 100,
|
||||
max_fields: 100,
|
||||
max_pinvoke_imports: 100,
|
||||
max_native_implementations: 100,
|
||||
},
|
||||
};
|
||||
|
||||
const boundaryEvidence = () => {
|
||||
const result: ManagedNativeBoundaryInspection = {
|
||||
schema_version: 1,
|
||||
artifact: {
|
||||
path: "/examples/ManagedInterop.exe",
|
||||
sha256: "6".repeat(64),
|
||||
@@ -204,51 +172,35 @@ const boundaryEvidence = () => {
|
||||
managed_native_header_rva: 0,
|
||||
managed_native_header_size: 0,
|
||||
},
|
||||
module_refs: {
|
||||
items: [
|
||||
{
|
||||
token: "0x1a000001",
|
||||
row_offset: 256,
|
||||
name: "nativehelper.dll",
|
||||
},
|
||||
],
|
||||
offset: 0,
|
||||
limit: 100,
|
||||
total: 1,
|
||||
returned: 1,
|
||||
dropped: 0,
|
||||
complete: true,
|
||||
},
|
||||
pinvoke_imports: {
|
||||
items: [
|
||||
{
|
||||
token: "0x1c000001",
|
||||
row_offset: 288,
|
||||
mapping_flags: 0,
|
||||
mapping_flags_hex: "0x0000",
|
||||
member_token: "0x06000001",
|
||||
member_kind: "method",
|
||||
member_name: "OpenNative",
|
||||
import_name: "open_native",
|
||||
import_scope_token: "0x1a000001",
|
||||
import_scope_name: "nativehelper.dll",
|
||||
no_mangle: true,
|
||||
char_set: "not-specified",
|
||||
call_convention: "cdecl",
|
||||
supports_last_error: false,
|
||||
best_fit: "assembly-default",
|
||||
throw_on_unmappable_char: "assembly-default",
|
||||
verification: "managed-declaration-only",
|
||||
},
|
||||
],
|
||||
offset: 0,
|
||||
limit: 100,
|
||||
total: 1,
|
||||
returned: 1,
|
||||
dropped: 0,
|
||||
complete: true,
|
||||
},
|
||||
native_implementations: emptyPage(100),
|
||||
module_refs: [
|
||||
{
|
||||
token: "0x1a000001",
|
||||
row_offset: 256,
|
||||
name: "nativehelper.dll",
|
||||
},
|
||||
],
|
||||
pinvoke_imports: [
|
||||
{
|
||||
token: "0x1c000001",
|
||||
row_offset: 288,
|
||||
mapping_flags: 0,
|
||||
mapping_flags_hex: "0x0000",
|
||||
member_token: "0x06000001",
|
||||
member_kind: "method",
|
||||
member_name: "OpenNative",
|
||||
import_name: "open_native",
|
||||
import_scope_token: "0x1a000001",
|
||||
import_scope_name: "nativehelper.dll",
|
||||
no_mangle: true,
|
||||
char_set: "not-specified",
|
||||
call_convention: "cdecl",
|
||||
supports_last_error: false,
|
||||
best_fit: "assembly-default",
|
||||
throw_on_unmappable_char: "assembly-default",
|
||||
verification: "managed-declaration-only",
|
||||
},
|
||||
],
|
||||
native_implementations: [],
|
||||
summary: {
|
||||
module_ref_count: 1,
|
||||
pinvoke_import_count: 1,
|
||||
@@ -354,10 +306,6 @@ export const MANAGED_RECONSTRUCTION_IMPORT_EXAMPLE = {
|
||||
export const MANAGED_NATIVE_VERIFICATION_EXAMPLE = {
|
||||
managed_boundaries: boundaryEvidence(),
|
||||
native_observations: [nativeExportEvidence()],
|
||||
limits: {
|
||||
max_native_observations: 20,
|
||||
max_candidates_per_import: 25,
|
||||
},
|
||||
};
|
||||
|
||||
/** Minimal valid managed runtime-correlation planning request. */
|
||||
|
||||
@@ -4,7 +4,6 @@ import { compareManagedMembersInputSchema } from "../domain/managedMemberCompari
|
||||
import { managedNativeVerificationInputSchema } from "../domain/managedNativeVerification.js";
|
||||
import { managedReconstructionImportInputSchema } from "../domain/managedReconstruction.js";
|
||||
import { managedRuntimeCorrelationInputSchema } from "../domain/managedRuntimeCorrelation.js";
|
||||
import { projectManagedApplicationGraphInputSchema } from "../domain/managedApplicationGraph.js";
|
||||
import type { ToolContract } from "./toolContracts.js";
|
||||
import { managedWorkflowOutputSchemas } from "./toolOutputSchemas.js";
|
||||
import {
|
||||
@@ -36,7 +35,6 @@ export const compareManagedMembersReferenceInputSchema = z
|
||||
.strictObject({
|
||||
left_evidence_id: managedEvidenceIdSchema,
|
||||
right_evidence_id: managedEvidenceIdSchema,
|
||||
limits: compareManagedMembersInputSchema.shape.limits,
|
||||
unknown_registry_approved:
|
||||
compareManagedMembersInputSchema.shape.unknown_registry_approved,
|
||||
})
|
||||
@@ -68,9 +66,7 @@ export const managedNativeVerificationReferenceInputSchema = z
|
||||
native_observation_evidence_ids: z
|
||||
.array(nativeObservationEvidenceIdSchema)
|
||||
.min(1)
|
||||
.max(50)
|
||||
.describe("Unique session-owned native observation Evidence IDs"),
|
||||
limits: managedNativeVerificationInputSchema.shape.limits,
|
||||
unknown_registry_approved:
|
||||
managedNativeVerificationInputSchema.shape.unknown_registry_approved,
|
||||
})
|
||||
@@ -97,9 +93,7 @@ export const managedNativeVerificationReferenceInputSchema = z
|
||||
}
|
||||
});
|
||||
|
||||
const managedApplicationGraphReferenceFacts = {
|
||||
limits: projectManagedApplicationGraphInputSchema.shape.limits,
|
||||
} as const;
|
||||
const managedApplicationGraphReferenceFacts = {} as const;
|
||||
|
||||
/** MCP references requiring at least one managed Evidence source. */
|
||||
export const managedApplicationGraphReferenceInputSchema = z
|
||||
@@ -176,7 +170,6 @@ export const MANAGED_WORKFLOW_TOOL_CONTRACTS = [
|
||||
left_evidence_id: MANAGED_MEMBER_COMPARISON_EXAMPLE.left.evidence_id,
|
||||
right_evidence_id:
|
||||
MANAGED_MEMBER_COMPARISON_EXAMPLE.right.evidence_id,
|
||||
limits: MANAGED_MEMBER_COMPARISON_EXAMPLE.limits,
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -199,7 +192,6 @@ export const MANAGED_WORKFLOW_TOOL_CONTRACTS = [
|
||||
MANAGED_NATIVE_VERIFICATION_EXAMPLE.native_observations.map(
|
||||
({ evidence_id: evidenceId }) => evidenceId,
|
||||
),
|
||||
limits: MANAGED_NATIVE_VERIFICATION_EXAMPLE.limits,
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -262,7 +254,6 @@ export const MANAGED_WORKFLOW_TOOL_CONTRACTS = [
|
||||
input: {
|
||||
managed_members_evidence_id:
|
||||
MANAGED_APPLICATION_GRAPH_EXAMPLE.managed_members.evidence_id,
|
||||
limits: MANAGED_APPLICATION_GRAPH_EXAMPLE.limits,
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -54,11 +54,7 @@ export const NATIVE_TOOL_CONTRACTS = [
|
||||
"inspect_plist",
|
||||
"Parse a plist at a bounded relative path beneath the active artifact container. Symlink and traversal escapes are rejected; output is normalized JSON rather than plutil text.",
|
||||
z.object({
|
||||
relative_path: z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(1_024)
|
||||
.default("Contents/Info.plist"),
|
||||
relative_path: z.string().min(1).default("Contents/Info.plist"),
|
||||
}),
|
||||
),
|
||||
native(
|
||||
@@ -70,7 +66,7 @@ export const NATIVE_TOOL_CONTRACTS = [
|
||||
"demangle_swift",
|
||||
"Demangle an ordered bounded batch of Swift symbols without requiring Hopper. Each input returns demangled, unchanged, or invalid status.",
|
||||
z.object({
|
||||
symbols: z.array(z.string().min(1).max(4_096)).min(1).max(500),
|
||||
symbols: z.array(z.string().min(1)).min(1),
|
||||
}),
|
||||
),
|
||||
] as const satisfies readonly ToolContract[];
|
||||
|
||||
@@ -149,9 +149,9 @@ export const PROMPT_CONTRACTS = [
|
||||
"Build function dossiers and corroborate references and call relationships. Keep indirect or truncated paths unknown.",
|
||||
},
|
||||
{
|
||||
tools: ["snapshot_evidence_bundle", "record_unknown"],
|
||||
tools: ["get_evidence_bundle", "record_unknown"],
|
||||
instruction:
|
||||
"Snapshot the canonical bundle, copy its opaque URI unchanged, and read that resource before citing retained Evidence IDs. Record residual unknowns only after separate explicit approval for registry mutation.",
|
||||
"Snapshot the current Evidence bundle when a durable export is useful, then cite the Evidence IDs you used. Record residual unknowns when the evidence does not settle a material question.",
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -198,9 +198,9 @@ export const PROMPT_CONTRACTS = [
|
||||
"For JavaScript/Electron versions, reconstruct each approved artifact independently, optionally reconcile separately retained passive runtime Evidence, then compare authenticated graphs with unique-only identity tiers. Keep ambiguous and incomplete matches unknown.",
|
||||
},
|
||||
{
|
||||
tools: ["snapshot_evidence_bundle", "compare_artifacts"],
|
||||
tools: ["get_evidence_bundle", "compare_artifacts"],
|
||||
instruction:
|
||||
"Snapshot and read the canonical bundle through its exact resource URI, resolve any supplied manifest IDs to retained inventory Evidence, validate graph commitments, then compare the complete left and right Evidence page sets.",
|
||||
"Read the complete session bundle inline, resolve supplied manifest IDs to inventory Evidence, validate graph commitments, then compare the complete left and right Evidence page sets.",
|
||||
},
|
||||
{
|
||||
tools: ["open_binary", "analyze_function", "compare_functions"],
|
||||
@@ -241,9 +241,9 @@ export const PROMPT_CONTRACTS = [
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
tools: ["snapshot_evidence_bundle"],
|
||||
tools: ["get_evidence_bundle"],
|
||||
instruction:
|
||||
"Snapshot the current canonical bundle, copy its opaque URI unchanged, read the resource, and verify that every selected comparison Evidence ID is present and compatible with the intended claim.",
|
||||
"Check that every selected comparison Evidence ID is present and compatible with the intended claim.",
|
||||
},
|
||||
{
|
||||
tools: [
|
||||
@@ -270,7 +270,7 @@ export const PROMPT_CONTRACTS = [
|
||||
name: "trace_crash",
|
||||
title: "Trace a crash",
|
||||
description:
|
||||
"Correlate a crash symptom with bounded static call and reference evidence plus optional approved Process Capture v4 observations.",
|
||||
"Correlate a crash symptom with bounded static call and reference evidence plus optional approved process capture observations.",
|
||||
objective:
|
||||
"Localize plausible crash paths while separating observed runtime failure, static reachability, inferred causality, and unobserved paths.",
|
||||
arguments: {
|
||||
@@ -286,7 +286,7 @@ export const PROMPT_CONTRACTS = [
|
||||
"procedure",
|
||||
),
|
||||
capture_evidence_id: optional(
|
||||
"Retained Process Capture v4 Evidence for the crash",
|
||||
"Retained process capture Evidence for the crash",
|
||||
"capture",
|
||||
),
|
||||
},
|
||||
@@ -313,12 +313,12 @@ export const PROMPT_CONTRACTS = [
|
||||
},
|
||||
{
|
||||
tools: [
|
||||
"snapshot_evidence_bundle",
|
||||
"get_evidence_bundle",
|
||||
"capture_process_scenario",
|
||||
"correlate_static_and_runtime",
|
||||
],
|
||||
instruction:
|
||||
"Snapshot and read retained Evidence through the exact resource URI. Reuse a retained capture when supplied. Otherwise capture only after operator policy and per-call approval, then correlate through explicit hypotheses rather than timing or name coincidence.",
|
||||
"Read retained Evidence inline. Reuse a retained capture when supplied. Otherwise capture only after operator policy and per-call approval, then correlate through explicit hypotheses rather than timing or name coincidence.",
|
||||
},
|
||||
{
|
||||
tools: ["record_unknown"],
|
||||
@@ -354,9 +354,9 @@ export const PROMPT_CONTRACTS = [
|
||||
"List current heads first and select only active, session-owned unknown IDs. Preserve their exact revision and requirements.",
|
||||
},
|
||||
{
|
||||
tools: ["snapshot_evidence_bundle", "verify_unknown_resolution"],
|
||||
tools: ["get_evidence_bundle", "verify_unknown_resolution"],
|
||||
instruction:
|
||||
"Snapshot and read the canonical bundle through its exact resource URI, inspect cited supporting, contradicting, and mutation Evidence, then validate any resolved head against bundle integrity and authority requirements.",
|
||||
"Read the canonical bundle inline, inspect cited supporting, contradicting, and mutation Evidence, then validate any resolved head against bundle integrity and authority requirements.",
|
||||
},
|
||||
{
|
||||
tools: ["update_unknown"],
|
||||
@@ -374,7 +374,7 @@ export const PROMPT_CONTRACTS = [
|
||||
name: "prepare_bounded_process_capture",
|
||||
title: "Prepare a bounded process capture",
|
||||
description:
|
||||
"Design an approval-gated Process Capture v4 scenario with exact executable, filesystem, environment, network, replay, timeout, and cleanup boundaries.",
|
||||
"Design an approval-gated process capture scenario with exact executable, filesystem, environment, network, replay, timeout, and cleanup boundaries.",
|
||||
objective:
|
||||
"Prepare and, only after authorization, run the smallest controlled process experiment that can answer the stated behavioral question.",
|
||||
arguments: {
|
||||
@@ -388,7 +388,7 @@ export const PROMPT_CONTRACTS = [
|
||||
"Absolute working directory requested for the scenario",
|
||||
),
|
||||
prior_capture_evidence_id: optional(
|
||||
"Retained Process Capture v4 Evidence to compare or refine",
|
||||
"Retained process capture Evidence to compare or refine",
|
||||
"capture",
|
||||
),
|
||||
},
|
||||
@@ -399,9 +399,9 @@ export const PROMPT_CONTRACTS = [
|
||||
"Inspect capture capability, declared effects, and limits before proposing execution. An unavailable capability is not permission to widen policy.",
|
||||
},
|
||||
{
|
||||
tools: ["snapshot_evidence_bundle"],
|
||||
tools: ["get_evidence_bundle"],
|
||||
instruction:
|
||||
"Snapshot and read the canonical bundle through its exact resource URI, then review any prior capture for unanswered dimensions, truncation, scenario commitments, and descendant settlement before designing a repeat.",
|
||||
"Read the canonical bundle inline, then review any prior capture for unanswered dimensions, truncation, scenario commitments, and descendant settlement before designing a repeat.",
|
||||
},
|
||||
{
|
||||
tools: ["capture_process_scenario"],
|
||||
@@ -411,7 +411,7 @@ export const PROMPT_CONTRACTS = [
|
||||
{
|
||||
tools: ["compare_process_captures"],
|
||||
instruction:
|
||||
"When a prior compatible capture exists, compare complete Process Capture v4 observations under recorded normalization and freshness requirements.",
|
||||
"When a prior compatible capture exists, compare complete process capture observations under recorded normalization and freshness requirements.",
|
||||
},
|
||||
{
|
||||
tools: ["record_unknown"],
|
||||
|
||||
@@ -4,7 +4,6 @@ import { z } from "zod";
|
||||
export const analysisProviderIdSchema = z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(64)
|
||||
.regex(/^[a-z][a-z0-9-]*$/u)
|
||||
.refine((value) => value !== "auto", {
|
||||
message: "auto is reserved for provider selection",
|
||||
|
||||
@@ -72,7 +72,6 @@ const EVIDENCE_STATES = [
|
||||
|
||||
/** Complete synthetic input shared by docs, tests, CLI, MCP, and verifier. */
|
||||
export const RECONSTRUCTION_READINESS_EXAMPLE: ReconstructionReadinessInput = {
|
||||
schema_version: 1,
|
||||
identity: {
|
||||
cli_version: "2.4.0",
|
||||
server_version: "2.4.0",
|
||||
@@ -220,15 +219,11 @@ export const RECONSTRUCTION_READINESS_EXAMPLE: ReconstructionReadinessInput = {
|
||||
],
|
||||
obligation_ledger: {
|
||||
schema: "ReconstructionObligationLedger",
|
||||
schema_version: 1,
|
||||
ledger_id: `rol_${HASH}`,
|
||||
closure_digest: HASH,
|
||||
status: "ready",
|
||||
coverage: {
|
||||
status: "complete",
|
||||
truncated: false,
|
||||
omitted_count: 0,
|
||||
max_obligations: 100,
|
||||
},
|
||||
summary: {
|
||||
total: 1,
|
||||
|
||||
@@ -1,26 +1,7 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { TOOL_KINDS } from "./toolContractTypes.js";
|
||||
|
||||
/** Caller observations and projection controls for binary_session. */
|
||||
/** Optional expectations used to compare the live session with its caller. */
|
||||
export const binarySessionInputSchema = z.object({
|
||||
detail: z
|
||||
.enum(["summary", "capabilities", "full"])
|
||||
.default("summary")
|
||||
.describe(
|
||||
"summary returns routing state; capabilities returns one filtered tool-availability page; full returns complete diagnostics only when required",
|
||||
),
|
||||
capability_family: z
|
||||
.enum(TOOL_KINDS)
|
||||
.optional()
|
||||
.describe("Optional tool family for detail=capabilities"),
|
||||
cursor: z
|
||||
.number()
|
||||
.int()
|
||||
.min(0)
|
||||
.default(0)
|
||||
.describe("Zero-based capability cursor for detail=capabilities"),
|
||||
limit: z.number().int().min(1).max(100).default(25),
|
||||
expected_package_version: z.string().min(1).optional(),
|
||||
expected_catalog_digest: z
|
||||
.string()
|
||||
|
||||
@@ -19,13 +19,8 @@ import {
|
||||
} from "./sessionLifecycleInputs.js";
|
||||
import { binarySessionInputSchema } from "./sessionStatusContract.js";
|
||||
|
||||
/** Retain the current canonical Evidence bundle as a session resource. */
|
||||
export const snapshotEvidenceBundleInputSchema = z.strictObject({});
|
||||
|
||||
/** Release one session-retained immutable Evidence bundle. */
|
||||
export const releaseEvidenceBundleInputSchema = z.strictObject({
|
||||
bundle_digest: z.string().regex(/^[a-f0-9]{64}$/u),
|
||||
});
|
||||
/** Return the current canonical Evidence bundle inline. */
|
||||
export const getEvidenceBundleInputSchema = z.strictObject({});
|
||||
|
||||
/** Optional document selection for volatile navigation context. */
|
||||
export const navigationContextInputSchema = z.strictObject({
|
||||
@@ -61,9 +56,7 @@ export const listUnknownsInputSchema = z.strictObject({
|
||||
.enum(["open", "investigating", "blocked", "contradicted", "resolved"])
|
||||
.optional(),
|
||||
severity: z.enum(["low", "medium", "high", "critical"]).optional(),
|
||||
domain: z.string().trim().min(1).max(100).optional(),
|
||||
offset: z.number().int().min(0).default(0),
|
||||
limit: z.number().int().min(1).max(500).default(100),
|
||||
domain: z.string().trim().min(1).optional(),
|
||||
});
|
||||
|
||||
/** Exact residual-unknown identity to revalidate. */
|
||||
|
||||
@@ -43,7 +43,6 @@ export const TOOL_EXAMPLE_OVERRIDES: Readonly<
|
||||
export_evidence_bundle: { path: "/tmp/evidence.json" },
|
||||
inspect_address_context: { address: "0x1000" },
|
||||
import_evidence_bundle: { path: "evidence.json" },
|
||||
release_evidence_bundle: { bundle_digest: "a".repeat(64) },
|
||||
capture_process_scenario: {
|
||||
approved: true,
|
||||
executable: "/usr/bin/true",
|
||||
@@ -59,8 +58,8 @@ export const TOOL_EXAMPLE_OVERRIDES: Readonly<
|
||||
right_evidence_ids: [ARTIFACT_COMPARISON_EXAMPLE.right.evidence_id],
|
||||
},
|
||||
compare_functions: {
|
||||
left_evidence_ids: [FUNCTION_COMPARISON_EXAMPLE.left.evidence_id],
|
||||
right_evidence_ids: [FUNCTION_COMPARISON_EXAMPLE.right.evidence_id],
|
||||
left_evidence_id: FUNCTION_COMPARISON_EXAMPLE.left.evidence_id,
|
||||
right_evidence_id: FUNCTION_COMPARISON_EXAMPLE.right.evidence_id,
|
||||
},
|
||||
compare_bundles: {
|
||||
left_bundle_path: "/approved/left-evidence.json",
|
||||
|
||||
@@ -12,11 +12,6 @@ export const address = z
|
||||
);
|
||||
export const optionalAddress = address.optional();
|
||||
export const procedure = z.string().describe("The procedure name or address");
|
||||
export const pagination = {
|
||||
offset: z.number().int().min(0).default(0),
|
||||
limit: z.number().int().min(1).max(500).default(100),
|
||||
};
|
||||
|
||||
const exampleInputSchema = z.record(z.string(), jsonValueSchema);
|
||||
|
||||
export const examplesFor = (
|
||||
|
||||
@@ -87,8 +87,7 @@ describe("tool contract inventory", () => {
|
||||
"update_unknown",
|
||||
"verify_unknown_resolution",
|
||||
"run_replay_machine",
|
||||
"snapshot_evidence_bundle",
|
||||
"release_evidence_bundle",
|
||||
"get_evidence_bundle",
|
||||
"get_navigation_context",
|
||||
"inspect_address_context",
|
||||
]);
|
||||
@@ -96,27 +95,4 @@ describe("tool contract inventory", () => {
|
||||
TOOL_CONTRACTS.length,
|
||||
);
|
||||
});
|
||||
|
||||
it("retains documented enhanced-tool limits at the input boundary", () => {
|
||||
const batch = ENHANCED_TOOL_CONTRACTS.find(
|
||||
({ name }) => name === "batch_decompile",
|
||||
);
|
||||
const graph = ENHANCED_TOOL_CONTRACTS.find(
|
||||
({ name }) => name === "get_call_graph",
|
||||
);
|
||||
|
||||
expect(
|
||||
batch?.inputSchema.safeParse({
|
||||
addresses: Array.from({ length: 21 }, () => "0x1"),
|
||||
}).success,
|
||||
).toBe(false);
|
||||
expect(
|
||||
graph?.inputSchema.safeParse({ address: "0x1", depth: 6 }).success,
|
||||
).toBe(false);
|
||||
expect(graph?.inputSchema.parse({ address: "0x1" })).toEqual({
|
||||
address: "0x1",
|
||||
depth: 2,
|
||||
direction: "forward",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -31,9 +31,8 @@ import {
|
||||
processScenarioSchema,
|
||||
reconstructionVerificationInputSchema,
|
||||
recordUnknownInputSchema,
|
||||
releaseEvidenceBundleInputSchema,
|
||||
replayMachineRunInputSchema,
|
||||
snapshotEvidenceBundleInputSchema,
|
||||
getEvidenceBundleInputSchema,
|
||||
staticRuntimeCorrelationInputSchema,
|
||||
updateUnknownInputSchema,
|
||||
verifyUnknownResolutionInputSchema,
|
||||
@@ -43,7 +42,6 @@ import {
|
||||
document,
|
||||
examplesFor,
|
||||
optionalAddress,
|
||||
pagination,
|
||||
procedure,
|
||||
} from "./toolContractHelpers.js";
|
||||
import type { ToolContract } from "./toolContractTypes.js";
|
||||
@@ -60,8 +58,7 @@ export {
|
||||
listUnknownsInputSchema,
|
||||
navigationContextInputSchema,
|
||||
processComparisonInputSchema,
|
||||
releaseEvidenceBundleInputSchema,
|
||||
snapshotEvidenceBundleInputSchema,
|
||||
getEvidenceBundleInputSchema,
|
||||
verifyUnknownResolutionInputSchema,
|
||||
} from "./sessionToolSchemas.js";
|
||||
|
||||
@@ -170,13 +167,13 @@ export const OFFICIAL_TOOL_CONTRACTS = [
|
||||
),
|
||||
official(
|
||||
"list_names",
|
||||
"Page through analyzed memory and external symbols as address/value pairs. Provider metadata distinguishes Ghidra primary, dynamic, external, type, and source facts when available; follow next_offset before claiming exhaustive coverage.",
|
||||
z.object({ document, address: optionalAddress, ...pagination }),
|
||||
"List every analyzed memory and external symbol as address/value pairs. Provider metadata distinguishes Ghidra primary, dynamic, external, type, and source facts when available.",
|
||||
z.object({ document, address: optionalAddress }),
|
||||
),
|
||||
official(
|
||||
"list_procedures",
|
||||
"Page through analyzed procedures as address/value pairs after provider analysis. Ghidra metadata distinguishes thunks and external functions; follow next_offset for exhaustive coverage and use returned addresses in later function operations.",
|
||||
z.object({ document, ...pagination }),
|
||||
"List every analyzed procedure as address/value pairs after provider analysis. Ghidra metadata distinguishes thunks and external functions; use returned addresses in later function operations.",
|
||||
z.object({ document }),
|
||||
),
|
||||
official(
|
||||
"list_segments",
|
||||
@@ -185,8 +182,8 @@ export const OFFICIAL_TOOL_CONTRACTS = [
|
||||
),
|
||||
official(
|
||||
"list_strings",
|
||||
"Page through provider-defined strings, or filter to one address, as address/value pairs. Ghidra reports charset, missing-terminator status, byte length, and explicit value truncation; follow next_offset for exhaustive results.",
|
||||
z.object({ document, address: optionalAddress, ...pagination }),
|
||||
"List every provider-defined string, or filter to one address, as address/value pairs. Ghidra reports charset, missing-terminator status, byte length, and explicit value truncation.",
|
||||
z.object({ document, address: optionalAddress }),
|
||||
),
|
||||
official(
|
||||
"next_address",
|
||||
@@ -225,7 +222,7 @@ export const OFFICIAL_TOOL_CONTRACTS = [
|
||||
),
|
||||
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.",
|
||||
"Read every raw instruction for an analyzed procedure without decompilation, caller discovery, or whole-program string/name scans. Instruction text is provider-specific.",
|
||||
functionInstructionInputSchema,
|
||||
),
|
||||
...HOPPER_MEMORY_TOOL_DEFINITIONS.map(({ name, description, inputSchema }) =>
|
||||
@@ -233,13 +230,10 @@ export const OFFICIAL_TOOL_CONTRACTS = [
|
||||
),
|
||||
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.",
|
||||
"Return every raw incoming or outgoing reference edge for one procedure. Endpoint procedures are resolved only from provider containment; Ghidra preserves observed reference kinds while providers without kind authority mark them unavailable.",
|
||||
z.object({
|
||||
procedure,
|
||||
direction: z.enum(["incoming", "outgoing"]).default("outgoing"),
|
||||
offset: z.number().int().min(0).default(0),
|
||||
limit: z.number().int().min(1).max(500).default(100),
|
||||
max_instructions: z.number().int().min(1).max(5000).default(500),
|
||||
document,
|
||||
}),
|
||||
),
|
||||
@@ -255,12 +249,12 @@ export const OFFICIAL_TOOL_CONTRACTS = [
|
||||
),
|
||||
official(
|
||||
"search_procedures",
|
||||
"Search analyzed procedure names using literal matching by default or regex opt-in. Providers bound search work and reject regex constructs, paths, candidates, or cumulative work outside their finite budgets. Results are deterministic and offset-paginated.",
|
||||
"Search every analyzed procedure name using literal matching by default or regex when requested. Results are deterministic and complete.",
|
||||
z.object(analysisSearchInput),
|
||||
),
|
||||
official(
|
||||
"search_strings",
|
||||
"Search analyzed strings using literal matching by default or regex opt-in. Providers bound search work and reject regex constructs, paths, candidates, or cumulative work outside their finite budgets. Results are deterministic, offset-paginated, and explicitly truncated.",
|
||||
"Search every analyzed string using literal matching by default or regex when requested. Results are deterministic and complete.",
|
||||
z.object(analysisSearchInput),
|
||||
),
|
||||
official(
|
||||
@@ -312,32 +306,32 @@ export type OfficialToolName = (typeof OFFICIAL_TOOL_CONTRACTS)[number]["name"];
|
||||
export const ENHANCED_TOOL_CONTRACTS = [
|
||||
enhanced(
|
||||
"swift_classes",
|
||||
"Discover legacy-mangled Swift class procedures after exhaustively paging analyzed procedures. Returns at most 100 entries and scans at most 5,000 symbols; use analyze_swift_types for other Swift kinds.",
|
||||
"Discover legacy-mangled Swift class procedures by scanning analyzed procedures; returns every matching entry. Use analyze_swift_types for other Swift kinds.",
|
||||
enhancedInputSchemas.swift_classes,
|
||||
),
|
||||
enhanced(
|
||||
"get_objc_classes",
|
||||
"Discover and deduplicate Objective-C class labels after exhaustively paging names, optionally filtering by literal substring. Returns at most 100 classes; inspect matching metadata and references next.",
|
||||
"Discover and deduplicate every Objective-C class label, optionally filtering by literal substring; inspect matching metadata and references next.",
|
||||
enhancedInputSchemas.get_objc_classes,
|
||||
),
|
||||
enhanced(
|
||||
"get_objc_protocols",
|
||||
"Discover and deduplicate Objective-C and Swift protocol labels after exhaustively paging names. Returns at most 100 entries; use xrefs or analyze_function to connect a protocol to implementations.",
|
||||
"Discover and deduplicate every Objective-C and Swift protocol label; use xrefs or analyze_function to connect a protocol to implementations.",
|
||||
enhancedInputSchemas.get_objc_protocols,
|
||||
),
|
||||
enhanced(
|
||||
"batch_decompile",
|
||||
"Decompile up to 20 explicit procedure symbols or addresses concurrently. Returns ordered per-item ok/error variants and aggregate counts; use analyze_function for a richer single-function dossier.",
|
||||
"Decompile each explicit procedure symbol or address concurrently. Returns ordered per-item ok/error variants and aggregate counts; use analyze_function for a richer single-function dossier.",
|
||||
enhancedInputSchemas.batch_decompile,
|
||||
),
|
||||
enhanced(
|
||||
"get_call_graph",
|
||||
"Traverse the bound provider's caller or callee relationships from one symbol or address for at most five levels. Every node has an ok/error status and failures use safe typed projections; unresolved indirect calls may be missing and results are not a whole-program CFG.",
|
||||
"Traverse the bound provider's caller or callee relationships from one symbol or address until the reachable graph is exhausted. Every node has an ok/error status and failures use safe typed projections; unresolved indirect calls may be missing and results are not a whole-program CFG.",
|
||||
enhancedInputSchemas.get_call_graph,
|
||||
),
|
||||
enhanced(
|
||||
"analyze_swift_types",
|
||||
"Categorize exhaustively paged procedure names into Swift classes, structs, enums, protocols, extensions, and other symbols. Scans at most 5,000 names and returns at most 50 entries per category.",
|
||||
"Categorize all analyzed procedure names into Swift classes, structs, enums, protocols, extensions, and other symbols.",
|
||||
enhancedInputSchemas.analyze_swift_types,
|
||||
),
|
||||
enhanced(
|
||||
@@ -347,23 +341,23 @@ export const ENHANCED_TOOL_CONTRACTS = [
|
||||
),
|
||||
enhanced(
|
||||
"binary_overview",
|
||||
"Use immediately after opening a target to summarize document, exhaustive procedure/string counts, and a bounded segment sample. detail controls segment fields and limit controls only the returned segment sample.",
|
||||
"Use immediately after opening a target to summarize the document, every segment with its length, and exhaustive procedure/string counts.",
|
||||
enhancedInputSchemas.binary_overview,
|
||||
),
|
||||
...FUNCTION_WORKFLOW_TOOL_CONTRACTS,
|
||||
enhanced(
|
||||
"trace_feature",
|
||||
"Trace a bounded literal feature query through matching strings and procedures, xrefs, and truthful containing-procedure resolution. Returns the operation budget, truncation, and residual unknowns; unknown_registry_approved: true records them durably without inferring reference kinds.",
|
||||
"Trace a literal feature query through every matching string and procedure, their xrefs, and truthful containing-procedure resolution. Returns observations, operation count, and residual unknowns; unknown_registry_approved: true records residual unknowns without inferring reference kinds.",
|
||||
enhancedInputSchemas.trace_feature,
|
||||
),
|
||||
enhanced(
|
||||
"find_code_for_string",
|
||||
"Resolve one literal string query to bounded analyzed string entries, xrefs, and truthful containing-procedure candidates. Returns an Evidence ID, exact operation budget, truncation, and residual unknowns; it never infers reference kinds or runtime reachability.",
|
||||
"Resolve one literal string query across analyzed string entries, xrefs, and truthful containing-procedure candidates. Returns observations, operation count, and residual unknowns; it never infers reference kinds or runtime reachability.",
|
||||
enhancedInputSchemas.find_code_for_string,
|
||||
),
|
||||
enhanced(
|
||||
"trace_call_path",
|
||||
"Trace a deterministic bounded caller or callee path from one exact procedure address, optionally stopping at a goal. Returns visited nodes, direct-call edges, one shortest traversal path, failures, frontier, consumed limits, an Evidence ID, and explicit residual unknowns without claiming unresolved indirect calls are absent.",
|
||||
"Trace direct callers or callees from one exact procedure address until the graph is exhausted or the optional goal is reached. Returns visited nodes, direct-call edges, a shortest traversal path, provider failures, and residual unknowns; unresolved indirect calls remain unknown.",
|
||||
enhancedInputSchemas.trace_call_path,
|
||||
),
|
||||
] as const satisfies readonly ToolContract[];
|
||||
@@ -388,12 +382,12 @@ export const SESSION_TOOL_CONTRACTS = [
|
||||
),
|
||||
session(
|
||||
"binary_session",
|
||||
"Report compact target, provider, and alignment state without starting analysis. The default summary is the routing check agents should use; detail=capabilities returns one family-filtered availability page, while detail=full is reserved for complete provider diagnostics.",
|
||||
"Report the complete current target, provider, capability availability, client-feature, analysis, and server-identity status without starting analysis.",
|
||||
binarySessionInputSchema,
|
||||
),
|
||||
session(
|
||||
"export_evidence_bundle",
|
||||
"Atomically write the session's deterministic Evidence v2 bundle beneath an operator-approved root. Existing files require overwrite: true; records and manifests use canonical byte-stable ordering. For an in-session read, use snapshot_evidence_bundle and read its exact resource URI instead.",
|
||||
"Atomically write the session's deterministic Evidence bundle to the requested local path. Existing files require overwrite: true; records and manifests use canonical byte-stable ordering.",
|
||||
exportEvidenceBundleInputSchema,
|
||||
),
|
||||
session(
|
||||
@@ -403,12 +397,12 @@ export const SESSION_TOOL_CONTRACTS = [
|
||||
),
|
||||
session(
|
||||
"capture_process_scenario",
|
||||
"Run one bounded process under a PTY using operator-approved executable and working roots. Produces Process Capture v4; legacy v3 captures cannot be upgraded and must be recaptured with this tool. Requires approved: true; unknown_registry_approved: true separately records capture residuals. Captures raw and xterm-rendered terminal frames, scripted interactions, lifecycle filesystem checkpoints, process ownership, declarative command shims, and loopback replay. Disabled unless operator policy enables it; not a security sandbox.",
|
||||
"Run one bounded process under a PTY using operator-approved executable and working roots. Produces process capture Evidence. Requires approved: true; unknown_registry_approved: true separately records capture residuals. Captures raw and xterm-rendered terminal frames, scripted interactions, lifecycle filesystem checkpoints, process ownership, declarative command shims, and loopback replay. Disabled unless operator policy enables it; not a security sandbox.",
|
||||
processScenarioSchema,
|
||||
),
|
||||
session(
|
||||
"compare_process_captures",
|
||||
"Compare two compatible Process Capture v4 observations across terminal, interaction, lifecycle, process, filesystem, command-shim, HTTP, and WebSocket evidence. Optional trace_spec validates exact events against an explicit partial order or finite trace language; concurrency is never inferred from timestamps or broad sorting. Missing, journal-free, or truncated observations are never treated as equivalent.",
|
||||
"Compare two compatible process capture observations across terminal, interaction, lifecycle, process, filesystem, command-shim, HTTP, and WebSocket evidence. Optional trace_spec validates exact events against an explicit partial order or finite trace language; concurrency is never inferred from timestamps or broad sorting. Missing, journal-free, or truncated observations are never treated as equivalent.",
|
||||
processComparisonInputSchema,
|
||||
),
|
||||
session(
|
||||
@@ -433,7 +427,7 @@ export const SESSION_TOOL_CONTRACTS = [
|
||||
),
|
||||
session(
|
||||
"build_call_path",
|
||||
"Build bounded shortest-first direct-callee paths from explicit analyze_function Evidence groups using exact canonical addresses. Missing dossiers, incomplete callee pages, provider mixing, and depth frontiers remain unknown; every node and edge cites source Evidence.",
|
||||
"Build every shortest direct-callee path inline from complete analyze_function Evidence records using exact canonical addresses. Missing dossiers and provider mixing remain unknown; every node and edge cites source Evidence.",
|
||||
callPathInputSchema,
|
||||
),
|
||||
session(
|
||||
@@ -448,7 +442,7 @@ export const SESSION_TOOL_CONTRACTS = [
|
||||
),
|
||||
session(
|
||||
"list_unknowns",
|
||||
"List current residual-unknown heads in deterministic ID order, with optional exact status, severity, and domain filters. Pages default to 100 items; while has_more is true, pass next_offset as offset and continue until false. This is read-only; unresolved, contradicted, and non-truth dispositions remain distinct.",
|
||||
"List every current residual-unknown head in deterministic ID order, with optional exact status, severity, and domain filters. Results are complete and inline. This is read-only; unresolved, contradicted, and non-truth dispositions remain distinct.",
|
||||
listUnknownsInputSchema,
|
||||
),
|
||||
session(
|
||||
@@ -472,14 +466,9 @@ export const SESSION_TOOL_CONTRACTS = [
|
||||
replayMachineRunInputSchema,
|
||||
),
|
||||
session(
|
||||
"snapshot_evidence_bundle",
|
||||
"Retain the current canonical Evidence v2 bundle as an immutable session resource. Returns a compact digest summary and exact opaque URI; copy that URI unchanged and call MCP resources/read (Codex: read_mcp_resource) for the full bundle. Repeating an unchanged snapshot is idempotent.",
|
||||
snapshotEvidenceBundleInputSchema,
|
||||
),
|
||||
session(
|
||||
"release_evidence_bundle",
|
||||
"Release one immutable session-retained Evidence v2 bundle by exact digest. This is the recovery operation when bounded bundle retention is exhausted; releasing an unknown digest is idempotent and reports released: false.",
|
||||
releaseEvidenceBundleInputSchema,
|
||||
"get_evidence_bundle",
|
||||
"Return every Evidence record and residual unknown currently retained by this session as one inline bundle for direct inspection or follow-up workflows.",
|
||||
getEvidenceBundleInputSchema,
|
||||
),
|
||||
session(
|
||||
"get_navigation_context",
|
||||
|
||||
@@ -182,11 +182,7 @@ export const TOOL_EFFECTS: Readonly<Record<string, ToolEffects>> = {
|
||||
writesFilesystem: true,
|
||||
mayDiscardData: true,
|
||||
}),
|
||||
snapshot_evidence_bundle: effects({ mutatesSession: true }),
|
||||
release_evidence_bundle: effects({
|
||||
mutatesSession: true,
|
||||
mayDiscardData: true,
|
||||
}),
|
||||
get_evidence_bundle: effects(),
|
||||
get_navigation_context: effects({ mutatesSession: true }),
|
||||
inspect_address_context: effects({ mutatesSession: true }),
|
||||
import_evidence_bundle: effects({ mutatesSession: true }),
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { z } from "zod";
|
||||
import { jsonValueSchema } from "../domain/jsonValue.js";
|
||||
import { residualUnknownSchema } from "../domain/residualUnknown.js";
|
||||
import { evidenceBundleSchema } from "../domain/evidenceBundle.js";
|
||||
|
||||
import {
|
||||
processCaptureComparisonSchema,
|
||||
processCaptureSchema,
|
||||
} from "../domain/processCapture.js";
|
||||
import { residualUnknownSchema } from "../domain/residualUnknown.js";
|
||||
import {
|
||||
functionInstructionWindowSchema,
|
||||
referenceKindSchema,
|
||||
@@ -44,24 +45,18 @@ import { replayMachineRunOutputSchema } from "../domain/replayMachineRun.js";
|
||||
import { analysisErrorProjectionSchema } from "./errorSchemas.js";
|
||||
import {
|
||||
addressList,
|
||||
addressedValue,
|
||||
addressedEntry,
|
||||
analysisActivity,
|
||||
bounded,
|
||||
containingProcedureResolution,
|
||||
clientFeatureAvailabilitySchema,
|
||||
functionDossierOutput,
|
||||
graphNode,
|
||||
lifecycleResultOf,
|
||||
nullableText,
|
||||
pageOutput,
|
||||
procedureIdentity,
|
||||
procedureInfoOutput,
|
||||
evidenceResultOf as resultOf,
|
||||
searchPageOutput,
|
||||
segmentOutput,
|
||||
sessionProvider,
|
||||
providerIdentity,
|
||||
toolAvailability,
|
||||
symbolDiscoveryOutput,
|
||||
targetFormatSchema,
|
||||
targetKindSchema,
|
||||
@@ -95,10 +90,10 @@ export const officialOutputSchemas: Readonly<Record<string, z.ZodObject>> = {
|
||||
inline_comment: resultOf(nullableText),
|
||||
list_bookmarks: resultOf(z.array(addressedEntry)),
|
||||
list_documents: resultOf(z.array(z.string())),
|
||||
list_names: resultOf(pageOutput),
|
||||
list_procedures: resultOf(pageOutput),
|
||||
list_names: resultOf(z.array(addressedValue)),
|
||||
list_procedures: resultOf(z.array(addressedValue)),
|
||||
list_segments: segmentOutput,
|
||||
list_strings: resultOf(pageOutput),
|
||||
list_strings: resultOf(z.array(addressedValue)),
|
||||
next_address: resultOf(z.string()),
|
||||
prev_address: resultOf(z.string()),
|
||||
procedure_address: resultOf(z.string()),
|
||||
@@ -126,7 +121,7 @@ export const officialOutputSchemas: Readonly<Record<string, z.ZodObject>> = {
|
||||
z.object({
|
||||
procedure: procedureIdentity,
|
||||
direction: z.enum(["incoming", "outgoing"]),
|
||||
references: bounded(
|
||||
references: z.array(
|
||||
z.object({
|
||||
source_address: z.string(),
|
||||
target_address: z.string(),
|
||||
@@ -135,14 +130,16 @@ export const officialOutputSchemas: Readonly<Record<string, z.ZodObject>> = {
|
||||
kind: referenceKindSchema,
|
||||
}),
|
||||
),
|
||||
instructions_scanned: z.number().int().min(0),
|
||||
instruction_scan_truncated: z.boolean(),
|
||||
}),
|
||||
),
|
||||
procedure_pseudo_code: resultOf(nullableText),
|
||||
resolve_containing_procedure: resultOf(containingProcedureResolution),
|
||||
search_procedures: resultOf(searchPageOutput),
|
||||
search_strings: resultOf(searchPageOutput),
|
||||
search_procedures: resultOf(
|
||||
z.array(z.object({ address: z.string(), value: z.string() })),
|
||||
),
|
||||
search_strings: resultOf(
|
||||
z.array(z.object({ address: z.string(), value: z.string() })),
|
||||
),
|
||||
set_address_name: resultOf(z.boolean()),
|
||||
set_addresses_names: resultOf(z.record(z.string(), z.boolean())),
|
||||
set_bookmark: resultOf(z.boolean()),
|
||||
@@ -157,8 +154,6 @@ const literalTraceOutput = resultOf(
|
||||
z.object({
|
||||
query: z.string(),
|
||||
search_mode: z.literal("literal"),
|
||||
operations_used: z.number().int().min(0),
|
||||
operation_budget: z.number().int().min(1),
|
||||
matches: z.array(
|
||||
z.object({
|
||||
type: z.enum(["string", "procedure"]),
|
||||
@@ -204,13 +199,8 @@ const callPathTraceOutput = resultOf(
|
||||
error: analysisErrorProjectionSchema,
|
||||
}),
|
||||
),
|
||||
frontier: z.array(z.string()),
|
||||
limits: z.object({
|
||||
max_depth: z.number().int().min(1),
|
||||
max_nodes: z.number().int().min(1),
|
||||
max_operations: z.number().int().min(1),
|
||||
traversal: z.object({
|
||||
nodes_visited: z.number().int().min(1),
|
||||
operations_used: z.number().int().min(0),
|
||||
}),
|
||||
truncated: z.boolean(),
|
||||
residual_unknowns: z.array(z.string()),
|
||||
@@ -275,13 +265,12 @@ export const enhancedOutputSchemas: Readonly<Record<string, z.ZodObject>> = {
|
||||
binary_overview: resultOf(
|
||||
z.object({
|
||||
document: z.string(),
|
||||
detail: z.enum(["concise", "detailed"]),
|
||||
segments: z.array(
|
||||
z.object({
|
||||
name: z.string(),
|
||||
start: z.string(),
|
||||
end: z.string(),
|
||||
length: z.number().min(0).optional(),
|
||||
length: z.number().min(0),
|
||||
}),
|
||||
),
|
||||
segment_count: z.number().int().min(0),
|
||||
@@ -364,51 +353,11 @@ export const sessionOutputSchemas: Readonly<Record<string, z.ZodObject>> = {
|
||||
),
|
||||
binary_session: lifecycleResultOf(
|
||||
z.union([
|
||||
z.object({
|
||||
view: z.literal("summary"),
|
||||
open: z.boolean(),
|
||||
provider: providerIdentity,
|
||||
active_provider: providerIdentity.nullable(),
|
||||
target: z
|
||||
.object({
|
||||
path: z.string(),
|
||||
format: targetFormatSchema,
|
||||
kind: targetKindSchema,
|
||||
sha256: z.string().regex(/^[a-f0-9]{64}$/u),
|
||||
architecture: z.enum(["x86", "x86_64", "arm", "arm64"]).nullable(),
|
||||
})
|
||||
.nullable(),
|
||||
alignment: z.object({
|
||||
state: z.enum(["aligned", "mcp_server_restart_required", "unknown"]),
|
||||
reasons: z.array(z.string()),
|
||||
remediation: z.string().nullable(),
|
||||
}),
|
||||
analysis_activity: analysisActivity,
|
||||
recommended_actions: z.array(z.string()),
|
||||
}),
|
||||
z.object({
|
||||
view: z.literal("capabilities"),
|
||||
open: z.boolean(),
|
||||
provider: providerIdentity,
|
||||
active_provider: providerIdentity.nullable(),
|
||||
capability_family: z.string().nullable(),
|
||||
capabilities: z.object({
|
||||
items: z.array(toolAvailability),
|
||||
cursor: z.number().int().min(0),
|
||||
limit: z.number().int().min(1),
|
||||
total: z.number().int().min(0),
|
||||
next_cursor: z.number().int().min(0).nullable(),
|
||||
has_more: z.boolean(),
|
||||
}),
|
||||
client_features: clientFeatureAvailabilitySchema,
|
||||
}),
|
||||
z.union([
|
||||
sessionProvider.extend({
|
||||
view: z.literal("full"),
|
||||
open: z.literal(false),
|
||||
}),
|
||||
sessionProvider.extend({
|
||||
view: z.literal("full"),
|
||||
open: z.literal(true),
|
||||
path: z.string(),
|
||||
format: targetFormatSchema,
|
||||
@@ -427,24 +376,7 @@ export const sessionOutputSchemas: Readonly<Record<string, z.ZodObject>> = {
|
||||
unknowns: z.number().int().min(0),
|
||||
}),
|
||||
),
|
||||
snapshot_evidence_bundle: lifecycleResultOf(
|
||||
z.object({
|
||||
bundle_digest: z.string().regex(/^[a-f0-9]{64}$/u),
|
||||
bundle_version: z.literal(2),
|
||||
bytes: z.number().int().min(0),
|
||||
records: z.number().int().min(0),
|
||||
unknowns: z.number().int().min(0),
|
||||
scope: z.literal("session"),
|
||||
survives_session: z.literal(false),
|
||||
bundle_uri: z.string().regex(/^rea:\/\/evidence-bundle\/[a-f0-9]{64}$/u),
|
||||
}),
|
||||
),
|
||||
release_evidence_bundle: lifecycleResultOf(
|
||||
z.object({
|
||||
bundle_digest: z.string().regex(/^[a-f0-9]{64}$/u),
|
||||
released: z.boolean(),
|
||||
}),
|
||||
),
|
||||
get_evidence_bundle: lifecycleResultOf(evidenceBundleSchema),
|
||||
get_navigation_context: lifecycleResultOf(
|
||||
z.object({
|
||||
document: z.string(),
|
||||
@@ -481,17 +413,8 @@ export const sessionOutputSchemas: Readonly<Record<string, z.ZodObject>> = {
|
||||
verify_reconstruction: resultOf(reconstructionVerificationResultSchema),
|
||||
list_unknowns: lifecycleResultOf(
|
||||
z.object({
|
||||
items: z.array(
|
||||
z.object({
|
||||
unknown: residualUnknownSchema,
|
||||
uri: z.string().regex(/^rea:\/\/unknown\/unk_[a-f0-9]{64}$/u),
|
||||
}),
|
||||
),
|
||||
offset: z.number().int().min(0),
|
||||
limit: z.number().int().min(1).max(500),
|
||||
items: z.array(residualUnknownSchema),
|
||||
total: z.number().int().min(0),
|
||||
next_offset: z.number().int().min(0).nullable(),
|
||||
has_more: z.boolean(),
|
||||
}),
|
||||
),
|
||||
record_unknown: lifecycleResultOf(residualUnknownSchema),
|
||||
|
||||
@@ -7,18 +7,24 @@ import {
|
||||
functionDossierSchema,
|
||||
} from "../domain/hopperValues.js";
|
||||
import { analysisProfileSchema } from "../domain/analysisProfile.js";
|
||||
import { evidenceEnvelopeSchema } from "../domain/evidence.js";
|
||||
import { jsonValueSchema } from "../domain/jsonValue.js";
|
||||
import {
|
||||
PROVIDER_REJECTION_CODES,
|
||||
type ProviderRejectionCode,
|
||||
} from "./providerSelection.js";
|
||||
import { analysisErrorProjectionSchema } from "./errorSchemas.js";
|
||||
|
||||
/** Compact MCP result with an immutable link to complete session Evidence. */
|
||||
/** Inline result with its complete Evidence record. */
|
||||
export const inlineEvidenceRecordSchema = evidenceEnvelopeSchema.omit({
|
||||
normalized_result: true,
|
||||
});
|
||||
|
||||
export const evidenceResultOf = (schema: z.ZodType) =>
|
||||
z.strictObject({
|
||||
result: schema,
|
||||
evidence_id: z.string().regex(/^ev_[a-f0-9]{64}$/u),
|
||||
evidence_uri: z.string().regex(/^rea:\/\/evidence\/ev_[a-f0-9]{64}$/u),
|
||||
evidence: inlineEvidenceRecordSchema,
|
||||
});
|
||||
|
||||
const resultOf = evidenceResultOf;
|
||||
@@ -64,8 +70,6 @@ export const targetKindSchema = z.enum([
|
||||
|
||||
const providerCapabilityFacts = {
|
||||
operation: z.string(),
|
||||
input_contract_version: z.number().int().min(1),
|
||||
output_contract_version: z.number().int().min(1),
|
||||
pagination: z.enum(["none", "offset", "cursor"]),
|
||||
exhaustive: z.boolean(),
|
||||
effects: z.object({
|
||||
@@ -122,7 +126,6 @@ const processLineageObservation = z.discriminatedUnion("status", [
|
||||
z.object({
|
||||
status: z.literal("verified"),
|
||||
observed_at: z.iso.datetime(),
|
||||
schema_version: z.literal(1),
|
||||
...processCoordinates,
|
||||
launcher_parent_pid: z.number().int().min(0),
|
||||
descendants: z.array(
|
||||
@@ -176,7 +179,7 @@ const providerRejectionCode: z.ZodType<ProviderRejectionCode> = z.enum(
|
||||
PROVIDER_REJECTION_CODES,
|
||||
);
|
||||
|
||||
const providerDiagnostics = z.record(z.string(), z.json());
|
||||
const providerDiagnostics = z.record(z.string(), jsonValueSchema);
|
||||
|
||||
const providerAvailability = z.discriminatedUnion("status", [
|
||||
z.object({
|
||||
@@ -312,74 +315,75 @@ export type ToolUnavailabilityReason = z.output<
|
||||
typeof toolUnavailabilityReason
|
||||
>;
|
||||
|
||||
export const sessionProvider = z.object({
|
||||
provider: providerIdentity,
|
||||
providers: z.array(providerIdentity),
|
||||
capabilities: z.array(providerCapability),
|
||||
analysis_run: analysisRun,
|
||||
analysis_activity: analysisActivity,
|
||||
analysis_provider_binding: z
|
||||
.object({
|
||||
provider: providerIdentity,
|
||||
selection_source: z.enum([
|
||||
"request",
|
||||
"environment",
|
||||
"auto-single-candidate",
|
||||
]),
|
||||
analysis_profile: analysisProfileSchema,
|
||||
})
|
||||
.nullable(),
|
||||
analysis_provider_candidates: z.array(
|
||||
z.object({
|
||||
provider: providerIdentity,
|
||||
availability: providerAvailability,
|
||||
target_support: providerTargetSupport,
|
||||
selected: z.boolean(),
|
||||
capabilities: z.array(providerCapability),
|
||||
export const sessionProvider = z
|
||||
.object({
|
||||
provider: providerIdentity,
|
||||
providers: z.array(providerIdentity),
|
||||
capabilities: z.array(providerCapability),
|
||||
analysis_run: analysisRun,
|
||||
analysis_activity: analysisActivity,
|
||||
analysis_provider_binding: z
|
||||
.object({
|
||||
provider: providerIdentity,
|
||||
selection_source: z.enum([
|
||||
"request",
|
||||
"environment",
|
||||
"auto-single-candidate",
|
||||
]),
|
||||
analysis_profile: analysisProfileSchema,
|
||||
})
|
||||
.nullable(),
|
||||
analysis_provider_candidates: z.array(
|
||||
z.object({
|
||||
provider: providerIdentity,
|
||||
availability: providerAvailability,
|
||||
target_support: providerTargetSupport,
|
||||
selected: z.boolean(),
|
||||
capabilities: z.array(providerCapability),
|
||||
}),
|
||||
),
|
||||
tool_availability: z.array(toolAvailability),
|
||||
client_features: z.object({
|
||||
elicitation_form: z.boolean(),
|
||||
elicitation_url: z.boolean(),
|
||||
roots: z.boolean(),
|
||||
sampling: z.boolean(),
|
||||
}),
|
||||
),
|
||||
tool_availability: z.array(toolAvailability),
|
||||
client_features: z.object({
|
||||
elicitation_form: z.boolean(),
|
||||
elicitation_url: z.boolean(),
|
||||
roots: z.boolean(),
|
||||
sampling: z.boolean(),
|
||||
}),
|
||||
server_identity: z.object({
|
||||
package: z.object({
|
||||
name: z.string(),
|
||||
version: z.string(),
|
||||
root_path: z.string(),
|
||||
build_commit: z.string().nullable(),
|
||||
server_identity: z.object({
|
||||
package: z.object({
|
||||
name: z.string(),
|
||||
version: z.string(),
|
||||
root_path: z.string(),
|
||||
build_commit: z.string().nullable(),
|
||||
}),
|
||||
server: z.object({
|
||||
name: z.string(),
|
||||
version: z.string(),
|
||||
started_at: z.string(),
|
||||
command_path: z.string(),
|
||||
}),
|
||||
sdk: z.object({
|
||||
server: z.string(),
|
||||
client_test: z.string(),
|
||||
core: z.string(),
|
||||
}),
|
||||
negotiated_protocol_version: z.string().nullable(),
|
||||
client: z.object({ name: z.string(), version: z.string() }).nullable(),
|
||||
skill: z.object({ name: z.string(), expected_version: z.string() }),
|
||||
catalog: z.record(z.string(), z.json()),
|
||||
protocol_features: z.object({
|
||||
progress: z.boolean(),
|
||||
cancellation: z.boolean(),
|
||||
elicitation: z.boolean(),
|
||||
}),
|
||||
alignment: z.object({
|
||||
state: z.enum(["aligned", "mcp_server_restart_required", "unknown"]),
|
||||
reasons: z.array(z.string()),
|
||||
remediation: z.string().nullable(),
|
||||
}),
|
||||
}),
|
||||
server: z.object({
|
||||
name: z.string(),
|
||||
version: z.string(),
|
||||
started_at: z.string(),
|
||||
command_path: z.string(),
|
||||
}),
|
||||
sdk: z.object({
|
||||
server: z.string(),
|
||||
client_test: z.string(),
|
||||
core: z.string(),
|
||||
}),
|
||||
negotiated_protocol_version: z.string().nullable(),
|
||||
client: z.object({ name: z.string(), version: z.string() }).nullable(),
|
||||
skill: z.object({ name: z.string(), expected_version: z.string() }),
|
||||
catalog: z.record(z.string(), z.json()),
|
||||
protocol_features: z.object({
|
||||
progress: z.boolean(),
|
||||
cancellation: z.boolean(),
|
||||
evidence_resources: z.boolean(),
|
||||
elicitation: z.boolean(),
|
||||
}),
|
||||
alignment: z.object({
|
||||
state: z.enum(["aligned", "mcp_server_restart_required", "unknown"]),
|
||||
reasons: z.array(z.string()),
|
||||
remediation: z.string().nullable(),
|
||||
}),
|
||||
}),
|
||||
});
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
export const nullableText = z.string().nullable();
|
||||
export const addressList = z.array(z.string());
|
||||
@@ -434,10 +438,9 @@ export const bounded = (item: z.ZodType) => {
|
||||
]);
|
||||
};
|
||||
|
||||
const addressedValue = z.object({
|
||||
export const addressedValue = z.object({
|
||||
address: z.string(),
|
||||
value: z.string(),
|
||||
value_truncated: z.boolean().optional(),
|
||||
symbol: z
|
||||
.object({
|
||||
primary: z.boolean(),
|
||||
@@ -463,25 +466,6 @@ const addressedValue = z.object({
|
||||
.optional(),
|
||||
});
|
||||
|
||||
export const pageOutput = z.object({
|
||||
items: z.array(addressedValue),
|
||||
offset: z.number().int().min(0),
|
||||
limit: z.number().int().min(1),
|
||||
total: z.number().int().min(0),
|
||||
next_offset: z.number().int().min(0).nullable(),
|
||||
has_more: z.boolean(),
|
||||
});
|
||||
|
||||
export const searchPageOutput = pageOutput.extend({
|
||||
items: z.array(
|
||||
z.object({
|
||||
address: z.string(),
|
||||
value: z.string(),
|
||||
value_truncated: z.boolean(),
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
||||
const memoryRegionOutput = z.object({
|
||||
name: z.string(),
|
||||
start: z.string(),
|
||||
|
||||
@@ -14,14 +14,11 @@ const PROPERTY_DESCRIPTIONS: Readonly<Record<string, string>> = {
|
||||
comment: "Exact analyst comment text to write.",
|
||||
comparisons: "Validated comparison Evidence records to aggregate.",
|
||||
coverage: "Exact reconstruction-coverage commitment to verify.",
|
||||
detail: "Requested response detail level.",
|
||||
direction: "Direction in which to traverse or compare relationships.",
|
||||
document: "Exact provider document or program identity.",
|
||||
error: "Structured, caller-actionable error when the operation fails.",
|
||||
evidence: "Evidence v2 record produced by this operation.",
|
||||
evidence_id: "Stable identifier of the recorded Evidence v2 observation.",
|
||||
evidence_uri:
|
||||
"Session resource URI for the recorded Evidence v2 observation.",
|
||||
executable: "Approved absolute path of the executable to run.",
|
||||
format: "Declared input artifact format.",
|
||||
name: "Exact name used by this operation.",
|
||||
@@ -42,7 +39,6 @@ const PROPERTY_DESCRIPTIONS: Readonly<Record<string, string>> = {
|
||||
provider_id:
|
||||
"Exact deep-analysis provider ID, or automatic selection when omitted.",
|
||||
right: "Right-hand input used for comparison or differential execution.",
|
||||
schema_version: "Version of this structured result schema.",
|
||||
source_evidence:
|
||||
"Evidence records supporting the prepared source transformation.",
|
||||
status: "Current lifecycle or verification status.",
|
||||
|
||||
Reference in New Issue
Block a user