@exulu/backend 5.18.0 → 5.20.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-JIZCKSJO.js → chunk-NJWNOXLJ.js} +2 -2
- package/dist/{chunk-7UDWQTFZ.js → chunk-Q4DFJFUI.js} +20 -28
- package/dist/{chunk-PNBVWUEA.js → chunk-XVUJ3WIC.js} +89 -73
- 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-7BDMKCSR.js} +2 -2
- package/dist/{doc_processor-RJNG7GGH.js → doc_processor-VCFQZ5WI.js} +3 -3
- package/dist/index.cjs +761 -237
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +582 -105
- 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
|
|
@@ -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,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-7BDMKCSR.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
|
}
|
|
@@ -10483,6 +10493,13 @@ var agentsSchema = {
|
|
|
10483
10493
|
name: "reasoning_effort",
|
|
10484
10494
|
type: "text"
|
|
10485
10495
|
},
|
|
10496
|
+
{
|
|
10497
|
+
// Language the agent answers in. null/"off" = nothing is added to the
|
|
10498
|
+
// prompt; "auto" = the language of the user's message; a locale ("en")
|
|
10499
|
+
// = always that language. See response-language.ts. Auto-ALTERed on boot.
|
|
10500
|
+
name: "response_language",
|
|
10501
|
+
type: "text"
|
|
10502
|
+
},
|
|
10486
10503
|
{
|
|
10487
10504
|
name: "guest_access",
|
|
10488
10505
|
type: "boolean",
|
|
@@ -16588,7 +16605,7 @@ async function downloadKeyIntoSandbox(opts) {
|
|
|
16588
16605
|
}
|
|
16589
16606
|
async function resolvePythonVenvPath() {
|
|
16590
16607
|
try {
|
|
16591
|
-
const { getPythonVenvPath } = await import("./python-setup-
|
|
16608
|
+
const { getPythonVenvPath } = await import("./python-setup-LJSGTTXI.js");
|
|
16592
16609
|
return getPythonVenvPath();
|
|
16593
16610
|
} catch (err3) {
|
|
16594
16611
|
console.warn("[SKILLS] Could not resolve the Python venv for the session sandbox; skill scripts fall back to the system python.", err3);
|
|
@@ -17268,6 +17285,55 @@ function createRoutineStatusTool(handle) {
|
|
|
17268
17285
|
});
|
|
17269
17286
|
}
|
|
17270
17287
|
|
|
17288
|
+
// src/templates/tools/tool-upload.ts
|
|
17289
|
+
import { PutObjectCommand as PutObjectCommand3, S3Client as S3Client3, S3ServiceException } from "@aws-sdk/client-s3";
|
|
17290
|
+
import { randomUUID as randomUUID8 } from "crypto";
|
|
17291
|
+
var generateS3Key = (filename) => `${randomUUID8()}-${filename}`;
|
|
17292
|
+
var s3Client2;
|
|
17293
|
+
var buildToolUpload = (exuluConfig, user) => {
|
|
17294
|
+
const uploads = exuluConfig?.fileUploads;
|
|
17295
|
+
if (!uploads?.s3endpoint || !uploads?.s3key || !uploads?.s3secret || !uploads?.s3Bucket) {
|
|
17296
|
+
return void 0;
|
|
17297
|
+
}
|
|
17298
|
+
s3Client2 ??= new S3Client3({
|
|
17299
|
+
region: uploads.s3region,
|
|
17300
|
+
forcePathStyle: true,
|
|
17301
|
+
endpoint: uploads.s3endpoint,
|
|
17302
|
+
credentials: {
|
|
17303
|
+
accessKeyId: uploads.s3key ?? "",
|
|
17304
|
+
secretAccessKey: uploads.s3secret ?? ""
|
|
17305
|
+
}
|
|
17306
|
+
});
|
|
17307
|
+
const client = s3Client2;
|
|
17308
|
+
return async ({ name, data, type }) => {
|
|
17309
|
+
const mime = getMimeType(type);
|
|
17310
|
+
const prefix = uploads.s3prefix ? `${uploads.s3prefix.replace(/\/$/, "")}/` : "";
|
|
17311
|
+
const key = `${prefix}${user?.id}/${generateS3Key(name)}${type}`;
|
|
17312
|
+
const command = new PutObjectCommand3({
|
|
17313
|
+
Bucket: uploads.s3Bucket,
|
|
17314
|
+
Key: key,
|
|
17315
|
+
Body: data,
|
|
17316
|
+
ContentType: mime
|
|
17317
|
+
});
|
|
17318
|
+
try {
|
|
17319
|
+
await client.send(command);
|
|
17320
|
+
const bucket = uploads.s3Bucket ?? "";
|
|
17321
|
+
const presignedUrl = await getPresignedUrl(bucket, key, exuluConfig);
|
|
17322
|
+
return { url: presignedUrl, key: `${bucket}/${key}` };
|
|
17323
|
+
} catch (caught) {
|
|
17324
|
+
if (caught instanceof S3ServiceException && caught.name === "EntityTooLarge") {
|
|
17325
|
+
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).`);
|
|
17326
|
+
} else if (caught instanceof S3ServiceException) {
|
|
17327
|
+
throw new Error(
|
|
17328
|
+
`[EXULU] Error from S3 while uploading object to ${uploads.s3Bucket}. ${caught.name}: ${caught.message}`
|
|
17329
|
+
);
|
|
17330
|
+
} else {
|
|
17331
|
+
throw caught;
|
|
17332
|
+
}
|
|
17333
|
+
}
|
|
17334
|
+
};
|
|
17335
|
+
};
|
|
17336
|
+
|
|
17271
17337
|
// src/utils/truncate-tool-output.ts
|
|
17272
17338
|
var truncateToolOutput = (output, maxContextLength, toolName, tailFraction = 0.1, charLimitOverride) => {
|
|
17273
17339
|
const effectiveCtx = maxContextLength != null && maxContextLength > 0 ? maxContextLength : 128e3;
|
|
@@ -17292,7 +17358,7 @@ var truncateToolOutput = (output, maxContextLength, toolName, tailFraction = 0.1
|
|
|
17292
17358
|
};
|
|
17293
17359
|
|
|
17294
17360
|
// src/exulu/tool-output-offload.ts
|
|
17295
|
-
import { randomUUID as
|
|
17361
|
+
import { randomUUID as randomUUID9 } from "crypto";
|
|
17296
17362
|
|
|
17297
17363
|
// src/exulu/context-budget.ts
|
|
17298
17364
|
var DEFAULT_CONTEXT_WINDOW = 128e3;
|
|
@@ -17396,7 +17462,7 @@ var PREVIEW_CHARS = 4e3;
|
|
|
17396
17462
|
var storeAsSessionFile = async (serialized, ctx) => {
|
|
17397
17463
|
if (!ctx.sessionID || !ctx.exuluConfig?.fileUploads) return void 0;
|
|
17398
17464
|
const safeTool = ctx.toolName.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 40);
|
|
17399
|
-
const name = `tool-output-${safeTool}-${
|
|
17465
|
+
const name = `tool-output-${safeTool}-${randomUUID9().slice(0, 8)}.txt`;
|
|
17400
17466
|
try {
|
|
17401
17467
|
await uploadFile(
|
|
17402
17468
|
Buffer.from(serialized, "utf-8"),
|
|
@@ -17563,7 +17629,6 @@ var createSessionFileReadTool = ({
|
|
|
17563
17629
|
// src/templates/tools/parse-document-tool.ts
|
|
17564
17630
|
import { z as z22 } from "zod";
|
|
17565
17631
|
import { extname as extname2 } from "path";
|
|
17566
|
-
import { parseOfficeAsync as parseOfficeAsync2 } from "officeparser";
|
|
17567
17632
|
|
|
17568
17633
|
// src/templates/tools/document-render-helpers.ts
|
|
17569
17634
|
import { execFile as execFile2 } from "child_process";
|
|
@@ -17663,7 +17728,6 @@ async function renderPdfPageToPng(pdf, page, scaleTo) {
|
|
|
17663
17728
|
}
|
|
17664
17729
|
|
|
17665
17730
|
// src/exulu/attachment-text.ts
|
|
17666
|
-
import { parseOfficeAsync } from "officeparser";
|
|
17667
17731
|
var DEFAULT_ATTACHMENT_MAX_PAGES = 50;
|
|
17668
17732
|
function attachmentMaxPages(env = process.env) {
|
|
17669
17733
|
const raw = env.EXULU_ATTACHMENT_MAX_PAGES;
|
|
@@ -17682,7 +17746,7 @@ function tooLongForToolNotice(filename, pageCount, maxPages) {
|
|
|
17682
17746
|
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
17747
|
}
|
|
17684
17748
|
var loadDocumentProcessor = async () => {
|
|
17685
|
-
const mod = await import("./doc_processor-
|
|
17749
|
+
const mod = await import("./doc_processor-VCFQZ5WI.js");
|
|
17686
17750
|
return mod.documentProcessor;
|
|
17687
17751
|
};
|
|
17688
17752
|
function pagesToText(pages) {
|
|
@@ -17700,7 +17764,7 @@ function pagesFromProcessor(result) {
|
|
|
17700
17764
|
function degradedPagesOf(result) {
|
|
17701
17765
|
return (result ?? []).filter((p) => p.vlm_failed).map((p) => p.page);
|
|
17702
17766
|
}
|
|
17703
|
-
var defaultOfficeParse =
|
|
17767
|
+
var defaultOfficeParse = (bytes) => officeToText(bytes);
|
|
17704
17768
|
async function extractDocument(input) {
|
|
17705
17769
|
const config = input.exuluConfig?.attachments?.documentProcessor;
|
|
17706
17770
|
if (config) {
|
|
@@ -18136,11 +18200,8 @@ ${text.trim()}`).join("\n")
|
|
|
18136
18200
|
};
|
|
18137
18201
|
}
|
|
18138
18202
|
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 };
|
|
18203
|
+
const parsed = await officeToText(officeBytes);
|
|
18204
|
+
return { text: parsed, storable: !processorFellBack };
|
|
18144
18205
|
};
|
|
18145
18206
|
const stored = await readThroughDocument({
|
|
18146
18207
|
io,
|
|
@@ -18574,8 +18635,6 @@ var isReadingProgress = (value) => {
|
|
|
18574
18635
|
return typeof v.filename === "string" && typeof v.pagesDone === "number" && typeof v.pagesTotal === "number";
|
|
18575
18636
|
};
|
|
18576
18637
|
var OUTPUT_OFFLOAD_EXEMPT_TOOL_IDS = /* @__PURE__ */ new Set(["agentic_context_search"]);
|
|
18577
|
-
var generateS3Key = (filename) => `${randomUUID9()}-${filename}`;
|
|
18578
|
-
var s3Client2;
|
|
18579
18638
|
var hydrateVariables = async (tool3) => {
|
|
18580
18639
|
const { db } = await postgresClient();
|
|
18581
18640
|
const promises = tool3.config.map(async (toolConfig) => {
|
|
@@ -18976,54 +19035,7 @@ var convertExuluToolsToAiSdkTools = async (currentTools, currentSkills, approved
|
|
|
18976
19035
|
if (toolVariableConfig) {
|
|
18977
19036
|
toolVariableConfig = await hydrateVariables(toolVariableConfig || []);
|
|
18978
19037
|
}
|
|
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
|
-
}
|
|
19038
|
+
const upload = buildToolUpload(exuluConfig, user);
|
|
19027
19039
|
const contextsMap = contexts?.reduce((acc, curr) => {
|
|
19028
19040
|
acc[curr.id] = curr;
|
|
19029
19041
|
return acc;
|
|
@@ -19345,6 +19357,7 @@ export {
|
|
|
19345
19357
|
SAVE_INVALID_NAME,
|
|
19346
19358
|
SAVE_EMPTY,
|
|
19347
19359
|
SAVE_FAILED,
|
|
19360
|
+
buildToolUpload,
|
|
19348
19361
|
truncateToolOutput,
|
|
19349
19362
|
DEFAULT_CONTEXT_WINDOW,
|
|
19350
19363
|
deriveContextBudget,
|
|
@@ -19361,11 +19374,14 @@ export {
|
|
|
19361
19374
|
SESSION_FILE_READ_TOOL_NAME,
|
|
19362
19375
|
extractDocument,
|
|
19363
19376
|
validateAttachmentsConfig,
|
|
19377
|
+
isInterimToolStatus,
|
|
19364
19378
|
PARSE_DOCUMENT_TOOL_NAME,
|
|
19365
19379
|
PreviewRenderError,
|
|
19366
19380
|
getPdfPreviewBytes,
|
|
19367
19381
|
imageAttachmentGuard,
|
|
19368
19382
|
VIEW_DOCUMENT_PAGE_TOOL_NAME,
|
|
19383
|
+
emitToolCallAudit,
|
|
19384
|
+
extractClientInfo,
|
|
19369
19385
|
OUTPUT_OFFLOAD_EXEMPT_TOOL_IDS,
|
|
19370
19386
|
hydrateVariables,
|
|
19371
19387
|
convertExuluToolsToAiSdkTools,
|
|
@@ -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-XVUJ3WIC.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,
|