ConusAI vendor v0.1.0-dev.20261027+9b1131fb
ci / gate (push) Waiting to run

This commit is contained in:
ConusAI vendor v0.1.0-dev.20261027+9b1131fb
2026-10-27 18:05:17 +00:00
commit 3102273ec7
538 changed files with 80203 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
// The OCR job: what `files.processors` enqueues once per matching upload.
//
// The tenant comes from the container, never from the payload (a module cannot mint a system
// actor, decision AT-F6), so a payload that named another organization would change nothing.
import { internal, type JobDef } from "@conusai-kit/core"
import { OBJECT_STORE } from "@conusai-kit/data"
import { type ProcessorJobPayload, processorJobPayloadSchema } from "@conusai-kit/files"
import { DOCUMENT_OCR, DOCUMENTS_SCOPE } from "../core/ports.js"
import { processDocument } from "../core/process.js"
import { DOCUMENT_EXCLUDED_PAGE_CLASSES, DOCUMENT_MODEL, MODEL_GATEWAY, modelLineExtractor } from "./model-extractor.js"
import { documentsDeps } from "./procedures.js"
export const ocrJob: JobDef<ProcessorJobPayload> = {
payload: processorJobPayloadSchema,
async handler(payload, ctx) {
const scope = ctx.container.resolve(DOCUMENTS_SCOPE)
if (scope.level !== "project") throw internal(`a documents job runs in a project scope, not a ${scope.level} one`)
await processDocument(
{
...documentsDeps(ctx.container),
store: ctx.container.resolve(OBJECT_STORE),
ocr: ctx.container.resolve(DOCUMENT_OCR),
// The model behind the platform's AI gateway, which the composition root binds with its model id.
extractor: modelLineExtractor({
gateway: ctx.container.resolve(MODEL_GATEWAY),
model: ctx.container.resolve(DOCUMENT_MODEL),
...(ctx.container.has(DOCUMENT_EXCLUDED_PAGE_CLASSES)
? { excludedPageClasses: ctx.container.resolve(DOCUMENT_EXCLUDED_PAGE_CLASSES) }
: {}),
}),
...(ctx.signal ? { signal: ctx.signal } : {}),
},
scope,
payload,
)
},
}