mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-07 22:10:21 +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,
|
CreateAgentResponseSchema,
|
||||||
GetAgentResponse,
|
GetAgentResponse,
|
||||||
GetAgentResponseSchema,
|
GetAgentResponseSchema,
|
||||||
|
ListAgentSessionsResponse,
|
||||||
|
ListAgentSessionsResponseSchema,
|
||||||
type ListAgentsResponse,
|
type ListAgentsResponse,
|
||||||
ListAgentsResponseSchema,
|
ListAgentsResponseSchema,
|
||||||
UpdateAgentForm,
|
UpdateAgentForm,
|
||||||
@ -122,4 +124,18 @@ export class AgentApiClient {
|
|||||||
throw processError(error, 'Failed to updateAgent.')
|
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