File size: 3,871 Bytes
c52954a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
WEB_AGENT_SYSTEM_PROMPT = """
You are a 'web agent' capable of performing browser-based goals.
You use the PinchTab browser control plane to navigate the web, perceive page state via accessibility tree snapshots, and perform actions like clicking, typing, and scrolling.

### Guidelines:
1.  **Observe first**: Always start by navigating to the target URL and taking a snapshot to understand the page structure.
2.  **Use References**: Use the `ref` (e.g., 'e5', 'e12') from the accessibility tree snapshot to interact with elements.
3.  **Be Incremental**: If a goal is complex, break it down into smaller steps (e.g., Search -> Click Result -> Extract Info).
4.  **Confirm Success**: After an action, take another snapshot or check the page text to verify the expected change occurred.
5.  **Efficiency**: Favor the accessibility tree snapshot (`browser.snapshot`) over full page text when looking for interactive elements.

Today's date: {current_date}
""".strip()

WEB_TOOL_CONTENT = [
    {
        "type": "function",
        "function": {
            "name": "browser.navigate",
            "description": "Navigates the browser to a specific URL.",
            "parameters": {
                "type": "object",
                "properties": {
                    "url": {"type": "string", "description": "The URL to navigate to"}
                },
                "required": ["url"]
            }
        }
    },
    {
        "type": "function",
        "function": {
            "name": "browser.snapshot",
            "description": "Captures a snapshot of the current page's accessibility tree, showing interactive elements and their references.",
            "parameters": {
                "type": "object",
                "properties": {
                    "filter": {
                        "type": "string",
                        "enum": ["interactive", "all"],
                        "default": "interactive",
                        "description": "Whether to show only interactive elements or the entire tree."
                    }
                }
            }
        }
    },
    {
        "type": "function",
        "function": {
            "name": "browser.click",
            "description": "Clicks an element identified by its reference (ref) from the snapshot.",
            "parameters": {
                "type": "object",
                "properties": {
                    "ref": {"type": "string", "description": "The element reference (e.g., 'e5')"}
                },
                "required": ["ref"]
            }
        }
    },
    {
        "type": "function",
        "function": {
            "name": "browser.type",
            "description": "Types text into an element identified by its reference (ref).",
            "parameters": {
                "type": "object",
                "properties": {
                    "ref": {"type": "string", "description": "The element reference (e.g., 'e5')"},
                    "text": {"type": "string", "description": "The text to type"}
                },
                "required": ["ref", "text"]
            }
        }
    },
    {
        "type": "function",
        "function": {
            "name": "browser.press",
            "description": "Presses a specific key (e.g., 'Enter', 'Tab').",
            "parameters": {
                "type": "object",
                "properties": {
                    "key": {"type": "string", "description": "The key to press"}
                },
                "required": ["key"]
            }
        }
    },
    {
        "type": "function",
        "function": {
            "name": "browser.get_text",
            "description": "Extracts all visible text from the current page.",
            "parameters": {
                "type": "object",
                "properties": {}
            }
        }
    }
]