Documentation
¶
Overview ¶
internal/pkg/protocol/sync_routing.go
internal/pkg/protocol/sync_user.go
Index ¶
- Constants
- func NormalizeAgentCapabilities(capabilities []string) []string
- type APIPermissionGrant
- type APIRoleSet
- type APIRoleSetFetchRequest
- type APIRoleSetFetchResult
- type APIRoleSetInvalidate
- type APITraceEntry
- type APIUpstreamCredential
- type APIUsageEntry
- type Address
- type AgentCapabilitiesUpdate
- type AgentDirectAddressesUpdate
- type AuthBootstrapResponse
- type CacheEntityStats
- type DirectProbeResult
- type DirectProbeTarget
- type FetchEntityRequest
- type FetchEntityResponse
- type ForceFullSyncResponse
- type FullSyncRequest
- type FullSyncResponse
- type GetVersionResponse
- type HeartbeatParams
- type LimiterBucketStat
- type ManualProbeProgress
- type OperationAck
- type OperationRequest
- type PrivateChannelInvalidatePayload
- type ProbeAck
- type ProbePolicy
- type ProbeScope
- type PublicRouteError
- type RelayActiveRuntime
- type RelayDesiredRuntime
- type RelayProbeResult
- type RelayProbeStage
- type RelayProbeState
- type RelayProbeTarget
- type RelayRecentError
- type RelayRuntime
- type RelayTicketRequest
- type ReportedUsage
- type RouteEdgeDigest
- type RouteEdgeSnapshot
- type RouteEvent
- type RouteFailureObservation
- type RouteTelemetryBatch
- type RoutingMember
- type RoutingOwner
- type SyncPushParams
- type SyncedAPIRole
- type SyncedAPIRoute
- type SyncedAPIService
- type SyncedAPIUpstream
- type SyncedPrivateChannel
- type SyncedRouting
- type SyncedUser
- type TicketResponse
- type TokenFetchSide
- type TokenRoutingMap
- type UsageLogEntry
- type UsageReport
- type UserQuotaSync
- type UserRoutingMap
- type VisiblePrivateChannelSet
Constants ¶
const ( ProbeRespectBusinessPolicy = wire.ProbeRespectBusinessPolicy ProbeBypassBusinessPolicy = wire.ProbeBypassBusinessPolicy )
const ( FullSyncMaxPageSize = 500 AgentFullSyncSnapshotContractV1 = "agent_full_sync_v1" AgentCapabilitiesMaxCount = 32 AgentCapabilityMaxLength = 64 AgentAuthSigningKeysMaxCount = 8 AgentAuthKeyIDMaxLength = 128 AgentAuthAlgorithmEdDSA = "EdDSA" AgentCapabilityTunnelV2 = "agent_tunnel_v2" AgentCapabilityForwardV1 = "agent_forward_ticket_v1" AgentCapabilityDirectTunnelV1 = "agent_direct_tunnel_v1" AgentCapabilityRelayHTTPPingV1 = "agent_relay_http_ping_v1" AgentCapabilityTokenRoutingV1 = "agent_token_routing_v1" AgentCapabilityGenericAPIExecutionV1 = "generic_api_execution_v1" AgentCapabilityGenericAPIWebSocketV1 = "generic_api_websocket_v1" MasterCapabilityGenericAPIUsageV1 = "generic_api_usage_v1" )
const APIFullSyncSnapshotContractV1 = "api_full_sync_v1"
const TokenFetchSideSchemaV1 = 1
Variables ¶
This section is empty.
Functions ¶
func NormalizeAgentCapabilities ¶ added in v0.0.13
Types ¶
type APIPermissionGrant ¶ added in v0.0.16
type APIRoleSet ¶ added in v0.0.16
type APIRoleSet struct {
RoleIDs []uint `json:"role_ids"`
}
type APIRoleSetFetchRequest ¶ added in v0.0.16
type APIRoleSetFetchRequest struct {
PrincipalID uint `json:"principal_id"`
}
type APIRoleSetFetchResult ¶ added in v0.0.16
type APIRoleSetFetchResult struct {
PrincipalID uint `json:"principal_id"`
Exists bool `json:"exists"`
RoleSet APIRoleSet `json:"role_set"`
}
type APIRoleSetInvalidate ¶ added in v0.0.16
type APIRoleSetInvalidate struct {
PrincipalID uint `json:"principal_id"`
}
type APITraceEntry ¶ added in v0.0.16
type APITraceEntry = apiattempt.APIExecutionTrace
APITraceEntry is the bounded Generic API execution trace returned by the execution Agent. Source-side trace enrichment remains owned by UsageBuilder.
type APIUpstreamCredential ¶ added in v0.0.16
type APIUpstreamCredential struct {
BearerToken string `json:"bearer_token,omitempty"`
HeaderName string `json:"header_name,omitempty"`
HeaderValue string `json:"header_value,omitempty"`
QueryName string `json:"query_name,omitempty"`
QueryValue string `json:"query_value,omitempty"`
BasicUsername string `json:"basic_username,omitempty"`
BasicPassword string `json:"basic_password,omitempty"`
}
type APIUsageEntry ¶ added in v0.0.16
type APIUsageEntry struct {
RequestID string `json:"request_id"`
UserID uint `json:"user_id"`
TokenID uint `json:"token_id"`
TokenName string `json:"token_name"`
ClientIP string `json:"client_ip"`
APIServiceID uint `json:"api_service_id"`
APIRouteID uint `json:"api_route_id"`
APIUpstreamID uint `json:"api_upstream_id"`
ServiceName string `json:"service_name"`
RouteName string `json:"route_name"`
UpstreamName string `json:"upstream_name"`
Protocol string `json:"protocol"`
Method string `json:"method"`
Subpath string `json:"subpath"`
SourceAgentID string `json:"source_agent_id"`
ExecutionAgentID string `json:"execution_agent_id"`
AgentRouteID uint `json:"agent_route_id"`
AgentRoutePath string `json:"agent_route_path"`
StatusCode int `json:"status_code"`
DurationMs int `json:"duration_ms"`
FirstByteMs int `json:"first_byte_ms"`
RequestBytes int64 `json:"request_bytes"`
ResponseBytes int64 `json:"response_bytes"`
WebSocketCloseCode int `json:"websocket_close_code"`
ProviderDispatchKnown bool `json:"provider_dispatch_known"`
ProviderDispatched bool `json:"provider_dispatched"`
QuotaGateDecision string `json:"quota_gate_decision"`
ErrorStage string `json:"error_stage"`
ErrorCode string `json:"error_code"`
ErrorMessage string `json:"error_message,omitempty"`
RateLimitDecision string `json:"rate_limit_decision"`
RateLimitWaitMs int `json:"rate_limit_wait_ms"`
RateLimitReason string `json:"rate_limit_reason"`
RateLimitHits []models.RateLimitHit `json:"rate_limit_hits,omitempty"`
RateLimitHitTotal int `json:"rate_limit_hit_total"`
RateLimitHitsTruncated bool `json:"rate_limit_hits_truncated"`
Trace *APITraceEntry `json:"trace,omitempty"`
Timestamp int64 `json:"timestamp"`
}
APIUsageEntry is the Source Agent's single terminal record for one Generic API request. It is intentionally separate from the LLM UsageLogEntry shape.
type Address ¶ added in v0.0.13
Address is the shared agent HTTP address value used by probe and routing APIs.
type AgentCapabilitiesUpdate ¶ added in v0.0.13
type AgentDirectAddressesUpdate ¶ added in v0.0.13
type AgentDirectAddressesUpdate struct {
MasterInstanceID string `json:"master_instance_id"`
AgentID string `json:"agent_id"`
SessionGeneration uint64 `json:"session_generation"`
Sequence uint64 `json:"sequence"`
HTTPAddresses []Address `json:"http_addresses"`
}
AgentDirectAddressesUpdate carries one ordered auto-detected address change. Manual addresses remain part of the authoritative Agent configuration.
type AuthBootstrapResponse ¶ added in v0.0.13
type CacheEntityStats ¶
type CacheEntityStats struct {
Kind string `json:"kind,omitempty"` // "lru" | "index";旧 agent 上报空串,前端按 lru 兜底
Hits int64 `json:"hits"`
Misses int64 `json:"misses"`
Evictions int64 `json:"evictions"`
NegativeHits int64 `json:"negative_hits"`
LoadErrors int64 `json:"load_errors"`
Invalidations int64 `json:"invalidations"`
Size int `json:"size"`
Capacity int `json:"capacity"`
Extra map[string]int64 `json:"extra,omitempty"` // 索引细分,如 {"limiters":12,"bindings":30}
}
CacheEntityStats 是单个实体缓存的运行统计。 LRU 模式实体上报全字段;Full 模式实体仅 Size 有意义、其他字段为 0。
type DirectProbeResult ¶ added in v0.0.13
type DirectProbeResult struct {
TargetAgentID string `json:"target_agent_id"`
AddressFingerprint string `json:"address_fingerprint"`
Network string `json:"network"`
Identity string `json:"identity"`
Eligible bool `json:"eligible"`
LatencyMS int64 `json:"latency_ms"`
CheckedAt int64 `json:"checked_at"`
ReasonCode string `json:"reason_code,omitempty"`
Stage string `json:"stage,omitempty"`
Policy ProbePolicy `json:"policy"`
PolicyDisabled bool `json:"policy_disabled"`
PolicyReasonCode string `json:"policy_reason_code,omitempty"`
}
type DirectProbeTarget ¶ added in v0.0.13
type DirectProbeTarget struct {
TargetAgentID string `json:"target_agent_id"`
Addresses []Address `json:"addresses"`
EffectiveProxy string `json:"effective_proxy"`
AddressFingerprint string `json:"address_fingerprint"`
TargetGeneration uint64 `json:"target_generation"`
Policy ProbePolicy `json:"policy"`
}
type FetchEntityRequest ¶
FetchEntityRequest 是 sync.fetchEntity 的入参。 Entity 取 events.Entity* 常量;Key 由各实体 handler 解读 (token: API key 字符串;user: id 字符串)。
type FetchEntityResponse ¶
type FetchEntityResponse struct {
Found bool `json:"found"`
Data json.RawMessage `json:"data,omitempty"`
Side json.RawMessage `json:"side,omitempty"`
}
FetchEntityResponse 是 sync.fetchEntity 的响应。 Found=false 表示 master 也未查到;调用方应进入负缓存。 Side 是可选旁路负载(如 token 响应附带的 SyncedUser),由 agent 端 fetcher 解读。
type ForceFullSyncResponse ¶
type FullSyncRequest ¶
type FullSyncResponse ¶
type FullSyncResponse struct {
Items []byte `json:"items"`
Total int64 `json:"total"`
Page int `json:"page,omitempty"`
HasMore bool `json:"has_more"`
Version int64 `json:"version"`
Keyset bool `json:"keyset,omitempty"`
LastID uint `json:"last_id,omitempty"`
SnapshotMaxID uint `json:"snapshot_max_id,omitempty"`
BaseVersion int64 `json:"base_version,omitempty"`
SnapshotContract string `json:"snapshot_contract,omitempty"`
}
type GetVersionResponse ¶
type GetVersionResponse struct {
Version int64 `json:"version"`
}
type HeartbeatParams ¶
type HeartbeatParams struct {
Uptime int64 `json:"uptime"`
CachedTokens int `json:"cached_tokens"`
CachedChannels int `json:"cached_channels"`
CachedModels int `json:"cached_models"`
CachedGlobalRoutings int `json:"cached_global_routings"`
CachedUserRoutings int `json:"cached_user_routings"`
ActiveConnections int `json:"active_connections"`
Version int64 `json:"version"`
PendingUsage int `json:"pending_usage,omitempty"`
Capabilities []string `json:"capabilities,omitempty"`
Relay *RelayRuntime `json:"relay,omitempty"`
HTTPAddresses json.RawMessage `json:"http_addresses,omitempty"`
Tags string `json:"tags,omitempty"`
ProxyURL string `json:"proxy_url,omitempty"`
ListenPort int `json:"listen_port,omitempty"`
CacheStats map[string]CacheEntityStats `json:"cache_stats,omitempty"`
}
type LimiterBucketStat ¶ added in v0.0.8
type LimiterBucketStat struct {
LimiterID uint `json:"limiter_id"`
Name string `json:"name"`
Bucket string `json:"bucket"`
Metric string `json:"metric"` // concurrency | rate
KeyBy string `json:"key_by"`
Occupied int64 `json:"occupied"` // 并发:当前占用; 速率:当前窗口已用
Capacity int64 `json:"capacity"`
Waiters int64 `json:"waiters"`
WindowEndMs int64 `json:"window_end_ms"` // 速率桶本窗口复位时刻(unix ms);并发为 0
}
LimiterBucketStat 是一个 (限流器,桶) 的实时仪表读数。agent 采样 + join 规则元数据后上报。
type ManualProbeProgress ¶ added in v0.0.13
type OperationAck ¶ added in v0.0.13
type OperationRequest ¶ added in v0.0.13
type OperationRequest struct {
AgentID string `json:"agent_id"`
Operation string `json:"operation"`
TargetAgentID string `json:"target_agent_id,omitempty"`
RequestID string `json:"request_id,omitempty"`
ExpectedEpoch string `json:"expected_epoch"`
ExpectedControlGeneration uint64 `json:"expected_control_generation,omitempty"`
ExpectedRelayGeneration uint64 `json:"expected_relay_generation,omitempty"`
}
type PrivateChannelInvalidatePayload ¶ added in v0.0.2
type PrivateChannelInvalidatePayload struct {
Action string `json:"action"` // "invalidate"
AffectedUserIDs []uint `json:"affected_user_ids"`
}
PrivateChannelInvalidatePayload is the WS push notification fired after CRUD / share changes. Master expands (owner ∪ share.targets) into the affected_user_ids list; agent only sees the post-expansion user list and invalidates each user's cache block (no incremental merge).
type ProbePolicy ¶ added in v0.0.14
type ProbePolicy = wire.ProbePolicy
type ProbeScope ¶ added in v0.0.13
type PublicRouteError ¶ added in v0.0.13
type PublicRouteError struct {
Code string `json:"code"`
Stage string `json:"stage"`
RequestID string `json:"request_id"`
Message string `json:"message"`
}
func NewPublicRouteError ¶ added in v0.0.13
func NewPublicRouteError(code, stage, requestID string) PublicRouteError
func (PublicRouteError) Error ¶ added in v0.0.13
func (e PublicRouteError) Error() string
type RelayActiveRuntime ¶ added in v0.0.13
type RelayDesiredRuntime ¶ added in v0.0.13
type RelayProbeResult ¶ added in v0.0.13
type RelayProbeResult struct {
TargetAgentID string `json:"target_agent_id"`
State RelayProbeState `json:"state"`
Stage RelayProbeStage `json:"stage,omitempty"`
LatencyMS int64 `json:"latency_ms"`
CheckedAt int64 `json:"checked_at"`
ReasonCode string `json:"reason_code,omitempty"`
Policy ProbePolicy `json:"policy"`
PolicyDisabled bool `json:"policy_disabled"`
PolicyReasonCode string `json:"policy_reason_code,omitempty"`
}
type RelayProbeStage ¶ added in v0.0.13
type RelayProbeStage string
const ( RelayProbeStageOpen RelayProbeStage = "open" RelayProbeStageCommit RelayProbeStage = "commit" RelayProbeStageResponse RelayProbeStage = "response" )
type RelayProbeState ¶ added in v0.0.13
type RelayProbeState string
const ( RelayProbeReachable RelayProbeState = "reachable" RelayProbeUnreachable RelayProbeState = "unreachable" RelayProbeUnknown RelayProbeState = "unknown" )
type RelayProbeTarget ¶ added in v0.0.13
type RelayProbeTarget struct {
TargetAgentID string `json:"target_agent_id"`
SourceRelayGeneration uint64 `json:"source_relay_generation"`
TargetRelayGeneration uint64 `json:"target_relay_generation"`
Policy ProbePolicy `json:"policy"`
}
type RelayRecentError ¶ added in v0.0.13
type RelayRuntime ¶ added in v0.0.13
type RelayRuntime struct {
Support string `json:"support"`
Config string `json:"config"`
Availability string `json:"availability"`
AcceptingNewStreams bool `json:"accepting_new_streams"`
Convergence string `json:"convergence"`
Desired RelayDesiredRuntime `json:"desired"`
Active RelayActiveRuntime `json:"active"`
LastError string `json:"last_error,omitempty"`
RecentErrors []RelayRecentError `json:"recent_errors,omitempty"`
}
type RelayTicketRequest ¶ added in v0.0.13
type RelayTicketRequest struct {
DesiredGeneration uint64 `json:"desired_generation"`
}
type ReportedUsage ¶ added in v0.0.16
type ReportedUsage struct {
LLM *UsageLogEntry `json:"llm,omitempty"`
API *APIUsageEntry `json:"api,omitempty"`
}
ReportedUsage is the internal strongly typed queue item. Exactly one member must be non-nil; wire reports split the union back into their two arrays.
func (ReportedUsage) IsAPI ¶ added in v0.0.16
func (usage ReportedUsage) IsAPI() bool
func (ReportedUsage) QueueID ¶ added in v0.0.16
func (usage ReportedUsage) QueueID() string
func (ReportedUsage) RequestID ¶ added in v0.0.16
func (usage ReportedUsage) RequestID() string
func (ReportedUsage) Timestamp ¶ added in v0.0.16
func (usage ReportedUsage) Timestamp() int64
func (ReportedUsage) Valid ¶ added in v0.0.16
func (usage ReportedUsage) Valid() bool
type RouteEdgeDigest ¶ added in v0.0.13
type RouteEdgeDigest struct {
Generation uint64 `json:"generation"`
Edges []RouteEdgeSnapshot `json:"edges"`
CoveredThrough uint64 `json:"covered_through,omitempty"`
}
type RouteEdgeSnapshot ¶ added in v0.0.13
type RouteEdgeSnapshot struct {
TargetAgentID string `json:"target_agent_id"`
RouteID uint `json:"route_id"`
SelectorKind string `json:"selector_kind"`
LastUsedAt int64 `json:"last_used_at"`
LastDirectResult string `json:"last_direct_result"`
AddressFingerprint string `json:"address_fingerprint"`
SuccessCount uint64 `json:"success_count"`
LatencyTotalMS uint64 `json:"latency_total_ms"`
}
type RouteEvent ¶ added in v0.0.13
type RouteEvent struct {
RequestID string `json:"request_id,omitempty"`
TargetAgentID string `json:"target_agent_id"`
RouteID uint `json:"route_id"`
SelectorKind string `json:"selector_kind"`
PathKind string `json:"path_kind"`
Result string `json:"result"`
Stage string `json:"stage"`
ReasonCode string `json:"reason_code"`
CommitState string `json:"commit_state"`
AddressFingerprint string `json:"address_fingerprint"`
DurationMS int64 `json:"duration_ms"`
ObservedAt int64 `json:"observed_at"`
Sequence uint64 `json:"sequence,omitempty"`
Failures []RouteFailureObservation `json:"failures,omitempty"`
}
type RouteFailureObservation ¶ added in v0.0.13
type RouteFailureObservation struct {
PathKind string `json:"path_kind"`
Stage string `json:"stage"`
CommitState string `json:"commit_state"`
ReasonCode string `json:"reason_code"`
}
RouteFailureObservation describes one failed transport attempt without changing the final route event fields used by connectivity edge summaries.
type RouteTelemetryBatch ¶ added in v0.0.13
type RouteTelemetryBatch struct {
Generation uint64 `json:"generation"`
Events []RouteEvent `json:"events"`
}
type RoutingMember ¶
type RoutingMember struct {
Ref string `json:"ref"`
Priority int `json:"priority"`
Weight int `json:"weight"`
}
RoutingMember 与 models.RoutingMember 字段一致。protocol 包独立定义避免反向依赖 models 包。
type RoutingOwner ¶ added in v0.0.13
type SyncPushParams ¶
type SyncedAPIRole ¶ added in v0.0.16
type SyncedAPIRole struct {
ID uint `json:"id"`
Name string `json:"name"`
Permissions []APIPermissionGrant `json:"permissions"`
}
type SyncedAPIRoute ¶ added in v0.0.16
type SyncedAPIRoute struct {
ID uint `json:"id"`
ServiceID uint `json:"service_id"`
BackendID uint `json:"backend_id"`
Slug string `json:"slug"`
Protocols []string `json:"protocols"`
AllowedMethods []string `json:"allowed_methods"`
WebSocketSubprotocols []string `json:"websocket_subprotocols"`
UpstreamPath string `json:"upstream_path"`
ForwardSubpath bool `json:"forward_subpath"`
Status int `json:"status"`
}
type SyncedAPIService ¶ added in v0.0.16
type SyncedAPIUpstream ¶ added in v0.0.16
type SyncedAPIUpstream struct {
ID uint `json:"id"`
BackendID uint `json:"backend_id"`
Name string `json:"name"`
BaseURL string `json:"base_url"`
AuthType string `json:"auth_type"`
Credential APIUpstreamCredential `json:"credential"`
HeaderOverride map[string]string `json:"header_override"`
ProxyURL string `json:"proxy_url"`
Priority int `json:"priority"`
Weight int `json:"weight"`
Status int `json:"status"`
}
type SyncedPrivateChannel ¶ added in v0.0.2
type SyncedPrivateChannel struct {
models.ChannelCore
OwnerID uint `json:"owner_id"`
KeyPlaintext string `json:"key"`
Models []string `json:"models"`
ModelMapping map[string]string `json:"model_mapping"`
}
SyncedPrivateChannel is the projection of a PrivateChannel that master pushes to agent over WS sync. KeyPlaintext is the master-decrypted key; agent never holds the KEK. HeaderOverride / ProxyURL never appear here (PrivateChannel schema does not include those columns).
Scalar fields shared with models.PrivateChannel come from the embedded ChannelCore. BYOK-projection-only fields (KeyPlaintext, OwnerID, plus the downstream-friendly Models / ModelMapping types) stay on the outer struct.
type SyncedRouting ¶
type SyncedRouting struct {
ID uint `json:"id"`
Name string `json:"name"`
Scope string `json:"scope"`
UserID uint `json:"user_id"`
TokenID uint `json:"token_id"`
Members []RoutingMember `json:"members"`
Enabled bool `json:"enabled"`
}
SyncedRouting 是 master 推送给 agent 的 ModelRouting 投影。 与 models.ModelRouting 保持字段对等,但脱离 GORM 依赖(agent 端不需要持久化)。
type SyncedUser ¶
type SyncedUser struct {
ID uint `json:"id"`
GroupID uint `json:"group_id"`
Quota int64 `json:"quota"`
}
SyncedUser 是 master 推送给 agent 的精简 User 投影。 只包含鉴权和配额所需字段,不暴露 Password / Username。
type TicketResponse ¶ added in v0.0.13
type TokenFetchSide ¶ added in v0.0.13
type TokenFetchSide struct {
SchemaVersion int `json:"schema_version"`
User *SyncedUser `json:"user,omitempty"`
TokenRoutings *TokenRoutingMap `json:"token_routings,omitempty"`
}
type TokenRoutingMap ¶ added in v0.0.13
type TokenRoutingMap struct {
Routings map[string]*SyncedRouting `json:"routings"`
}
type UsageLogEntry ¶
type UsageLogEntry struct {
RequestID string `json:"request_id"`
UserID uint `json:"user_id"`
TokenID uint `json:"token_id"`
ChannelID uint `json:"channel_id"`
PrivateChannelID uint `json:"private_channel_id"`
OwnerType string `json:"owner_type"`
ModelName string `json:"model_name"`
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
IsStream bool `json:"is_stream"`
Duration int `json:"duration"`
ClientIP string `json:"client_ip"`
Timestamp int64 `json:"timestamp"`
ExecutionAgentID *string `json:"execution_agent_id,omitempty"`
RouteSourceAgentID string `json:"route_source_agent_id,omitempty"`
AgentRouteID uint `json:"agent_route_id,omitempty"`
AgentRoutePath string `json:"agent_route_path,omitempty"`
// Enhanced logging fields
TokenName string `json:"token_name"`
UpstreamModel string `json:"upstream_model"`
FirstResponseMs int `json:"first_response_ms"`
CacheReadTokens int `json:"cache_read_tokens"`
CacheWriteTokens int `json:"cache_write_tokens"`
InboundProtocol string `json:"inbound_protocol"`
OutboundProtocol string `json:"outbound_protocol"`
UseLegacy bool `json:"use_legacy"`
Status int `json:"status"`
ErrorMessage string `json:"error_message,omitempty"`
TraceData string `json:"trace_data,omitempty"`
Other string `json:"other"`
TokenSource string `json:"token_source,omitempty"`
RoutingName string `json:"routing_name,omitempty"`
TraceRetentionStatus models.TraceRetentionStatus `json:"trace_retention_status,omitempty"`
// Channel affinity(渠道缓存粘性)
AffinityStatus string `json:"affinity_status,omitempty"` // "hit" | "fallback" | "none" | ""
AffinityRecorded bool `json:"affinity_recorded,omitempty"`
ErrorStage string `json:"error_stage,omitempty"`
InboundDecodeMs int `json:"inbound_decode_ms,omitempty"`
OutboundEncodeMs int `json:"outbound_encode_ms,omitempty"`
UpstreamDispatchMs int `json:"upstream_dispatch_ms,omitempty"`
UpstreamDecodeMs int `json:"upstream_decode_ms,omitempty"`
ClientEncodeMs int `json:"client_encode_ms,omitempty"`
// PriceRatio 是 relay 选中的公共 channel 在请求时刻的计费倍率快照。
// 零值 0(旧 agent 未发 / channel 未配)= 原价,settler 归一到 1.0。
PriceRatio float64 `json:"price_ratio,omitempty"`
// Free 是 relay 选中的公共 channel 在请求时刻的"免费渠道"标记快照。
// private 行不填,保持 false。settler 见 true 则四桶成本清零。
Free bool `json:"free,omitempty"`
// FallbackChain 是本次请求的候选链路(每候选一条);空表示无链路信息。
FallbackChain []models.AttemptRecord `json:"fallback_chain,omitempty"`
// AttemptTraces 是逐候选 mask 过的 header/body trace,index 对应 FallbackChain 的 Seq-1。
// AttemptIndex assigned by settler from slice order until Task 5 adds the field.
AttemptTraces []models.UsageLogTrace `json:"attempt_traces,omitempty"`
// 限流决策(请求级 limiter):Decision/WaitMs/Reason 标量 + Hits 命中明细。
// 无命中时全为零值/空,omitempty 不上报。
RateLimitDecision string `json:"rate_limit_decision,omitempty"`
RateLimitWaitMs int `json:"rate_limit_wait_ms,omitempty"`
RateLimitReason string `json:"rate_limit_reason,omitempty"`
RateLimitHits []models.RateLimitHit `json:"rate_limit_hits,omitempty"`
// AutoDisableTriggers is internal Agent-to-Master transport state.
AutoDisableTriggers []attemptproxy.ChannelAutoDisableTrigger `json:"auto_disable_triggers,omitempty"`
}
type UsageReport ¶
type UsageReport struct {
AgentID string `json:"agent_id"`
Logs []UsageLogEntry `json:"logs,omitempty"`
APIRequests []APIUsageEntry `json:"api_requests,omitempty"`
}
type UserQuotaSync ¶ added in v0.0.8
type UserQuotaSync struct {
AgentID string `json:"agent_id"`
Users []SyncedUser `json:"users"`
}
UserQuotaSync 是 master 结算后定向回送给来源 agent 的余额更新。
type UserRoutingMap ¶
type UserRoutingMap struct {
Routings map[string]*SyncedRouting `json:"routings"`
}
UserRoutingMap 是单个用户的 routing 集合(name → routing), 按用户整体存取,避免每条 user routing 单独缓存。 放在 protocol 包是因为 loaders 与 cache 都需要引用此类型, 而 loaders 包不能反向 import cache。
type VisiblePrivateChannelSet ¶ added in v0.0.2
type VisiblePrivateChannelSet struct {
UserID uint `json:"user_id"`
Channels []SyncedPrivateChannel `json:"channels"`
}
VisiblePrivateChannelSet is the entire block returned to agent on LRU miss: all private channels visible to the requesting user, with plaintext keys injected.