tensorlake 0.5.4 → 0.5.6
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/bin/darwin-arm64/tensorlake +0 -0
- package/dist/bin/darwin-arm64/tl +0 -0
- package/dist/bin/linux-x64/tensorlake +0 -0
- package/dist/bin/linux-x64/tl +0 -0
- package/dist/bin/win32-x64/tensorlake.exe +0 -0
- package/dist/bin/win32-x64/tl.exe +0 -0
- package/dist/index.cjs +40 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +40 -2
- package/dist/index.js.map +1 -1
- package/dist/sandbox-image.cjs +40 -2
- package/dist/sandbox-image.cjs.map +1 -1
- package/dist/sandbox-image.js +40 -2
- package/dist/sandbox-image.js.map +1 -1
- package/package.json +1 -1
package/dist/sandbox-image.js
CHANGED
|
@@ -3593,15 +3593,53 @@ var init_sandbox = __esm({
|
|
|
3593
3593
|
}
|
|
3594
3594
|
/** Connect to a sandbox VNC session for programmatic desktop control. */
|
|
3595
3595
|
async connectDesktop(options) {
|
|
3596
|
+
const port = options?.port ?? 5901;
|
|
3597
|
+
const connectTimeout = options?.connectTimeout ?? 10;
|
|
3598
|
+
const startMs = Date.now();
|
|
3599
|
+
const deadlineMs = startMs + connectTimeout * 1e3;
|
|
3600
|
+
await this.waitForPortReady(port, deadlineMs);
|
|
3601
|
+
const remainingSecs = Math.max(0.1, (deadlineMs - Date.now()) / 1e3);
|
|
3596
3602
|
return Desktop.connect({
|
|
3597
3603
|
baseUrl: this.baseUrl,
|
|
3598
3604
|
wsHeaders: this.wsHeaders,
|
|
3599
|
-
port
|
|
3605
|
+
port,
|
|
3600
3606
|
password: options?.password,
|
|
3601
3607
|
shared: options?.shared,
|
|
3602
|
-
connectTimeout:
|
|
3608
|
+
connectTimeout: remainingSecs
|
|
3603
3609
|
});
|
|
3604
3610
|
}
|
|
3611
|
+
/**
|
|
3612
|
+
* Poll the in-sandbox daemon until `127.0.0.1:port` accepts a TCP connection.
|
|
3613
|
+
* Uses `bash`'s `/dev/tcp` builtin via `processes/run` — no extra deps in
|
|
3614
|
+
* the sandbox image. `bash` is present on every image we ship.
|
|
3615
|
+
*/
|
|
3616
|
+
async waitForPortReady(port, deadlineMs) {
|
|
3617
|
+
const probeIntervalMs = 250;
|
|
3618
|
+
const probeProcessTimeoutSecs = 2;
|
|
3619
|
+
let lastError;
|
|
3620
|
+
while (Date.now() < deadlineMs) {
|
|
3621
|
+
try {
|
|
3622
|
+
const result = await this.run("/bin/bash", {
|
|
3623
|
+
args: ["-c", `exec 3<>/dev/tcp/127.0.0.1/${port}`],
|
|
3624
|
+
timeout: probeProcessTimeoutSecs
|
|
3625
|
+
});
|
|
3626
|
+
if (result.exitCode === 0) {
|
|
3627
|
+
return;
|
|
3628
|
+
}
|
|
3629
|
+
} catch (error) {
|
|
3630
|
+
lastError = error;
|
|
3631
|
+
}
|
|
3632
|
+
const remainingMs = deadlineMs - Date.now();
|
|
3633
|
+
if (remainingMs <= 0) break;
|
|
3634
|
+
await new Promise(
|
|
3635
|
+
(resolve) => setTimeout(resolve, Math.min(probeIntervalMs, remainingMs))
|
|
3636
|
+
);
|
|
3637
|
+
}
|
|
3638
|
+
const detail = lastError instanceof Error ? `: ${lastError.message}` : "";
|
|
3639
|
+
throw new SandboxError(
|
|
3640
|
+
`port ${port} did not become reachable inside sandbox within the connect timeout${detail}`
|
|
3641
|
+
);
|
|
3642
|
+
}
|
|
3605
3643
|
ptyWsUrl(sessionId, token) {
|
|
3606
3644
|
let wsBase;
|
|
3607
3645
|
if (this.baseUrl.startsWith("https://")) {
|