mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-03 01:29:56 +00:00
* fix: bound concurrent compute work and pending worker inputs * fix: supply the host response budget in worker checkpoint tests * fix: preserve prepared catalog ownership under admission pressure * improve: keep image and PDF processing responsive * fix: register PDF worker declarations in build fixtures * test: rebalance SQLite checks into the state shard * fix: resolve workers in standalone plugin packages * docs: separate worker entrypoint guidance
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import type {
|
|
DocumentExtractionRequest,
|
|
DocumentExtractionResult,
|
|
} from "openclaw/plugin-sdk/document-extractor";
|
|
import { serveWorkerTasks } from "openclaw/plugin-sdk/process-runtime";
|
|
import { extractPdfContent } from "./document-extractor.runtime.js";
|
|
|
|
export type DocumentExtractorWorkerRequest = Omit<
|
|
DocumentExtractionRequest,
|
|
"signal" | "onImageExtractionError"
|
|
>;
|
|
export type DocumentExtractorWorkerReply = { imageErrors: Error[] } & (
|
|
| { status: "ok"; result: DocumentExtractionResult }
|
|
| { status: "failed"; error: Error }
|
|
);
|
|
|
|
serveWorkerTasks<DocumentExtractorWorkerReply>(async (input) => {
|
|
// SAFETY: The plugin-owned pool sends this private request shape; both sides are built together.
|
|
const request = input as DocumentExtractorWorkerRequest;
|
|
const imageErrors: Error[] = [];
|
|
try {
|
|
const result = await extractPdfContent({
|
|
...request,
|
|
onImageExtractionError: (error) =>
|
|
imageErrors.push(error instanceof Error ? error : new Error(String(error))),
|
|
});
|
|
return { status: "ok", result, imageErrors };
|
|
} catch (error) {
|
|
return {
|
|
status: "failed",
|
|
error: error instanceof Error ? error : new Error(String(error)),
|
|
imageErrors,
|
|
};
|
|
}
|
|
});
|