Add Epiphany view lens wrapper

This commit is contained in:
Meta Vens 2026-05-12 03:51:17 +01:00
commit e551bbf6c5
8 changed files with 221 additions and 0 deletions

View file

@ -341,6 +341,11 @@ client_request_definitions! {
params: v2::ThreadEpiphanySceneParams,
response: v2::ThreadEpiphanySceneResponse,
},
#[experimental("thread/epiphany/view")]
ThreadEpiphanyView => "thread/epiphany/view" {
params: v2::ThreadEpiphanyViewParams,
response: v2::ThreadEpiphanyViewResponse,
},
#[experimental("thread/epiphany/jobs")]
ThreadEpiphanyJobs => "thread/epiphany/jobs" {
params: v2::ThreadEpiphanyJobsParams,
@ -1891,6 +1896,68 @@ mod tests {
Ok(())
}
#[test]
fn serialize_thread_epiphany_view_response() -> Result<()> {
let request = ClientRequest::ThreadEpiphanyView {
request_id: RequestId::Integer(8),
params: v2::ThreadEpiphanyViewParams {
thread_id: "thr_123".to_string(),
lenses: vec![v2::ThreadEpiphanyViewLens::Pressure],
},
};
assert_eq!(request.method(), "thread/epiphany/view");
let response = ClientResponse::ThreadEpiphanyView {
request_id: RequestId::Integer(8),
response: v2::ThreadEpiphanyViewResponse {
thread_id: "thr_123".to_string(),
lenses: vec![v2::ThreadEpiphanyViewLens::Pressure],
scene: None,
jobs: Vec::new(),
pressure: Some(v2::ThreadEpiphanyPressure {
status: v2::ThreadEpiphanyPressureStatus::Ready,
level: v2::ThreadEpiphanyPressureLevel::Low,
basis: v2::ThreadEpiphanyPressureBasis::ModelContextWindow,
used_tokens: Some(10),
model_context_window: Some(100),
model_auto_compact_token_limit: Some(100),
remaining_tokens: Some(90),
ratio_per_mille: Some(100),
should_prepare_compaction: false,
note: "Context window usage is below the compaction prep threshold."
.to_string(),
}),
},
};
assert_eq!(response.id(), &RequestId::Integer(8));
assert_eq!(response.method(), "thread/epiphany/view");
assert_eq!(
json!({
"method": "thread/epiphany/view",
"id": 8,
"response": {
"threadId": "thr_123",
"lenses": ["pressure"],
"pressure": {
"status": "ready",
"level": "low",
"basis": "modelContextWindow",
"usedTokens": 10,
"modelContextWindow": 100,
"modelAutoCompactTokenLimit": 100,
"remainingTokens": 90,
"ratioPerMille": 100,
"shouldPrepareCompaction": false,
"note": "Context window usage is below the compaction prep threshold."
}
}
}),
serde_json::to_value(&response)?,
);
Ok(())
}
#[test]
fn serialize_thread_epiphany_jobs_response() -> Result<()> {
let response = ClientResponse::ThreadEpiphanyJobs {

View file

@ -3940,6 +3940,41 @@ pub struct ThreadEpiphanySceneResponse {
pub scene: ThreadEpiphanyScene,
}
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub enum ThreadEpiphanyViewLens {
Scene,
Jobs,
Pressure,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanyViewParams {
pub thread_id: String,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub lenses: Vec<ThreadEpiphanyViewLens>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanyViewResponse {
pub thread_id: String,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub lenses: Vec<ThreadEpiphanyViewLens>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub scene: Option<ThreadEpiphanyScene>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub jobs: Vec<ThreadEpiphanyJob>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub pressure: Option<ThreadEpiphanyPressure>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]