Default connect to waiting for health

This commit is contained in:
Nathan Flurry 2026-03-05 19:01:14 -08:00
parent b860767d3f
commit ebf450bd99
9 changed files with 10 additions and 10 deletions

View file

@ -27,7 +27,7 @@ if (result.exitCode !== 0) throw new Error(`Failed to start server: ${result.std
const baseUrl = "http://localhost:3000"; const baseUrl = "http://localhost:3000";
console.log("Connecting to server..."); console.log("Connecting to server...");
const client = await SandboxAgent.connect({ baseUrl, waitForHealth: { timeoutMs: 120_000 } }); const client = await SandboxAgent.connect({ baseUrl });
const session = await client.createSession({ agent: detectAgent(), sessionInit: { cwd: "/root", mcpServers: [] } }); const session = await client.createSession({ agent: detectAgent(), sessionInit: { cwd: "/root", mcpServers: [] } });
const sessionId = session.id; const sessionId = session.id;

View file

@ -138,7 +138,7 @@ export async function runComputeSdkExample(): Promise<void> {
process.once("SIGINT", handleExit); process.once("SIGINT", handleExit);
process.once("SIGTERM", handleExit); process.once("SIGTERM", handleExit);
const client = await SandboxAgent.connect({ baseUrl, waitForHealth: { timeoutMs: 120_000 } }); const client = await SandboxAgent.connect({ baseUrl });
const session = await client.createSession({ agent: detectAgent(), sessionInit: { cwd: "/home", mcpServers: [] } }); const session = await client.createSession({ agent: detectAgent(), sessionInit: { cwd: "/home", mcpServers: [] } });
const sessionId = session.id; const sessionId = session.id;

View file

@ -26,7 +26,7 @@ await sandbox.process.executeCommand(
const baseUrl = (await sandbox.getSignedPreviewUrl(3000, 4 * 60 * 60)).url; const baseUrl = (await sandbox.getSignedPreviewUrl(3000, 4 * 60 * 60)).url;
console.log("Connecting to server..."); console.log("Connecting to server...");
const client = await SandboxAgent.connect({ baseUrl, waitForHealth: { timeoutMs: 120_000 } }); const client = await SandboxAgent.connect({ baseUrl });
const session = await client.createSession({ agent: detectAgent(), sessionInit: { cwd: "/home/daytona", mcpServers: [] } }); const session = await client.createSession({ agent: detectAgent(), sessionInit: { cwd: "/home/daytona", mcpServers: [] } });
const sessionId = session.id; const sessionId = session.id;

View file

@ -31,7 +31,7 @@ await sandbox.process.executeCommand(
const baseUrl = (await sandbox.getSignedPreviewUrl(3000, 4 * 60 * 60)).url; const baseUrl = (await sandbox.getSignedPreviewUrl(3000, 4 * 60 * 60)).url;
console.log("Connecting to server..."); console.log("Connecting to server...");
const client = await SandboxAgent.connect({ baseUrl, waitForHealth: { timeoutMs: 120_000 } }); const client = await SandboxAgent.connect({ baseUrl });
const session = await client.createSession({ agent: detectAgent(), sessionInit: { cwd: "/home/daytona", mcpServers: [] } }); const session = await client.createSession({ agent: detectAgent(), sessionInit: { cwd: "/home/daytona", mcpServers: [] } });
const sessionId = session.id; const sessionId = session.id;

View file

@ -44,7 +44,7 @@ await container.start();
const baseUrl = `http://127.0.0.1:${PORT}`; const baseUrl = `http://127.0.0.1:${PORT}`;
const client = await SandboxAgent.connect({ baseUrl, waitForHealth: { timeoutMs: 120_000 } }); const client = await SandboxAgent.connect({ baseUrl });
const session = await client.createSession({ agent: detectAgent(), sessionInit: { cwd: "/root", mcpServers: [] } }); const session = await client.createSession({ agent: detectAgent(), sessionInit: { cwd: "/root", mcpServers: [] } });
const sessionId = session.id; const sessionId = session.id;

View file

@ -28,7 +28,7 @@ await sandbox.commands.run("sandbox-agent server --no-token --host 0.0.0.0 --por
const baseUrl = `https://${sandbox.getHost(3000)}`; const baseUrl = `https://${sandbox.getHost(3000)}`;
console.log("Connecting to server..."); console.log("Connecting to server...");
const client = await SandboxAgent.connect({ baseUrl, waitForHealth: { timeoutMs: 120_000 } }); const client = await SandboxAgent.connect({ baseUrl });
const session = await client.createSession({ agent: detectAgent(), sessionInit: { cwd: "/home/user", mcpServers: [] } }); const session = await client.createSession({ agent: detectAgent(), sessionInit: { cwd: "/home/user", mcpServers: [] } });
const sessionId = session.id; const sessionId = session.id;

View file

@ -39,7 +39,7 @@ await sandbox.runCommand({
const baseUrl = sandbox.domain(3000); const baseUrl = sandbox.domain(3000);
console.log("Connecting to server..."); console.log("Connecting to server...");
const client = await SandboxAgent.connect({ baseUrl, waitForHealth: { timeoutMs: 120_000 } }); const client = await SandboxAgent.connect({ baseUrl });
const session = await client.createSession({ agent: detectAgent(), sessionInit: { cwd: "/home/vercel-sandbox", mcpServers: [] } }); const session = await client.createSession({ agent: detectAgent(), sessionInit: { cwd: "/home/vercel-sandbox", mcpServers: [] } });
const sessionId = session.id; const sessionId = session.id;

View file

@ -510,6 +510,7 @@ export class SandboxAgent {
token: handle.token, token: handle.token,
fetch: options.fetch, fetch: options.fetch,
headers: options.headers, headers: options.headers,
waitForHealth: false,
persist: options.persist, persist: options.persist,
replayMaxEvents: options.replayMaxEvents, replayMaxEvents: options.replayMaxEvents,
replayMaxChars: options.replayMaxChars, replayMaxChars: options.replayMaxChars,
@ -1297,11 +1298,11 @@ function normalizePositiveInt(value: number | undefined, fallback: number): numb
function normalizeHealthWaitOptions( function normalizeHealthWaitOptions(
value: boolean | SandboxAgentHealthWaitOptions | undefined, value: boolean | SandboxAgentHealthWaitOptions | undefined,
): NormalizedHealthWaitOptions { ): NormalizedHealthWaitOptions {
if (!value) { if (value === false) {
return { enabled: false }; return { enabled: false };
} }
if (value === true) { if (value === true || value === undefined) {
return { enabled: true }; return { enabled: true };
} }

View file

@ -204,7 +204,6 @@ describe("Integration: TypeScript SDK flat session API", () => {
const sdk = await SandboxAgent.connect({ const sdk = await SandboxAgent.connect({
token, token,
fetch: customFetch, fetch: customFetch,
waitForHealth: true,
}); });
const agents = await sdk.listAgents(); const agents = await sdk.listAgents();