@exulu/backend 5.7.1 → 5.7.2

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.
@@ -1723,7 +1723,7 @@ var ExuluTool = class _ExuluTool {
1723
1723
  if (!agent) {
1724
1724
  throw new Error("Agent not found.");
1725
1725
  }
1726
- const { convertExuluToolsToAiSdkTools: convertExuluToolsToAiSdkTools2 } = await import("./convert-exulu-tools-to-ai-sdk-tools-XOL5J5ET.js");
1726
+ const { convertExuluToolsToAiSdkTools: convertExuluToolsToAiSdkTools2 } = await import("./convert-exulu-tools-to-ai-sdk-tools-L6SESYPH.js");
1727
1727
  const tools = await convertExuluToolsToAiSdkTools2(
1728
1728
  [this],
1729
1729
  [],
@@ -13285,6 +13285,41 @@ var buildSkillEnv = ({
13285
13285
  };
13286
13286
  };
13287
13287
 
13288
+ // ee/invoke-skills/binary-file-guard.ts
13289
+ var BINARY_DOCUMENT_EXTENSIONS = /* @__PURE__ */ new Set([
13290
+ ".pdf",
13291
+ ".doc",
13292
+ ".docx",
13293
+ ".xls",
13294
+ ".xlsx",
13295
+ ".ppt",
13296
+ ".pptx",
13297
+ ".odt",
13298
+ ".ods",
13299
+ ".odp",
13300
+ ".zip",
13301
+ ".gz",
13302
+ ".png",
13303
+ ".jpg",
13304
+ ".jpeg",
13305
+ ".gif",
13306
+ ".bmp",
13307
+ ".tif",
13308
+ ".tiff",
13309
+ ".webp"
13310
+ ]);
13311
+ function isBinaryDocumentPath(path3) {
13312
+ const dot = path3.lastIndexOf(".");
13313
+ if (dot < 0) return false;
13314
+ return BINARY_DOCUMENT_EXTENSIONS.has(path3.slice(dot).toLowerCase());
13315
+ }
13316
+ function looksBinary(content) {
13317
+ return content.slice(0, 8192).includes("\0");
13318
+ }
13319
+ function binaryReadHint(path3) {
13320
+ return `"${path3}" is a binary file \u2014 readFile would return raw bytes that cannot be interpreted and would flood the context. The text of mail attachments is already in the conversation (the <file file name=\u2026> block); for other documents use parse_document to extract the text first, then read within that extracted text.`;
13321
+ }
13322
+
13288
13323
  // ee/invoke-skills/variable-grants.ts
13289
13324
  var selectRowsToDecrypt = (rows) => rows.filter((row) => Boolean(row?.name) && row.allow_skill_access === true);
13290
13325
  var deriveWithheldNames = (rows, granted) => [
@@ -14408,7 +14443,13 @@ Probe error: ${probe.reason ?? "(no detail)"}`
14408
14443
  }),
14409
14444
  execute: async ({ path: path3 }) => {
14410
14445
  const resolvedPath = resolveSessionPath(path3, sessionDir);
14446
+ if (isBinaryDocumentPath(resolvedPath)) {
14447
+ return { content: "", error: binaryReadHint(path3) };
14448
+ }
14411
14449
  const content = await customSandbox.readFile(resolvedPath);
14450
+ if (looksBinary(content)) {
14451
+ return { content: "", error: binaryReadHint(path3) };
14452
+ }
14412
14453
  return { content };
14413
14454
  }
14414
14455
  });
@@ -3,7 +3,7 @@ import {
3
3
  OUTPUT_OFFLOAD_EXEMPT_TOOL_IDS,
4
4
  convertExuluToolsToAiSdkTools,
5
5
  hydrateVariables
6
- } from "./chunk-XNTGIQLC.js";
6
+ } from "./chunk-RELZZYVA.js";
7
7
  import "./chunk-4PDWNVNT.js";
8
8
  export {
9
9
  OUTPUT_OFFLOAD_EXEMPT_TOOL_IDS,
package/dist/index.cjs CHANGED
@@ -11308,6 +11308,48 @@ var init_skill_env = __esm({
11308
11308
  }
11309
11309
  });
11310
11310
 
11311
+ // ee/invoke-skills/binary-file-guard.ts
11312
+ function isBinaryDocumentPath(path4) {
11313
+ const dot = path4.lastIndexOf(".");
11314
+ if (dot < 0) return false;
11315
+ return BINARY_DOCUMENT_EXTENSIONS.has(path4.slice(dot).toLowerCase());
11316
+ }
11317
+ function looksBinary(content) {
11318
+ return content.slice(0, 8192).includes("\0");
11319
+ }
11320
+ function binaryReadHint(path4) {
11321
+ return `"${path4}" is a binary file \u2014 readFile would return raw bytes that cannot be interpreted and would flood the context. The text of mail attachments is already in the conversation (the <file file name=\u2026> block); for other documents use parse_document to extract the text first, then read within that extracted text.`;
11322
+ }
11323
+ var BINARY_DOCUMENT_EXTENSIONS;
11324
+ var init_binary_file_guard = __esm({
11325
+ "ee/invoke-skills/binary-file-guard.ts"() {
11326
+ "use strict";
11327
+ init_cjs_shims();
11328
+ BINARY_DOCUMENT_EXTENSIONS = /* @__PURE__ */ new Set([
11329
+ ".pdf",
11330
+ ".doc",
11331
+ ".docx",
11332
+ ".xls",
11333
+ ".xlsx",
11334
+ ".ppt",
11335
+ ".pptx",
11336
+ ".odt",
11337
+ ".ods",
11338
+ ".odp",
11339
+ ".zip",
11340
+ ".gz",
11341
+ ".png",
11342
+ ".jpg",
11343
+ ".jpeg",
11344
+ ".gif",
11345
+ ".bmp",
11346
+ ".tif",
11347
+ ".tiff",
11348
+ ".webp"
11349
+ ]);
11350
+ }
11351
+ });
11352
+
11311
11353
  // ee/invoke-skills/variable-grants.ts
11312
11354
  var selectRowsToDecrypt, deriveWithheldNames, selectGrantedVariables;
11313
11355
  var init_variable_grants = __esm({
@@ -12690,7 +12732,13 @@ Probe error: ${probe.reason ?? "(no detail)"}`
12690
12732
  }),
12691
12733
  execute: async ({ path: path4 }) => {
12692
12734
  const resolvedPath = resolveSessionPath(path4, sessionDir);
12735
+ if (isBinaryDocumentPath(resolvedPath)) {
12736
+ return { content: "", error: binaryReadHint(path4) };
12737
+ }
12693
12738
  const content = await customSandbox.readFile(resolvedPath);
12739
+ if (looksBinary(content)) {
12740
+ return { content: "", error: binaryReadHint(path4) };
12741
+ }
12694
12742
  return { content };
12695
12743
  }
12696
12744
  });
