-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathinPage.ts
More file actions
52 lines (46 loc) · 1.24 KB
/
inPage.ts
File metadata and controls
52 lines (46 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* @license
* Copyright 2026 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import {type JSONSchema7} from '../third_party/index.js';
import {ToolCategory} from './categories.js';
import {definePageTool} from './ToolDefinition.js';
export interface ToolDefinition {
name: string;
description: string;
inputSchema: JSONSchema7;
}
export interface ToolGroup<T extends ToolDefinition> {
name: string;
description: string;
tools: T[];
}
declare global {
interface Window {
__dtmcp?: {
toolGroup?: ToolGroup<
ToolDefinition & {execute: (args: Record<string, unknown>) => unknown}
>;
executeTool?: (
toolName: string,
args: Record<string, unknown>,
) => unknown;
};
}
}
export const listInPageTools = definePageTool({
name: 'list_in_page_tools',
description: `Lists all in-page-tools the page exposes for providing runtime information.
To call 'list_in_page_tools', call 'evaluate_script' with
'window.__dtmcp.executeTool("list_in_page_tools", {})'.`,
annotations: {
category: ToolCategory.IN_PAGE,
readOnlyHint: true,
conditions: ['inPageTools'],
},
schema: {},
handler: async (_request, response, _context) => {
response.setListInPageTools();
},
});