Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849package daemon
import ( "context" "encoding/base64" "fmt" "io" "net/http"
"albedo/cli/internal/daemon/protocol")
// ReadHistoryImage uses the declared image resource and the shared transport's// authentication/read recovery, never a private editor HTTP path.func ReadHistoryImage(ctx context.Context, conn *Connection, session, entry string, index int, mime ImageMimeType) (ImageAttachment, error) { switch mime { case ImagePNG, ImageJPEG, ImageWEBP: default: return ImageAttachment{}, fieldError("image MIME type") } data, err := requestBytes(ctx, conn, operation{Name: "read history image", BuildRequest: func(base string, _ io.Reader) (*http.Request, error) { return protocol.NewGetHistoryImageRequest(base, session, entry, fmt.Sprintf("image-%d", index)) }, Policy: readRecovery}, responseLimits{successStatus: 200, bodyBytes: 5 << 20, errorBytes: 64 << 10}) if err != nil { return ImageAttachment{}, err } return ImageAttachment{Data: base64.StdEncoding.EncodeToString(data), ImageMetadata: ImageMetadata{MimeType: mime, Bytes: len(data)}}, nil}
type ImageMimeType string
const ( ImagePNG ImageMimeType = "image/png" ImageJPEG ImageMimeType = "image/jpeg" ImageWEBP ImageMimeType = "image/webp")
type ImageMetadata struct { MimeType ImageMimeType `json:"mime_type"` Width int `json:"width"` Height int `json:"height"` Bytes int `json:"bytes"`}
type ImageAttachment struct { Data string `json:"data"` ImageMetadata}