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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
//! AWS Bedrock Converse transport — a thin bridge onto `trusty_common::inference`
//! (#2407 migration).
//!
//! Why: the entire Bedrock Converse wire integration (region resolution, the AWS
//! credential chain, the `ChatRequest`/`ChatResponse` <-> Converse conversion,
//! and the `cachePoint` prompt-cache translation) moved into the shared
//! `trusty_common::inference::bedrock` adapter in #2407, so every consumer shares
//! ONE implementation instead of tcode owning a private ~1000-SLOC copy. This
//! module is what remains in tcode: a thin wrapper that delegates every method
//! to the shared adapter — zero local Bedrock/Converse logic.
//! What: [`BedrockChatClient`] wraps a
//! [`trusty_common::inference::BedrockAdapter`] and implements
//! [`InferenceAdapter`] by delegation. Since #4425 unified trusty-code's wire
//! types with `trusty_common::inference`'s, the wrapper no longer converts
//! anything: the request, the response, and the error type are already the
//! shared ones, so the former `super::convert` bridge is gone. The shared
//! adapter constructs its AWS client lazily on first `chat`, so
//! [`Self::from_env`]/[`Self::new`] touch no AWS credentials.
//! [`Self::new`]/[`Self::region`] are thin passthroughs kept for public-API
//! compatibility with the pre-#2407 local transport (no in-tree caller uses
//! them post-migration, but this is a published rlib crate and the surface
//! removal would otherwise be undocumented/silent).
//!
//! Streaming (#4425/#4426): [`Self::chat_stream`] forwards to the shared
//! adapter's, which since #4426 is a NATIVE `ConverseStream` transport — a
//! Bedrock turn arrives token-by-token, not as one buffered delta. This
//! wrapper needed no edit for that (only this doc line): because it delegates
//! rather than reimplements, the whole change landed inside
//! `trusty_common::inference::bedrock`.
//! Test: `bedrock::tests::*` (offline construction) plus the shared adapter's own
//! conversion + `#[ignore]`-gated live coverage in
//! `trusty_common::inference::bedrock`.
use async_trait;
use ;
/// AWS Bedrock Converse transport, backed by the shared inference adapter.
///
/// Why: satisfies the same `chat(&ChatRequest) -> Result<ChatResponse, ..>`
/// contract every other tcode transport exposes, so `DispatchingLlmClient`
/// (`super::dispatch`) can route `bedrock/*` slugs here without any caller
/// knowing the backend differs — while the Converse mechanics live in
/// `trusty_common::inference::bedrock`, not in this crate.
/// What: holds a shared [`BedrockAdapter`] (which owns the resolved region and a
/// lazily-built AWS client). `Debug` so `DispatchingLlmClient`'s
/// `OnceCell<BedrockChatClient>` can derive it.
/// Test: `bedrock::tests::from_env_constructs_offline`.
/// Delegating [`InferenceAdapter`] impl (#4425).
///
/// Why: `DispatchingLlmClient` routes `bedrock/*` slugs here through the SHARED
/// trait, so this wrapper must satisfy that trait rather than expose a
/// look-alike inherent `chat`. Every method delegates — including the
/// capability and tool-choice hooks, which Bedrock overrides with the
/// Anthropic dialect: forwarding them (instead of inheriting the trait's
/// OpenAI-dialect defaults) is what keeps a `bedrock/*` turn wire-identical to
/// calling the shared adapter directly.
/// What: name/capabilities/chat/chat_stream/map_tool_choice all forward to
/// [`BedrockAdapter`]. The capability-derived `supports_*` defaults need no
/// override because they read `capabilities()`, which is forwarded.
/// Test: `bedrock::tests::*`; wire behaviour is covered by the shared adapter's
/// own tests.
// ── Tests ─────────────────────────────────────────────────────────────────────