mirror of
https://github.com/morluto/rea.git
synced 2026-11-23 23:15:58 +00:00
Serve retained capture Evidence as a bounded MCP replay environment with discovery. Preserve default stdio, caller-selected facts and complete source Evidence. Fix numeric fidelity, argument identity, startup cancellation and bounded discovery, query/path matching and output metadata. Verify real recorded API data and public CLI/MCP workflows; preserve explicit gaps for Windows and third-party hosts. Co-authored-by: Edgar Arakelyan <edgar.arakelyan@scale.com> Co-authored-by: gensokyo-dev <gensokyo-dev@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
1.8 KiB
TypeScript
51 lines
1.8 KiB
TypeScript
import { expect, it } from "vitest";
|
|
import { environmentServeSourceWithBody } from "../../../tests/fixtures/environmentServe.js";
|
|
import {
|
|
replayEnvironmentTool,
|
|
selectReplayExchange,
|
|
} from "./environmentReplay.js";
|
|
|
|
it("matches a late repeated query and a distant path coordinate without full tuple/segment arrays", () => {
|
|
const source = environmentServeSourceWithBody("{}", "application/json");
|
|
const original = source.manifest.tools.find(
|
|
(tool) => tool.name === "get_users_by_id",
|
|
)!;
|
|
const ordinal = original.record_ordinals[0]!;
|
|
const exchange = source.exchanges.get(ordinal)!;
|
|
const tool = {
|
|
...original,
|
|
params: [{ ...original.params[0]!, index: 20000 }],
|
|
query_parameter_names: ["q"],
|
|
};
|
|
const retained = {
|
|
...exchange,
|
|
path: `/${"literal/".repeat(20000)}wanted`,
|
|
query: `?${"q=miss&".repeat(20000)}q=hit`,
|
|
};
|
|
expect(
|
|
selectReplayExchange(tool, new Map([[ordinal, retained]]), {
|
|
id: "wanted",
|
|
q: "hit",
|
|
}),
|
|
).toEqual({ exchange: retained, exact: true });
|
|
});
|
|
|
|
it("bounds content-type display without changing body interpretation or retained source", () => {
|
|
const contentType = `application/json;${"x".repeat(100000)}`;
|
|
const source = environmentServeSourceWithBody('{"value":1}', contentType);
|
|
const tool = source.manifest.tools.find(
|
|
(tool) => tool.name === "get_users_by_id",
|
|
)!;
|
|
const result = replayEnvironmentTool(source, tool, { id: "2" });
|
|
expect(result.ok).toBe(true);
|
|
if (!result.ok) throw result.error;
|
|
expect(result.value.body).toEqual({ value: 1 });
|
|
expect(
|
|
Buffer.byteLength(result.value.content_type ?? ""),
|
|
).toBeLessThanOrEqual(1024);
|
|
expect(result.value.replay.content_type_truncated).toBe(true);
|
|
expect(source.exchanges.get(tool.record_ordinals[0]!)?.contentType).toBe(
|
|
contentType,
|
|
);
|
|
});
|