mirror of
https://github.com/openai/codex.git
synced 2026-11-25 23:30:49 +00:00
[codex-analytics] add protocol-native item timestamps
This commit is contained in:
@@ -1823,6 +1823,9 @@ pub struct RawResponseItemEvent {
|
||||
pub struct ItemStartedEvent {
|
||||
pub thread_id: ThreadId,
|
||||
pub turn_id: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub started_at_ms: Option<i64>,
|
||||
pub item: TurnItem,
|
||||
}
|
||||
|
||||
@@ -1831,10 +1834,12 @@ impl HasLegacyEvent for ItemStartedEvent {
|
||||
match &self.item {
|
||||
TurnItem::WebSearch(item) => vec![EventMsg::WebSearchBegin(WebSearchBeginEvent {
|
||||
call_id: item.id.clone(),
|
||||
started_at_ms: item.started_at_ms,
|
||||
})],
|
||||
TurnItem::ImageGeneration(item) => {
|
||||
vec![EventMsg::ImageGenerationBegin(ImageGenerationBeginEvent {
|
||||
call_id: item.id.clone(),
|
||||
started_at_ms: item.started_at_ms,
|
||||
})]
|
||||
}
|
||||
_ => Vec::new(),
|
||||
@@ -1846,6 +1851,12 @@ impl HasLegacyEvent for ItemStartedEvent {
|
||||
pub struct ItemCompletedEvent {
|
||||
pub thread_id: ThreadId,
|
||||
pub turn_id: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub started_at_ms: Option<i64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub completed_at_ms: Option<i64>,
|
||||
pub item: TurnItem,
|
||||
}
|
||||
|
||||
@@ -2336,6 +2347,9 @@ pub struct McpToolCallBeginEvent {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub mcp_app_resource_uri: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub started_at_ms: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema, TS, PartialEq)]
|
||||
@@ -2346,6 +2360,12 @@ pub struct McpToolCallEndEvent {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub mcp_app_resource_uri: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub started_at_ms: Option<i64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub completed_at_ms: Option<i64>,
|
||||
#[ts(type = "string")]
|
||||
pub duration: Duration,
|
||||
/// Result of the tool call. Note this could be an error.
|
||||
@@ -2371,6 +2391,14 @@ pub struct DynamicToolCallResponseEvent {
|
||||
pub success: bool,
|
||||
/// Optional error text when the tool call failed before producing a response.
|
||||
pub error: Option<String>,
|
||||
/// Unix timestamp (in milliseconds) when dynamic tool execution started, if known.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub started_at_ms: Option<i64>,
|
||||
/// Unix timestamp (in milliseconds) when dynamic tool execution completed, if known.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub completed_at_ms: Option<i64>,
|
||||
/// The duration of the dynamic tool call.
|
||||
#[ts(type = "string")]
|
||||
pub duration: Duration,
|
||||
@@ -2388,6 +2416,9 @@ impl McpToolCallEndEvent {
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema, TS)]
|
||||
pub struct WebSearchBeginEvent {
|
||||
pub call_id: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub started_at_ms: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema, TS)]
|
||||
@@ -2395,11 +2426,23 @@ pub struct WebSearchEndEvent {
|
||||
pub call_id: String,
|
||||
pub query: String,
|
||||
pub action: WebSearchAction,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub started_at_ms: Option<i64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub completed_at_ms: Option<i64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub duration_ms: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema, TS)]
|
||||
pub struct ImageGenerationBeginEvent {
|
||||
pub call_id: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub started_at_ms: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema, TS)]
|
||||
@@ -2413,6 +2456,15 @@ pub struct ImageGenerationEndEvent {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub saved_path: Option<AbsolutePathBuf>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub started_at_ms: Option<i64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub completed_at_ms: Option<i64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub duration_ms: Option<i64>,
|
||||
}
|
||||
|
||||
// Conversation kept for backward compatibility.
|
||||
@@ -3080,6 +3132,9 @@ pub struct ExecCommandBeginEvent {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub interaction_input: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub started_at_ms: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema, TS)]
|
||||
@@ -3104,6 +3159,12 @@ pub struct ExecCommandEndEvent {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub interaction_input: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub started_at_ms: Option<i64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub completed_at_ms: Option<i64>,
|
||||
|
||||
/// Captured stdout
|
||||
pub stdout: String,
|
||||
@@ -3225,6 +3286,9 @@ pub struct PatchApplyBeginEvent {
|
||||
pub auto_approved: bool,
|
||||
/// The changes to be applied.
|
||||
pub changes: HashMap<PathBuf, FileChange>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub started_at_ms: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema, TS)]
|
||||
@@ -3254,6 +3318,15 @@ pub struct PatchApplyEndEvent {
|
||||
pub changes: HashMap<PathBuf, FileChange>,
|
||||
/// Completion status for this patch application.
|
||||
pub status: PatchApplyStatus,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub started_at_ms: Option<i64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub completed_at_ms: Option<i64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub duration_ms: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, JsonSchema, TS)]
|
||||
@@ -3776,6 +3849,9 @@ pub struct CollabAgentSpawnBeginEvent {
|
||||
pub prompt: String,
|
||||
pub model: String,
|
||||
pub reasoning_effort: ReasoningEffortConfig,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub started_at_ms: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, JsonSchema, TS)]
|
||||
@@ -3827,6 +3903,15 @@ pub struct CollabAgentSpawnEndEvent {
|
||||
pub reasoning_effort: ReasoningEffortConfig,
|
||||
/// Last known status of the new agent reported to the sender agent.
|
||||
pub status: AgentStatus,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub started_at_ms: Option<i64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub completed_at_ms: Option<i64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub duration_ms: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, JsonSchema, TS)]
|
||||
@@ -3840,6 +3925,9 @@ pub struct CollabAgentInteractionBeginEvent {
|
||||
/// Prompt sent from the sender to the receiver. Can be empty to prevent CoT
|
||||
/// leaking at the beginning.
|
||||
pub prompt: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub started_at_ms: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, JsonSchema, TS)]
|
||||
@@ -3861,6 +3949,15 @@ pub struct CollabAgentInteractionEndEvent {
|
||||
pub prompt: String,
|
||||
/// Last known status of the receiver agent reported to the sender agent.
|
||||
pub status: AgentStatus,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub started_at_ms: Option<i64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub completed_at_ms: Option<i64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub duration_ms: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, JsonSchema, TS)]
|
||||
@@ -3874,6 +3971,9 @@ pub struct CollabWaitingBeginEvent {
|
||||
pub receiver_agents: Vec<CollabAgentRef>,
|
||||
/// ID of the waiting call.
|
||||
pub call_id: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub started_at_ms: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, JsonSchema, TS)]
|
||||
@@ -3887,6 +3987,15 @@ pub struct CollabWaitingEndEvent {
|
||||
pub agent_statuses: Vec<CollabAgentStatusEntry>,
|
||||
/// Last known status of the receiver agents reported to the sender agent.
|
||||
pub statuses: HashMap<ThreadId, AgentStatus>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub started_at_ms: Option<i64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub completed_at_ms: Option<i64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub duration_ms: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, JsonSchema, TS)]
|
||||
@@ -3897,6 +4006,9 @@ pub struct CollabCloseBeginEvent {
|
||||
pub sender_thread_id: ThreadId,
|
||||
/// Thread ID of the receiver.
|
||||
pub receiver_thread_id: ThreadId,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub started_at_ms: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, JsonSchema, TS)]
|
||||
@@ -3916,6 +4028,15 @@ pub struct CollabCloseEndEvent {
|
||||
/// Last known status of the receiver agent reported to the sender agent before
|
||||
/// the close.
|
||||
pub status: AgentStatus,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub started_at_ms: Option<i64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub completed_at_ms: Option<i64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub duration_ms: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, JsonSchema, TS)]
|
||||
@@ -3932,6 +4053,9 @@ pub struct CollabResumeBeginEvent {
|
||||
/// Optional role assigned to the receiver agent.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub receiver_agent_role: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub started_at_ms: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, JsonSchema, TS)]
|
||||
@@ -3951,6 +4075,15 @@ pub struct CollabResumeEndEvent {
|
||||
/// Last known status of the receiver agent reported to the sender agent after
|
||||
/// resume.
|
||||
pub status: AgentStatus,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub started_at_ms: Option<i64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub completed_at_ms: Option<i64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub duration_ms: Option<i64>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -4567,6 +4700,7 @@ mod tests {
|
||||
let event = ItemStartedEvent {
|
||||
thread_id: ThreadId::new(),
|
||||
turn_id: "turn-1".into(),
|
||||
started_at_ms: None,
|
||||
item: TurnItem::WebSearch(WebSearchItem {
|
||||
id: "search-1".into(),
|
||||
query: "find docs".into(),
|
||||
@@ -4574,6 +4708,9 @@ mod tests {
|
||||
query: Some("find docs".into()),
|
||||
queries: None,
|
||||
},
|
||||
started_at_ms: None,
|
||||
completed_at_ms: None,
|
||||
duration_ms: None,
|
||||
}),
|
||||
};
|
||||
|
||||
@@ -4590,6 +4727,7 @@ mod tests {
|
||||
let event = ItemStartedEvent {
|
||||
thread_id: ThreadId::new(),
|
||||
turn_id: "turn-1".into(),
|
||||
started_at_ms: None,
|
||||
item: TurnItem::UserMessage(UserMessageItem::new(&[])),
|
||||
};
|
||||
|
||||
@@ -4605,12 +4743,16 @@ mod tests {
|
||||
let event = ItemStartedEvent {
|
||||
thread_id: ThreadId::new(),
|
||||
turn_id: "turn-1".into(),
|
||||
started_at_ms: None,
|
||||
item: TurnItem::ImageGeneration(ImageGenerationItem {
|
||||
id: "ig-1".into(),
|
||||
status: "in_progress".into(),
|
||||
revised_prompt: None,
|
||||
result: String::new(),
|
||||
saved_path: None,
|
||||
started_at_ms: None,
|
||||
completed_at_ms: None,
|
||||
duration_ms: None,
|
||||
}),
|
||||
};
|
||||
|
||||
@@ -4627,12 +4769,17 @@ mod tests {
|
||||
let event = ItemCompletedEvent {
|
||||
thread_id: ThreadId::new(),
|
||||
turn_id: "turn-1".into(),
|
||||
started_at_ms: None,
|
||||
completed_at_ms: None,
|
||||
item: TurnItem::ImageGeneration(ImageGenerationItem {
|
||||
id: "ig-1".into(),
|
||||
status: "completed".into(),
|
||||
revised_prompt: Some("A tiny blue square".into()),
|
||||
result: "Zm9v".into(),
|
||||
saved_path: Some(test_path_buf("/tmp/ig-1.png").abs()),
|
||||
started_at_ms: None,
|
||||
completed_at_ms: None,
|
||||
duration_ms: None,
|
||||
}),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user