mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-24 10:40:07 +08:00
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:
parent
08772741e6
commit
db2042800b
@ -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.')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user