server: add ws hello/welcome message schemas
This commit is contained in:
@@ -197,6 +197,19 @@ const ToolCallDetailPayloadSchema: z.ZodType<ToolCallDetail> = z.discriminatedUn
|
|||||||
),
|
),
|
||||||
truncated: z.boolean().optional(),
|
truncated: z.boolean().optional(),
|
||||||
}),
|
}),
|
||||||
|
z.object({
|
||||||
|
type: z.literal('sub_agent'),
|
||||||
|
subAgentType: z.string().optional(),
|
||||||
|
description: z.string().optional(),
|
||||||
|
log: z.string(),
|
||||||
|
actions: z.array(
|
||||||
|
z.object({
|
||||||
|
index: z.number().int().positive(),
|
||||||
|
toolName: z.string(),
|
||||||
|
summary: z.string().optional(),
|
||||||
|
})
|
||||||
|
),
|
||||||
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
type: z.literal('unknown'),
|
type: z.literal('unknown'),
|
||||||
input: UnknownValueSchema,
|
input: UnknownValueSchema,
|
||||||
@@ -2201,6 +2214,29 @@ export const WSPongMessageSchema = z.object({
|
|||||||
type: z.literal('pong'),
|
type: z.literal('pong'),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const WSHelloMessageSchema = z.object({
|
||||||
|
type: z.literal('hello'),
|
||||||
|
clientId: z.string().min(1),
|
||||||
|
clientType: z.enum(['mobile', 'browser', 'cli', 'mcp']),
|
||||||
|
protocolVersion: z.number().int(),
|
||||||
|
capabilities: z
|
||||||
|
.object({
|
||||||
|
voice: z.boolean().optional(),
|
||||||
|
pushNotifications: z.boolean().optional(),
|
||||||
|
})
|
||||||
|
.passthrough()
|
||||||
|
.optional(),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const WSWelcomeMessageSchema = z.object({
|
||||||
|
type: z.literal('welcome'),
|
||||||
|
serverId: z.string(),
|
||||||
|
hostname: z.string().nullable(),
|
||||||
|
version: z.string().nullable(),
|
||||||
|
resumed: z.boolean(),
|
||||||
|
capabilities: ServerCapabilitiesSchema.optional(),
|
||||||
|
})
|
||||||
|
|
||||||
export const WSRecordingStateMessageSchema = z.object({
|
export const WSRecordingStateMessageSchema = z.object({
|
||||||
type: z.literal('recording_state'),
|
type: z.literal('recording_state'),
|
||||||
isRecording: z.boolean(),
|
isRecording: z.boolean(),
|
||||||
@@ -2220,17 +2256,21 @@ export const WSSessionOutboundSchema = z.object({
|
|||||||
// Complete WebSocket message schemas
|
// Complete WebSocket message schemas
|
||||||
export const WSInboundMessageSchema = z.discriminatedUnion('type', [
|
export const WSInboundMessageSchema = z.discriminatedUnion('type', [
|
||||||
WSPingMessageSchema,
|
WSPingMessageSchema,
|
||||||
|
WSHelloMessageSchema,
|
||||||
WSRecordingStateMessageSchema,
|
WSRecordingStateMessageSchema,
|
||||||
WSSessionInboundSchema,
|
WSSessionInboundSchema,
|
||||||
])
|
])
|
||||||
|
|
||||||
export const WSOutboundMessageSchema = z.discriminatedUnion('type', [
|
export const WSOutboundMessageSchema = z.discriminatedUnion('type', [
|
||||||
WSPongMessageSchema,
|
WSPongMessageSchema,
|
||||||
|
WSWelcomeMessageSchema,
|
||||||
WSSessionOutboundSchema,
|
WSSessionOutboundSchema,
|
||||||
])
|
])
|
||||||
|
|
||||||
export type WSInboundMessage = z.infer<typeof WSInboundMessageSchema>
|
export type WSInboundMessage = z.infer<typeof WSInboundMessageSchema>
|
||||||
export type WSOutboundMessage = z.infer<typeof WSOutboundMessageSchema>
|
export type WSOutboundMessage = z.infer<typeof WSOutboundMessageSchema>
|
||||||
|
export type WSHelloMessage = z.infer<typeof WSHelloMessageSchema>
|
||||||
|
export type WSWelcomeMessage = z.infer<typeof WSWelcomeMessageSchema>
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Helper functions for message conversion
|
// Helper functions for message conversion
|
||||||
|
|||||||
Reference in New Issue
Block a user