feat(agent): add listSessions method to AgentApiClient

Implement session listing functionality for agents by adding the listSessions method. This enables retrieving all sessions associated with a specific agent.
This commit is contained in:
icarus 2025-09-18 21:50:14 +08:00
parent 08772741e6
commit db2042800b

View File

@ -8,6 +8,8 @@ import {
CreateAgentResponseSchema,
GetAgentResponse,
GetAgentResponseSchema,
ListAgentSessionsResponse,
ListAgentSessionsResponseSchema,
type ListAgentsResponse,
ListAgentsResponseSchema,
UpdateAgentForm,
@ -122,4 +124,18 @@ export class AgentApiClient {
throw processError(error, 'Failed to updateAgent.')
}
}
public async listSessions(agentId: string): Promise<ListAgentSessionsResponse> {
const url = this.getSessionPaths(agentId).base
try {
const response = await this.axios.get(url)
const result = ListAgentSessionsResponseSchema.safeParse(response.data)
if (!result.success) {
throw new Error('Not a valid Sessions array.')
}
return result.data
} catch (error) {
throw processError(error, 'Failed to list sessions.')
}
}
}