feat(agent): add ListAgentsResponse type and update service

Add ListAgentsResponse schema and type to handle agent listing responses
Update AgentService to use the new type for listAgents method
This commit is contained in:
icarus 2025-09-18 13:19:57 +08:00
parent 0f777e357d
commit f9fb0f9125
2 changed files with 9 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import type {
CreateAgentRequest,
CreateAgentResponse,
GetAgentResponse,
ListAgentsResponse,
ListOptions,
UpdateAgentRequest
} from '@types'
@ -85,7 +86,7 @@ export class AgentService extends BaseService {
return agent
}
async listAgents(options: ListOptions = {}): Promise<{ agents: GetAgentResponse[]; total: number }> {
async listAgents(options: ListOptions = {}): Promise<ListAgentsResponse> {
this.ensureInitialized() // Build query with pagination
const totalResult = await this.database.select({ count: count() }).from(agentsTable)

View File

@ -131,6 +131,13 @@ export const GetAgentResponseSchema = AgentEntitySchema.extend({
export type GetAgentResponse = z.infer<typeof GetAgentResponseSchema>
export const ListAgentsResponseSchema = z.object({
agents: z.array(GetAgentResponseSchema),
total: z.number()
})
export type ListAgentsResponse = z.infer<typeof ListAgentsResponseSchema>
export type CreateSessionRequest = AgentBase
export interface UpdateSessionRequest extends Partial<AgentBase> {}