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

@@ -176,6 +176,23 @@ public class AgentGrain : Grain, IAgentGrain
await UpdateSummary();
}
/// <summary>
/// Forces an immediate update of the agent summary without cooldown check (for critical updates like after topup)
/// Invalidates cached balance data to ensure fresh balance fetch
/// </summary>
public async Task ForceUpdateSummaryImmediate()
{
// Invalidate cached balance data to force fresh fetch
_state.State.CachedBalanceData = null;
await _state.WriteStateAsync();
_logger.LogInformation("Force updating agent summary immediately for user {UserId} (cache invalidated)",
this.GetPrimaryKeyLong());
// Update summary immediately without cooldown check
await UpdateSummary();
}
/// <summary>
/// Updates the agent summary by recalculating from position data (used for initialization or manual refresh)
/// </summary>