Add structured runtime logging

This commit is contained in:
morluto
2026-07-12 10:57:34 +08:00
parent 5ed56d63e0
commit 03072e0ea7
16 changed files with 795 additions and 48 deletions
+3 -1
View File
@@ -1,6 +1,7 @@
import { parseConfig } from "../config.js";
import type { JsonValue } from "../hopper/protocol.js";
import { createBinarySession } from "./runtime.js";
import { silentLogger, type Logger } from "../logger.js";
/**
* Open one binary, execute one tool, and always release the bridge session.
@@ -11,11 +12,12 @@ export const runDirectAnalysis = async (
path: string,
tool: "binary_overview" | "procedure_pseudo_code",
arguments_: Readonly<Record<string, JsonValue>>,
logger: Logger = silentLogger,
): Promise<JsonValue> => {
const config = parseConfig(process.env);
if (!config.ok)
return { error: config.error._tag, message: config.error.message };
const session = createBinarySession(config.value);
const session = createBinarySession(config.value, logger);
try {
const opened = await session.open(path);
if (!opened.ok)
+6 -1
View File
@@ -4,13 +4,17 @@ import type { AppConfig } from "../config.js";
import { BinarySession } from "./BinarySession.js";
import { HopperApplicationLauncher } from "../hopper/BridgeLauncher.js";
import { HopperClient } from "../hopper/HopperClient.js";
import { silentLogger, type Logger } from "../logger.js";
/**
* 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 => {
export const createBinarySession = (
config: AppConfig,
logger: Logger = silentLogger,
): BinarySession => {
const bridgeScriptPath = fileURLToPath(
new URL("../../bridge/hopper_bridge.py", import.meta.url),
);
@@ -27,6 +31,7 @@ export const createBinarySession = (config: AppConfig): BinarySession => {
: target.loaderArgs,
bridgeScriptPath,
}),
logger: logger.child({ layer: "bridge" }),
}),
);
};