mirror of
https://github.com/openai/codex.git
synced 2026-11-08 20:40:33 +00:00
Switch alarms to structured triggers
This commit is contained in:
@@ -1838,41 +1838,6 @@ mod tests {
|
||||
assert_eq!(reason, Some("thread/realtime/outputAudio/delta"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thread_alarm_create_is_marked_experimental() {
|
||||
let request = ClientRequest::ThreadAlarmCreate {
|
||||
request_id: RequestId::Integer(1),
|
||||
params: v2::ThreadAlarmCreateParams {
|
||||
thread_id: "thr_123".to_string(),
|
||||
cron_expression: "@after-turn".to_string(),
|
||||
prompt: "run tests".to_string(),
|
||||
run_once: Some(false),
|
||||
delivery: v2::AlarmDelivery::AfterTurn,
|
||||
},
|
||||
};
|
||||
let reason = crate::experimental_api::ExperimentalApi::experimental_reason(&request);
|
||||
assert_eq!(reason, Some("thread/alarm/create"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thread_alarm_fired_notification_is_marked_experimental() {
|
||||
let notification = ServerNotification::ThreadAlarmFired(v2::ThreadAlarmFiredNotification {
|
||||
thread_id: "thr_123".to_string(),
|
||||
alarm: v2::ThreadAlarm {
|
||||
id: "alarm_123".to_string(),
|
||||
cron_expression: "@after-turn".to_string(),
|
||||
prompt: "run tests".to_string(),
|
||||
run_once: false,
|
||||
delivery: v2::AlarmDelivery::AfterTurn,
|
||||
created_at: 1,
|
||||
next_run_at: None,
|
||||
last_run_at: None,
|
||||
},
|
||||
});
|
||||
let reason = crate::experimental_api::ExperimentalApi::experimental_reason(¬ification);
|
||||
assert_eq!(reason, Some("thread/alarm/fired"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn command_execution_request_approval_additional_permissions_is_marked_experimental() {
|
||||
let params = v2::CommandExecutionRequestApprovalParams {
|
||||
|
||||
@@ -3161,14 +3161,33 @@ pub enum AlarmDelivery {
|
||||
SteerCurrentTurn,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(tag = "kind", rename_all = "camelCase")]
|
||||
#[ts(tag = "kind")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub enum AlarmTrigger {
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(rename_all = "camelCase")]
|
||||
Delay {
|
||||
#[ts(type = "number")]
|
||||
seconds: u64,
|
||||
repeat: Option<bool>,
|
||||
},
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(rename_all = "camelCase")]
|
||||
Schedule {
|
||||
dtstart: Option<String>,
|
||||
rrule: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadAlarm {
|
||||
pub id: String,
|
||||
pub cron_expression: String,
|
||||
pub trigger: AlarmTrigger,
|
||||
pub prompt: String,
|
||||
pub run_once: bool,
|
||||
pub delivery: AlarmDelivery,
|
||||
#[ts(type = "number")]
|
||||
pub created_at: i64,
|
||||
@@ -3183,10 +3202,8 @@ pub struct ThreadAlarm {
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadAlarmCreateParams {
|
||||
pub thread_id: String,
|
||||
pub cron_expression: String,
|
||||
pub trigger: AlarmTrigger,
|
||||
pub prompt: String,
|
||||
#[ts(optional = nullable)]
|
||||
pub run_once: Option<bool>,
|
||||
pub delivery: AlarmDelivery,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user