mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-26 03:31:24 +08:00
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:
parent
5a71807cc9
commit
dca6be45b0
@ -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']
|
||||
|
||||
Loading…
Reference in New Issue
Block a user