Initial commit: tkmind admin frontend (React + Vite).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-06-16 19:44:31 +08:00
commit 8ad1a8a8da
30 changed files with 5981 additions and 0 deletions
+169
View File
@@ -0,0 +1,169 @@
export type InsufficientBalanceDetails = {
code: 'INSUFFICIENT_BALANCE';
balanceCents: number;
minRechargeCents: number;
suggestedTiers: number[];
};
export type PortalUser = {
id: string;
username: string;
slug?: string;
email?: string | null;
displayName: string;
role: 'user' | 'admin';
status: 'active' | 'suspended' | 'disabled';
planType?: 'free' | 'growth' | 'pro' | 'enterprise';
workspaceRoot: string;
balanceCents: number;
totalCreditCents?: number;
tokensUsed: number;
publishSlug?: string;
publishUrl?: string;
publishSkillName?: string;
};
export type CapabilityMap = Record<string, boolean>;
export type PolicyValue = string | boolean;
export type PolicyMap = Record<string, PolicyValue>;
export type SkillMap = Record<string, boolean>;
export type AuthStatus = {
authenticated: boolean;
mode?: 'user' | 'legacy' | 'none';
user?: PortalUser | null;
capabilities?: CapabilityMap;
grantedSkills?: string[];
unrestricted?: boolean;
};
export type AdminUserRow = PortalUser & {
createdAt: number;
updatedAt: number;
};
export type CapabilityDefinition = {
key: string;
label: string;
description: string;
risk: 'low' | 'medium' | 'high';
category: string;
};
export type SkillDefinition = {
name: string;
dirName: string;
label: string;
description: string;
category: string;
requiresPublish?: boolean;
};
export type PolicyDefinition = {
key: string;
label: string;
description: string;
type: 'select' | 'boolean';
options?: Array<{ value: string; label: string }>;
defaultValue: PolicyValue;
category: string;
risk: 'low' | 'medium' | 'high';
};
export type LlmProviderDefinition = {
id: string;
label: string;
kind?: 'builtin' | 'custom';
apiKeyEnv: string | null;
defaultModel: string;
models: string[];
};
export type LlmProviderKeyRow = {
id: string;
providerId: string;
providerKind: 'builtin' | 'custom';
providerLabel: string;
name: string;
defaultModel: string;
models: string[];
apiUrl: string | null;
basePath: string | null;
engine: string;
relayProvider: string | null;
goosedProviderId: string | null;
status: 'active' | 'disabled';
isSelected: boolean;
apiKeyMasked: string;
createdAt: number;
updatedAt: number;
};
export type LlmGlobalSettings = {
keyId: string | null;
keyName: string | null;
providerLabel: string | null;
globalModel: string | null;
availableModels: string[];
};
export type LlmConnectionTestResult = {
ok: boolean;
latencyMs?: number;
reply?: string;
model?: string;
message?: string;
};
export type UsageRecord = {
id: number;
userId: string;
username: string;
agentSessionId: string;
requestId: string | null;
inputTokens: number;
outputTokens: number;
costCents: number;
balanceAfterCents: number;
createdAt: number;
};
export type LedgerEntry = {
id: number;
userId: string;
username: string;
type: 'recharge' | 'deduct' | 'refund' | 'adjust';
amountCents: number;
tokens: number;
sessionId: string | null;
note: string | null;
createdAt: number;
};
export type AdminDashboardSummary = {
users: {
total: number;
active: number;
lowBalance: number;
totalBalanceCents: number;
};
usage24h: {
count: number;
costCents: number;
};
lowBalanceUsers: Array<{
id: string;
username: string;
displayName: string;
balanceCents: number;
}>;
recentUsage: UsageRecord[];
recentLedger: LedgerEntry[];
llm: {
keyCount: number;
selectedKeyName: string | null;
globalModel: string | null;
} | null;
};