MiniSearch / client /modules /pageExcerptWorkerProtocol.ts
system's picture
system HF Staff
Sync from felladrin/MiniSearch@6c9fb20
1a6d0d2 verified
Raw History Blame Contribute Delete
678 Bytes
/**
* Messages exchanged with `pageExcerptWorker`, shared by both sides.
*
* Each allocation gets its own worker, terminated as soon as the excerpts
* come back, so there is no cancel message and no need for the worker to
* tell requests apart.
*/
export interface WorkerRequest {
/** Full body of every page read by `/page-content`, in result order. */
contents: string[];
/** Tokens the excerpts may occupy together. */
tokenBudget: number;
}
export type WorkerResponse =
| {
type: "excerpts";
/** One entry per request entry, same order; empty when a page got no share. */
excerpts: string[];
}
| { type: "error"; message: string };