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
//! 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 `LlmClientTrait`-shaped wrapper that
//! bridges tcode's wire types to the shared adapter at exactly one seam (reusing
//! `super::convert`, the same field-by-field bridge #2406 established for the
//! OpenAI-compatible transport) — zero local Bedrock/Converse logic.
//! What: [`BedrockChatClient`] wraps a
//! [`trusty_common::inference::BedrockAdapter`]. `chat` converts the request via
//! [`super::convert::to_shared_request`] (passing the FULL `bedrock/`-prefixed
//! slug as the wire model — the shared adapter strips the prefix before the AWS
//! call and keeps it for telemetry), delegates to the shared adapter, maps its
//! [`trusty_common::inference::InferenceError`] back to [`LlmError`] via
//! [`super::convert::map_error`], and converts the response via
//! [`super::convert::from_shared_response`]. 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).
//! Test: `bedrock::tests::*` (offline construction) plus the shared adapter's own
//! conversion + `#[ignore]`-gated live coverage in
//! `trusty_common::inference::bedrock`.
use ;
use ;
use LlmError;
use ChatRequest;
use ChatResponse;
/// 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`.
// ── Tests ─────────────────────────────────────────────────────────────────────