feat(pro): add analytics, export, and multi-account commercial features
3 new agor-pro modules: analytics.rs (usage dashboard queries), export.rs (session/project Markdown report generation), profiles.rs (multi-account switching via accounts.json). 9 Tauri plugin commands. Frontend IPC bridge (pro-bridge.ts). 168 cargo tests, 14 commercial vitest tests.
This commit is contained in:
parent
6973c70c5a
commit
03fe2e2237
8 changed files with 805 additions and 3 deletions
99
src/lib/commercial/pro-bridge.ts
Normal file
99
src/lib/commercial/pro-bridge.ts
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
// SPDX-License-Identifier: LicenseRef-Commercial
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
|
||||
// --- Analytics ---
|
||||
|
||||
export interface AnalyticsSummary {
|
||||
totalSessions: number;
|
||||
totalCostUsd: number;
|
||||
totalTokens: number;
|
||||
totalTurns: number;
|
||||
totalToolCalls: number;
|
||||
avgCostPerSession: number;
|
||||
avgTokensPerSession: number;
|
||||
periodDays: number;
|
||||
}
|
||||
|
||||
export interface DailyStats {
|
||||
date: string;
|
||||
sessionCount: number;
|
||||
costUsd: number;
|
||||
tokens: number;
|
||||
turns: number;
|
||||
toolCalls: number;
|
||||
}
|
||||
|
||||
export interface ModelBreakdown {
|
||||
model: string;
|
||||
sessionCount: number;
|
||||
totalCostUsd: number;
|
||||
totalTokens: number;
|
||||
avgCostPerSession: number;
|
||||
}
|
||||
|
||||
export const proAnalyticsSummary = (projectId: string, days?: number) =>
|
||||
invoke<AnalyticsSummary>('plugin:agor-pro|pro_analytics_summary', { projectId, days });
|
||||
|
||||
export const proAnalyticsDaily = (projectId: string, days?: number) =>
|
||||
invoke<DailyStats[]>('plugin:agor-pro|pro_analytics_daily', { projectId, days });
|
||||
|
||||
export const proAnalyticsModelBreakdown = (projectId: string, days?: number) =>
|
||||
invoke<ModelBreakdown[]>('plugin:agor-pro|pro_analytics_model_breakdown', { projectId, days });
|
||||
|
||||
// --- Export ---
|
||||
|
||||
export interface SessionReport {
|
||||
projectId: string;
|
||||
sessionId: string;
|
||||
markdown: string;
|
||||
costUsd: number;
|
||||
turnCount: number;
|
||||
toolCallCount: number;
|
||||
durationMinutes: number;
|
||||
model: string;
|
||||
}
|
||||
|
||||
export interface ProjectSummaryReport {
|
||||
projectId: string;
|
||||
markdown: string;
|
||||
totalSessions: number;
|
||||
totalCostUsd: number;
|
||||
periodDays: number;
|
||||
}
|
||||
|
||||
export const proExportSession = (projectId: string, sessionId: string) =>
|
||||
invoke<SessionReport>('plugin:agor-pro|pro_export_session', { projectId, sessionId });
|
||||
|
||||
export const proExportProjectSummary = (projectId: string, days?: number) =>
|
||||
invoke<ProjectSummaryReport>('plugin:agor-pro|pro_export_project_summary', { projectId, days });
|
||||
|
||||
// --- Profiles ---
|
||||
|
||||
export interface AccountProfile {
|
||||
id: string;
|
||||
displayName: string;
|
||||
email: string | null;
|
||||
provider: string;
|
||||
configDir: string;
|
||||
isActive: boolean;
|
||||
}
|
||||
|
||||
export interface ActiveAccount {
|
||||
profileId: string;
|
||||
provider: string;
|
||||
configDir: string;
|
||||
}
|
||||
|
||||
export const proListAccounts = () =>
|
||||
invoke<AccountProfile[]>('plugin:agor-pro|pro_list_accounts');
|
||||
|
||||
export const proGetActiveAccount = () =>
|
||||
invoke<ActiveAccount>('plugin:agor-pro|pro_get_active_account');
|
||||
|
||||
export const proSetActiveAccount = (profileId: string) =>
|
||||
invoke<ActiveAccount>('plugin:agor-pro|pro_set_active_account', { profileId });
|
||||
|
||||
// --- Status ---
|
||||
|
||||
export const proStatus = () =>
|
||||
invoke<string>('plugin:agor-pro|pro_status');
|
||||
Loading…
Add table
Add a link
Reference in a new issue