mirror of
https://github.com/morluto/rea.git
synced 2026-11-30 02:17:09 +00:00
fix(browser): deliver the analyze_web_bundle summary when no view is named
The description said detail summary retains the complete Evidence, but
the request schema required a view with it, so {detail: "summary"} was
refused at view, and the binding only projected when a view was present.
analyze_javascript_application, which shares the route delivery, already
accepted a summary without a view.
The summary delivery now makes the view optional, and the binding projects
the retained analysis's summary view when none is named. A summary with a
view is unchanged.
Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
This commit is contained in:
1 parent
fe4e466ef9
commit
ebe01e7884
4 files changed
+59
-7
No files matched your search
@@ -41,7 +41,8 @@ describe.each(cases)("%s delivery contract", (name, base) => {
|
||||
[{}, true],
|
||||
[{ detail: "complete" }, true],
|
||||
[{ detail: "summary", view }, true],
|
||||
[{ detail: "summary" }, name === "analyze_javascript_application"],
|
||||
// Without a view, both deliver the summary of the retained analysis.
|
||||
[{ detail: "summary" }, true],
|
||||
[{ view }, false],
|
||||
[{ detail: "complete", view }, false],
|
||||
[{ detail: "summary", view: { ...view, kind: "other" } }, false],
|
||||
|
||||
@@ -124,10 +124,10 @@ export const javaScriptRoutesSummaryDeliveryShape = {
|
||||
};
|
||||
export const webRoutesSummaryDeliveryShape = {
|
||||
detail: z.literal("summary"),
|
||||
view: z.union([
|
||||
javaScriptRoutesViewRequestSchema,
|
||||
webBundleViewRequestSchema,
|
||||
]),
|
||||
// Omitted, the summary view of the retained analysis is returned.
|
||||
view: z
|
||||
.union([javaScriptRoutesViewRequestSchema, webBundleViewRequestSchema])
|
||||
.exactOptional(),
|
||||
};
|
||||
export const javaScriptRouteProvenanceSchema = z.strictObject({
|
||||
source_id: javaScriptRouteInventorySourceSchema.shape.id,
|
||||
|
||||
@@ -109,8 +109,12 @@ export const bindBrowserObservationTools = (
|
||||
if (!ready.ok) return ready;
|
||||
}
|
||||
const analyzed = await analyzeWebBundle(browser, request, options);
|
||||
return analyzed.ok && view !== undefined
|
||||
? projectRetainedAnalysis(analyzed.value, retention, view)
|
||||
return analyzed.ok && detail === "summary"
|
||||
? projectRetainedAnalysis(
|
||||
analyzed.value,
|
||||
retention,
|
||||
view ?? { kind: "summary" },
|
||||
)
|
||||
: analyzed;
|
||||
},
|
||||
},
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import { expect, it, onTestFinished } from "vitest";
|
||||
import { CdpBrowserProvider } from "../../../src/browser/CdpBrowserProvider.js";
|
||||
import { parseEvidence } from "../../../src/domain/evidence.js";
|
||||
import { createApplicationMcpHarness } from "../../fixtures/applicationMcpHarness.js";
|
||||
import { withCanonicalOutputSchema } from "../../fixtures/canonicalOutputSchema.js";
|
||||
import { startFakeCdpBrowser } from "../../fixtures/fakeCdpBrowser.js";
|
||||
|
||||
const connect = async () => {
|
||||
const browser = await startFakeCdpBrowser({});
|
||||
onTestFinished(() => browser.close());
|
||||
const { client } = await createApplicationMcpHarness({
|
||||
serverOptions: { browserObservation: new CdpBrowserProvider() },
|
||||
});
|
||||
const definitions = (await client.listTools()).tools;
|
||||
const call = async (name: string, args: Record<string, unknown>) => {
|
||||
const definition = definitions.find((tool) => tool.name === name);
|
||||
if (definition === undefined) throw new Error(`Missing tool ${name}`);
|
||||
const reply = await client.callTool(
|
||||
{ name, arguments: args },
|
||||
{ toolDefinition: withCanonicalOutputSchema(definition) },
|
||||
);
|
||||
expect(reply.isError, JSON.stringify(reply.content)).not.toBe(true);
|
||||
return parseEvidence(reply.structuredContent);
|
||||
};
|
||||
const page = {
|
||||
cdp_endpoint: browser.endpoint,
|
||||
allowed_origins: [browser.allowedOrigin],
|
||||
target_id: "allowed-page",
|
||||
observation_ms: 0,
|
||||
};
|
||||
return { call, page };
|
||||
};
|
||||
|
||||
it("returns the analyze_web_bundle summary when detail summary names no view", async () => {
|
||||
const { call, page } = await connect();
|
||||
const summary = await call("analyze_web_bundle", {
|
||||
...page,
|
||||
detail: "summary",
|
||||
});
|
||||
expect(summary).toMatchObject({
|
||||
operation: "inspect_analysis_view",
|
||||
normalized_result: {
|
||||
kind: "summary",
|
||||
parent_operation: "analyze_web_bundle",
|
||||
},
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user