mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-09 14:59:27 +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 PermissionMode = z.infer<typeof PermissionModeSchema>
|
||||||
|
|
||||||
export type SessionMessageRole = ModelMessage['role']
|
export type SessionMessageRole = ModelMessage['role']
|
||||||
export type AgentType = 'claude-code'
|
|
||||||
|
|
||||||
export const isAgentType = (type: string): type is AgentType => {
|
export const AgentTypeSchema = z.enum(['claude-code'])
|
||||||
return ['claude-code'].includes(type)
|
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']
|
export type SessionMessageType = TextStreamPart<Record<string, any>>['type']
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user