Add agent summary update functionality and improve user controller

- Introduced a new endpoint in UserController to update the agent summary, ensuring balance data is refreshed after transactions.
- Implemented ForceUpdateSummaryImmediate method in IAgentGrain to allow immediate updates without cooldown checks.
- Enhanced StartBotCommandHandler to force update the agent summary before starting the bot, ensuring accurate balance data.
- Updated TypeScript API client to include the new update-agent-summary method for frontend integration.
This commit is contained in:
2026-01-03 03:09:44 +07:00
parent 78c2788ba7
commit fb49190346
7 changed files with 163 additions and 3 deletions

View File

@@ -4461,6 +4461,46 @@ export class UserClient extends AuthorizedApiBase {
}
return Promise.resolve<User>(null as any);
}
user_UpdateAgentSummary(): Promise<FileResponse> {
let url_ = this.baseUrl + "/User/update-agent-summary";
url_ = url_.replace(/[?&]$/, "");
let options_: RequestInit = {
method: "POST",
headers: {
"Accept": "application/octet-stream"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response: Response) => {
return this.processUser_UpdateAgentSummary(_response);
});
}
protected processUser_UpdateAgentSummary(response: Response): Promise<FileResponse> {
const status = response.status;
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
if (status === 200 || status === 206) {
const contentDisposition = response.headers ? response.headers.get("content-disposition") : undefined;
let fileNameMatch = contentDisposition ? /filename\*=(?:(\\?['"])(.*?)\1|(?:[^\s]+'.*?')?([^;\n]*))/g.exec(contentDisposition) : undefined;
let fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[3] || fileNameMatch[2] : undefined;
if (fileName) {
fileName = decodeURIComponent(fileName);
} else {
fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
}
return response.blob().then(blob => { return { fileName: fileName, data: blob, status: status, headers: _headers }; });
} else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve<FileResponse>(null as any);
}
}
export class WhitelistClient extends AuthorizedApiBase {