Skip to main content

codex_extension_items/
web_search.rs

1use schemars::JsonSchema;
2use serde::Deserialize;
3use serde::Serialize;
4use serde_json::Value as JsonValue;
5use ts_rs::TS;
6
7// Standalone web-search item owned by the web extension. This is also the
8// field-level representation exposed by app-server; core and rollout
9// persistence only carry it inside an ExtensionItem envelope.
10#[derive(Debug, Clone, Deserialize, Serialize, TS, JsonSchema, PartialEq)]
11#[serde(rename_all = "camelCase")]
12#[ts(rename_all = "camelCase")]
13pub struct WebSearchItem {
14    pub id: String,
15    pub query: String,
16    pub action: Option<WebSearchAction>,
17    /// Structured search results returned out-of-band by standalone web search.
18    ///
19    /// These stay as opaque JSON at the extension/app-server boundary so new
20    /// result fields and result types can pass through without a Codex release.
21    #[serde(default)]
22    pub results: Option<Vec<JsonValue>>,
23}
24
25// App-server-facing description of the action performed by standalone web search.
26#[derive(Debug, Clone, Deserialize, Serialize, TS, JsonSchema, PartialEq)]
27#[serde(tag = "type", rename_all = "camelCase")]
28#[ts(tag = "type", rename_all = "camelCase")]
29// Keep app-server's existing v2 TS path. The root WebSearchAction name is
30// already used by the snake_case Responses API action type.
31#[ts(export_to = "v2/")]
32pub enum WebSearchAction {
33    Search {
34        query: Option<String>,
35        queries: Option<Vec<String>>,
36    },
37    OpenPage {
38        url: Option<String>,
39    },
40    FindInPage {
41        url: Option<String>,
42        pattern: Option<String>,
43    },
44    #[serde(other)]
45    Other,
46}