Documentation
¶
Overview ¶
Package imageextract externalizes inline base64 images from an agent's session transcript into a checkpoint asset store, replacing each with a compact, path-bearing placeholder, and re-injects them byte-exactly on restore.
The transform is per-agent because transcript formats differ: only agents that inline base64 images (Claude Code and Codex today) register a codec; every other agent resolves to nil and its transcript flows through untouched (a graceful no-op). All codecs share one extraction engine and reinjection routine and differ only in how they *find* images (their collector).
Correctness contract: for any transcript x from a supported agent, ReinjectImages(ExtractImages(x)) == x, byte-for-byte. This is achieved by only ever swapping the base64 image *value* in place (never re-marshalling the JSON) and by refusing to externalize any image whose raw bytes don't re-encode to the exact original base64 string.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasPlaceholders ¶
HasPlaceholders reports whether a transcript carries any externalized-image placeholders — so restore knows to reinject regardless of the current config.
Types ¶
type Asset ¶
type Asset = agent.CompactedTranscriptAsset
Asset is one externalized image. It reuses the canonical agent asset model; Name is the stable asset filename (also the id used in the placeholder).
type ImageCodec ¶
type ImageCodec interface {
// ExtractImages lifts inline base64 images out, returning the rewritten
// (placeholder-bearing) transcript plus the extracted assets. A transcript
// with no externalizable images is returned unchanged with nil assets.
ExtractImages(transcript []byte) (rewritten []byte, assets []Asset, err error)
// ReinjectImages restores the original transcript by looking each placeholder's
// asset up by Name. Placeholders whose asset is missing are left in place.
ReinjectImages(transcript []byte, lookup func(name string) (Asset, bool)) ([]byte, error)
}
ImageCodec extracts/reinjects inline images for one agent's transcript format.
func CodecFor ¶
func CodecFor(t types.AgentType) ImageCodec
CodecFor returns the image codec for an agent type, or nil if the agent's transcript is not known to inline images (a no-op).