mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-03 02:59:07 +08:00
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:
parent
f5f542911f
commit
08772741e6
@ -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({
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user