MCPcopy Index your code
hub / github.com/coder/coder / captureScreenshot

Method captureScreenshot

coderd/x/chatd/chattool/computeruse.go:352–373  ·  view source on GitHub ↗
(
	ctx context.Context,
	conn workspacesdk.AgentConn,
	declaredWidth, declaredHeight int,
)

Source from the content-addressed store, hash-verified

350}
351
352func (t *computerUseTool) captureScreenshot(
353 ctx context.Context,
354 conn workspacesdk.AgentConn,
355 declaredWidth, declaredHeight int,
356) (fantasy.ToolResponse, error) {
357 screenResp, err := executeScreenshotAction(ctx, conn, declaredWidth, declaredHeight)
358 if err != nil {
359 return fantasy.NewTextErrorResponse(
360 fmt.Sprintf("screenshot failed: %v", err),
361 ), nil
362 }
363 screenData, err := base64.StdEncoding.DecodeString(screenResp.ScreenshotData)
364 if err != nil {
365 t.logger.Error(ctx, "failed to decode screenshot base64 in captureScreenshot",
366 slog.Error(err),
367 )
368 return fantasy.NewTextErrorResponse(
369 fmt.Sprintf("failed to decode screenshot data: %v", err),
370 ), nil
371 }
372 return fantasy.NewImageResponse(screenData, "image/png"), nil
373}
374
375func (t *computerUseTool) captureSharedScreenshot(
376 ctx context.Context,

Callers 1

Calls 3

executeScreenshotActionFunction · 0.85
DecodeStringMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected