mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-17 22:02:51 +00:00
Default connect to waiting for health
This commit is contained in:
parent
b860767d3f
commit
ebf450bd99
9 changed files with 10 additions and 10 deletions
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue