-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathinPage.ts
More file actions
50 lines (44 loc) · 1.2 KB
/
inPage.ts
File metadata and controls
50 lines (44 loc) · 1.2 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
/**
* @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;
execute: (input: Record<string, unknown>) => unknown;
}
export interface ToolGroup {
name: string;
description: string;
tools: ToolDefinition[];
}
declare global {
interface Window {
__dtmcp?: {
toolGroup?: ToolGroup;
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.
In-page-tools are exposed on the page via the 'window.__dtmcp.executeTool(toolName, params)'
function where they can be called by 'evaluate_script'.`,
annotations: {
category: ToolCategory.IN_PAGE,
readOnlyHint: true,
},
schema: {},
handler: async (_request, response, _context) => {
response.setListInPageTools();
},
});