@exulu/backend 5.18.0 → 5.19.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/{chunk-NBAFO66K.js → chunk-43QIPMLT.js} +13 -1
- package/dist/{chunk-PNBVWUEA.js → chunk-4NYSMZ6F.js} +82 -73
- package/dist/{chunk-JIZCKSJO.js → chunk-NJWNOXLJ.js} +2 -2
- package/dist/{chunk-7UDWQTFZ.js → chunk-Q4DFJFUI.js} +20 -28
- package/dist/cli/start-whisper.js +1 -1
- package/dist/{convert-exulu-tools-to-ai-sdk-tools-6GKOSRRE.js → convert-exulu-tools-to-ai-sdk-tools-4RXVKJHW.js} +2 -2
- package/dist/{doc_processor-RJNG7GGH.js → doc_processor-VCFQZ5WI.js} +3 -3
- package/dist/index.cjs +474 -194
- package/dist/index.d.cts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +317 -71
- package/dist/{python-setup-UYSNAW5V.js → python-setup-LJSGTTXI.js} +1 -1
- package/ee/python/documents/processing/doc_processor.ts +26 -28
- package/ee/python/requirements.txt +18 -18
- package/package.json +28 -42
- package/scripts/postinstall.cjs +1 -1
|
@@ -171,7 +171,7 @@ var LITELLM_UI_PATH = "/litellm-admin";
|
|
|
171
171
|
var MAX_CRASHES = 5;
|
|
172
172
|
var INITIAL_BACKOFF_MS = 1e3;
|
|
173
173
|
var MAX_BACKOFF_MS = 3e4;
|
|
174
|
-
var READY_TIMEOUT_MS =
|
|
174
|
+
var READY_TIMEOUT_MS = 15e4;
|
|
175
175
|
var WAIT_TIMEOUT_MS = 6e4;
|
|
176
176
|
var READY_POLL_INTERVAL_MS = 200;
|
|
177
177
|
var SHUTDOWN_GRACE_MS = 5e3;
|
|
@@ -1119,6 +1119,17 @@ async function resolveModel(input) {
|
|
|
1119
1119
|
};
|
|
1120
1120
|
}
|
|
1121
1121
|
|
|
1122
|
+
// src/utils/office-text.ts
|
|
1123
|
+
import { parseOffice } from "officeparser";
|
|
1124
|
+
var officeToText = async (bytes) => {
|
|
1125
|
+
const ast = await parseOffice(bytes, { newlineDelimiter: "\n" });
|
|
1126
|
+
const { value } = await ast.to("text", {
|
|
1127
|
+
includeImages: false,
|
|
1128
|
+
textConfig: { preserveLayout: false }
|
|
1129
|
+
});
|
|
1130
|
+
return String(value);
|
|
1131
|
+
};
|
|
1132
|
+
|
|
1122
1133
|
// ee/python/documents/processing/limits.ts
|
|
1123
1134
|
import pLimit from "p-limit";
|
|
1124
1135
|
var PROCESS_WIDE_LIMIT = 8;
|
|
@@ -1184,6 +1195,7 @@ export {
|
|
|
1184
1195
|
getUserBudgetView,
|
|
1185
1196
|
ResolveModelError,
|
|
1186
1197
|
resolveModel,
|
|
1198
|
+
officeToText,
|
|
1187
1199
|
processWideLimiters,
|
|
1188
1200
|
ocrConcurrency,
|
|
1189
1201
|
withRetry
|
|
@@ -3,13 +3,14 @@ import {
|
|
|
3
3
|
buildTags,
|
|
4
4
|
checkLicense,
|
|
5
5
|
isLiteLLMEnabled,
|
|
6
|
+
officeToText,
|
|
6
7
|
postgresClient,
|
|
7
8
|
processWideLimiters,
|
|
8
9
|
provisionDefaultUserBudget,
|
|
9
10
|
resolveModel,
|
|
10
11
|
waitForLiteLLMReady,
|
|
11
12
|
withRetry
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-43QIPMLT.js";
|
|
13
14
|
import {
|
|
14
15
|
findLiteLLMModel
|
|
15
16
|
} from "./chunk-F534XOQR.js";
|
|
@@ -17,9 +18,6 @@ import {
|
|
|
17
18
|
resolveLiteLLMTarget
|
|
18
19
|
} from "./chunk-6URU62NI.js";
|
|
19
20
|
|
|
20
|
-
// src/templates/tools/convert-exulu-tools-to-ai-sdk-tools.ts
|
|
21
|
-
import { S3Client as S3Client3, PutObjectCommand as PutObjectCommand3, S3ServiceException } from "@aws-sdk/client-s3";
|
|
22
|
-
|
|
23
21
|
// src/exulu/tool.ts
|
|
24
22
|
import { tool } from "ai";
|
|
25
23
|
import { z } from "zod";
|
|
@@ -593,6 +591,8 @@ var ExuluTool = class _ExuluTool {
|
|
|
593
591
|
*/
|
|
594
592
|
alwaysAskWhen;
|
|
595
593
|
authentication;
|
|
594
|
+
/** Always set; `{ enabled: false }` unless the tool opted in. See ExuluToolApiConfig. */
|
|
595
|
+
api;
|
|
596
596
|
config;
|
|
597
597
|
constructor({
|
|
598
598
|
id,
|
|
@@ -606,7 +606,8 @@ var ExuluTool = class _ExuluTool {
|
|
|
606
606
|
needsApproval,
|
|
607
607
|
needsApprovalFn,
|
|
608
608
|
alwaysAskWhen,
|
|
609
|
-
authentication: authentication2
|
|
609
|
+
authentication: authentication2,
|
|
610
|
+
api
|
|
610
611
|
}) {
|
|
611
612
|
if (!PUBLIC_TOOL_TYPES.includes(type)) {
|
|
612
613
|
throw new Error(
|
|
@@ -619,6 +620,17 @@ var ExuluTool = class _ExuluTool {
|
|
|
619
620
|
validateAuthConfig(id, authentication2);
|
|
620
621
|
authRegistry.register(id, authentication2);
|
|
621
622
|
}
|
|
623
|
+
this.api = { enabled: api?.enabled === true };
|
|
624
|
+
if (this.api.enabled) {
|
|
625
|
+
const variables = config.filter((c) => c.type === "variable").map((c) => c.name);
|
|
626
|
+
if (variables.length > 0) {
|
|
627
|
+
throw new Error(
|
|
628
|
+
`ExuluTool "${id}": api.enabled is not possible with "variable" config params (${variables.join(
|
|
629
|
+
", "
|
|
630
|
+
)}). Their values come from an agent's tool configuration, and a call to /tools/${id} has no agent.`
|
|
631
|
+
);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
622
634
|
this.authentication = authentication2;
|
|
623
635
|
this.id = id;
|
|
624
636
|
this.config = config;
|
|
@@ -669,7 +681,7 @@ var ExuluTool = class _ExuluTool {
|
|
|
669
681
|
if (!agent) {
|
|
670
682
|
throw new Error("Agent not found.");
|
|
671
683
|
}
|
|
672
|
-
const { convertExuluToolsToAiSdkTools: convertExuluToolsToAiSdkTools2 } = await import("./convert-exulu-tools-to-ai-sdk-tools-
|
|
684
|
+
const { convertExuluToolsToAiSdkTools: convertExuluToolsToAiSdkTools2 } = await import("./convert-exulu-tools-to-ai-sdk-tools-4RXVKJHW.js");
|
|
673
685
|
const tools = await convertExuluToolsToAiSdkTools2(
|
|
674
686
|
[this],
|
|
675
687
|
[],
|
|
@@ -3981,9 +3993,6 @@ function sanitizeToolName(name) {
|
|
|
3981
3993
|
return sanitized;
|
|
3982
3994
|
}
|
|
3983
3995
|
|
|
3984
|
-
// src/templates/tools/convert-exulu-tools-to-ai-sdk-tools.ts
|
|
3985
|
-
import { randomUUID as randomUUID9 } from "crypto";
|
|
3986
|
-
|
|
3987
3996
|
// types/enums/statistics.ts
|
|
3988
3997
|
var STATISTICS_TYPE_ENUM = {
|
|
3989
3998
|
CONTEXT_RETRIEVE: "CONTEXT_RETRIEVE",
|
|
@@ -4340,6 +4349,7 @@ import { createHash as createHash2 } from "crypto";
|
|
|
4340
4349
|
import { extname } from "path";
|
|
4341
4350
|
var DERIVED_ROOT = "derived";
|
|
4342
4351
|
var EXTRACTOR_VERSION = 1;
|
|
4352
|
+
var OFFICEPARSER_VERSION = 2;
|
|
4343
4353
|
var generalPrefix2 = (s3prefix) => {
|
|
4344
4354
|
const trimmed = (s3prefix ?? "").replace(/^\/+|\/+$/g, "");
|
|
4345
4355
|
return trimmed ? `${trimmed}/` : "";
|
|
@@ -4363,11 +4373,11 @@ function extractorFingerprint(args) {
|
|
|
4363
4373
|
const vlm = processorConfig.vlm?.model ? `vlm:${processorConfig.vlm.model}` : "vlm:off";
|
|
4364
4374
|
const extension = extname(args.filename).toLowerCase() || "-";
|
|
4365
4375
|
const chunk = processorConfig.processor.maxPagesPerChunk ?? 25;
|
|
4366
|
-
label = `document-processor/${name}/${ocrModel}/${vlm}/${extension}/chunk:${chunk}@${EXTRACTOR_VERSION}`;
|
|
4376
|
+
label = `document-processor/${name}/${ocrModel}/${vlm}/${extension}/chunk:${chunk}@${name === "officeparser" ? OFFICEPARSER_VERSION : EXTRACTOR_VERSION}`;
|
|
4367
4377
|
} else if (args.filename.toLowerCase().endsWith(".pdf")) {
|
|
4368
4378
|
label = `pdftotext@${EXTRACTOR_VERSION}`;
|
|
4369
4379
|
} else {
|
|
4370
|
-
label = `officeparser@${
|
|
4380
|
+
label = `officeparser@${OFFICEPARSER_VERSION}`;
|
|
4371
4381
|
}
|
|
4372
4382
|
return { id: sha256(label).slice(0, 16), label };
|
|
4373
4383
|
}
|
|
@@ -16588,7 +16598,7 @@ async function downloadKeyIntoSandbox(opts) {
|
|
|
16588
16598
|
}
|
|
16589
16599
|
async function resolvePythonVenvPath() {
|
|
16590
16600
|
try {
|
|
16591
|
-
const { getPythonVenvPath } = await import("./python-setup-
|
|
16601
|
+
const { getPythonVenvPath } = await import("./python-setup-LJSGTTXI.js");
|
|
16592
16602
|
return getPythonVenvPath();
|
|
16593
16603
|
} catch (err3) {
|
|
16594
16604
|
console.warn("[SKILLS] Could not resolve the Python venv for the session sandbox; skill scripts fall back to the system python.", err3);
|
|
@@ -17268,6 +17278,55 @@ function createRoutineStatusTool(handle) {
|
|
|
17268
17278
|
});
|
|
17269
17279
|
}
|
|
17270
17280
|
|
|
17281
|
+
// src/templates/tools/tool-upload.ts
|
|
17282
|
+
import { PutObjectCommand as PutObjectCommand3, S3Client as S3Client3, S3ServiceException } from "@aws-sdk/client-s3";
|
|
17283
|
+
import { randomUUID as randomUUID8 } from "crypto";
|
|
17284
|
+
var generateS3Key = (filename) => `${randomUUID8()}-${filename}`;
|
|
17285
|
+
var s3Client2;
|
|
17286
|
+
var buildToolUpload = (exuluConfig, user) => {
|
|
17287
|
+
const uploads = exuluConfig?.fileUploads;
|
|
17288
|
+
if (!uploads?.s3endpoint || !uploads?.s3key || !uploads?.s3secret || !uploads?.s3Bucket) {
|
|
17289
|
+
return void 0;
|
|
17290
|
+
}
|
|
17291
|
+
s3Client2 ??= new S3Client3({
|
|
17292
|
+
region: uploads.s3region,
|
|
17293
|
+
forcePathStyle: true,
|
|
17294
|
+
endpoint: uploads.s3endpoint,
|
|
17295
|
+
credentials: {
|
|
17296
|
+
accessKeyId: uploads.s3key ?? "",
|
|
17297
|
+
secretAccessKey: uploads.s3secret ?? ""
|
|
17298
|
+
}
|
|
17299
|
+
});
|
|
17300
|
+
const client = s3Client2;
|
|
17301
|
+
return async ({ name, data, type }) => {
|
|
17302
|
+
const mime = getMimeType(type);
|
|
17303
|
+
const prefix = uploads.s3prefix ? `${uploads.s3prefix.replace(/\/$/, "")}/` : "";
|
|
17304
|
+
const key = `${prefix}${user?.id}/${generateS3Key(name)}${type}`;
|
|
17305
|
+
const command = new PutObjectCommand3({
|
|
17306
|
+
Bucket: uploads.s3Bucket,
|
|
17307
|
+
Key: key,
|
|
17308
|
+
Body: data,
|
|
17309
|
+
ContentType: mime
|
|
17310
|
+
});
|
|
17311
|
+
try {
|
|
17312
|
+
await client.send(command);
|
|
17313
|
+
const bucket = uploads.s3Bucket ?? "";
|
|
17314
|
+
const presignedUrl = await getPresignedUrl(bucket, key, exuluConfig);
|
|
17315
|
+
return { url: presignedUrl, key: `${bucket}/${key}` };
|
|
17316
|
+
} catch (caught) {
|
|
17317
|
+
if (caught instanceof S3ServiceException && caught.name === "EntityTooLarge") {
|
|
17318
|
+
throw new Error(`[EXULU] Error from S3 while uploading object to ${uploads.s3Bucket}. The object was too large. To upload objects larger than 5GB, use the S3 console (160GB max) or the multipart upload API (5TB max).`);
|
|
17319
|
+
} else if (caught instanceof S3ServiceException) {
|
|
17320
|
+
throw new Error(
|
|
17321
|
+
`[EXULU] Error from S3 while uploading object to ${uploads.s3Bucket}. ${caught.name}: ${caught.message}`
|
|
17322
|
+
);
|
|
17323
|
+
} else {
|
|
17324
|
+
throw caught;
|
|
17325
|
+
}
|
|
17326
|
+
}
|
|
17327
|
+
};
|
|
17328
|
+
};
|
|
17329
|
+
|
|
17271
17330
|
// src/utils/truncate-tool-output.ts
|
|
17272
17331
|
var truncateToolOutput = (output, maxContextLength, toolName, tailFraction = 0.1, charLimitOverride) => {
|
|
17273
17332
|
const effectiveCtx = maxContextLength != null && maxContextLength > 0 ? maxContextLength : 128e3;
|
|
@@ -17292,7 +17351,7 @@ var truncateToolOutput = (output, maxContextLength, toolName, tailFraction = 0.1
|
|
|
17292
17351
|
};
|
|
17293
17352
|
|
|
17294
17353
|
// src/exulu/tool-output-offload.ts
|
|
17295
|
-
import { randomUUID as
|
|
17354
|
+
import { randomUUID as randomUUID9 } from "crypto";
|
|
17296
17355
|
|
|
17297
17356
|
// src/exulu/context-budget.ts
|
|
17298
17357
|
var DEFAULT_CONTEXT_WINDOW = 128e3;
|
|
@@ -17396,7 +17455,7 @@ var PREVIEW_CHARS = 4e3;
|
|
|
17396
17455
|
var storeAsSessionFile = async (serialized, ctx) => {
|
|
17397
17456
|
if (!ctx.sessionID || !ctx.exuluConfig?.fileUploads) return void 0;
|
|
17398
17457
|
const safeTool = ctx.toolName.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 40);
|
|
17399
|
-
const name = `tool-output-${safeTool}-${
|
|
17458
|
+
const name = `tool-output-${safeTool}-${randomUUID9().slice(0, 8)}.txt`;
|
|
17400
17459
|
try {
|
|
17401
17460
|
await uploadFile(
|
|
17402
17461
|
Buffer.from(serialized, "utf-8"),
|
|
@@ -17563,7 +17622,6 @@ var createSessionFileReadTool = ({
|
|
|
17563
17622
|
// src/templates/tools/parse-document-tool.ts
|
|
17564
17623
|
import { z as z22 } from "zod";
|
|
17565
17624
|
import { extname as extname2 } from "path";
|
|
17566
|
-
import { parseOfficeAsync as parseOfficeAsync2 } from "officeparser";
|
|
17567
17625
|
|
|
17568
17626
|
// src/templates/tools/document-render-helpers.ts
|
|
17569
17627
|
import { execFile as execFile2 } from "child_process";
|
|
@@ -17663,7 +17721,6 @@ async function renderPdfPageToPng(pdf, page, scaleTo) {
|
|
|
17663
17721
|
}
|
|
17664
17722
|
|
|
17665
17723
|
// src/exulu/attachment-text.ts
|
|
17666
|
-
import { parseOfficeAsync } from "officeparser";
|
|
17667
17724
|
var DEFAULT_ATTACHMENT_MAX_PAGES = 50;
|
|
17668
17725
|
function attachmentMaxPages(env = process.env) {
|
|
17669
17726
|
const raw = env.EXULU_ATTACHMENT_MAX_PAGES;
|
|
@@ -17682,7 +17739,7 @@ function tooLongForToolNotice(filename, pageCount, maxPages) {
|
|
|
17682
17739
|
return `[Document too long: "${filename}" has ${pageCount} pages, the limit for reading a document is ${maxPages} pages (EXULU_DOCUMENT_MAX_PAGES). The document was NOT read. Tell the user plainly and suggest splitting the file.]`;
|
|
17683
17740
|
}
|
|
17684
17741
|
var loadDocumentProcessor = async () => {
|
|
17685
|
-
const mod = await import("./doc_processor-
|
|
17742
|
+
const mod = await import("./doc_processor-VCFQZ5WI.js");
|
|
17686
17743
|
return mod.documentProcessor;
|
|
17687
17744
|
};
|
|
17688
17745
|
function pagesToText(pages) {
|
|
@@ -17700,7 +17757,7 @@ function pagesFromProcessor(result) {
|
|
|
17700
17757
|
function degradedPagesOf(result) {
|
|
17701
17758
|
return (result ?? []).filter((p) => p.vlm_failed).map((p) => p.page);
|
|
17702
17759
|
}
|
|
17703
|
-
var defaultOfficeParse =
|
|
17760
|
+
var defaultOfficeParse = (bytes) => officeToText(bytes);
|
|
17704
17761
|
async function extractDocument(input) {
|
|
17705
17762
|
const config = input.exuluConfig?.attachments?.documentProcessor;
|
|
17706
17763
|
if (config) {
|
|
@@ -18136,11 +18193,8 @@ ${text.trim()}`).join("\n")
|
|
|
18136
18193
|
};
|
|
18137
18194
|
}
|
|
18138
18195
|
const officeBytes = isLegacyOfficeFormat(ext) ? await convertLegacyOfficeToModern(bytes, ext) : bytes;
|
|
18139
|
-
const parsed = await
|
|
18140
|
-
|
|
18141
|
-
newlineDelimiter: "\n"
|
|
18142
|
-
});
|
|
18143
|
-
return { text: String(parsed), storable: !processorFellBack };
|
|
18196
|
+
const parsed = await officeToText(officeBytes);
|
|
18197
|
+
return { text: parsed, storable: !processorFellBack };
|
|
18144
18198
|
};
|
|
18145
18199
|
const stored = await readThroughDocument({
|
|
18146
18200
|
io,
|
|
@@ -18574,8 +18628,6 @@ var isReadingProgress = (value) => {
|
|
|
18574
18628
|
return typeof v.filename === "string" && typeof v.pagesDone === "number" && typeof v.pagesTotal === "number";
|
|
18575
18629
|
};
|
|
18576
18630
|
var OUTPUT_OFFLOAD_EXEMPT_TOOL_IDS = /* @__PURE__ */ new Set(["agentic_context_search"]);
|
|
18577
|
-
var generateS3Key = (filename) => `${randomUUID9()}-${filename}`;
|
|
18578
|
-
var s3Client2;
|
|
18579
18631
|
var hydrateVariables = async (tool3) => {
|
|
18580
18632
|
const { db } = await postgresClient();
|
|
18581
18633
|
const promises = tool3.config.map(async (toolConfig) => {
|
|
@@ -18976,54 +19028,7 @@ var convertExuluToolsToAiSdkTools = async (currentTools, currentSkills, approved
|
|
|
18976
19028
|
if (toolVariableConfig) {
|
|
18977
19029
|
toolVariableConfig = await hydrateVariables(toolVariableConfig || []);
|
|
18978
19030
|
}
|
|
18979
|
-
|
|
18980
|
-
if (exuluConfig?.fileUploads?.s3endpoint && exuluConfig?.fileUploads?.s3key && exuluConfig?.fileUploads?.s3secret && exuluConfig?.fileUploads?.s3Bucket) {
|
|
18981
|
-
s3Client2 ??= new S3Client3({
|
|
18982
|
-
region: exuluConfig?.fileUploads?.s3region,
|
|
18983
|
-
...exuluConfig?.fileUploads?.s3endpoint && {
|
|
18984
|
-
forcePathStyle: true,
|
|
18985
|
-
endpoint: exuluConfig?.fileUploads?.s3endpoint
|
|
18986
|
-
},
|
|
18987
|
-
credentials: {
|
|
18988
|
-
accessKeyId: exuluConfig?.fileUploads?.s3key ?? "",
|
|
18989
|
-
secretAccessKey: exuluConfig?.fileUploads?.s3secret ?? ""
|
|
18990
|
-
}
|
|
18991
|
-
});
|
|
18992
|
-
upload = async ({
|
|
18993
|
-
name,
|
|
18994
|
-
data,
|
|
18995
|
-
type
|
|
18996
|
-
}) => {
|
|
18997
|
-
const mime = getMimeType(type);
|
|
18998
|
-
const prefix = exuluConfig?.fileUploads?.s3prefix ? `${exuluConfig.fileUploads.s3prefix.replace(/\/$/, "")}/` : "";
|
|
18999
|
-
const key = `${prefix}${user?.id}/${generateS3Key(name)}${type}`;
|
|
19000
|
-
const command = new PutObjectCommand3({
|
|
19001
|
-
Bucket: exuluConfig?.fileUploads?.s3Bucket,
|
|
19002
|
-
Key: key,
|
|
19003
|
-
Body: data,
|
|
19004
|
-
ContentType: mime
|
|
19005
|
-
});
|
|
19006
|
-
try {
|
|
19007
|
-
if (!s3Client2) {
|
|
19008
|
-
throw new Error("S3 client not initialized");
|
|
19009
|
-
}
|
|
19010
|
-
await s3Client2.send(command);
|
|
19011
|
-
const bucket = exuluConfig?.fileUploads?.s3Bucket ?? "";
|
|
19012
|
-
const presignedUrl = await getPresignedUrl(bucket, key, exuluConfig);
|
|
19013
|
-
return { url: presignedUrl, key: `${bucket}/${key}` };
|
|
19014
|
-
} catch (caught) {
|
|
19015
|
-
if (caught instanceof S3ServiceException && caught.name === "EntityTooLarge") {
|
|
19016
|
-
throw new Error(`[EXULU] Error from S3 while uploading object to ${exuluConfig?.fileUploads?.s3Bucket}. The object was too large. To upload objects larger than 5GB, use the S3 console (160GB max) or the multipart upload API (5TB max).`);
|
|
19017
|
-
} else if (caught instanceof S3ServiceException) {
|
|
19018
|
-
throw new Error(
|
|
19019
|
-
`[EXULU] Error from S3 while uploading object to ${exuluConfig?.fileUploads?.s3Bucket}. ${caught.name}: ${caught.message}`
|
|
19020
|
-
);
|
|
19021
|
-
} else {
|
|
19022
|
-
throw caught;
|
|
19023
|
-
}
|
|
19024
|
-
}
|
|
19025
|
-
};
|
|
19026
|
-
}
|
|
19031
|
+
const upload = buildToolUpload(exuluConfig, user);
|
|
19027
19032
|
const contextsMap = contexts?.reduce((acc, curr) => {
|
|
19028
19033
|
acc[curr.id] = curr;
|
|
19029
19034
|
return acc;
|
|
@@ -19345,6 +19350,7 @@ export {
|
|
|
19345
19350
|
SAVE_INVALID_NAME,
|
|
19346
19351
|
SAVE_EMPTY,
|
|
19347
19352
|
SAVE_FAILED,
|
|
19353
|
+
buildToolUpload,
|
|
19348
19354
|
truncateToolOutput,
|
|
19349
19355
|
DEFAULT_CONTEXT_WINDOW,
|
|
19350
19356
|
deriveContextBudget,
|
|
@@ -19361,11 +19367,14 @@ export {
|
|
|
19361
19367
|
SESSION_FILE_READ_TOOL_NAME,
|
|
19362
19368
|
extractDocument,
|
|
19363
19369
|
validateAttachmentsConfig,
|
|
19370
|
+
isInterimToolStatus,
|
|
19364
19371
|
PARSE_DOCUMENT_TOOL_NAME,
|
|
19365
19372
|
PreviewRenderError,
|
|
19366
19373
|
getPdfPreviewBytes,
|
|
19367
19374
|
imageAttachmentGuard,
|
|
19368
19375
|
VIEW_DOCUMENT_PAGE_TOOL_NAME,
|
|
19376
|
+
emitToolCallAudit,
|
|
19377
|
+
extractClientInfo,
|
|
19369
19378
|
OUTPUT_OFFLOAD_EXEMPT_TOOL_IDS,
|
|
19370
19379
|
hydrateVariables,
|
|
19371
19380
|
convertExuluToolsToAiSdkTools,
|
|
@@ -54,8 +54,8 @@ async function setupPythonEnvironment(options = {}) {
|
|
|
54
54
|
packageRoot = getPackageRoot(),
|
|
55
55
|
force = false,
|
|
56
56
|
verbose = false,
|
|
57
|
-
timeout =
|
|
58
|
-
//
|
|
57
|
+
timeout = 18e5
|
|
58
|
+
// 30 minutes
|
|
59
59
|
} = options;
|
|
60
60
|
const alreadyExisted = isPythonEnvironmentSetup(packageRoot);
|
|
61
61
|
if (verbose) {
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import "dotenv/config";
|
|
2
2
|
import {
|
|
3
3
|
validatePythonEnvironment
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NJWNOXLJ.js";
|
|
5
5
|
import {
|
|
6
6
|
buildTags,
|
|
7
7
|
checkLicense,
|
|
8
8
|
isLiteLLMEnabled,
|
|
9
9
|
ocrConcurrency,
|
|
10
|
+
officeToText,
|
|
10
11
|
provisionDefaultUserBudget,
|
|
11
12
|
resolveModel,
|
|
12
13
|
waitForLiteLLMReady,
|
|
13
14
|
withRetry
|
|
14
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-43QIPMLT.js";
|
|
15
16
|
import {
|
|
16
17
|
resolveLiteLLMTarget
|
|
17
18
|
} from "./chunk-6URU62NI.js";
|
|
@@ -26,7 +27,6 @@ import { randomUUID } from "crypto";
|
|
|
26
27
|
import * as mammoth from "mammoth";
|
|
27
28
|
import TurndownService from "turndown";
|
|
28
29
|
import WordExtractor from "word-extractor";
|
|
29
|
-
import { parseOfficeAsync } from "officeparser";
|
|
30
30
|
|
|
31
31
|
// src/utils/python-executor.ts
|
|
32
32
|
import { exec } from "child_process";
|
|
@@ -718,14 +718,21 @@ async function processDocument(filePath, fileType, buffer, tempDir, config, verb
|
|
|
718
718
|
}
|
|
719
719
|
};
|
|
720
720
|
}
|
|
721
|
+
async function saveScreenshots(screenshots, dir) {
|
|
722
|
+
await fs.promises.mkdir(dir, { recursive: true });
|
|
723
|
+
const saved = /* @__PURE__ */ new Map();
|
|
724
|
+
for (const screenshot of screenshots) {
|
|
725
|
+
const file = path.join(dir, `${screenshot.pageNum}.png`);
|
|
726
|
+
await fs.promises.writeFile(file, screenshot.imageBuffer);
|
|
727
|
+
saved.set(screenshot.pageNum, file);
|
|
728
|
+
}
|
|
729
|
+
return saved;
|
|
730
|
+
}
|
|
721
731
|
async function processPdf(buffer, paths, config, verbose = false, tolerateVisionFailures = false, onProgress, limiters) {
|
|
722
732
|
try {
|
|
723
733
|
let json = [];
|
|
724
734
|
if (config?.processor.name === "officeparser") {
|
|
725
|
-
const text = await
|
|
726
|
-
outputErrorToConsole: false,
|
|
727
|
-
newlineDelimiter: "\n"
|
|
728
|
-
});
|
|
735
|
+
const text = await officeToText(buffer);
|
|
729
736
|
json = [{
|
|
730
737
|
page: 1,
|
|
731
738
|
content: text,
|
|
@@ -783,40 +790,25 @@ stderr: ${splitResult.stderr.slice(-1e3)}`
|
|
|
783
790
|
const mergedPages = chunkResults.sort((a, b) => a.offset - b.offset).flatMap(
|
|
784
791
|
({ pages, offset }) => pages.map((p) => ({ ...p, index: p.index + offset }))
|
|
785
792
|
);
|
|
786
|
-
const parser = new LiteParse();
|
|
793
|
+
const parser = new LiteParse({ quiet: true });
|
|
787
794
|
const screenshots = await parser.screenshot(paths.source, void 0);
|
|
788
|
-
await
|
|
789
|
-
for (const screenshot of screenshots) {
|
|
790
|
-
await fs.promises.writeFile(
|
|
791
|
-
path.join(
|
|
792
|
-
paths.images,
|
|
793
|
-
`${screenshot.pageNum}.png`
|
|
794
|
-
),
|
|
795
|
-
screenshot.imageBuffer
|
|
796
|
-
);
|
|
797
|
-
screenshot.imagePath = path.join(paths.images, `${screenshot.pageNum}.png`);
|
|
798
|
-
}
|
|
795
|
+
const imagePaths = await saveScreenshots(screenshots, paths.images);
|
|
799
796
|
json = mergedPages.map((page) => ({
|
|
800
797
|
page: page.index + 1,
|
|
801
798
|
content: page.markdown,
|
|
802
|
-
image:
|
|
799
|
+
image: imagePaths.get(page.index + 1),
|
|
803
800
|
headings: []
|
|
804
801
|
}));
|
|
805
802
|
fs.writeFileSync(paths.json, JSON.stringify(json, null, 2));
|
|
806
803
|
} else if (config?.processor.name === "liteparse") {
|
|
807
|
-
const parser = new LiteParse();
|
|
804
|
+
const parser = new LiteParse({ quiet: true });
|
|
808
805
|
const result = await parser.parse(paths.source);
|
|
809
806
|
const screenshots = await parser.screenshot(paths.source, void 0);
|
|
810
|
-
|
|
811
|
-
await fs.promises.mkdir(paths.images, { recursive: true });
|
|
812
|
-
for (const screenshot of screenshots) {
|
|
813
|
-
await fs.promises.writeFile(path.join(paths.images, `${screenshot.pageNum}.png`), screenshot.imageBuffer);
|
|
814
|
-
screenshot.imagePath = path.join(paths.images, `${screenshot.pageNum}.png`);
|
|
815
|
-
}
|
|
807
|
+
const imagePaths = await saveScreenshots(screenshots, paths.images);
|
|
816
808
|
json = result.pages.map((page) => ({
|
|
817
809
|
page: page.pageNum,
|
|
818
810
|
content: page.text,
|
|
819
|
-
image:
|
|
811
|
+
image: imagePaths.get(page.pageNum)
|
|
820
812
|
}));
|
|
821
813
|
fs.writeFileSync(paths.json, JSON.stringify(json, null, 2));
|
|
822
814
|
} else {
|
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
OUTPUT_OFFLOAD_EXEMPT_TOOL_IDS,
|
|
4
4
|
convertExuluToolsToAiSdkTools,
|
|
5
5
|
hydrateVariables
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-4NYSMZ6F.js";
|
|
7
|
+
import "./chunk-43QIPMLT.js";
|
|
8
8
|
import "./chunk-F534XOQR.js";
|
|
9
9
|
import "./chunk-6URU62NI.js";
|
|
10
10
|
export {
|
|
@@ -2,9 +2,9 @@ import "dotenv/config";
|
|
|
2
2
|
import {
|
|
3
3
|
documentProcessor,
|
|
4
4
|
reconstructTableHeaders
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-Q4DFJFUI.js";
|
|
6
|
+
import "./chunk-NJWNOXLJ.js";
|
|
7
|
+
import "./chunk-43QIPMLT.js";
|
|
8
8
|
import "./chunk-6URU62NI.js";
|
|
9
9
|
export {
|
|
10
10
|
documentProcessor,
|