mirror of
https://github.com/openai/codex.git
synced 2026-09-08 15:50:34 +00:00
## What changed - Define `SleepItem` in `codex-extension-items` and carry `clock.sleep` events through `TurnItem::Extension`. - Preserve sleep persistence, thread-history reconstruction, and the app-server's `type: "sleep"` schema while reusing the extension-owned type. ## Testing - Add serialization coverage for the `clock.sleep` extension wire shape and its protocol wrapper. - Update sleep lifecycle and thread-history tests to exercise the extension-owned item. GitOrigin-RevId: 34bb33ed9b90a09bf4744aafdb56e019c717a168
62 lines
1.7 KiB
Rust
62 lines
1.7 KiB
Rust
//! Typed display items owned by Codex extensions.
|
|
//!
|
|
//! This crate intentionally sits below `codex-protocol` so core can carry
|
|
//! extension items without owning each extension's display schema.
|
|
|
|
use schemars::JsonSchema;
|
|
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
use ts_rs::TS;
|
|
|
|
pub mod image_generation;
|
|
pub mod sleep;
|
|
pub mod web_search;
|
|
|
|
/// Canonical extension-owned turn item carried through core lifecycle events.
|
|
///
|
|
/// The item is serialized as a flattened, namespaced envelope:
|
|
///
|
|
/// ```json
|
|
/// {
|
|
/// "kind": "image_gen.generation",
|
|
/// "id": "call-id",
|
|
/// "status": "completed",
|
|
/// "revisedPrompt": "A blue square",
|
|
/// "result": "cG5n",
|
|
/// "savedPath": "/tmp/image.png"
|
|
/// }
|
|
/// ```
|
|
///
|
|
/// `kind` values follow `<extension_namespace>.<item_kind>`. Adding a variant
|
|
/// also requires app-server to add its typed public wrapper.
|
|
#[derive(Debug, Clone, Deserialize, Serialize, TS, JsonSchema, PartialEq)]
|
|
#[serde(tag = "kind")]
|
|
#[ts(tag = "kind")]
|
|
pub enum ExtensionItem {
|
|
#[serde(rename = "image_gen.generation")]
|
|
#[ts(rename = "image_gen.generation")]
|
|
ImageGeneration(image_generation::ImageGenerationItem),
|
|
#[serde(rename = "clock.sleep")]
|
|
#[ts(rename = "clock.sleep")]
|
|
Sleep(sleep::SleepItem),
|
|
#[serde(rename = "web.search")]
|
|
#[ts(rename = "web.search")]
|
|
WebSearch(web_search::WebSearchItem),
|
|
}
|
|
|
|
impl ExtensionItem {
|
|
/// Returns the stable item identifier without exposing variant fields to
|
|
/// core or rollout persistence.
|
|
pub fn id(&self) -> &str {
|
|
match self {
|
|
Self::ImageGeneration(item) => &item.id,
|
|
Self::Sleep(item) => &item.id,
|
|
Self::WebSearch(item) => &item.id,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "tests.rs"]
|
|
mod tests;
|