519 lines
11 KiB
TypeScript
519 lines
11 KiB
TypeScript
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;
|
|
spaceQuotaBytes?: number;
|
|
spaceUsedBytes?: number;
|
|
spaceReservedBytes?: number;
|
|
spaceAvailableBytes?: 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;
|
|
isVisionSelected: 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 LlmVisionSettings = {
|
|
keyId: string | null;
|
|
keyName: string | null;
|
|
providerLabel: string | null;
|
|
visionModel: string | null;
|
|
availableModels: string[];
|
|
};
|
|
|
|
export type LlmConnectionTestResult = {
|
|
ok: boolean;
|
|
latencyMs?: number;
|
|
reply?: string;
|
|
model?: string;
|
|
message?: string;
|
|
};
|
|
|
|
export type LlmExecutorId = 'goose' | 'aider' | 'openhands';
|
|
|
|
export type LlmExecutorBinding = {
|
|
id: string | null;
|
|
executor: LlmExecutorId;
|
|
executorLabel: string;
|
|
executorDescription: string;
|
|
purpose: string;
|
|
providerKeyId: string | null;
|
|
providerName: string | null;
|
|
providerLabel: string | null;
|
|
providerId: string | null;
|
|
model: string;
|
|
enabled: boolean;
|
|
availableModels: string[];
|
|
createdAt: number | null;
|
|
updatedAt: number | null;
|
|
};
|
|
|
|
export type LlmExecutorRuntime = {
|
|
ok: boolean;
|
|
executor: LlmExecutorId;
|
|
executorLabel?: string;
|
|
purpose?: string;
|
|
providerKeyId?: string;
|
|
providerName?: string;
|
|
providerKind?: string;
|
|
providerId?: string;
|
|
providerLabel?: string;
|
|
goosedProviderId?: string | null;
|
|
model?: string;
|
|
apiUrl?: string | null;
|
|
apiBaseUrl?: string;
|
|
apiKeyMasked?: string;
|
|
env?: Record<string, string>;
|
|
message?: string;
|
|
};
|
|
|
|
export type LlmExecutorLaunchPlan = {
|
|
ok: boolean;
|
|
executor: LlmExecutorId | null;
|
|
cwd?: string;
|
|
command?: string;
|
|
args?: string[];
|
|
env?: Record<string, string>;
|
|
notes?: string[];
|
|
message?: string;
|
|
};
|
|
|
|
export type LlmExecutorLaunchState = {
|
|
executor: LlmExecutorId;
|
|
purpose: string;
|
|
pid: number | null;
|
|
running: boolean;
|
|
command: string | null;
|
|
args: string[];
|
|
cwd: string | null;
|
|
logFile: string | null;
|
|
startedAt: number | null;
|
|
stoppedAt: number | null;
|
|
exitReason: string | null;
|
|
mode: string | null;
|
|
instruction: string | null;
|
|
};
|
|
|
|
export type AssetPluginConfig = {
|
|
pluginId: string;
|
|
label: string;
|
|
description: string;
|
|
providers: string[];
|
|
supportsLlm: boolean;
|
|
enabled: boolean;
|
|
provider: string | null;
|
|
llmProviderKeyId: string | null;
|
|
llmProviderName: string | null;
|
|
llmProviderId: string | null;
|
|
llmModel: string | null;
|
|
updatedAt: number | null;
|
|
};
|
|
|
|
export type AssetGatewayConfig = {
|
|
enabled: boolean;
|
|
updatedAt: number | null;
|
|
plugins: AssetPluginConfig[];
|
|
};
|
|
|
|
export type AdminServiceRestartAction = 'local_restart' | 'pro_restart';
|
|
|
|
export type AdminServiceRestartResult = {
|
|
ok: boolean;
|
|
action: AdminServiceRestartAction;
|
|
message: string;
|
|
pid?: number | null;
|
|
output?: string;
|
|
logFile?: string | null;
|
|
};
|
|
|
|
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 WechatAdminSummary = {
|
|
config: {
|
|
mpEnabled: boolean;
|
|
scheduleEnabled: boolean;
|
|
reminderWorkerEnabled: boolean;
|
|
appId: string | null;
|
|
publicBaseUrl: string | null;
|
|
bindPath: string | null;
|
|
tokenEndpointConfigured: boolean;
|
|
customerServiceEndpointConfigured: boolean;
|
|
scheduleLlmEnabled: boolean;
|
|
};
|
|
counts: {
|
|
boundUsers: number;
|
|
routes: { total: number; active: number };
|
|
recentMessages: Record<string, number>;
|
|
digests: Record<string, number>;
|
|
recentDeliveries: Record<string, number>;
|
|
};
|
|
};
|
|
|
|
export type WechatScheduleLlmConfig = {
|
|
scheduleLlmEnabled: boolean;
|
|
updatedAt: number | null;
|
|
updatedBy: string | null;
|
|
};
|
|
|
|
export type MindSpaceAdminConfig = {
|
|
publicPageLimit: number;
|
|
};
|
|
|
|
export type MemoryV2AdminSection = Record<string, string | boolean>;
|
|
export type MemoryV2ModelApiType = 'chat' | 'response';
|
|
|
|
export type MemoryV2AdminConfig = {
|
|
global: {
|
|
enabled?: boolean;
|
|
backend?: string;
|
|
profileEnabled?: boolean;
|
|
eventLogEnabled?: boolean;
|
|
vectorEnabled?: boolean;
|
|
failOpen?: boolean;
|
|
};
|
|
chatIntentRouter: MemoryV2AdminSection;
|
|
pgvector: MemoryV2AdminSection;
|
|
qdrant: MemoryV2AdminSection;
|
|
weaviate: MemoryV2AdminSection;
|
|
mem0: MemoryV2AdminSection;
|
|
letta: MemoryV2AdminSection;
|
|
neo4j: MemoryV2AdminSection;
|
|
redisStreams: MemoryV2AdminSection;
|
|
langgraph: MemoryV2AdminSection;
|
|
};
|
|
|
|
export type MemoryV2AdminConfigResponse = {
|
|
config: MemoryV2AdminConfig;
|
|
updatedAt: number | null;
|
|
updatedBy: string | null;
|
|
};
|
|
|
|
export type AdminSystemTestStepStatus = 'passed' | 'warning' | 'failed';
|
|
|
|
export type AdminSystemTestStep = {
|
|
key: string;
|
|
label: string;
|
|
status: AdminSystemTestStepStatus;
|
|
message: string;
|
|
details?: Record<string, unknown> | null;
|
|
};
|
|
|
|
export type AdminSystemTestIssue = {
|
|
stepKey: string;
|
|
severity: 'warning' | 'error';
|
|
title: string;
|
|
detail: string;
|
|
};
|
|
|
|
export type AdminSystemTestReport = {
|
|
ok: boolean;
|
|
startedAt: number;
|
|
finishedAt: number;
|
|
portalBaseUrl: string;
|
|
selectedSkill: string;
|
|
account: {
|
|
userId?: string;
|
|
username: string;
|
|
displayName?: string | null;
|
|
};
|
|
summary: {
|
|
passed: number;
|
|
warnings: number;
|
|
failed: number;
|
|
};
|
|
steps: AdminSystemTestStep[];
|
|
issues: AdminSystemTestIssue[];
|
|
};
|
|
|
|
export type AdminSystemTestAccount = {
|
|
id: string;
|
|
label: string;
|
|
username: string;
|
|
passwordMasked: string;
|
|
createdAt: number;
|
|
updatedAt: number;
|
|
updatedBy?: string | null;
|
|
};
|
|
|
|
export type WechatBinding = {
|
|
userId: string;
|
|
username: string;
|
|
displayName: string;
|
|
status: string;
|
|
appId: string | null;
|
|
openidMasked: string;
|
|
nickname: string | null;
|
|
avatarUrl: string | null;
|
|
lastLoginAt: number;
|
|
boundAt: number;
|
|
routeId: string | null;
|
|
routeStatus: string | null;
|
|
agentSessionId: string | null;
|
|
routeUpdatedAt: number | null;
|
|
};
|
|
|
|
export type WechatMessage = {
|
|
appId: string | null;
|
|
openidMasked: string;
|
|
msgId: string;
|
|
status: string;
|
|
agentSessionId: string | null;
|
|
createdAt: number;
|
|
updatedAt: number;
|
|
userId: string | null;
|
|
username: string | null;
|
|
displayName: string | null;
|
|
};
|
|
|
|
export type WechatDigestSubscription = {
|
|
id: string;
|
|
userId: string;
|
|
username: string;
|
|
displayName: string;
|
|
digestType: string;
|
|
hour: number;
|
|
minute: number;
|
|
timezone: string;
|
|
channel: string;
|
|
status: string;
|
|
nextRunAt: number;
|
|
lastRunAt: number | null;
|
|
attempts: number;
|
|
lastError: string | null;
|
|
sourceText: string | null;
|
|
createdAt: number;
|
|
updatedAt: number;
|
|
};
|
|
|
|
export type WechatDeliveryLog = {
|
|
id: string;
|
|
reminderId: string | null;
|
|
subscriptionId: string | null;
|
|
userId: string;
|
|
username: string;
|
|
displayName: string;
|
|
channel: string;
|
|
status: string;
|
|
providerMessageId: string | null;
|
|
errorCode: string | null;
|
|
errorMessage: string | null;
|
|
createdAt: number;
|
|
digestType: string | null;
|
|
};
|
|
|
|
export type WechatWebNotification = {
|
|
id: string;
|
|
userId: string;
|
|
username: string;
|
|
displayName: string;
|
|
channel: string;
|
|
notificationType: string;
|
|
title: string;
|
|
body: string;
|
|
status: string;
|
|
readAt: number | null;
|
|
createdAt: number;
|
|
updatedAt: 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;
|
|
};
|
|
|
|
|
|
export type BlockedWord = {
|
|
id: string;
|
|
word: string;
|
|
replacement: string;
|
|
note: string | null;
|
|
status: 'active' | 'disabled';
|
|
created_at: number;
|
|
updated_at: number;
|
|
};
|
|
|
|
export type PlanDefinition = {
|
|
planType: string;
|
|
name: string;
|
|
priceCents: number;
|
|
periodDays: number;
|
|
periodTokens: number;
|
|
periodImages: number;
|
|
modelTier: string;
|
|
overageRate: number;
|
|
sortOrder: number;
|
|
isActive: boolean;
|
|
description: string | null;
|
|
};
|
|
|
|
export type PlanSyncResult = {
|
|
enabled: boolean;
|
|
ok: boolean;
|
|
message: string;
|
|
synced?: number;
|
|
total?: number;
|
|
failures?: string[];
|
|
};
|
|
|
|
export type AdminSubscription = {
|
|
id: string;
|
|
userId: string;
|
|
username: string;
|
|
displayName: string;
|
|
planType: string;
|
|
status: 'active' | 'expired' | 'cancelled';
|
|
startedAt: number;
|
|
expiresAt: number;
|
|
periodTokensLimit: number;
|
|
periodTokensUsed: number;
|
|
periodImagesLimit: number;
|
|
periodImagesUsed: number;
|
|
note: string | null;
|
|
createdAt: number;
|
|
};
|