@tangle-network/agent-app 0.58.1 → 0.58.3

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.
@@ -577,6 +577,9 @@ function formatSandboxProvisioningUserMessage(diagnostics) {
577
577
  return "I'm unable to reconnect to the sandbox because its runtime authentication failed. This can happen when an existing sandbox is reused with stale credentials.";
578
578
  }
579
579
  if (diagnostics.causes.some((cause) => cause.code === "PAYLOAD_TOO_LARGE" || cause.code === "FILE_TOO_LARGE" || cause.status === 413 || cause.status === "413")) {
580
+ if (diagnostics.causes.some((cause) => cause.message?.startsWith("writeProfileFilesToBox"))) {
581
+ return "A workspace file is too large to copy into the sandbox. The support details name the file.";
582
+ }
580
583
  return "An attachment is too large for the sandbox to accept. Use a smaller file and try again.";
581
584
  }
582
585
  if (diagnostics.causes.some((cause) => cause.code === "UPLOAD_BUDGET_EXHAUSTED")) {
@@ -1411,6 +1414,12 @@ function isExecutableProfileFile(mount) {
1411
1414
  function profileFileMode(mount) {
1412
1415
  return isExecutableProfileFile(mount) ? 493 : void 0;
1413
1416
  }
1417
+ var PROFILE_FILE_API_MAX_JSON_BYTES = 1024 * 1024 - 16 * 1024;
1418
+ function fitsProfileFileApi(content) {
1419
+ const encoder = new TextEncoder();
1420
+ if (encoder.encode(content).byteLength * 6 <= PROFILE_FILE_API_MAX_JSON_BYTES) return true;
1421
+ return encoder.encode(JSON.stringify(content)).byteLength <= PROFILE_FILE_API_MAX_JSON_BYTES;
1422
+ }
1414
1423
  function fileApiSupportsMode(box) {
1415
1424
  const fs = box.fs;
1416
1425
  return fs?.supportsWriteMode === true;
@@ -1421,7 +1430,9 @@ async function writeProfileFilesToBox(box, files, options = {}) {
1421
1430
  const maxRetries = options.maxRetries ?? PROFILE_WRITE_MAX_RETRIES;
1422
1431
  const fileApiAvailable = typeof box.fs?.writeMany === "function";
1423
1432
  const modeAwareFileApi = fileApiSupportsMode(box);
1433
+ const uploadData = box.fs?.uploadData;
1424
1434
  const viaFileApi = [];
1435
+ const viaUpload = [];
1425
1436
  const viaExec = [];
1426
1437
  for (const mount of files) {
1427
1438
  if (mount.resource.kind !== "inline") continue;
@@ -1429,11 +1440,11 @@ async function writeProfileFilesToBox(box, files, options = {}) {
1429
1440
  const executable = isExecutableProfileFile(mount);
1430
1441
  if (fileApiPath !== null && (!executable || modeAwareFileApi)) {
1431
1442
  const mode = profileFileMode(mount);
1432
- viaFileApi.push({
1433
- path: fileApiPath,
1434
- content: mount.resource.content ?? "",
1435
- ...mode !== void 0 ? { mode } : {}
1436
- });
1443
+ const content = mount.resource.content ?? "";
1444
+ const write = { path: fileApiPath, content, ...mode !== void 0 ? { mode } : {} };
1445
+ if (fitsProfileFileApi(content)) viaFileApi.push(write);
1446
+ else if (typeof uploadData === "function") viaUpload.push(write);
1447
+ else viaExec.push(mount);
1437
1448
  } else viaExec.push(mount);
1438
1449
  }
1439
1450
  if (viaFileApi.length > 0) {
@@ -1443,6 +1454,13 @@ async function writeProfileFilesToBox(box, files, options = {}) {
1443
1454
  return fail(new Error("writeProfileFilesToBox: file-API batch write failed", { cause: err }));
1444
1455
  }
1445
1456
  }
1457
+ for (const upload of viaUpload) {
1458
+ try {
1459
+ await uploadData.call(box.fs, upload.path, upload.content, upload.mode !== void 0 ? { mode: upload.mode } : void 0);
1460
+ } catch (err) {
1461
+ return fail(new Error(`writeProfileFilesToBox: chunked upload failed for ${upload.path}`, { cause: err }));
1462
+ }
1463
+ }
1446
1464
  let execStarted = false;
1447
1465
  const paceAndRetry = async (run, path) => {
1448
1466
  for (let attempt = 0; ; attempt++) {
@@ -2869,4 +2887,4 @@ export {
2869
2887
  isTerminalPromptEvent,
2870
2888
  detectInteractiveQuestion
2871
2889
  };
2872
- //# sourceMappingURL=chunk-73WE4UQG.js.map
2890
+ //# sourceMappingURL=chunk-Q3XW5YKR.js.map