mirror of
https://github.com/morluto/rea.git
synced 2026-11-09 16:26:36 +00:00
* fix(ghidra): qualify selected project call coverage * test(ghidra): retain verifier MCP cleanup ownership * test(ghidra): document trusted verifier compiler selection * test(ghidra): document owned verifier exit marker * test(ghidra): remove ineffective scan directives * fix(ghidra): supervise project coverage verification * fix(ghidra): supervise verifier compiler process
55 lines
1.6 KiB
JavaScript
55 lines
1.6 KiB
JavaScript
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
|
|
import {
|
|
closeVerifierResources,
|
|
withVerifierCleanup,
|
|
} from "./verifier-cleanup.mjs";
|
|
|
|
/** Share an in-flight SDK close, including one started during failed initialization. */
|
|
export class VerifierStdioTransport extends StdioClientTransport {
|
|
#closing;
|
|
|
|
close() {
|
|
if (this.#closing !== undefined) return this.#closing;
|
|
this.#closing = super.close().catch((error) => {
|
|
this.#closing = undefined;
|
|
throw error;
|
|
});
|
|
return this.#closing;
|
|
}
|
|
}
|
|
|
|
/** Own MCP transports from connection through discovery, use, and cleanup retry. */
|
|
export function createVerifierMcpOwner() {
|
|
const owned = new Set();
|
|
const closeConnection = async (connection) => {
|
|
await closeVerifierResources([
|
|
() => connection.client.close(),
|
|
() => connection.transport.close(),
|
|
]);
|
|
owned.delete(connection);
|
|
};
|
|
return {
|
|
async open(client, transport) {
|
|
const connection = { client, transport, definitions: new Map() };
|
|
owned.add(connection);
|
|
try {
|
|
await client.connect(transport);
|
|
connection.definitions = new Map(
|
|
(await client.listTools()).tools.map((tool) => [tool.name, tool]),
|
|
);
|
|
return connection;
|
|
} catch (cause) {
|
|
return withVerifierCleanup(() => {
|
|
throw cause;
|
|
}, [() => closeConnection(connection)]);
|
|
}
|
|
},
|
|
closeConnection,
|
|
close() {
|
|
return closeVerifierResources(
|
|
[...owned].map((connection) => () => closeConnection(connection)),
|
|
);
|
|
},
|
|
};
|
|
}
|