Merge remote-tracking branch 'origin/main' into feat/persistent-workspace-investigation-runs

# Conflicts:
#	README.md
#	scripts/verify-package.mjs
#	src/cli.ts
#	src/domain/errors.ts
#	src/server/registerInvestigationTools.ts
#	tests/errors.test.ts
This commit is contained in:
morluto
2026-07-14 04:28:14 +08:00
91 changed files with 4402 additions and 711 deletions
+28 -39
View File
@@ -1,5 +1,5 @@
import { z } from "zod";
import { jsonValueSchema, type JsonValue } from "../domain/jsonValue.js";
import { jsonValueSchema } from "../domain/jsonValue.js";
import {
processCaptureSchema,
processScenarioSchema,
@@ -26,6 +26,22 @@ import {
import { TOOL_EXAMPLE_OVERRIDES } from "./toolContractExamples.js";
import { NATIVE_TOOL_CONTRACTS } from "./nativeToolContracts.js";
import { ARTIFACT_TOOL_CONTRACTS } from "./artifactToolContracts.js";
import {
closeBinaryInputSchema,
openBinaryInputSchema,
} from "./sessionLifecycleInputs.js";
import type {
ToolAnnotations,
ToolContract,
ToolExample,
ToolKind,
} from "./toolContractTypes.js";
export type {
ToolAnnotations,
ToolContract,
ToolExample,
} from "./toolContractTypes.js";
const document = z.string().optional().describe("The document name");
const address = z.string().describe("A Hopper address");
@@ -53,37 +69,6 @@ const searchInput = {
document,
};
export interface ToolAnnotations {
readonly readOnlyHint: boolean;
readonly destructiveHint: boolean;
readonly idempotentHint: boolean;
readonly openWorldHint: boolean;
}
export interface ToolExample {
readonly title: string;
readonly input: Readonly<Record<string, JsonValue>>;
}
/** Adapter family responsible for implementing a public MCP tool. */
type ToolKind =
| "official-proxy"
| "enhanced"
| "native-provider"
| "artifact-provider"
| "session";
/** Single source of truth for a public tool's name, description, and input. */
export interface ToolContract<Name extends string = string> {
readonly name: Name;
readonly description: string;
readonly kind: ToolKind;
readonly inputSchema: z.ZodObject;
readonly outputSchema: z.ZodObject;
readonly annotations: ToolAnnotations;
readonly examples: readonly ToolExample[];
}
const exampleInputSchema = z.record(z.string(), jsonValueSchema);
const examplesFor = (
name: string,
@@ -106,12 +91,16 @@ const annotations = (name: string, kind: ToolKind): ToolAnnotations => ({
name === "verify_unknown_resolution",
destructiveHint:
name === "export_evidence_bundle" ||
name === "close_binary" ||
name === "unset_bookmark" ||
name === "set_address_name" ||
name === "set_addresses_names" ||
name === "set_comment" ||
name === "set_inline_comment",
idempotentHint: name !== "record_unknown" && name !== "update_unknown",
idempotentHint:
name !== "close_binary" &&
name !== "record_unknown" &&
name !== "update_unknown",
openWorldHint: name === "capture_process_scenario",
});
@@ -293,12 +282,12 @@ export const OFFICIAL_TOOL_CONTRACTS = [
),
official(
"search_procedures",
"Search analyzed procedure names using literal matching by default or a structurally bounded regex. Returns a deterministic, offset-paginated page; continue at next_offset while has_more is true.",
"Search analyzed procedure names using literal matching by default or regex opt-in. Regex rejects unsupported constructs, more than 10,000 static backtracking paths, candidates over 4,096 characters, and searches over 1,000,000 work units. Results are deterministic and offset-paginated.",
z.object(searchInput),
),
official(
"search_strings",
"Search analyzed strings using literal matching by default or a structurally bounded regex. Returns a deterministic, offset-paginated page with explicit value truncation; follow matches with xrefs.",
"Search analyzed strings using literal matching by default or regex opt-in. Regex rejects unsupported constructs, more than 10,000 static backtracking paths, candidates over 4,096 characters, and searches over 1,000,000 work units. Results are deterministic, offset-paginated, and explicitly truncated.",
z.object(searchInput),
),
official(
@@ -404,13 +393,13 @@ export const ENHANCED_TOOL_CONTRACTS = [
export const SESSION_TOOL_CONTRACTS = [
session(
"open_binary",
"Open a local executable, application bundle, archive, JavaScript, source map, plist, or Hopper database after validation. Providers start lazily: inventory_artifact does not launch Hopper; deep native operations may show Hopper UI.",
z.object({ path: z.string().min(1) }),
"Open a local executable, application bundle, archive, JavaScript, source map, plist, or Hopper database after validation. An optional provider-neutral snapshot is imported atomically and must match the binary digest, format, and architecture exactly; provider resources may still start before an MCP cache replay.",
openBinaryInputSchema,
),
session(
"close_binary",
"Close the active target and every provider resource started for it. The operation is idempotent; call binary_session to verify the session is closed.",
z.object({}),
"Optionally write a provider-neutral analysis snapshot atomically, then close the active target and every provider resource started for it. Snapshot files require an operator-approved root and explicit overwrite; a failed save leaves the session open so cached analysis is not lost.",
closeBinaryInputSchema,
),
session(
"binary_session",