feat: add message field to ProgressNotification according to 2025-03-26 spec (#69)
* feat: add message field to ProgressNotification to provide descriptive status updates * chore: commit api dump --------- Co-authored-by: Leonid Stashevsky <e5l@users.noreply.github.com>
This commit is contained in:
parent
129731c34c
commit
b60e12af8f
3 changed files with 23 additions and 7 deletions
|
|
@ -1485,8 +1485,9 @@ public final class io/modelcontextprotocol/kotlin/sdk/PingRequest$Companion {
|
|||
|
||||
public class io/modelcontextprotocol/kotlin/sdk/Progress : io/modelcontextprotocol/kotlin/sdk/ProgressBase {
|
||||
public static final field Companion Lio/modelcontextprotocol/kotlin/sdk/Progress$Companion;
|
||||
public synthetic fun <init> (IILjava/lang/Double;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
|
||||
public fun <init> (ILjava/lang/Double;)V
|
||||
public synthetic fun <init> (IILjava/lang/Double;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
|
||||
public fun <init> (ILjava/lang/Double;Ljava/lang/String;)V
|
||||
public fun getMessage ()Ljava/lang/String;
|
||||
public fun getProgress ()I
|
||||
public fun getTotal ()Ljava/lang/Double;
|
||||
public static final synthetic fun write$Self (Lio/modelcontextprotocol/kotlin/sdk/Progress;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
|
|
@ -1509,6 +1510,7 @@ public final class io/modelcontextprotocol/kotlin/sdk/Progress$Companion {
|
|||
|
||||
public abstract interface class io/modelcontextprotocol/kotlin/sdk/ProgressBase {
|
||||
public static final field Companion Lio/modelcontextprotocol/kotlin/sdk/ProgressBase$Companion;
|
||||
public abstract fun getMessage ()Ljava/lang/String;
|
||||
public abstract fun getProgress ()I
|
||||
public abstract fun getTotal ()Ljava/lang/Double;
|
||||
}
|
||||
|
|
@ -1519,15 +1521,17 @@ public final class io/modelcontextprotocol/kotlin/sdk/ProgressBase$Companion {
|
|||
|
||||
public final class io/modelcontextprotocol/kotlin/sdk/ProgressNotification : io/modelcontextprotocol/kotlin/sdk/ClientNotification, io/modelcontextprotocol/kotlin/sdk/ProgressBase, io/modelcontextprotocol/kotlin/sdk/ServerNotification {
|
||||
public static final field Companion Lio/modelcontextprotocol/kotlin/sdk/ProgressNotification$Companion;
|
||||
public fun <init> (ILio/modelcontextprotocol/kotlin/sdk/RequestId;Lkotlinx/serialization/json/JsonObject;Ljava/lang/Double;)V
|
||||
public synthetic fun <init> (ILio/modelcontextprotocol/kotlin/sdk/RequestId;Lkotlinx/serialization/json/JsonObject;Ljava/lang/Double;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun <init> (ILio/modelcontextprotocol/kotlin/sdk/RequestId;Lkotlinx/serialization/json/JsonObject;Ljava/lang/Double;Ljava/lang/String;)V
|
||||
public synthetic fun <init> (ILio/modelcontextprotocol/kotlin/sdk/RequestId;Lkotlinx/serialization/json/JsonObject;Ljava/lang/Double;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun component1 ()I
|
||||
public final fun component2 ()Lio/modelcontextprotocol/kotlin/sdk/RequestId;
|
||||
public final fun component3 ()Lkotlinx/serialization/json/JsonObject;
|
||||
public final fun component4 ()Ljava/lang/Double;
|
||||
public final fun copy (ILio/modelcontextprotocol/kotlin/sdk/RequestId;Lkotlinx/serialization/json/JsonObject;Ljava/lang/Double;)Lio/modelcontextprotocol/kotlin/sdk/ProgressNotification;
|
||||
public static synthetic fun copy$default (Lio/modelcontextprotocol/kotlin/sdk/ProgressNotification;ILio/modelcontextprotocol/kotlin/sdk/RequestId;Lkotlinx/serialization/json/JsonObject;Ljava/lang/Double;ILjava/lang/Object;)Lio/modelcontextprotocol/kotlin/sdk/ProgressNotification;
|
||||
public final fun component5 ()Ljava/lang/String;
|
||||
public final fun copy (ILio/modelcontextprotocol/kotlin/sdk/RequestId;Lkotlinx/serialization/json/JsonObject;Ljava/lang/Double;Ljava/lang/String;)Lio/modelcontextprotocol/kotlin/sdk/ProgressNotification;
|
||||
public static synthetic fun copy$default (Lio/modelcontextprotocol/kotlin/sdk/ProgressNotification;ILio/modelcontextprotocol/kotlin/sdk/RequestId;Lkotlinx/serialization/json/JsonObject;Ljava/lang/Double;Ljava/lang/String;ILjava/lang/Object;)Lio/modelcontextprotocol/kotlin/sdk/ProgressNotification;
|
||||
public fun equals (Ljava/lang/Object;)Z
|
||||
public fun getMessage ()Ljava/lang/String;
|
||||
public fun getMethod ()Lio/modelcontextprotocol/kotlin/sdk/Method;
|
||||
public fun getProgress ()I
|
||||
public final fun getProgressToken ()Lio/modelcontextprotocol/kotlin/sdk/RequestId;
|
||||
|
|
|
|||
|
|
@ -260,6 +260,7 @@ public abstract class Protocol(
|
|||
LOGGER.trace { "Received progress notification: token=${notification.progressToken}, progress=${notification.progress}/${notification.total}" }
|
||||
val progress = notification.progress
|
||||
val total = notification.total
|
||||
val message = notification.message
|
||||
val progressToken = notification.progressToken
|
||||
|
||||
val handler = progressHandlers[progressToken]
|
||||
|
|
@ -272,7 +273,7 @@ public abstract class Protocol(
|
|||
return
|
||||
}
|
||||
|
||||
handler.invoke(Progress(progress, total))
|
||||
handler.invoke(Progress(progress, total, message))
|
||||
}
|
||||
|
||||
private fun onResponse(response: JSONRPCResponse?, error: JSONRPCError?) {
|
||||
|
|
|
|||
|
|
@ -512,6 +512,11 @@ public sealed interface ProgressBase {
|
|||
* Total number of items to a process (or total progress required), if known.
|
||||
*/
|
||||
public val total: Double?
|
||||
|
||||
/**
|
||||
* An optional message describing the current progress.
|
||||
*/
|
||||
public val message: String?
|
||||
}
|
||||
|
||||
/* Progress notifications */
|
||||
|
|
@ -532,6 +537,11 @@ public open class Progress(
|
|||
* Total number of items to a process (or total progress required), if known.
|
||||
*/
|
||||
override val total: Double?,
|
||||
|
||||
/**
|
||||
* An optional message describing the current progress.
|
||||
*/
|
||||
override val message: String?,
|
||||
) : ProgressBase
|
||||
|
||||
/**
|
||||
|
|
@ -548,6 +558,7 @@ public data class ProgressNotification(
|
|||
public val progressToken: ProgressToken,
|
||||
@Suppress("PropertyName") val _meta: JsonObject = EmptyJsonObject,
|
||||
override val total: Double?,
|
||||
override val message: String?,
|
||||
) : ClientNotification, ServerNotification, ProgressBase {
|
||||
override val method: Method = Method.Defined.NotificationsProgress
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue