feat(FN-1265): add agent budget settings UI and API
- Add Budget Settings section to ConfigTab with token limit, usage threshold, budget period, and reset day inputs - Add budget usage badge to DashboardTab showing token consumption and threshold warning - Add budget API functions to api.ts (getBudgetSummary, updateBudgetConfig, deleteBudgetUsage) - Add budget routes to routes.ts for GET/PATCH/DELETE agent budget endpoints - Add CSS styles for budget progress bar, warning indicators, and section layout - Add comprehensive tests for budget UI components and API routes
This commit is contained in:
@@ -1975,8 +1975,9 @@ import type {
|
||||
AgentReflection,
|
||||
AgentPerformanceSummary,
|
||||
ReflectionTrigger,
|
||||
AgentBudgetStatus,
|
||||
} from "@fusion/core";
|
||||
export type { Agent, AgentDetail, AgentCapability, AgentState, AgentHeartbeatEvent, AgentHeartbeatRun, AgentCreateInput, AgentUpdateInput, AgentTaskSession, AgentStats, HeartbeatInvocationSource, OrgTreeNode, AgentReflection, AgentPerformanceSummary, ReflectionTrigger };
|
||||
export type { Agent, AgentDetail, AgentCapability, AgentState, AgentHeartbeatEvent, AgentHeartbeatRun, AgentCreateInput, AgentUpdateInput, AgentTaskSession, AgentStats, HeartbeatInvocationSource, OrgTreeNode, AgentReflection, AgentPerformanceSummary, ReflectionTrigger, AgentBudgetStatus };
|
||||
|
||||
function withProjectId(path: string, projectId?: string): string {
|
||||
if (!projectId) return path;
|
||||
@@ -3799,6 +3800,20 @@ export function deleteAgentRating(agentId: string, ratingId: string, projectId?:
|
||||
});
|
||||
}
|
||||
|
||||
// ── Agent Budget API ──────────────────────────────────────────────────────
|
||||
|
||||
/** Fetch budget status for an agent */
|
||||
export function fetchAgentBudgetStatus(agentId: string, projectId?: string): Promise<AgentBudgetStatus> {
|
||||
return api<AgentBudgetStatus>(withProjectId(`/agents/${encodeURIComponent(agentId)}/budget`, projectId));
|
||||
}
|
||||
|
||||
/** Reset budget usage for an agent */
|
||||
export function resetAgentBudget(agentId: string, projectId?: string): Promise<void> {
|
||||
return api<void>(withProjectId(`/agents/${encodeURIComponent(agentId)}/budget/reset`, projectId), {
|
||||
method: "POST",
|
||||
});
|
||||
}
|
||||
|
||||
// ── Plugin Management ────────────────────────────────────────────────────────
|
||||
|
||||
/** Fetch all installed plugins */
|
||||
|
||||
Reference in New Issue
Block a user