* fix(providers): use Bearer auth for Gemini CLI OAuth tokens When credentials come from ~/.gemini/oauth_creds.json (Gemini CLI), send them as Authorization: Bearer header instead of ?key= query parameter. API keys from env vars or config continue using ?key=. Fixes #194 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor(gemini): harden OAuth bearer auth flow and tests * fix(gemini): granular auth source tracking and review fixes Build on chumyin's auth model refactor with: - Expand GeminiAuth to 4 variants (ExplicitKey/EnvGeminiKey/EnvGoogleKey/ OAuthToken) so auth_source() uses stored discriminant without re-reading env vars at call time - Add is_api_key()/credential() helpers on the enum - Upgrade expired OAuth token log from debug to warn - Add tests: provider_rejects_empty_key, auth_source_explicit_key, auth_source_none_without_credentials Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style: apply rustfmt to fix CI lint failures Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: root <root@instance-20220913-1738.vcn09131738.oraclevcn.com> Co-authored-by: argenis de la rosa <theonlyhennygod@gmail.com>
60 lines
1.3 KiB
Rust
60 lines
1.3 KiB
Rust
use std::time::Duration;
|
|
|
|
/// Events the observer can record
|
|
#[derive(Debug, Clone)]
|
|
pub enum ObserverEvent {
|
|
AgentStart {
|
|
provider: String,
|
|
model: String,
|
|
},
|
|
AgentEnd {
|
|
duration: Duration,
|
|
tokens_used: Option<u64>,
|
|
},
|
|
ToolCall {
|
|
tool: String,
|
|
duration: Duration,
|
|
success: bool,
|
|
},
|
|
ChannelMessage {
|
|
channel: String,
|
|
direction: String,
|
|
},
|
|
HeartbeatTick,
|
|
Error {
|
|
component: String,
|
|
message: String,
|
|
},
|
|
}
|
|
|
|
/// Numeric metrics
|
|
#[derive(Debug, Clone)]
|
|
pub enum ObserverMetric {
|
|
RequestLatency(Duration),
|
|
TokensUsed(u64),
|
|
ActiveSessions(u64),
|
|
QueueDepth(u64),
|
|
}
|
|
|
|
/// Core observability trait — implement for any backend
|
|
pub trait Observer: Send + Sync + 'static {
|
|
/// Record a discrete event
|
|
fn record_event(&self, event: &ObserverEvent);
|
|
|
|
/// Record a numeric metric
|
|
fn record_metric(&self, metric: &ObserverMetric);
|
|
|
|
/// Flush any buffered data (no-op for most backends)
|
|
fn flush(&self) {}
|
|
|
|
/// Human-readable name of this observer
|
|
fn name(&self) -> &str;
|
|
|
|
/// Downcast to `Any` for backend-specific operations
|
|
fn as_any(&self) -> &dyn std::any::Any
|
|
where
|
|
Self: Sized,
|
|
{
|
|
self
|
|
}
|
|
}
|