import { Plugin, PluginContext } from '@objectstack/core'; import { IKnowledgeAdapter, AdapterContext, AdapterSearchOptions } from '@objectstack/spec/contracts'; import { KnowledgeDocument, KnowledgeHit } from '@objectstack/spec/ai'; /** * Subset of `fetch` used by the adapter. Inject in tests; defaults to * the global `fetch`. */ type FetchLike = (input: string, init?: { method?: string; headers?: Record; body?: string; signal?: AbortSignal; }) => Promise<{ ok: boolean; status: number; statusText: string; text(): Promise; json(): Promise; }>; interface KnowledgeRagflowAdapterOptions { /** RAGFlow endpoint, e.g. `http://localhost:9380`. */ endpoint: string; /** RAGFlow API key (Bearer token). */ apiKey: string; /** Adapter id. @default 'ragflow' */ id?: string; /** Override `fetch` for tests. */ fetch?: FetchLike; /** Request timeout in milliseconds. @default 30000 */ timeoutMs?: number; } /** * RAGFlow adapter. Maps {@link KnowledgeDocument} upserts to the * dataset's chunk API, delegates retrieval to `/api/v1/retrieval`, and * returns {@link KnowledgeHit}s with `sourceRecordId` preserved so the * orchestrator can run a permission re-check. */ declare class KnowledgeRagflowAdapter implements IKnowledgeAdapter { readonly id: string; private readonly endpoint; private readonly apiKey; private readonly fetchImpl; private readonly timeoutMs; constructor(opts: KnowledgeRagflowAdapterOptions); upsert(docs: KnowledgeDocument[], ctx: AdapterContext): Promise; delete(documentIds: string[], ctx: AdapterContext): Promise; search(query: string, opts: AdapterSearchOptions): Promise; healthCheck(): Promise<{ ok: boolean; message?: string; }>; private deleteChunksByDocumentId; private request; } interface KnowledgeRagflowPluginOptions extends KnowledgeRagflowAdapterOptions { } declare class KnowledgeRagflowPlugin implements Plugin { name: string; version: string; type: string; private readonly adapter; constructor(opts: KnowledgeRagflowPluginOptions); init(_ctx: PluginContext): Promise; start(ctx: PluginContext): Promise; } export { type FetchLike, KnowledgeRagflowAdapter, type KnowledgeRagflowAdapterOptions, KnowledgeRagflowPlugin, type KnowledgeRagflowPluginOptions };