Skip to content

Commit a1306ea

Browse files
committed
format
1 parent 9b3dfce commit a1306ea

4 files changed

Lines changed: 56 additions & 52 deletions

File tree

src/McpResponse.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ interface TraceInsightData {
4141
insightName: InsightName;
4242
}
4343

44-
async function getToolGroup(page: McpPage): Promise<ToolGroup<ToolDefinition> | undefined> {
44+
async function getToolGroup(
45+
page: McpPage,
46+
): Promise<ToolGroup<ToolDefinition> | undefined> {
4547
// Check if there is a `devtoolstooldiscovery` event listener
4648
const windowHandle = await page.pptrPage.evaluateHandle(() => window);
4749
// @ts-expect-error internal API

src/tools/inPage.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ export interface ToolGroup<T extends ToolDefinition> {
2424
declare global {
2525
interface Window {
2626
__dtmcp?: {
27-
toolGroup?: ToolGroup<ToolDefinition & {execute: (args: Record<string, unknown>) => unknown}>;
27+
toolGroup?: ToolGroup<
28+
ToolDefinition & {execute: (args: Record<string, unknown>) => unknown}
29+
>;
2830
executeTool?: (
2931
toolName: string,
3032
args: Record<string, unknown>,

tests/index.test.ts

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -72,58 +72,56 @@ describe('e2e', () => {
7272
});
7373

7474
it('has all tools', async () => {
75-
await withClient(
76-
async client => {
77-
const {tools} = await client.listTools();
78-
const exposedNames = tools.map(t => t.name).sort();
79-
const files = fs.readdirSync('build/src/tools');
80-
const definedNames = [];
81-
for (const file of files) {
82-
if (
83-
file === 'ToolDefinition.js' ||
84-
file === 'tools.js' ||
85-
file === 'slim'
86-
) {
87-
continue;
88-
}
89-
const fileTools = await import(`../src/tools/${file}`);
90-
for (const maybeTool of Object.values<unknown>(fileTools)) {
91-
if (typeof maybeTool === 'function') {
92-
const tool = (maybeTool as (val: boolean) => ToolDefinition)(
93-
false,
94-
);
95-
if (tool && typeof tool === 'object' && 'name' in tool) {
96-
if (tool.annotations?.conditions) {
97-
continue;
98-
}
99-
definedNames.push(tool.name);
100-
}
101-
continue;
102-
}
103-
if (
104-
typeof maybeTool === 'object' &&
105-
maybeTool !== null &&
106-
'name' in maybeTool
107-
) {
108-
const tool = maybeTool as ToolDefinition;
75+
await withClient(async client => {
76+
const {tools} = await client.listTools();
77+
const exposedNames = tools.map(t => t.name).sort();
78+
const files = fs.readdirSync('build/src/tools');
79+
const definedNames = [];
80+
for (const file of files) {
81+
if (
82+
file === 'ToolDefinition.js' ||
83+
file === 'tools.js' ||
84+
file === 'slim'
85+
) {
86+
continue;
87+
}
88+
const fileTools = await import(`../src/tools/${file}`);
89+
for (const maybeTool of Object.values<unknown>(fileTools)) {
90+
if (typeof maybeTool === 'function') {
91+
const tool = (maybeTool as (val: boolean) => ToolDefinition)(false);
92+
if (tool && typeof tool === 'object' && 'name' in tool) {
10993
if (tool.annotations?.conditions) {
11094
continue;
11195
}
11296
definedNames.push(tool.name);
11397
}
98+
continue;
99+
}
100+
if (
101+
typeof maybeTool === 'object' &&
102+
maybeTool !== null &&
103+
'name' in maybeTool
104+
) {
105+
const tool = maybeTool as ToolDefinition;
106+
if (tool.annotations?.conditions) {
107+
continue;
108+
}
109+
definedNames.push(tool.name);
114110
}
115111
}
116-
definedNames.sort();
117-
assert.deepStrictEqual(exposedNames, definedNames);
118-
},
119-
);
112+
}
113+
definedNames.sort();
114+
assert.deepStrictEqual(exposedNames, definedNames);
115+
});
120116
});
121117

122118
it('has experimental in-Page tools', async () => {
123119
await withClient(
124120
async client => {
125121
const {tools} = await client.listTools();
126-
const listInPageTools = tools.find(t => t.name === 'list_in_page_tools');
122+
const listInPageTools = tools.find(
123+
t => t.name === 'list_in_page_tools',
124+
);
127125
assert.ok(listInPageTools);
128126
},
129127
['--category-in-page-tools'],
@@ -134,7 +132,9 @@ describe('e2e', () => {
134132
await withClient(
135133
async client => {
136134
const {tools} = await client.listTools();
137-
const installExtension = tools.find(t => t.name === 'install_extension');
135+
const installExtension = tools.find(
136+
t => t.name === 'install_extension',
137+
);
138138
assert.ok(installExtension);
139139
},
140140
['--category-extensions'],

tests/tools/inPage.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ describe('inPage', () => {
5353
assert.strictEqual(actualGroup.description, 'test description');
5454
assert.strictEqual(actualGroup.tools.length, 1);
5555
assert.strictEqual(actualGroup.tools[0].name, 'test-tool');
56-
assert.strictEqual(
57-
actualGroup.tools[0].description,
58-
'test tool description',
59-
);
60-
assert.deepEqual(actualGroup.tools[0].inputSchema, {
61-
type: 'object',
62-
properties: {
63-
arg: {type: 'string'},
64-
},
65-
});
56+
assert.strictEqual(
57+
actualGroup.tools[0].description,
58+
'test tool description',
59+
);
60+
assert.deepEqual(actualGroup.tools[0].inputSchema, {
61+
type: 'object',
62+
properties: {
63+
arg: {type: 'string'},
64+
},
65+
});
6666
},
6767
undefined,
6868
{categoryInPageTools: true} as ParsedArguments,

0 commit comments

Comments
 (0)