refactor: return complete tool results inline

This commit is contained in:
morluto
2026-09-29 07:08:46 +08:00
parent 2160d4fae5
commit 0d96275b68
535 changed files with 4084 additions and 13537 deletions
-1
View File
@@ -11,7 +11,6 @@ const literal = (value: string) => ({
});
const baseScenario = () => ({
schema_version: 1,
browser: {
mode: "launch",
executable_path: "/opt/chromium/chrome",
+2 -16
View File
@@ -92,24 +92,10 @@ export class CdpBrowserProvider implements BrowserObservationPort {
);
const allowedOrigins = new Set(input.allowed_origins);
const selected = selectTargets(discovery, allowedOrigins);
const items = selected.allowed.slice(
input.offset,
input.offset + input.limit,
);
const nextOffset = input.offset + items.length;
return ok(
browserTargetListSchema.parse({
schema_version: 1,
browser: discovery.version,
targets: {
items,
offset: input.offset,
limit: input.limit,
total: selected.allowed.length,
next_offset:
nextOffset < selected.allowed.length ? nextOffset : null,
has_more: nextOffset < selected.allowed.length,
},
targets: selected.allowed,
excluded: selected.excluded,
limitations: [
"Only page targets whose current URL matches an approved exact origin are listed.",
@@ -352,7 +338,7 @@ const selectTargets = (
discovery: CdpEndpointDiscovery,
allowedOrigins: ReadonlySet<string>,
): {
readonly allowed: readonly BrowserTargetList["targets"]["items"][number][];
readonly allowed: readonly BrowserTargetList["targets"][number][];
readonly excluded: BrowserTargetList["excluded"];
readonly unconnectable: number;
} => {
-1
View File
@@ -113,7 +113,6 @@ const runElectronInspection = async (
await assertStableMainFrame(context, state, main.file_path);
await report(context.progress, 3, "Electron inspection complete");
return {
schema_version: 1,
browser: context.discovery.version,
target: {
target_id: context.target.id,
+1 -11
View File
@@ -90,20 +90,10 @@ export class CdpElectronProvider implements ElectronObservationPort {
allowed.sort((left, right) =>
left.target_id.localeCompare(right.target_id),
);
const items = allowed.slice(input.offset, input.offset + input.limit);
const next = input.offset + items.length;
return ok(
electronTargetListSchema.parse({
schema_version: 1,
browser: discovery.version,
targets: {
items,
offset: input.offset,
limit: input.limit,
total: allowed.length,
next_offset: next < allowed.length ? next : null,
has_more: next < allowed.length,
},
targets: allowed,
excluded: {
outside_root: outsideRoot,
unsupported_url: unsupportedUrl,
-1
View File
@@ -107,7 +107,6 @@ export const observeCdpSession = async (
terminal: true,
});
return {
schema_version: 1,
browser: context.discovery.version,
target: {
target_id: context.target.id,
-1
View File
@@ -255,7 +255,6 @@ const normalizedInspection = (
state: CaptureState,
captured: CapturedSections,
): WebPageInspection => ({
schema_version: 2,
browser: state.context.discovery.version,
target: normalizedTarget(
state.context.target,
-1
View File
@@ -106,7 +106,6 @@ export const captureCdpScreenshot = async (
terminal: true,
});
return {
schema_version: 1,
browser: context.discovery.version,
target: {
target_id: context.target.id,
-1
View File
@@ -374,7 +374,6 @@ const buildWebMcpResult = (options: WebMcpResultOptions): WebMcpDiscovery => {
new Set(context.input.allowed_origins),
);
return {
schema_version: 1,
browser: context.discovery.version,
target: {
target_id: context.target.id,
@@ -40,7 +40,6 @@ const scenario = (
} = {},
): BrowserScenario =>
browserScenarioSchema.parse({
schema_version: 1,
browser:
options.mode === "connect"
? {
@@ -317,7 +317,6 @@ const runScenario = async (
const events = session.events();
const completeness = globalCompleteness(scenario, session, steps);
return browserScenarioCaptureSchema.parse({
schema_version: 1,
browser: {
mode: session.mode,
process_ownership: session.processOwnership,
@@ -9,7 +9,6 @@ import { runElectronActions } from "./PlaywrightElectronActiveActions.js";
it("parses bounded window, renderer, and deep-link actions for agents", () => {
const input = electronActiveObservationInputSchema.parse({
schema_version: 1,
executable_path: "/opt/electron",
application_path: "/opt/app/main.js",
application_root: "/opt/app",
@@ -47,7 +46,6 @@ it("parses bounded window, renderer, and deep-link actions for agents", () => {
it("rejects non-absolute deep-link values", () => {
const result = electronActiveObservationInputSchema.safeParse({
schema_version: 1,
executable_path: "/opt/electron",
application_path: "/opt/app/main.js",
application_root: "/opt/app",
@@ -68,7 +66,6 @@ it("rejects non-absolute deep-link values", () => {
it("redacts action inputs from Playwright failures", async () => {
const selector = "#secret-selector";
const input = electronActiveObservationInputSchema.parse({
schema_version: 1,
executable_path: "/opt/electron",
application_path: "/opt/app/main.js",
application_root: "/opt/app",
@@ -103,7 +100,6 @@ it("redacts action inputs from Playwright failures", async () => {
it("runs an untargeted deep-link without requiring a BrowserWindow", async () => {
const input = electronActiveObservationInputSchema.parse({
schema_version: 1,
executable_path: "/opt/electron",
application_path: "/opt/app/main.js",
application_root: "/opt/app",
@@ -327,7 +327,6 @@ const createResult = (
ipcEventKinds.has(kind),
);
return electronActiveObservationResultSchema.parse({
schema_version: 1,
application: {
executable_path: paths.executable,
application_path: paths.application,
@@ -16,7 +16,6 @@ describe("PlaywrightScenarioEvents", () => {
},
} as unknown as Page;
const scenario = browserScenarioSchema.parse({
schema_version: 1,
browser: {
mode: "launch",
executable_path: "/opt/chromium",
-2
View File
@@ -21,7 +21,6 @@ export const comparePngScreenshots = (
const after = decodePng(input.after, input.maximum_pixels);
if (before.width !== after.width || before.height !== after.height)
return {
schema_version: 1,
status: "dimension_mismatch",
before: dimensions(before),
after: dimensions(after),
@@ -51,7 +50,6 @@ export const comparePngScreenshots = (
}
const pixels = before.width * before.height;
const context = {
schema_version: 1 as const,
before: dimensions(before),
after: dimensions(after),
channel_threshold: input.channel_threshold,
@@ -90,7 +90,6 @@ export const finalizeInspectorCapture = async ({
: 0,
);
return {
schema_version: 1,
runtime,
target: {
target_id: target.id,
+1 -13
View File
@@ -114,22 +114,10 @@ export class V8InspectorProvider implements JavaScriptRuntimeObservationPort {
allowed.sort((left, right) =>
left.id < right.id ? -1 : left.id > right.id ? 1 : 0,
);
const items = allowed
.slice(input.offset, input.offset + input.limit)
.map(projectTarget);
const nextOffset = input.offset + items.length;
return ok(
javascriptRuntimeTargetListSchema.parse({
schema_version: 1,
runtime: discovery.runtime,
targets: {
items,
offset: input.offset,
limit: input.limit,
total: allowed.length,
next_offset: nextOffset < allowed.length ? nextOffset : null,
has_more: nextOffset < allowed.length,
},
targets: allowed.map(projectTarget),
excluded: { ...excluded, unconnectable: 0 },
limitations: describeInspectorTargetLimitations(),
}),