@computesdk/sandbox0 1.0.21 → 1.0.23

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/index.mjs CHANGED
@@ -22525,10 +22525,11 @@ function normalizeMemory(value) {
22525
22525
  }
22526
22526
  function buildClaimOptions(config, options) {
22527
22527
  const providerOptions = options;
22528
- const ttl = optionalPositiveSeconds("ttl", providerOptions?.ttl ?? config.ttl);
22528
+ const timeoutSeconds = typeof options?.timeout === "number" && Number.isFinite(options.timeout) && options.timeout > 0 ? Math.ceil(options.timeout / 1e3) : void 0;
22529
+ const ttl = optionalPositiveSeconds("ttl", providerOptions?.ttl ?? timeoutSeconds ?? config.ttl);
22529
22530
  const hardTtl = optionalPositiveSeconds(
22530
22531
  "hardTtl",
22531
- providerOptions?.hardTtl ?? config.hardTtl
22532
+ providerOptions?.hardTtl ?? timeoutSeconds ?? config.hardTtl
22532
22533
  );
22533
22534
  const autoResume = providerOptions?.autoResume;
22534
22535
  if (autoResume !== void 0 && typeof autoResume !== "boolean") {
@@ -22856,17 +22857,44 @@ var _provider = defineProvider({
22856
22857
  const second = await readViaCommand(`cat ${path}`);
22857
22858
  return Buffer.byteLength(second) >= Buffer.byteLength(first) ? second : first;
22858
22859
  };
22860
+ const readDirect = async () => {
22861
+ const decoder = new TextDecoder();
22862
+ const read = (suffix) => sandbox.readFile(`${base}.${suffix}`);
22863
+ try {
22864
+ const [out, err, outLen, errLen, code] = await withinCommandDeadline(
22865
+ Promise.all([read("out"), read("err"), read("outlen"), read("errlen"), read("code")]),
22866
+ deadline,
22867
+ timeout
22868
+ );
22869
+ const expected = (bytes) => Number.parseInt(decoder.decode(bytes).trim(), 10);
22870
+ if (out.byteLength !== expected(outLen) || err.byteLength !== expected(errLen)) {
22871
+ return void 0;
22872
+ }
22873
+ return [decoder.decode(out), decoder.decode(err), decoder.decode(code)];
22874
+ } catch (error) {
22875
+ if (error instanceof Sandbox0CommandTimeoutError) throw error;
22876
+ return void 0;
22877
+ }
22878
+ };
22859
22879
  let stdout;
22860
22880
  let stderr;
22861
22881
  let codeText;
22862
- try {
22863
- stdout = await readVerified(`${base}.out`, `${base}.outlen`);
22864
- stderr = await readVerified(`${base}.err`, `${base}.errlen`);
22865
- codeText = await readViaCommand(`cat ${base}.code 2>/dev/null`).catch(() => "");
22866
- } finally {
22867
- await readViaCommand(
22882
+ const direct = await readDirect();
22883
+ if (direct) {
22884
+ [stdout, stderr, codeText] = direct;
22885
+ void readViaCommand(
22868
22886
  `rm -f ${base}.out ${base}.err ${base}.outlen ${base}.errlen ${base}.code`
22869
22887
  ).catch(() => void 0);
22888
+ } else {
22889
+ try {
22890
+ stdout = await readVerified(`${base}.out`, `${base}.outlen`);
22891
+ stderr = await readVerified(`${base}.err`, `${base}.errlen`);
22892
+ codeText = await readViaCommand(`cat ${base}.code 2>/dev/null`).catch(() => "");
22893
+ } finally {
22894
+ await readViaCommand(
22895
+ `rm -f ${base}.out ${base}.err ${base}.outlen ${base}.errlen ${base}.code`
22896
+ ).catch(() => void 0);
22897
+ }
22870
22898
  }
22871
22899
  const fileExit = Number.parseInt(codeText.trim(), 10);
22872
22900
  return {