Skip to content

Chrome DevTools for coding agents

refactor: extract common paginate type (#415)

Nikolay Vitkov29fd60216ca1
diff --git a/src/McpResponse.ts b/src/McpResponse.ts
index a3890f3a..24e8e157 100644
--- a/src/McpResponse.ts
+++ b/src/McpResponse.ts
@@ -21,7 +21,8 @@ import type {
} from './third_party/modelcontextprotocol-sdk/index.js';
import {handleDialog} from './tools/pages.js';
import type {ImageContentData, Response} from './tools/ToolDefinition.js';
-import {paginate, type PaginationOptions} from './utils/pagination.js';
+import {paginate} from './utils/pagination.js';
+import type {PaginationOptions} from './utils/types.js';
interface NetworkRequestData {
networkRequestStableId: number;
@@ -65,9 +66,7 @@ export class McpResponse implements Response {
setIncludeNetworkRequests(
value: boolean,
- options?: {
- pageSize?: number;
- pageIdx?: number;
+ options?: PaginationOptions & {
resourceTypes?: ResourceType[];
},
): void {
@@ -91,9 +90,7 @@ export class McpResponse implements Response {
setIncludeConsoleData(
value: boolean,
- options?: {
- pageSize?: number;
- pageIdx?: number;
+ options?: PaginationOptions & {
types?: string[];
},
): void {
diff --git a/src/tools/ToolDefinition.ts b/src/tools/ToolDefinition.ts
index e920417c..f5cb454b 100644
--- a/src/tools/ToolDefinition.ts
+++ b/src/tools/ToolDefinition.ts
@@ -9,6 +9,7 @@ import z from 'zod';
import type {TextSnapshotNode} from '../McpContext.js';
import type {TraceResult} from '../trace-processing/parse.js';
+import type {PaginationOptions} from '../utils/types.js';
import type {ToolCategories} from './categories.js';
@@ -45,11 +46,15 @@ export interface Response {
setIncludePages(value: boolean): void;
setIncludeNetworkRequests(
value: boolean,
- options?: {pageSize?: number; pageIdx?: number; resourceTypes?: string[]},
+ options?: PaginationOptions & {
+ resourceTypes?: string[];
+ },
): void;
setIncludeConsoleData(
value: boolean,
- options?: {pageSize?: number; pageIdx?: number; types?: string[]},
+ options?: PaginationOptions & {
+ types?: string[];
+ },
): void;
setIncludeSnapshot(value: boolean): void;
setIncludeSnapshot(value: boolean, verbose?: boolean): void;
diff --git a/src/utils/pagination.ts b/src/utils/pagination.ts
index 8041cc4b..f9ffe35b 100644
--- a/src/utils/pagination.ts
+++ b/src/utils/pagination.ts
@@ -4,10 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
-export interface PaginationOptions {
- pageSize?: number;
- pageIdx?: number;
-}
+import type {PaginationOptions} from './types.js';
export interface PaginationResult<Item> {
items: readonly Item[];
diff --git a/src/utils/types.ts b/src/utils/types.ts
new file mode 100644
index 00000000..997bc58f
--- /dev/null
+++ b/src/utils/types.ts
@@ -0,0 +1,10 @@
+/**
+ * @license
+ * Copyright 2025 Google LLC
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+export interface PaginationOptions {
+ pageSize?: number;
+ pageIdx?: number;
+}