style(design): apply Minimal Dark Mode design system\n\n- Switched to complete Dark Mode (OLED-friendly)\n- Established standard color palette matching modern technical aesthetics\n- Changed font to Plus Jakarta Sans for increased legibility\n- Enforced dark mode as default in App.tsx\n- Fixed several React cascading render (setState in useEffect) warnings
This commit is contained in:
1 parent
b80531f8a8
commit
bac7b5591e
738 files changed
+138513
-138123
No files matched your search
+101
-101
@@ -1,101 +1,101 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export interface DeviceProfile {
|
||||
machineId: string;
|
||||
macMachineId: string;
|
||||
devDeviceId: string;
|
||||
sqmId: string;
|
||||
}
|
||||
|
||||
export interface DeviceProfileVersion {
|
||||
id: string;
|
||||
createdAt: number;
|
||||
label: string;
|
||||
profile: DeviceProfile;
|
||||
isCurrent: boolean;
|
||||
}
|
||||
|
||||
export interface DeviceProfilesSnapshot {
|
||||
currentStorage?: DeviceProfile;
|
||||
boundProfile?: DeviceProfile;
|
||||
history: DeviceProfileVersion[];
|
||||
baseline?: DeviceProfile;
|
||||
}
|
||||
|
||||
export interface Account {
|
||||
id: string; // UUID
|
||||
name: string;
|
||||
email: string;
|
||||
backup_file?: string;
|
||||
avatar_url?: string;
|
||||
deviceProfile?: DeviceProfile;
|
||||
deviceHistory?: DeviceProfileVersion[];
|
||||
created_at: string;
|
||||
last_used: string;
|
||||
}
|
||||
|
||||
export interface AccountBackupData {
|
||||
version: string; // Backup format version
|
||||
account: Account;
|
||||
data: {
|
||||
// Key-value pairs from Gemini Nexus database
|
||||
geminiNexusAuthStatus?: string;
|
||||
'jetskiStateSync.agentManagerInitState'?: string;
|
||||
'geminiNexusUnifiedStateSync.oauthToken'?: string;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
}
|
||||
|
||||
export interface AccountInfo {
|
||||
email: string;
|
||||
name?: string;
|
||||
isAuthenticated: boolean;
|
||||
}
|
||||
|
||||
// Zod Schemas for validation
|
||||
|
||||
export const DeviceProfileSchema = z.object({
|
||||
machineId: z.string(),
|
||||
macMachineId: z.string(),
|
||||
devDeviceId: z.string(),
|
||||
sqmId: z.string(),
|
||||
});
|
||||
|
||||
export const DeviceProfileVersionSchema = z.object({
|
||||
id: z.string(),
|
||||
createdAt: z.number(),
|
||||
label: z.string(),
|
||||
profile: DeviceProfileSchema,
|
||||
isCurrent: z.boolean(),
|
||||
});
|
||||
|
||||
export const DeviceProfilesSnapshotSchema = z.object({
|
||||
currentStorage: DeviceProfileSchema.optional(),
|
||||
boundProfile: DeviceProfileSchema.optional(),
|
||||
history: z.array(DeviceProfileVersionSchema),
|
||||
baseline: DeviceProfileSchema.optional(),
|
||||
});
|
||||
|
||||
export const AccountSchema = z.object({
|
||||
id: z.string(), // Relaxed from .uuid()
|
||||
name: z.string(), // Relaxed from .min(1)
|
||||
email: z.string(), // Relaxed from .email()
|
||||
backup_file: z.string().optional(),
|
||||
avatar_url: z.string().optional(),
|
||||
deviceProfile: DeviceProfileSchema.optional(),
|
||||
deviceHistory: z.array(DeviceProfileVersionSchema).optional(),
|
||||
created_at: z.string(),
|
||||
last_used: z.string(),
|
||||
});
|
||||
|
||||
export const AccountBackupDataSchema = z.object({
|
||||
version: z.string(),
|
||||
account: AccountSchema,
|
||||
data: z.record(z.string(), z.any()),
|
||||
});
|
||||
|
||||
export const AccountInfoSchema = z.object({
|
||||
email: z.string(), // Allow empty string for unauthenticated state
|
||||
name: z.string().optional(),
|
||||
isAuthenticated: z.boolean(),
|
||||
});
|
||||
import { z } from 'zod';
|
||||
|
||||
export interface DeviceProfile {
|
||||
machineId: string;
|
||||
macMachineId: string;
|
||||
devDeviceId: string;
|
||||
sqmId: string;
|
||||
}
|
||||
|
||||
export interface DeviceProfileVersion {
|
||||
id: string;
|
||||
createdAt: number;
|
||||
label: string;
|
||||
profile: DeviceProfile;
|
||||
isCurrent: boolean;
|
||||
}
|
||||
|
||||
export interface DeviceProfilesSnapshot {
|
||||
currentStorage?: DeviceProfile;
|
||||
boundProfile?: DeviceProfile;
|
||||
history: DeviceProfileVersion[];
|
||||
baseline?: DeviceProfile;
|
||||
}
|
||||
|
||||
export interface Account {
|
||||
id: string; // UUID
|
||||
name: string;
|
||||
email: string;
|
||||
backup_file?: string;
|
||||
avatar_url?: string;
|
||||
deviceProfile?: DeviceProfile;
|
||||
deviceHistory?: DeviceProfileVersion[];
|
||||
created_at: string;
|
||||
last_used: string;
|
||||
}
|
||||
|
||||
export interface AccountBackupData {
|
||||
version: string; // Backup format version
|
||||
account: Account;
|
||||
data: {
|
||||
// Key-value pairs from Gemini Nexus database
|
||||
geminiNexusAuthStatus?: string;
|
||||
'jetskiStateSync.agentManagerInitState'?: string;
|
||||
'geminiNexusUnifiedStateSync.oauthToken'?: string;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
}
|
||||
|
||||
export interface AccountInfo {
|
||||
email: string;
|
||||
name?: string;
|
||||
isAuthenticated: boolean;
|
||||
}
|
||||
|
||||
// Zod Schemas for validation
|
||||
|
||||
export const DeviceProfileSchema = z.object({
|
||||
machineId: z.string(),
|
||||
macMachineId: z.string(),
|
||||
devDeviceId: z.string(),
|
||||
sqmId: z.string(),
|
||||
});
|
||||
|
||||
export const DeviceProfileVersionSchema = z.object({
|
||||
id: z.string(),
|
||||
createdAt: z.number(),
|
||||
label: z.string(),
|
||||
profile: DeviceProfileSchema,
|
||||
isCurrent: z.boolean(),
|
||||
});
|
||||
|
||||
export const DeviceProfilesSnapshotSchema = z.object({
|
||||
currentStorage: DeviceProfileSchema.optional(),
|
||||
boundProfile: DeviceProfileSchema.optional(),
|
||||
history: z.array(DeviceProfileVersionSchema),
|
||||
baseline: DeviceProfileSchema.optional(),
|
||||
});
|
||||
|
||||
export const AccountSchema = z.object({
|
||||
id: z.string(), // Relaxed from .uuid()
|
||||
name: z.string(), // Relaxed from .min(1)
|
||||
email: z.string(), // Relaxed from .email()
|
||||
backup_file: z.string().optional(),
|
||||
avatar_url: z.string().optional(),
|
||||
deviceProfile: DeviceProfileSchema.optional(),
|
||||
deviceHistory: z.array(DeviceProfileVersionSchema).optional(),
|
||||
created_at: z.string(),
|
||||
last_used: z.string(),
|
||||
});
|
||||
|
||||
export const AccountBackupDataSchema = z.object({
|
||||
version: z.string(),
|
||||
account: AccountSchema,
|
||||
data: z.record(z.string(), z.any()),
|
||||
});
|
||||
|
||||
export const AccountInfoSchema = z.object({
|
||||
email: z.string(), // Allow empty string for unauthenticated state
|
||||
name: z.string().optional(),
|
||||
isAuthenticated: z.boolean(),
|
||||
});
|
||||
+138
-138
@@ -1,138 +1,138 @@
|
||||
import { z } from 'zod';
|
||||
import {
|
||||
DeviceProfileSchema,
|
||||
DeviceProfileVersionSchema,
|
||||
type DeviceProfile,
|
||||
type DeviceProfileVersion,
|
||||
} from './account';
|
||||
|
||||
export interface CloudTokenData {
|
||||
access_token: string;
|
||||
refresh_token: string;
|
||||
expires_in: number;
|
||||
expiry_timestamp: number;
|
||||
token_type: string;
|
||||
email?: string;
|
||||
project_id?: string;
|
||||
oauth_client_key?: string;
|
||||
session_id?: string;
|
||||
upstream_proxy_url?: string;
|
||||
is_gcp_tos?: boolean;
|
||||
}
|
||||
|
||||
export interface CloudQuotaModelInfo {
|
||||
percentage: number;
|
||||
resetTime: string;
|
||||
display_name?: string;
|
||||
supports_images?: boolean;
|
||||
supports_thinking?: boolean;
|
||||
thinking_budget?: number;
|
||||
recommended?: boolean;
|
||||
max_tokens?: number;
|
||||
max_output_tokens?: number;
|
||||
supported_mime_types?: Record<string, boolean>;
|
||||
}
|
||||
|
||||
export interface CloudQuotaData {
|
||||
models: Record<string, CloudQuotaModelInfo>;
|
||||
model_forwarding_rules?: Record<string, string>;
|
||||
subscription_tier?: string;
|
||||
is_forbidden?: boolean;
|
||||
isForbidden?: boolean;
|
||||
ai_credits?: { credits: number; expiryDate: string };
|
||||
}
|
||||
|
||||
export interface CloudAccount {
|
||||
id: string; // UUID
|
||||
provider: 'google' | 'anthropic';
|
||||
email: string;
|
||||
name?: string | null;
|
||||
avatar_url?: string | null;
|
||||
token: CloudTokenData;
|
||||
quota?: CloudQuotaData;
|
||||
device_profile?: DeviceProfile;
|
||||
device_history?: DeviceProfileVersion[];
|
||||
created_at: number;
|
||||
last_used: number; // Unix timestamp
|
||||
status?: 'active' | 'rate_limited' | 'expired';
|
||||
status_reason?: string;
|
||||
is_active?: boolean;
|
||||
proxy_url?: string;
|
||||
}
|
||||
|
||||
// Zod Schemas
|
||||
export const CloudTokenDataSchema = z.object({
|
||||
access_token: z.string(),
|
||||
refresh_token: z.string(),
|
||||
expires_in: z.number(),
|
||||
expiry_timestamp: z.number(),
|
||||
token_type: z.string(),
|
||||
email: z.string().optional(),
|
||||
project_id: z.string().optional(),
|
||||
oauth_client_key: z.string().optional(),
|
||||
session_id: z.string().optional(),
|
||||
upstream_proxy_url: z.string().optional(),
|
||||
is_gcp_tos: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export const CloudQuotaModelInfoSchema = z.object({
|
||||
percentage: z.number(),
|
||||
resetTime: z.string(),
|
||||
display_name: z.string().optional(),
|
||||
supports_images: z.boolean().optional(),
|
||||
supports_thinking: z.boolean().optional(),
|
||||
thinking_budget: z.number().optional(),
|
||||
recommended: z.boolean().optional(),
|
||||
max_tokens: z.number().optional(),
|
||||
max_output_tokens: z.number().optional(),
|
||||
supported_mime_types: z.record(z.string(), z.boolean()).optional(),
|
||||
});
|
||||
|
||||
export const CloudQuotaDataSchema = z.object({
|
||||
models: z.record(z.string(), CloudQuotaModelInfoSchema),
|
||||
model_forwarding_rules: z.record(z.string(), z.string()).optional(),
|
||||
subscription_tier: z.string().optional(),
|
||||
is_forbidden: z.boolean().optional(),
|
||||
isForbidden: z.boolean().optional(),
|
||||
ai_credits: z.object({ credits: z.number(), expiryDate: z.string() }).optional(),
|
||||
});
|
||||
|
||||
export const CloudAccountSchema = z.object({
|
||||
id: z.string(),
|
||||
provider: z.enum(['google', 'anthropic']),
|
||||
email: z.string(), // Relaxed: was z.string().email() but caused validation issues with some formats
|
||||
name: z.string().optional().nullable(),
|
||||
avatar_url: z.string().optional().nullable(),
|
||||
token: CloudTokenDataSchema,
|
||||
quota: CloudQuotaDataSchema.optional(),
|
||||
device_profile: DeviceProfileSchema.optional(),
|
||||
device_history: z.array(DeviceProfileVersionSchema).optional(),
|
||||
created_at: z.number(),
|
||||
last_used: z.number(),
|
||||
status: z.enum(['active', 'rate_limited', 'expired']).optional(),
|
||||
status_reason: z.string().optional(),
|
||||
is_active: z.boolean().optional(),
|
||||
proxy_url: z.string().optional(),
|
||||
});
|
||||
|
||||
export const CloudAccountExportSchema = z.object({
|
||||
version: z.literal('1.0'),
|
||||
exportedAt: z.number(),
|
||||
accounts: z.array(
|
||||
z.object({
|
||||
provider: z.enum(['google', 'anthropic']),
|
||||
email: z.string(),
|
||||
name: z.string().optional().nullable(),
|
||||
avatar_url: z.string().optional().nullable(),
|
||||
token: CloudTokenDataSchema,
|
||||
quota: CloudQuotaDataSchema.optional(),
|
||||
device_profile: z.any().optional(),
|
||||
device_history: z.any().optional(),
|
||||
proxy_url: z.string().optional().nullable(),
|
||||
status: z.enum(['active', 'rate_limited', 'expired']).optional(),
|
||||
status_reason: z.string().optional(),
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
||||
export type CloudAccountExport = z.infer<typeof CloudAccountExportSchema>;
|
||||
import { z } from 'zod';
|
||||
import {
|
||||
DeviceProfileSchema,
|
||||
DeviceProfileVersionSchema,
|
||||
type DeviceProfile,
|
||||
type DeviceProfileVersion,
|
||||
} from './account';
|
||||
|
||||
export interface CloudTokenData {
|
||||
access_token: string;
|
||||
refresh_token: string;
|
||||
expires_in: number;
|
||||
expiry_timestamp: number;
|
||||
token_type: string;
|
||||
email?: string;
|
||||
project_id?: string;
|
||||
oauth_client_key?: string;
|
||||
session_id?: string;
|
||||
upstream_proxy_url?: string;
|
||||
is_gcp_tos?: boolean;
|
||||
}
|
||||
|
||||
export interface CloudQuotaModelInfo {
|
||||
percentage: number;
|
||||
resetTime: string;
|
||||
display_name?: string;
|
||||
supports_images?: boolean;
|
||||
supports_thinking?: boolean;
|
||||
thinking_budget?: number;
|
||||
recommended?: boolean;
|
||||
max_tokens?: number;
|
||||
max_output_tokens?: number;
|
||||
supported_mime_types?: Record<string, boolean>;
|
||||
}
|
||||
|
||||
export interface CloudQuotaData {
|
||||
models: Record<string, CloudQuotaModelInfo>;
|
||||
model_forwarding_rules?: Record<string, string>;
|
||||
subscription_tier?: string;
|
||||
is_forbidden?: boolean;
|
||||
isForbidden?: boolean;
|
||||
ai_credits?: { credits: number; expiryDate: string };
|
||||
}
|
||||
|
||||
export interface CloudAccount {
|
||||
id: string; // UUID
|
||||
provider: 'google' | 'anthropic';
|
||||
email: string;
|
||||
name?: string | null;
|
||||
avatar_url?: string | null;
|
||||
token: CloudTokenData;
|
||||
quota?: CloudQuotaData;
|
||||
device_profile?: DeviceProfile;
|
||||
device_history?: DeviceProfileVersion[];
|
||||
created_at: number;
|
||||
last_used: number; // Unix timestamp
|
||||
status?: 'active' | 'rate_limited' | 'expired';
|
||||
status_reason?: string;
|
||||
is_active?: boolean;
|
||||
proxy_url?: string;
|
||||
}
|
||||
|
||||
// Zod Schemas
|
||||
export const CloudTokenDataSchema = z.object({
|
||||
access_token: z.string(),
|
||||
refresh_token: z.string(),
|
||||
expires_in: z.number(),
|
||||
expiry_timestamp: z.number(),
|
||||
token_type: z.string(),
|
||||
email: z.string().optional(),
|
||||
project_id: z.string().optional(),
|
||||
oauth_client_key: z.string().optional(),
|
||||
session_id: z.string().optional(),
|
||||
upstream_proxy_url: z.string().optional(),
|
||||
is_gcp_tos: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export const CloudQuotaModelInfoSchema = z.object({
|
||||
percentage: z.number(),
|
||||
resetTime: z.string(),
|
||||
display_name: z.string().optional(),
|
||||
supports_images: z.boolean().optional(),
|
||||
supports_thinking: z.boolean().optional(),
|
||||
thinking_budget: z.number().optional(),
|
||||
recommended: z.boolean().optional(),
|
||||
max_tokens: z.number().optional(),
|
||||
max_output_tokens: z.number().optional(),
|
||||
supported_mime_types: z.record(z.string(), z.boolean()).optional(),
|
||||
});
|
||||
|
||||
export const CloudQuotaDataSchema = z.object({
|
||||
models: z.record(z.string(), CloudQuotaModelInfoSchema),
|
||||
model_forwarding_rules: z.record(z.string(), z.string()).optional(),
|
||||
subscription_tier: z.string().optional(),
|
||||
is_forbidden: z.boolean().optional(),
|
||||
isForbidden: z.boolean().optional(),
|
||||
ai_credits: z.object({ credits: z.number(), expiryDate: z.string() }).optional(),
|
||||
});
|
||||
|
||||
export const CloudAccountSchema = z.object({
|
||||
id: z.string(),
|
||||
provider: z.enum(['google', 'anthropic']),
|
||||
email: z.string(), // Relaxed: was z.string().email() but caused validation issues with some formats
|
||||
name: z.string().optional().nullable(),
|
||||
avatar_url: z.string().optional().nullable(),
|
||||
token: CloudTokenDataSchema,
|
||||
quota: CloudQuotaDataSchema.optional(),
|
||||
device_profile: DeviceProfileSchema.optional(),
|
||||
device_history: z.array(DeviceProfileVersionSchema).optional(),
|
||||
created_at: z.number(),
|
||||
last_used: z.number(),
|
||||
status: z.enum(['active', 'rate_limited', 'expired']).optional(),
|
||||
status_reason: z.string().optional(),
|
||||
is_active: z.boolean().optional(),
|
||||
proxy_url: z.string().optional(),
|
||||
});
|
||||
|
||||
export const CloudAccountExportSchema = z.object({
|
||||
version: z.literal('1.0'),
|
||||
exportedAt: z.number(),
|
||||
accounts: z.array(
|
||||
z.object({
|
||||
provider: z.enum(['google', 'anthropic']),
|
||||
email: z.string(),
|
||||
name: z.string().optional().nullable(),
|
||||
avatar_url: z.string().optional().nullable(),
|
||||
token: CloudTokenDataSchema,
|
||||
quota: CloudQuotaDataSchema.optional(),
|
||||
device_profile: z.any().optional(),
|
||||
device_history: z.any().optional(),
|
||||
proxy_url: z.string().optional().nullable(),
|
||||
status: z.enum(['active', 'rate_limited', 'expired']).optional(),
|
||||
status_reason: z.string().optional(),
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
||||
export type CloudAccountExport = z.infer<typeof CloudAccountExportSchema>;
|
||||
+97
-97
@@ -1,97 +1,97 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const UpstreamProxyConfigSchema = z.object({
|
||||
enabled: z.boolean(),
|
||||
url: z.string(),
|
||||
});
|
||||
|
||||
export const ProxyConfigSchema = z.object({
|
||||
enabled: z.boolean(),
|
||||
port: z.number(),
|
||||
api_key: z.string(),
|
||||
auto_start: z.boolean(),
|
||||
backend_canary_enabled: z.boolean().default(true),
|
||||
parity_enabled: z.boolean().default(false),
|
||||
parity_shadow_enabled: z.boolean().default(false),
|
||||
parity_kill_switch: z.boolean().default(false),
|
||||
parity_no_go_mismatch_rate: z.number().default(0.15),
|
||||
parity_no_go_error_rate: z.number().default(0.4),
|
||||
scheduling_mode: z.enum(['cache-first', 'balance', 'performance-first']).default('balance'),
|
||||
max_wait_seconds: z.number().default(60),
|
||||
preferred_account_id: z.string().default(''),
|
||||
circuit_breaker_enabled: z.boolean().default(true),
|
||||
circuit_breaker_backoff_steps: z.array(z.number()).default([60, 300, 1800, 7200]),
|
||||
custom_mapping: z.record(z.string(), z.string()).default({}),
|
||||
anthropic_mapping: z.record(z.string(), z.string()), // Mapping table
|
||||
request_timeout: z.number().default(120), // Timeout in seconds
|
||||
upstream_proxy: UpstreamProxyConfigSchema,
|
||||
});
|
||||
|
||||
export const AppConfigSchema = z.object({
|
||||
language: z.string(),
|
||||
theme: z.string(),
|
||||
auto_refresh: z.boolean(),
|
||||
refresh_interval: z.number(), // minutes
|
||||
auto_sync: z.boolean(),
|
||||
sync_interval: z.number(), // minutes
|
||||
auto_startup: z.boolean(),
|
||||
error_reporting_enabled: z.boolean(),
|
||||
privacy_consent_asked: z.boolean().optional().default(false), // Optional for backward compatibility
|
||||
default_export_path: z.string().nullable().optional(), // Export path
|
||||
model_visibility: z.record(z.string(), z.boolean()).default({}), // Model visibility preferences
|
||||
provider_groupings_enabled: z.boolean().default(false), // Enable provider groupings UI
|
||||
grid_layout: z.enum(['auto', '2-col', '3-col', 'list', 'compact']).default('auto'), // Account card grid layout
|
||||
account_sort: z
|
||||
.enum(['recently-used', 'quota-overall', 'quota-claude', 'quota-pro3', 'quota-flash'])
|
||||
.default('recently-used'),
|
||||
quota_alert_enabled: z.boolean().default(false),
|
||||
quota_alert_threshold: z.number().default(20),
|
||||
proxy: ProxyConfigSchema,
|
||||
});
|
||||
|
||||
export type UpstreamProxyConfig = z.infer<typeof UpstreamProxyConfigSchema>;
|
||||
export type ProxyConfig = z.infer<typeof ProxyConfigSchema>;
|
||||
export type AppConfig = z.infer<typeof AppConfigSchema>;
|
||||
|
||||
export const DEFAULT_APP_CONFIG: AppConfig = {
|
||||
language: 'zh-CN',
|
||||
theme: 'dark',
|
||||
auto_refresh: false,
|
||||
refresh_interval: 15,
|
||||
auto_sync: false,
|
||||
sync_interval: 5,
|
||||
auto_startup: false,
|
||||
error_reporting_enabled: true, // Default to disabled for privacy
|
||||
privacy_consent_asked: false, // Whether the user has been asked for consent
|
||||
default_export_path: null,
|
||||
model_visibility: {}, // Model visibility preferences
|
||||
provider_groupings_enabled: false, // Enable provider groupings UI
|
||||
grid_layout: 'auto' as const, // Account card grid layout
|
||||
account_sort: 'recently-used' as const,
|
||||
quota_alert_enabled: false,
|
||||
quota_alert_threshold: 20,
|
||||
proxy: {
|
||||
enabled: false,
|
||||
port: 8045,
|
||||
api_key: '', // Generated dynamically if default needed
|
||||
auto_start: false,
|
||||
backend_canary_enabled: true,
|
||||
parity_enabled: false,
|
||||
parity_shadow_enabled: false,
|
||||
parity_kill_switch: false,
|
||||
parity_no_go_mismatch_rate: 0.15,
|
||||
parity_no_go_error_rate: 0.4,
|
||||
scheduling_mode: 'balance',
|
||||
max_wait_seconds: 60,
|
||||
preferred_account_id: '',
|
||||
circuit_breaker_enabled: true,
|
||||
circuit_breaker_backoff_steps: [60, 300, 1800, 7200],
|
||||
custom_mapping: {},
|
||||
anthropic_mapping: {},
|
||||
request_timeout: 120,
|
||||
upstream_proxy: {
|
||||
enabled: false,
|
||||
url: '',
|
||||
},
|
||||
},
|
||||
};
|
||||
import { z } from 'zod';
|
||||
|
||||
export const UpstreamProxyConfigSchema = z.object({
|
||||
enabled: z.boolean(),
|
||||
url: z.string(),
|
||||
});
|
||||
|
||||
export const ProxyConfigSchema = z.object({
|
||||
enabled: z.boolean(),
|
||||
port: z.number(),
|
||||
api_key: z.string(),
|
||||
auto_start: z.boolean(),
|
||||
backend_canary_enabled: z.boolean().default(true),
|
||||
parity_enabled: z.boolean().default(false),
|
||||
parity_shadow_enabled: z.boolean().default(false),
|
||||
parity_kill_switch: z.boolean().default(false),
|
||||
parity_no_go_mismatch_rate: z.number().default(0.15),
|
||||
parity_no_go_error_rate: z.number().default(0.4),
|
||||
scheduling_mode: z.enum(['cache-first', 'balance', 'performance-first']).default('balance'),
|
||||
max_wait_seconds: z.number().default(60),
|
||||
preferred_account_id: z.string().default(''),
|
||||
circuit_breaker_enabled: z.boolean().default(true),
|
||||
circuit_breaker_backoff_steps: z.array(z.number()).default([60, 300, 1800, 7200]),
|
||||
custom_mapping: z.record(z.string(), z.string()).default({}),
|
||||
anthropic_mapping: z.record(z.string(), z.string()), // Mapping table
|
||||
request_timeout: z.number().default(120), // Timeout in seconds
|
||||
upstream_proxy: UpstreamProxyConfigSchema,
|
||||
});
|
||||
|
||||
export const AppConfigSchema = z.object({
|
||||
language: z.string(),
|
||||
theme: z.string(),
|
||||
auto_refresh: z.boolean(),
|
||||
refresh_interval: z.number(), // minutes
|
||||
auto_sync: z.boolean(),
|
||||
sync_interval: z.number(), // minutes
|
||||
auto_startup: z.boolean(),
|
||||
error_reporting_enabled: z.boolean(),
|
||||
privacy_consent_asked: z.boolean().optional().default(false), // Optional for backward compatibility
|
||||
default_export_path: z.string().nullable().optional(), // Export path
|
||||
model_visibility: z.record(z.string(), z.boolean()).default({}), // Model visibility preferences
|
||||
provider_groupings_enabled: z.boolean().default(false), // Enable provider groupings UI
|
||||
grid_layout: z.enum(['auto', '2-col', '3-col', 'list', 'compact']).default('auto'), // Account card grid layout
|
||||
account_sort: z
|
||||
.enum(['recently-used', 'quota-overall', 'quota-claude', 'quota-pro3', 'quota-flash'])
|
||||
.default('recently-used'),
|
||||
quota_alert_enabled: z.boolean().default(false),
|
||||
quota_alert_threshold: z.number().default(20),
|
||||
proxy: ProxyConfigSchema,
|
||||
});
|
||||
|
||||
export type UpstreamProxyConfig = z.infer<typeof UpstreamProxyConfigSchema>;
|
||||
export type ProxyConfig = z.infer<typeof ProxyConfigSchema>;
|
||||
export type AppConfig = z.infer<typeof AppConfigSchema>;
|
||||
|
||||
export const DEFAULT_APP_CONFIG: AppConfig = {
|
||||
language: 'zh-CN',
|
||||
theme: 'dark',
|
||||
auto_refresh: false,
|
||||
refresh_interval: 15,
|
||||
auto_sync: false,
|
||||
sync_interval: 5,
|
||||
auto_startup: false,
|
||||
error_reporting_enabled: true, // Default to disabled for privacy
|
||||
privacy_consent_asked: false, // Whether the user has been asked for consent
|
||||
default_export_path: null,
|
||||
model_visibility: {}, // Model visibility preferences
|
||||
provider_groupings_enabled: false, // Enable provider groupings UI
|
||||
grid_layout: 'auto' as const, // Account card grid layout
|
||||
account_sort: 'recently-used' as const,
|
||||
quota_alert_enabled: false,
|
||||
quota_alert_threshold: 20,
|
||||
proxy: {
|
||||
enabled: false,
|
||||
port: 8045,
|
||||
api_key: '', // Generated dynamically if default needed
|
||||
auto_start: false,
|
||||
backend_canary_enabled: true,
|
||||
parity_enabled: false,
|
||||
parity_shadow_enabled: false,
|
||||
parity_kill_switch: false,
|
||||
parity_no_go_mismatch_rate: 0.15,
|
||||
parity_no_go_error_rate: 0.4,
|
||||
scheduling_mode: 'balance',
|
||||
max_wait_seconds: 60,
|
||||
preferred_account_id: '',
|
||||
circuit_breaker_enabled: true,
|
||||
circuit_breaker_backoff_steps: [60, 300, 1800, 7200],
|
||||
custom_mapping: {},
|
||||
anthropic_mapping: {},
|
||||
request_timeout: 120,
|
||||
upstream_proxy: {
|
||||
enabled: false,
|
||||
url: '',
|
||||
},
|
||||
},
|
||||
};
|
||||
+136
-136
@@ -1,136 +1,136 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const CloudAccountRowSchema = z.object({
|
||||
id: z.string(),
|
||||
provider: z.string(),
|
||||
email: z.string(),
|
||||
name: z.string().nullable(),
|
||||
avatar_url: z.string().nullable(),
|
||||
token_json: z.string(),
|
||||
quota_json: z.string().nullable(),
|
||||
device_profile_json: z.string().nullable().optional(),
|
||||
device_history_json: z.string().nullable().optional(),
|
||||
created_at: z.number(),
|
||||
last_used: z.number(),
|
||||
status: z.string().nullable(),
|
||||
is_active: z.number().int(),
|
||||
});
|
||||
|
||||
export type CloudAccountRow = z.infer<typeof CloudAccountRowSchema>;
|
||||
|
||||
export const AccountTokenRowSchema = z.object({
|
||||
id: z.string(),
|
||||
token_json: z.string(),
|
||||
quota_json: z.string().nullable(),
|
||||
});
|
||||
|
||||
export type AccountTokenRow = z.infer<typeof AccountTokenRowSchema>;
|
||||
|
||||
export const SettingsRowSchema = z.object({
|
||||
key: z.string(),
|
||||
value: z.string(),
|
||||
});
|
||||
|
||||
export type SettingsRow = z.infer<typeof SettingsRowSchema>;
|
||||
|
||||
export const SettingsValueRowSchema = z.object({
|
||||
value: z.string(),
|
||||
});
|
||||
|
||||
export type SettingsValueRow = z.infer<typeof SettingsValueRowSchema>;
|
||||
|
||||
export const ItemTableKeys = [
|
||||
'geminiNexusAuthStatus',
|
||||
'geminiNexusOnboarding',
|
||||
'geminiNexusUnifiedStateSync.oauthToken',
|
||||
'jetskiStateSync.agentManagerInitState',
|
||||
'google.geminiNexus',
|
||||
'geminiNexusUserSettings.allUserSettings',
|
||||
] as const;
|
||||
|
||||
export const ItemTableKeySchema = z.enum(ItemTableKeys);
|
||||
|
||||
export type ItemTableKey = z.infer<typeof ItemTableKeySchema>;
|
||||
|
||||
export const ItemTableRowSchema = z.object({
|
||||
key: z.string(),
|
||||
value: z.string().nullable(),
|
||||
});
|
||||
|
||||
export type ItemTableRow = z.infer<typeof ItemTableRowSchema>;
|
||||
|
||||
export const ItemTableValueRowSchema = z.object({
|
||||
value: z.string().nullable(),
|
||||
});
|
||||
|
||||
export type ItemTableValueRow = z.infer<typeof ItemTableValueRowSchema>;
|
||||
|
||||
export const TableInfoRowSchema = z.object({
|
||||
name: z.string(),
|
||||
});
|
||||
|
||||
export type TableInfoRow = z.infer<typeof TableInfoRowSchema>;
|
||||
|
||||
export const TokenUsageRowSchema = z.object({
|
||||
id: z.number(),
|
||||
account_id: z.string(),
|
||||
model: z.string(),
|
||||
prompt_tokens: z.number(),
|
||||
completion_tokens: z.number(),
|
||||
total_tokens: z.number(),
|
||||
timestamp: z.number(),
|
||||
request_type: z.string().nullable(),
|
||||
is_estimated: z.number().nullable(),
|
||||
});
|
||||
|
||||
export type TokenUsageRow = z.infer<typeof TokenUsageRowSchema>;
|
||||
|
||||
export const HourlyUsageSchema = z.object({
|
||||
bucket: z.string(),
|
||||
promptTokens: z.number(),
|
||||
completionTokens: z.number(),
|
||||
totalTokens: z.number(),
|
||||
requests: z.number(),
|
||||
});
|
||||
|
||||
export type HourlyUsage = z.infer<typeof HourlyUsageSchema>;
|
||||
|
||||
export const DailyUsageSchema = z.object({
|
||||
bucket: z.string(),
|
||||
promptTokens: z.number(),
|
||||
completionTokens: z.number(),
|
||||
totalTokens: z.number(),
|
||||
requests: z.number(),
|
||||
});
|
||||
|
||||
export type DailyUsage = z.infer<typeof DailyUsageSchema>;
|
||||
|
||||
export const WeeklyUsageSchema = z.object({
|
||||
bucket: z.string(),
|
||||
promptTokens: z.number(),
|
||||
completionTokens: z.number(),
|
||||
totalTokens: z.number(),
|
||||
requests: z.number(),
|
||||
});
|
||||
|
||||
export type WeeklyUsage = z.infer<typeof WeeklyUsageSchema>;
|
||||
|
||||
export const MonthlyUsageSchema = z.object({
|
||||
bucket: z.string(),
|
||||
promptTokens: z.number(),
|
||||
completionTokens: z.number(),
|
||||
totalTokens: z.number(),
|
||||
requests: z.number(),
|
||||
});
|
||||
|
||||
export type MonthlyUsage = z.infer<typeof MonthlyUsageSchema>;
|
||||
|
||||
export const ModelUsageSchema = z.object({
|
||||
model: z.string(),
|
||||
promptTokens: z.number(),
|
||||
completionTokens: z.number(),
|
||||
totalTokens: z.number(),
|
||||
requests: z.number(),
|
||||
});
|
||||
|
||||
export type ModelUsage = z.infer<typeof ModelUsageSchema>;
|
||||
import { z } from 'zod';
|
||||
|
||||
export const CloudAccountRowSchema = z.object({
|
||||
id: z.string(),
|
||||
provider: z.string(),
|
||||
email: z.string(),
|
||||
name: z.string().nullable(),
|
||||
avatar_url: z.string().nullable(),
|
||||
token_json: z.string(),
|
||||
quota_json: z.string().nullable(),
|
||||
device_profile_json: z.string().nullable().optional(),
|
||||
device_history_json: z.string().nullable().optional(),
|
||||
created_at: z.number(),
|
||||
last_used: z.number(),
|
||||
status: z.string().nullable(),
|
||||
is_active: z.number().int(),
|
||||
});
|
||||
|
||||
export type CloudAccountRow = z.infer<typeof CloudAccountRowSchema>;
|
||||
|
||||
export const AccountTokenRowSchema = z.object({
|
||||
id: z.string(),
|
||||
token_json: z.string(),
|
||||
quota_json: z.string().nullable(),
|
||||
});
|
||||
|
||||
export type AccountTokenRow = z.infer<typeof AccountTokenRowSchema>;
|
||||
|
||||
export const SettingsRowSchema = z.object({
|
||||
key: z.string(),
|
||||
value: z.string(),
|
||||
});
|
||||
|
||||
export type SettingsRow = z.infer<typeof SettingsRowSchema>;
|
||||
|
||||
export const SettingsValueRowSchema = z.object({
|
||||
value: z.string(),
|
||||
});
|
||||
|
||||
export type SettingsValueRow = z.infer<typeof SettingsValueRowSchema>;
|
||||
|
||||
export const ItemTableKeys = [
|
||||
'geminiNexusAuthStatus',
|
||||
'geminiNexusOnboarding',
|
||||
'geminiNexusUnifiedStateSync.oauthToken',
|
||||
'jetskiStateSync.agentManagerInitState',
|
||||
'google.geminiNexus',
|
||||
'geminiNexusUserSettings.allUserSettings',
|
||||
] as const;
|
||||
|
||||
export const ItemTableKeySchema = z.enum(ItemTableKeys);
|
||||
|
||||
export type ItemTableKey = z.infer<typeof ItemTableKeySchema>;
|
||||
|
||||
export const ItemTableRowSchema = z.object({
|
||||
key: z.string(),
|
||||
value: z.string().nullable(),
|
||||
});
|
||||
|
||||
export type ItemTableRow = z.infer<typeof ItemTableRowSchema>;
|
||||
|
||||
export const ItemTableValueRowSchema = z.object({
|
||||
value: z.string().nullable(),
|
||||
});
|
||||
|
||||
export type ItemTableValueRow = z.infer<typeof ItemTableValueRowSchema>;
|
||||
|
||||
export const TableInfoRowSchema = z.object({
|
||||
name: z.string(),
|
||||
});
|
||||
|
||||
export type TableInfoRow = z.infer<typeof TableInfoRowSchema>;
|
||||
|
||||
export const TokenUsageRowSchema = z.object({
|
||||
id: z.number(),
|
||||
account_id: z.string(),
|
||||
model: z.string(),
|
||||
prompt_tokens: z.number(),
|
||||
completion_tokens: z.number(),
|
||||
total_tokens: z.number(),
|
||||
timestamp: z.number(),
|
||||
request_type: z.string().nullable(),
|
||||
is_estimated: z.number().nullable(),
|
||||
});
|
||||
|
||||
export type TokenUsageRow = z.infer<typeof TokenUsageRowSchema>;
|
||||
|
||||
export const HourlyUsageSchema = z.object({
|
||||
bucket: z.string(),
|
||||
promptTokens: z.number(),
|
||||
completionTokens: z.number(),
|
||||
totalTokens: z.number(),
|
||||
requests: z.number(),
|
||||
});
|
||||
|
||||
export type HourlyUsage = z.infer<typeof HourlyUsageSchema>;
|
||||
|
||||
export const DailyUsageSchema = z.object({
|
||||
bucket: z.string(),
|
||||
promptTokens: z.number(),
|
||||
completionTokens: z.number(),
|
||||
totalTokens: z.number(),
|
||||
requests: z.number(),
|
||||
});
|
||||
|
||||
export type DailyUsage = z.infer<typeof DailyUsageSchema>;
|
||||
|
||||
export const WeeklyUsageSchema = z.object({
|
||||
bucket: z.string(),
|
||||
promptTokens: z.number(),
|
||||
completionTokens: z.number(),
|
||||
totalTokens: z.number(),
|
||||
requests: z.number(),
|
||||
});
|
||||
|
||||
export type WeeklyUsage = z.infer<typeof WeeklyUsageSchema>;
|
||||
|
||||
export const MonthlyUsageSchema = z.object({
|
||||
bucket: z.string(),
|
||||
promptTokens: z.number(),
|
||||
completionTokens: z.number(),
|
||||
totalTokens: z.number(),
|
||||
requests: z.number(),
|
||||
});
|
||||
|
||||
export type MonthlyUsage = z.infer<typeof MonthlyUsageSchema>;
|
||||
|
||||
export const ModelUsageSchema = z.object({
|
||||
model: z.string(),
|
||||
promptTokens: z.number(),
|
||||
completionTokens: z.number(),
|
||||
totalTokens: z.number(),
|
||||
requests: z.number(),
|
||||
});
|
||||
|
||||
export type ModelUsage = z.infer<typeof ModelUsageSchema>;
|
||||
@@ -1 +1 @@
|
||||
export type ThemeMode = 'dark' | 'light' | 'system';
|
||||
export type ThemeMode = 'dark' | 'light' | 'system';
|
||||
Reference in new issue
Block a user