- Add firstChunkTimestamp field to ResponseWriterWrapper for sync capture
- Capture TTFB in Write() and WriteString() before async channel send
- Add SetFirstChunkTimestamp() to StreamingLogWriter interface
- Make requestTimestamp/apiResponseTimestamp required in LogRequest()
- Remove timestamp capture from WriteAPIResponse() (now via setter)
- Fix Gemini handler to set API_RESPONSE_TIMESTAMP before writing response
This ensures accurate TTFB measurement for all streaming API formats
(OpenAI, Gemini, Claude) by capturing timestamp synchronously when
the first response chunk arrives, not when the stream finalizes.
Cherry-picked from upstream: 295f34d7
Co-Authored-By: Claude (gemini-claude-opus-4-5-thinking) <noreply@anthropic.com>
Previously:
- REQUEST INFO timestamp was captured at log write time (not request arrival)
- API RESPONSE had NO timestamp at all
This fix:
- Captures REQUEST INFO timestamp when request first arrives
- Adds API RESPONSE timestamp when upstream response arrives
- Add Timestamp field to RequestInfo, set at middleware initialization
- Set API_RESPONSE_TIMESTAMP in appendAPIResponse() and gemini handler
- Pass timestamps through logging chain to writeNonStreamingLog()
- Add timestamp output to API RESPONSE section
Cherry-picked from upstream: c41ce77e
Co-Authored-By: Claude (gemini-claude-opus-4-5-thinking) <noreply@anthropic.com>
Add migration logic for converting oauth-model-mappings to oauth-model-alias
with comprehensive test coverage.
Co-Authored-By: Claude (gemini-claude-opus-4-5-thinking) <noreply@anthropic.com>
Add complete Amp module for routing requests through the Amp CLI:
- Core module with lifecycle management
- Gemini bridge for model translation
- Model mapping configuration
- Proxy handler for request forwarding
- Response rewriter for format conversion
- Secret management for API keys
- Route definitions and fallback handlers
- Comprehensive test coverage
Co-Authored-By: Claude (gemini-claude-opus-4-5-thinking) <noreply@anthropic.com>
Features ported from upstream:
- feat(claude): add native request cloaking support
- feat(translator): add candidate count (n param) support for Gemini
- fix(translator): consolidate multiple system messages into single message (#1064)
- feat(codex): add config toggle for codex instructions injection
- feat(auth): add hashed account ID to credential filenames for team plans
- feat(config): add support for raw JSON payload rules (default-raw, override-raw)
- feat(codex): add OpenCode instructions based on user agent
Also includes minor whitespace cleanup and code organization.
Add InfoByProvider map to ModelRegistration to store provider-specific
ModelInfo, enabling different capabilities for the same model across
providers (e.g., direct API vs OpenRouter).
Changes:
- Add InfoByProvider field to ModelRegistration struct
- Update GetModelInfo to accept provider parameter for provider-specific lookup
- Update LookupModelInfo to accept variadic provider parameter
- Add LookupStaticModelInfo for fallback to static model definitions
- Update ApplyThinking to pass providerKey for registry lookups
- Update all GetModelInfo callers to use new signature
- Remove ensureMaxTokensForThinking test (function moved to thinking package)
Ported from CLIProxyAPI e641fde2
- Add ResolveLogDirectory() for consistent log path resolution
- Add SetLogLevel() for string-based log level configuration
- Update ConfigureLogOutput() to take *config.Config parameter
- Update all callers to use simplified API
Cherry-picked from CLIProxyAPI with adaptations.
- GET /v0/management/rate-limits - detailed per-credential status
- GET /v0/management/rate-limits/summary - availability overview
- Shows available, cooling_down, disabled counts and next recovery time
ProviderLogins table now shows:
- Priority column with up/down reorder buttons
- Expires column with color-coded status (green/yellow/red)
API exposes token_expires_at for WebUI consumption.
Add GET/PUT /thinking-budget endpoint for configuring extended
thinking token budgets. Supports preset levels (Low 2048, Medium 8192,
High 32768) and custom values with enable/disable toggle.
Add management endpoints for request history:
- GET /request-history - list entries with pagination
- GET /request-history/stats - aggregate statistics
- DELETE /request-history - clear all entries
- POST /request-history/export - export to JSON
- POST /request-history/import - import from JSON
- POST /request-history/save - force save to disk
Integrate RequestHistoryManager with request logging middleware.
Add RequestHistoryManager with file-based persistence at
~/.cli-proxy-api/request-history.json. Features:
- Max 500 entries with automatic pruning
- Auto-save every 30 seconds
- Thread-safe with mutex protection
- In-memory ring buffer for performance