/** * @license * Copyright 2025 Steven Roussey * SPDX-License-Identifier: Apache-2.0 */ import { CreateWorkflow, IExecuteContext, Task } from "@workglow/task-graph"; import type { IRunConfig, TaskConfig } from "@workglow/task-graph"; import { DataPortSchema } from "@workglow/util/schema"; import type { Capability } from "../capability/Capabilities"; export type RerankerTaskInput = { metadata?: { [x: string]: unknown; }[] | undefined; scores?: number[] | undefined; topK?: number | undefined; method?: "reciprocal-rank-fusion" | "simple" | undefined; chunks: string[]; query: string; }; export type RerankerTaskOutput = { metadata?: { [x: string]: unknown; }[] | undefined; chunks: string[]; count: number; scores: number[]; originalIndices: number[]; }; export type RerankerTaskConfig = TaskConfig; /** * Rerank retrieved chunks to improve relevance using in-process heuristics. * Supports `simple` (keyword overlap + position) and `reciprocal-rank-fusion`. * Note: a `cross-encoder` method will be added when a real cross-encoder * task exists; until then, use a dedicated model task upstream. */ export declare class RerankerTask extends Task { static type: string; /** * Informational: capability this task uses. NOT enforced by the dispatcher — * RerankerTask extends `Task` (not `AiTask`) and implements its own `execute()`, * so `gateOrThrow` is never called against this value. The audit test in * `task/index.test.ts` validates the value is a known {@link Capability}. */ static readonly requires: readonly Capability[]; static category: string; static title: string; static description: string; static cacheable: boolean; static inputSchema(): DataPortSchema; static outputSchema(): DataPortSchema; execute(input: RerankerTaskInput, _context: IExecuteContext): Promise; /** Simple heuristic reranking: keyword overlap + exact match bonus - position penalty */ private simpleRerank; /** Reciprocal Rank Fusion: 1 / (k + rank) — useful when combining multiple rankings */ private reciprocalRankFusion; } export declare const reranker: (input: RerankerTaskInput, config?: RerankerTaskConfig, runConfig?: Partial) => Promise; declare module "@workglow/task-graph" { interface Workflow { reranker: CreateWorkflow; } } //# sourceMappingURL=RerankerTask.d.ts.map