use std::collections::BTreeMap; use crate::JsonSchema; use crate::TS; use codex_experimental_api_macros::ExperimentalApi; use codex_utils_absolute_path::AbsolutePathBuf; use serde::Deserialize; use serde::Serialize; use super::SortDirection; #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] pub struct ProjectRoot { pub path: AbsolutePathBuf, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] pub struct Project { pub id: String, pub name: String, pub roots: Vec, pub metadata: BTreeMap, #[ts(type = "number")] pub position: i64, #[ts(type = "number")] pub created_at: i64, #[ts(type = "number")] pub updated_at: i64, /// Newest non-archived member thread's recency, in Unix seconds; null when none exist. #[ts(type = "number | null")] pub recency_at: Option, } #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(rename_all = "camelCase", export_to = "v2/")] pub enum ProjectSortKey { Position, RecencyAt, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS, ExperimentalApi)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] pub struct ProjectListParams { #[ts(optional = nullable)] pub cursor: Option, #[ts(optional = nullable)] pub limit: Option, /// Defaults to position. Recency sorting always places empty projects last. #[ts(optional = nullable)] pub sort_key: Option, /// Requires sortKey. Defaults to asc for position and desc for recencyAt. #[ts(optional = nullable)] pub sort_direction: Option, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] pub struct ProjectListResponse { pub data: Vec, pub next_cursor: Option, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS, ExperimentalApi)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] pub struct ProjectReadParams { pub project_id: String, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] pub struct ProjectReadResponse { pub project: Project, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS, ExperimentalApi)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] pub struct ProjectCreateParams { pub name: String, pub roots: Vec, #[ts(optional = nullable)] pub metadata: Option>, pub idempotency_key: String, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] pub struct ProjectCreateResponse { pub project: Project, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS, ExperimentalApi)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] pub struct ProjectImportParams { pub name: String, pub roots: Vec, #[ts(optional = nullable)] pub metadata: Option>, #[ts(optional = nullable)] pub threads: Option>, pub idempotency_key: String, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] pub struct ProjectImportResponse { pub project: Project, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS, ExperimentalApi)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] pub struct ProjectUpdateParams { pub project_id: String, #[ts(optional = nullable)] pub name: Option, #[ts(optional = nullable)] pub roots: Option>, #[ts(optional = nullable)] pub metadata: Option>, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] pub struct ProjectUpdateResponse { pub project: Project, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS, ExperimentalApi)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] pub struct ProjectMoveParams { pub project_id: String, #[ts(optional = nullable)] pub before_project_id: Option, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] pub struct ProjectMoveResponse {} #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS, ExperimentalApi)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] pub struct ProjectDeleteParams { pub project_id: String, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] pub struct ProjectDeleteResponse {} #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] pub enum ProjectChangeType { Created, Updated, Deleted, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] pub struct ProjectChangedNotification { pub project_id: String, pub change_type: ProjectChangeType, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] pub struct ThreadProjectUpdatedNotification { pub thread_id: String, #[schemars( required, schema_with = "crate::protocol::serde_helpers::nullable_string_schema" )] pub project_id: Option, }