|
1 |
| -import { z } from "zod"; |
| 1 | +import { z, ZodTypeAny } from "zod"; |
2 | 2 |
|
3 | 3 | export const LATEST_PROTOCOL_VERSION = "2024-11-05";
|
4 | 4 | export const SUPPORTED_PROTOCOL_VERSIONS = [
|
@@ -1123,114 +1123,113 @@ type Flatten<T> = T extends Primitive
|
1123 | 1123 | ? { [K in keyof T]: Flatten<T[K]> }
|
1124 | 1124 | : T;
|
1125 | 1125 |
|
1126 |
| -// eslint-disable-next-line @typescript-eslint/no-explicit-any |
1127 |
| -type Infer<Parse extends (...args: any) => any> = Flatten<ReturnType<Parse>>; |
| 1126 | +type Infer<Schema extends ZodTypeAny> = Flatten<z.infer<Schema>>; |
1128 | 1127 |
|
1129 | 1128 | /* JSON-RPC types */
|
1130 |
| -export type ProgressToken = Infer<typeof ProgressTokenSchema.parse>; |
1131 |
| -export type Cursor = Infer<typeof CursorSchema.parse>; |
1132 |
| -export type Request = Infer<typeof RequestSchema.parse>; |
1133 |
| -export type Notification = Infer<typeof NotificationSchema.parse>; |
1134 |
| -export type Result = Infer<typeof ResultSchema.parse>; |
1135 |
| -export type RequestId = Infer<typeof RequestIdSchema.parse>; |
1136 |
| -export type JSONRPCRequest = Infer<typeof JSONRPCRequestSchema.parse>; |
1137 |
| -export type JSONRPCNotification = Infer<typeof JSONRPCNotificationSchema.parse>; |
1138 |
| -export type JSONRPCResponse = Infer<typeof JSONRPCResponseSchema.parse>; |
1139 |
| -export type JSONRPCError = Infer<typeof JSONRPCErrorSchema.parse>; |
1140 |
| -export type JSONRPCMessage = Infer<typeof JSONRPCMessageSchema.parse>; |
| 1129 | +export type ProgressToken = Infer<typeof ProgressTokenSchema>; |
| 1130 | +export type Cursor = Infer<typeof CursorSchema>; |
| 1131 | +export type Request = Infer<typeof RequestSchema>; |
| 1132 | +export type Notification = Infer<typeof NotificationSchema>; |
| 1133 | +export type Result = Infer<typeof ResultSchema>; |
| 1134 | +export type RequestId = Infer<typeof RequestIdSchema>; |
| 1135 | +export type JSONRPCRequest = Infer<typeof JSONRPCRequestSchema>; |
| 1136 | +export type JSONRPCNotification = Infer<typeof JSONRPCNotificationSchema>; |
| 1137 | +export type JSONRPCResponse = Infer<typeof JSONRPCResponseSchema>; |
| 1138 | +export type JSONRPCError = Infer<typeof JSONRPCErrorSchema>; |
| 1139 | +export type JSONRPCMessage = Infer<typeof JSONRPCMessageSchema>; |
1141 | 1140 |
|
1142 | 1141 | /* Empty result */
|
1143 |
| -export type EmptyResult = Infer<typeof EmptyResultSchema.parse>; |
| 1142 | +export type EmptyResult = Infer<typeof EmptyResultSchema>; |
1144 | 1143 |
|
1145 | 1144 | /* Cancellation */
|
1146 |
| -export type CancelledNotification = Infer<typeof CancelledNotificationSchema.parse>; |
| 1145 | +export type CancelledNotification = Infer<typeof CancelledNotificationSchema>; |
1147 | 1146 |
|
1148 | 1147 | /* Initialization */
|
1149 |
| -export type Implementation = Infer<typeof ImplementationSchema.parse>; |
1150 |
| -export type ClientCapabilities = Infer<typeof ClientCapabilitiesSchema.parse>; |
1151 |
| -export type InitializeRequest = Infer<typeof InitializeRequestSchema.parse>; |
1152 |
| -export type ServerCapabilities = Infer<typeof ServerCapabilitiesSchema.parse>; |
1153 |
| -export type InitializeResult = Infer<typeof InitializeResultSchema.parse>; |
1154 |
| -export type InitializedNotification = Infer<typeof InitializedNotificationSchema.parse>; |
| 1148 | +export type Implementation = Infer<typeof ImplementationSchema>; |
| 1149 | +export type ClientCapabilities = Infer<typeof ClientCapabilitiesSchema>; |
| 1150 | +export type InitializeRequest = Infer<typeof InitializeRequestSchema>; |
| 1151 | +export type ServerCapabilities = Infer<typeof ServerCapabilitiesSchema>; |
| 1152 | +export type InitializeResult = Infer<typeof InitializeResultSchema>; |
| 1153 | +export type InitializedNotification = Infer<typeof InitializedNotificationSchema>; |
1155 | 1154 |
|
1156 | 1155 | /* Ping */
|
1157 |
| -export type PingRequest = Infer<typeof PingRequestSchema.parse>; |
| 1156 | +export type PingRequest = Infer<typeof PingRequestSchema>; |
1158 | 1157 |
|
1159 | 1158 | /* Progress notifications */
|
1160 |
| -export type Progress = Infer<typeof ProgressSchema.parse>; |
1161 |
| -export type ProgressNotification = Infer<typeof ProgressNotificationSchema.parse>; |
| 1159 | +export type Progress = Infer<typeof ProgressSchema>; |
| 1160 | +export type ProgressNotification = Infer<typeof ProgressNotificationSchema>; |
1162 | 1161 |
|
1163 | 1162 | /* Pagination */
|
1164 |
| -export type PaginatedRequest = Infer<typeof PaginatedRequestSchema.parse>; |
1165 |
| -export type PaginatedResult = Infer<typeof PaginatedResultSchema.parse>; |
| 1163 | +export type PaginatedRequest = Infer<typeof PaginatedRequestSchema>; |
| 1164 | +export type PaginatedResult = Infer<typeof PaginatedResultSchema>; |
1166 | 1165 |
|
1167 | 1166 | /* Resources */
|
1168 |
| -export type ResourceContents = Infer<typeof ResourceContentsSchema.parse>; |
1169 |
| -export type TextResourceContents = Infer<typeof TextResourceContentsSchema.parse>; |
1170 |
| -export type BlobResourceContents = Infer<typeof BlobResourceContentsSchema.parse>; |
1171 |
| -export type Resource = Infer<typeof ResourceSchema.parse>; |
1172 |
| -export type ResourceTemplate = Infer<typeof ResourceTemplateSchema.parse>; |
1173 |
| -export type ListResourcesRequest = Infer<typeof ListResourcesRequestSchema.parse>; |
1174 |
| -export type ListResourcesResult = Infer<typeof ListResourcesResultSchema.parse>; |
1175 |
| -export type ListResourceTemplatesRequest = Infer<typeof ListResourceTemplatesRequestSchema.parse>; |
1176 |
| -export type ListResourceTemplatesResult = Infer<typeof ListResourceTemplatesResultSchema.parse>; |
1177 |
| -export type ReadResourceRequest = Infer<typeof ReadResourceRequestSchema.parse>; |
1178 |
| -export type ReadResourceResult = Infer<typeof ReadResourceResultSchema.parse>; |
1179 |
| -export type ResourceListChangedNotification = Infer<typeof ResourceListChangedNotificationSchema.parse>; |
1180 |
| -export type SubscribeRequest = Infer<typeof SubscribeRequestSchema.parse>; |
1181 |
| -export type UnsubscribeRequest = Infer<typeof UnsubscribeRequestSchema.parse>; |
1182 |
| -export type ResourceUpdatedNotification = Infer<typeof ResourceUpdatedNotificationSchema.parse>; |
| 1167 | +export type ResourceContents = Flatten<z.infer<typeof ResourceContentsSchema>>; |
| 1168 | +export type TextResourceContents = Infer<typeof TextResourceContentsSchema>; |
| 1169 | +export type BlobResourceContents = Infer<typeof BlobResourceContentsSchema>; |
| 1170 | +export type Resource = Infer<typeof ResourceSchema>; |
| 1171 | +export type ResourceTemplate = Infer<typeof ResourceTemplateSchema>; |
| 1172 | +export type ListResourcesRequest = Infer<typeof ListResourcesRequestSchema>; |
| 1173 | +export type ListResourcesResult = Infer<typeof ListResourcesResultSchema>; |
| 1174 | +export type ListResourceTemplatesRequest = Infer<typeof ListResourceTemplatesRequestSchema>; |
| 1175 | +export type ListResourceTemplatesResult = Infer<typeof ListResourceTemplatesResultSchema>; |
| 1176 | +export type ReadResourceRequest = Infer<typeof ReadResourceRequestSchema>; |
| 1177 | +export type ReadResourceResult = Infer<typeof ReadResourceResultSchema>; |
| 1178 | +export type ResourceListChangedNotification = Infer<typeof ResourceListChangedNotificationSchema>; |
| 1179 | +export type SubscribeRequest = Infer<typeof SubscribeRequestSchema>; |
| 1180 | +export type UnsubscribeRequest = Infer<typeof UnsubscribeRequestSchema>; |
| 1181 | +export type ResourceUpdatedNotification = Infer<typeof ResourceUpdatedNotificationSchema>; |
1183 | 1182 |
|
1184 | 1183 | /* Prompts */
|
1185 |
| -export type PromptArgument = Infer<typeof PromptArgumentSchema.parse>; |
1186 |
| -export type Prompt = Infer<typeof PromptSchema.parse>; |
1187 |
| -export type ListPromptsRequest = Infer<typeof ListPromptsRequestSchema.parse>; |
1188 |
| -export type ListPromptsResult = Infer<typeof ListPromptsResultSchema.parse>; |
1189 |
| -export type GetPromptRequest = Infer<typeof GetPromptRequestSchema.parse>; |
1190 |
| -export type TextContent = Infer<typeof TextContentSchema.parse>; |
1191 |
| -export type ImageContent = Infer<typeof ImageContentSchema.parse>; |
1192 |
| -export type EmbeddedResource = Infer<typeof EmbeddedResourceSchema.parse>; |
1193 |
| -export type PromptMessage = Infer<typeof PromptMessageSchema.parse>; |
1194 |
| -export type GetPromptResult = Infer<typeof GetPromptResultSchema.parse>; |
1195 |
| -export type PromptListChangedNotification = Infer<typeof PromptListChangedNotificationSchema.parse>; |
| 1184 | +export type PromptArgument = Infer<typeof PromptArgumentSchema>; |
| 1185 | +export type Prompt = Infer<typeof PromptSchema>; |
| 1186 | +export type ListPromptsRequest = Infer<typeof ListPromptsRequestSchema>; |
| 1187 | +export type ListPromptsResult = Infer<typeof ListPromptsResultSchema>; |
| 1188 | +export type GetPromptRequest = Infer<typeof GetPromptRequestSchema>; |
| 1189 | +export type TextContent = Infer<typeof TextContentSchema>; |
| 1190 | +export type ImageContent = Infer<typeof ImageContentSchema>; |
| 1191 | +export type EmbeddedResource = Infer<typeof EmbeddedResourceSchema>; |
| 1192 | +export type PromptMessage = Infer<typeof PromptMessageSchema>; |
| 1193 | +export type GetPromptResult = Infer<typeof GetPromptResultSchema>; |
| 1194 | +export type PromptListChangedNotification = Infer<typeof PromptListChangedNotificationSchema>; |
1196 | 1195 |
|
1197 | 1196 | /* Tools */
|
1198 |
| -export type Tool = Infer<typeof ToolSchema.parse>; |
1199 |
| -export type ListToolsRequest = Infer<typeof ListToolsRequestSchema.parse>; |
1200 |
| -export type ListToolsResult = Infer<typeof ListToolsResultSchema.parse>; |
1201 |
| -export type CallToolResult = Infer<typeof CallToolResultSchema.parse>; |
1202 |
| -export type CompatibilityCallToolResult = Infer<typeof CompatibilityCallToolResultSchema.parse>; |
1203 |
| -export type CallToolRequest = Infer<typeof CallToolRequestSchema.parse>; |
1204 |
| -export type ToolListChangedNotification = Infer<typeof ToolListChangedNotificationSchema.parse>; |
| 1197 | +export type Tool = Infer<typeof ToolSchema>; |
| 1198 | +export type ListToolsRequest = Infer<typeof ListToolsRequestSchema>; |
| 1199 | +export type ListToolsResult = Infer<typeof ListToolsResultSchema>; |
| 1200 | +export type CallToolResult = Infer<typeof CallToolResultSchema>; |
| 1201 | +export type CompatibilityCallToolResult = Infer<typeof CompatibilityCallToolResultSchema>; |
| 1202 | +export type CallToolRequest = Infer<typeof CallToolRequestSchema>; |
| 1203 | +export type ToolListChangedNotification = Infer<typeof ToolListChangedNotificationSchema>; |
1205 | 1204 |
|
1206 | 1205 | /* Logging */
|
1207 |
| -export type LoggingLevel = Infer<typeof LoggingLevelSchema.parse>; |
1208 |
| -export type SetLevelRequest = Infer<typeof SetLevelRequestSchema.parse>; |
1209 |
| -export type LoggingMessageNotification = Infer<typeof LoggingMessageNotificationSchema.parse>; |
| 1206 | +export type LoggingLevel = Infer<typeof LoggingLevelSchema>; |
| 1207 | +export type SetLevelRequest = Infer<typeof SetLevelRequestSchema>; |
| 1208 | +export type LoggingMessageNotification = Infer<typeof LoggingMessageNotificationSchema>; |
1210 | 1209 |
|
1211 | 1210 | /* Sampling */
|
1212 |
| -export type SamplingMessage = Infer<typeof SamplingMessageSchema.parse>; |
1213 |
| -export type CreateMessageRequest = Infer<typeof CreateMessageRequestSchema.parse>; |
1214 |
| -export type CreateMessageResult = Infer<typeof CreateMessageResultSchema.parse>; |
| 1211 | +export type SamplingMessage = Infer<typeof SamplingMessageSchema>; |
| 1212 | +export type CreateMessageRequest = Infer<typeof CreateMessageRequestSchema>; |
| 1213 | +export type CreateMessageResult = Infer<typeof CreateMessageResultSchema>; |
1215 | 1214 |
|
1216 | 1215 | /* Autocomplete */
|
1217 |
| -export type ResourceReference = Infer<typeof ResourceReferenceSchema.parse>; |
1218 |
| -export type PromptReference = Infer<typeof PromptReferenceSchema.parse>; |
1219 |
| -export type CompleteRequest = Infer<typeof CompleteRequestSchema.parse>; |
1220 |
| -export type CompleteResult = Infer<typeof CompleteResultSchema.parse>; |
| 1216 | +export type ResourceReference = Infer<typeof ResourceReferenceSchema>; |
| 1217 | +export type PromptReference = Infer<typeof PromptReferenceSchema>; |
| 1218 | +export type CompleteRequest = Infer<typeof CompleteRequestSchema>; |
| 1219 | +export type CompleteResult = Infer<typeof CompleteResultSchema>; |
1221 | 1220 |
|
1222 | 1221 | /* Roots */
|
1223 |
| -export type Root = Infer<typeof RootSchema.parse>; |
1224 |
| -export type ListRootsRequest = Infer<typeof ListRootsRequestSchema.parse>; |
1225 |
| -export type ListRootsResult = Infer<typeof ListRootsResultSchema.parse>; |
1226 |
| -export type RootsListChangedNotification = Infer<typeof RootsListChangedNotificationSchema.parse>; |
| 1222 | +export type Root = Infer<typeof RootSchema>; |
| 1223 | +export type ListRootsRequest = Infer<typeof ListRootsRequestSchema>; |
| 1224 | +export type ListRootsResult = Infer<typeof ListRootsResultSchema>; |
| 1225 | +export type RootsListChangedNotification = Infer<typeof RootsListChangedNotificationSchema>; |
1227 | 1226 |
|
1228 | 1227 | /* Client messages */
|
1229 |
| -export type ClientRequest = Infer<typeof ClientRequestSchema.parse>; |
1230 |
| -export type ClientNotification = Infer<typeof ClientNotificationSchema.parse>; |
1231 |
| -export type ClientResult = Infer<typeof ClientResultSchema.parse>; |
| 1228 | +export type ClientRequest = Infer<typeof ClientRequestSchema>; |
| 1229 | +export type ClientNotification = Infer<typeof ClientNotificationSchema>; |
| 1230 | +export type ClientResult = Infer<typeof ClientResultSchema>; |
1232 | 1231 |
|
1233 | 1232 | /* Server messages */
|
1234 |
| -export type ServerRequest = Infer<typeof ServerRequestSchema.parse>; |
1235 |
| -export type ServerNotification = Infer<typeof ServerNotificationSchema.parse>; |
1236 |
| -export type ServerResult = Infer<typeof ServerResultSchema.parse>; |
| 1233 | +export type ServerRequest = Infer<typeof ServerRequestSchema>; |
| 1234 | +export type ServerNotification = Infer<typeof ServerNotificationSchema>; |
| 1235 | +export type ServerResult = Infer<typeof ServerResultSchema>; |
0 commit comments