diff --git a/src/renderer/src/api/agent.ts b/src/renderer/src/api/agent.ts index 39386b5946..f9563d5faf 100644 --- a/src/renderer/src/api/agent.ts +++ b/src/renderer/src/api/agent.ts @@ -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 { + 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.') + } + } }