refactor(mcp): migrate Prompts requests and results through rmcp SDK
CI / UI Checks (pull_request) Successful in 11s
CI / Rust Checks (pull_request) Successful in 30m13s
CI / Rust Feature Validation (pull_request) Skipped
CI / Frontend E2E (pull_request) Skipped
CI / Community Image Smoke (pull_request) Skipped
CI / Required Checks (pull_request) Successful in 1s
CI / Deploy (pull_request) Skipped
CI / UI Checks (pull_request) Successful in 11s
CI / Rust Checks (pull_request) Successful in 30m13s
CI / Rust Feature Validation (pull_request) Skipped
CI / Frontend E2E (pull_request) Skipped
CI / Community Image Smoke (pull_request) Skipped
CI / Required Checks (pull_request) Successful in 1s
CI / Deploy (pull_request) Skipped
This commit is contained in:
1 parent
f56553c4d6
commit
24bba2cf33
8 files changed
+944
-24
No files matched your search
@@ -21,7 +21,7 @@ use crate::{
|
||||
PromptGetCommand, PromptsCommand, PromptsListCommand, PromptsOutcome, RequestIdentity,
|
||||
ResourceReadCommand, ResourcesCommand, ResourcesListCommand, ResourcesOutcome,
|
||||
ServiceContext, ToolCallCommand, ToolsCommand, ToolsListCommand, ToolsOutcome,
|
||||
declared_mcp_method, discover_result, handle_completion_command, handle_prompts_command,
|
||||
declared_mcp_method, discover_result, handle_completion_command,
|
||||
validate_modern_request_name,
|
||||
},
|
||||
session::SessionState,
|
||||
@@ -468,7 +468,7 @@ pub(super) async fn handle_modern_request(
|
||||
);
|
||||
}
|
||||
};
|
||||
let outcome = handle_prompts_command(
|
||||
let outcome = super::rmcp_dispatch::handle_prompts_command(
|
||||
state,
|
||||
resource_service_context(path, credential, transport_correlation, message),
|
||||
version,
|
||||
@@ -485,7 +485,10 @@ pub(super) async fn handle_modern_request(
|
||||
request_id(message),
|
||||
crate::protocol::project_modern_cacheable_result(
|
||||
version,
|
||||
prompts_list_result(prompts, next_cursor),
|
||||
match prompts_list_result(prompts, next_cursor) {
|
||||
Ok(result) => result,
|
||||
Err(error) => return internal_jsonrpc_error(message, error),
|
||||
},
|
||||
),
|
||||
),
|
||||
response_mode,
|
||||
@@ -527,7 +530,7 @@ pub(super) async fn handle_modern_request(
|
||||
if let Err(response) = validate_modern_request_name(message, headers, &command.name) {
|
||||
return *response;
|
||||
}
|
||||
let outcome = handle_prompts_command(
|
||||
let outcome = super::rmcp_dispatch::handle_prompts_command(
|
||||
state,
|
||||
resource_service_context(path, credential, transport_correlation, message),
|
||||
version,
|
||||
@@ -544,7 +547,10 @@ pub(super) async fn handle_modern_request(
|
||||
request_id(message),
|
||||
crate::protocol::project_modern_result(
|
||||
version,
|
||||
prompt_get_result(description, messages),
|
||||
match prompt_get_result(description, messages) {
|
||||
Ok(result) => result,
|
||||
Err(error) => return internal_jsonrpc_error(message, error),
|
||||
},
|
||||
),
|
||||
),
|
||||
response_mode,
|
||||
|
||||
@@ -58,9 +58,24 @@ pub(crate) struct CounterSet {
|
||||
sdk_resources_list_result: AtomicUsize,
|
||||
sdk_resources_read_result: AtomicUsize,
|
||||
sdk_resource_templates_list_result: AtomicUsize,
|
||||
sdk_prompts_dispatch: AtomicUsize,
|
||||
sdk_prompts_list_result: AtomicUsize,
|
||||
sdk_prompts_get_result: AtomicUsize,
|
||||
}
|
||||
|
||||
impl CounterSet {
|
||||
pub(crate) fn sdk_prompts_dispatch(&self) -> usize {
|
||||
self.sdk_prompts_dispatch.load(Ordering::SeqCst)
|
||||
}
|
||||
|
||||
pub(crate) fn sdk_prompts_list_result(&self) -> usize {
|
||||
self.sdk_prompts_list_result.load(Ordering::SeqCst)
|
||||
}
|
||||
|
||||
pub(crate) fn sdk_prompts_get_result(&self) -> usize {
|
||||
self.sdk_prompts_get_result.load(Ordering::SeqCst)
|
||||
}
|
||||
|
||||
pub(crate) fn sdk_resources_dispatch(&self) -> usize {
|
||||
self.sdk_resources_dispatch.load(Ordering::SeqCst)
|
||||
}
|
||||
@@ -212,6 +227,25 @@ pub(crate) fn sdk_resource_templates_list_result_serialized() {
|
||||
#[path = "../rmcp_resources_runtime_tests.rs"]
|
||||
mod rmcp_resources_runtime_tests;
|
||||
|
||||
/// Mark only after converting a Prompts request through the real SDK typed path.
|
||||
pub(crate) fn sdk_prompts_dispatch_enter() {
|
||||
increment(|counters| &counters.sdk_prompts_dispatch);
|
||||
}
|
||||
|
||||
/// Mark only after successfully serializing a real SDK ListPromptsResult.
|
||||
pub(crate) fn sdk_prompts_list_result_serialized() {
|
||||
increment(|counters| &counters.sdk_prompts_list_result);
|
||||
}
|
||||
|
||||
/// Mark only after successfully serializing a real SDK GetPromptResult.
|
||||
pub(crate) fn sdk_prompts_get_result_serialized() {
|
||||
increment(|counters| &counters.sdk_prompts_get_result);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "../rmcp_prompts_runtime_tests.rs"]
|
||||
mod rmcp_prompts_runtime_tests;
|
||||
|
||||
fn increment(counter: impl Fn(&CounterSet) -> &AtomicUsize) {
|
||||
let _ = OBSERVER.try_with(|counters| {
|
||||
counter(counters).fetch_add(1, Ordering::SeqCst);
|
||||
|
||||
@@ -40,7 +40,7 @@ use crate::{
|
||||
PromptsCommand, PromptsListCommand, PromptsOutcome, RequestIdentity, ResourceReadCommand,
|
||||
ResourcesCommand, ResourcesListCommand, ResourcesOutcome, ServiceContext, SetLevelCommand,
|
||||
ToolCallCommand, ToolsCommand, ToolsListCommand, ToolsOutcome, handle_completion_command,
|
||||
handle_logging_command, handle_prompts_command,
|
||||
handle_logging_command,
|
||||
},
|
||||
tool_error::execution_locale,
|
||||
transport::{ResponseMode, session_id_from_headers, transport_response},
|
||||
@@ -485,7 +485,7 @@ pub(super) async fn handle_legacy_request(
|
||||
);
|
||||
}
|
||||
};
|
||||
let outcome = handle_prompts_command(
|
||||
let outcome = super::rmcp_dispatch::handle_prompts_command(
|
||||
&state,
|
||||
ServiceContext {
|
||||
workspace_slug: &session.workspace_slug,
|
||||
@@ -507,7 +507,10 @@ pub(super) async fn handle_legacy_request(
|
||||
StatusCode::OK,
|
||||
jsonrpc_result(
|
||||
request_id(message),
|
||||
prompts_list_result(prompts, next_cursor),
|
||||
match prompts_list_result(prompts, next_cursor) {
|
||||
Ok(result) => result,
|
||||
Err(error) => return internal_jsonrpc_error(message, error),
|
||||
},
|
||||
),
|
||||
response_mode,
|
||||
None,
|
||||
@@ -547,7 +550,7 @@ pub(super) async fn handle_legacy_request(
|
||||
);
|
||||
}
|
||||
};
|
||||
let outcome = handle_prompts_command(
|
||||
let outcome = super::rmcp_dispatch::handle_prompts_command(
|
||||
&state,
|
||||
ServiceContext {
|
||||
workspace_slug: &session.workspace_slug,
|
||||
@@ -569,7 +572,10 @@ pub(super) async fn handle_legacy_request(
|
||||
StatusCode::OK,
|
||||
jsonrpc_result(
|
||||
request_id(message),
|
||||
prompt_get_result(description, messages),
|
||||
match prompt_get_result(description, messages) {
|
||||
Ok(result) => result,
|
||||
Err(error) => return internal_jsonrpc_error(message, error),
|
||||
},
|
||||
),
|
||||
response_mode,
|
||||
None,
|
||||
|
||||
@@ -239,24 +239,88 @@ fn preserve_resource_fields(raw: &[Value], serialized: &mut Value, sdk_fields: &
|
||||
}
|
||||
}
|
||||
|
||||
/// The era-neutral `prompts/list` result shape (Story 3.14). Same pagination wire keys as
|
||||
/// `resources/list`; `nextCursor` is absent on the last page.
|
||||
pub(super) fn prompts_list_result(prompts: Vec<Value>, next_cursor: Option<String>) -> Value {
|
||||
let mut result = json!({ "prompts": prompts });
|
||||
if let Some(cursor) = next_cursor {
|
||||
result["nextCursor"] = Value::String(cursor);
|
||||
/// SDK pagination with lossless Crank argument schemas/defaults and optional nulls.
|
||||
pub(super) fn prompts_list_result(
|
||||
prompts: Vec<Value>,
|
||||
next_cursor: Option<String>,
|
||||
) -> Result<Value, serde_json::Error> {
|
||||
let result = rmcp::model::ListPromptsResult {
|
||||
prompts: prompts
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(serde_json::from_value)
|
||||
.collect::<Result<Vec<rmcp::model::Prompt>, _>>()?,
|
||||
next_cursor,
|
||||
result_type: None,
|
||||
ttl_ms: None,
|
||||
cache_scope: None,
|
||||
meta: None,
|
||||
};
|
||||
let mut result = serde_json::to_value(result)?;
|
||||
preserve_resource_fields(
|
||||
&prompts,
|
||||
&mut result["prompts"],
|
||||
&["name", "title", "description", "arguments", "_meta"],
|
||||
);
|
||||
for (raw, serialized) in prompts
|
||||
.iter()
|
||||
.zip(result["prompts"].as_array_mut().expect("SDK prompts"))
|
||||
{
|
||||
if let Some(arguments) = raw["arguments"].as_array() {
|
||||
preserve_resource_fields(
|
||||
arguments,
|
||||
&mut serialized["arguments"],
|
||||
&["name", "title", "description", "required"],
|
||||
);
|
||||
}
|
||||
}
|
||||
result
|
||||
#[cfg(test)]
|
||||
super::dispatch_observer::sdk_prompts_list_result_serialized();
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
/// The era-neutral `prompts/get` result shape: the rendered `messages[]` and the description of the
|
||||
/// exact bound Published Prompt Version it came from.
|
||||
pub(super) fn prompt_get_result(description: Option<String>, messages: Vec<Value>) -> Value {
|
||||
let mut result = json!({ "messages": messages });
|
||||
if let Some(description) = description {
|
||||
result["description"] = Value::String(description);
|
||||
/// Preserve Crank's system role, which the pinned SDK's user/assistant Role cannot express.
|
||||
pub(super) fn prompt_get_result(
|
||||
description: Option<String>,
|
||||
messages: Vec<Value>,
|
||||
) -> Result<Value, serde_json::Error> {
|
||||
let sdk_messages = messages
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(|mut message| {
|
||||
if message["role"] == "system" {
|
||||
message["role"] = json!("user");
|
||||
}
|
||||
serde_json::from_value::<rmcp::model::PromptMessage>(message)
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
let mut result = rmcp::model::GetPromptResult::new(sdk_messages);
|
||||
result.description = description;
|
||||
// Era-specific resultType/cache projection remains at the existing dispatch boundary.
|
||||
result.result_type = None;
|
||||
let mut result = serde_json::to_value(result)?;
|
||||
preserve_resource_fields(&messages, &mut result["messages"], &["role", "content"]);
|
||||
for (raw, serialized) in messages
|
||||
.iter()
|
||||
.zip(result["messages"].as_array_mut().expect("SDK messages"))
|
||||
{
|
||||
if raw["role"] == "system" {
|
||||
serialized["role"] = raw["role"].clone();
|
||||
}
|
||||
// Content extensions/optional nulls are opaque to the pinned SDK.
|
||||
let content = serialized["content"].as_object_mut().expect("SDK content");
|
||||
for (key, value) in raw["content"].as_object().expect("validated content") {
|
||||
if !content.contains_key(key)
|
||||
|| value.is_null()
|
||||
|| matches!(key.as_str(), "annotations" | "resource")
|
||||
{
|
||||
content.insert(key.clone(), value.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
result
|
||||
#[cfg(test)]
|
||||
super::dispatch_observer::sdk_prompts_get_result_serialized();
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
/// The era-neutral `completion/complete` result shape (Story 3.17): the bounded `values[]`, the
|
||||
@@ -425,6 +489,44 @@ mod sdk_result_tests {
|
||||
use super::*;
|
||||
use crate::jsonrpc::{LEGACY_PROTOCOL_VERSION, MODERN_PROTOCOL_VERSION};
|
||||
|
||||
#[test]
|
||||
fn prompts_sdk_projection_preserves_typed_extensions_and_system_content() {
|
||||
let prompt = json!({"name":"p", "description":null, "icons":null,
|
||||
"x-prompt":{}, "arguments":[{"name":"count", "description":null,
|
||||
"required":false, "schema":{"type":"integer"}, "default":7}]});
|
||||
for cursor in [None, Some(String::new()), Some("opaque".to_owned())] {
|
||||
let result = prompts_list_result(vec![prompt.clone()], cursor.clone()).unwrap();
|
||||
assert_eq!(result["prompts"], json!([prompt]));
|
||||
assert_eq!(result.get("nextCursor"), cursor.map(Value::String).as_ref());
|
||||
assert!(result.get("resultType").is_none());
|
||||
}
|
||||
let messages = vec![
|
||||
json!({"role":"system", "x-message":null,
|
||||
"content":{"type":"text", "text":"\0é\n", "annotations":null, "x-content":[]}}),
|
||||
json!({"role":"assistant", "content":{"type":"text", "text":""}}),
|
||||
];
|
||||
assert_eq!(
|
||||
prompt_get_result(None, messages.clone()).unwrap(),
|
||||
json!({"messages":messages})
|
||||
);
|
||||
assert_eq!(
|
||||
prompts_list_result(vec![], None).unwrap(),
|
||||
json!({"prompts":[]})
|
||||
);
|
||||
assert_eq!(
|
||||
prompt_get_result(Some(String::new()), vec![]).unwrap(),
|
||||
json!({"description":"", "messages":[]})
|
||||
);
|
||||
assert!(prompts_list_result(vec![json!({"name":42})], None).is_err());
|
||||
assert!(
|
||||
prompt_get_result(
|
||||
None,
|
||||
vec![json!({"role":"invalid", "content":{"type":"text", "text":"secret"}})]
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resources_sdk_projection_is_lossless_for_templates_contents_and_catalog() {
|
||||
for version in [LEGACY_PROTOCOL_VERSION, MODERN_PROTOCOL_VERSION] {
|
||||
|
||||
@@ -66,6 +66,35 @@ pub(super) async fn handle_tools_command(
|
||||
crate::protocol::handle_tools_command(state, context, command, lifecycle).await
|
||||
}
|
||||
|
||||
pub(super) async fn handle_prompts_command(
|
||||
state: &Arc<AppState>,
|
||||
context: ServiceContext<'_>,
|
||||
revision: &str,
|
||||
command: crate::protocol::PromptsCommand,
|
||||
) -> crate::protocol::PromptsOutcome {
|
||||
use crate::protocol::{PromptGetCommand, PromptsCommand, PromptsListCommand};
|
||||
let command = match command {
|
||||
PromptsCommand::List(list) => {
|
||||
let params = PaginatedRequestParams::default().with_cursor(list.cursor);
|
||||
PromptsCommand::List(PromptsListCommand {
|
||||
cursor: params.cursor,
|
||||
limit: list.limit,
|
||||
})
|
||||
}
|
||||
PromptsCommand::Get(get) => {
|
||||
let mut params = rmcp::model::GetPromptRequestParams::new(get.name);
|
||||
params.arguments = get.arguments;
|
||||
PromptsCommand::Get(PromptGetCommand {
|
||||
name: params.name,
|
||||
arguments: params.arguments,
|
||||
})
|
||||
}
|
||||
};
|
||||
#[cfg(test)]
|
||||
super::dispatch_observer::sdk_prompts_dispatch_enter();
|
||||
crate::protocol::handle_prompts_command(state, context, revision, command).await
|
||||
}
|
||||
|
||||
pub(super) async fn handle_resources_command(
|
||||
state: &Arc<AppState>,
|
||||
context: ServiceContext<'_>,
|
||||
|
||||
@@ -0,0 +1,436 @@
|
||||
//! #107 Prompts: existing wire GREEN and an independent SDK typed-path RED oracle.
|
||||
use super::{CounterSet, observe, support::*};
|
||||
use axum::{body::Body, response::Response};
|
||||
use futures_util::{StreamExt, stream};
|
||||
use serde_json::{Value, json};
|
||||
use std::{sync::Arc, time::Duration};
|
||||
#[path = "rmcp_prompts_test_support.rs"]
|
||||
mod fixtures;
|
||||
use fixtures::Endpoint;
|
||||
|
||||
fn observe_body(response: Response, counters: Arc<CounterSet>) -> Response {
|
||||
let (parts, body) = response.into_parts();
|
||||
let body = stream::unfold(
|
||||
(body.into_data_stream(), counters),
|
||||
|(mut body, counters)| async move {
|
||||
observe(counters.clone(), body.next())
|
||||
.await
|
||||
.map(|chunk| (chunk, (body, counters)))
|
||||
},
|
||||
);
|
||||
Response::from_parts(parts, Body::from_stream(body))
|
||||
}
|
||||
fn counts(c: &CounterSet) -> [usize; 3] {
|
||||
[
|
||||
c.sdk_prompts_dispatch(),
|
||||
c.sdk_prompts_list_result(),
|
||||
c.sdk_prompts_get_result(),
|
||||
]
|
||||
}
|
||||
fn request(revision: &str, method: &str, mut params: Value) -> Value {
|
||||
if revision == MODERN_REVISION {
|
||||
params["_meta"] = modern_meta();
|
||||
}
|
||||
json!({"jsonrpc":"2.0","id":9007199254740993_u64,"method":method,"params":params})
|
||||
}
|
||||
async fn wire(response: reqwest::Response, id: &Value, sse: bool) -> Value {
|
||||
assert_eq!(response.status(), 200);
|
||||
assert_eq!(response.headers()["x-request-id"], "sdk-prompts-wire");
|
||||
assert_eq!(
|
||||
response.headers()["x-trace-id"],
|
||||
"11111111111111111111111111111111"
|
||||
);
|
||||
let content_type = response.headers()["content-type"]
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.to_owned();
|
||||
let text = tokio::time::timeout(Duration::from_secs(5), response.text())
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let body: Value = if sse {
|
||||
assert!(
|
||||
content_type.starts_with("text/event-stream"),
|
||||
"{content_type}: {text}"
|
||||
);
|
||||
let frames: Vec<Value> = text
|
||||
.lines()
|
||||
.filter_map(|line| {
|
||||
line.strip_prefix("data:")
|
||||
.map(|s| serde_json::from_str(s.trim()).unwrap())
|
||||
})
|
||||
.collect();
|
||||
let terminal: Vec<_> = frames.iter().filter(|f| f.get("id") == Some(id)).collect();
|
||||
assert_eq!(terminal.len(), 1, "{frames:?}");
|
||||
assert_eq!(frames.last(), Some(terminal[0]), "terminal must be last");
|
||||
terminal[0].clone()
|
||||
} else {
|
||||
assert!(
|
||||
content_type.starts_with("application/json"),
|
||||
"{content_type}: {text}"
|
||||
);
|
||||
serde_json::from_str(&text).unwrap()
|
||||
};
|
||||
assert_eq!(body["jsonrpc"], "2.0");
|
||||
assert_eq!(&body["id"], id);
|
||||
body
|
||||
}
|
||||
fn era(result: &Value, revision: &str, method: &str) {
|
||||
if revision == MODERN_REVISION {
|
||||
assert_eq!(result["resultType"], "complete", "{result}");
|
||||
if method == "prompts/list" {
|
||||
assert_eq!(result["ttlMs"], 0);
|
||||
assert_eq!(result["cacheScope"], "private");
|
||||
} else {
|
||||
assert!(result.get("ttlMs").is_none(), "{result}");
|
||||
assert!(result.get("cacheScope").is_none(), "{result}");
|
||||
}
|
||||
} else {
|
||||
for key in ["resultType", "ttlMs", "cacheScope"] {
|
||||
assert!(result.get(key).is_none(), "{result}");
|
||||
}
|
||||
}
|
||||
assert!(result.get("_meta").is_none(), "{result}");
|
||||
}
|
||||
async fn success(
|
||||
h: &Endpoint,
|
||||
revision: &str,
|
||||
session: Option<&str>,
|
||||
method: &str,
|
||||
params: Value,
|
||||
sse: bool,
|
||||
) -> (Value, [usize; 3]) {
|
||||
let req = request(revision, method, params);
|
||||
let before = counts(&h.counters);
|
||||
let body = wire(h.post(revision, session, &req, sse).await, &req["id"], sse).await;
|
||||
assert!(body.get("error").is_none(), "{body}");
|
||||
era(&body["result"], revision, method);
|
||||
let after = counts(&h.counters);
|
||||
(
|
||||
body["result"].clone(),
|
||||
std::array::from_fn(|i| after[i] - before[i]),
|
||||
)
|
||||
}
|
||||
async fn control(revision: &str) -> Vec<([usize; 3], [usize; 3])> {
|
||||
let h = Endpoint::started().await;
|
||||
let session = h.session(revision).await;
|
||||
let session = session.as_deref();
|
||||
let mut deltas = Vec::new();
|
||||
let mut first_cursor = None;
|
||||
// Both revisions' JSON contract, plus modern terminal SSE through the same normal app.
|
||||
let modes: &[bool] = if revision == MODERN_REVISION {
|
||||
&[false, true]
|
||||
} else {
|
||||
&[false]
|
||||
};
|
||||
for &sse in modes {
|
||||
let mut cursor = None;
|
||||
for (page, name) in ["greeting", "archived-prompt"].iter().enumerate() {
|
||||
let mut params = json!({"limit":1});
|
||||
if let Some(ref cursor) = cursor {
|
||||
params["cursor"] = json!(cursor);
|
||||
}
|
||||
let (result, delta) = success(&h, revision, session, "prompts/list", params, sse).await;
|
||||
let prompts = result["prompts"].as_array().unwrap();
|
||||
assert_eq!(prompts.len(), 1, "{result}");
|
||||
assert_eq!(
|
||||
prompts[0],
|
||||
json!({
|
||||
"name":name, "description":format!("Published {name}"),
|
||||
"arguments":[
|
||||
{"name":"name","schema":{"type":"string"},"required":true},
|
||||
{"name":"count","schema":{"type":"integer"},"required":false,"default":2},
|
||||
{"name":"enabled","schema":{"type":"boolean"},"required":false,"default":true},
|
||||
{"name":"tone","schema":{"type":"string","enum":["warm","dry"]},"required":false,"default":"warm"}
|
||||
]
|
||||
})
|
||||
);
|
||||
cursor = result
|
||||
.get("nextCursor")
|
||||
.map(|v| v.as_str().unwrap().to_owned());
|
||||
assert_eq!(cursor.is_some(), page == 0, "{result}");
|
||||
if page == 0 {
|
||||
assert_ne!(cursor.as_deref(), Some("1"));
|
||||
first_cursor = cursor.clone();
|
||||
}
|
||||
deltas.push((delta, [1, 1, 0]));
|
||||
}
|
||||
for (name, args, text) in [
|
||||
(
|
||||
"greeting",
|
||||
json!({"name":"Ada"}),
|
||||
"Hello Ada count=2 enabled=true tone=warm",
|
||||
),
|
||||
(
|
||||
"greeting",
|
||||
json!({"name":"Ada","count":7,"enabled":false,"tone":"dry"}),
|
||||
"Hello Ada count=7 enabled=false tone=dry",
|
||||
),
|
||||
(
|
||||
"archived-prompt",
|
||||
json!({"name":"Ada"}),
|
||||
"Hello Ada count=2 enabled=true tone=warm",
|
||||
),
|
||||
] {
|
||||
let mut previous = None;
|
||||
for _ in 0..2 {
|
||||
let (result, delta) = success(
|
||||
&h,
|
||||
revision,
|
||||
session,
|
||||
"prompts/get",
|
||||
json!({"name":name,"arguments":args}),
|
||||
sse,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(result["description"], format!("Published {name}"));
|
||||
assert_eq!(
|
||||
result["messages"],
|
||||
json!([
|
||||
{"role":"system","content":{"type":"text","text":"Be brief."}},
|
||||
{"role":"user","content":{"type":"text","text":text}}
|
||||
])
|
||||
);
|
||||
if let Some(ref previous) = previous {
|
||||
assert_eq!(&result, previous);
|
||||
}
|
||||
previous = Some(result);
|
||||
deltas.push((delta, [1, 0, 1]));
|
||||
}
|
||||
}
|
||||
for (arguments, reason, argument) in [
|
||||
(json!({}), "missing_argument", "name"),
|
||||
(
|
||||
json!({"name":"Ada","extra":"x"}),
|
||||
"unknown_argument",
|
||||
"extra",
|
||||
),
|
||||
(json!({"name":5}), "argument_invalid", "name"),
|
||||
(
|
||||
json!({"name":"Ada","count":"7"}),
|
||||
"argument_invalid",
|
||||
"count",
|
||||
),
|
||||
(
|
||||
json!({"name":"Ada","enabled":"false"}),
|
||||
"argument_invalid",
|
||||
"enabled",
|
||||
),
|
||||
(
|
||||
json!({"name":"Ada","tone":"loud"}),
|
||||
"argument_invalid",
|
||||
"tone",
|
||||
),
|
||||
(
|
||||
json!({"name":"x".repeat(crank_core::prompt::MAX_TEXT_BYTES + 1)}),
|
||||
"argument_too_large",
|
||||
"name",
|
||||
),
|
||||
] {
|
||||
let req = request(
|
||||
revision,
|
||||
"prompts/get",
|
||||
json!({"name":"greeting","arguments":arguments}),
|
||||
);
|
||||
let body = wire(h.post(revision, session, &req, sse).await, &req["id"], sse).await;
|
||||
assert_eq!(body["error"]["code"], -32602, "{body}");
|
||||
assert_eq!(body["error"]["data"]["reason"], reason, "{body}");
|
||||
assert_eq!(body["error"]["data"]["argument"], argument);
|
||||
assert!(body.get("result").is_none(), "{body}");
|
||||
for leaked in [
|
||||
"Be brief.",
|
||||
"Hello ",
|
||||
"Changed ",
|
||||
"Published unbound-prompt",
|
||||
] {
|
||||
assert!(!body.to_string().contains(leaked), "{body}");
|
||||
}
|
||||
}
|
||||
let mut unavailable = None;
|
||||
for name in [
|
||||
"draft-prompt",
|
||||
"unbound-prompt",
|
||||
"other-agent-prompt",
|
||||
"never-existed",
|
||||
"prm_a",
|
||||
] {
|
||||
let req = request(revision, "prompts/get", json!({"name":name}));
|
||||
let body = wire(h.post(revision, session, &req, sse).await, &req["id"], sse).await;
|
||||
assert_eq!(body["error"]["code"], -32602, "{body}");
|
||||
assert_eq!(
|
||||
body["error"]["message"],
|
||||
"the requested prompt is not available"
|
||||
);
|
||||
assert!(body.get("result").is_none());
|
||||
if let Some(ref previous) = unavailable {
|
||||
assert_eq!(&body, previous);
|
||||
}
|
||||
unavailable = Some(body);
|
||||
}
|
||||
}
|
||||
for params in [json!({"cursor":"invalid"}), json!({"limit":"invalid"})] {
|
||||
let req = request(revision, "prompts/list", params);
|
||||
let body = wire(
|
||||
h.post(revision, session, &req, false).await,
|
||||
&req["id"],
|
||||
false,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(body["error"]["code"], -32602, "{body}");
|
||||
}
|
||||
let other = if revision == MODERN_REVISION {
|
||||
LEGACY_REVISION
|
||||
} else {
|
||||
MODERN_REVISION
|
||||
};
|
||||
let other_session = h.session(other).await;
|
||||
let req = request(
|
||||
other,
|
||||
"prompts/list",
|
||||
json!({"cursor":first_cursor.unwrap()}),
|
||||
);
|
||||
let body = wire(
|
||||
h.post(other, other_session.as_deref(), &req, false).await,
|
||||
&req["id"],
|
||||
false,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(
|
||||
body["error"]["code"], -32602,
|
||||
"cross-revision cursor: {body}"
|
||||
);
|
||||
// Archive keeps serving v1 above, but disallows new publications and bindings.
|
||||
use crank_core::ids::PromptId;
|
||||
use crank_registry::model::{
|
||||
AgentPromptBinding, PublishPromptRequest, SaveAgentCatalogConfigRequest,
|
||||
};
|
||||
let publication = h
|
||||
.registry
|
||||
.publish_prompt_draft(PublishPromptRequest {
|
||||
workspace_id: workspace_id(),
|
||||
prompt_id: PromptId::new("prm_b"),
|
||||
expected_updated_at: h.archived_at,
|
||||
published_at: time::OffsetDateTime::now_utc(),
|
||||
})
|
||||
.await;
|
||||
assert!(
|
||||
matches!(
|
||||
publication,
|
||||
Err(crank_registry::RegistryError::PromptNotDraft { .. })
|
||||
),
|
||||
"{publication:?}"
|
||||
);
|
||||
let binding = h
|
||||
.registry
|
||||
.save_agent_catalog_config_editable_with_prompts(
|
||||
SaveAgentCatalogConfigRequest {
|
||||
workspace_id: &workspace_id(),
|
||||
agent_id: &agent_id(),
|
||||
agent_version: 1,
|
||||
bindings: &[],
|
||||
tool_selection_policy: &crank_core::ToolSelectionPolicy::default(),
|
||||
resource_bindings: &[],
|
||||
expected_state: None,
|
||||
},
|
||||
&[AgentPromptBinding {
|
||||
prompt_id: PromptId::new("prm_b"),
|
||||
prompt_version: 1,
|
||||
}],
|
||||
)
|
||||
.await;
|
||||
assert!(
|
||||
matches!(
|
||||
binding,
|
||||
Err(crank_registry::RegistryError::PromptArchived { .. })
|
||||
),
|
||||
"{binding:?}"
|
||||
);
|
||||
h.registry
|
||||
.revoke_platform_api_key(
|
||||
&workspace_id(),
|
||||
&crank_core::PlatformApiKeyId::new("pk_dispatch_observer"),
|
||||
&time::OffsetDateTime::now_utc(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
for (method, params) in [
|
||||
("prompts/list", json!({})),
|
||||
(
|
||||
"prompts/get",
|
||||
json!({"name":"greeting","arguments":{"name":"Ada"}}),
|
||||
),
|
||||
] {
|
||||
assert_eq!(
|
||||
h.post(revision, session, &request(revision, method, params), false)
|
||||
.await
|
||||
.status(),
|
||||
401
|
||||
);
|
||||
}
|
||||
eprintln!(
|
||||
"existing GREEN Prompts wire {revision}: populated pagination, typed metadata/values, exact immutable rendering, archive, structured refusals/non-disclosure, correlation/ID/cache, revoked401; SDK actual/expected={deltas:?}"
|
||||
);
|
||||
deltas
|
||||
}
|
||||
#[tokio::test]
|
||||
async fn rmcp_prompts_wire_legacy() {
|
||||
control(LEGACY_REVISION).await;
|
||||
}
|
||||
#[tokio::test]
|
||||
async fn rmcp_prompts_wire_modern() {
|
||||
control(MODERN_REVISION).await;
|
||||
}
|
||||
#[tokio::test]
|
||||
async fn rmcp_prompts_sdk_legacy() {
|
||||
let deltas = control(LEGACY_REVISION).await;
|
||||
assert!(
|
||||
deltas.iter().all(|(a, e)| a == e),
|
||||
"SDK typed dispatch/result missing after successful HTTP: {deltas:?}"
|
||||
);
|
||||
}
|
||||
#[tokio::test]
|
||||
async fn rmcp_prompts_sdk_modern() {
|
||||
let deltas = control(MODERN_REVISION).await;
|
||||
assert!(
|
||||
deltas.iter().all(|(a, e)| a == e),
|
||||
"SDK typed dispatch/result missing after successful HTTP: {deltas:?}"
|
||||
);
|
||||
}
|
||||
#[tokio::test]
|
||||
async fn rmcp_prompts_observer_scope_control() {
|
||||
use super::{
|
||||
sdk_prompts_dispatch_enter, sdk_prompts_get_result_serialized,
|
||||
sdk_prompts_list_result_serialized,
|
||||
};
|
||||
let a = Arc::new(CounterSet::default());
|
||||
let b = Arc::new(CounterSet::default());
|
||||
sdk_prompts_dispatch_enter();
|
||||
assert_eq!(counts(&a), [0; 3]);
|
||||
let snapshot = a.snapshot();
|
||||
observe(a.clone(), async {
|
||||
sdk_prompts_dispatch_enter();
|
||||
sdk_prompts_list_result_serialized();
|
||||
sdk_prompts_get_result_serialized();
|
||||
})
|
||||
.await;
|
||||
observe(b.clone(), async {
|
||||
sdk_prompts_get_result_serialized();
|
||||
})
|
||||
.await;
|
||||
assert_eq!(counts(&a), [1; 3]);
|
||||
assert_eq!(counts(&b), [0, 0, 1]);
|
||||
assert_eq!(a.snapshot(), snapshot);
|
||||
let body = Body::from_stream(stream::once(async {
|
||||
sdk_prompts_list_result_serialized();
|
||||
Ok::<_, std::convert::Infallible>("terminal")
|
||||
}));
|
||||
let response = observe_body(Response::new(body), b.clone());
|
||||
assert_eq!(
|
||||
&axum::body::to_bytes(response.into_body(), 100)
|
||||
.await
|
||||
.unwrap()[..],
|
||||
b"terminal"
|
||||
);
|
||||
assert_eq!(counts(&b), [0, 1, 1]);
|
||||
assert_eq!(counts(&a), [1; 3]);
|
||||
}
|
||||
@@ -0,0 +1,305 @@
|
||||
//! Published Prompts fixture using the existing observed HTTP app and disposable PostgreSQL.
|
||||
use super::*;
|
||||
use crank_core::prompt::{PromptDefinition, PromptSensitivity};
|
||||
use crank_core::{Agent, AgentStatus, AgentVersion, ToolSelectionPolicy, ids::PromptId};
|
||||
use crank_registry::model::{
|
||||
AgentPromptBinding, ArchivePromptRequest, CreatePromptDraftRequest, PublishPromptRequest,
|
||||
SaveAgentCatalogConfigRequest, UpdatePromptDraftRequest,
|
||||
};
|
||||
use crank_registry::{CreateAgentRequest, PublishAgentRequest};
|
||||
use crank_runtime::{
|
||||
InMemoryCoordinationStateStore, RequestRateLimitConfig, RequestRateLimiter, SecretCrypto,
|
||||
};
|
||||
|
||||
pub(super) fn definition(name: &str, content: &str) -> PromptDefinition {
|
||||
PromptDefinition::parse(&json!({
|
||||
"name":name, "description":format!("Published {name}"),
|
||||
"arguments":[
|
||||
{"name":"name","schema":{"type":"string"},"required":true},
|
||||
{"name":"count","schema":{"type":"integer"},"required":false,"default":2},
|
||||
{"name":"enabled","schema":{"type":"boolean"},"required":false,"default":true},
|
||||
{"name":"tone","schema":{"type":"string","enum":["warm","dry"]},"required":false,"default":"warm"}
|
||||
],
|
||||
"messages":[{"role":"system","content":"Be brief."},{"role":"user","content":content}]
|
||||
})).unwrap()
|
||||
}
|
||||
|
||||
pub(super) struct Endpoint {
|
||||
pub registry: crank_registry::PostgresRegistry,
|
||||
pub counters: Arc<CounterSet>,
|
||||
pub key: String,
|
||||
pub url: String,
|
||||
pub archived_at: time::OffsetDateTime,
|
||||
server: tokio::task::JoinHandle<()>,
|
||||
}
|
||||
impl Drop for Endpoint {
|
||||
fn drop(&mut self) {
|
||||
self.server.abort();
|
||||
}
|
||||
}
|
||||
impl Endpoint {
|
||||
pub async fn started() -> Self {
|
||||
crank_test_support::postgres_schema_url_for_task("prompts_owner", "t_160a763a").await;
|
||||
let registry = test_registry().await;
|
||||
let mut archived_at = test_time();
|
||||
for (id, name, publish) in [
|
||||
("prm_a", "greeting", true),
|
||||
("prm_b", "archived-prompt", true),
|
||||
("prm_c", "unbound-prompt", true),
|
||||
("prm_d", "draft-prompt", false),
|
||||
("prm_e", "other-agent-prompt", true),
|
||||
] {
|
||||
let row = registry
|
||||
.create_prompt_draft(CreatePromptDraftRequest {
|
||||
workspace_id: workspace_id(),
|
||||
prompt_id: PromptId::new(id),
|
||||
sensitivity: PromptSensitivity::Internal,
|
||||
definition: definition(
|
||||
name,
|
||||
"Hello {{name}} count={{count}} enabled={{enabled}} tone={{tone}}",
|
||||
),
|
||||
created_at: time::OffsetDateTime::now_utc(),
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
if publish {
|
||||
let row = registry
|
||||
.publish_prompt_draft(PublishPromptRequest {
|
||||
workspace_id: workspace_id(),
|
||||
prompt_id: PromptId::new(id),
|
||||
expected_updated_at: row.updated_at,
|
||||
published_at: time::OffsetDateTime::now_utc(),
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
if id == "prm_b" {
|
||||
archived_at = row.updated_at;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (id, slug) in [
|
||||
(agent_id(), AGENT_SLUG),
|
||||
(
|
||||
crank_core::AgentId::new("agent_other_prompts"),
|
||||
"other-prompts",
|
||||
),
|
||||
] {
|
||||
registry
|
||||
.create_agent(CreateAgentRequest {
|
||||
agent: &Agent {
|
||||
id: id.clone(),
|
||||
workspace_id: workspace_id(),
|
||||
slug: slug.into(),
|
||||
display_name: "SDK Prompts".into(),
|
||||
description: String::new(),
|
||||
status: AgentStatus::Draft,
|
||||
current_draft_version: 1,
|
||||
latest_published_version: None,
|
||||
created_at: test_time(),
|
||||
updated_at: test_time(),
|
||||
published_at: None,
|
||||
},
|
||||
version: &AgentVersion {
|
||||
agent_id: id,
|
||||
version: 1,
|
||||
status: AgentStatus::Draft,
|
||||
instructions: json!({}),
|
||||
tool_selection_policy: ToolSelectionPolicy::default(),
|
||||
created_at: test_time(),
|
||||
},
|
||||
bindings: &[],
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
let other_agent = crank_core::AgentId::new("agent_other_prompts");
|
||||
registry
|
||||
.save_agent_catalog_config_editable_with_prompts(
|
||||
SaveAgentCatalogConfigRequest {
|
||||
workspace_id: &workspace_id(),
|
||||
agent_id: &other_agent,
|
||||
agent_version: 1,
|
||||
bindings: &[],
|
||||
tool_selection_policy: &ToolSelectionPolicy::default(),
|
||||
resource_bindings: &[],
|
||||
expected_state: None,
|
||||
},
|
||||
&[AgentPromptBinding {
|
||||
prompt_id: PromptId::new("prm_e"),
|
||||
prompt_version: 1,
|
||||
}],
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
registry
|
||||
.publish_agent(PublishAgentRequest {
|
||||
workspace_id: &workspace_id(),
|
||||
agent_id: &other_agent,
|
||||
version: 1,
|
||||
published_at: &test_time(),
|
||||
published_by: Some("alice"),
|
||||
expected_state: None,
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
registry
|
||||
.save_agent_catalog_config_editable_with_prompts(
|
||||
SaveAgentCatalogConfigRequest {
|
||||
workspace_id: &workspace_id(),
|
||||
agent_id: &agent_id(),
|
||||
agent_version: 1,
|
||||
bindings: &[],
|
||||
tool_selection_policy: &ToolSelectionPolicy::default(),
|
||||
resource_bindings: &[],
|
||||
expected_state: None,
|
||||
},
|
||||
&[
|
||||
AgentPromptBinding {
|
||||
prompt_id: PromptId::new("prm_a"),
|
||||
prompt_version: 1,
|
||||
},
|
||||
AgentPromptBinding {
|
||||
prompt_id: PromptId::new("prm_b"),
|
||||
prompt_version: 1,
|
||||
},
|
||||
],
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
registry
|
||||
.publish_agent(PublishAgentRequest {
|
||||
workspace_id: &workspace_id(),
|
||||
agent_id: &agent_id(),
|
||||
version: 1,
|
||||
published_at: &test_time(),
|
||||
published_by: Some("alice"),
|
||||
expected_state: None,
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let archived_at = registry
|
||||
.archive_prompt_draft(ArchivePromptRequest {
|
||||
workspace_id: workspace_id(),
|
||||
prompt_id: PromptId::new("prm_b"),
|
||||
expected_updated_at: archived_at,
|
||||
archived_at: time::OffsetDateTime::now_utc(),
|
||||
})
|
||||
.await
|
||||
.unwrap()
|
||||
.updated_at;
|
||||
// A mutable v2 draft must not change the bound v1 rendering or discovery metadata.
|
||||
let draft = registry
|
||||
.get_prompt_draft(&workspace_id(), &PromptId::new("prm_a"))
|
||||
.await
|
||||
.unwrap();
|
||||
registry
|
||||
.update_prompt_draft(UpdatePromptDraftRequest {
|
||||
workspace_id: workspace_id(),
|
||||
prompt_id: PromptId::new("prm_a"),
|
||||
sensitivity: PromptSensitivity::Internal,
|
||||
definition: definition("changed-draft", "Changed {{name}}"),
|
||||
expected_updated_at: draft.updated_at,
|
||||
updated_at: time::OffsetDateTime::now_utc(),
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let key = create_api_key(®istry).await;
|
||||
let counters = Arc::new(CounterSet::default());
|
||||
let app = crate::build_app(
|
||||
registry.clone(),
|
||||
Duration::ZERO,
|
||||
None,
|
||||
SecretCrypto::new("test-master-key-00000000000000000000000000000000").unwrap(),
|
||||
crank_runtime::community_with_outbound_policy(
|
||||
crank_runtime::OutboundHttpPolicy::allowing_hosts(["127.0.0.1"]),
|
||||
)
|
||||
.build(),
|
||||
RequestRateLimiter::new(RequestRateLimitConfig::new(10_000, 10_000).unwrap()),
|
||||
Arc::new(InMemoryCoordinationStateStore::default()),
|
||||
Arc::new(crate::session::InMemorySessionStore::default()),
|
||||
Arc::new(crate::auth::CommunityMachineCredentialVerifier),
|
||||
);
|
||||
let app = observe_requests(app, counters.clone(), None).layer(axum::middleware::from_fn({
|
||||
let counters = counters.clone();
|
||||
move |request: axum::extract::Request, next: axum::middleware::Next| {
|
||||
let counters = counters.clone();
|
||||
async move { observe_body(next.run(request).await, counters) }
|
||||
}
|
||||
}));
|
||||
let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();
|
||||
let url = format!(
|
||||
"http://{}/v1/{WORKSPACE_SLUG}/{AGENT_SLUG}",
|
||||
listener.local_addr().unwrap()
|
||||
);
|
||||
let server = tokio::spawn(async move {
|
||||
axum::serve(listener, app).await.unwrap();
|
||||
});
|
||||
Self {
|
||||
registry,
|
||||
counters,
|
||||
key,
|
||||
url,
|
||||
archived_at,
|
||||
server,
|
||||
}
|
||||
}
|
||||
pub async fn post(
|
||||
&self,
|
||||
revision: &str,
|
||||
session: Option<&str>,
|
||||
body: &Value,
|
||||
sse: bool,
|
||||
) -> reqwest::Response {
|
||||
let mut request = reqwest::Client::new()
|
||||
.post(&self.url)
|
||||
.bearer_auth(&self.key)
|
||||
.header(
|
||||
"Accept",
|
||||
if sse {
|
||||
"text/event-stream, application/json"
|
||||
} else {
|
||||
"application/json"
|
||||
},
|
||||
)
|
||||
.header("x-request-id", "sdk-prompts-wire")
|
||||
.header(
|
||||
"traceparent",
|
||||
"00-11111111111111111111111111111111-2222222222222222-01",
|
||||
)
|
||||
.header("MCP-Protocol-Version", revision);
|
||||
if let Some(session) = session {
|
||||
request = request.header("MCP-Session-Id", session);
|
||||
}
|
||||
if revision == MODERN_REVISION {
|
||||
request = request.header("Mcp-Method", body["method"].as_str().unwrap());
|
||||
if let Some(name) = body["params"]["name"].as_str() {
|
||||
request = request.header("Mcp-Name", name);
|
||||
}
|
||||
}
|
||||
request.json(body).send().await.unwrap()
|
||||
}
|
||||
pub async fn session(&self, revision: &str) -> Option<String> {
|
||||
if revision == MODERN_REVISION {
|
||||
return None;
|
||||
}
|
||||
let response = self
|
||||
.post(revision, None, &legacy_initialize(1), false)
|
||||
.await;
|
||||
assert_eq!(response.status(), 200);
|
||||
let session = response.headers()["MCP-Session-Id"]
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.to_owned();
|
||||
assert_eq!(
|
||||
json_body(response).await["result"]["protocolVersion"],
|
||||
revision
|
||||
);
|
||||
assert_eq!(
|
||||
self.post(revision, Some(&session), &initialized_notification(), false)
|
||||
.await
|
||||
.status(),
|
||||
202
|
||||
);
|
||||
Some(session)
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,8 @@
|
||||
|
||||
Следующий Resources-срез #107 подключает `resources/list`, `resources/read` и `resources/templates/list` обеих revisions к тому же `app/rmcp_dispatch.rs`: `PaginatedRequestParams`/`ReadResourceRequestParams` передают cursor/URI прежнему shared Resources service, а Crank `limit` сохраняется отдельно. `app/response.rs` сериализует rmcp `ListResourcesResult`/`Resource`, `ReadResourceResult`/`ResourceContents` и `ListResourceTemplatesResult`/`ResourceTemplate` с прежними revision-specific cache defaults. Минимальная lossless-проекция сохраняет Crank template `parameters`, extensions/optional null и непрозрачные annotations/icons. Штатные producers по-прежнему публикуют прежние поля; builder-регрессия не добавляет runtime-возможностей. Потребитель — действующий `build_app` HTTP JSON/SSE terminal. Реальные HTTP-тесты отдельно подтверждают SDK request/result seam и сохранение wire; существующая Resources-матрица проверяет заполненные templates, exact-version binding, text/JSON/blob, scope/revocation и cursors. Handwritten builders этих трёх результатов заменены; domain/storage/auth, envelopes, transport и lifecycle не меняются. Subscribe/unsubscribe/notifications остаются прежними и не объявляются перенесёнными; остальные handlers и полный #107 ещё не завершены.
|
||||
|
||||
Prompts-срез #107 подключает `prompts/list` и `prompts/get` обеих revisions к `app/rmcp_dispatch.rs`: реальные `PaginatedRequestParams`/`GetPromptRequestParams` передают cursor/name и JSON-значения аргументов прежнему shared Prompts service; Crank `limit` сохраняется отдельно. `app/response.rs` сериализует rmcp `ListPromptsResult`/`Prompt` и `GetPromptResult`/`PromptMessage`/`ContentBlock`, используемые штатным `build_app` HTTP JSON/SSE. Lossless-проекция сохраняет typed argument schemas/defaults, extensions/optional null и существующую роль `system`, которую pinned SDK Role не представляет; она восстанавливается после SDK serialization, не меняя опубликованные message boundaries. Прежний dispatch сохраняет revision-specific result/cache projections и ошибки. HTTP ATDD проверяет wire обеих revisions и реальный SDK request/result seam отдельно; affected Prompts/composition regression — exact binding, archive, typed rendering, pinned static/dynamic Resource content и fail-closed dependency errors. Handwritten list/get builders заменены; domain/storage/auth/envelopes/transport/lifecycle не меняются. Completion, notifications/subscriptions/progress/cancel/logging не объявляются перенесёнными. Полный #107 и feature qualification (UI/full/load/p95) этим срезом не завершены.
|
||||
|
||||
Проверяемый результат:
|
||||
|
||||
- Через SDK проходят действующие Tools, Resources, Prompts, completion, уведомления и подписки в применимых revisions, а также progress/cancel и существующая logging policy.
|
||||
|
||||
Reference in new issue
Block a user