MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / makeTabCaptureBlockScreenshot

Function makeTabCaptureBlockScreenshot

pkg/aiusechat/tools_screenshot.go:18–50  ·  view source on GitHub ↗
(tabId string)

Source from the content-addressed store, hash-verified

16)
17
18func 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
52func GetCaptureScreenshotToolDefinition(tabId string) uctypes.ToolDefinition {
53 return uctypes.ToolDefinition{

Callers 1

Calls 4

ResolveBlockIdFromPrefixFunction · 0.92
GetBareRpcClientFunction · 0.92
MakeTabRouteIdFunction · 0.92

Tested by

no test coverage detected