MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / transform_messages

Function transform_messages

crates/opencode-provider/src/transform.rs:619–645  ·  view source on GitHub ↗
(
    messages: &mut Vec<Message>,
    provider_type: ProviderType,
    model_id: &str,
    supported_modalities: &[Modality],
    npm: &str,
    provider_id: &str,
)

Source from the content-addressed store, hash-verified

617// ---------------------------------------------------------------------------
618
619pub fn transform_messages(
620 messages: &mut Vec<Message>,
621 provider_type: ProviderType,
622 model_id: &str,
623 supported_modalities: &[Modality],
624 npm: &str,
625 provider_id: &str,
626) {
627 unsupported_parts(messages, supported_modalities);
628 normalize_messages(messages, provider_type, model_id);
629
630 // TS: apply caching when the model is anthropic/claude/bedrock, but NOT gateway.
631 // Checks: providerID == "anthropic", api.id contains "anthropic"/"claude",
632 // model.id contains "anthropic"/"claude", or npm == "@ai-sdk/anthropic"
633 let id_lower = model_id.to_lowercase();
634 let pid_lower = provider_id.to_lowercase();
635 let is_anthropic_like = pid_lower == "anthropic"
636 || id_lower.contains("anthropic")
637 || id_lower.contains("claude")
638 || npm == "@ai-sdk/anthropic";
639 if is_anthropic_like && npm != "@ai-sdk/gateway" {
640 apply_caching(messages, provider_type);
641 }
642
643 // Remap providerOptions keys from stored providerID to expected SDK key
644 remap_provider_options(messages, npm, provider_id);
645}
646
647/// Remap providerOptions keys from the stored `provider_id` to the expected SDK key.
648/// Matches the TS logic that remaps `providerOptions[providerID]` -> `providerOptions[sdkKey]`.

Callers

nothing calls this directly

Calls 5

unsupported_partsFunction · 0.85
normalize_messagesFunction · 0.85
apply_cachingFunction · 0.85
remap_provider_optionsFunction · 0.85
containsMethod · 0.80

Tested by

no test coverage detected