@exulu/backend 5.21.0 → 5.23.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.
@@ -2,15 +2,22 @@ import "dotenv/config";
2
2
  import {
3
3
  buildTags,
4
4
  checkLicense,
5
+ convertLegacyOfficeToModern,
6
+ convertOfficeToPdf,
7
+ isLegacyOfficeFormat,
5
8
  isLiteLLMEnabled,
9
+ isPresentationFormat,
6
10
  officeToText,
11
+ pdfPageCount,
12
+ pdfToText,
7
13
  postgresClient,
8
14
  processWideLimiters,
9
15
  provisionDefaultUserBudget,
16
+ renderPdfPageToPng,
10
17
  resolveModel,
11
18
  waitForLiteLLMReady,
12
19
  withRetry
13
- } from "./chunk-43QIPMLT.js";
20
+ } from "./chunk-BFIDSFRQ.js";
14
21
  import {
15
22
  findLiteLLMModel
16
23
  } from "./chunk-F534XOQR.js";
@@ -681,7 +688,7 @@ var ExuluTool = class _ExuluTool {
681
688
  if (!agent) {
682
689
  throw new Error("Agent not found.");
683
690
  }
684
- const { convertExuluToolsToAiSdkTools: convertExuluToolsToAiSdkTools2 } = await import("./convert-exulu-tools-to-ai-sdk-tools-4TT2M2JH.js");
691
+ const { convertExuluToolsToAiSdkTools: convertExuluToolsToAiSdkTools2 } = await import("./convert-exulu-tools-to-ai-sdk-tools-XEPIBTZT.js");
685
692
  const tools = await convertExuluToolsToAiSdkTools2(
686
693
  [this],
687
694
  [],
@@ -861,6 +868,51 @@ var readAgentSlots = (value) => {
861
868
  })() : value;
862
869
  return Array.isArray(parsed) ? parsed : [];
863
870
  };
871
+ var EXTERNAL_LOGIN_ONLY = "External release requires a login share.";
872
+ var EXTERNAL_NEEDS_TEAM = "External release requires the share to be granted to at least one team.";
873
+ var EXTERNAL_SUPER_ADMIN_ONLY = "Only a super admin can release an artifact externally.";
874
+ var EXTERNAL_TEAM_NAME = "external";
875
+ var validateExternalAccess = (input) => {
876
+ const flag = input.external_access;
877
+ if (flag === void 0) return null;
878
+ if (typeof flag !== "boolean") return "external_access must be a boolean.";
879
+ if (!flag) return null;
880
+ if (input.auth_mode !== "regular") return EXTERNAL_LOGIN_ONLY;
881
+ const teams = input.teams ?? [];
882
+ if (input.rights_mode !== "teams" || teams.length === 0) return EXTERNAL_NEEDS_TEAM;
883
+ if (teams.some((t) => String(t.name).trim().toLowerCase() === EXTERNAL_TEAM_NAME)) {
884
+ return `The team "${EXTERNAL_TEAM_NAME}" holds self-registered guests and cannot be used for external release.`;
885
+ }
886
+ return null;
887
+ };
888
+ var mayChangeExternalRelease = (user, requested, current) => requested !== true || current === true || user.super_admin === true;
889
+ var teamNamesByIds = async (db, ids) => {
890
+ const clean = ids.filter((id) => id !== void 0 && id !== null);
891
+ if (!clean.length) return [];
892
+ const rows = await db("teams").whereIn("id", clean).select("name");
893
+ return rows;
894
+ };
895
+ var externalAccessCheckApplies = (input, row) => input.external_access !== void 0 || row.external_access === true;
896
+ var externalAccessNeedsTeams = (input, row) => {
897
+ const mode = input.auth_mode ?? row.auth_mode;
898
+ const effective = input.external_access !== void 0 ? input.external_access : row.external_access === true;
899
+ return effective === true && mode === "regular";
900
+ };
901
+ var validateExternalAccessUpdate = (input, row, teams) => {
902
+ const mode = input.auth_mode ?? row.auth_mode;
903
+ const effective = input.external_access !== void 0 ? input.external_access : row.external_access === true;
904
+ return validateExternalAccess({
905
+ external_access: effective,
906
+ auth_mode: mode,
907
+ rights_mode: resultingRightsMode(input, row),
908
+ teams
909
+ });
910
+ };
911
+ var resultingRightsMode = (input, row) => {
912
+ const mode = input.auth_mode ?? row.auth_mode;
913
+ if (mode !== "regular") return "public";
914
+ return input.rights_mode ?? (row.auth_mode === "regular" ? row.rights_mode ?? "private" : "private");
915
+ };
864
916
  var RIGHTS_MODES = /* @__PURE__ */ new Set(["private", "users", "roles", "teams", "public"]);
865
917
  var canManageShare = (row, user) => user.super_admin === true || row.created_by != null && String(row.created_by) === String(user.id);
866
918
  var validateUpdateInput = (input, row, now) => {
@@ -909,15 +961,12 @@ var planShareUpdate = (input, row, newPasswordHash, now) => {
909
961
  if (input.content_type !== void 0) patch.content_type = input.content_type;
910
962
  patch.password_hash = mode === "password" ? newPasswordHash ?? row.password_hash : null;
911
963
  if (input.expires_at !== void 0) patch.expires_at = input.expires_at;
912
- if (mode === "regular") {
913
- patch.rights_mode = input.rights_mode ?? (row.auth_mode === "regular" ? row.rights_mode ?? "private" : "private");
914
- } else {
915
- patch.rights_mode = "public";
916
- }
964
+ patch.rights_mode = resultingRightsMode(input, row);
917
965
  if (input.agent_slots !== void 0) {
918
966
  const slotsResult = validateAgentSlots(input.agent_slots);
919
967
  if (slotsResult.ok) patch.agent_slots = slotsResult.slots;
920
968
  }
969
+ if (typeof input.external_access === "boolean") patch.external_access = input.external_access;
921
970
  return patch;
922
971
  };
923
972
  var hashSharePassword = (password) => bcrypt.hash(password, 10);
@@ -7803,7 +7852,11 @@ var applyAccessControl = (table, query, user, field_prefix) => {
7803
7852
  );
7804
7853
  return query.whereRaw("1 = 0");
7805
7854
  }
