Role - moved from inline to reusable type (#1221)
This commit is contained in:
parent
b0aac584fb
commit
e7ab32f9b5
2 changed files with 15 additions and 6 deletions
|
|
@ -660,6 +660,10 @@ const sdkTypeChecks = {
|
|||
Annotations: (sdk: SDKTypes.Annotations, spec: SpecTypes.Annotations) => {
|
||||
sdk = spec;
|
||||
spec = sdk;
|
||||
},
|
||||
Role: (sdk: SDKTypes.Role, spec: SpecTypes.Role) => {
|
||||
sdk = spec;
|
||||
spec = sdk;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -669,7 +673,6 @@ const SDK_TYPES_FILE = 'src/types.ts';
|
|||
|
||||
const MISSING_SDK_TYPES = [
|
||||
// These are inlined in the SDK:
|
||||
'Role',
|
||||
'Error', // The inner error object of a JSONRPCError
|
||||
'URLElicitationRequiredError' // In the SDK, but with a custom definition
|
||||
];
|
||||
|
|
|
|||
16
src/types.ts
16
src/types.ts
|
|
@ -790,6 +790,11 @@ export const BlobResourceContentsSchema = ResourceContentsSchema.extend({
|
|||
blob: Base64Schema
|
||||
});
|
||||
|
||||
/**
|
||||
* The sender or recipient of messages and data in a conversation.
|
||||
*/
|
||||
export const RoleSchema = z.enum(['user', 'assistant']);
|
||||
|
||||
/**
|
||||
* Optional annotations providing clients additional context about a resource.
|
||||
*/
|
||||
|
|
@ -797,7 +802,7 @@ export const AnnotationsSchema = z.object({
|
|||
/**
|
||||
* Intended audience(s) for the resource.
|
||||
*/
|
||||
audience: z.array(z.enum(['user', 'assistant'])).optional(),
|
||||
audience: z.array(RoleSchema).optional(),
|
||||
|
||||
/**
|
||||
* Importance hint for the resource, from 0 (least) to 1 (most).
|
||||
|
|
@ -1200,7 +1205,7 @@ export const ContentBlockSchema = z.union([
|
|||
* Describes a message returned as part of a prompt.
|
||||
*/
|
||||
export const PromptMessageSchema = z.object({
|
||||
role: z.enum(['user', 'assistant']),
|
||||
role: RoleSchema,
|
||||
content: ContentBlockSchema
|
||||
});
|
||||
|
||||
|
|
@ -1647,7 +1652,7 @@ export const SamplingMessageContentBlockSchema = z.discriminatedUnion('type', [
|
|||
*/
|
||||
export const SamplingMessageSchema = z
|
||||
.object({
|
||||
role: z.enum(['user', 'assistant']),
|
||||
role: RoleSchema,
|
||||
content: z.union([SamplingMessageContentBlockSchema, z.array(SamplingMessageContentBlockSchema)]),
|
||||
/**
|
||||
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
||||
|
|
@ -1731,7 +1736,7 @@ export const CreateMessageResultSchema = ResultSchema.extend({
|
|||
* This field is an open string to allow for provider-specific stop reasons.
|
||||
*/
|
||||
stopReason: z.optional(z.enum(['endTurn', 'stopSequence', 'maxTokens']).or(z.string())),
|
||||
role: z.enum(['user', 'assistant']),
|
||||
role: RoleSchema,
|
||||
/**
|
||||
* Response content. Single content block (text, image, or audio).
|
||||
*/
|
||||
|
|
@ -1759,7 +1764,7 @@ export const CreateMessageResultWithToolsSchema = ResultSchema.extend({
|
|||
* This field is an open string to allow for provider-specific stop reasons.
|
||||
*/
|
||||
stopReason: z.optional(z.enum(['endTurn', 'stopSequence', 'maxTokens', 'toolUse']).or(z.string())),
|
||||
role: z.enum(['user', 'assistant']),
|
||||
role: RoleSchema,
|
||||
/**
|
||||
* Response content. May be a single block or array. May include ToolUseContent if stopReason is "toolUse".
|
||||
*/
|
||||
|
|
@ -2349,6 +2354,7 @@ export type Icon = Infer<typeof IconSchema>;
|
|||
export type Icons = Infer<typeof IconsSchema>;
|
||||
export type BaseMetadata = Infer<typeof BaseMetadataSchema>;
|
||||
export type Annotations = Infer<typeof AnnotationsSchema>;
|
||||
export type Role = Infer<typeof RoleSchema>;
|
||||
|
||||
/* Initialization */
|
||||
export type Implementation = Infer<typeof ImplementationSchema>;
|
||||
|
|
|
|||
Loading…
Reference in a new issue