/** * VectorStoreWebhookHandler - 处理 Solid Notification 触发的索引操作 * * 当 VectorStore 关联的 Container 中文件发生变化时,自动触发索引更新: * - 文件创建 (as:Create) -> 索引文件 * - 文件删除 (as:Delete) -> 删除索引 * - 文件更新 (as:Update) -> 重新索引 * * 使用方式: * 1. 用户创建 VectorStore 时,系统自动为 Container 创建 WebSocket 订阅 * 2. 当文件变化时,Solid Server 发送通知 * 3. 本 Handler 处理通知并触发相应的索引操作 */ import type { VectorStoreService } from '../service/VectorStoreService'; import type { AuthContext } from '../auth/AuthContext'; /** * Solid Notification 消息格式 (Activity Streams 2.0) */ export interface SolidNotification { '@context': string | string[]; type: 'Create' | 'Update' | 'Delete' | 'Add' | 'Remove'; actor?: { type: string; id: string; }; object: { type?: string | string[]; id: string; }; target?: { type: string; id: string; }; published: string; } export interface VectorStoreWebhookHandlerOptions { vectorStoreService: VectorStoreService; } /** * VectorStoreWebhookHandler - 处理文件变更通知 */ export declare class VectorStoreWebhookHandler { private readonly logger; private readonly vectorStoreService; constructor(options: VectorStoreWebhookHandlerOptions); /** * 处理 Solid Notification * * @param notification Solid Notification 消息 * @param auth 认证上下文 * @param accessToken 访问令牌 */ handleNotification(notification: SolidNotification, auth: AuthContext, accessToken: string): Promise; /** * 处理文件创建或更新 * 注意:文件只索引一份,VectorStore 只是用来定位分块策略 */ private handleFileCreatedOrUpdated; /** * 处理文件删除 * 注意:文件只索引一份,删除时直接按 fileUrl 删除 */ private handleFileDeleted; /** * 从文件 URL 提取容器 URL */ private extractContainerUrl; } /** * 创建 WebSocket 订阅配置 * * 用于订阅 Container 的文件变更通知 */ export declare function createSubscriptionRequest(containerUrl: string): object;