refactor(observation): retain complete tool results
This commit is contained in:
+29
-1
@@ -11,6 +11,17 @@ export const emitEvents = (
|
||||
emitDebuggerEvents(socket, command, port, options);
|
||||
emitNetworkEvents(socket, command, port, options);
|
||||
emitRuntimeEvents(socket, command, port, options);
|
||||
emitWebMcpEvents(socket, command, port, options);
|
||||
emitSessionTimeline(socket, command, port, options);
|
||||
emitCaptureNavigation(socket, command, options);
|
||||
};
|
||||
|
||||
const emitWebMcpEvents = (
|
||||
socket: WebSocket,
|
||||
command: FakeCdpCommand,
|
||||
port: number,
|
||||
options: FakeOptions,
|
||||
): void => {
|
||||
if (command.method === "WebMCP.enable" && options.webMcpTools === true) {
|
||||
event(socket, "WebMCP.toolsAdded", command.sessionId, {
|
||||
tools: [
|
||||
@@ -60,6 +71,16 @@ export const emitEvents = (
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(options.webMcpFrameCount !== undefined &&
|
||||
options.webMcpFrameCount > 0
|
||||
? [
|
||||
{
|
||||
name: "beyond_frame_limit_tool",
|
||||
description: "Registered in an in-scope frame after index 999",
|
||||
frameId: `webmcp-frame-${String(options.webMcpFrameCount - 1)}`,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(options.webMcpChildLeavesScope === true
|
||||
? [
|
||||
{
|
||||
@@ -90,7 +111,14 @@ export const emitEvents = (
|
||||
});
|
||||
}
|
||||
}
|
||||
emitCaptureNavigation(socket, command, options);
|
||||
};
|
||||
|
||||
const emitSessionTimeline = (
|
||||
socket: WebSocket,
|
||||
command: FakeCdpCommand,
|
||||
port: number,
|
||||
options: FakeOptions,
|
||||
): void => {
|
||||
if (
|
||||
command.method === "Page.setLifecycleEventsEnabled" &&
|
||||
options.sessionTimeline !== undefined
|
||||
|
||||
+10
@@ -66,6 +66,7 @@ const frameTreeResult = (
|
||||
? ":"
|
||||
: (options.electronFileUrl ?? options.attachedFrameUrl),
|
||||
options.extraCollections === true,
|
||||
options.webMcpFrameCount,
|
||||
);
|
||||
|
||||
const resourceTreeResult = (port: number, options: FakeOptions) =>
|
||||
@@ -214,6 +215,7 @@ const frameTree = (
|
||||
port: number,
|
||||
overrideUrl?: string,
|
||||
extraCollections = false,
|
||||
webMcpFrameCount = 0,
|
||||
): Readonly<Record<string, unknown>> => ({
|
||||
frameTree: {
|
||||
frame: {
|
||||
@@ -236,6 +238,14 @@ const frameTree = (
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...Array.from({ length: webMcpFrameCount }, (_value, index) => ({
|
||||
frame: {
|
||||
id: `webmcp-frame-${String(index)}`,
|
||||
parentId: "frame-main",
|
||||
loaderId: `loader-webmcp-${String(index)}`,
|
||||
url: `http://127.0.0.1:${String(port)}/webmcp-frame/${String(index)}`,
|
||||
},
|
||||
})),
|
||||
{
|
||||
frame: {
|
||||
id: "frame-private",
|
||||
|
||||
+1
@@ -57,6 +57,7 @@ export interface FakeOptions {
|
||||
readonly sensitiveShapes?: boolean;
|
||||
readonly invalidResponseBodyBase64?: boolean;
|
||||
readonly webMcpTools?: boolean;
|
||||
readonly webMcpFrameCount?: number;
|
||||
readonly webMcpChildLeavesScope?: boolean;
|
||||
readonly electronFileUrl?: string;
|
||||
readonly duplicateElectronInventory?: boolean;
|
||||
|
||||
Reference in New Issue
Block a user