refactor(types): replace hardcoded agent type check with zod schema

Use zod schema validation for type safety and maintainability instead of manual array checking
This commit is contained in:
icarus 2025-09-18 12:52:58 +08:00
parent 5a71807cc9
commit dca6be45b0

View File

@ -9,10 +9,12 @@ export const PermissionModeSchema = z.enum(['default', 'acceptEdits', 'bypassPer
export type PermissionMode = z.infer<typeof PermissionModeSchema>
export type SessionMessageRole = ModelMessage['role']
export type AgentType = 'claude-code'
export const isAgentType = (type: string): type is AgentType => {
return ['claude-code'].includes(type)
export const AgentTypeSchema = z.enum(['claude-code'])
export type AgentType = z.infer<typeof AgentTypeSchema>
export const isAgentType = (type: unknown): type is AgentType => {
return AgentTypeSchema.safeParse(type).success
}
export type SessionMessageType = TextStreamPart<Record<string, any>>['type']