feat(billing): add usage increment API + wire hand/pipeline execution tracking
Server side: - POST /api/v1/billing/usage/increment endpoint with dimension whitelist (hand_executions, pipeline_runs, relay_requests) and count validation (1-100) - Returns updated usage quota after increment Desktop side: - New saas-billing.ts mixin with incrementUsageDimension() and reportUsageFireAndForget() (non-blocking, safe for finally blocks) - handStore.triggerHand: reports hand_executions after successful run - PipelinesPanel.handleRunComplete: reports pipeline_runs on completion - SaaSClient type declarations for new billing methods Billing pipeline now covers all three dimensions: relay_requests → relay handler (server-side, real-time) hand_executions → handStore (client-side, fire-and-forget) pipeline_runs → PipelinesPanel (client-side, fire-and-forget)
This commit is contained in:
@@ -132,6 +132,7 @@ import { installAdminMethods } from './saas-admin';
|
||||
import { installRelayMethods } from './saas-relay';
|
||||
import { installPromptMethods } from './saas-prompt';
|
||||
import { installTelemetryMethods } from './saas-telemetry';
|
||||
import { installBillingMethods } from './saas-billing';
|
||||
|
||||
// === Client Implementation ===
|
||||
|
||||
@@ -411,6 +412,7 @@ installAdminMethods(SaaSClient);
|
||||
installRelayMethods(SaaSClient);
|
||||
installPromptMethods(SaaSClient);
|
||||
installTelemetryMethods(SaaSClient);
|
||||
installBillingMethods(SaaSClient);
|
||||
|
||||
// === API Method Type Declarations ===
|
||||
// These methods are installed at runtime by installXxxMethods() in saas-*.ts.
|
||||
@@ -516,6 +518,10 @@ export interface SaaSClient {
|
||||
timestamp: string;
|
||||
}>;
|
||||
}): Promise<{ accepted: number; total: number }>;
|
||||
|
||||
// --- Billing (saas-billing.ts) ---
|
||||
incrementUsageDimension(dimension: string, count?: number): Promise<import('./saas-billing').UsageIncrementResult>;
|
||||
reportUsageFireAndForget(dimension: string, count?: number): void;
|
||||
}
|
||||
|
||||
// === Singleton ===
|
||||
|
||||
Reference in New Issue
Block a user