mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-15 04:03:31 +00:00
chore: fix bad merge
This commit is contained in:
parent
e72eb9f611
commit
b9efe971ff
32 changed files with 3654 additions and 15543 deletions
|
|
@ -8,7 +8,8 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@sandbox-agent/example-shared": "workspace:*",
|
||||
"computesdk": "latest"
|
||||
"computesdk": "latest",
|
||||
"sandbox-agent": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "latest",
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ import {
|
|||
type ExplicitComputeConfig,
|
||||
type ProviderName,
|
||||
} from "computesdk";
|
||||
import { runPrompt, waitForHealth } from "@sandbox-agent/example-shared";
|
||||
import { SandboxAgent } from "sandbox-agent";
|
||||
import { detectAgent, buildInspectorUrl, waitForHealth } from "@sandbox-agent/example-shared";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { resolve } from "node:path";
|
||||
|
||||
|
|
@ -140,8 +141,15 @@ export async function runComputeSdkExample(): Promise<void> {
|
|||
process.once("SIGINT", handleExit);
|
||||
process.once("SIGTERM", handleExit);
|
||||
|
||||
await runPrompt(baseUrl);
|
||||
await cleanup();
|
||||
const client = await SandboxAgent.connect({ baseUrl });
|
||||
const session = await client.createSession({ agent: detectAgent(), sessionInit: { cwd: "/root", mcpServers: [] } });
|
||||
const sessionId = session.id;
|
||||
|
||||
console.log(` UI: ${buildInspectorUrl({ baseUrl, sessionId })}`);
|
||||
console.log(" Press Ctrl+C to stop.");
|
||||
|
||||
// Keep alive until SIGINT/SIGTERM triggers cleanup above
|
||||
await new Promise(() => {});
|
||||
}
|
||||
|
||||
const isDirectRun = Boolean(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { Daytona, Image } from "@daytonaio/sdk";
|
||||
import { SandboxAgent } from "sandbox-agent";
|
||||
import { detectAgent, buildInspectorUrl, generateSessionId, waitForHealth } from "@sandbox-agent/example-shared";
|
||||
import { detectAgent, buildInspectorUrl, waitForHealth } from "@sandbox-agent/example-shared";
|
||||
|
||||
const daytona = new Daytona();
|
||||
|
||||
|
|
@ -13,7 +13,7 @@ if (process.env.OPENAI_API_KEY)
|
|||
// Build a custom image with sandbox-agent pre-installed (slower first run, faster subsequent runs)
|
||||
const image = Image.base("ubuntu:22.04").runCommands(
|
||||
"apt-get update && apt-get install -y curl ca-certificates",
|
||||
"curl -fsSL https://releases.rivet.dev/sandbox-agent/latest/install.sh | sh",
|
||||
"curl -fsSL https://releases.rivet.dev/sandbox-agent/0.2.x/install.sh | sh",
|
||||
);
|
||||
|
||||
console.log("Creating Daytona sandbox (first run builds the base image and may take a few minutes, subsequent runs are fast)...");
|
||||
|
|
@ -29,8 +29,8 @@ console.log("Waiting for server...");
|
|||
await waitForHealth({ baseUrl });
|
||||
|
||||
const client = await SandboxAgent.connect({ baseUrl });
|
||||
const sessionId = generateSessionId();
|
||||
await client.createSession(sessionId, { agent: detectAgent() });
|
||||
const session = await client.createSession({ agent: detectAgent(), sessionInit: { cwd: "/root", mcpServers: [] } });
|
||||
const sessionId = session.id;
|
||||
|
||||
console.log(` UI: ${buildInspectorUrl({ baseUrl, sessionId })}`);
|
||||
console.log(" Press Ctrl+C to stop.");
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { Daytona } from "@daytonaio/sdk";
|
||||
import { SandboxAgent } from "sandbox-agent";
|
||||
import { detectAgent, buildInspectorUrl, generateSessionId, waitForHealth } from "@sandbox-agent/example-shared";
|
||||
import { detectAgent, buildInspectorUrl, waitForHealth } from "@sandbox-agent/example-shared";
|
||||
|
||||
const daytona = new Daytona();
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ const sandbox = await daytona.create({ envVars, autoStopInterval: 0 });
|
|||
// Install sandbox-agent and start server
|
||||
console.log("Installing sandbox-agent...");
|
||||
await sandbox.process.executeCommand(
|
||||
"curl -fsSL https://releases.rivet.dev/sandbox-agent/latest/install.sh | sh",
|
||||
"curl -fsSL https://releases.rivet.dev/sandbox-agent/0.2.x/install.sh | sh",
|
||||
);
|
||||
|
||||
await sandbox.process.executeCommand(
|
||||
|
|
@ -30,8 +30,8 @@ console.log("Waiting for server...");
|
|||
await waitForHealth({ baseUrl });
|
||||
|
||||
const client = await SandboxAgent.connect({ baseUrl });
|
||||
const sessionId = generateSessionId();
|
||||
await client.createSession(sessionId, { agent: detectAgent() });
|
||||
const session = await client.createSession({ agent: detectAgent(), sessionInit: { cwd: "/root", mcpServers: [] } });
|
||||
const sessionId = session.id;
|
||||
|
||||
console.log(` UI: ${buildInspectorUrl({ baseUrl, sessionId })}`);
|
||||
console.log(" Press Ctrl+C to stop.");
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import Docker from "dockerode";
|
||||
import { SandboxAgent } from "sandbox-agent";
|
||||
import { detectAgent, buildInspectorUrl, generateSessionId, waitForHealth } from "@sandbox-agent/example-shared";
|
||||
import { detectAgent, buildInspectorUrl, waitForHealth } from "@sandbox-agent/example-shared";
|
||||
|
||||
const IMAGE = "alpine:latest";
|
||||
const PORT = 3000;
|
||||
|
|
@ -25,7 +25,7 @@ const container = await docker.createContainer({
|
|||
Image: IMAGE,
|
||||
Cmd: ["sh", "-c", [
|
||||
"apk add --no-cache curl ca-certificates libstdc++ libgcc bash",
|
||||
"curl -fsSL https://releases.rivet.dev/sandbox-agent/latest/install.sh | sh",
|
||||
"curl -fsSL https://releases.rivet.dev/sandbox-agent/0.2.x/install.sh | sh",
|
||||
"sandbox-agent install-agent claude",
|
||||
"sandbox-agent install-agent codex",
|
||||
`sandbox-agent server --no-token --host 0.0.0.0 --port ${PORT}`,
|
||||
|
|
@ -46,8 +46,8 @@ const baseUrl = `http://127.0.0.1:${PORT}`;
|
|||
await waitForHealth({ baseUrl });
|
||||
|
||||
const client = await SandboxAgent.connect({ baseUrl });
|
||||
const sessionId = generateSessionId();
|
||||
await client.createSession(sessionId, { agent: detectAgent() });
|
||||
const session = await client.createSession({ agent: detectAgent(), sessionInit: { cwd: "/root", mcpServers: [] } });
|
||||
const sessionId = session.id;
|
||||
|
||||
console.log(` UI: ${buildInspectorUrl({ baseUrl, sessionId })}`);
|
||||
console.log(" Press Ctrl+C to stop.");
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { Sandbox } from "@e2b/code-interpreter";
|
||||
import { SandboxAgent } from "sandbox-agent";
|
||||
import { detectAgent, buildInspectorUrl, generateSessionId, waitForHealth } from "@sandbox-agent/example-shared";
|
||||
import { detectAgent, buildInspectorUrl, waitForHealth } from "@sandbox-agent/example-shared";
|
||||
|
||||
const envs: Record<string, string> = {};
|
||||
if (process.env.ANTHROPIC_API_KEY) envs.ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY;
|
||||
|
|
@ -16,7 +16,7 @@ const run = async (cmd: string) => {
|
|||
};
|
||||
|
||||
console.log("Installing sandbox-agent...");
|
||||
await run("curl -fsSL https://releases.rivet.dev/sandbox-agent/latest/install.sh | sh");
|
||||
await run("curl -fsSL https://releases.rivet.dev/sandbox-agent/0.2.x/install.sh | sh");
|
||||
|
||||
console.log("Installing agents...");
|
||||
await run("sandbox-agent install-agent claude");
|
||||
|
|
@ -31,8 +31,8 @@ console.log("Waiting for server...");
|
|||
await waitForHealth({ baseUrl });
|
||||
|
||||
const client = await SandboxAgent.connect({ baseUrl });
|
||||
const sessionId = generateSessionId();
|
||||
await client.createSession(sessionId, { agent: detectAgent() });
|
||||
const session = await client.createSession({ agent: detectAgent(), sessionInit: { cwd: "/root", mcpServers: [] } });
|
||||
const sessionId = session.id;
|
||||
|
||||
console.log(` UI: ${buildInspectorUrl({ baseUrl, sessionId })}`);
|
||||
console.log(" Press Ctrl+C to stop.");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { SandboxAgent } from "sandbox-agent";
|
||||
import { detectAgent, buildInspectorUrl, generateSessionId } from "@sandbox-agent/example-shared";
|
||||
import { detectAgent, buildInspectorUrl } from "@sandbox-agent/example-shared";
|
||||
import { startDockerSandbox } from "@sandbox-agent/example-shared/docker";
|
||||
import * as tar from "tar";
|
||||
import fs from "node:fs";
|
||||
|
|
@ -47,8 +47,8 @@ const readmeText = new TextDecoder().decode(readmeBytes);
|
|||
console.log(` README.md content: ${readmeText.trim()}`);
|
||||
|
||||
console.log("Creating session...");
|
||||
const sessionId = generateSessionId();
|
||||
await client.createSession(sessionId, { agent: detectAgent() });
|
||||
const session = await client.createSession({ agent: detectAgent(), sessionInit: { cwd: "/opt/my-project", mcpServers: [] } });
|
||||
const sessionId = session.id;
|
||||
console.log(` UI: ${buildInspectorUrl({ baseUrl, sessionId })}`);
|
||||
console.log(' Try: "read the README in /opt/my-project"');
|
||||
console.log(" Press Ctrl+C to stop.");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { SandboxAgent } from "sandbox-agent";
|
||||
import { detectAgent, buildInspectorUrl, generateSessionId } from "@sandbox-agent/example-shared";
|
||||
import { detectAgent, buildInspectorUrl } from "@sandbox-agent/example-shared";
|
||||
import { startDockerSandbox } from "@sandbox-agent/example-shared/docker";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
|
@ -36,15 +36,17 @@ const skillResult = await client.writeFsFile(
|
|||
);
|
||||
console.log(` Skill: ${skillResult.path} (${skillResult.bytesWritten} bytes)`);
|
||||
|
||||
// Create a session with the uploaded skill as a local source.
|
||||
// Configure the uploaded skill.
|
||||
console.log("Configuring custom skill...");
|
||||
await client.setSkillsConfig(
|
||||
{ directory: "/", skillName: "random-number" },
|
||||
{ sources: [{ type: "local", source: "/opt/skills/random-number" }] },
|
||||
);
|
||||
|
||||
// Create a session.
|
||||
console.log("Creating session with custom skill...");
|
||||
const sessionId = generateSessionId();
|
||||
await client.createSession(sessionId, {
|
||||
agent: detectAgent(),
|
||||
skills: {
|
||||
sources: [{ type: "local", source: "/opt/skills/random-number" }],
|
||||
},
|
||||
});
|
||||
const session = await client.createSession({ agent: detectAgent(), sessionInit: { cwd: "/root", mcpServers: [] } });
|
||||
const sessionId = session.id;
|
||||
console.log(` UI: ${buildInspectorUrl({ baseUrl, sessionId })}`);
|
||||
console.log(' Try: "generate a random number between 1 and 100"');
|
||||
console.log(" Press Ctrl+C to stop.");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { SandboxAgent } from "sandbox-agent";
|
||||
import { detectAgent, buildInspectorUrl, generateSessionId } from "@sandbox-agent/example-shared";
|
||||
import { detectAgent, buildInspectorUrl } from "@sandbox-agent/example-shared";
|
||||
import { startDockerSandbox } from "@sandbox-agent/example-shared/docker";
|
||||
|
||||
console.log("Starting sandbox...");
|
||||
|
|
@ -7,17 +7,16 @@ const { baseUrl, cleanup } = await startDockerSandbox({
|
|||
port: 3001,
|
||||
});
|
||||
|
||||
console.log("Creating session with skill source...");
|
||||
console.log("Configuring skill source...");
|
||||
const client = await SandboxAgent.connect({ baseUrl });
|
||||
const sessionId = generateSessionId();
|
||||
await client.createSession(sessionId, {
|
||||
agent: detectAgent(),
|
||||
skills: {
|
||||
sources: [
|
||||
{ type: "github", source: "rivet-dev/skills", skills: ["sandbox-agent"] },
|
||||
],
|
||||
},
|
||||
});
|
||||
await client.setSkillsConfig(
|
||||
{ directory: "/", skillName: "rivet-dev-skills" },
|
||||
{ sources: [{ type: "github", source: "rivet-dev/skills", skills: ["sandbox-agent"] }] },
|
||||
);
|
||||
|
||||
console.log("Creating session...");
|
||||
const session = await client.createSession({ agent: detectAgent(), sessionInit: { cwd: "/root", mcpServers: [] } });
|
||||
const sessionId = session.id;
|
||||
console.log(` UI: ${buildInspectorUrl({ baseUrl, sessionId })}`);
|
||||
console.log(' Try: "How do I start sandbox-agent?"');
|
||||
console.log(" Press Ctrl+C to stop.");
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { Sandbox } from "@vercel/sandbox";
|
||||
import { SandboxAgent } from "sandbox-agent";
|
||||
import { detectAgent, buildInspectorUrl, generateSessionId, waitForHealth } from "@sandbox-agent/example-shared";
|
||||
import { detectAgent, buildInspectorUrl, waitForHealth } from "@sandbox-agent/example-shared";
|
||||
|
||||
const envs: Record<string, string> = {};
|
||||
if (process.env.ANTHROPIC_API_KEY) envs.ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY;
|
||||
|
|
@ -22,7 +22,7 @@ const run = async (cmd: string, args: string[] = []) => {
|
|||
};
|
||||
|
||||
console.log("Installing sandbox-agent...");
|
||||
await run("sh", ["-c", "curl -fsSL https://releases.rivet.dev/sandbox-agent/latest/install.sh | sh"]);
|
||||
await run("sh", ["-c", "curl -fsSL https://releases.rivet.dev/sandbox-agent/0.2.x/install.sh | sh"]);
|
||||
|
||||
console.log("Installing agents...");
|
||||
await run("sandbox-agent", ["install-agent", "claude"]);
|
||||
|
|
@ -42,8 +42,8 @@ console.log("Waiting for server...");
|
|||
await waitForHealth({ baseUrl });
|
||||
|
||||
const client = await SandboxAgent.connect({ baseUrl });
|
||||
const sessionId = generateSessionId();
|
||||
await client.createSession(sessionId, { agent: detectAgent() });
|
||||
const session = await client.createSession({ agent: detectAgent(), sessionInit: { cwd: "/root", mcpServers: [] } });
|
||||
const sessionId = session.id;
|
||||
|
||||
console.log(` UI: ${buildInspectorUrl({ baseUrl, sessionId })}`);
|
||||
console.log(" Press Ctrl+C to stop.");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue