mirror of
https://github.com/openai/codex.git
synced 2026-11-19 22:30:42 +00:00
add deferred image content reads
This commit is contained in:
@@ -1478,6 +1478,13 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"LargeContentMode": {
|
||||
"enum": [
|
||||
"inline",
|
||||
"deferred"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"ListMcpServerStatusParams": {
|
||||
"properties": {
|
||||
"cursor": {
|
||||
|
||||
@@ -215,6 +215,13 @@
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"LargeContentMode": {
|
||||
"enum": [
|
||||
"inline",
|
||||
"deferred"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"LocalShellAction": {
|
||||
"oneOf": [
|
||||
{
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type LargeContentMode = "inline" | "deferred";
|
||||
@@ -177,6 +177,7 @@ export type { ItemCompletedNotification } from "./ItemCompletedNotification";
|
||||
export type { ItemGuardianApprovalReviewCompletedNotification } from "./ItemGuardianApprovalReviewCompletedNotification";
|
||||
export type { ItemGuardianApprovalReviewStartedNotification } from "./ItemGuardianApprovalReviewStartedNotification";
|
||||
export type { ItemStartedNotification } from "./ItemStartedNotification";
|
||||
export type { LargeContentMode } from "./LargeContentMode";
|
||||
export type { ListMcpServerStatusParams } from "./ListMcpServerStatusParams";
|
||||
export type { ListMcpServerStatusResponse } from "./ListMcpServerStatusResponse";
|
||||
export type { LoginAccountParams } from "./LoginAccountParams";
|
||||
|
||||
@@ -584,6 +584,13 @@ client_request_definitions! {
|
||||
serialization: None,
|
||||
response: v2::ThreadTurnsItemsListResponse,
|
||||
},
|
||||
#[experimental("thread/item/content/read")]
|
||||
ThreadItemContentRead => "thread/item/content/read" {
|
||||
params: v2::ThreadItemContentReadParams,
|
||||
// Explicitly concurrent: this primarily reads append-only rollout storage.
|
||||
serialization: None,
|
||||
response: v2::ThreadItemContentReadResponse,
|
||||
},
|
||||
/// Append raw Responses API items to the thread history without starting a user turn.
|
||||
ThreadInjectItems => "thread/inject_items" {
|
||||
params: v2::ThreadInjectItemsParams,
|
||||
@@ -1844,6 +1851,7 @@ mod tests {
|
||||
cursor: None,
|
||||
limit: None,
|
||||
sort_direction: None,
|
||||
large_content: None,
|
||||
},
|
||||
};
|
||||
assert_eq!(thread_turns_list.serialization_scope(), None);
|
||||
|
||||
@@ -3980,6 +3980,11 @@ pub struct ThreadResumeParams {
|
||||
#[experimental("thread/resume.excludeTurns")]
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
pub exclude_turns: bool,
|
||||
/// Controls whether large item payloads are embedded in returned turns or
|
||||
/// replaced with deferred-content metadata.
|
||||
#[experimental("thread/resume.largeContent")]
|
||||
#[ts(optional = nullable)]
|
||||
pub large_content: Option<LargeContentMode>,
|
||||
/// Deprecated and ignored by app-server. Kept only so older clients can
|
||||
/// continue sending the field while rollout persistence always uses the
|
||||
/// limited history policy.
|
||||
@@ -4677,6 +4682,10 @@ pub struct ThreadTurnsListParams {
|
||||
/// Optional turn pagination direction; defaults to descending.
|
||||
#[ts(optional = nullable)]
|
||||
pub sort_direction: Option<SortDirection>,
|
||||
/// Controls whether large item payloads are embedded in returned turns or
|
||||
/// replaced with deferred-content metadata.
|
||||
#[ts(optional = nullable)]
|
||||
pub large_content: Option<LargeContentMode>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
@@ -4694,6 +4703,15 @@ pub struct ThreadTurnsListResponse {
|
||||
pub backwards_cursor: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub enum LargeContentMode {
|
||||
#[default]
|
||||
Inline,
|
||||
Deferred,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
@@ -4709,6 +4727,10 @@ pub struct ThreadTurnsItemsListParams {
|
||||
/// Optional item pagination direction; defaults to ascending.
|
||||
#[ts(optional = nullable)]
|
||||
pub sort_direction: Option<SortDirection>,
|
||||
/// Controls whether large item payloads are embedded in returned items or
|
||||
/// replaced with deferred-content metadata.
|
||||
#[ts(optional = nullable)]
|
||||
pub large_content: Option<LargeContentMode>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
@@ -4726,6 +4748,25 @@ pub struct ThreadTurnsItemsListResponse {
|
||||
pub backwards_cursor: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadItemContentReadParams {
|
||||
pub thread_id: String,
|
||||
pub turn_id: String,
|
||||
pub item_id: String,
|
||||
pub content_id: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadItemContentReadResponse {
|
||||
pub mime_type: String,
|
||||
pub data_base64: String,
|
||||
pub byte_length: u64,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
@@ -9108,6 +9149,31 @@ mod tests {
|
||||
assert_eq!(decoded, response);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn image_generation_defaults_missing_content_for_legacy_payloads() {
|
||||
let item: ThreadItem = serde_json::from_value(json!({
|
||||
"type": "imageGeneration",
|
||||
"id": "ig_123",
|
||||
"status": "completed",
|
||||
"revisedPrompt": null,
|
||||
"result": "Zm9v",
|
||||
"savedPath": null
|
||||
}))
|
||||
.expect("legacy image generation item should deserialize");
|
||||
|
||||
assert_eq!(
|
||||
item,
|
||||
ThreadItem::ImageGeneration {
|
||||
id: "ig_123".to_string(),
|
||||
status: "completed".to_string(),
|
||||
revised_prompt: None,
|
||||
content: ImageGenerationContent::default(),
|
||||
result: "Zm9v".to_string(),
|
||||
saved_path: None,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fs_read_file_params_round_trip() {
|
||||
let params = FsReadFileParams {
|
||||
@@ -12037,29 +12103,4 @@ mod tests {
|
||||
"unexpected error: {err}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn image_generation_defaults_missing_content_for_legacy_payloads() {
|
||||
let item: ThreadItem = serde_json::from_value(json!({
|
||||
"type": "imageGeneration",
|
||||
"id": "ig_123",
|
||||
"status": "completed",
|
||||
"revisedPrompt": null,
|
||||
"result": "Zm9v",
|
||||
"savedPath": null
|
||||
}))
|
||||
.expect("legacy image generation item should deserialize");
|
||||
|
||||
assert_eq!(
|
||||
item,
|
||||
ThreadItem::ImageGeneration {
|
||||
id: "ig_123".to_string(),
|
||||
status: "completed".to_string(),
|
||||
revised_prompt: None,
|
||||
content: ImageGenerationContent::default(),
|
||||
result: "Zm9v".to_string(),
|
||||
saved_path: None,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user