mirror of
https://github.com/morluto/rea.git
synced 2026-10-12 02:19:24 +00:00
* feat(javascript): recover readable modules with Wakaru Integrate pinned upstream source behind a typed optional recovery port, preserve source identity and producer provenance, and publish verified artifacts for existing JavaScript analysis through CLI and MCP. Add focused real-tool CI with genuine bundler fixtures and bounded resource, cancellation, cleanup, schema and packaged-artifact checks. Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis) Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing) * fix(javascript): align recovery catalog and browser verification Share canonical Wakaru provider identity, describe CLI mode options, and format the new workflow test. Disconnect the real page transport after its observation readiness progress instead of a fixed delay. Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis) Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing) * refactor(javascript): consume the investigation evidence writer Verify that the SDK recovery handler records complete Evidence through the newly shared investigation owner. Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis) * chore(test): account for isolated recovery fixture compilers * fix(javascript): validate recovery paths before acquiring the engine Return field-specific invalid_format diagnostics for relative paths and verify compiled CLI/MCP parity even when the optional engine is unavailable. Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis) Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)
65 lines
2.8 KiB
TypeScript
65 lines
2.8 KiB
TypeScript
import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
|
|
import { Ajv2020 } from "ajv/dist/2020.js";
|
|
import { expect, it, onTestFinished } from "vitest";
|
|
import { toolContract } from "../../../src/contracts/toolContracts.js";
|
|
import { parseEvidence } from "../../../src/domain/evidence.js";
|
|
import { createServer } from "../../../src/server/createServer.js";
|
|
import { createTestBinarySession } from "../../fixtures/binarySession.js";
|
|
import {
|
|
assertRecoveryCleanup,
|
|
recoveryFixture,
|
|
} from "../../fixtures/javascript-recovery/provider.js";
|
|
|
|
it.skipIf(process.platform !== "linux" || process.arch !== "x64")(
|
|
"advertises and executes recovery through the named SDK contract without a binary target",
|
|
async () => {
|
|
const fixture = await recoveryFixture();
|
|
const session = createTestBinarySession(() => {
|
|
throw new Error("no binary provider should start");
|
|
});
|
|
const server = createServer(session, session, {
|
|
javascriptRecovery: fixture.provider,
|
|
});
|
|
const client = new Client({ name: "recovery-contract", version: "1" });
|
|
onTestFinished(async () => {
|
|
await client.close();
|
|
await server.close();
|
|
await session.close();
|
|
});
|
|
const [clientTransport, serverTransport] =
|
|
InMemoryTransport.createLinkedPair();
|
|
await server.connect(serverTransport);
|
|
await client.connect(clientTransport);
|
|
const tools = await client.listTools();
|
|
const advertised = tools.tools.find(
|
|
(tool) => tool.name === "recover_javascript_sources",
|
|
);
|
|
if (advertised === undefined || advertised.outputSchema === undefined)
|
|
throw new Error("recovery tool must advertise both schemas");
|
|
const ajv = new Ajv2020({ strict: false, validateFormats: false });
|
|
const inputSchema: Record<string, unknown> = advertised.inputSchema;
|
|
const outputSchema: Record<string, unknown> = advertised.outputSchema;
|
|
expect(ajv.validateSchema(inputSchema)).toBe(true);
|
|
expect(ajv.validateSchema(outputSchema)).toBe(true);
|
|
const args = { path: fixture.path, output_directory: fixture.output };
|
|
expect(ajv.validate(inputSchema, args)).toBe(true);
|
|
const response = await client.callTool({
|
|
name: "recover_javascript_sources",
|
|
arguments: args,
|
|
});
|
|
expect(response.isError, JSON.stringify(response)).not.toBe(true);
|
|
expect(
|
|
ajv.validate(outputSchema, response.structuredContent),
|
|
JSON.stringify(ajv.errors),
|
|
).toBe(true);
|
|
const parsed = toolContract(
|
|
"recover_javascript_sources",
|
|
).outputSchema.parse(response.structuredContent);
|
|
const evidence = parseEvidence(parsed.evidence);
|
|
expect(parsed.result).toEqual(evidence.normalized_result);
|
|
expect(parsed.evidence_id).toBe(evidence.evidence_id);
|
|
expect(session.evidenceById(evidence.evidence_id)).toEqual(evidence);
|
|
await assertRecoveryCleanup(fixture.launches);
|
|
},
|
|
);
|