feat(agent-sessions): add schema and type for listing agent sessions

Add ListAgentSessionsResponseSchema and type to support paginated session listing
This commit is contained in:
icarus 2025-09-18 21:49:02 +08:00
parent f5f542911f
commit 08772741e6
2 changed files with 11 additions and 2 deletions

View File

@ -1,6 +1,6 @@
import { loggerService } from '@logger'
import { sessionMessageService, sessionService } from '@main/services/agents'
import { CreateSessionResponse } from '@types'
import { CreateSessionResponse, ListAgentSessionsResponse } from '@types'
import { Request, Response } from 'express'
const logger = loggerService.withContext('ApiServerSessionsHandlers')
@ -269,7 +269,7 @@ export const listAllSessions = async (req: Request, res: Response): Promise<Resp
total: result.total,
limit,
offset
})
} satisfies ListAgentSessionsResponse)
} catch (error: any) {
logger.error('Error listing all sessions:', error)
return res.status(500).json({

View File

@ -182,6 +182,15 @@ export const GetAgentSessionResponseSchema = AgentSessionEntitySchema.extend({
export type GetAgentSessionResponse = z.infer<typeof GetAgentSessionResponseSchema>
export const ListAgentSessionsResponseSchema = z.object({
data: z.array(AgentSessionEntitySchema),
total: z.int(),
limit: z.int(),
offset: z.int()
})
export type ListAgentSessionsResponse = z.infer<typeof ListAgentSessionsResponseSchema>
export interface CreateSessionMessageRequest {
content: string
}