@computesdk/sandbox0 1.0.20 → 1.0.22
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.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +33 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -23,6 +23,8 @@ interface Sandbox0Config {
|
|
|
23
23
|
/** Default command timeout in milliseconds. */
|
|
24
24
|
commandTimeout?: number;
|
|
25
25
|
}
|
|
26
|
-
declare const sandbox0: (config?: Sandbox0Config) => _computesdk_provider.Provider<Sandbox, any, any, computesdk.Volume
|
|
26
|
+
declare const sandbox0: (config?: Sandbox0Config) => _computesdk_provider.Provider<Sandbox, any, any, computesdk.Volume> & {
|
|
27
|
+
readonly sizes: computesdk.InstanceSizeManager;
|
|
28
|
+
};
|
|
27
29
|
|
|
28
30
|
export { type Sandbox0Config, sandbox0 };
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ interface Sandbox0Config {
|
|
|
23
23
|
/** Default command timeout in milliseconds. */
|
|
24
24
|
commandTimeout?: number;
|
|
25
25
|
}
|
|
26
|
-
declare const sandbox0: (config?: Sandbox0Config) => _computesdk_provider.Provider<Sandbox, any, any, computesdk.Volume
|
|
26
|
+
declare const sandbox0: (config?: Sandbox0Config) => _computesdk_provider.Provider<Sandbox, any, any, computesdk.Volume> & {
|
|
27
|
+
readonly sizes: computesdk.InstanceSizeManager;
|
|
28
|
+
};
|
|
27
29
|
|
|
28
30
|
export { type Sandbox0Config, sandbox0 };
|
package/dist/index.js
CHANGED
|
@@ -22874,17 +22874,44 @@ var _provider = (0, import_provider.defineProvider)({
|
|
|
22874
22874
|
const second = await readViaCommand(`cat ${path}`);
|
|
22875
22875
|
return Buffer.byteLength(second) >= Buffer.byteLength(first) ? second : first;
|
|
22876
22876
|
};
|
|
22877
|
+
const readDirect = async () => {
|
|
22878
|
+
const decoder = new TextDecoder();
|
|
22879
|
+
const read = (suffix) => sandbox.readFile(`${base}.${suffix}`);
|
|
22880
|
+
try {
|
|
22881
|
+
const [out, err, outLen, errLen, code] = await withinCommandDeadline(
|
|
22882
|
+
Promise.all([read("out"), read("err"), read("outlen"), read("errlen"), read("code")]),
|
|
22883
|
+
deadline,
|
|
22884
|
+
timeout
|
|
22885
|
+
);
|
|
22886
|
+
const expected = (bytes) => Number.parseInt(decoder.decode(bytes).trim(), 10);
|
|
22887
|
+
if (out.byteLength !== expected(outLen) || err.byteLength !== expected(errLen)) {
|
|
22888
|
+
return void 0;
|
|
22889
|
+
}
|
|
22890
|
+
return [decoder.decode(out), decoder.decode(err), decoder.decode(code)];
|
|
22891
|
+
} catch (error) {
|
|
22892
|
+
if (error instanceof Sandbox0CommandTimeoutError) throw error;
|
|
22893
|
+
return void 0;
|
|
22894
|
+
}
|
|
22895
|
+
};
|
|
22877
22896
|
let stdout;
|
|
22878
22897
|
let stderr;
|
|
22879
22898
|
let codeText;
|
|
22880
|
-
|
|
22881
|
-
|
|
22882
|
-
stderr =
|
|
22883
|
-
|
|
22884
|
-
} finally {
|
|
22885
|
-
await readViaCommand(
|
|
22899
|
+
const direct = await readDirect();
|
|
22900
|
+
if (direct) {
|
|
22901
|
+
[stdout, stderr, codeText] = direct;
|
|
22902
|
+
void readViaCommand(
|
|
22886
22903
|
`rm -f ${base}.out ${base}.err ${base}.outlen ${base}.errlen ${base}.code`
|
|
22887
22904
|
).catch(() => void 0);
|
|
22905
|
+
} else {
|
|
22906
|
+
try {
|
|
22907
|
+
stdout = await readVerified(`${base}.out`, `${base}.outlen`);
|
|
22908
|
+
stderr = await readVerified(`${base}.err`, `${base}.errlen`);
|
|
22909
|
+
codeText = await readViaCommand(`cat ${base}.code 2>/dev/null`).catch(() => "");
|
|
22910
|
+
} finally {
|
|
22911
|
+
await readViaCommand(
|
|
22912
|
+
`rm -f ${base}.out ${base}.err ${base}.outlen ${base}.errlen ${base}.code`
|
|
22913
|
+
).catch(() => void 0);
|
|
22914
|
+
}
|
|
22888
22915
|
}
|
|
22889
22916
|
const fileExit = Number.parseInt(codeText.trim(), 10);
|
|
22890
22917
|
return {
|