mirror of
https://github.com/openai/codex.git
synced 2026-11-21 22:50:37 +00:00
feat(tui): support goal budgets
This commit is contained in:
@@ -3521,6 +3521,52 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ThreadGoalBudgetParams": {
|
||||
"oneOf": [
|
||||
{
|
||||
"properties": {
|
||||
"token_budget": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"tokens"
|
||||
],
|
||||
"title": "TokensThreadGoalBudgetParamsType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"token_budget",
|
||||
"type"
|
||||
],
|
||||
"title": "TokensThreadGoalBudgetParams",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"percent": {
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"fiveHourLimitPercent"
|
||||
],
|
||||
"title": "FiveHourLimitPercentThreadGoalBudgetParamsType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"percent",
|
||||
"type"
|
||||
],
|
||||
"title": "FiveHourLimitPercentThreadGoalBudgetParams",
|
||||
"type": "object"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ThreadGoalStatus": {
|
||||
"enum": [
|
||||
"active",
|
||||
|
||||
@@ -3045,6 +3045,16 @@
|
||||
},
|
||||
"ThreadGoal": {
|
||||
"properties": {
|
||||
"budget": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ThreadGoalBudget"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"createdAt": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
@@ -3089,6 +3099,80 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ThreadGoalBudget": {
|
||||
"oneOf": [
|
||||
{
|
||||
"properties": {
|
||||
"token_budget": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"tokens"
|
||||
],
|
||||
"title": "TokensThreadGoalBudgetType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"token_budget",
|
||||
"type"
|
||||
],
|
||||
"title": "TokensThreadGoalBudget",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"baseline_resets_at": {
|
||||
"format": "int64",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"baseline_used_percent": {
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"latest_resets_at": {
|
||||
"format": "int64",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"latest_used_percent": {
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"limit_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"percent": {
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"fiveHourLimitPercent"
|
||||
],
|
||||
"title": "FiveHourLimitPercentThreadGoalBudgetType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"baseline_used_percent",
|
||||
"latest_used_percent",
|
||||
"limit_id",
|
||||
"percent",
|
||||
"type"
|
||||
],
|
||||
"title": "FiveHourLimitPercentThreadGoalBudget",
|
||||
"type": "object"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ThreadGoalClearedNotification": {
|
||||
"properties": {
|
||||
"threadId": {
|
||||
|
||||
+130
@@ -15265,6 +15265,16 @@
|
||||
},
|
||||
"ThreadGoal": {
|
||||
"properties": {
|
||||
"budget": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/v2/ThreadGoalBudget"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"createdAt": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
@@ -15309,6 +15319,126 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ThreadGoalBudget": {
|
||||
"oneOf": [
|
||||
{
|
||||
"properties": {
|
||||
"token_budget": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"tokens"
|
||||
],
|
||||
"title": "TokensThreadGoalBudgetType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"token_budget",
|
||||
"type"
|
||||
],
|
||||
"title": "TokensThreadGoalBudget",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"baseline_resets_at": {
|
||||
"format": "int64",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"baseline_used_percent": {
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"latest_resets_at": {
|
||||
"format": "int64",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"latest_used_percent": {
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"limit_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"percent": {
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"fiveHourLimitPercent"
|
||||
],
|
||||
"title": "FiveHourLimitPercentThreadGoalBudgetType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"baseline_used_percent",
|
||||
"latest_used_percent",
|
||||
"limit_id",
|
||||
"percent",
|
||||
"type"
|
||||
],
|
||||
"title": "FiveHourLimitPercentThreadGoalBudget",
|
||||
"type": "object"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ThreadGoalBudgetParams": {
|
||||
"oneOf": [
|
||||
{
|
||||
"properties": {
|
||||
"token_budget": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"tokens"
|
||||
],
|
||||
"title": "TokensThreadGoalBudgetParamsType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"token_budget",
|
||||
"type"
|
||||
],
|
||||
"title": "TokensThreadGoalBudgetParams",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"percent": {
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"fiveHourLimitPercent"
|
||||
],
|
||||
"title": "FiveHourLimitPercentThreadGoalBudgetParamsType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"percent",
|
||||
"type"
|
||||
],
|
||||
"title": "FiveHourLimitPercentThreadGoalBudgetParams",
|
||||
"type": "object"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ThreadGoalClearedNotification": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"properties": {
|
||||
|
||||
+130
@@ -13151,6 +13151,16 @@
|
||||
},
|
||||
"ThreadGoal": {
|
||||
"properties": {
|
||||
"budget": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ThreadGoalBudget"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"createdAt": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
@@ -13195,6 +13205,126 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ThreadGoalBudget": {
|
||||
"oneOf": [
|
||||
{
|
||||
"properties": {
|
||||
"token_budget": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"tokens"
|
||||
],
|
||||
"title": "TokensThreadGoalBudgetType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"token_budget",
|
||||
"type"
|
||||
],
|
||||
"title": "TokensThreadGoalBudget",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"baseline_resets_at": {
|
||||
"format": "int64",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"baseline_used_percent": {
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"latest_resets_at": {
|
||||
"format": "int64",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"latest_used_percent": {
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"limit_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"percent": {
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"fiveHourLimitPercent"
|
||||
],
|
||||
"title": "FiveHourLimitPercentThreadGoalBudgetType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"baseline_used_percent",
|
||||
"latest_used_percent",
|
||||
"limit_id",
|
||||
"percent",
|
||||
"type"
|
||||
],
|
||||
"title": "FiveHourLimitPercentThreadGoalBudget",
|
||||
"type": "object"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ThreadGoalBudgetParams": {
|
||||
"oneOf": [
|
||||
{
|
||||
"properties": {
|
||||
"token_budget": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"tokens"
|
||||
],
|
||||
"title": "TokensThreadGoalBudgetParamsType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"token_budget",
|
||||
"type"
|
||||
],
|
||||
"title": "TokensThreadGoalBudgetParams",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"percent": {
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"fiveHourLimitPercent"
|
||||
],
|
||||
"title": "FiveHourLimitPercentThreadGoalBudgetParamsType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"percent",
|
||||
"type"
|
||||
],
|
||||
"title": "FiveHourLimitPercentThreadGoalBudgetParams",
|
||||
"type": "object"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ThreadGoalClearedNotification": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"properties": {
|
||||
|
||||
+84
@@ -3,6 +3,16 @@
|
||||
"definitions": {
|
||||
"ThreadGoal": {
|
||||
"properties": {
|
||||
"budget": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ThreadGoalBudget"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"createdAt": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
@@ -47,6 +57,80 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ThreadGoalBudget": {
|
||||
"oneOf": [
|
||||
{
|
||||
"properties": {
|
||||
"token_budget": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"tokens"
|
||||
],
|
||||
"title": "TokensThreadGoalBudgetType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"token_budget",
|
||||
"type"
|
||||
],
|
||||
"title": "TokensThreadGoalBudget",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"baseline_resets_at": {
|
||||
"format": "int64",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"baseline_used_percent": {
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"latest_resets_at": {
|
||||
"format": "int64",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"latest_used_percent": {
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"limit_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"percent": {
|
||||
"format": "double",
|
||||
"type": "number"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"fiveHourLimitPercent"
|
||||
],
|
||||
"title": "FiveHourLimitPercentThreadGoalBudgetType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"baseline_used_percent",
|
||||
"latest_used_percent",
|
||||
"limit_id",
|
||||
"percent",
|
||||
"type"
|
||||
],
|
||||
"title": "FiveHourLimitPercentThreadGoalBudget",
|
||||
"type": "object"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ThreadGoalStatus": {
|
||||
"enum": [
|
||||
"active",
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { ThreadGoalStatus } from "./ThreadGoalStatus";
|
||||
|
||||
export type ThreadGoal = { threadId: string, objective: string, status: ThreadGoalStatus, tokenBudget: number | null, tokensUsed: number, timeUsedSeconds: number, createdAt: number, updatedAt: number, };
|
||||
export type ThreadGoal = { threadId: string, objective: string, status: ThreadGoalStatus, budget: ThreadGoalBudget | null, tokenBudget: number | null, tokensUsed: number, timeUsedSeconds: number, createdAt: number, updatedAt: number, };
|
||||
|
||||
@@ -1675,6 +1675,7 @@ mod tests {
|
||||
thread_id: "goal-thread".to_string(),
|
||||
objective: Some("ship it".to_string()),
|
||||
status: None,
|
||||
budget: None,
|
||||
token_budget: None,
|
||||
},
|
||||
};
|
||||
@@ -2795,6 +2796,7 @@ mod tests {
|
||||
thread_id: "thr_123".to_string(),
|
||||
objective: Some("ship goal mode".to_string()),
|
||||
status: Some(v2::ThreadGoalStatus::Active),
|
||||
budget: None,
|
||||
token_budget: Some(Some(10_000)),
|
||||
},
|
||||
};
|
||||
@@ -2831,6 +2833,7 @@ mod tests {
|
||||
thread_id: "thr_123".to_string(),
|
||||
objective: "ship goal mode".to_string(),
|
||||
status: v2::ThreadGoalStatus::Active,
|
||||
budget: None,
|
||||
token_budget: Some(10_000),
|
||||
tokens_used: 123,
|
||||
time_used_seconds: 45,
|
||||
|
||||
@@ -3991,6 +3991,66 @@ v2_enum_from_core! {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
#[ts(tag = "type")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub enum ThreadGoalBudget {
|
||||
Tokens {
|
||||
#[ts(type = "number")]
|
||||
token_budget: i64,
|
||||
},
|
||||
FiveHourLimitPercent {
|
||||
limit_id: String,
|
||||
percent: f64,
|
||||
baseline_used_percent: f64,
|
||||
#[ts(type = "number | null")]
|
||||
baseline_resets_at: Option<i64>,
|
||||
latest_used_percent: f64,
|
||||
#[ts(type = "number | null")]
|
||||
latest_resets_at: Option<i64>,
|
||||
},
|
||||
}
|
||||
|
||||
impl From<codex_protocol::protocol::ThreadGoalBudget> for ThreadGoalBudget {
|
||||
fn from(value: codex_protocol::protocol::ThreadGoalBudget) -> Self {
|
||||
match value {
|
||||
codex_protocol::protocol::ThreadGoalBudget::Tokens { token_budget } => {
|
||||
Self::Tokens { token_budget }
|
||||
}
|
||||
codex_protocol::protocol::ThreadGoalBudget::FiveHourLimitPercent {
|
||||
limit_id,
|
||||
percent,
|
||||
baseline_used_percent,
|
||||
baseline_resets_at,
|
||||
latest_used_percent,
|
||||
latest_resets_at,
|
||||
} => Self::FiveHourLimitPercent {
|
||||
limit_id,
|
||||
percent,
|
||||
baseline_used_percent,
|
||||
baseline_resets_at,
|
||||
latest_used_percent,
|
||||
latest_resets_at,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
#[ts(tag = "type")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub enum ThreadGoalBudgetParams {
|
||||
Tokens {
|
||||
#[ts(type = "number")]
|
||||
token_budget: i64,
|
||||
},
|
||||
FiveHourLimitPercent {
|
||||
percent: f64,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
@@ -3998,6 +4058,8 @@ pub struct ThreadGoal {
|
||||
pub thread_id: String,
|
||||
pub objective: String,
|
||||
pub status: ThreadGoalStatus,
|
||||
#[ts(type = "ThreadGoalBudget | null")]
|
||||
pub budget: Option<ThreadGoalBudget>,
|
||||
#[ts(type = "number | null")]
|
||||
pub token_budget: Option<i64>,
|
||||
#[ts(type = "number")]
|
||||
@@ -4016,6 +4078,7 @@ impl From<codex_protocol::protocol::ThreadGoal> for ThreadGoal {
|
||||
thread_id: value.thread_id.to_string(),
|
||||
objective: value.objective,
|
||||
status: value.status.into(),
|
||||
budget: value.budget.map(ThreadGoalBudget::from),
|
||||
token_budget: value.token_budget,
|
||||
tokens_used: value.tokens_used,
|
||||
time_used_seconds: value.time_used_seconds,
|
||||
@@ -4040,6 +4103,14 @@ pub struct ThreadGoalSetParams {
|
||||
serialize_with = "super::serde_helpers::serialize_double_option",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
#[ts(optional = nullable, type = "ThreadGoalBudgetParams | null")]
|
||||
pub budget: Option<Option<ThreadGoalBudgetParams>>,
|
||||
#[serde(
|
||||
default,
|
||||
deserialize_with = "super::serde_helpers::deserialize_double_option",
|
||||
serialize_with = "super::serde_helpers::serialize_double_option",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
#[ts(optional = nullable, type = "number | null")]
|
||||
pub token_budget: Option<Option<i64>>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user