refactor(core): Fix Kotlin language and api version to 2.1 in build config (#620)
## Fix Kotlin language and api version to 2.1 - Remove language constructs not supported in Kotlin 2.1 <!-- Provide a brief summary of your changes --> ## Motivation and Context To ensure binary compatibility ## How Has This Been Tested? Regression tests ## Breaking Changes <!-- Will users need to update their code or configurations? --> ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [x] Build update ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [ ] I have added appropriate error handling - [ ] I have added or updated documentation as needed ## Additional context <!-- Add any other context, implementation notes, or design decisions -->
This commit is contained in:
parent
cd91eed35d
commit
c77ebe0c00
4 changed files with 19 additions and 17 deletions
|
|
@ -5,6 +5,7 @@ import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
|
|||
import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmDefaultMode
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
|
|
@ -15,6 +16,8 @@ plugins {
|
|||
kotlin {
|
||||
|
||||
compilerOptions {
|
||||
languageVersion = KotlinVersion.KOTLIN_2_1
|
||||
apiVersion = KotlinVersion.KOTLIN_2_1
|
||||
freeCompilerArgs =
|
||||
listOf(
|
||||
"-Wextra",
|
||||
|
|
|
|||
|
|
@ -148,18 +148,17 @@ class StreamableHttpClientTransportTest {
|
|||
)
|
||||
|
||||
val transport = createTransport { request ->
|
||||
when (
|
||||
val msg = McpJson.decodeFromString<JSONRPCMessage>(
|
||||
(request.body as TextContent).text,
|
||||
)
|
||||
) {
|
||||
is JSONRPCRequest if msg.method == "initialize" -> respond(
|
||||
val msg = McpJson.decodeFromString<JSONRPCMessage>(
|
||||
(request.body as TextContent).text,
|
||||
)
|
||||
when {
|
||||
msg is JSONRPCRequest && msg.method == "initialize" -> respond(
|
||||
content = "",
|
||||
status = HttpStatusCode.OK,
|
||||
headers = headersOf("mcp-session-id", "test-session-id"),
|
||||
)
|
||||
|
||||
is JSONRPCNotification if msg.method == "test" -> {
|
||||
msg is JSONRPCNotification && msg.method == "test" -> {
|
||||
assertEquals("test-session-id", request.headers["mcp-session-id"])
|
||||
respond(
|
||||
content = "",
|
||||
|
|
@ -246,8 +245,8 @@ class StreamableHttpClientTransportTest {
|
|||
var sseStarted = false
|
||||
|
||||
val transport = createTransport { request ->
|
||||
when (request.method) {
|
||||
HttpMethod.Post if request.body.toString().contains("notifications/initialized") -> {
|
||||
when {
|
||||
request.method == HttpMethod.Post && request.body.toString().contains("notifications/initialized") -> {
|
||||
respond(
|
||||
content = "",
|
||||
status = HttpStatusCode.Accepted,
|
||||
|
|
@ -256,7 +255,7 @@ class StreamableHttpClientTransportTest {
|
|||
}
|
||||
|
||||
// Handle SSE connection
|
||||
HttpMethod.Get -> {
|
||||
request.method == HttpMethod.Get -> {
|
||||
sseStarted = true
|
||||
val sseContent = buildString {
|
||||
// Server sends various notifications
|
||||
|
|
@ -288,7 +287,7 @@ class StreamableHttpClientTransportTest {
|
|||
}
|
||||
|
||||
// Handle regular notifications
|
||||
HttpMethod.Post -> {
|
||||
request.method == HttpMethod.Post -> {
|
||||
respond(
|
||||
content = "",
|
||||
status = HttpStatusCode.Accepted,
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ import kotlin.jvm.JvmInline
|
|||
public value class RequestMeta(public val json: JsonObject) {
|
||||
public val progressToken: ProgressToken?
|
||||
get() = json["progressToken"]?.let { element ->
|
||||
when (element) {
|
||||
is JsonPrimitive if (element.isString) -> ProgressToken(element.content)
|
||||
is JsonPrimitive if (element.longOrNull != null) -> ProgressToken(element.long)
|
||||
when {
|
||||
element is JsonPrimitive && element.isString -> ProgressToken(element.content)
|
||||
element is JsonPrimitive && element.longOrNull != null -> ProgressToken(element.long)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -414,9 +414,9 @@ internal object JSONRPCMessagePolymorphicSerializer :
|
|||
* Supports both string and number IDs.
|
||||
*/
|
||||
internal object RequestIdPolymorphicSerializer : JsonContentPolymorphicSerializer<RequestId>(RequestId::class) {
|
||||
override fun selectDeserializer(element: JsonElement): DeserializationStrategy<RequestId> = when (element) {
|
||||
is JsonPrimitive if (element.isString) -> RequestId.StringId.serializer()
|
||||
is JsonPrimitive if (element.longOrNull != null) -> RequestId.NumberId.serializer()
|
||||
override fun selectDeserializer(element: JsonElement): DeserializationStrategy<RequestId> = when {
|
||||
element is JsonPrimitive && element.isString -> RequestId.StringId.serializer()
|
||||
element is JsonPrimitive && element.longOrNull != null -> RequestId.NumberId.serializer()
|
||||
else -> throw SerializationException("Invalid RequestId type: $element")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue