From 0f777e357d6b951aea0a91251b3de5d082c6ad32 Mon Sep 17 00:00:00 2001 From: icarus Date: Thu, 18 Sep 2025 13:17:32 +0800 Subject: [PATCH] refactor(types): convert GetAgentSessionResponse interface to zod schema Improve type safety by using zod schema definition and inference instead of manual interface --- src/renderer/src/types/agent.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/renderer/src/types/agent.ts b/src/renderer/src/types/agent.ts index 752d9544a2..8dc090f7e6 100644 --- a/src/renderer/src/types/agent.ts +++ b/src/renderer/src/types/agent.ts @@ -135,10 +135,12 @@ export type CreateSessionRequest = AgentBase export interface UpdateSessionRequest extends Partial {} -export interface GetAgentSessionResponse extends AgentSessionEntity { - built_in_tools?: Tool[] // Built-in tools available to the agent - messages: AgentSessionMessageEntity[] // Messages in the session -} +export const GetAgentSessionResponseSchema = AgentSessionEntitySchema.extend({ + built_in_tools: z.array(ToolSchema).optional(), // Built-in tools available to the agent + messages: z.array(AgentSessionMessageEntitySchema) // Messages in the session +}) + +export type GetAgentSessionResponse = z.infer export interface CreateSessionMessageRequest { content: string