update to RMCP 0.6.2 (#4523)

This commit is contained in:
Max Novich
2025-09-05 06:54:10 -07:00
committed by GitHub
parent 0db329bac4
commit 195f389972
24 changed files with 191 additions and 24 deletions
+2
View File
@@ -21,7 +21,9 @@ rmcp = { workspace = true, features = [
"reqwest",
"transport-child-process",
"transport-sse-client",
"transport-sse-client-reqwest",
"transport-streamable-http-client",
"transport-streamable-http-client-reqwest",
] }
anyhow = "1.0"
thiserror = "1.0"
@@ -1154,6 +1154,7 @@ mod tests {
content: vec![],
is_error: None,
structured_content: None,
meta: None,
}),
_ => Err(Error::TransportClosed),
}
@@ -255,6 +255,7 @@ mod tests {
vec![MessageContent::Text(
RawTextContent {
text: "Summary of conversation".to_string(),
meta: None,
}
.no_annotation(),
)],
@@ -101,6 +101,7 @@ mod tests {
vec![MessageContent::Text(
RawTextContent {
text: "Summarized content".to_string(),
meta: None,
}
.no_annotation(),
)],
+24 -3
View File
@@ -168,7 +168,13 @@ impl fmt::Display for MessageContent {
impl MessageContent {
pub fn text<S: Into<String>>(text: S) -> Self {
MessageContent::Text(RawTextContent { text: text.into() }.no_annotation())
MessageContent::Text(
RawTextContent {
text: text.into(),
meta: None,
}
.no_annotation(),
)
}
pub fn image<S: Into<String>, T: Into<String>>(data: S, mime_type: T) -> Self {
@@ -176,6 +182,7 @@ impl MessageContent {
RawImageContent {
data: data.into(),
mime_type: mime_type.into(),
meta: None,
}
.no_annotation(),
)
@@ -317,6 +324,7 @@ impl From<Content> for MessageContent {
RawContent::Image(image) => {
MessageContent::Image(image.optional_annotate(content.annotations))
}
RawContent::ResourceLink(_link) => MessageContent::text("[Resource link]"),
RawContent::Resource(resource) => {
let text = match &resource.resource {
ResourceContents::TextResourceContents { text, .. } => text.clone(),
@@ -347,6 +355,7 @@ impl From<PromptMessage> for Message {
PromptMessageContent::Image { image } => {
MessageContent::image(image.data.clone(), image.mime_type.clone())
}
PromptMessageContent::ResourceLink { .. } => MessageContent::text("[Resource link]"),
PromptMessageContent::Resource { resource } => {
// For resources, convert to text content with the resource text
match &resource.resource {
@@ -445,6 +454,7 @@ impl Message {
self.with_content(MessageContent::Text(
RawTextContent {
text: sanitized_text,
meta: None,
}
.no_annotation(),
))
@@ -756,6 +766,7 @@ mod tests {
image: RawImageContent {
data: "base64data".to_string(),
mime_type: "image/jpeg".to_string(),
meta: None,
}
.no_annotation(),
};
@@ -781,10 +792,15 @@ mod tests {
uri: "file:///test.txt".to_string(),
mime_type: Some("text/plain".to_string()),
text: "Resource content".to_string(),
meta: None,
};
let prompt_content = PromptMessageContent::Resource {
resource: RawEmbeddedResource { resource }.no_annotation(),
resource: RawEmbeddedResource {
resource,
meta: None,
}
.no_annotation(),
};
let prompt_message = PromptMessage {
@@ -807,10 +823,15 @@ mod tests {
uri: "file:///test.bin".to_string(),
mime_type: Some("application/octet-stream".to_string()),
blob: "binary_data".to_string(),
meta: None,
};
let prompt_content = PromptMessageContent::Resource {
resource: RawEmbeddedResource { resource }.no_annotation(),
resource: RawEmbeddedResource {
resource,
meta: None,
}
.no_annotation(),
};
let prompt_message = PromptMessage {
+1
View File
@@ -221,6 +221,7 @@ mod tests {
"Response from {} with model {}",
self.name, self.model_config.model_name
),
meta: None,
}
.no_annotation(),
)],
@@ -124,6 +124,9 @@ pub fn to_bedrock_tool_result_content_block(
RawContent::Image(image) => {
bedrock::ToolResultContentBlock::Image(to_bedrock_image(&image.data, &image.mime_type)?)
}
RawContent::ResourceLink(_link) => {
bedrock::ToolResultContentBlock::Text("[Resource link]".to_string())
}
RawContent::Resource(resource) => match &resource.resource {
ResourceContents::TextResourceContents { text, .. } => {
match to_bedrock_document(tool_use_id, &resource.resource)? {
@@ -381,6 +384,7 @@ mod tests {
let image = RawImageContent {
data: TEST_IMAGE_BASE64.to_string(),
mime_type: mime_type.to_string(),
meta: None,
}
.no_annotation();
@@ -396,6 +400,7 @@ mod tests {
let image = RawImageContent {
data: TEST_IMAGE_BASE64.to_string(),
mime_type: "image/bmp".to_string(),
meta: None,
}
.no_annotation();
@@ -411,6 +416,7 @@ mod tests {
let image = RawImageContent {
data: "invalid_base64_data!!!".to_string(),
mime_type: "image/png".to_string(),
meta: None,
}
.no_annotation();
@@ -425,6 +431,7 @@ mod tests {
let image = RawImageContent {
data: TEST_IMAGE_BASE64.to_string(),
mime_type: "image/png".to_string(),
meta: None,
}
.no_annotation();
@@ -490,6 +490,7 @@ mod tests {
vec![MessageContent::Text(
RawTextContent {
text: format!("Response from {}", self.name),
meta: None,
}
.no_annotation(),
)],
@@ -656,6 +657,7 @@ mod tests {
vec![MessageContent::Text(
RawTextContent {
text: format!("Response from {}", self.name),
meta: None,
}
.no_annotation(),
)],
@@ -203,6 +203,7 @@ mod tests {
vec![MessageContent::Text(TextContent {
raw: RawTextContent {
text: self.response.clone(),
meta: None,
},
annotations: None,
})],
+1
View File
@@ -374,6 +374,7 @@ pub fn load_image_file(path: &str) -> Result<ImageContent, ProviderError> {
Ok(RawImageContent {
mime_type: mime_type.to_string(),
data,
meta: None,
}
.no_annotation())
}
+1
View File
@@ -1406,6 +1406,7 @@ mod tests {
vec![MessageContent::Text(
RawTextContent {
text: "Mocked scheduled response".to_string(),
meta: None,
}
.no_annotation(),
)],
+1
View File
@@ -277,6 +277,7 @@ impl ProviderTester {
let image_content = RawImageContent {
data: base64_image,
mime_type: "image/png".to_string(),
meta: None,
}
.no_annotation();