feat: AI Worker 平台 MVP v1.0.0 - 多租户/项目管理/AI Worker/任务编排/HITL审核/成本治理
This commit is contained in:
@@ -0,0 +1,283 @@
|
|||||||
|
// ============ User & Auth ============
|
||||||
|
|
||||||
|
export type UserRole = 'super_admin' | 'tenant_admin' | 'project_manager' | 'reviewer' | 'worker';
|
||||||
|
|
||||||
|
export interface User {
|
||||||
|
id: number;
|
||||||
|
email: string;
|
||||||
|
username: string;
|
||||||
|
role: UserRole;
|
||||||
|
user_type: string;
|
||||||
|
tenant_id: number;
|
||||||
|
is_active: boolean;
|
||||||
|
avatar?: string;
|
||||||
|
phone?: string;
|
||||||
|
worker_id?: number;
|
||||||
|
created_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AuthResponse {
|
||||||
|
access_token: string;
|
||||||
|
token_type?: string;
|
||||||
|
user: User;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LoginPayload {
|
||||||
|
email: string;
|
||||||
|
password: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RegisterPayload {
|
||||||
|
email: string;
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
role: string;
|
||||||
|
tenant_slug: string;
|
||||||
|
tenant_name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============ Tenant ============
|
||||||
|
|
||||||
|
export interface Tenant {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
slug: string;
|
||||||
|
description?: string;
|
||||||
|
is_active: boolean;
|
||||||
|
created_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TenantCreate {
|
||||||
|
name: string;
|
||||||
|
slug: string;
|
||||||
|
description?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============ Project ============
|
||||||
|
|
||||||
|
export type ProjectStatus = 'draft' | 'planning' | 'in_progress' | 'review' | 'accepted' | 'archived';
|
||||||
|
|
||||||
|
export interface Project {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
status: string;
|
||||||
|
owner_id: number;
|
||||||
|
tenant_id: number;
|
||||||
|
start_date?: string;
|
||||||
|
end_date?: string;
|
||||||
|
budget_limit_cents?: number;
|
||||||
|
acceptance_criteria: string;
|
||||||
|
tags: string;
|
||||||
|
created_at: string;
|
||||||
|
updated_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ProjectCreate {
|
||||||
|
name: string;
|
||||||
|
description?: string;
|
||||||
|
start_date?: string;
|
||||||
|
end_date?: string;
|
||||||
|
budget_limit_cents?: number;
|
||||||
|
acceptance_criteria?: string;
|
||||||
|
tags?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ProjectStats {
|
||||||
|
total_tasks: number;
|
||||||
|
pending_tasks: number;
|
||||||
|
in_progress_tasks: number;
|
||||||
|
review_tasks: number;
|
||||||
|
done_tasks: number;
|
||||||
|
total_cost_cents: number;
|
||||||
|
total_artifacts: number;
|
||||||
|
pending_reviews: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============ Task ============
|
||||||
|
|
||||||
|
export type TaskStatus =
|
||||||
|
| 'pending'
|
||||||
|
| 'assigned'
|
||||||
|
| 'in_progress'
|
||||||
|
| 'review'
|
||||||
|
| 'done'
|
||||||
|
| 'rejected'
|
||||||
|
| 'cancelled';
|
||||||
|
|
||||||
|
export type TaskPriority = 'low' | 'medium' | 'high' | 'urgent';
|
||||||
|
|
||||||
|
export interface Task {
|
||||||
|
id: number;
|
||||||
|
project_id: number;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
status: TaskStatus;
|
||||||
|
priority: TaskPriority;
|
||||||
|
assignee_id?: number;
|
||||||
|
worker_id?: number;
|
||||||
|
task_type: string;
|
||||||
|
input_data: string;
|
||||||
|
output_data?: string;
|
||||||
|
requires_review: boolean;
|
||||||
|
review_status?: string;
|
||||||
|
due_date?: string;
|
||||||
|
started_at?: string;
|
||||||
|
completed_at?: string;
|
||||||
|
tenant_id: number;
|
||||||
|
created_at: string;
|
||||||
|
updated_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TaskCreate {
|
||||||
|
title: string;
|
||||||
|
description?: string;
|
||||||
|
priority?: TaskPriority;
|
||||||
|
task_type?: string;
|
||||||
|
input_data?: string;
|
||||||
|
requires_review?: boolean;
|
||||||
|
assignee_id?: number;
|
||||||
|
worker_id?: number;
|
||||||
|
due_date?: string;
|
||||||
|
depends_on?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TaskAssignPayload {
|
||||||
|
assignee_id?: number;
|
||||||
|
worker_id?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TaskExecutePayload {
|
||||||
|
override_input?: string;
|
||||||
|
max_retries?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ExecutionResult {
|
||||||
|
task_id: number;
|
||||||
|
status: string;
|
||||||
|
output: string;
|
||||||
|
token_usage: number;
|
||||||
|
cost_cents: number;
|
||||||
|
duration_ms: number;
|
||||||
|
error?: string;
|
||||||
|
artifact_id?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============ Worker ============
|
||||||
|
|
||||||
|
export interface Worker {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
provider: string;
|
||||||
|
model_name: string;
|
||||||
|
base_url?: string;
|
||||||
|
temperature: number;
|
||||||
|
system_prompt: string;
|
||||||
|
tools: string;
|
||||||
|
max_cost_per_task_cents?: number;
|
||||||
|
max_cost_per_month_cents?: number;
|
||||||
|
status: string;
|
||||||
|
is_active: boolean;
|
||||||
|
current_task_count: number;
|
||||||
|
max_concurrent_tasks: number;
|
||||||
|
tenant_id: number;
|
||||||
|
created_at: string;
|
||||||
|
updated_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WorkerCreate {
|
||||||
|
name: string;
|
||||||
|
description?: string;
|
||||||
|
provider: string;
|
||||||
|
model_name: string;
|
||||||
|
api_key?: string;
|
||||||
|
base_url?: string;
|
||||||
|
temperature?: number;
|
||||||
|
system_prompt?: string;
|
||||||
|
tools?: string;
|
||||||
|
max_cost_per_task_cents?: number;
|
||||||
|
max_cost_per_month_cents?: number;
|
||||||
|
available_hours?: string;
|
||||||
|
max_concurrent_tasks?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WorkerTestResult {
|
||||||
|
success: boolean;
|
||||||
|
response: string;
|
||||||
|
latency_ms: number;
|
||||||
|
error?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============ Review ============
|
||||||
|
|
||||||
|
export interface Review {
|
||||||
|
id: number;
|
||||||
|
task_id: number;
|
||||||
|
project_id: number;
|
||||||
|
review_type: string;
|
||||||
|
status: string;
|
||||||
|
reviewer_id?: number;
|
||||||
|
reviewer_role?: string;
|
||||||
|
review_content: string;
|
||||||
|
reviewer_comment: string;
|
||||||
|
auto_check_result: string;
|
||||||
|
submitted_at: string;
|
||||||
|
reviewed_at?: string;
|
||||||
|
tenant_id: number;
|
||||||
|
created_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ReviewDecisionPayload {
|
||||||
|
comment: string;
|
||||||
|
status: 'approved' | 'rejected';
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============ Artifact ============
|
||||||
|
|
||||||
|
export interface Artifact {
|
||||||
|
id: number;
|
||||||
|
task_id: number;
|
||||||
|
project_id: number;
|
||||||
|
title: string;
|
||||||
|
content: string;
|
||||||
|
artifact_type: string;
|
||||||
|
version: number;
|
||||||
|
is_latest: string;
|
||||||
|
created_by_user_id?: number;
|
||||||
|
created_by_worker_id?: number;
|
||||||
|
sources: string;
|
||||||
|
tenant_id: number;
|
||||||
|
created_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============ Dashboard ============
|
||||||
|
|
||||||
|
export interface DashboardStats {
|
||||||
|
projects: number;
|
||||||
|
tasks: number;
|
||||||
|
active_workers: number;
|
||||||
|
pending_reviews: number;
|
||||||
|
task_status: Record<string, number>;
|
||||||
|
cost: {
|
||||||
|
total_cost_cents: number;
|
||||||
|
total_calls: number;
|
||||||
|
by_model: Array<{
|
||||||
|
model: string;
|
||||||
|
cost_cents: number;
|
||||||
|
tokens: number;
|
||||||
|
calls: number;
|
||||||
|
}>;
|
||||||
|
};
|
||||||
|
user: {
|
||||||
|
id: number;
|
||||||
|
username: string;
|
||||||
|
role: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============ Generic ============
|
||||||
|
|
||||||
|
export interface ApiError {
|
||||||
|
detail: string;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user