Skip to content

Commit b09f62a

Browse files
authored
[Codex] Use Number instead of BigInt for TokenCountEvent (#4856)
Adjust to use typescript number so reduce casting and normalizing code for VSCE since js supports up to 2^53-1
1 parent 5833508 commit b09f62a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

codex-rs/protocol/src/protocol.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,17 +548,23 @@ pub struct TaskStartedEvent {
548548

549549
#[derive(Debug, Clone, Deserialize, Serialize, Default, TS)]
550550
pub struct TokenUsage {
551+
#[ts(type = "number")]
551552
pub input_tokens: u64,
553+
#[ts(type = "number")]
552554
pub cached_input_tokens: u64,
555+
#[ts(type = "number")]
553556
pub output_tokens: u64,
557+
#[ts(type = "number")]
554558
pub reasoning_output_tokens: u64,
559+
#[ts(type = "number")]
555560
pub total_tokens: u64,
556561
}
557562

558563
#[derive(Debug, Clone, Deserialize, Serialize, TS)]
559564
pub struct TokenUsageInfo {
560565
pub total_token_usage: TokenUsage,
561566
pub last_token_usage: TokenUsage,
567+
#[ts(type = "number | null")]
562568
pub model_context_window: Option<u64>,
563569
}
564570

@@ -634,8 +640,10 @@ pub struct RateLimitWindow {
634640
/// Percentage (0-100) of the window that has been consumed.
635641
pub used_percent: f64,
636642
/// Rolling window duration, in minutes.
643+
#[ts(type = "number | null")]
637644
pub window_minutes: Option<u64>,
638645
/// Seconds until the window resets.
646+
#[ts(type = "number | null")]
639647
pub resets_in_seconds: Option<u64>,
640648
}
641649

0 commit comments

Comments
 (0)