mirror of
https://github.com/andy-stack/vaultkeeper-ai.git
synced 2026-07-22 06:42:03 +00:00
Implement a comprehensive diff viewing system that allows users to review and approve/reject file changes before they're applied. The system includes event-driven architecture for managing diff lifecycle and integrates diff2html for rich visual diffs. Key changes: - Add DiffService for managing diff approval workflow with accept/reject/suggest actions - Create EventService for type-safe event handling (DiffOpened/DiffClosed) - Add DiffView component with diff2html integration for visual diff rendering - Modify VaultService to propose changes and require confirmation before file operations - Update FileSystemService to support optional confirmation for write operations - Add Event enum for centralized event type definitions - Import custom styles and diff2html styles for proper diff rendering - Update ConversationContent validation to support optional toolId field - Remove FileManager from dependency injection (now accessed directly from app) - Update .gitignore to track styles.css instead of main.css
53 lines
No EOL
2.1 KiB
TypeScript
53 lines
No EOL
2.1 KiB
TypeScript
import { Role } from "Enums/Role";
|
|
import { ApiErrorType } from "Types/ApiError";
|
|
|
|
export class ConversationContent {
|
|
role: Role;
|
|
content: string;
|
|
promptContent: string;
|
|
functionCall: string;
|
|
timestamp: Date;
|
|
isFunctionCall: boolean;
|
|
isFunctionCallResponse: boolean;
|
|
toolId?: string;
|
|
errorType?: ApiErrorType;
|
|
|
|
constructor(role: Role, content: string = "", promptContent: string = "", functionCall: string = "", timestamp: Date = new Date(), isFunctionCall = false, isFunctionCallResponse = false, toolId?: string, errorType?: ApiErrorType) {
|
|
this.role = role;
|
|
this.content = content;
|
|
this.promptContent = promptContent;
|
|
this.functionCall = functionCall;
|
|
this.timestamp = timestamp;
|
|
this.isFunctionCall = isFunctionCall;
|
|
this.isFunctionCallResponse = isFunctionCallResponse;
|
|
this.toolId = toolId;
|
|
this.errorType = errorType;
|
|
}
|
|
|
|
public static isConversationContentData(this: void, data: unknown): data is {
|
|
role: string; content: string; promptContent: string; functionCall: string; timestamp: string, isFunctionCall: boolean, isFunctionCallResponse: boolean, toolId?: string, errorType?: string
|
|
} {
|
|
return (
|
|
data !== null &&
|
|
typeof data === "object" &&
|
|
"role" in data &&
|
|
"content" in data &&
|
|
"promptContent" in data &&
|
|
"functionCall" in data &&
|
|
"timestamp" in data &&
|
|
"isFunctionCall" in data &&
|
|
"isFunctionCallResponse" in data &&
|
|
typeof data.role === "string" &&
|
|
typeof data.content === "string" &&
|
|
typeof data.promptContent === "string" &&
|
|
typeof data.functionCall === "string" &&
|
|
typeof data.timestamp === "string" &&
|
|
typeof data.isFunctionCall === "boolean" &&
|
|
typeof data.isFunctionCallResponse === "boolean" &&
|
|
|
|
// optional conversation data fields
|
|
(!("toolId" in data) || typeof data.toolId === "string") &&
|
|
(!("errorType" in data) || typeof data.errorType === "string")
|
|
);
|
|
}
|
|
} |