feat(session): add dynamic binary lifecycle

This commit is contained in:
morluto
2026-07-12 06:34:18 +08:00
parent c2c3d989eb
commit f32e718cc7
16 changed files with 942 additions and 28 deletions
+19 -1
View File
@@ -13,7 +13,7 @@ const caseSensitive = z
.describe("Whether to match case");
/** The architectural owner of a tool implementation. */
export type ToolKind = "official-proxy" | "enhanced";
export type ToolKind = "official-proxy" | "enhanced" | "session";
/** Stable caller-visible contract retained across the Python-to-TypeScript migration. */
export interface ToolContract {
@@ -35,6 +35,12 @@ const enhanced = (
inputSchema: z.ZodObject,
): ToolContract => ({ name, description, kind: "enhanced", inputSchema });
const session = (
name: string,
description: string,
inputSchema: z.ZodObject,
): ToolContract => ({ name, description, kind: "session", inputSchema });
/** All 31 tools forwarded unchanged to Hopper's official MCP server. */
export const OFFICIAL_TOOL_CONTRACTS = [
official(
@@ -218,8 +224,20 @@ export const ENHANCED_TOOL_CONTRACTS = [
),
] as const satisfies readonly ToolContract[];
/** Binary lifecycle tools available before Hopper is launched. */
export const SESSION_TOOL_CONTRACTS = [
session(
"open_binary",
"Open or switch the active binary",
z.object({ path: z.string().min(1) }),
),
session("close_binary", "Close the active binary", z.object({})),
session("binary_session", "Describe the active binary session", z.object({})),
] as const satisfies readonly ToolContract[];
/** Complete caller-visible tool inventory. */
export const TOOL_CONTRACTS = [
...OFFICIAL_TOOL_CONTRACTS,
...ENHANCED_TOOL_CONTRACTS,
...SESSION_TOOL_CONTRACTS,
] as const;