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
//! Native LLM clients for trusty-code: OpenRouter (HTTP) and AWS Bedrock
//! (Converse API).
//!
//! Why: trusty-code agents need to invoke LLMs via OpenRouter's chat-
//! completions endpoint OR, for organisations running on AWS (#1021), via
//! Bedrock's Converse API — without pulling in a third-party SDK
//! (`async-openai`, etc.) that pins us to one provider's contract. Both
//! transports speak the same provider-neutral `ChatRequest`/`ChatResponse`
//! shape so `AgentLoop` and every other caller never branches on the
//! backend.
//! What: This module exports `LlmClient` (OpenRouter HTTP), `BedrockChatClient`
//! (Bedrock Converse), `DispatchingLlmClient` (routes each request to the
//! right transport by model slug via `crate::provider::provider_for`),
//! `LlmClientConfig`, all request/response types (`ChatRequest`,
//! `ChatResponse`, `ChatMessage`, `ToolDefinition`, …), `LlmError`, and
//! (#2264) the opt-in `debug_capture` module — `DebugCaptureSink` +
//! `wrap_with_debug_capture` — that dumps the FULL wire-level request/
//! response of every round-trip to JSONL when `TCODE_DEBUG_TRANSCRIPT` is
//! set. The OpenRouter API key is injected at construction time via
//! `LlmClientConfig::new`/`from_env`; Bedrock uses the standard AWS
//! credential chain (no key). Library helpers never read `std::env` directly
//! except at these documented construction seams.
//! Test: `cargo test -p trusty-code` covers all unit tests (serialisation,
//! deserialisation, error mapping, Bedrock message/tool-choice/response
//! conversion, debug-capture). `cargo test -p trusty-code -- --include-ignored`
//! additionally runs the live `live_openrouter_call`/`live_bedrock_call` tests.
// ── Public API re-exports ─────────────────────────────────────────────────────
pub use BedrockChatClient;
pub use ;
pub use LlmClientTrait;
pub use ;
pub use DispatchingLlmClient;
pub use LlmError;
pub use ChatMessage;
pub use ;
pub use ;
pub use ;
pub use UsageBlock;