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
//! LLM transports for trusty-code: the shared OpenAI-compatible adapter
//! (OpenRouter / Fireworks) and AWS Bedrock (Converse API).
//!
//! Why: trusty-code agents need to invoke LLMs via OpenAI-compatible endpoints
//! (OpenRouter, and — since #2406 — Fireworks) OR, for organisations running on
//! AWS (#1021), via Bedrock's Converse API. Both transports speak the same
//! provider-neutral `ChatRequest`/`ChatResponse` shape so `AgentLoop` and every
//! other caller never branches on the backend. The OpenAI-compatible HTTP
//! mechanics now live in the shared `trusty_common::inference` adapter layer
//! (epic #2400) rather than a bespoke tcode client — `OpenAiCompatClient`
//! (`client`) is the thin consumer of that core, bridged to tcode's wire types
//! by `convert`.
//! What: This module exports `OpenAiCompatClient` (shared OpenRouter/Fireworks
//! transport), `BedrockChatClient` (Bedrock Converse), `DispatchingLlmClient`
//! (routes each request to the right transport by model slug via
//! `crate::provider::provider_for`), 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.
//! OpenRouter/Fireworks credentials are resolved via the shared 3-tier chain
//! (process env > `.env.local` > secure store); Bedrock uses the standard AWS
//! credential chain (no key). Library helpers never read `std::env` for secrets
//! directly — resolution is centralised in the shared resolver.
//! Test: `cargo test -p trusty-code` covers all unit tests (serialisation,
//! deserialisation, type conversion + error mapping, Bedrock message/tool-choice/
//! response conversion, debug-capture) plus the offline black-box HTTP round-trip
//! in `tests/inference_shared_adapter_e2e.rs`. `cargo test -p trusty-code --
//! --include-ignored` additionally runs the live
//! `live_openrouter_call`/`live_fireworks_call`/`live_bedrock_call` tests.
// ── Public API re-exports ─────────────────────────────────────────────────────
pub use BedrockChatClient;
pub use OpenAiCompatClient;
pub use LlmClientTrait;
pub use ;
pub use DispatchingLlmClient;
pub use LlmError;
pub use ChatMessage;
pub use ;
pub use ;
pub use ;
pub use UsageBlock;