7806
- if (table.name.plural !== "agent_sessions" && user?.super_admin === true) {
7855
+ const viaCompanion = user?.via_companion === true;
7856
+ if (viaCompanion && table.RBAC !== true) {
7857
+ return query.whereRaw("1 = 0");
7858
+ }
7859
+ if (!viaCompanion && table.name.plural !== "agent_sessions" && user?.super_admin === true) {
7807
7860
  return query;
7808
7861
  }
7809
7862
  if (user && !user?.super_admin && (table.name.plural === "agents" || table.name.plural === "workflow_templates" || table.name.plural === "variables" || table.name.plural === "users" || table.name.plural === "test_cases" || table.name.plural === "eval_sets" || table.name.plural === "eval_runs") && (!user?.role || !(table.name.plural === "agents" && (user.role.agents === "read" || user.role.agents === "write")) && !(table.name.plural === "workflow_templates" && (user.role.workflows === "read" || user.role.workflows === "write")) && !(table.name.plural === "variables" && (user.role.variables === "read" || user.role.variables === "write")) && !(table.name.plural === "users" && (user.role.users === "read" || user.role.users === "write")) && !((table.name.plural === "test_cases" || table.name.plural === "eval_sets" || table.name.plural === "eval_runs") && (user.role.evals === "read" || user.role.evals === "write")))) {
@@ -7819,16 +7872,20 @@ var applyAccessControl = (table, query, user, field_prefix) => {
7819
7872
  if (!hasRBAC) {
7820
7873
  return query;
7821
7874
  }
7822
- if (user?.super_admin) {
7875
+ if (!viaCompanion && user?.super_admin) {
7823
7876
  return query;
7824
7877
  }
7825
7878
  const prefix = field_prefix ? field_prefix + "." : "";
7826
7879
  console.log("[EXULU] applying access control with this prefix", prefix);
7827
7880
  try {
7828
7881
  query = query.where(function() {
7829
- this.where(`${prefix}rights_mode`, "public");
7882
+ if (!viaCompanion) {
7883
+ this.where(`${prefix}rights_mode`, "public");
7884
+ }
7830
7885
  if (user) {
7831
- this.orWhere(`${prefix}created_by`, user.id);
7886
+ if (!viaCompanion) {
7887
+ this.orWhere(`${prefix}created_by`, user.id);
7888
+ }
7832
7889
  this.orWhere(function() {
7833
7890
  this.where(`${prefix}rights_mode`, "users").whereExists(function() {
7834
7891
  this.select("*").from("rbac").whereRaw(
@@ -11658,6 +11715,9 @@ var sharedArtifactsSchema = {
11658
11715
  // to protect. /settings and /panel are unaffected: both read row.agent_slots
11659
11716
  // straight off the knex row, not through the generated GraphQL field.
11660
11717
  { name: "agent_slots", type: "json", hidden: true },
11718
+ // Released for the public companion server. Only meaningful for
11719
+ // auth_mode "regular" (validateExternalAccess). Not reported by /meta.
11720
+ { name: "external_access", type: "boolean", default: false },
11661
11721
  // Artifact library (2026-12): how a share presents itself and is found in
11662
11722
  // the Artifacts screen. All optional, all additive — a database that never
11663
11723
  // ran init-db for them reads them as absent, and every reader coerces.
@@ -12485,11 +12545,41 @@ function collectMemoryDecisions(messages) {
12485
12545
  import { z as z13 } from "zod";
12486
12546
  import { randomUUID as randomUUID3 } from "crypto";
12487
12547
 
12548
+ // src/exulu/companion/write-grant.ts
12549
+ var idOf = (v) => {
12550
+ const id = typeof v === "object" && v !== null ? v.id : v;
12551
+ if (typeof id === "number") return id;
12552
+ if (typeof id === "string" && id !== "") return id;
12553
+ return void 0;
12554
+ };
12555
+ var hasCompanionWriteGrant = async (db, entity, id, user, rightsMode) => {
12556
+ let grantee;
12557
+ if (rightsMode === "users") {
12558
+ grantee = { access_type: "User", user_id: user.id };
12559
+ } else if (rightsMode === "roles") {
12560
+ const roleId = idOf(user.role);
12561
+ if (roleId === void 0) return false;
12562
+ grantee = { access_type: "Role", role_id: roleId };
12563
+ } else if (rightsMode === "teams") {
12564
+ const teamId = idOf(user.team);
12565
+ if (teamId === void 0) return false;
12566
+ grantee = { access_type: "Team", team_id: teamId };
12567
+ } else {
12568
+ return false;
12569
+ }
12570
+ const grant = await db.from("rbac").where({ entity, target_resource_id: id, rights: "write", ...grantee }).first();
12571
+ return !!grant;
12572
+ };
12573
+
12488
12574
  // src/utils/check-item-write-access.ts
12489
12575
  var checkItemWriteAccess = async (context, record, user) => {
12490
12576
  if (!user) {
12491
12577
  return false;
12492
12578
  }
12579
+ if (user.via_companion === true) {
12580
+ const { db: db2 } = await postgresClient();
12581
+ return hasCompanionWriteGrant(db2, getTableName(context.id), record.id, user, record.rights_mode);
12582
+ }
12493
12583
  if (user.super_admin === true) {
12494
12584
  return true;
12495
12585
  }
@@ -13327,7 +13417,7 @@ import { z as z14 } from "zod";
13327
13417
 
13328
13418
  // src/exulu/project-access.ts
13329
13419
  var sameEntityId = (a, b) => a != null && b != null && a !== "" && b !== "" && String(a) === String(b);
13330
- var idOf = (v) => typeof v === "object" && v ? v.id : v;
13420
+ var idOf2 = (v) => typeof v === "object" && v ? v.id : v;
13331
13421
  function hasProjectAccess(args) {
13332
13422
  const { project, rbac, user, want } = args;
13333
13423
  if (user.super_admin) return true;
@@ -13340,9 +13430,9 @@ function hasProjectAccess(args) {
13340
13430
  case "users":
13341
13431
  return granted(rbac.users, user.id);
13342
13432
  case "roles":
13343
- return granted(rbac.roles, idOf(user.role));
13433
+ return granted(rbac.roles, idOf2(user.role));
13344
13434
  case "teams":
13345
- return granted(rbac.teams, idOf(user.team));
13435
+ return granted(rbac.teams, idOf2(user.team));
13346
13436
  default:
13347
13437
  return false;
13348
13438
  }
@@ -17545,7 +17635,8 @@ function buildSaveSessionFile(args) {
17545
17635
  if (!uploads?.s3endpoint || !uploads.s3key || !uploads.s3secret || !uploads.s3Bucket) {
17546
17636
  return void 0;
17547
17637
  }
17548
- if (args.inRoutineRun || treatAsGuest(args.req, args.user)) return void 0;
17638
+ if (args.inRoutineRun) return void 0;
17639
+ if (treatAsGuest(args.req, args.user) && !(args.user?.id && args.guestFiles)) return void 0;
17549
17640
  const ownerId = args.ownerId ?? args.user?.id;
17550
17641
  return (file) => writeSessionFile({
17551
17642
  ownerId,
@@ -17557,6 +17648,30 @@ function buildSaveSessionFile(args) {
17557
17648
  });
17558
17649
  }
17559
17650
 
17651
+ // src/exulu/guest-session-files.ts
17652
+ function guestFilesEnabled(agent) {
17653
+ return agent?.sandbox_enabled === true && (agent.guest_auth_mode || "regular") === "regular";
17654
+ }
17655
+ function agentAllowsGuestFiles(agent) {
17656
+ return agent?.guest_access === true && agent.active !== false && guestFilesEnabled(agent);
17657
+ }
17658
+ var GUEST_MAX_FILE_BYTES = MAX_ADOPT_UPLOAD_BYTES;
17659
+ var GUEST_MAX_SESSION_FILES = 50;
17660
+ var GUEST_MAX_SESSION_BYTES = 250 * 1024 * 1024;
17661
+ function guestUploadRefusal(objects) {
17662
+ if (objects.length >= GUEST_MAX_SESSION_FILES) {
17663
+ return `This conversation already holds ${GUEST_MAX_SESSION_FILES} files. Remove one or start a new conversation.`;
17664
+ }
17665
+ const total = objects.reduce((sum, object) => sum + (object.size || 0), 0);
17666
+ if (total >= GUEST_MAX_SESSION_BYTES) {
17667
+ return "This conversation's file storage is full. Remove a file or start a new conversation.";
17668
+ }
17669
+ return void 0;
17670
+ }
17671
+ function guestFileTooLarge(size) {
17672
+ return typeof size === "number" && size > GUEST_MAX_FILE_BYTES;
17673
+ }
17674
+
17560
17675
  // src/templates/tools/routine-status-tool.ts
17561
17676
  import { z as z20 } from "zod";
17562
17677
  var SET_ROUTINE_STATUS_TOOL_ID = "set_routine_status";
@@ -17933,103 +18048,6 @@ var createSessionFileReadTool = ({
17933
18048
  import { z as z22 } from "zod";
17934
18049
  import { extname as extname2 } from "path";
17935
18050
 
17936
- // src/templates/tools/document-render-helpers.ts
17937
- import { execFile as execFile2 } from "child_process";
17938
- import { promisify as promisify4 } from "util";
17939
- import { existsSync as existsSync5 } from "fs";
17940
- import { mkdtemp, readdir as readdir3, readFile as readFile2, rm as rm3, writeFile as writeFile3 } from "fs/promises";
17941
- import { tmpdir } from "os";
17942
- import { join as join7 } from "path";
17943
- var execFileAsync2 = promisify4(execFile2);
17944
- var MAX_STDOUT_BYTES = 64 * 1024 * 1024;
17945
- var LEGACY_OFFICE_CONVERSION_TARGETS = {
17946
- ".doc": "docx",
17947
- ".xls": "xlsx",
17948
- ".ppt": "pptx",
17949
- ".rtf": "docx"
17950
- };
17951
- function isLegacyOfficeFormat(ext) {
17952
- return ext in LEGACY_OFFICE_CONVERSION_TARGETS;
17953
- }
17954
- async function convertLegacyOfficeToModern(bytes, ext) {
17955
- const target = LEGACY_OFFICE_CONVERSION_TARGETS[ext];
17956
- if (!target) {
17957
- throw new Error(`No modern-format conversion target registered for "${ext}"`);
17958
- }
17959
- const dir = await mkdtemp(join7(tmpdir(), "exulu-officeconv-"));
17960
- try {
17961
- const inputPath = join7(dir, `input${ext}`);
17962
- await writeFile3(inputPath, bytes);
17963
- try {
17964
- await execFileAsync2(
17965
- "soffice",
17966
- ["--headless", "--convert-to", target, inputPath, "--outdir", dir],
17967
- { timeout: 6e4, maxBuffer: MAX_STDOUT_BYTES }
17968
- );
17969
- } catch (err3) {
17970
- throw new Error(
17971
- `LibreOffice could not convert the legacy "${ext}" file to ${target}: ` + (err3 instanceof Error ? err3.message : String(err3))
17972
- );
17973
- }
17974
- const outputPath = join7(dir, `input.${target}`);
17975
- if (!existsSync5(outputPath)) {
17976
- throw new Error(`LibreOffice produced no output converting "${ext}" to ${target}`);
17977
- }
17978
- return await readFile2(outputPath);
17979
- } finally {
17980
- await rm3(dir, { recursive: true, force: true });
17981
- }
17982
- }
17983
- async function pdfToText(pdf) {
17984
- const dir = await mkdtemp(join7(tmpdir(), "exulu-parse-"));
17985
- try {
17986
- const inputPath = join7(dir, "input.pdf");
17987
- await writeFile3(inputPath, pdf);
17988
- const { stdout } = await execFileAsync2("pdftotext", ["-layout", inputPath, "-"], {
17989
- timeout: 6e4,
17990
- maxBuffer: MAX_STDOUT_BYTES
17991
- });
17992
- return stdout;
17993
- } finally {
17994
- await rm3(dir, { recursive: true, force: true });
17995
- }
17996
- }
17997
- async function pdfPageCount(pdf) {
17998
- const dir = await mkdtemp(join7(tmpdir(), "exulu-pdfinfo-"));
17999
- try {
18000
- const inputPath = join7(dir, "input.pdf");
18001
- await writeFile3(inputPath, pdf);
18002
- const { stdout } = await execFileAsync2("pdfinfo", [inputPath], { timeout: 3e4, maxBuffer: 1e6 });
18003
- const match = /^Pages:\s+(\d+)/m.exec(stdout);
18004
- if (!match) throw new Error("pdfinfo did not report a page count");
18005
- return Number(match[1]);
18006
- } finally {
18007
- await rm3(dir, { recursive: true, force: true });
18008
- }
18009
- }
18010
- async function renderPdfPageToPng(pdf, page, scaleTo) {
18011
- const dir = await mkdtemp(join7(tmpdir(), "exulu-render-"));
18012
- try {
18013
- const inputPath = join7(dir, "input.pdf");
18014
- await writeFile3(inputPath, pdf);
18015
- try {
18016
- await execFileAsync2(
18017
- "pdftoppm",
18018
- ["-png", "-f", String(page), "-l", String(page), "-scale-to", String(scaleTo), inputPath, join7(dir, "page")],
18019
- { timeout: 6e4, maxBuffer: MAX_STDOUT_BYTES }
18020
- );
18021
- } catch (err3) {
18022
- if (err3?.code === 99) return null;
18023
- throw err3;
18024
- }
18025
- const produced = (await readdir3(dir)).find((f) => f.startsWith("page") && f.endsWith(".png"));
18026
- if (!produced) return null;
18027
- return await readFile2(join7(dir, produced));
18028
- } finally {
18029
- await rm3(dir, { recursive: true, force: true });
18030
- }
18031
- }
18032
-
18033
18051
  // src/exulu/attachment-text.ts
18034
18052
  var DEFAULT_ATTACHMENT_MAX_PAGES = 50;
18035
18053
  function attachmentMaxPages(env = process.env) {
@@ -18049,7 +18067,7 @@ function tooLongForToolNotice(filename, pageCount, maxPages) {
18049
18067
  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.]`;
18050
18068
  }
18051
18069
  var loadDocumentProcessor = async () => {
18052
- const mod = await import("./doc_processor-VCFQZ5WI.js");
18070
+ const mod = await import("./doc_processor-SR7ZCECL.js");
18053
18071
  return mod.documentProcessor;
18054
18072
  };
18055
18073
  function pagesToText(pages) {
@@ -18070,7 +18088,17 @@ function degradedPagesOf(result) {
18070
18088
  var defaultOfficeParse = (bytes) => officeToText(bytes);
18071
18089
  async function extractDocument(input) {
18072
18090
  const config = input.exuluConfig?.attachments?.documentProcessor;
18091
+ const original = input;
18073
18092
  if (config) {
18093
+ const ext = input.filename.slice(input.filename.lastIndexOf(".")).toLowerCase();
18094
+ if (isPresentationFormat(ext)) {
18095
+ try {
18096
+ const pdf = await (input.toPdf ?? convertOfficeToPdf)(input.bytes, ext);
18097
+ input = { ...input, bytes: pdf, filename: `${input.filename.slice(0, -ext.length)}.pdf` };
18098
+ } catch (error) {
18099
+ console.warn(`[EXULU] Could not render ${input.filename} to PDF:`, error instanceof Error ? error.message : String(error));
18100
+ }
18101
+ }
18074
18102
  if (input.filename.toLowerCase().endsWith(".pdf")) {
18075
18103
  const forTool = input.maxPages !== void 0;
18076
18104
  const maxPages = input.maxPages ?? attachmentMaxPages();
@@ -18084,7 +18112,7 @@ async function extractDocument(input) {
18084
18112
  console.warn(`[EXULU] ${input.filename} has ${pageCount} pages, over the ${forTool ? "document" : "attachment"} cap of ${maxPages}; not read.`);
18085
18113
  return {
18086
18114
  pages: [],
18087
- text: (forTool ? tooLongForToolNotice : tooLongNotice)(input.filename, pageCount, maxPages),
18115
+ text: (forTool ? tooLongForToolNotice : tooLongNotice)(original.filename, pageCount, maxPages),
18088
18116
  engine: "document-processor",
18089
18117
  tooLong: { pageCount, maxPages }
18090
18118
  };
@@ -18120,7 +18148,7 @@ async function extractDocument(input) {
18120
18148
  );
18121
18149
  }
18122
18150
  }
18123
- const text = (await (input.officeParse ?? defaultOfficeParse)(input.bytes)).trim();
18151
+ const text = (await (input.officeParse ?? defaultOfficeParse)(original.bytes)).trim();
18124
18152
  return { pages: [{ page: 1, text }], text, engine: "officeparser" };
18125
18153
  }
18126
18154
  var PROCESSOR_NAMES = /* @__PURE__ */ new Set(["liteparse", "mistral", "officeparser"]);
@@ -18617,14 +18645,14 @@ import { extname as extname4 } from "path";
18617
18645
 
18618
18646
  // src/sessions/pdf-preview-cache.ts
18619
18647
  import { exec as exec3 } from "child_process";
18620
- import { existsSync as existsSync6 } from "fs";
18621
- import { mkdir as mkdir5, readFile as readFile3, rename as rename3, rm as rm4, writeFile as writeFile4 } from "fs/promises";
18622
- import { extname as extname3, join as join8 } from "path";
18623
- import { promisify as promisify5 } from "util";
18624
- var execAsync3 = promisify5(exec3);
18648
+ import { existsSync as existsSync5 } from "fs";
18649
+ import { mkdir as mkdir5, readFile as readFile2, rename as rename3, rm as rm3, writeFile as writeFile3 } from "fs/promises";
18650
+ import { extname as extname3, join as join7 } from "path";
18651
+ import { promisify as promisify4 } from "util";
18652
+ var execAsync3 = promisify4(exec3);
18625
18653
  var CACHE_ROOT = "/tmp/exulu-pdf-cache";
18626
- var CACHE_IN = join8(CACHE_ROOT, "_in");
18627
- var CACHE_OUT = join8(CACHE_ROOT, "_out");
18654
+ var CACHE_IN = join7(CACHE_ROOT, "_in");
18655
+ var CACHE_OUT = join7(CACHE_ROOT, "_out");
18628
18656
  var inFlight2 = /* @__PURE__ */ new Map();
18629
18657
  var PreviewRenderError = class extends Error {
18630
18658
  constructor(message) {
@@ -18641,9 +18669,9 @@ async function getPdfPreviewBytes(opts) {
18641
18669
  if (!safeEtag) {
18642
18670
  throw new PreviewRenderError(`Invalid ETag for ${sourceKey}`);
18643
18671
  }
18644
- const cachedPath = join8(CACHE_ROOT, `${safeEtag}.pdf`);
18645
- if (existsSync6(cachedPath)) {
18646
- return readFile3(cachedPath);
18672
+ const cachedPath = join7(CACHE_ROOT, `${safeEtag}.pdf`);
18673
+ if (existsSync5(cachedPath)) {
18674
+ return readFile2(cachedPath);
18647
18675
  }
18648
18676
  const existing = inFlight2.get(safeEtag);
18649
18677
  if (existing) return existing;
@@ -18652,11 +18680,11 @@ async function getPdfPreviewBytes(opts) {
18652
18680
  await mkdir5(CACHE_IN, { recursive: true });
18653
18681
  await mkdir5(CACHE_OUT, { recursive: true });
18654
18682
  const ext = (extname3(sourceKey) || ".docx").toLowerCase();
18655
- const inputPath = join8(CACHE_IN, `${safeEtag}${ext}`);
18656
- const outputPath = join8(CACHE_OUT, `${safeEtag}.pdf`);
18683
+ const inputPath = join7(CACHE_IN, `${safeEtag}${ext}`);
18684
+ const outputPath = join7(CACHE_OUT, `${safeEtag}.pdf`);
18657
18685
  try {
18658
18686
  const bytes = await getS3ObjectBytes(sourceKey, config);
18659
- await writeFile4(inputPath, bytes);
18687
+ await writeFile3(inputPath, bytes);
18660
18688
  try {
18661
18689
  await execAsync3(
18662
18690
  `soffice --headless --convert-to pdf "${inputPath}" --outdir "${CACHE_OUT}"`,
@@ -18667,15 +18695,15 @@ async function getPdfPreviewBytes(opts) {
18667
18695
  `LibreOffice conversion failed for ${sourceKey} (etag ${etag}): ${err3?.stderr ?? err3?.message ?? "unknown error"}`
18668
18696
  );
18669
18697
  }
18670
- if (!existsSync6(outputPath)) {
18698
+ if (!existsSync5(outputPath)) {
18671
18699
  throw new PreviewRenderError(
18672
18700
  `LibreOffice produced no output for ${sourceKey} (etag ${etag})`
18673
18701
  );
18674
18702
  }
18675
18703
  await rename3(outputPath, cachedPath);
18676
- return await readFile3(cachedPath);
18704
+ return await readFile2(cachedPath);
18677
18705
  } finally {
18678
- await rm4(inputPath, { force: true });
18706
+ await rm3(inputPath, { force: true });
18679
18707
  }
18680
18708
  } finally {
18681
18709
  inFlight2.delete(safeEtag);
@@ -19374,7 +19402,8 @@ var convertExuluToolsToAiSdkTools = async (currentTools, currentSkills, approved
19374
19402
  user,
19375
19403
  req,
19376
19404
  exuluConfig,
19377
- inRoutineRun: inRoutineRun ?? Boolean(routineHandleFactory)
19405
+ inRoutineRun: inRoutineRun ?? Boolean(routineHandleFactory),
19406
+ guestFiles: agentAllowsGuestFiles(agent)
19378
19407
  }),
19379
19408
  exuluConfig,
19380
19409
  toolVariablesConfig: toolVariablesConfigData,
@@ -19473,6 +19502,7 @@ export {
19473
19502
  sanitizeFilename,
19474
19503
  MAX_PROJECT_FILES,
19475
19504
  projectFilePrefix,
19505
+ isProjectKey,
19476
19506
  DERIVED_ROOT,
19477
19507
  isDerivedKey,
19478
19508
  documentCacheDays,
@@ -19483,6 +19513,8 @@ export {
19483
19513
  getS3ObjectContent,
19484
19514
  getS3ObjectStream,
19485
19515
  getS3ObjectEtag,
19516
+ mayUseGenericS3Route,
19517
+ mayReadGenericS3Key,
19486
19518
  getS3ObjectSize,
19487
19519
  getS3ObjectBytes,
19488
19520
  deleteS3Object,
@@ -19589,6 +19621,13 @@ export {
19589
19621
  isExpired,
19590
19622
  validateCreateInput,
19591
19623
  readAgentSlots,
19624
+ EXTERNAL_SUPER_ADMIN_ONLY,
19625
+ validateExternalAccess,
19626
+ mayChangeExternalRelease,
19627
+ teamNamesByIds,
19628
+ externalAccessCheckApplies,
19629
+ externalAccessNeedsTeams,
19630
+ validateExternalAccessUpdate,
19592
19631
  canManageShare,
19593
19632
  validateUpdateInput,
19594
19633
  ownsObjectKey,
@@ -19624,6 +19663,7 @@ export {
19624
19663
  buildMemoryPromptBlock,
19625
19664
  normalizeRbac,
19626
19665
  collectMemoryDecisions,
19666
+ hasCompanionWriteGrant,
19627
19667
  PUBLIC_SURFACE_HEADER,
19628
19668
  isPublicSurface,
19629
19669
  treatAsGuest,
@@ -19676,6 +19716,10 @@ export {
19676
19716
  SAVE_INVALID_NAME,
19677
19717
  SAVE_EMPTY,
19678
19718
  SAVE_FAILED,
19719
+ guestFilesEnabled,
19720
+ agentAllowsGuestFiles,
19721
+ guestUploadRefusal,
19722
+ guestFileTooLarge,
19679
19723
  buildToolUpload,
19680
19724
  truncateToolOutput,
19681
19725
  DEFAULT_CONTEXT_WINDOW,
@@ -3,8 +3,8 @@ import {
3
3
  OUTPUT_OFFLOAD_EXEMPT_TOOL_IDS,
4
4
  convertExuluToolsToAiSdkTools,
5
5
  hydrateVariables
6
- } from "./chunk-YTW26TUA.js";
7
- import "./chunk-43QIPMLT.js";
6
+ } from "./chunk-K7CGLUW4.js";
7
+ import "./chunk-BFIDSFRQ.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-Q4DFJFUI.js";
5
+ } from "./chunk-DAVYWGEE.js";
6
6
  import "./chunk-NJWNOXLJ.js";
7
- import "./chunk-43QIPMLT.js";
7
+ import "./chunk-BFIDSFRQ.js";
8
8
  import "./chunk-6URU62NI.js";
9
9
  export {
10
10
  documentProcessor,