(tabId string)
| 16 | ) |
| 17 | |
| 18 | func makeTabCaptureBlockScreenshot(tabId string) func(any) (string, error) { |
| 19 | return func(input any) (string, error) { |
| 20 | inputMap, ok := input.(map[string]any) |
| 21 | if !ok { |
| 22 | return "", fmt.Errorf("invalid input format") |
| 23 | } |
| 24 | |
| 25 | blockIdPrefix, ok := inputMap["widget_id"].(string) |
| 26 | if !ok { |
| 27 | return "", fmt.Errorf("missing or invalid widget_id parameter") |
| 28 | } |
| 29 | |
| 30 | ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second) |
| 31 | defer cancelFn() |
| 32 | |
| 33 | fullBlockId, err := wcore.ResolveBlockIdFromPrefix(ctx, tabId, blockIdPrefix) |
| 34 | if err != nil { |
| 35 | return "", err |
| 36 | } |
| 37 | |
| 38 | rpcClient := wshclient.GetBareRpcClient() |
| 39 | screenshotData, err := wshclient.CaptureBlockScreenshotCommand( |
| 40 | rpcClient, |
| 41 | wshrpc.CommandCaptureBlockScreenshotData{BlockId: fullBlockId}, |
| 42 | &wshrpc.RpcOpts{Route: wshutil.MakeTabRouteId(tabId)}, |
| 43 | ) |
| 44 | if err != nil { |
| 45 | return "", fmt.Errorf("failed to capture screenshot: %w", err) |
| 46 | } |
| 47 | |
| 48 | return screenshotData, nil |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | func GetCaptureScreenshotToolDefinition(tabId string) uctypes.ToolDefinition { |
| 53 | return uctypes.ToolDefinition{ |
no test coverage detected