mirror of
https://github.com/browseros-ai/BrowserOS.git
synced 2026-05-18 11:06:19 +00:00
git-subtree-dir: packages/browseros-agent git-subtree-mainline:8f148d0918git-subtree-split:90bd4be300
43 lines
930 B
Go
43 lines
930 B
Go
package cmd
|
|
|
|
import (
|
|
"browseros-cli/output"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func init() {
|
|
cmd := &cobra.Command{
|
|
Use: "snap",
|
|
Annotations: map[string]string{"group": "Observe:"},
|
|
Short: "Snapshot interactive elements on the page",
|
|
Args: cobra.NoArgs,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
enhanced, _ := cmd.Flags().GetBool("enhanced")
|
|
c := newClient()
|
|
pageID, err := resolvePageID(c)
|
|
if err != nil {
|
|
output.Error(err.Error(), 2)
|
|
}
|
|
|
|
toolName := "take_snapshot"
|
|
if enhanced {
|
|
toolName = "take_enhanced_snapshot"
|
|
}
|
|
|
|
result, err := c.CallTool(toolName, map[string]any{"page": pageID})
|
|
if err != nil {
|
|
output.Error(err.Error(), 1)
|
|
}
|
|
if jsonOut {
|
|
output.JSON(result)
|
|
} else {
|
|
output.Text(result)
|
|
}
|
|
},
|
|
}
|
|
|
|
cmd.Flags().BoolP("enhanced", "e", false, "Detailed accessibility tree with structural context")
|
|
rootCmd.AddCommand(cmd)
|
|
}
|