Skip to content
2 min read · 306 words

@nhtio/adk/batteries/generation/_shared

Structural contracts and normalization helpers shared by the media generation batteries (text→image + image editing).

Remarks

This module imports nothing from @nhtio/adk core — not even a type-only import — per CONTRIBUTING.md → Design Decisions → #13 "Battery design — no concrete core-class coupling", tier 2 (locally-declared structural duck-types). A generation adapter is handed an image to edit at runtime (the source image, an optional mask) but never constructs a Media itself, so it has no genuine reason to import the class: GenerationMediaLike declares the exact shape it reads (mimeType + asBytes()), and a real core Media instance satisfies it automatically, with zero import edge between the generation domain and core.

This is the structural twin of src/batteries/specialists/_shared/index.ts restricted to the image half (specialists' audio-specific SpecialistPcmInput / DecodeAudioFn machinery has no counterpart here — generation batteries only ever consume images as input, never audio).

Interfaces

InterfaceDescription
GenerationBytesInputRaw bytes plus an optional MIME type — the plain-object form of image input.
GenerationMediaLikeStructural duck-type of core Media: the exact shape a generation adapter reads off a media value it was handed as edit input — its declared MIME type, and an async accessor for its raw bytes.

Type Aliases

Type AliasDescription
GenerationImageInputAny of the three forms a generation adapter accepts as image input (for edit calls, and for a future mask parameter): a bare Uint8Array (MIME type unknown), a GenerationBytesInput record (bytes + declared MIME), or a GenerationMediaLike (a real Media or any duck-typed equivalent).

Functions

FunctionDescription
toBytesNormalizes any GenerationImageInput form to plain bytes plus an optional MIME type.