docs: record runtime and release constraints
This commit is contained in:
@@ -13,10 +13,17 @@ import type { HopperToolPort } from "./HopperToolPort.js";
|
||||
export interface BinaryClient extends HopperToolPort {
|
||||
close(): Promise<void>;
|
||||
}
|
||||
/** Production seam for creating a target-scoped Hopper client. */
|
||||
/** Production seam for creating one unstarted client for a parsed target. */
|
||||
export type BinaryClientFactory = (target: BinaryTarget) => BinaryClient;
|
||||
|
||||
/** Serializes target transitions while allowing calls within the active session. */
|
||||
/**
|
||||
* Owns the single active target shared by CLI and MCP adapters.
|
||||
*
|
||||
* Target transitions are serialized because each client dispatches Hopper API
|
||||
* work on its dedicated Python thread, and switching targets tears that bridge
|
||||
* down. A failed switch recreates the previous target instead of retaining a
|
||||
* client whose bridge was already shut down.
|
||||
*/
|
||||
export class BinarySession implements HopperToolPort {
|
||||
#active:
|
||||
| { readonly target: BinaryTarget; readonly client: BinaryClient }
|
||||
@@ -25,7 +32,10 @@ export class BinarySession implements HopperToolPort {
|
||||
readonly #calls = new Set<Promise<unknown>>();
|
||||
constructor(readonly createClient: BinaryClientFactory) {}
|
||||
|
||||
/** Open or switch to a target, retaining the old session when the new one fails. */
|
||||
/**
|
||||
* Open or switch targets after draining calls against the current target.
|
||||
* Returns the switch failure even if best-effort restoration also fails.
|
||||
*/
|
||||
open(
|
||||
path: string,
|
||||
options: { readonly signal?: AbortSignal } = {},
|
||||
@@ -82,7 +92,11 @@ export class BinarySession implements HopperToolPort {
|
||||
};
|
||||
}
|
||||
|
||||
/** Invoke a Hopper tool against the active target. */
|
||||
/**
|
||||
* Invoke a Hopper tool against the active target.
|
||||
* Calls may overlap, but a pending target transition prevents new calls from
|
||||
* entering until the transition has settled.
|
||||
*/
|
||||
async callTool(
|
||||
name: string,
|
||||
arguments_: Readonly<Record<string, JsonValue>>,
|
||||
|
||||
@@ -2,7 +2,11 @@ import { parseConfig } from "../config.js";
|
||||
import type { JsonValue } from "../hopper/protocol.js";
|
||||
import { createBinarySession } from "./runtime.js";
|
||||
|
||||
/** Open one binary, execute one tool, and always release the target session. */
|
||||
/**
|
||||
* Open one binary, execute one tool, and always release the bridge session.
|
||||
* Unlike MCP mode, every CLI invocation is intentionally isolated and does not
|
||||
* retain a target or bridge resources for a subsequent command.
|
||||
*/
|
||||
export const runDirectAnalysis = async (
|
||||
path: string,
|
||||
tool: "binary_overview" | "procedure_pseudo_code",
|
||||
|
||||
@@ -19,7 +19,7 @@ export interface DoctorCheck {
|
||||
readonly detail?: string;
|
||||
readonly remediation?: string;
|
||||
}
|
||||
/** Host facts and effects required by diagnostics. */
|
||||
/** Read-only host capabilities required by diagnostics. */
|
||||
export interface DoctorHost {
|
||||
readonly platform: NodeJS.Platform;
|
||||
readonly nodeVersion: string;
|
||||
@@ -30,7 +30,11 @@ export interface DoctorHost {
|
||||
manualHopperPaths(): Promise<readonly string[]>;
|
||||
}
|
||||
|
||||
/** Check requirements and an optional target without mutating the host. */
|
||||
/**
|
||||
* Check requirements and an optional target without mutating the host.
|
||||
* Every failed check includes remediation suitable for either the one-shot CLI
|
||||
* or an agent consuming the structured result.
|
||||
*/
|
||||
export const runDoctor = async (
|
||||
target?: string,
|
||||
host: DoctorHost = systemDoctorHost(),
|
||||
|
||||
@@ -21,11 +21,15 @@ import type { JsonValue } from "../hopper/protocol.js";
|
||||
|
||||
type EnhancedResult = Promise<Result<JsonValue, HopperError>>;
|
||||
|
||||
/** Application services composing official Hopper operations into eight RE tools. */
|
||||
/**
|
||||
* Composes official Hopper operations into bounded reverse-engineering tools.
|
||||
* Inputs are parsed again at this application boundary even though MCP normally
|
||||
* validates them, allowing direct callers to use the same service safely.
|
||||
*/
|
||||
export class EnhancedTools {
|
||||
constructor(private readonly hopper: HopperToolPort) {}
|
||||
|
||||
/** Parse and dispatch one enhanced tool call. */
|
||||
/** Parse inputs again at the direct-call boundary, then dispatch exhaustively. */
|
||||
execute(
|
||||
name: EnhancedToolName,
|
||||
input: unknown,
|
||||
|
||||
@@ -4,6 +4,11 @@ import type { JsonValue } from "../hopper/protocol.js";
|
||||
|
||||
/** Application-owned capability for invoking one official Hopper tool. */
|
||||
export interface HopperToolPort {
|
||||
/**
|
||||
* Invoke a declared bridge operation with JSON-safe arguments.
|
||||
* Implementations return expected Hopper, timeout, and cancellation failures
|
||||
* as values and must honor an already-aborted signal.
|
||||
*/
|
||||
callTool(
|
||||
name: string,
|
||||
arguments_: Readonly<Record<string, JsonValue>>,
|
||||
|
||||
@@ -34,7 +34,11 @@ export type ClientConfigurationResult =
|
||||
readonly status: "failed";
|
||||
readonly reason: "backup" | "write" | "readback";
|
||||
};
|
||||
/** Effects required by the idempotent setup workflow. */
|
||||
/**
|
||||
* Effects required by the idempotent setup workflow.
|
||||
* Implementations report interrupted installers as values: setup must not wait
|
||||
* indefinitely for stdin or a GUI response in an unattended agent invocation.
|
||||
*/
|
||||
export interface SetupHost {
|
||||
readonly platform: NodeJS.Platform;
|
||||
readonly nodeVersion: string;
|
||||
@@ -48,7 +52,11 @@ export interface SetupHost {
|
||||
installSkill(): Promise<"installed" | "unchanged" | "failed">;
|
||||
doctor(): Promise<Awaited<ReturnType<typeof runDoctor>>>;
|
||||
}
|
||||
/** Structured setup outcome with actionable partial progress. */
|
||||
/**
|
||||
* Structured setup outcome intended to travel back through an agent to a human.
|
||||
* `needs_human` carries remediation text instead of initiating an interactive
|
||||
* prompt, avoiding deadlocks in stdio and other unattended environments.
|
||||
*/
|
||||
export interface SetupResult {
|
||||
readonly status: "ready" | "needs_human";
|
||||
readonly actions: readonly string[];
|
||||
@@ -57,7 +65,11 @@ export interface SetupResult {
|
||||
readonly remediation?: string;
|
||||
}
|
||||
|
||||
/** Install prerequisites and configure every detected supported client idempotently. */
|
||||
/**
|
||||
* Install prerequisites and configure detected clients idempotently.
|
||||
* With `yes` false, mutations requiring consent are reported as `needs_human`;
|
||||
* with `yes` true, external installers still fail closed if they require UI.
|
||||
*/
|
||||
export const runSetup = async (
|
||||
yes: boolean,
|
||||
host: SetupHost = systemSetupHost(),
|
||||
|
||||
@@ -5,7 +5,11 @@ export const HOMEBREW_COMMANDS = [
|
||||
"/usr/local/bin/brew",
|
||||
] as const;
|
||||
|
||||
/** Return the first successful result from the standard Homebrew executables. */
|
||||
/**
|
||||
* Return the first defined result from standard Homebrew executables.
|
||||
* A probe returning `undefined` means that location was unavailable or failed;
|
||||
* other falsy values are successful results and stop discovery.
|
||||
*/
|
||||
export const probeHomebrew = async <T>(
|
||||
probe: (command: string) => Promise<T | undefined>,
|
||||
): Promise<T | undefined> => {
|
||||
|
||||
@@ -5,7 +5,11 @@ import { BinarySession } from "./BinarySession.js";
|
||||
import { HopperApplicationLauncher } from "../hopper/BridgeLauncher.js";
|
||||
import { HopperClient } from "../hopper/HopperClient.js";
|
||||
|
||||
/** Create the target-switching session used by both the CLI and MCP adapters. */
|
||||
/**
|
||||
* Compose the target-switching runtime shared directly by CLI and MCP adapters.
|
||||
* This is the sole production wiring point for Hopper so neither adapter shells
|
||||
* out to the other and both retain identical loader and bridge semantics.
|
||||
*/
|
||||
export const createBinarySession = (config: AppConfig): BinarySession => {
|
||||
const bridgeScriptPath = fileURLToPath(
|
||||
new URL("../../bridge/hopper_bridge.py", import.meta.url),
|
||||
|
||||
Reference in New Issue
Block a user