mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-14 01:50:39 +09:00
feat(costs): add agent model breakdown, harden date validation, sync CostByProject type, fix quota threshold and tab-gated queries
- add byAgentModel endpoint and expandable per-agent model sub-rows in the spend tab - validate date range inputs with isNaN + badRequest to return HTTP 400 on bad input - move CostByProject from a local api/costs.ts definition into packages/shared types - gate providerData query on mainTab === providers, consistent with weekData/windowData/quotaData - fix byProject range filter from finishedAt to startedAt, consistent with byProvider runs query - fix WHAM used_percent threshold from <= 1 to < 1 to avoid misclassifying 1% usage as 100% - replace inline opacity style with tailwind bg-primary/85 class in ProviderQuotaCard - reset expandedAgents set when company or date range changes - sort agent model sub-rows by cost descending in ui memo
This commit is contained in:
parent
db20f4f46e
commit
9d21380699
9 changed files with 192 additions and 56 deletions
|
|
@ -133,7 +133,9 @@ export type {
|
|||
CostSummary,
|
||||
CostByAgent,
|
||||
CostByProviderModel,
|
||||
CostByAgentModel,
|
||||
CostWindowSpendRow,
|
||||
CostByProject,
|
||||
HeartbeatRun,
|
||||
HeartbeatRunEvent,
|
||||
AgentRuntimeState,
|
||||
|
|
|
|||
|
|
@ -47,6 +47,17 @@ export interface CostByProviderModel {
|
|||
subscriptionOutputTokens: number;
|
||||
}
|
||||
|
||||
/** per-agent breakdown by provider + model, for identifying token-hungry agents */
|
||||
export interface CostByAgentModel {
|
||||
agentId: string;
|
||||
agentName: string | null;
|
||||
provider: string;
|
||||
model: string;
|
||||
costCents: number;
|
||||
inputTokens: number;
|
||||
outputTokens: number;
|
||||
}
|
||||
|
||||
/** spend per provider for a fixed rolling time window */
|
||||
export interface CostWindowSpendRow {
|
||||
provider: string;
|
||||
|
|
@ -58,3 +69,12 @@ export interface CostWindowSpendRow {
|
|||
inputTokens: number;
|
||||
outputTokens: number;
|
||||
}
|
||||
|
||||
/** cost attributed to a project via heartbeat run → activity log → issue → project chain */
|
||||
export interface CostByProject {
|
||||
projectId: string | null;
|
||||
projectName: string | null;
|
||||
costCents: number;
|
||||
inputTokens: number;
|
||||
outputTokens: number;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ export type {
|
|||
CompanySecret,
|
||||
SecretProviderDescriptor,
|
||||
} from "./secrets.js";
|
||||
export type { CostEvent, CostSummary, CostByAgent, CostByProviderModel, CostWindowSpendRow } from "./cost.js";
|
||||
export type { CostEvent, CostSummary, CostByAgent, CostByProviderModel, CostByAgentModel, CostWindowSpendRow, CostByProject } from "./cost.js";
|
||||
export type {
|
||||
HeartbeatRun,
|
||||
HeartbeatRunEvent,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue