From 93ecfc8a347471a16d21a5bd9f1cfc99fe39a538 Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Tue, 3 Mar 2026 09:27:05 +0300 Subject: Enha: palywright dom and elements fetching --- tools.go | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'tools.go') diff --git a/tools.go b/tools.go index 87956ef..5683a90 100644 --- a/tools.go +++ b/tools.go @@ -1493,6 +1493,9 @@ func registerPlaywrightTools() { fnMap["pw_screenshot_and_view"] = pwScreenshotAndView fnMap["pw_wait_for_selector"] = pwWaitForSelector fnMap["pw_drag"] = pwDrag + fnMap["pw_get_html"] = pwGetHTML + fnMap["pw_get_dom"] = pwGetDOM + fnMap["pw_search_elements"] = pwSearchElements playwrightTools := []models.Tool{ { Type: "function", @@ -1702,6 +1705,61 @@ func registerPlaywrightTools() { }, }, }, + { + Type: "function", + Function: models.ToolFunc{ + Name: "pw_get_html", + Description: "Get the HTML content of the page or a specific element.", + Parameters: models.ToolFuncParams{ + Type: "object", + Required: []string{}, + Properties: map[string]models.ToolArgProps{ + "selector": models.ToolArgProps{ + Type: "string", + Description: "optional CSS selector (default: body)", + }, + }, + }, + }, + }, + { + Type: "function", + Function: models.ToolFunc{ + Name: "pw_get_dom", + Description: "Get a structured DOM representation of an element with tag, attributes, text, and children.", + Parameters: models.ToolFuncParams{ + Type: "object", + Required: []string{}, + Properties: map[string]models.ToolArgProps{ + "selector": models.ToolArgProps{ + Type: "string", + Description: "optional CSS selector (default: body)", + }, + }, + }, + }, + }, + { + Type: "function", + Function: models.ToolFunc{ + Name: "pw_search_elements", + Description: "Search for elements by text content or CSS selector. Returns matching elements with their tags, text, and HTML.", + Parameters: models.ToolFuncParams{ + Type: "object", + Required: []string{}, + Properties: map[string]models.ToolArgProps{ + "text": models.ToolArgProps{ + Type: "string", + Description: "text to search for in elements", + }, + "selector": models.ToolArgProps{ + Type: "string", + Description: "CSS selector to search for", + }, + }, + }, + }, + }, } baseTools = append(baseTools, playwrightTools...) toolSysMsg += browserToolSysMsg -- cgit v1.2.3