1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//! v2 attachment table — binary payloads referenced by content blocks.
//!
//! Per ADR 0015 §"v2 Attachment", as amended by ADR 0016 (consumer
//! decodes media before sending). Attachments are sent once at the
//! request envelope's top level and referenced by `id` from any
//! number of `image` / `audio` / `video` content blocks across the
//! request's `messages[]`. This indirection matches the Anthropic
//! shape and lets a multi-image conversation avoid duplicating bytes.
//!
//! ## Decode posture (ADR 0013 + ADR 0016)
//!
//! The wire carries **already-decoded** binary payloads — raw RGB
//! interleaved bytes for images, float32 PCM samples for audio.
//! The daemon does *not* link image/audio codec libraries; consumer
//! middleware decodes before sending. This matches ADR 0013's
//! gateway framing ("middleware owns the bytes") and matches what
//! libmtmd's C API expects (`mtmd_bitmap_init` takes `nx * ny * 3`
//! interleaved RGB; `mtmd_bitmap_init_from_audio` takes a float32
//! PCM slice).
//!
//! Each attachment kind carries the metadata it needs:
//! - `Image`: `width`, `height` (the daemon recomputes nothing).
//! - `Audio`: `sample_rate` (Hz; the daemon doesn't resample).
//! - `Video`: reserved; the actual shape is TBD when a video-
//! capable adapter lands.
use ;
/// One binary attachment in the request's top-level `attachments[]` table.
///
/// Tagged-enum shape: each variant carries exactly the metadata libmtmd
/// (and other engines' multimodal interfaces) need for that modality.
/// Unknown variants deserialise as [`Attachment::Unknown`] so v2.0
/// clients don't reject newer payloads at parse time; resolve()
/// rejects them only when they reach validation.
///
/// `id` must be unique within a single request; content blocks
/// reference attachments by exactly this string.
///
/// `bytes` is standard-base64-encoded (RFC 4648, with `+/` and `=`
/// padding). After ~1.33× inflation the raw payload must still leave
/// room within the 64 MiB per-frame cap.