@@ -12788,6 +12836,7 @@ var init_create_sandbox = __esm({
12788
12836
  init_artifact_filter();
12789
12837
  init_system_dependencies();
12790
12838
  init_skill_env();
12839
+ init_binary_file_guard();
12791
12840
  init_variable_grants();
12792
12841
  init_os_environ_names();
12793
12842
  init_logger();
@@ -21330,6 +21379,12 @@ var bullmq = {
21330
21379
  }
21331
21380
  };
21332
21381
 
21382
+ // src/utils/jsonb-safe.ts
21383
+ init_cjs_shims();
21384
+ function jsonbSafeStringify(value) {
21385
+ return JSON.stringify(value).replace(/\\u0000/g, "");
21386
+ }
21387
+
21333
21388
  // src/exulu/turn-metadata.ts
21334
21389
  init_cjs_shims();
21335
21390
  function finishTurnMetadata(opts) {
@@ -24442,8 +24497,8 @@ var createWorkers = async (queues2, config, contexts, evals, tools, tracer) => {
24442
24497
  );
24443
24498
  if (result.pausedAtStepIndex !== void 0) {
24444
24499
  await db2.from("job_results").where({ id: jobResultId }).update({
24445
- result: messages.length > 0 ? JSON.stringify(messages[messages.length - 1]) : null,
24446
- metadata: JSON.stringify({
24500
+ result: messages.length > 0 ? jsonbSafeStringify(messages[messages.length - 1]) : null,
24501
+ metadata: jsonbSafeStringify({
24447
24502
  messages,
24448
24503
  ...metadata,
24449
24504
  tokens,
@@ -24931,8 +24986,9 @@ var createWorkers = async (queues2, config, contexts, evals, tools, tracer) => {
24931
24986
  const { db: db2 } = await postgresClient();
24932
24987
  await db2.from("job_results").where({ job_id: job.id, state: JOB_STATUS_ENUM.active }).update({
24933
24988
  state: JOB_STATUS_ENUM.completed,
24934
- result: returnvalue.result != null ? JSON.stringify(returnvalue.result) : null,
24935
- metadata: returnvalue.metadata != null ? JSON.stringify(returnvalue.metadata) : null
24989
+ // jsonb rejects the NUL escape; a raw attachment read can carry it (2026-10-29).
24990
+ result: returnvalue.result != null ? jsonbSafeStringify(returnvalue.result) : null,
24991
+ metadata: returnvalue.metadata != null ? jsonbSafeStringify(returnvalue.metadata) : null
24936
24992
  });
24937
24993
  void maybePruneJobResults(db2);
24938
24994
  }
package/dist/index.js CHANGED
@@ -208,7 +208,7 @@ import {
208
208
  willEmbedOnQueue,
209
209
  withRetry,
210
210
  workflowTemplatesSchema
211
- } from "./chunk-XNTGIQLC.js";
211
+ } from "./chunk-RELZZYVA.js";
212
212
  import {
213
213
  LiteLLMAdminError,
214
214
  findLiteLLMModel,
@@ -3963,6 +3963,11 @@ var bullmq = {
3963
3963
  }
3964
3964
  };
3965
3965
 
3966
+ // src/utils/jsonb-safe.ts
3967
+ function jsonbSafeStringify(value) {
3968
+ return JSON.stringify(value).replace(/\\u0000/g, "");
3969
+ }
3970
+
3966
3971
  // src/exulu/turn-metadata.ts
3967
3972
  function finishTurnMetadata(opts) {
3968
3973
  const now = opts.now ?? Date.now();
@@ -6965,8 +6970,8 @@ var createWorkers = async (queues2, config, contexts, evals, tools, tracer) => {
6965
6970
  );
6966
6971
  if (result.pausedAtStepIndex !== void 0) {
6967
6972
  await db.from("job_results").where({ id: jobResultId }).update({
6968
- result: messages.length > 0 ? JSON.stringify(messages[messages.length - 1]) : null,
6969
- metadata: JSON.stringify({
6973
+ result: messages.length > 0 ? jsonbSafeStringify(messages[messages.length - 1]) : null,
6974
+ metadata: jsonbSafeStringify({
6970
6975
  messages,
6971
6976
  ...metadata,
6972
6977
  tokens,
@@ -7454,8 +7459,9 @@ var createWorkers = async (queues2, config, contexts, evals, tools, tracer) => {
7454
7459
  const { db } = await postgresClient();
7455
7460
  await db.from("job_results").where({ job_id: job.id, state: JOB_STATUS_ENUM.active }).update({
7456
7461
  state: JOB_STATUS_ENUM.completed,
7457
- result: returnvalue.result != null ? JSON.stringify(returnvalue.result) : null,
7458
- metadata: returnvalue.metadata != null ? JSON.stringify(returnvalue.metadata) : null
7462
+ // jsonb rejects the NUL escape; a raw attachment read can carry it (2026-10-29).
7463
+ result: returnvalue.result != null ? jsonbSafeStringify(returnvalue.result) : null,
7464
+ metadata: returnvalue.metadata != null ? jsonbSafeStringify(returnvalue.metadata) : null
7459
7465
  });
7460
7466
  void maybePruneJobResults(db);
7461
7467
  }
@@ -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
  })
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 ? JSON.stringify(messages[messages.length - 1]) : null,
709
- metadata: JSON.stringify({
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
- result: returnvalue.result != null ? JSON.stringify(returnvalue.result) : null,
1378
- metadata: returnvalue.metadata != null ? JSON.stringify(returnvalue.metadata) : null,
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).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@exulu/backend",
3
3
  "author": "Qventu B.V.",
4
- "version": "5.7.1",
4
+ "version": "5.7.2",
5
5
  "main": "./dist/index.js",
6
6
  "private": false,
7
7
  "publishConfig": {