2025-03-28 21:04:12 +00:00
|
|
|
/**
|
|
|
|
* Interface for note data in cache
|
|
|
|
*/
|
|
|
|
export interface CachedNoteData<T> {
|
|
|
|
timestamp: number;
|
|
|
|
data: T;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface for query results in cache
|
|
|
|
*/
|
|
|
|
export interface CachedQueryResults<T> {
|
|
|
|
timestamp: number;
|
|
|
|
results: T;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface for cache manager
|
|
|
|
*/
|
|
|
|
export interface ICacheManager {
|
|
|
|
getNoteData<T>(noteId: string, type: string): T | null;
|
|
|
|
storeNoteData<T>(noteId: string, type: string, data: T): void;
|
|
|
|
getQueryResults<T>(query: string, contextNoteId: string | null): T | null;
|
|
|
|
storeQueryResults<T>(query: string, results: T, contextNoteId: string | null): void;
|
|
|
|
cleanupCache(): void;
|
|
|
|
clearAllCaches(): void;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface for note data in search results
|
|
|
|
*/
|
|
|
|
export interface NoteSearchResult {
|
|
|
|
noteId: string;
|
|
|
|
title: string;
|
2025-04-08 21:24:56 +00:00
|
|
|
content: string | null;
|
2025-03-28 21:04:12 +00:00
|
|
|
similarity: number;
|
|
|
|
parentId?: string;
|
2025-04-08 21:24:56 +00:00
|
|
|
parentPath?: string;
|
|
|
|
type?: string;
|
|
|
|
mime?: string;
|
2025-03-28 21:04:12 +00:00
|
|
|
parentTitle?: string;
|
|
|
|
dateCreated?: string;
|
|
|
|
dateModified?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface for context formatter
|
|
|
|
*/
|
|
|
|
export interface IContextFormatter {
|
2025-03-30 22:13:40 +00:00
|
|
|
buildContextFromNotes(
|
|
|
|
sources: NoteSearchResult[],
|
|
|
|
query: string,
|
|
|
|
providerId?: string,
|
|
|
|
messages?: Array<{role: string, content: string}>
|
|
|
|
): Promise<string>;
|
2025-03-28 21:04:12 +00:00
|
|
|
}
|
|
|
|
|
2025-04-16 17:07:54 +00:00
|
|
|
/**
|
|
|
|
* Interface for LLM Service
|
|
|
|
*/
|
|
|
|
export interface ILLMService {
|
|
|
|
sendMessage(message: string, options?: Record<string, unknown>): Promise<string>;
|
|
|
|
streamMessage?(message: string, callback: (text: string) => void, options?: Record<string, unknown>): Promise<string>;
|
|
|
|
}
|
|
|
|
|
2025-03-28 21:04:12 +00:00
|
|
|
/**
|
|
|
|
* Interface for query enhancer
|
|
|
|
*/
|
|
|
|
export interface IQueryEnhancer {
|
2025-04-16 17:07:54 +00:00
|
|
|
generateSearchQueries(question: string, llmService: ILLMService): Promise<string[]>;
|
2025-04-08 21:24:56 +00:00
|
|
|
estimateQueryComplexity(query: string): number;
|
2025-03-28 21:04:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface for content chunk
|
|
|
|
*/
|
|
|
|
export interface ContentChunk {
|
|
|
|
content: string;
|
|
|
|
metadata?: Record<string, unknown>;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface for note chunk
|
|
|
|
*/
|
|
|
|
export interface NoteChunk {
|
|
|
|
noteId: string;
|
|
|
|
title: string;
|
|
|
|
content: string;
|
|
|
|
type?: string;
|
|
|
|
metadata?: Record<string, unknown>;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface for content chunking service
|
|
|
|
*/
|
|
|
|
export interface IContentChunker {
|
|
|
|
chunkContent(content: string, metadata?: Record<string, unknown>): ContentChunk[];
|
|
|
|
chunkNoteContent(noteId: string, content: string, title: string): Promise<NoteChunk[]>;
|
|
|
|
}
|
2025-04-08 21:24:56 +00:00
|
|
|
|
2025-04-16 17:07:54 +00:00
|
|
|
/**
|
|
|
|
* Options for context service
|
|
|
|
*/
|
|
|
|
export interface ContextServiceOptions {
|
|
|
|
maxResults?: number;
|
|
|
|
summarize?: boolean;
|
|
|
|
llmService?: ILLMService;
|
|
|
|
}
|
|
|
|
|
2025-04-08 21:24:56 +00:00
|
|
|
/**
|
|
|
|
* Interface for context service
|
|
|
|
*/
|
|
|
|
export interface IContextService {
|
|
|
|
initialize(): Promise<void>;
|
|
|
|
processQuery(
|
|
|
|
userQuestion: string,
|
2025-04-16 17:07:54 +00:00
|
|
|
llmService: ILLMService,
|
2025-04-08 21:24:56 +00:00
|
|
|
contextNoteId?: string | null,
|
|
|
|
showThinking?: boolean
|
|
|
|
): Promise<{ context: string; sources: NoteSearchResult[]; thinking?: string }>;
|
|
|
|
findRelevantNotes(
|
|
|
|
query: string,
|
|
|
|
contextNoteId?: string | null,
|
2025-04-16 17:07:54 +00:00
|
|
|
options?: ContextServiceOptions
|
2025-04-08 21:24:56 +00:00
|
|
|
): Promise<NoteSearchResult[]>;
|
|
|
|
}
|