Skip to content

Commit 246e5ce

Browse files
committed
replace Annotated superclass with annotations property
1 parent bb8f4b7 commit 246e5ce

File tree

3 files changed

+88
-144
lines changed

3 files changed

+88
-144
lines changed

docs/specification/draft/basic/messages.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ Responses are sent in reply to requests.
5555

5656
## Notifications
5757

58-
Notifications are sent from the client to the server or vice versa. The receiver **MUST NOT**
59-
send a response.
58+
Notifications are sent from the client to the server or vice versa. The receiver **MUST
59+
NOT** send a response.
6060

6161
```typescript
6262
{

schema/draft/schema.json

Lines changed: 25 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"definitions": {
4-
"Annotated": {
5-
"description": "Base for objects that include optional annotations for the client. The client can use annotations to inform how objects are used or displayed",
4+
"Annotations": {
5+
"description": "Optional annotations for the client. The client can use annotations to inform how objects are used or displayed",
66
"properties": {
7-
"annotations": {
8-
"properties": {
9-
"audience": {
10-
"description": "Describes who the intended customer of this object or data is.\n\nIt can include multiple entries to indicate content useful for multiple audiences (e.g., `[\"user\", \"assistant\"]`).",
11-
"items": {
12-
"$ref": "#/definitions/Role"
13-
},
14-
"type": "array"
15-
},
16-
"priority": {
17-
"description": "Describes how important this data is for operating the server.\n\nA value of 1 means \"most important,\" and indicates that the data is\neffectively required, while 0 means \"least important,\" and indicates that\nthe data is entirely optional.",
18-
"maximum": 1,
19-
"minimum": 0,
20-
"type": "number"
21-
}
7+
"audience": {
8+
"description": "Describes who the intended customer of this object or data is.\n\nIt can include multiple entries to indicate content useful for multiple audiences (e.g., `[\"user\", \"assistant\"]`).",
9+
"items": {
10+
"$ref": "#/definitions/Role"
2211
},
23-
"type": "object"
12+
"type": "array"
13+
},
14+
"priority": {
15+
"description": "Describes how important this data is for operating the server.\n\nA value of 1 means \"most important,\" and indicates that the data is\neffectively required, while 0 means \"least important,\" and indicates that\nthe data is entirely optional.",
16+
"maximum": 1,
17+
"minimum": 0,
18+
"type": "number"
2419
}
2520
},
2621
"type": "object"
@@ -29,22 +24,8 @@
2924
"description": "Audio provided to or from an LLM.",
3025
"properties": {
3126
"annotations": {
32-
"properties": {
33-
"audience": {
34-
"description": "Describes who the intended customer of this object or data is.\n\nIt can include multiple entries to indicate content useful for multiple audiences (e.g., `[\"user\", \"assistant\"]`).",
35-
"items": {
36-
"$ref": "#/definitions/Role"
37-
},
38-
"type": "array"
39-
},
40-
"priority": {
41-
"description": "Describes how important this data is for operating the server.\n\nA value of 1 means \"most important,\" and indicates that the data is\neffectively required, while 0 means \"least important,\" and indicates that\nthe data is entirely optional.",
42-
"maximum": 1,
43-
"minimum": 0,
44-
"type": "number"
45-
}
46-
},
47-
"type": "object"
27+
"$ref": "#/definitions/Annotations",
28+
"description": "Optional annotations for the client."
4829
},
4930
"data": {
5031
"description": "The base64-encoded audio data.",
@@ -487,22 +468,8 @@
487468
"description": "The contents of a resource, embedded into a prompt or tool call result.\n\nIt is up to the client how best to render embedded resources for the benefit\nof the LLM and/or the user.",
488469
"properties": {
489470
"annotations": {
490-
"properties": {
491-
"audience": {
492-
"description": "Describes who the intended customer of this object or data is.\n\nIt can include multiple entries to indicate content useful for multiple audiences (e.g., `[\"user\", \"assistant\"]`).",
493-
"items": {
494-
"$ref": "#/definitions/Role"
495-
},
496-
"type": "array"
497-
},
498-
"priority": {
499-
"description": "Describes how important this data is for operating the server.\n\nA value of 1 means \"most important,\" and indicates that the data is\neffectively required, while 0 means \"least important,\" and indicates that\nthe data is entirely optional.",
500-
"maximum": 1,
501-
"minimum": 0,
502-
"type": "number"
503-
}
504-
},
505-
"type": "object"
471+
"$ref": "#/definitions/Annotations",
472+
"description": "Optional annotations for the client."
506473
},
507474
"resource": {
508475
"anyOf": [
@@ -589,22 +556,8 @@
589556
"description": "An image provided to or from an LLM.",
590557
"properties": {
591558
"annotations": {
592-
"properties": {
593-
"audience": {
594-
"description": "Describes who the intended customer of this object or data is.\n\nIt can include multiple entries to indicate content useful for multiple audiences (e.g., `[\"user\", \"assistant\"]`).",
595-
"items": {
596-
"$ref": "#/definitions/Role"
597-
},
598-
"type": "array"
599-
},
600-
"priority": {
601-
"description": "Describes how important this data is for operating the server.\n\nA value of 1 means \"most important,\" and indicates that the data is\neffectively required, while 0 means \"least important,\" and indicates that\nthe data is entirely optional.",
602-
"maximum": 1,
603-
"minimum": 0,
604-
"type": "number"
605-
}
606-
},
607-
"type": "object"
559+
"$ref": "#/definitions/Annotations",
560+
"description": "Optional annotations for the client."
608561
},
609562
"data": {
610563
"description": "The base64-encoded image data.",
@@ -1528,22 +1481,8 @@
15281481
"description": "A known resource that the server is capable of reading.",
15291482
"properties": {
15301483
"annotations": {
1531-
"properties": {
1532-
"audience": {
1533-
"description": "Describes who the intended customer of this object or data is.\n\nIt can include multiple entries to indicate content useful for multiple audiences (e.g., `[\"user\", \"assistant\"]`).",
1534-
"items": {
1535-
"$ref": "#/definitions/Role"
1536-
},
1537-
"type": "array"
1538-
},
1539-
"priority": {
1540-
"description": "Describes how important this data is for operating the server.\n\nA value of 1 means \"most important,\" and indicates that the data is\neffectively required, while 0 means \"least important,\" and indicates that\nthe data is entirely optional.",
1541-
"maximum": 1,
1542-
"minimum": 0,
1543-
"type": "number"
1544-
}
1545-
},
1546-
"type": "object"
1484+
"$ref": "#/definitions/Annotations",
1485+
"description": "Optional annotations for the client."
15471486
},
15481487
"description": {
15491488
"description": "A description of what this resource represents.\n\nThis can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a \"hint\" to the model.",
@@ -1634,22 +1573,8 @@
16341573
"description": "A template description for resources available on the server.",
16351574
"properties": {
16361575
"annotations": {
1637-
"properties": {
1638-
"audience": {
1639-
"description": "Describes who the intended customer of this object or data is.\n\nIt can include multiple entries to indicate content useful for multiple audiences (e.g., `[\"user\", \"assistant\"]`).",
1640-
"items": {
1641-
"$ref": "#/definitions/Role"
1642-
},
1643-
"type": "array"
1644-
},
1645-
"priority": {
1646-
"description": "Describes how important this data is for operating the server.\n\nA value of 1 means \"most important,\" and indicates that the data is\neffectively required, while 0 means \"least important,\" and indicates that\nthe data is entirely optional.",
1647-
"maximum": 1,
1648-
"minimum": 0,
1649-
"type": "number"
1650-
}
1651-
},
1652-
"type": "object"
1576+
"$ref": "#/definitions/Annotations",
1577+
"description": "Optional annotations for the client."
16531578
},
16541579
"description": {
16551580
"description": "A description of what this template is for.\n\nThis can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a \"hint\" to the model.",
@@ -1970,22 +1895,8 @@
19701895
"description": "Text provided to or from an LLM.",
19711896
"properties": {
19721897
"annotations": {
1973-
"properties": {
1974-
"audience": {
1975-
"description": "Describes who the intended customer of this object or data is.\n\nIt can include multiple entries to indicate content useful for multiple audiences (e.g., `[\"user\", \"assistant\"]`).",
1976-
"items": {
1977-
"$ref": "#/definitions/Role"
1978-
},
1979-
"type": "array"
1980-
},
1981-
"priority": {
1982-
"description": "Describes how important this data is for operating the server.\n\nA value of 1 means \"most important,\" and indicates that the data is\neffectively required, while 0 means \"least important,\" and indicates that\nthe data is entirely optional.",
1983-
"maximum": 1,
1984-
"minimum": 0,
1985-
"type": "number"
1986-
}
1987-
},
1988-
"type": "object"
1898+
"$ref": "#/definitions/Annotations",
1899+
"description": "Optional annotations for the client."
19891900
},
19901901
"text": {
19911902
"description": "The text content of the message.",

schema/draft/schema.ts

Lines changed: 61 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ export interface ResourceUpdatedNotification extends Notification {
421421
/**
422422
* A known resource that the server is capable of reading.
423423
*/
424-
export interface Resource extends Annotated {
424+
export interface Resource {
425425
/**
426426
* The URI of this resource.
427427
*
@@ -447,12 +447,17 @@ export interface Resource extends Annotated {
447447
* The MIME type of this resource, if known.
448448
*/
449449
mimeType?: string;
450+
451+
/**
452+
* Optional annotations for the client.
453+
*/
454+
annotations?: Annotations;
450455
}
451456

452457
/**
453458
* A template description for resources available on the server.
454459
*/
455-
export interface ResourceTemplate extends Annotated {
460+
export interface ResourceTemplate {
456461
/**
457462
* A URI template (according to RFC 6570) that can be used to construct resource URIs.
458463
*
@@ -478,6 +483,11 @@ export interface ResourceTemplate extends Annotated {
478483
* The MIME type for all resources that match this template. This should only be included if all resources matching this template have the same type.
479484
*/
480485
mimeType?: string;
486+
487+
/**
488+
* Optional annotations for the client.
489+
*/
490+
annotations?: Annotations;
481491
}
482492

483493
/**
@@ -613,9 +623,14 @@ export interface PromptMessage {
613623
* It is up to the client how best to render embedded resources for the benefit
614624
* of the LLM and/or the user.
615625
*/
616-
export interface EmbeddedResource extends Annotated {
626+
export interface EmbeddedResource {
617627
type: "resource";
618628
resource: TextResourceContents | BlobResourceContents;
629+
630+
/**
631+
* Optional annotations for the client.
632+
*/
633+
annotations?: Annotations;
619634
}
620635

621636
/**
@@ -813,76 +828,94 @@ export interface SamplingMessage {
813828
}
814829

815830
/**
816-
* Base for objects that include optional annotations for the client. The client can use annotations to inform how objects are used or displayed
831+
* Optional annotations for the client. The client can use annotations to inform how objects are used or displayed
817832
*/
818-
export interface Annotated {
819-
annotations?: {
820-
/**
821-
* Describes who the intended customer of this object or data is.
822-
*
823-
* It can include multiple entries to indicate content useful for multiple audiences (e.g., `["user", "assistant"]`).
824-
*/
825-
audience?: Role[];
833+
export interface Annotations {
834+
/**
835+
* Describes who the intended customer of this object or data is.
836+
*
837+
* It can include multiple entries to indicate content useful for multiple audiences (e.g., `["user", "assistant"]`).
838+
*/
839+
audience?: Role[];
826840

827-
/**
828-
* Describes how important this data is for operating the server.
829-
*
830-
* A value of 1 means "most important," and indicates that the data is
831-
* effectively required, while 0 means "least important," and indicates that
832-
* the data is entirely optional.
833-
*
834-
* @TJS-type number
835-
* @minimum 0
836-
* @maximum 1
837-
*/
838-
priority?: number;
839-
}
841+
/**
842+
* Describes how important this data is for operating the server.
843+
*
844+
* A value of 1 means "most important," and indicates that the data is
845+
* effectively required, while 0 means "least important," and indicates that
846+
* the data is entirely optional.
847+
*
848+
* @TJS-type number
849+
* @minimum 0
850+
* @maximum 1
851+
*/
852+
priority?: number;
840853
}
841854

842855
/**
843856
* Text provided to or from an LLM.
844857
*/
845-
export interface TextContent extends Annotated {
858+
export interface TextContent {
846859
type: "text";
860+
847861
/**
848862
* The text content of the message.
849863
*/
850864
text: string;
865+
866+
/**
867+
* Optional annotations for the client.
868+
*/
869+
annotations?: Annotations;
851870
}
852871

853872
/**
854873
* An image provided to or from an LLM.
855874
*/
856-
export interface ImageContent extends Annotated {
875+
export interface ImageContent {
857876
type: "image";
877+
858878
/**
859879
* The base64-encoded image data.
860880
*
861881
* @format byte
862882
*/
863883
data: string;
884+
864885
/**
865886
* The MIME type of the image. Different providers may support different image types.
866887
*/
867888
mimeType: string;
889+
890+
/**
891+
* Optional annotations for the client.
892+
*/
893+
annotations?: Annotations;
868894
}
869895

870896

871897
/**
872898
* Audio provided to or from an LLM.
873899
*/
874-
export interface AudioContent extends Annotated {
900+
export interface AudioContent {
875901
type: "audio";
902+
876903
/**
877904
* The base64-encoded audio data.
878905
*
879906
* @format byte
880907
*/
881908
data: string;
909+
882910
/**
883911
* The MIME type of the audio. Different providers may support different audio types.
884912
*/
885913
mimeType: string;
914+
915+
/**
916+
* Optional annotations for the client.
917+
*/
918+
annotations?: Annotations;
886919
}
887920

888921

0 commit comments

Comments
 (0)