@exulu/backend 5.7.1 → 5.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{catalog-3QLU2G7R.js → catalog-4P3TKOV7.js} +2 -1
- package/dist/chunk-4W3V7IHR.js +1166 -0
- package/dist/chunk-6URU62NI.js +54 -0
- package/dist/{chunk-4PDWNVNT.js → chunk-F534XOQR.js} +3 -50
- package/dist/{chunk-XNTGIQLC.js → chunk-NUEM3HMI.js} +501 -1471
- package/dist/chunk-RNZ4IDCT.js +946 -0
- package/dist/{convert-exulu-tools-to-ai-sdk-tools-XOL5J5ET.js → convert-exulu-tools-to-ai-sdk-tools-3UCQOIY6.js} +4 -2
- package/dist/doc_processor-E5GCE2ZT.js +10 -0
- package/dist/index.cjs +29509 -29270
- package/dist/index.d.cts +118 -105
- package/dist/index.d.ts +118 -105
- package/dist/index.js +154 -1053
- package/ee/invoke-skills/binary-file-guard.test.ts +22 -0
- package/ee/invoke-skills/binary-file-guard.ts +33 -0
- package/ee/invoke-skills/create-sandbox.ts +10 -0
- package/ee/python/documents/processing/doc_processor.ts +3 -3
- package/ee/workers.ts +6 -4
- package/package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isBinaryDocumentPath, looksBinary, binaryReadHint } from './binary-file-guard'
|
|
2
|
+
|
|
3
|
+
describe('binary-file-guard', () => {
|
|
4
|
+
it('recognises PDF/Office/image/archive paths regardless of case', () => {
|
|
5
|
+
expect(isBinaryDocumentPath('TEST_Anhang_einzeln.pdf')).toBe(true)
|
|
6
|
+
expect(isBinaryDocumentPath('/tmp/exulu-sessions/abc/Angebot.DOCX')).toBe(true)
|
|
7
|
+
expect(isBinaryDocumentPath('skills/Standard-Angebotsaufbau ALGI/SKILL.md')).toBe(false)
|
|
8
|
+
expect(isBinaryDocumentPath('notes.txt')).toBe(false)
|
|
9
|
+
expect(isBinaryDocumentPath('Makefile')).toBe(false)
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it('detects NUL bytes in the head of the content', () => {
|
|
13
|
+
expect(looksBinary('%PDF-1.4\n\u0000\u0000stream')).toBe(true)
|
|
14
|
+
expect(looksBinary('plain text with ü and emoji 🙂')).toBe(false)
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('names the file and points at the extracted text', () => {
|
|
18
|
+
const hint = binaryReadHint('TEST_Anhang_einzeln.pdf')
|
|
19
|
+
expect(hint).toContain('TEST_Anhang_einzeln.pdf')
|
|
20
|
+
expect(hint).toContain('parse_document')
|
|
21
|
+
})
|
|
22
|
+
})
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps raw binary out of the model's context.
|
|
3
|
+
*
|
|
4
|
+
* The sandbox readFile tool runs `cat`; on a PDF or Office file that returns
|
|
5
|
+
* compressed bytes that are useless to the model, bloat the turn (2026-10-13:
|
|
6
|
+
* a routine turn grew to ~2M tokens) and carry NUL bytes that later break the
|
|
7
|
+
* jsonb write of the job result (2026-10-29: run stuck in "active"). The
|
|
8
|
+
* attachment's text is already in the conversation (intake extracts it into a
|
|
9
|
+
* `<file file name=…>` block) or reachable via parse_document.
|
|
10
|
+
*/
|
|
11
|
+
const BINARY_DOCUMENT_EXTENSIONS = new Set([
|
|
12
|
+
'.pdf', '.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx', '.odt', '.ods', '.odp',
|
|
13
|
+
'.zip', '.gz', '.png', '.jpg', '.jpeg', '.gif', '.bmp', '.tif', '.tiff', '.webp',
|
|
14
|
+
])
|
|
15
|
+
|
|
16
|
+
export function isBinaryDocumentPath(path: string): boolean {
|
|
17
|
+
const dot = path.lastIndexOf('.')
|
|
18
|
+
if (dot < 0) return false
|
|
19
|
+
return BINARY_DOCUMENT_EXTENSIONS.has(path.slice(dot).toLowerCase())
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** NUL bytes never occur in text files; one in the first 8 KB means binary. */
|
|
23
|
+
export function looksBinary(content: string): boolean {
|
|
24
|
+
return content.slice(0, 8192).includes('\u0000')
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function binaryReadHint(path: string): string {
|
|
28
|
+
return (
|
|
29
|
+
`"${path}" is a binary file — readFile would return raw bytes that cannot be interpreted and would ` +
|
|
30
|
+
'flood the context. The text of mail attachments is already in the conversation (the <file file name=…> block); ' +
|
|
31
|
+
'for other documents use parse_document to extract the text first, then read within that extracted text.'
|
|
32
|
+
)
|
|
33
|
+
}
|
|
@@ -11,6 +11,7 @@ import { listS3ObjectsByPrefix, getS3ObjectBytes, uploadFile, getPresignedUrl, t
|
|
|
11
11
|
import { isIgnoredArtifactPath, capArtifacts, needsDownload } from './artifact-filter'
|
|
12
12
|
import { getNpmGlobalRoot } from '@SRC/exulu/system-dependencies.ts'
|
|
13
13
|
import { buildSkillEnv } from './skill-env'
|
|
14
|
+
import { isBinaryDocumentPath, looksBinary, binaryReadHint } from './binary-file-guard'
|
|
14
15
|
import { selectGrantedVariables, selectRowsToDecrypt, deriveWithheldNames } from './variable-grants'
|
|
15
16
|
import { readLiteLLMOsEnvironNames } from '@SRC/exulu/litellm/os-environ-names'
|
|
16
17
|
import { getAuditLogger } from '@SRC/exulu/audit/logger'
|
|
@@ -1025,7 +1026,16 @@ export async function createSessionSandbox(
|
|
|
1025
1026
|
}),
|
|
1026
1027
|
execute: async ({ path }) => {
|
|
1027
1028
|
const resolvedPath = resolveSessionPath(path, sessionDir)
|
|
1029
|
+
// Binary documents never go to the model as raw bytes (see
|
|
1030
|
+
// binary-file-guard.ts). Returned, not thrown: a throw fails the
|
|
1031
|
+
// whole step in a routine, a hint lets the agent self-correct.
|
|
1032
|
+
if (isBinaryDocumentPath(resolvedPath)) {
|
|
1033
|
+
return { content: '', error: binaryReadHint(path) }
|
|
1034
|
+
}
|
|
1028
1035
|
const content = await customSandbox.readFile(resolvedPath)
|
|
1036
|
+
if (looksBinary(content)) {
|
|
1037
|
+
return { content: '', error: binaryReadHint(path) }
|
|
1038
|
+
}
|
|
1029
1039
|
return { content }
|
|
1030
1040
|
},
|
|
1031
1041
|
})
|
|
@@ -17,7 +17,7 @@ import { resolveOcr } from '@SRC/exulu/resolve-ocr';
|
|
|
17
17
|
import type { ResolveOcrInput } from '@SRC/exulu/resolve-ocr';
|
|
18
18
|
import { resolveModel } from '@SRC/exulu/resolve-model';
|
|
19
19
|
|
|
20
|
-
type DocumentProcessorConfig = {
|
|
20
|
+
export type DocumentProcessorConfig = {
|
|
21
21
|
vlm?: {
|
|
22
22
|
/**
|
|
23
23
|
* LiteLLM model_name for the VLM page-validation pass (declared in
|
|
@@ -60,7 +60,7 @@ type DocumentProcessorConfig = {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
type ProcessedPage = {
|
|
63
|
+
export type ProcessedPage = {
|
|
64
64
|
page: number;
|
|
65
65
|
content: string;
|
|
66
66
|
headings?: any;
|
|
@@ -68,7 +68,7 @@ type ProcessedPage = {
|
|
|
68
68
|
vlm_corrected_text?: string;
|
|
69
69
|
vlm_validated?: boolean;
|
|
70
70
|
}
|
|
71
|
-
type ProcessedDocument = ProcessedPage[];
|
|
71
|
+
export type ProcessedDocument = ProcessedPage[];
|
|
72
72
|
|
|
73
73
|
type ProcessorOutput = {
|
|
74
74
|
markdown: string,
|
package/ee/workers.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { guardRedisStartup, logRedisErrors } from "@EE/queues/redis-startup.ts";
|
|
|
4
4
|
import { Job, Worker, type JobState } from "bullmq";
|
|
5
5
|
import { bullmq } from "@SRC/validators/bullmq.ts";
|
|
6
6
|
import { serializeError } from "@SRC/utils/serialize-error.ts";
|
|
7
|
+
import { jsonbSafeStringify } from "@SRC/utils/jsonb-safe.ts";
|
|
7
8
|
import { finishTurnMetadata } from "@SRC/exulu/turn-metadata.ts";
|
|
8
9
|
import { getEnabledTools } from "@SRC/utils/enabled-tools.ts";
|
|
9
10
|
import { ExuluStorage } from "@SRC/exulu/storage.ts";
|
|
@@ -705,8 +706,8 @@ export const createWorkers = async (
|
|
|
705
706
|
.where({ id: jobResultId })
|
|
706
707
|
.update({
|
|
707
708
|
result:
|
|
708
|
-
messages.length > 0 ?
|
|
709
|
-
metadata:
|
|
709
|
+
messages.length > 0 ? jsonbSafeStringify(messages[messages.length - 1]) : null,
|
|
710
|
+
metadata: jsonbSafeStringify({
|
|
710
711
|
messages,
|
|
711
712
|
...metadata,
|
|
712
713
|
tokens,
|
|
@@ -1374,8 +1375,9 @@ export const createWorkers = async (
|
|
|
1374
1375
|
.where({ job_id: job.id, state: JOB_STATUS_ENUM.active })
|
|
1375
1376
|
.update({
|
|
1376
1377
|
state: JOB_STATUS_ENUM.completed,
|
|
1377
|
-
|
|
1378
|
-
|
|
1378
|
+
// jsonb rejects the NUL escape; a raw attachment read can carry it (2026-10-29).
|
|
1379
|
+
result: returnvalue.result != null ? jsonbSafeStringify(returnvalue.result) : null,
|
|
1380
|
+
metadata: returnvalue.metadata != null ? jsonbSafeStringify(returnvalue.metadata) : null,
|
|
1379
1381
|
});
|
|
1380
1382
|
|
|
1381
1383
|
// Cap the table as rows become terminal (every Nth, idempotent).
|