Use rmcp ContentBlock in goose-sdk UniFFI (#11210)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -74,6 +74,30 @@ jobs:
|
||||
env:
|
||||
RUST_MIN_STACK: 8388608
|
||||
|
||||
goose-sdk-uniffi:
|
||||
name: Check goose-sdk UniFFI
|
||||
runs-on: ubuntu-latest
|
||||
needs: changes
|
||||
if: needs.changes.outputs.code == 'true' || github.event_name != 'pull_request'
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0
|
||||
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
sudo apt update -y
|
||||
sudo apt install -y libdbus-1-dev libxcb1-dev
|
||||
|
||||
- name: Check UniFFI feature
|
||||
run: |
|
||||
export CARGO_INCREMENTAL=0
|
||||
cargo check -p goose-sdk --features uniffi --locked
|
||||
cargo test -p goose-sdk --features uniffi --locked
|
||||
env:
|
||||
RUST_MIN_STACK: 8388608
|
||||
|
||||
rust-build-and-test-tls:
|
||||
name: Build and Test TLS Backend (${{ matrix.tls-feature }})
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -25,8 +25,7 @@ use goose_providers::{
|
||||
utils::sanitize_unicode_tags,
|
||||
};
|
||||
use rmcp::model::{
|
||||
CallToolRequestParams, CallToolResult, ContentBlock as Content, ErrorCode, ErrorData, Role,
|
||||
Tool,
|
||||
CallToolRequestParams, CallToolResult, ContentBlock, ErrorCode, ErrorData, Role, Tool,
|
||||
};
|
||||
use serde_json::Value;
|
||||
|
||||
@@ -306,15 +305,15 @@ fn call_tool_result(value: Value, is_error: bool) -> CallToolResult {
|
||||
}
|
||||
}
|
||||
|
||||
fn value_to_content(value: Value) -> Content {
|
||||
fn value_to_content(value: Value) -> ContentBlock {
|
||||
match value {
|
||||
Value::String(text) => Content::text(text),
|
||||
Value::String(text) => ContentBlock::text(text),
|
||||
Value::Object(object) => match object.get("type").and_then(|value| value.as_str()) {
|
||||
Some("text") => object
|
||||
.get("text")
|
||||
.and_then(|value| value.as_str().map(str::to_owned))
|
||||
.map(Content::text)
|
||||
.unwrap_or_else(|| Content::text(Value::Object(object).to_string())),
|
||||
.map(ContentBlock::text)
|
||||
.unwrap_or_else(|| ContentBlock::text(Value::Object(object).to_string())),
|
||||
Some("image") => {
|
||||
let mime_type = object
|
||||
.get("mimeType")
|
||||
@@ -325,11 +324,11 @@ fn value_to_content(value: Value) -> Content {
|
||||
.get("data")
|
||||
.and_then(|value| value.as_str().map(str::to_owned))
|
||||
.unwrap_or_default();
|
||||
Content::image(data, mime_type)
|
||||
ContentBlock::image(data, mime_type)
|
||||
}
|
||||
_ => Content::text(Value::Object(object).to_string()),
|
||||
_ => ContentBlock::text(Value::Object(object).to_string()),
|
||||
},
|
||||
other => Content::text(other.to_string()),
|
||||
other => ContentBlock::text(other.to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user