semblance/src/types/cancellable.ts
2025-12-19 19:26:16 +00:00

93 lines
No EOL
2 KiB
TypeScript
Executable file

/**
* Type definitions for cancellable operations and task management.
*/
export interface CancellableResponse<T = any> {
task_id: string;
[key: string]: any;
}
export interface TaskCancellationRequest {
task_id: string;
}
export interface TaskCancellationResponse {
success: boolean;
message?: string;
error?: string;
task_id: string;
task_type?: string;
}
export interface WebSocketTaskEvent {
type: 'task_cancelled' | 'task_completed' | 'task_failed';
task_id: string;
task_type: string;
message: string;
data?: any;
}
export interface CancellableGenerationHookState {
isGenerating: boolean;
isCancelling: boolean;
hasError: boolean;
isComplete: boolean;
taskId: string | null;
error: string | null;
}
export interface GenerationProgressProps {
isActive: boolean;
isComplete: boolean;
hasError: boolean;
isCancelling: boolean;
label?: string;
onComplete?: () => void;
onCancel?: () => void;
showCancel?: boolean;
taskId?: string;
className?: string;
}
// Common response interfaces for generation endpoints
export interface PersonaGenerationResponse extends CancellableResponse {
message: string;
personas?: any[];
persona?: any;
profiles?: any[];
}
export interface DiscussionGuideResponse extends CancellableResponse {
message: string;
discussionGuide: any;
success: boolean;
}
export interface KeyThemesResponse extends CancellableResponse {
message: string;
themes: any[];
focus_group_id: string;
}
export interface PersonaModificationResponse extends CancellableResponse {
success: boolean;
message: string;
persona: any;
preview_only: boolean;
}
export interface SummaryGenerationResponse extends CancellableResponse {
message: string;
summaries: any[];
summary_stats: {
total_requested: number;
total_found: number;
total_successful: number;
total_failed: number;
missing_personas: number;
};
errors?: {
failed_summaries: any[];
missing_personas: string[];
};
}