MCPcopy Create free account
hub / github.com/diillson/chatcli / loadFirstGeneratedImage

Function loadFirstGeneratedImage

cli/gateway_command.go:453–466  ·  view source on GitHub ↗

loadFirstGeneratedImage reads the first existing image path into an OutboundImage. Returns nil when there is nothing to send or it is unreadable.

(paths []string)

Source from the content-addressed store, hash-verified

451// loadFirstGeneratedImage reads the first existing image path into an
452// OutboundImage. Returns nil when there is nothing to send or it is unreadable.
453func loadFirstGeneratedImage(paths []string) *gateway.OutboundImage {
454 for _, p := range paths {
455 data, err := os.ReadFile(p) //#nosec G304 -- path written by the @image tool during this run, not external input
456 if err != nil || len(data) == 0 {
457 continue
458 }
459 mime, ok := models.DetectImageMediaType(data)
460 if !ok {
461 mime = "image/png"
462 }
463 return &gateway.OutboundImage{Data: data, Mime: mime, FileName: filepath.Base(p)}
464 }
465 return nil
466}
467
468// teeLoggerToGatewayLog adds a JSON sink at gatewayStatePath("gateway.log") to
469// cli.logger so the daemon's structured logs land in the file /gateway start

Callers 1

gatewayAgentFuncMethod · 0.85

Calls 1

DetectImageMediaTypeFunction · 0.92

Tested by

no test coverage detected