mirror of
https://github.com/openai/codex.git
synced 2026-04-24 14:45:27 +00:00
cut some lines
This commit is contained in:
@@ -272,33 +272,17 @@ impl McpProcess {
|
||||
}
|
||||
|
||||
/// Connect stream for a conversation and wait for the initial_state notification.
|
||||
/// Returns the params of the initial_state notification for further inspection.
|
||||
/// Returns (requestId, params) where params are the initial_state notification params.
|
||||
pub async fn connect_stream_and_expect_initial_state(
|
||||
&mut self,
|
||||
session_id: &str,
|
||||
) -> anyhow::Result<serde_json::Value> {
|
||||
) -> anyhow::Result<(i64, serde_json::Value)> {
|
||||
let req_id = self.send_conversation_stream_tool_call(session_id).await?;
|
||||
// Wait for stream() tool-call response first
|
||||
let _ = self
|
||||
.read_stream_until_response_message(RequestId::Integer(req_id))
|
||||
.await?;
|
||||
// Then the initial_state notification
|
||||
let note = self
|
||||
.read_stream_until_notification_method("notifications/initial_state")
|
||||
.await?;
|
||||
note.params
|
||||
.ok_or_else(|| anyhow::format_err!("initial_state must have params"))
|
||||
}
|
||||
|
||||
/// Connect stream and also return the request id for later cancellation.
|
||||
pub async fn connect_stream_get_req_and_initial_state(
|
||||
&mut self,
|
||||
session_id: &str,
|
||||
) -> anyhow::Result<(i64, serde_json::Value)> {
|
||||
let req_id = self.send_conversation_stream_tool_call(session_id).await?;
|
||||
let _ = self
|
||||
.read_stream_until_response_message(RequestId::Integer(req_id))
|
||||
.await?;
|
||||
let note = self
|
||||
.read_stream_until_notification_method("notifications/initial_state")
|
||||
.await?;
|
||||
|
||||
@@ -38,7 +38,7 @@ async fn test_connect_then_send_receives_initial_state_and_notifications() {
|
||||
.expect("create conversation");
|
||||
|
||||
// Connect the stream
|
||||
let params = mcp
|
||||
let (_stream_req, params) = mcp
|
||||
.connect_stream_and_expect_initial_state(&conv_id)
|
||||
.await
|
||||
.expect("initial_state params");
|
||||
@@ -94,7 +94,7 @@ async fn test_send_then_connect_receives_initial_state_with_message() {
|
||||
.expect("send message ok");
|
||||
|
||||
// Now connect stream and expect InitialState with the prior message included
|
||||
let params = mcp
|
||||
let (_stream_req, params) = mcp
|
||||
.connect_stream_and_expect_initial_state(&conv_id)
|
||||
.await
|
||||
.expect("initial_state params");
|
||||
@@ -151,7 +151,7 @@ async fn test_cancel_stream_then_reconnect_catches_up_initial_state() {
|
||||
.await
|
||||
.expect("create");
|
||||
let (stream_a_id, _params) = mcp
|
||||
.connect_stream_get_req_and_initial_state(&conv_id)
|
||||
.connect_stream_and_expect_initial_state(&conv_id)
|
||||
.await
|
||||
.expect("stream A initial_state");
|
||||
|
||||
@@ -183,7 +183,7 @@ async fn test_cancel_stream_then_reconnect_catches_up_initial_state() {
|
||||
);
|
||||
|
||||
// Connect stream B and expect initial_state that includes the response
|
||||
let params = mcp
|
||||
let (_stream_req, params) = mcp
|
||||
.connect_stream_and_expect_initial_state(&conv_id)
|
||||
.await
|
||||
.expect("stream B initial_state");
|
||||
|
||||
Reference in New Issue
Block a user