mirror of
https://github.com/openai/codex.git
synced 2026-08-25 13:28:55 +00:00
## Description This PR migrates standalone web search onto the extension-owned turn-item path introduced in #31283. Standalone web search now emits `ExtensionItem::WebSearch` through generic `TurnItem::Extension`, while app-server still exposes the existing typed `ThreadItem::WebSearch` JSON shape. Hosted Responses API web search stays on core-owned `TurnItem::WebSearch`. ## What changed - Added `web_search::WebSearchItem` and `WebSearchAction` to `codex-extension-items` under the stable `web.search` kind. - Collapsed `ExtensionTurnItem` to generic `{ item, legacy_events }` now that no typed extension special cases remain. - Kept the existing `WebSearchBegin` / `WebSearchEnd` compatibility events and canonical-first ordering. - Updated app-server projection/history and generated TypeScript; the app-server JSON schema is unchanged.
57 lines
1.6 KiB
Rust
57 lines
1.6 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 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 = "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::WebSearch(item) => &item.id,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "tests.rs"]
|
|
mod tests;
|