mirror of
https://github.com/instructkr/claw-code.git
synced 2026-06-05 22:17:10 +08:00
Cherry-picked from PR #2816 onto current upstream/main, resolving conflicts from PR #3015's merge (which added retry_after to ApiError but some construction sites were missing it). Commits preserved: -ade85398: API timeout config, Retry-After header, configurable retry - TimeoutConfig in HTTP client builder (connect 30s, request 5min) - CLAW_API_CONNECT_TIMEOUT and CLAW_API_REQUEST_TIMEOUT env vars - Retry-After header parsing on 429 responses - ApiTimeoutConfig in runtime config (settings.json) -8a883430: retry 400 responses with transient gateway error bodies - Detects known gateway phrases in 400 response bodies - Marks them as retryable instead of hard-failing -ed91a61e: add 'no parseable body' to CONTEXT_WINDOW_ERROR_MARKERS - Some providers return 400 with 'no parseable body' for oversized requests instead of a proper context_length_exceeded error Commits skipped (already in upstream via PR #3015): -453ab642: optional id field (already merged) -baa8d1ba: HTML detection in streaming (already merged) -33d2f789: JSON error detection in streaming (already merged) 8 files changed, 299 insertions, 80 deletions
47 lines
1.9 KiB
Rust
47 lines
1.9 KiB
Rust
mod client;
|
|
mod error;
|
|
mod http_client;
|
|
mod prompt_cache;
|
|
mod providers;
|
|
mod sse;
|
|
mod types;
|
|
|
|
pub use client::{
|
|
oauth_token_is_expired, read_base_url, read_xai_base_url, resolve_saved_oauth_token,
|
|
resolve_startup_auth_source, MessageStream, OAuthTokenSet, ProviderClient,
|
|
};
|
|
pub use error::ApiError;
|
|
pub use http_client::{
|
|
build_http_client, build_http_client_or_default, build_http_client_with,
|
|
build_http_client_with_opts, ProxyConfig, TimeoutConfig,
|
|
};
|
|
pub use prompt_cache::{
|
|
CacheBreakEvent, PromptCache, PromptCacheConfig, PromptCachePaths, PromptCacheRecord,
|
|
PromptCacheStats,
|
|
};
|
|
pub use providers::anthropic::{AnthropicClient, AnthropicClient as ApiClient, AuthSource};
|
|
pub use providers::openai_compat::{
|
|
build_chat_completion_request, check_request_body_size, estimate_request_body_size,
|
|
flatten_tool_result_content, is_reasoning_model, model_rejects_is_error_field,
|
|
model_requires_reasoning_content_in_history, translate_message, OpenAiCompatClient,
|
|
OpenAiCompatConfig,
|
|
};
|
|
pub use providers::{
|
|
detect_provider_kind, max_tokens_for_model, max_tokens_for_model_with_override,
|
|
model_family_identity_for, model_family_identity_for_kind, provider_diagnostics_for_model,
|
|
resolve_model_alias, ProviderDiagnostics, ProviderKind,
|
|
};
|
|
pub use sse::{parse_frame, SseParser};
|
|
pub use types::{
|
|
ContentBlockDelta, ContentBlockDeltaEvent, ContentBlockStartEvent, ContentBlockStopEvent,
|
|
InputContentBlock, InputMessage, MessageDelta, MessageDeltaEvent, MessageRequest,
|
|
MessageResponse, MessageStartEvent, MessageStopEvent, OutputContentBlock, StreamEvent,
|
|
ToolChoice, ToolDefinition, ToolResultContentBlock, Usage,
|
|
};
|
|
|
|
pub use telemetry::{
|
|
AnalyticsEvent, AnthropicRequestProfile, ClientIdentity, JsonlTelemetrySink,
|
|
MemoryTelemetrySink, SessionTraceRecord, SessionTracer, TelemetryEvent, TelemetrySink,
|
|
DEFAULT_ANTHROPIC_VERSION,
|
|
};
|