refactor(api): improve session messages path handling by returning object with base and withId

Simplify deleteSessionMessage implementation by using the new paths object structure
This commit is contained in:
icarus 2025-09-26 05:44:23 +08:00
parent b82b16b5f6
commit 122e4a10d0

View File

@ -75,8 +75,10 @@ export class AgentApiClient {
withId: (id: string) => `/${this.apiVersion}/agents/${agentId}/sessions/${id}`
})
public getSessionMessagesPath = (agentId: string, sessionId: string) =>
`/${this.apiVersion}/agents/${agentId}/sessions/${sessionId}/messages`
public getSessionMessagesPaths = (agentId: string, sessionId: string) => ({
base: `/${this.apiVersion}/agents/${agentId}/sessions/${sessionId}/messages`,
withId: (id: number) => `/${this.apiVersion}/agents/${agentId}/sessions/${sessionId}/messages/${id}`
})
public getModelsPath = (props?: ApiModelsFilter) => {
const base = `/${this.apiVersion}/models`
@ -207,8 +209,7 @@ export class AgentApiClient {
}
public async deleteSessionMessage(agentId: string, sessionId: string, messageId: number): Promise<void> {
const base = this.getSessionMessagesPath(agentId, sessionId)
const url = `${base}/${messageId}`
const url = this.getSessionMessagesPaths(agentId, sessionId).withId(messageId)
try {
await this.axios.delete(url)
} catch (error) {