Read Codex rate limits at startup so Status always shows them
This commit is contained in:
+121
-74
@@ -16,6 +16,7 @@ const (
|
||||
MethodTurnStart = "turn/start"
|
||||
MethodTurnSteer = "turn/steer"
|
||||
MethodTurnInterrupt = "turn/interrupt"
|
||||
MethodAccountRateLimitsRead = "account/rateLimits/read"
|
||||
MethodError = "error"
|
||||
MethodThreadStarted = "thread/started"
|
||||
MethodThreadStatusChanged = "thread/status/changed"
|
||||
@@ -113,15 +114,16 @@ const (
|
||||
)
|
||||
|
||||
var clientResults = map[string]func() any{
|
||||
MethodInitialize: func() any { return &InitializeResponse{} },
|
||||
MethodThreadStart: func() any { return &ThreadStartResponse{} },
|
||||
MethodThreadResume: func() any { return &ThreadResumeResponse{} },
|
||||
MethodThreadFork: func() any { return &ThreadForkResponse{} },
|
||||
MethodThreadCompactStart: func() any { return &ThreadCompactStartResponse{} },
|
||||
MethodThreadRead: func() any { return &ThreadReadResponse{} },
|
||||
MethodTurnStart: func() any { return &TurnStartResponse{} },
|
||||
MethodTurnSteer: func() any { return &TurnSteerResponse{} },
|
||||
MethodTurnInterrupt: func() any { return &TurnInterruptResponse{} },
|
||||
MethodInitialize: func() any { return &InitializeResponse{} },
|
||||
MethodThreadStart: func() any { return &ThreadStartResponse{} },
|
||||
MethodThreadResume: func() any { return &ThreadResumeResponse{} },
|
||||
MethodThreadFork: func() any { return &ThreadForkResponse{} },
|
||||
MethodThreadCompactStart: func() any { return &ThreadCompactStartResponse{} },
|
||||
MethodThreadRead: func() any { return &ThreadReadResponse{} },
|
||||
MethodTurnStart: func() any { return &TurnStartResponse{} },
|
||||
MethodTurnSteer: func() any { return &TurnSteerResponse{} },
|
||||
MethodTurnInterrupt: func() any { return &TurnInterruptResponse{} },
|
||||
MethodAccountRateLimitsRead: func() any { return &GetAccountRateLimitsResponse{} },
|
||||
}
|
||||
|
||||
var notificationParams = map[string]func() any{
|
||||
@@ -534,6 +536,47 @@ const (
|
||||
ReasoningSummaryNone ReasoningSummary = "none"
|
||||
)
|
||||
|
||||
const (
|
||||
RateLimitResetTypeCodexRateLimits RateLimitResetType = "codexRateLimits"
|
||||
RateLimitResetTypeUnknown RateLimitResetType = "unknown"
|
||||
)
|
||||
|
||||
const (
|
||||
RateLimitResetCreditStatusAvailable RateLimitResetCreditStatus = "available"
|
||||
RateLimitResetCreditStatusRedeeming RateLimitResetCreditStatus = "redeeming"
|
||||
RateLimitResetCreditStatusRedeemed RateLimitResetCreditStatus = "redeemed"
|
||||
RateLimitResetCreditStatusUnknown RateLimitResetCreditStatus = "unknown"
|
||||
)
|
||||
|
||||
const (
|
||||
PlanTypeFree PlanType = "free"
|
||||
PlanTypeGo PlanType = "go"
|
||||
PlanTypePlus PlanType = "plus"
|
||||
PlanTypePro PlanType = "pro"
|
||||
PlanTypeProlite PlanType = "prolite"
|
||||
PlanTypePromax PlanType = "promax"
|
||||
PlanTypeTeam PlanType = "team"
|
||||
PlanTypeSelfServeBusinessProlite PlanType = "self_serve_business_prolite"
|
||||
PlanTypeSelfServeBusinessUsageBased PlanType = "self_serve_business_usage_based"
|
||||
PlanTypeBusiness PlanType = "business"
|
||||
PlanTypeEnt26 PlanType = "ent26"
|
||||
PlanTypeEnterpriseCbpAutomation PlanType = "enterprise_cbp_automation"
|
||||
PlanTypeEnterpriseCbpUsageBased PlanType = "enterprise_cbp_usage_based"
|
||||
PlanTypeEnterprise PlanType = "enterprise"
|
||||
PlanTypeEdu PlanType = "edu"
|
||||
PlanTypeEduPlus PlanType = "edu_plus"
|
||||
PlanTypeEduPro PlanType = "edu_pro"
|
||||
PlanTypeUnknown PlanType = "unknown"
|
||||
)
|
||||
|
||||
const (
|
||||
RateLimitReachedTypeRateLimitReached RateLimitReachedType = "rate_limit_reached"
|
||||
RateLimitReachedTypeWorkspaceOwnerCreditsDepleted RateLimitReachedType = "workspace_owner_credits_depleted"
|
||||
RateLimitReachedTypeWorkspaceMemberCreditsDepleted RateLimitReachedType = "workspace_member_credits_depleted"
|
||||
RateLimitReachedTypeWorkspaceOwnerUsageLimitReached RateLimitReachedType = "workspace_owner_usage_limit_reached"
|
||||
RateLimitReachedTypeWorkspaceMemberUsageLimitReached RateLimitReachedType = "workspace_member_usage_limit_reached"
|
||||
)
|
||||
|
||||
const (
|
||||
ThreadAttachmentOperationCreated ThreadAttachmentOperation = "created"
|
||||
ThreadAttachmentOperationDeleted ThreadAttachmentOperation = "deleted"
|
||||
@@ -714,27 +757,6 @@ const (
|
||||
AuthModeBedrockAccessKeys AuthMode = "bedrockAccessKeys"
|
||||
)
|
||||
|
||||
const (
|
||||
PlanTypeFree PlanType = "free"
|
||||
PlanTypeGo PlanType = "go"
|
||||
PlanTypePlus PlanType = "plus"
|
||||
PlanTypePro PlanType = "pro"
|
||||
PlanTypeProlite PlanType = "prolite"
|
||||
PlanTypePromax PlanType = "promax"
|
||||
PlanTypeTeam PlanType = "team"
|
||||
PlanTypeSelfServeBusinessProlite PlanType = "self_serve_business_prolite"
|
||||
PlanTypeSelfServeBusinessUsageBased PlanType = "self_serve_business_usage_based"
|
||||
PlanTypeBusiness PlanType = "business"
|
||||
PlanTypeEnt26 PlanType = "ent26"
|
||||
PlanTypeEnterpriseCbpAutomation PlanType = "enterprise_cbp_automation"
|
||||
PlanTypeEnterpriseCbpUsageBased PlanType = "enterprise_cbp_usage_based"
|
||||
PlanTypeEnterprise PlanType = "enterprise"
|
||||
PlanTypeEdu PlanType = "edu"
|
||||
PlanTypeEduPlus PlanType = "edu_plus"
|
||||
PlanTypeEduPro PlanType = "edu_pro"
|
||||
PlanTypeUnknown PlanType = "unknown"
|
||||
)
|
||||
|
||||
const (
|
||||
GatewayOAuthStatusNotReady GatewayOAuthStatus = "notReady"
|
||||
GatewayOAuthStatusStarted GatewayOAuthStatus = "started"
|
||||
@@ -742,14 +764,6 @@ const (
|
||||
GatewayOAuthStatusFailed GatewayOAuthStatus = "failed"
|
||||
)
|
||||
|
||||
const (
|
||||
RateLimitReachedTypeRateLimitReached RateLimitReachedType = "rate_limit_reached"
|
||||
RateLimitReachedTypeWorkspaceOwnerCreditsDepleted RateLimitReachedType = "workspace_owner_credits_depleted"
|
||||
RateLimitReachedTypeWorkspaceMemberCreditsDepleted RateLimitReachedType = "workspace_member_credits_depleted"
|
||||
RateLimitReachedTypeWorkspaceOwnerUsageLimitReached RateLimitReachedType = "workspace_owner_usage_limit_reached"
|
||||
RateLimitReachedTypeWorkspaceMemberUsageLimitReached RateLimitReachedType = "workspace_member_usage_limit_reached"
|
||||
)
|
||||
|
||||
const (
|
||||
RemoteControlConnectionStatusDisabled RemoteControlConnectionStatus = "disabled"
|
||||
RemoteControlConnectionStatusConnecting RemoteControlConnectionStatus = "connecting"
|
||||
@@ -1611,6 +1625,75 @@ type TurnInterruptParams struct {
|
||||
|
||||
type TurnInterruptResponse = map[string]any
|
||||
|
||||
type GetAccountRateLimitsParams struct {
|
||||
ExcludeResetCreditDetails bool `json:"excludeResetCreditDetails,omitempty"`
|
||||
SupportsLunaReserve bool `json:"supportsLunaReserve,omitempty"`
|
||||
}
|
||||
|
||||
type RateLimitResetType string
|
||||
|
||||
type RateLimitResetCreditStatus string
|
||||
|
||||
type RateLimitResetCredit struct {
|
||||
Description string `json:"description,omitempty"`
|
||||
ExpiresAt int64 `json:"expiresAt,omitempty"`
|
||||
GrantedAt int64 `json:"grantedAt"`
|
||||
ID string `json:"id"`
|
||||
ResetType RateLimitResetType `json:"resetType"`
|
||||
Status RateLimitResetCreditStatus `json:"status"`
|
||||
Title string `json:"title,omitempty"`
|
||||
}
|
||||
|
||||
type RateLimitResetCreditsSummary struct {
|
||||
AvailableCount int64 `json:"availableCount"`
|
||||
Credits []RateLimitResetCredit `json:"credits,omitempty"`
|
||||
}
|
||||
|
||||
type CreditsSnapshot struct {
|
||||
Balance string `json:"balance,omitempty"`
|
||||
HasCredits bool `json:"hasCredits"`
|
||||
Unlimited bool `json:"unlimited"`
|
||||
}
|
||||
|
||||
type SpendControlLimitSnapshot struct {
|
||||
Limit string `json:"limit"`
|
||||
RemainingPercent int64 `json:"remainingPercent"`
|
||||
ResetsAt int64 `json:"resetsAt"`
|
||||
Used string `json:"used"`
|
||||
}
|
||||
|
||||
type PlanType string
|
||||
|
||||
type RateLimitWindow struct {
|
||||
ResetsAt int64 `json:"resetsAt,omitempty"`
|
||||
UsedPercent int64 `json:"usedPercent"`
|
||||
WindowDurationMins int64 `json:"windowDurationMins,omitempty"`
|
||||
}
|
||||
|
||||
type RateLimitReachedType string
|
||||
|
||||
type RateLimitSnapshot struct {
|
||||
Credits *CreditsSnapshot `json:"credits,omitempty"`
|
||||
IndividualLimit *SpendControlLimitSnapshot `json:"individualLimit,omitempty"`
|
||||
LimitID string `json:"limitId,omitempty"`
|
||||
LimitName string `json:"limitName,omitempty"`
|
||||
NormalModelSlug string `json:"normalModelSlug,omitempty"`
|
||||
PlanType PlanType `json:"planType,omitempty"`
|
||||
Primary *RateLimitWindow `json:"primary,omitempty"`
|
||||
RateLimitReachedType RateLimitReachedType `json:"rateLimitReachedType,omitempty"`
|
||||
Secondary *RateLimitWindow `json:"secondary,omitempty"`
|
||||
SpendControlReached bool `json:"spendControlReached,omitempty"`
|
||||
}
|
||||
|
||||
type GetAccountRateLimitsResponse struct {
|
||||
AccountID string `json:"accountId,omitempty"`
|
||||
OrdinaryUsageAllowed bool `json:"ordinaryUsageAllowed,omitempty"`
|
||||
RateLimitResetCredits *RateLimitResetCreditsSummary `json:"rateLimitResetCredits,omitempty"`
|
||||
RateLimitUpsell json.RawMessage `json:"rateLimitUpsell,omitempty"`
|
||||
RateLimits RateLimitSnapshot `json:"rateLimits"`
|
||||
RateLimitsByLimitID map[string]RateLimitSnapshot `json:"rateLimitsByLimitId,omitempty"`
|
||||
}
|
||||
|
||||
type ErrorNotification struct {
|
||||
Error TurnError `json:"error"`
|
||||
ThreadID string `json:"threadId"`
|
||||
@@ -2065,8 +2148,6 @@ type McpServerEventStreamNotification struct {
|
||||
|
||||
type AuthMode string
|
||||
|
||||
type PlanType string
|
||||
|
||||
type AccountUpdatedNotification struct {
|
||||
AuthMode AuthMode `json:"authMode,omitempty"`
|
||||
PlanType PlanType `json:"planType,omitempty"`
|
||||
@@ -2081,40 +2162,6 @@ type GatewayOAuthChangedNotification struct {
|
||||
Status GatewayOAuthStatus `json:"status"`
|
||||
}
|
||||
|
||||
type CreditsSnapshot struct {
|
||||
Balance string `json:"balance,omitempty"`
|
||||
HasCredits bool `json:"hasCredits"`
|
||||
Unlimited bool `json:"unlimited"`
|
||||
}
|
||||
|
||||
type SpendControlLimitSnapshot struct {
|
||||
Limit string `json:"limit"`
|
||||
RemainingPercent int64 `json:"remainingPercent"`
|
||||
ResetsAt int64 `json:"resetsAt"`
|
||||
Used string `json:"used"`
|
||||
}
|
||||
|
||||
type RateLimitWindow struct {
|
||||
ResetsAt int64 `json:"resetsAt,omitempty"`
|
||||
UsedPercent int64 `json:"usedPercent"`
|
||||
WindowDurationMins int64 `json:"windowDurationMins,omitempty"`
|
||||
}
|
||||
|
||||
type RateLimitReachedType string
|
||||
|
||||
type RateLimitSnapshot struct {
|
||||
Credits *CreditsSnapshot `json:"credits,omitempty"`
|
||||
IndividualLimit *SpendControlLimitSnapshot `json:"individualLimit,omitempty"`
|
||||
LimitID string `json:"limitId,omitempty"`
|
||||
LimitName string `json:"limitName,omitempty"`
|
||||
NormalModelSlug string `json:"normalModelSlug,omitempty"`
|
||||
PlanType PlanType `json:"planType,omitempty"`
|
||||
Primary *RateLimitWindow `json:"primary,omitempty"`
|
||||
RateLimitReachedType RateLimitReachedType `json:"rateLimitReachedType,omitempty"`
|
||||
Secondary *RateLimitWindow `json:"secondary,omitempty"`
|
||||
SpendControlReached bool `json:"spendControlReached,omitempty"`
|
||||
}
|
||||
|
||||
type AccountRateLimitsUpdatedNotification struct {
|
||||
RateLimits RateLimitSnapshot `json:"rateLimits"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user